query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
sequencelengths
0
101
negative_scores
sequencelengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Enable SQL logging. You can call this method within a block where SQL logging was disabled to renable it.
def enable_sql_logging(&block) sql_logging(enabled: true, &block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def log_sql\n @opts[:log_sql]\n end", "def log_sql(log_sql = true)\n if log_sql\n Sierra::DB.db.loggers << Sierra::Logging.logger\n else\n Sierra::DB.db.loggers.delete(Sierra::Logging.logger)\n end\n end", "def disable_sql_logging(&block)\n sql_logging(enabled: false, &block)\n end", "def enable_activerecord_sql_logging\n ActiveRecord::Base.logger.level = 0\nend", "def log_connection_yield(sql, conn, args=nil)\n if !@loggers.empty? && (external_caller = external_caller_for_log)\n sql = \"#{external_caller} #{sql}\"\n end\n super\n end", "def enable_logging\n initialize_logger\n end", "def set_logging_statement(opts)\n opts = check_params(opts,[:statement])\n super(opts)\n end", "def enable_logging(opts); end", "def disable_activerecord_sql_logging\n ActiveRecord::Base.logger.level = 1\nend", "def enable_enhanced_logging=(enable)\n self.enable_debug_logging = enable\n self.aces_level = (enable ? 'full' : 'none')\n end", "def sql(event)\n payload = crypt_keeper_payload_parse(event.payload[:sql])\n event.payload[:sql] = crypt_keeper_filter_postgres_log(payload)\n super(event)\n end", "def disable_sql_recording\n record_api_supportability_metric(:disable_sql_recording)\n\n return yield unless agent\n\n state = agent.set_record_sql(false)\n begin\n yield\n ensure\n agent.set_record_sql(state)\n end\n end", "def set_record_sql(should_record) # THREAD_LOCAL_ACCESS\n state = Tracer.state\n prev = state.record_sql\n state.record_sql = should_record\n prev.nil? || prev\n end", "def notice_sql(sql)\n return unless txn = NewRelic::Agent::Tracer.current_transaction\n\n current_segment = txn.current_segment\n return unless current_segment.is_a?(NewRelic::Agent::Transaction::DatastoreSegment)\n\n if current_segment.sql_statement\n current_segment.sql_statement.append_sql(sql)\n else\n current_segment._notice_sql(sql, self.opts, explainer_for(sql))\n end\n end", "def enable_logging(communicator_logger)\n @session.connection.enable_logging(communicator_logger)\n end", "def notice_sql(sql, config, duration, &explainer)\n if NewRelic::Agent.is_sql_recorded?\n statement = build_database_statement(sql, config, explainer)\n notice_extra_data(statement, duration, :sql)\n end\n end", "def log_sql(query, params = {})\n if @debug\n message = \"#{colorize(\"[#{@name}]\", :cyan)} #{query.gsub(/\\s+/, \" \").strip}\"\n message = \"#{message} #{params.inspect}\" if params.any?\n log message\n end\n end", "def logging_enabled=(value)\n @@logging_enabled = value\n end", "def log_query(sql)\n pad = ' '\n puts Paint[pad + sql, :cyan, :bold]\n # @loggers[0]&.debug(' ' + sql)\n end", "def autoflush_log; end", "def autoflush_log; end", "def setup_connection(conn)\n conn = super(conn)\n statement(conn) do |stmt|\n connection_configuration_sqls.each{|sql| log_yield(sql){stmt.execute(sql)}}\n end\n conn\n end", "def set_enable(opts = {})\n cmd = command_builder('logging on', opts)\n configure cmd\n end", "def sql_text_log\n @sql_text_log ||= ''\n end", "def before_query(query)\n Rails.logger.info(\"[QUERY BEGIN] >>> #{Time.now.to_i}\")\n end", "def trace_log!\n Merb.logger.auto_flush = true\n end", "def enable_binary_logging\n raise \"DB#enable_binary_logging is no longer supported, please use DB#restart_mysql() instead\"\n end", "def log_connection_execute(conn, sql)\n conn.execute(sql)\n end", "def log_connection_execute(conn, sql)\n conn.execute(sql)\n end", "def setup_connection(conn)\n conn = super(conn)\n statement(conn) do |stmt|\n connection_pragmas.each{|s| log_connection_yield(s, conn){stmt.execute(s)}}\n end\n conn\n end", "def enable_logging_for(name = nil, options = {})\n name = bucket_name(name)\n default_options = {'target_bucket' => name, 'target_prefix' => 'log-'}\n options = default_options.merge(options)\n grant_logging_access_to_target_bucket(options['target_bucket'])\n logging_status(name, Status.new(options))\n end", "def enable_debug_logging=(enable)\n return if enable.nil?\n logging = REXML::XPath.first(@xml, 'ScanTemplate/Logging')\n if logging.nil?\n logging = REXML::Element.new('Logging')\n @xml.add_element(logging)\n end\n debug_logging = REXML::XPath.first(logging, 'debugLogging')\n if debug_logging.nil?\n debug_logging = REXML::Element.new('debugLogging')\n logging.add_element(debug_logging)\n end\n debug_logging.attributes['enabled'] = (enable ? 1 : 0)\n end", "def setup_database_logger\n ActiveRecord::Base.logger = PuppetHerald.logger\n nil\n end", "def log_set (level)\n execute(:log_set, level)\n end", "def logging=(value)\n @logging = value ? true : false\n end", "def execute(sql, name = nil, binds = []) #:nodoc:\r\n if name == :skip_logging\r\n query(sql, binds)\r\n else\r\n log(sql, name, binds) { query(sql, binds) }\r\n end\r\n end", "def sparkEnableLog(logTarget, logType, syncLog = false)\n logNormal($sparkPrefix + \" sparkEnableLog logTarget=\"+logTarget+\" logType=\"+logType+\" syncLog=\"+syncLog.to_s+\"\\n\")\n\n logServer = get($serverPath+'log')\n if (logServer != nil)\n logServer.addStream(logTarget, logType, syncLog)\n end\nend", "def exec_query(sql, name = 'SQL', binds = [])\n if name == :skip_logging\n #execute(sql, name)\n hash_query(sql, name, binds)\n else\n log(sql, name) do\n #execute(sql, name)\n hash_query(sql, name, binds)\n end\n end \n end", "def enable_logging(opts)\n opts[:AccessLog] = []\n level = WEBrick::Log.const_get(opts[:BridgetownOptions][\"verbose\"] ? :DEBUG : :WARN)\n opts[:Logger] = WEBrick::Log.new($stdout, level)\n end", "def enable_logging(logger = Logger.new(STDOUT), log_level: Logger::DEBUG)\n stack.after 'request.factory', 'request.logger', AsyncRequestLogger.new(logger, log_level: log_level)\n stack.before 'response.factory', 'response.logger', AsyncResponseLogger.new(logger, log_level: log_level)\n self\n end", "def instrument_sql(name, title = nil, body = nil, &block)\n instrument(name, title, body, Appsignal::EventFormatter::SQL_BODY_FORMAT, &block)\n end", "def delete_logging_statement\n super\n end", "def logger=(lggr)\n ActiveRecord::Base.logger = lggr\n end", "def initialize\n ActiveRecord::Base.logger = Logger.new(STDOUT)\n end", "def verbose_logging; end", "def reset_logging\n\t\tTreequel.reset_logger\n\tend", "def logging\n @@logging ||= lambda { |msg| puts(\"#{Time.now} :minion: #{msg}\") }\n end", "def log_with( &block )\n @logger = block\n end", "def debug!\n self.severity = :DEBUG\n end", "def autoflush_log=(_arg0); end", "def autoflush_log=(_arg0); end", "def sql sql\n @master.puts \"#{sql};\"\n end", "def log_level\n @log_level ||= :debug\n end", "def log_level\n @log_level ||= :debug\n end", "def do_execute(sql, name = 'SQL')\n log(sql, name) { raw_connection_do(sql) }\n end", "def enable_performance_cache_logging\n performance_cache_logger.level = Logger::DEBUG\n end", "def execute(sql, name = nil) #:nodoc:\n log(sql, name) { @connection.exec sql }\n end", "def enable_stdout\n stdoutoutputter = Log4r::Outputter[\"#{@name.to_s}-stdout\"]\n stdoutoutputter.level = Log4r::ALL\n end", "def enable_logging(communicator_logger)\n raise ArgumentError, 'communicator_logger is required' unless communicator_logger\n\n @communicator_logger = communicator_logger\n end", "def configure_logging\n Chef::Log.logger = AuditLogger.new(sensitive_inputs)\n Chef::Log.logger.level = Log.level_from_sym(Log.level)\n end", "def begin_transaction_sql\n SQL_BEGIN\n end", "def begin_transaction_sql\n SQL_BEGIN\n end", "def sql! sql=nil\n require 'niceql'\n puts Niceql::Prettifier.prettify_sql sql || $last_sql_command\n end", "def log(msg)\n puts(msg) if @info_values['enable_debug_logging'] == \"Yes\"\n end", "def configure_logging(loglevel=:debug)\n Kitchenplan::Log.init(Logger.new(STDOUT))\n Kitchenplan::Log.level = loglevel\n end", "def sql(query)\n event = ActiveSupport::Notifications::Event.new(:sql, 1, 1, 1, { sql: query })\n\n subscriber = TestDebugLogSubscriber.new\n subscriber.sql event\n subscriber.debugs\n end", "def logger ; @log end", "def log_state\n super\n end", "def check_sql_before_running; tarif_optimizator.check_sql_before_running; end", "def execute(sql, name = nil, skip_logging = false)\n translate(sql) do |sql, args|\n if (name == :skip_logging) or skip_logging\n @connection.execute(sql, *args)\n else\n log(sql, args, name) do\n @connection.execute(sql, *args)\n end\n end\n end\n end", "def on_request(env)\n env['sinatra.commonlogger'] = true\n super\n end", "def sql\n Slacker.sql(self)\n end", "def force_debug\n self.level = :debug\n @level_frozen = true\n end", "def disable_logging\n @session.connection.disable_logging\n end", "def execute(sql, name = nil) \n # Only skip select statements from logging \n unless /^(select|show|begin|commit)/i.match(sql.strip) \n\t\tFile.open( File.join(RAILS_ROOT, 'db', 'ddl.sql'),'a') {|f|\n\t\t\ttemp_sql = sql.gsub(\"\\n\",\"\") \n\t\t\ttemp_sql = temp_sql + ';' if adapter_name != 'IBM_DB2' or adapter_name != 'IBM_DB'\n\t\t\tf.puts temp_sql\n\t\t}\n end\n\t old_execute sql, name\n end", "def log_traffic=(enable)\n @log_traffic = enable\n logger.level = Logger::DEBUG if enable\n end", "def redirect_log(options={})\n ActiveRecord::Base.logger = Logger.new(options.fetch(:to, STDERR))\n ActiveRecord::Base.clear_active_connections!\n ActiveRecord::Base.colorize_logging = options.fetch(:colorize, true)\nend", "def log()\n @log\n end", "def log=(logger); end", "def log_to(stream, colorize=true)\n ActiveRecord::Base.logger = Logger.new(stream)\n ActiveRecord::Base.clear_active_connections!\n ActiveRecord::Base.colorize_logging = colorize\nend", "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 snapshots_redact_sql_queries; end", "def fire\n PassiveRecord::Adapter.execute to_sql\n end", "def with_logging level = Logger::DEBUG\n original_level = Accessibility.log.level\n Accessibility.log.level = level\n yield\n Accessibility.log.level = original_level\n end", "def begin_savepoint(conn, opts)\n super\n\n unless (read_only = opts[:read_only]).nil?\n log_connection_execute(conn, \"SET TRANSACTION READ #{read_only ? 'ONLY' : 'WRITE'}\")\n end\n end", "def enable_monitor_status_logging\n monitor_logger.level = Logger::DEBUG\n end", "def option_logging\n block = proc { |level| Logging::Logger.root.level = level; propagate_option('--logging', level) }\n @cl_parser.on('--logging LEVEL', 'Specify the minimum log level that should be logged.', &block)\n end", "def debug_sql\n if eager_loading?\n including = (@eager_load_values + @includes_values).uniq\n join_dependency = ActiveRecord::Associations::ClassMethods::JoinDependency.new(@klass, including, nil)\n construct_relation_for_association_find(join_dependency).to_sql\n else\n arel.to_sql\n end\n end", "def log_current_test_query\n qc_current_inspection = get_current_inspection_record( session[:user_id].id, session[:qc_inspection_type_code] )\n if qc_current_inspection.nil?\n ActiveRecord::Base.connection.execute(\"INSERT INTO qc_current_inspections\n (user_id, qc_inspection_type_code, qc_tests_query, tests_columns_list)\n VALUES(#{session[:user_id].id}, '#{session[:qc_inspection_type_code]}',\n '#{dm_session[:search_engine_query_definition].gsub(/'/, \"''\")}', '#{session[:columns_list].to_yaml}')\")\n else\n ActiveRecord::Base.connection.execute(ActiveRecord::Base.extend_update_sql_with_request(\"UPDATE qc_current_inspections\n SET qc_tests_query = '#{dm_session[:search_engine_query_definition].gsub(/'/, \"''\")}',\n tests_columns_list = '#{session[:columns_list].to_yaml}'\n WHERE user_id = #{session[:user_id].id} AND qc_inspection_type_code = '#{session[:qc_inspection_type_code]}' \"))\n end\n end", "def set_up_logging\n\n if @parameters[:log_to_file] then\n\n @logger = Logger.new(@parameters[:log_to_file])\n\n else\n\n @logger = Logger.new(STDOUT)\n\n end\n\n if @parameters[:log_detailed_messages] then\n \n @logger.sev_threshold = Logger::DEBUG\n\n else\n\n @logger.sev_threshold = Logger::INFO\n\n end\n\n end", "def log\n Engines.log\n end", "def log_level=(level); end", "def set_debug_level(val)\n super\n end" ]
[ "0.73297447", "0.7178721", "0.6995771", "0.6811558", "0.6701986", "0.6605298", "0.65847754", "0.6432213", "0.6359256", "0.6253259", "0.6249488", "0.6209547", "0.61505383", "0.6128812", "0.61093336", "0.60587066", "0.60376793", "0.5924147", "0.5919858", "0.5833025", "0.5833025", "0.5823672", "0.577659", "0.57623583", "0.5719309", "0.5712155", "0.5709082", "0.5636024", "0.559589", "0.5572815", "0.55436134", "0.55424047", "0.5534536", "0.55173415", "0.55154926", "0.5506343", "0.54941785", "0.5477981", "0.54604876", "0.5449059", "0.54481244", "0.5437614", "0.5435037", "0.54170144", "0.5415995", "0.541205", "0.5396409", "0.53934336", "0.5388505", "0.5377679", "0.5377679", "0.53401", "0.5295753", "0.5295753", "0.52861637", "0.5285143", "0.5282628", "0.5281692", "0.5270052", "0.5264588", "0.52490133", "0.52490133", "0.52151245", "0.520657", "0.52057683", "0.5202679", "0.51933664", "0.51910603", "0.51909214", "0.5181267", "0.5176287", "0.51745915", "0.51737183", "0.5170719", "0.51679736", "0.5164357", "0.51538527", "0.513394", "0.5123613", "0.5122591", "0.51195806", "0.51195806", "0.51195806", "0.51195806", "0.51195806", "0.51195806", "0.51195806", "0.51195806", "0.511957", "0.51147735", "0.51132387", "0.5108446", "0.51059556", "0.50998473", "0.50972587", "0.5084436", "0.5083551", "0.5081754", "0.50765973", "0.5071597" ]
0.88641167
0
Use a different database connection for the block. You can use this if your application has multiple databases to swap connections for the migration. You can pass in either a database connection or an ActiveRecord::Base class to use the connection used by that class. The label argument will be added to the logged SQL as a comment.
def using_connection(connection_or_class, label: nil, &block) if connection_or_class.is_a?(Class) && connection_or_class < ActiveRecord::Base label ||= connection_or_class.name connection_or_class.connection_pool.with_connection do |connection| switch_connection_in_block(connection, label: label, &block) end else switch_connection_in_block(connection_or_class, label: label, &block) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def use(name)\n with(database: name)\n end", "def use(name)\n with(database: name)\n end", "def current_database_name\n ActiveRecord::Base.connection_pool.spec.config[:name] || 'default'\n end", "def log_connection_yield(sql, conn, args=nil)\n if !@loggers.empty? && (external_caller = external_caller_for_log)\n sql = \"#{external_caller} #{sql}\"\n end\n super\n end", "def database(dbname=nil, &block)\n dbname ||= database_name\n if dbname then\n repository dbname, &block\n else\n yield\n end\n end", "def initialize(connection, database, logger = nil)\n super(connection, logger)\n context = connection.context\n context.init(logger)\n @limit = @offset = 0\n unless connection.sql_norow(\"USE #{database}\")\n raise \"Cannot USE #{database}\"\n end\n end", "def with_connection(&db_logic)\n begin\n ActiveRecord::Base.connection_pool\n rescue Exception => e\n ActiveRecord::Base.establish_connection(\n adapter: db_adapter,\n database: db_file\n )\n ActiveRecord::Base.logger = Logger.new(File.open(db_log_file, 'a'))\n end\n\n ActiveRecord::Base.connection_pool.with_connection(&db_logic)\n end", "def use_database(db)\n self.database = db\n end", "def with_connection(&block)\n base_model.connection_pool.with_connection(&block)\n end", "def database_name\n @opts[:database]\n end", "def database_name # :nodoc:\n return nil unless Module.constants.include? 'DataMapper' or Module.constants.include? :DataMapper\n raise \"No such database connection #{options[:database]}\" if options[:database] and DataMapper::Repository.adapters[options[:database]].nil?\n # Custom database connection specified\n return options[:database].to_sym if options[:database]\n # Leaf config name\n return leaf_name.to_sym if DataMapper::Repository.adapters[leaf_name.to_sym]\n # Leaf config name, underscored\n return leaf_name.methodize.to_sym if DataMapper::Repository.adapters[leaf_name.methodize.to_sym]\n # Leaf class name\n return self.class.to_s.to_sym if DataMapper::Repository.adapters[self.class.to_s.to_sym]\n # Leaf class name, underscored\n return self.class.to_s.methodize.to_sym if DataMapper::Repository.adapters[self.class.to_s.methodize.to_sym]\n # I give up\n return nil\n end", "def setup_connection(conn)\n conn = super(conn)\n statement(conn) do |stmt|\n connection_configuration_sqls.each{|sql| log_yield(sql){stmt.execute(sql)}}\n end\n conn\n end", "def use(args)\n @dbh.select_db(args[:db_name])\n end", "def connection_pool_name # :nodoc:\n replica = current_replica_name\n if replica\n \"#{name}_#{replica}\"\n elsif self == ActiveRecord::Base\n name\n else\n superclass.connection_pool_name\n end\n end", "def setup_connection(conn)\n conn = super(conn)\n statement(conn) do |stmt|\n connection_pragmas.each{|s| log_connection_yield(s, conn){stmt.execute(s)}}\n end\n conn\n end", "def database\n \"--db='#{ name }'\" if name\n end", "def database\n \"--db='#{ name }'\"\n end", "def select_db(db)\n query \"use #{db}\"\n self\n end", "def with_db(db_name)\n ensure_db(db_name) do\n old_db_name = @db_name\n @db_name = db_name\n @schema_graph = \"#{db_name}:schema\"\n if block_given?\n yield\n @db_name = old_db_name\n end\n end\n self\n end", "def connect_to_old_db\n ActiveRecord::Base.establish_connection(\n :adapter => \"postgresql\",\n :host => \"localhost\",\n :username => \"postgres\",\n :password => \"vegpuf\",\n :database => \"affluence_staging_25_june\"\n )\nend", "def database_name\n __evaluate__(storage_options[:database])\n end", "def database_name\n @dbi.db_name\n end", "def database_name\n @dbi.db_name\n end", "def database(database, &block)\n @databases << Backup::Database.const_get(\n last_constant(database)\n ).new(&block)\n end", "def connection\n self.server[self.database][self.layout]\n end", "def database_name\n \"mysql_inspector_test\"\n end", "def database_name\n @database_name\n end", "def select_db(name)\n #This is a stub, used for indexing\n end", "def database\n database_name ? connection.db(database_name) : nil\n end", "def initialize(opts = {}, &block)\n @opts = opts\n \n # Determine if the DB is single threaded or multi threaded\n @single_threaded = opts[:single_threaded] || @@single_threaded\n # Construct pool\n if @single_threaded\n @pool = SingleThreadedPool.new(&block)\n else\n @pool = ConnectionPool.new(opts[:max_connections] || 4, &block)\n end\n @pool.connection_proc = block || proc {connect}\n\n @logger = opts[:logger]\n ::Sequel::DATABASES.push(self)\n end", "def set_db_connection\n @db_connection = DbConnection.find(params[:db_connection_id])\n end", "def connect_to_target_db\n ActiveRecord::Base.establish_connection(Rails.env.to_sym)\n end", "def connect(opts)\n c = super\n connection_pragmas.each{|s| log_connection_yield(s, c){c.execute(s)}}\n c\n end", "def db_connection\n begin\n connection = PG.connect(dbname: \"brussels_sprouts_recipes\")\n yield(connection)\n ensure\n connection.close\n end\nend", "def db_connection\n begin\n connection = PG.connect(dbname: \"brussels_sprouts_recipes\")\n yield(connection)\n ensure\n connection.close\n end\nend", "def db_connection\n begin\n connection = PG.connect(dbname: \"brussels_sprouts_recipes\")\n yield(connection)\n ensure\n connection.close\n end\nend", "def db_connection\n begin\n connection = PG.connect(dbname: \"brussels_sprouts_recipes\")\n yield(connection)\n ensure\n connection.close\n end\nend", "def db_connection\n begin\n connection = PG.connect(dbname: \"brussels_sprouts_recipes\")\n yield(connection)\n ensure\n connection.close\n end\nend", "def db_connection\n begin\n connection = PG.connect(dbname: \"brussels_sprouts_recipes\")\n yield(connection)\n ensure\n connection.close\n end\nend", "def db_connection\n begin\n connection = PG.connect(dbname: \"brussels_sprouts_recipes\")\n yield(connection)\n ensure\n connection.close\n end\nend", "def with_two_connections\n run_without_connection do |original_connection|\n ActiveRecord::Base.establish_connection(original_connection.merge(pool_size: 2))\n begin\n ddl_connection = ActiveRecord::Base.connection_pool.checkout\n begin\n yield original_connection, ddl_connection\n ensure\n ActiveRecord::Base.connection_pool.checkin ddl_connection\n end\n ensure\n ActiveRecord::Base.connection_handler.clear_all_connections!(:all)\n end\n end\n end", "def set_database_name(name)\n @database_name = name\n end", "def with_target_connection\n config = get_test_config\n conn_hash = config.target.dup\n database = conn_hash.delete(:database)\n client = PG::Connection.new(host: conn_hash[:host], user: conn_hash[:username])\n begin\n yield client, database\n ensure\n client.close\n end\n end", "def default_database_name\n self.name.tableize\n end", "def db_connection\n begin\n connection = PG.connect(dbname: 'recipes')\n yield(connection)\n ensure\n connection.close\n end\nend", "def name\n @db_name\n end", "def conn\n unless @conn\n # open the database config file\n db_config = YAML.load(ERB.new(File.read(\"config/ourstage_database.yml\")).result )\n database = db_config[environment]['database']\n @conn = EventMachine::Postgres.new(:database => database)\n @conn.setnonblocking(true) # may not be needed? \n end\n @conn\n end", "def database_connection\n\t\t\tPG.connect(dbname: \"Kung_Fu\")\n\t\tend", "def database(name, database_id = nil, &block)\n @databases << get_class_from_scope(Database, name)\n .new(self, database_id, &block)\n end", "def database_name \n self.database.nil? ? 'Not Assigned' : self.database.name \n end", "def db name = nil, &block\n repository = name || scopes.size < 1 ? repositories[name ||= :default] : scopes.last\n repository or raise \"Unknown db '#{name}', did you forget to #setup ?\"\n\n if block_given?\n begin\n scopes.push(repository)\n block.call(repository)\n ensure\n scopes.pop\n end\n end\n repository\n end", "def use_connection(connection)\n @connection = connection\n @collection = (@connection[@dbname])\n end", "def current_connection_name_and_base_model\n minutes_since_epoch = Time.current.to_i / 60\n connections_with_name = Gitlab::Database.database_base_models.to_a # this will never be empty\n connections_with_name[minutes_since_epoch % connections_with_name.count]\n end", "def define\r\n\t\tdatabase_names.call().collect do |database_name|\r\n\t\t\tnamespace database_name do\r\n\t\t\t\ttasks[:names].collect do |task_name|\r\n\t\t\t\t\tdesc \"#{task_name.to_s.capitalize} the #{database_name} database\"\r\n\t\t\t\t\ttask task_name => tasks[:dependencies] do\r\n\t\t\t\t\t\ttasks[:action].call(task_name, database_name)\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\t\t\r\n\t\t\t\tadd_tasks_for(:import, import, database_name)\r\n\t\t\t\tadd_tasks_for(:export, export, database_name)\r\n\t\t\tend\r\n\t\tend\r\n\t\t\r\n\t\tself\r\n\tend", "def mongodb_connection(options={}, &block)\n return @mongodb_conncetion if @mongodb_connection and !block_given?\n options.stringify_keys!\n options['adapter'] ||= 'mongodb'\n @mongodb_connection = no_sql_connection(options, &block)\n end", "def instrument_sql(name, title = nil, body = nil, &block)\n instrument(name, title, body, Appsignal::EventFormatter::SQL_BODY_FORMAT, &block)\n end", "def determine_database\n self.class.database \n end", "def with_connection\n ActiveRecord::Base.connection_pool.with_connection do |conn|\n yield conn\n end\n end", "def database\n @database ||= determine_database\n end", "def enable_sql_logging(&block)\n sql_logging(enabled: true, &block)\n end", "def run(worker_name)\n Parts::WithLocking.sql_comment = @short_description || @description\n @block.call(worker_name)\n ensure\n Parts::WithLocking.sql_comment = nil\n end", "def set_database(database)\n @database = database\n end", "def setup_connection(conn)\n conn = super(conn)\n conn.extend(Sequel::Swift::Postgres::AdapterMethods)\n conn.db = self\n conn.apply_connection_settings\n conn\n end", "def db_connection\n begin\n connection = PG.connect(dbname:'news')\n yield(connection)\n ensure\n connection.close\n end\nend", "def db(db_name, options={})\n DB.new(db_name, self, options.merge(:logger => @logger))\n end", "def perform_now(block=nil)\n Thread.current[:name] ||= name\n if defined?(Rails) && defined?(ActiveRecord::Base)\n require 'gb_dispatch/active_record_patch'\n thread_block = ->() do\n if Rails::VERSION::MAJOR < 5\n begin\n ActiveRecord::Base.connection_pool.force_new_connection do\n block ? block.call : yield\n end\n ensure\n ActiveRecord::Base.clear_active_connections!\n end\n else\n Rails.application.executor.wrap do\n ActiveRecord::Base.connection_pool.force_new_connection do\n block ? block.call : yield\n end\n end\n end\n end\n else\n thread_block = block ? block : ->() { yield }\n end\n begin\n Runner.execute thread_block, name: name\n rescue Exception => e\n return e\n end\n end", "def db_connection\n begin\n connection = PG.connect(dbname: \"korning\")\n yield(connection)\n ensure\n connection.close\n end\nend", "def database_name\n database&.name\n end", "def print\n $stdout.puts(\"DB #{@context.getDBConnection.toString}\")\n end", "def database_name\n header_db_label\n end", "def initialize(opts = {}, &block)\n @opts = opts\n \n @quote_identifiers = opts[:quote_identifiers] || @@quote_identifiers\n @single_threaded = opts[:single_threaded] || @@single_threaded\n @schemas = nil\n @pool = (@single_threaded ? SingleThreadedPool : ConnectionPool).new(connection_pool_default_options.merge(opts), &block)\n @pool.connection_proc = proc {connect} unless block\n\n @loggers = Array(opts[:logger]) + Array(opts[:loggers])\n ::Sequel::DATABASES.push(self)\n end", "def on_db_host(context, host)\n\tend", "def set_db_name\n @db_name = DbName.find(params[:id])\n end", "def database(name)\n Database.new(connection.db(name))\n end", "def set_dbconnection\n @dbconnection = Dbconnection.find(params[:id])\n end", "def connection_name\n raise \"You must override `connection_name' in your class\"\n end", "def name\n db_name = URI.parse(uri(self)).path.to_s.sub(\"/\", \"\")\n db_name.blank? ? database : db_name\n end", "def database(name)\n Database.new(self, name)\n end", "def db\n \n ActiveRecord::Base.establish_connection(:adapter => \"mysql2\",\n :database => \"prod1\",\n :user => \"root\",\n :password=>\"Sector@123\",\n :local_infile => true).connection()\n \n end", "def mysql_connection(name)\n name = name.to_s\n config = mysql_config_by_name(name)\n ConnectionWrapper.new(self, name, config)\n end", "def new_connection(params)\n Pod4.logger.info(__FILE__){ \"Connecting to DB\" }\n client = TinyTds::Client.new(params)\n raise \"Bad Connection\" unless client.active?\n\n client.execute(\"use [#{self.class.db}]\").do\n\n client\n\n rescue => e\n handle_error(e)\n end", "def db_connection\n begin\n connection = PG.connect(dbname: \"pet_db\")\n yield(connection)\n ensure\n connection.close\n end\nend", "def execute(sql, name = nil, &block)\n log(sql, name) do\n @connection.query(sql, &block)\n end\n end", "def conn\n builder.conn || ::ActiveRecord::Base.connection\n end", "def connect(*args)\n @@connection = FluidDB::Connection.new(*args)\n end", "def connection\n ActiveRecord::Base.connection\n end", "def db_connection\n begin connection = PG.connect(dbname: 'validity_take_home')\n yield(connection)\n ensure\n connection.close\n end\nend", "def migrate(opts, &block)\n opts[:target] = resolve(opts[:target])\n # Migrate the input.\n CaTissue::Migrator.new(opts).migrate_to_database(&block)\n end", "def db\n @connection.pg rescue nil\n end", "def hijack_db\n ActiveRecord::Base.establish_connection(\n :adapter => ENV['YAPTESTFE_DBTYPE'],\n :host => ENV['YAPTESTFE_DBIP'],\n :port => ENV['YAPTESTFE_DBPORT'].to_i,\n :username => ENV['YAPTESTFE_DBUSER'],\n :password => ENV['YAPTESTFE_DBPASS'],\n :database => ENV['YAPTESTFE_DBNAME']\n ) \n begin # catch db connection errors\n if not ActiveRecord::Base.connection.active?\n render :template => 'help/dberror', :layout => false\n end\n rescue PGError => msg\n logger.info \"DBERROR: #{msg}\"\n render :template => 'help/dberror', :layout => false\n end\n end", "def _connect_database\n _send_command(\"db_connect #{@options[:db_user]}:#{@options[:db_pass]}@#{@options[:db_host]}/#{@options[:db_name]}\")\n end", "def db_name\n data[:db_name]\n end", "def default_connection=(_arg0); end", "def default_connection=(_arg0); end", "def default_connection=(_arg0); end", "def database_name\n data[:database_name]\n end", "def make_connection database=nil\n \n self.sql ||= Mysql2::Client.new(:host => \"#{self.url}\", :username => \"username#{self.user_id}\", :password => \"cis400\", :port => 3306, :database=>\"#{database}\")\n end", "def db_connection\n begin\n connection = PG.connect(dbname: \"movies\")\n yield(connection)\n ensure\n connection.close\n end\nend", "def label(label = nil, &block)\n if label || block\n @label = label || block\n else\n if @label.nil?\n label = parent.nil? ? parent.abstract_model.pretty_name : parent.label\n else\n label = @label\n end\n label = instance_eval &label if label.kind_of?(Proc)\n label\n end\n end", "def default_pool_name\n super\n end" ]
[ "0.58952796", "0.58952796", "0.5864107", "0.58073604", "0.5803836", "0.56988025", "0.5618647", "0.556568", "0.55474716", "0.5438245", "0.541401", "0.5365838", "0.5349817", "0.5346079", "0.5331299", "0.53275156", "0.52839667", "0.52775586", "0.5259137", "0.5258833", "0.52521765", "0.519147", "0.519147", "0.5163664", "0.51478595", "0.51437366", "0.5124979", "0.5101293", "0.50984466", "0.5080297", "0.50583565", "0.50447065", "0.5033302", "0.50314", "0.50314", "0.50314", "0.50314", "0.50314", "0.50314", "0.50314", "0.50252604", "0.50246435", "0.50162977", "0.49836555", "0.4983647", "0.49794042", "0.495752", "0.49495924", "0.49420395", "0.49370053", "0.49219823", "0.49218425", "0.48978424", "0.48942685", "0.48861572", "0.48674938", "0.48667833", "0.48525357", "0.48493814", "0.48465285", "0.4845068", "0.48395455", "0.48393518", "0.4820769", "0.4820094", "0.4819972", "0.48130813", "0.48092204", "0.47976506", "0.47937644", "0.47908255", "0.47881126", "0.4784656", "0.4781302", "0.47787693", "0.47782722", "0.4777316", "0.4772212", "0.47706705", "0.4765654", "0.47639367", "0.4759081", "0.47451106", "0.47381845", "0.47362164", "0.47344992", "0.47335616", "0.47320396", "0.4730912", "0.47226843", "0.47193208", "0.47077388", "0.47065425", "0.47065425", "0.47065425", "0.47049513", "0.4701886", "0.4698504", "0.46938723", "0.46804288" ]
0.6936789
0
returns true if an update occurred
def git_fetch path Open3.popen2e *%W(git fetch origin), chdir: path do |stdin, stdout, _wait| not stdout.read.chomp.empty? end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update?\n @update\n end", "def updated?\n command.success?\n end", "def updated?() updated.present?; end", "def update?\n true\n end", "def updated?\n false\n end", "def update?\n state == STATE_UPDATE\n end", "def update\n true\n end", "def update_failed?\n @update_failed\n end", "def update\n\t\treturn true\n\tend", "def updated?\n return @_updated\n end", "def updated?\n self.connected && self.updated\n end", "def update?\n event == 'update'\n end", "def execute_if_updated\n if updated?\n execute\n true\n else\n false\n end\n end", "def updated?\n updater && author != updater\n end", "def update?\n false\n end", "def update?\n false\n end", "def update?\n if @w_up_to_date && true #all up_to_date-caches!!!\n @up_to_date = true\n return @up_to_date\n end\n false\n end", "def update\n perform && updated?\n end", "def any_updates?\n change_history.size > 1\n end", "def any_updates?\n change_history.size > 1\n end", "def update\n\t\tfalse\n\tend", "def has_updates?\n self['newUpdatesFlag']\n end", "def has_changes?\n @has_changed_the_db\n end", "def update?\n update_indicator.eql?('U')\n end", "def update_result_ok?(update_result)\n update_result.is_a?(Hash) && update_result[\"updatedExisting\"] == true\n end", "def updateable?\n return true if @cursor == STOP\n now = Time.now\n @last_update ||= now\n now - @last_update > UPDATE_DELAY\n end", "def update_phase!()\n @involved_entities.each do |involved_entity|\n return false unless ( !involved_entity.has_to_update || execute_update!( involved_entity.entity_class ) )\n end\n return true\n end", "def changed?\n if update_type == :no_change\n false\n else\n true\n end\n end", "def has_updates?\n !@update_map.empty?\n end", "def update\n return true unless attribute_changes?\n update!\n end", "def updatable\n can_update?\n end", "def update?\n return true if event_planner? || super_admin?\n\n my_record? && !registration_closed?\n end", "def has_changes?\n @has_updated || @has_created\n end", "def notify?\n update?\n end", "def changed? \n @changed == true\n end", "def updated?\n @changed_files.clear()\n start_size = @file_cache.size\n listen_for_changes\n end_size = @file_cache.size\n start_size != end_size || !@changed_files.empty?\n end", "def updated?\n !ignore? && !removed? && mtime != File.mtime(path)\n end", "def update?\n dif = (self[:upd_next].to_i - now_msec)\n return false if dif.between?(0, @periodm)\n self[:upd_next] = now_msec + @periodm\n verbose { \"Next Update is #{dif / 1000}sec later\" }\n cmt\n true\n end", "def update(*args)\n update!(*args)\n rescue *exceptions\n false\n end", "def update(*args)\n update!(*args)\n rescue *exceptions\n false\n end", "def updatable?\n true\n end", "def changed?\r\n @changed\r\n end", "def update_available?()\n update_info != \"\"\n end", "def auto_update?\n return jiak.auto_update\n end", "def updated?(new_payload)\n payload != new_payload\n end", "def update_completed? ; false ; end", "def after_update\n true\n end", "def update\n dirty_attributes = self.dirty_attributes\n return true if dirty_attributes.empty?\n repository.update(dirty_attributes, to_query) == 1\n end", "def update\n run_callbacks :update do\n true\n end\n end", "def auto_update?\n @jiak.auto_update\n end", "def dirty?\n @changes && @changes.size > 0\n end", "def is_feature_update\n return @is_feature_update\n end", "def changed?\n @changed\n end", "def should_update?(request)\n @should_update_checks.all? { |c| c.call(request) }\n end", "def should_update?(request)\n @should_update_checks.all? { |c| c.call(request) }\n end", "def up_to_date?\n lu = latest_stored_update\n\n if !lu && !@prev_latest_update\n # They match if both nil\n true\n elsif lu && @prev_latest_update && (lu - @prev_latest_update).abs < 2\n # Consider them a match if they are within 2 seconds of one another,\n # accounting for the difference between Rails and DB times\n true\n elsif @prev_latest_update.nil?\n # The remembered value was nil, so let the caller know this\n self.prev_latest_update = lu\n nil\n else\n # There was no match\n self.prev_latest_update = lu\n false\n end\n end", "def changed?\n @changed\n end", "def dirty?\n @changes.length > 0\n end", "def is_update?(action_name)\n action_name == 'update'\n end", "def modified?\r\n @modified\r\n end", "def updateable?\n false\n end", "def write?\n return true unless added.zero?\n return false unless update?\n !(updated + removed).zero?\n end", "def update_required?\n any?(&:update_required?)\n end", "def has_changes_to_save?\n mutations_from_database.any_changes?\n end", "def requires_update?\n\t\tif @twitter_account.new_record? || @twitter_account.name.nil?\n\t\t\treturn true\n\t\tend\n\n\t\treturn Time.now - @twitter_account.updated_at > 60 * CACHE_DURATION\n\tend", "def changed?\n true\n end", "def update?\n existing && !destroyable? && acceptable_id?\n end", "def change?\n updated? || deleted?\n end", "def can_update?\n object.updatable_by?(current_user)\n end", "def updated?\n\t\t\t@config.is_a? Hash\n\t\tend", "def changed?\n !!@changed\n end", "def modified?\n @modified\n end", "def has_changes?\n (@edited_rows_codes.count > 0) || (@destroyed_rows_codes.count > 0)\n end", "def changed?\n mutations_from_database.any_changes?\n end", "def changed?\n changes.changed?\n end", "def changed?\n\t\treturn self.changed_reason ? true : false\n\tend", "def will_record_after_update?\n on = @record.paper_trail_options[:on]\n on.nil? || on.include?(:update)\n end", "def updates_since? last_update\r\n return true unless self.updated_since(last_update).blank?\r\n return true unless self.problems.updated_since(last_update).blank?\r\n false\r\n end", "def update?\n if record.updateable_time?\n if record.subject&.personal?\n if record.vip_updateable_time?\n return true if user.staff.id.in? record.staff_ids\n return true if user.id == record.creator_id\n end\n end\n\n\n if record.klass_subject&.fixed == false\n return true if user.staff.id.in? record.staff_ids\n return true if user.id == record.creator_id\n end\n return true if user.role? 'STUDENT_ADMIN'\n end\n\n false\n end", "def modified?\n\t\treturn @dirty ? true : false\n\tend", "def update?\n create?\n end", "def update?\n create?\n end", "def update?\n create?\n end", "def update?\n create?\n end", "def sneaky_update\n\n # Handle no changes.\n return true if changes.empty?\n\n # Here we have changes --> save them.\n pk = self.class.primary_key\n original_id = changed_attributes.has_key?(pk) ? changes[pk].first : send(pk)\n !self.class.where(pk => original_id).update_all(attributes).zero?\n end", "def track_record_update\n true\n end", "def modified?\n @modified\n end", "def modified?\n @modified\n end", "def update_existing?\n !self.errors.any? && !item_return? && exists?\n end", "def update!\n write_to_disk ? true : false\n end", "def updatable?(database)\n result = true\n database.execute 'BEGIN'\n begin\n database.execute update_stmt\n rescue PG::UndefinedFile, PG::UndefinedObject, PG::ReadOnlySqlTransaction => err\n @error = err.message\n result = false\n end\n database.execute 'ROLLBACK'\n\n result\n end", "def update?(record, attrs)\n return false unless update_on\n existing_key = attrs[update_on.to_sym]\n existing_ids.key?(existing_key)\n end", "def anything_changed?\n self.changed?;\n end", "def update_found(feed, latest_db_post)\n if latest_db_post.nil?\n Log.log.debug \"Latest Post date is nil, table is empty. Performing initial update\"\n return true\n end\n last_blog_update = feed.updated.content\n Log.log.debug \"last_blog_update: #{last_blog_update}\"\n Log.log.debug \"latest_db_post: #{latest_db_post}\" \n if last_blog_update > latest_db_post\n Log.log.debug \"Updates Detected\"\n return true\n else\n Log.log.debug \"No updates found\"\n return false\n end\nend", "def updatable?\n sir_item.sir_entries.last.id == id\n end", "def locate_updatedb?\n if @updatedb\n true\n else\n false\n end\n end", "def modified?\n\t\t@modified\n\tend", "def has_update?(branch)\n zombie_check\n end", "def need_update?\n return true unless @lastread\n @lastread < File::stat(@path).mtime\n end", "def _update_check_needed\n (Time.now - @last_update_check) > UPDATE_VALID_PERIOD\n end", "def buildlog_updated?\n old_buildlog = buildlog\n update_buildlog\n buildlog && buildlog != old_buildlog\n end" ]
[ "0.8384876", "0.82848316", "0.818492", "0.8106037", "0.8061133", "0.8057604", "0.79850566", "0.79443085", "0.79440373", "0.79325265", "0.7848952", "0.7796269", "0.777988", "0.7770933", "0.77215767", "0.77215767", "0.7694314", "0.7693199", "0.76871115", "0.76871115", "0.7671504", "0.7629467", "0.7567054", "0.7565058", "0.7560996", "0.7530416", "0.75169957", "0.7455937", "0.73671114", "0.7352537", "0.73369694", "0.73220664", "0.73064333", "0.72542685", "0.7236657", "0.722487", "0.7223929", "0.7219507", "0.72117287", "0.72117287", "0.72097373", "0.7199365", "0.7186512", "0.7177621", "0.7155902", "0.7152407", "0.71296716", "0.7104181", "0.70950246", "0.70893496", "0.70396763", "0.7038402", "0.7016323", "0.7013577", "0.7013577", "0.70020545", "0.69733", "0.6971786", "0.6966927", "0.69654506", "0.6922351", "0.6916596", "0.69074696", "0.6898051", "0.689747", "0.68941957", "0.68911713", "0.6885622", "0.68648505", "0.6862374", "0.68530226", "0.68499655", "0.68493503", "0.6830307", "0.6828887", "0.68257606", "0.68221515", "0.68120235", "0.6806791", "0.6803268", "0.67867535", "0.67867535", "0.67867535", "0.67867535", "0.67830473", "0.6781192", "0.6766379", "0.6766379", "0.67557013", "0.6739886", "0.6738809", "0.6737166", "0.6726011", "0.67243814", "0.6722631", "0.67160624", "0.6700802", "0.66993123", "0.66966075", "0.6693598", "0.6680836" ]
0.0
-1
Returns a resized image for display.
def display_image image.variant(resize_to_limit: [500, 500]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_resized_image\n create_image do |xfrm|\n if size\n MiniMagick::Tool::Convert.new do |cmd|\n cmd << xfrm.path # input\n cmd.flatten\n cmd.resize(size)\n cmd << xfrm.path # output\n end\n end\n end\n end", "def display_image\n image.variant(resize_to_limit: [500,500])\n end", "def create_resized_image\n create_image do |xfrm|\n if size\n xfrm.flatten\n xfrm.resize(size)\n end\n end\n end", "def resize\n @image.resize \"#{@placement[:a]}x#{OUTER}\\!\"\n end", "def display_image \r\n self.image.variant(resize_to_limit: [1000, 1000]) \r\n end", "def display_image\n image.variant resize_to_limit: Settings.validation.post.img_resize\n end", "def resize_pic(filename,resizewidth,out_path)\n nw = resizewidth\n n = File.basename(filename)\n i = QuickMagick::Image.read(filename).first\n w = i.width.to_f # Retrieves width in pixels\n h = i.height.to_f # Retrieves height in pixels\n pr = w/h\n nh = nw/pr \n i.resize \"#{nw}x#{nh}!\"\n i.save \"#{out_path}/#{n}\"\nend", "def small(input) # Method that returns the image\n self.images[input].variant(resize: \"300x300\").processed # Resizing the image and return it\n end", "def resize\n image = ManagedImage.from_path(params[:image])\n width = params[:width].to_i\n height = params[:height].to_i\n render json: image.resize(width, height)\n end", "def resize\n\t\t@image = Qt::Image.new @parent.width/2, @parent.width/2, 7\n\t\t@image.fill Qt::Color.new \"#ffffff\"\n\tend", "def thumbnail(size); end", "def resize(size='512x512')\n if self.url.present?\n image = MiniMagick::Image.open(self.url)\n image.resize(size)\n image\n end\n end", "def create_medium\n return create_resized_pic(MEDIUM_HEIGHT, MEDIUM_WIDTH, SIZE_MEDIUM)\n end", "def resize_to_fit\n image = ManagedImage.from_path(params[:image])\n width = params[:width].to_i\n height = params[:height].to_i\n render json: image.resize_to_fit(width, height)\n end", "def my_resize(width, height)\n manipulate! do |img|\n img.resize \"#{width}x#{height}!\"\n img\n end\n end", "def small_image_url\n self.small_image.convert('-resize 50%').url\n end", "def resize_image(img_path)\n img = MiniMagick::Image.open(img_path)\n print_status(\"Original #{img_path} dimension = #{img.height}x#{img.width}\")\n new_width = img.width - (img.width * REIZEPERT).to_i\n new_height = img.height - (img.height * REIZEPERT).to_i\n img = img.resize(\"#{new_width}x#{new_height}\")\n print_status(\"Resized #{img_path} dimension = #{img.height}x#{img.width}\")\n img.write(img_path)\nend", "def image_as_medium_thumbnail\n image.variant(resize_to_fill: [350, 350]).processed\n end", "def create_thumbnail\n return create_resized_pic(THUMBNAIL_HEIGHT, THUMBNAIL_WIDTH, SIZE_THUMBNAIL)\n end", "def generate_thumbnail path, img\n img = img.resize_to_fit 200,200\n img.write path\n end", "def generate_image(url)\n # Capture the screenshot\n kit = IMGKit.new(url, quality: 90, width: 1280, height: 720)\n\n # Resize the screengrab using rmagick\n Image.from_blob(kit.to_img(:jpg)).first.\n resize_to_fill!(params['width'].to_i, params['height'].to_i).to_blob\nend", "def set_original\n if keep_original\n if size_o.blank?\n image = MiniMagick::Image.open(name)\n self.size_o = \"#{image.width}x#{image.height}\"\n end\n else\n self.size_o = ''\n end\nend", "def resizeImage(imageName)\n image = MiniMagick::Image.open(imageName)\n height = image.height\n width = image.width\n\n if height > width\n ratio = 128.0 / height\n reHeight = (height * ratio).floor\n reWidth = (width * ratio).floor\n else\n ratio = 128.0 / width\n reHeight = (height * ratio).floor\n reWidth = (width * ratio).floor\n end\n\n image.resize(\"#{reHeight} x #{reWidth}\")\n image.write(\"resize.jpg\")\n end", "def requested_image_resolution\n return resized_image_resolution unless resized_image_resolution.nil?\n original_image_resolution\n end", "def show\n respond_to do |format|\n format.jpeg { send_data @recipe_image.resize }\n end\n end", "def show\n maybe_update_aspect_ratio @image\n end", "def resize(width, height); end", "def resize_image(img, size)\n size = size.first if size.is_a?(Array) && size.length == 1\n if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))\n if size.is_a?(Fixnum)\n # Borrowed from image science's #thumbnail method and adapted \n # for this.\n scale = size.to_f / (img.width > img.height ? img.width.to_f : img.height.to_f)\n img.resize!((img.width * scale).round(1), (img.height * scale).round(1), false)\n else\n img.resize!(size.first, size.last, false) \n end\n else\n w, h = [img.width, img.height] / size.to_s\n img.resize!(w, h, false)\n end\n temp_paths.unshift random_tempfile_filename\n self.size = img.export(self.temp_path)\n end", "def resize_image(image, options = {})\n processor = ::RedArtisan::CoreImage::Processor.new(image)\n size = options[:size]\n size = size.first if size.is_a?(Array) && size.length == 1\n if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))\n if size.is_a?(Fixnum)\n processor.fit(size)\n else\n processor.resize(size[0], size[1])\n end\n else\n new_size = get_image_size(image) / size.to_s\n processor.resize(new_size[0], new_size[1])\n end\n \n destination = options[:to] || @file\n AttachmentFu::Pixels::Image.new destination do |img|\n processor.render do |result|\n img.width, img.height = get_image_size(result)\n result.save destination, OSX::NSJPEGFileType\n end\n end\n end", "def resize_and_optimize(width, height)\n manipulate! do |img|\n img.format(\"jpg\") do |c|\n c.quality \"70\"\n c.resize \"#{width}x#{height}\"\n end\n\n img\n end\n end", "def resize_image(file_name,resize_file_name=\"test\",resized_width=0,resized_height=0,render_file_as=\"png\")\n image = Image.import(file_name)\n resize_image = image.resize(resized_width, resized_height,true)\n\n file=File.new(resize_file_name,\"wb\")\n if render_file_as == \"png\"\n file.write resize_image.png\n elsif\t render_file_as == \"jpeg\"\n file.write resize_image.jpeg\n elsif\t render_file_as == \"gd\"\n file.write resize_image.gd\n elsif\t render_file_as == \"gd2\"\n file.write resize_image.gd2\n else\n puts \"Provide proper image\"\n end\n file.close\n end", "def old_resize_image(img, size)\n size = size.first if size.is_a?(Array) && size.length == 1 && !size.first.is_a?(Fixnum)\n if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))\n size = [size, size] if size.is_a?(Fixnum)\n img.thumbnail!(*size)\n elsif size.is_a?(String) && size =~ /^c.*$/ # Image cropping - example geometry string: c75x75\n dimensions = size[1..size.size].split(\"x\")\n img.crop_resized!(dimensions[0].to_i, dimensions[1].to_i)\n else\n img.change_geometry(size.to_s) { |cols, rows, image| image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows) }\n end\n self.width = img.columns if respond_to?(:width)\n self.height = img.rows if respond_to?(:height)\n img.strip! unless attachment_options[:keep_profile]\n quality = img.format.to_s[/JPEG/] && get_jpeg_quality\n out_file = write_to_temp_file(img.to_blob { self.quality = quality if quality })\n temp_paths.unshift out_file\n self.size = File.size(self.temp_path)\n end", "def resize\n if size.max > 1024\n res = %x( #{magick_bin_name(\"convert\")} -auto-orient -resize 1024x768 #{Shellwords.shellescape path} #{Shellwords.shellescape path})\n Rails.logger.info res\n end\n unless has_thumbnail?\n unless File.exists? path.gsub(/(.+)\\/.+/, '\\1/thumbs')\n Dir.mkdir path.gsub(/(.+)\\/.+/, '\\1/thumbs')\n end\n ## that's a bit broken on windows - why?\n res = %x( #{magick_bin_name(\"convert\")} -verbose -auto-orient -strip -thumbnail 300x160 #{Shellwords.shellescape path} #{Shellwords.shellescape path.gsub(/(.+)\\/(.+)/, '\\1/thumbs/\\2')})\n Rails.logger.info res\n end\n end", "def resizeImage(file, size)\n img_orig = Magick::Image.read(\"public/#{file}\").first\n \n width = img_orig.columns\n height = img_orig.rows\n \n if(width > size || height > size)\n if(width > height)\n height = size * height / width\n width = size\n else\n width = size * height / width\n height = size\n end\n \n img = img_orig.resize_to_fit(width, height)\n \n img.write(\"public/#{file}\")\n end\n end", "def resize_image(image_string, dest)\n image = Gg::ImageProcessing.new(image_string)\n i_name = dest.split('/').last\n image.blob_generate(project.image_for(i_name, 'show'))\n image.blob_generate(project.image_for(i_name, 'show_image_desk'), 'desktop')\n image.blob_generate(project.image_for(i_name, 'show_image_mob'), 'mobile')\n end", "def thumbnail input\n return self.images[input].variant(resize: '300x300').processed\n end", "def extract_thumb(input, output, width, height)\n Image::Editing::ResizeToFill.new(input, output, width, height).run\n end", "def process_small_image\n small_image.encode!(:png).convert!('-resize 50x50 -gravity center -background none -extent 50x50')\n end", "def resize_image uri, options = { }\n\n\t# parse id, mime type from image uri\n\tformat = uri.split('/').last.match(/\\.(.+)$/)[1]\n\tid = uri.split('/').last.sub(/\\..+$/, '').slugify\n\n\t# resize image and save to /tmp\n\timage = Image.read(uri)[0]\n\t\n\t# calculate width/height based on percentage of \n\t# difference of width from absolute value of 150\n\tif options[:width]\n\t\twidth = options[:width]\n\t\tscale = (image.page.width - width) / image.page.width.to_f\n\t\theight = image.page.height - (image.page.height * scale)\n\n\t\timage = image.thumbnail(width, height)\n\t\timage.write(\n\t\t\tpath = \"/tmp/#{id}-constrainedw.#{format}\"\n\t\t)\t\t\n\n\telsif options[:height]\n\t\theight = options[:height]\n\t\tscale = (image.page.height - height) / image.page.height.to_f\n\t\twidth = image.page.width - (image.page.width * scale)\n\n\t\timage = image.thumbnail(width, height)\n\t\timage.write(\n\t\t\tpath = \"/tmp/#{id}-thumbh.#{format}\"\n\t\t)\n\n\telse\n\t\twidth = 150\n\t\tscale = (image.page.width - width) / image.page.width.to_f\n\t\theight = image.page.height - (image.page.height * scale)\n\n\t\timage = image.thumbnail(width, height)\n\t\timage.write(\n\t\t\tpath = \"/tmp/#{id}-thumb.#{format}\"\n\t\t)\n\n\tend\n\n path\nend", "def getImg(width=64, height=64)\n if self.image\n self.image+\"?width=#{width}&height=#{height}\"\n else\n \"no_image.png\"\n end\n end", "def strict_resize image, w, h\n image.resize \"#{ w }x#{ h }!\"\n image\n end", "def large_image\n self.image.large\n end", "def resize_to_fill\n image = ManagedImage.from_path(params[:image])\n width = params[:width].to_i\n height = params[:height].to_i\n render json: image.resize_to_fill(width, height)\n end", "def size\n \"#{width}x#{height}\"\n end", "def size\n \"#{width}x#{height}\"\n end", "def resize_image\n image = params[:fleet][:image]\n return if image.nil?\n\n begin\n image = MiniMagick::Image.new(image.tempfile.path)\n image.resize '175x260>'\n rescue MiniMagick::Error\n # errors here will be caught in model validation\n end\n end", "def create_thumbnail\n image = Image.from_blob(self.photo_image).first\n thumbnail = image.resize_to_fill(320,240, gravity=CenterGravity)\n thumbnail.to_blob\n end", "def resize_to(width, height); end", "def resize_image(img, size)\n size = size.first if size.is_a?(Array) && size.length == 1 && !size.first.is_a?(Fixnum)\n if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))\n size = [size, size] if size.is_a?(Fixnum)\n img.thumbnail!(*size)\n elsif size.is_a?(String) && size =~ /^c.*$/ # Image cropping - example geometry string: c75x75\n dimensions = size[1..size.size].split(\"x\")\n img.crop_resized!(dimensions[0].to_i, dimensions[1].to_i)\n elsif size.is_a?(String) && size =~ /^b.*$/ # Resize w/border - example geometry string: b75x75\n dimensions = size[1..size.size].split(\"x\")\n img.change_geometry(dimensions.join(\"x\")) do |cols, rows, image|\n image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows )\n end\n img.background_color = \"black\"\n x_offset = (img.columns - dimensions[0].to_i) / 2\n y_offset = (img.rows - dimensions[1].to_i) / 2\n img = img.extent(dimensions[0].to_i, dimensions[1].to_i, x_offset, y_offset)\n else\n img.change_geometry(size.to_s) { |cols, rows, image| image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows) }\n end\n img.strip! unless attachment_options[:keep_profile]\n temp_paths.unshift write_to_temp_file(img.to_blob)\n end", "def to_image(width, height)\n image = Image.new_blank(width, height)\n self.render(image)\n return image\n end", "def create_thumbnail\n ImageGeneratingService.new(self, 'Thumbnail.png', 'image/png').generate_resized(120)\n end", "def resize_image(img, size)\n size = size.first if size.is_a?(Array) && size.length == 1 && !size.first.is_a?(Fixnum)\n if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))\n size = [size, size] if size.is_a?(Fixnum)\n img.thumbnail!(*size)\n elsif size.is_a?(String) && size =~ /^c.*$/ # Image cropping - example geometry string: c75x75\n dimensions = size[1..size.size].split(\"x\")\n img.crop_resized!(dimensions[0].to_i, dimensions[1].to_i)\n elsif size.is_a?(String) && size =~ /^b.*$/ # Resize w/border - example geometry string: b75x75\n dimensions = size[1..size.size].split(\"x\")\n img.change_geometry(dimensions.join(\"x\")) do |cols, rows, image| \n image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows ) \n end\n img.background_color = \"black\"\n x_offset = (img.columns - dimensions[0].to_i) / 2\n y_offset = (img.rows - dimensions[1].to_i) / 2\n img = img.extent(dimensions[0].to_i, dimensions[1].to_i, x_offset, y_offset)\n else\n img.change_geometry(size.to_s) { |cols, rows, image| image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows) }\n end\n img.strip! unless attachment_options[:keep_profile]\n temp_paths.unshift write_to_temp_file(img.to_blob)\n end", "def large\n if image.on_storage?\n variant(1200)\n else\n relevant_assets_cache.select { |item| item.width <= 1200 }.sort_by(&:width).last.url\n end\n end", "def resize(raw_geometry='320x240', quality: nil)\n \n geometry = calc_resize(raw_geometry\n )\n read() do |preview|\n \n preview.change_geometry!(geometry) do |cols, rows, img|\n img.resize!(cols, rows)\n end\n \n write preview, quality\n end\n \n end", "def scale_image(preferred_width, preferred_height)\n # Retrieve the current height and width\n image_data = ActiveStorage::Analyzer::ImageAnalyzer.new(image).metadata\n new_width = image_data[:width]\n new_height = image_data[:height]\n\n # Adjust the width\n if new_width > preferred_width\n new_width = preferred_width\n new_height = (new_height * new_width) / image_data[:width]\n end\n\n # Adjust the height\n if new_height > preferred_height\n old_height = new_height\n new_height = preferred_height\n new_width = (new_width * new_height) / old_height\n end\n\n # Return the resized image\n image.variant(resize_to_limit: [new_width, new_height])\n end", "def resize(path)\n gravity = @options.key?(:gravity) ? @options[:gravity] : 'Center'\n\n img = MiniMagick::Image.open(@file)\n cols, rows = img[:dimensions]\n\n img.combine_options do |cmd|\n if @width != cols || @height != rows\n scale_x = @width/cols.to_f\n scale_y = @height/rows.to_f\n\n if scale_x >= scale_y\n cols = (scale_x * (cols + 0.5)).round\n rows = (scale_x * (rows + 0.5)).round\n cmd.resize \"#{cols}\"\n else\n cols = (scale_y * (cols + 0.5)).round\n rows = (scale_y * (rows + 0.5)).round\n cmd.resize \"x#{rows}\"\n end\n end\n\n cmd.quality @options[:quality] if @options.key?(:quality)\n cmd.gravity gravity\n cmd.background 'rgba(255,255,255,0.0)'\n cmd.extent \"#{@width}x#{@height}\" if cols != @width || rows != @height\n end\n\n img.write(path)\n end", "def resize_image(params)\n # The path of the image\n path = \"public/images/#{params[1]}/#{@tempo.id}_#{params[1]}.#{params[0]}\"\n # Read the image\n img = Magick::Image.read(\"public/images/original/#{@original_image_name}\").first\n # Resize and Crop the image\n target = Magick::Image.new(params[2], params[3])\n thumb = img.resize_to_fill!(params[2], params[3])\n target.composite(thumb, Magick::CenterGravity, Magick::CopyCompositeOp).write(path)\n # Insert the width and height into an object\n @tempo.width, @tempo.height = \"#{params[2]}\", \"#{params[3]}\"\n # Add the link and tags to its DB\n add_linkID_tagsID(path,params[1])\n # Delete the image after uploading it to the storage\n File.delete(path)\n end", "def image_size(style = default_style)\n return nil if instance_read(:meta).nil? || instance_read(:meta).empty?\n \"#{width(style)}x#{height(style)}\"\n end", "def resize!\n end", "def resize(width, height)\n end", "def sized(width, height)\n\t\t\t@sized_thumb = @template\n\t\t\t@sized_thumb.sub! \"{width}\", width.to_s\n\t\t\t@sized_thumb.sub! \"{height}\", height.to_s\n\t\tend", "def display_image\n image.variant(combine_options: {\n auto_orient: true,\n gravity: \"center\",\n resize: \"250x250^\",\n crop: \"250x250+0+0\"\n })\n end", "def show\n\n matches = params[:size].match(\"([0-9]+)x([0-9]+).*\") if params[:size]\n\n default_size = 200\n min_size = 16\n max_size = 200\n\n if matches\n\n width = matches[1].to_i\n height = matches[2].to_i\n\n if ((width < min_size) || (width > max_size) || (height < min_size) || (height > max_size))\n width = default_size\n height = default_size\n end\n\n else\n width = 200\n height = 200\n end\n \n send_cached_data(\"public/pictures/show/#{width.to_i}x#{height.to_i}/#{params[:id].to_i}.jpg\",\n :type => 'image/jpeg', :disposition => 'inline') {\n\n img = Magick::Image.from_blob(@picture.data).first\n img = img.change_geometry(\"#{width}x#{height}>\") do |c, r, i| i.resize(c, r) end\n\n img.format = \"jpg\"\n img.to_blob\n }\n\n end", "def resize!(options)\n options = options.symbolize_keys\n raise ArgumentError, ':size must be included in resize options' unless options[:size]\n\n # load image\n img = rmagick_image.dup\n\n # Find dimensions\n x, y = size_to_xy(options[:size])\n\n # prevent upscaling unless :usample param exists.\n unless options[:upsample]\n x = img.columns if x > img.columns\n y = img.rows if y > img.rows\n end\n\n # Perform image resize\n case\n when options[:crop] && !options[:crop].is_a?(Hash) && img.respond_to?(:crop_resized!)\n # perform resize and crop\n scale_and_crop(img, [x, y], options[:offset])\n when options[:stretch]\n # stretch the image, ignoring aspect ratio\n stretch(img, [x, y]) \n else\n # perform the resize without crop\n scale(img, [x, y]) \n end\n\n if options[:format]\n img.format = options[:format].to_s.upcase\n img.strip!\n end\n\n options[:quality] ? img.to_blob { self.quality = options[:quality].to_i } : img.to_blob\n end", "def resize_image\n unless logo.nil?\n if logo.height != 100\n self.logo = logo.thumb('x100') # resize height and maintain aspect ratio\n end\n end\n end", "def scale_to(new_size, background:background)\n new_size = SugarCube::CoreGraphics::Size(new_size)\n\n image_size = self.size\n\n if CGSizeEqualToSize(image_size, new_size)\n return self\n end\n\n new_image = nil\n width = image_size.width\n height = image_size.height\n\n target_width = new_size.width\n target_height = new_size.height\n\n scale_factor = 0.0\n scaled_width = target_width\n scaled_height = target_height\n\n thumbnail_point = CGPoint.new(0.0, 0.0)\n width_factor = target_width / width\n height_factor = target_height / height\n\n if width_factor < height_factor\n scale_factor = width_factor\n else\n scale_factor = height_factor\n end\n\n scaled_width = width * scale_factor\n scaled_height = height * scale_factor\n\n # center the image\n\n if width_factor < height_factor\n thumbnail_point.y = (target_height - scaled_height) * 0.5\n elsif width_factor > height_factor\n thumbnail_point.x = (target_width - scaled_width) * 0.5\n end\n\n # this is actually the interesting part:\n\n UIGraphicsBeginImageContextWithOptions(new_size, false, self.scale)\n\n if background\n background = background.uicolor\n context = UIGraphicsGetCurrentContext()\n background.setFill\n CGContextAddRect(context, [[0, 0], new_size])\n CGContextDrawPath(context, KCGPathFill)\n end\n\n thumbnail_rect = CGRectZero\n thumbnail_rect.origin = thumbnail_point\n thumbnail_rect.size.width = scaled_width\n thumbnail_rect.size.height = scaled_height\n\n self.drawInRect(thumbnail_rect)\n\n new_image = UIGraphicsGetImageFromCurrentImageContext()\n UIGraphicsEndImageContext()\n\n raise \"could not scale image\" unless new_image\n\n return new_image\n end", "def create_advanced\n image_service = ImageGeneratingService.new(self, 'Advanced.jpg', 'image/jpeg', 69)\n output_path = image_service.generate\n original_size_mb = File.size(output_path).to_f / 2**20\n if original_size_mb > 1.0\n image_service.generate_resized(1200)\n end\n end", "def resize_image(download_path, resize_path, height, width, crop)\n `convert #{download_path.inspect} -resize \"#{height}x#{width}\" #{resize_path.inspect}`\n end", "def image_size(path)\n magick = MiniMagick::Image.open path\n \"#{magick.width}x#{magick.height}\"\nend", "def rmagick_img\n return @rmagick_img unless @rmagick_img.blank?\n if self.class.st_config[:blob].present?\n @rmagick_img ||= Magick::ImageList.new.from_blob(\n self.send(self.class.st_config[:blob])\n ).first\n elsif self.class.st_config[:file].present?\n @rmagick_img ||= Magick::ImageList.new.from_blob(\n File.read(self.send(self.class.st_config[:file]))\n ).first\n else\n raise \"No thumb source defined. You have to define neither :blob or :file\"\n end\n \n if self.class.st_config[:before_resize].present? && self.respond_to?(self.class.st_config[:before_resize].to_sym)\n self.send(self.class.st_config[:before_resize].to_sym)\n end\n @rmagick_img\n \n end", "def resize_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end", "def resize(path)\n img = MiniMagick::Image.open(@file)\n img.combine_options do |c|\n c.quality @options[:quality] if @options[:quality]\n c.resize \"#{@width}x#{@height}>\"\n end\n\n img.write(path)\n end", "def thumbnail(width, input, output)\n profile_normalization_args=[\"--eprofile\", srgb_profile_path, \"--delete\"]\n vips_jpg_params=\"[Q=#{@jpeg_q },interlace,optimize_coding,strip]\"\n args = if width\n # The image will be resized to fit within a box\n # which is `width` wide and very, very very tall.\n # See:\n # https://github.com/libvips/libvips/issues/781\n # https://github.com/libvips/ruby-vips/issues/150\n [\n vips_thumbnail_command, input.path,\n *profile_normalization_args,\n \"--size\", \"#{width}x1000000\",\n \"-o\", \"#{output.path}#{vips_jpg_params}\"\n ]\n else\n [ vips_command, \"copy\", input.path,\n *profile_normalization_args,\n \"#{output.path}#{vips_jpg_params}\"\n ]\n end\n @cmd.run(*args)\n end", "def create_resized_image(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end", "def resize_image(content, content_type, size)\n filename = \"/tmp/\" + (1 + rand(10000000)).to_s + \".\" + content_type\n filename_resized = \"/tmp/\" + (1 + rand(10000000)).to_s + \"_resized.\" + content_type\n File.open(filename, 'w') do |f|\n f.write( content)\n end\n result = %x[sips --resampleWidth #{size} #{filename} --out #{filename_resized}]\n content_resized = IO.readlines(filename_resized,'r').to_s\n return content_resized\nend", "def resize new_width, new_height\n win.resize new_width, new_height\n end", "def to_html\n \"<img src='#{@url}' height='#{@height}' width='#{width}' />\"\n end", "def do_resize(height = THUMBNAIL_HEIGHT, width = THUMBNAIL_WIDTH)\n #MES- Only do thumbnailing if the Image Magick library can be loaded.\n # This is to make setup easier for other developers- they are not\n # required to have Image Magick.\n # More information on Image Magick is available at \n # http://studio.imagemagick.org/RMagick/doc/usage.html\n if RMAGICK_SUPPORTED\n #MES- Turn the blob into an ImageMagick object\n img = Magick::Image.from_blob(data).first\n if img.nil?\n logger.info \"Failed to resize image #{self.name}- unable to create RMagick wrapper for image\"\n return nil\n end\n \n #MES- Shrink the image\n return img.crop_resized(width, height)\n else\n return nil\n end\n end", "def get_image(file, max_width, max_height)\n max_width_pixels = max_width * 300\n max_height_pixels = max_height * 300\n magick = MiniMagick::Image.read(file.download)\n magick.auto_orient\n magick.resize(\"#{max_width_pixels}x#{max_height_pixels}\") if magick.height > max_height_pixels || magick.width > max_width_pixels\n temp_path = \"#{Dir.tmpdir}/#{SecureRandom.alphanumeric(50)}\"\n magick.write(temp_path)\n return { path: temp_path, height: magick.height / 300.0, width: magick.width / 300.0 }\n end", "def img_resize( dat, w, h, options = {} )\n quality = options[:quality]\n format = options[:format]\n\n begin\n img = GD2::Image.load(dat)\n if h == 0\n h = ( w / img.aspect ).to_i\n end\n\n puts \"resizing image… width: #{w}, height: #{h}, quality: #{quality}\" if $debug\n\n # make sure it doesn't upscale image\n res = img.size\n\n if res[0] < w and res[1] < h\n w = res[0]\n h = res[1]\n elsif res[0] < w\n w = res[0]\n h = (w / img.aspect).to_i\n elsif res[1] < h\n h = res[1]\n w = (h / img.aspect).to_i\n end\n\n nimg = img.resize( w, h )\n\n if img_type(dat) == :jpeg and quality\n nimg.jpeg( quality.to_i )\n else\n case img_type(dat)\n when :png\n nimg.png\n when :jpeg\n nimg.jpeg\n when :gif\n nimg.gif\n else\n raise 'img_resize(), unknown output format'\n end\n end\n rescue => errmsg\n puts \"error: resize failed. #{w} #{h} #{quality}\"\n p errmsg\n return nil\n end\nend", "def resize(geometry)\n load_image.change_geometry(geometry) do |width, height, img|\n img.resize(width, height).to_blob\n end\n end", "def image_size\n end", "def create_image\r\n if @max_width\r\n @image = Gosu::Image.from_text($window, @text, @font, @size, @line_spacing, @max_width, @align)\r\n else\r\n @image = Gosu::Image.from_text($window, @text, @font, @size)\r\n end\r\n end", "def size\n width * height\n end", "def resize_image(img, size)\n img.delete_profile('*')\n\n # resize_image take size in a number of formats, we just want\n # Strings in the form of \"crop: WxH\"\n if (size.is_a?(String) && size =~ /^crop: (\\d*)x(\\d*)/i) ||\n (size.is_a?(Array) && size.first.is_a?(String) &&\n size.first =~ /^crop: (\\d*)x(\\d*)/i)\n img.crop_resized!($1.to_i, $2.to_i)\n # We need to save the resized image in the same way the\n # orignal does.\n quality = img.format.to_s[/JPEG/] && get_jpeg_quality\n out_file = write_to_temp_file(img.to_blob { self.quality = quality if quality })\n self.temp_paths.unshift out_file\n else\n old_resize_image(img, size) # Otherwise let attachment_fu handle it\n end\n end", "def scale_to_fit(width, height)\n @image = @image.scale_to_fit(width, height)\n self\n end", "def original_image_resolution\n @original_image_resolution ||= ScreenResolution.new(width: image_width, height: image_height)\n end", "def render(options={})\n original_media = self.media.original.first\n # In theory, there should be more code in here to look for a cached image and be smarter\n # about the resizing, but this is a good first pass.\n if options.key?(:width) || options.key?(:height)\n require 'image_utility'\n image = nil\n Graphic.benchmark(\"Image#from_blob\") do\n image = Magick::Image.from_blob(original_media.file_contents).first\n end\n\n # Resize the image to a height and width if they are both being set.\n # Round these numbers up to ensure the image will at least fill\n # the requested space.\n height = options[:height].nil? ? nil : options[:height].to_f.ceil\n width = options[:width].nil? ? nil : options[:width].to_f.ceil\n\n Graphic.benchmark(\"ImageUtility#resize\") do\n image = ImageUtility.resize(image, width, height, true)\n end\n\n file = Media.new(\n :attachable => self,\n :file_data => image.to_blob,\n :file_type => image.mime_type,\n :file_name => original_media.file_name\n )\n\n return file\n else\n return original_media\n end\n end", "def scale\n @photo = Photo.find(params[:id])\n img = Magick::Image.read('public' + @photo.attachment_url).first\n img = img.scale(1.5)\n img.write('public' + @photo.attachment_url)\n end", "def scale(width: @image.width, height: @image.height,\n algorithm: 'bilineal') # bilinear, nearest_neighbor\n if algorithm == 'nearest_neighbor'\n Image.new(@image.resample_nearest_neighbor(width, height), path)\n else\n Image.new(@image.resample_bilinear(width, height), path)\n end\n end", "def dynamic_resize_to_fit(size)\n resize_to_fit *(model.class::IMAGE_CONFIG[size])\n end", "def resize_and_write_file(filename, filename_output, max_width, max_height = nil)\n pic = Magick::Image.read(filename).first\n img_width, img_height = pic.columns, pic.rows\n ratio = img_width.to_f / max_width.to_f\n\n if max_height.nil?\n max_height = img_height / ratio\n end\n\n pic.change_geometry!(\"#{max_width}x#{max_height}>\") { |cols, rows, img|\n img.resize_to_fit!(cols, rows)\n img.write filename_output\n img.destroy!\n }\n\n nbytes, content = File.size(filename_output), nil\n File.open(filename_output, \"rb\") { |f| content = f.read nbytes }\n content\nend", "def thumbnail(input = 0)\n return self.uploads[input].variant(resize: '1000x1000').processed\n end", "def thumbnail(data, options = {})\n source_info = info data\n \n opts = {\n :width => source_info.width,\n :height => source_info.height,\n :preserve_aspect_ratio => true,\n :format => :png\n }.merge(options)\n \n width, height = calculate_aspect_ratio source_info, opts\n \n # Set res so we can assign it within the SmartImage.new block\n res = nil\n \n SmartImage.new(width, height) do |image|\n image.composite data, :width => width,\n :height => height,\n :preserve_aspect_ratio => false\n \n res = image.encode opts[:format]\n end\n \n res\n end", "def large_image_width\n 850\n end" ]
[ "0.74281555", "0.7337605", "0.7276508", "0.72498614", "0.71668667", "0.6908238", "0.6732925", "0.67188084", "0.66568625", "0.66387683", "0.65469444", "0.6546263", "0.65405697", "0.6535587", "0.6528795", "0.6500281", "0.6499397", "0.6488022", "0.6481025", "0.6469561", "0.64159244", "0.64140433", "0.6409584", "0.64076394", "0.6401538", "0.64012605", "0.63716", "0.6367713", "0.63598067", "0.63586235", "0.6342108", "0.6339572", "0.63337296", "0.63311124", "0.6326453", "0.6312615", "0.62912357", "0.62804997", "0.62709224", "0.62612903", "0.6233716", "0.62147063", "0.6208953", "0.6206828", "0.6206828", "0.6205417", "0.62052786", "0.6199134", "0.61984545", "0.6179115", "0.6172127", "0.6155899", "0.6143639", "0.6142739", "0.6141279", "0.6133443", "0.61264575", "0.6102807", "0.6100769", "0.6083572", "0.6077635", "0.60749316", "0.60707647", "0.60707587", "0.60651267", "0.60438514", "0.60243464", "0.6018449", "0.60043854", "0.59973645", "0.5989315", "0.59889734", "0.5982552", "0.59797454", "0.59737736", "0.59737647", "0.59610325", "0.5947572", "0.5945407", "0.59387535", "0.5922697", "0.5913449", "0.59114033", "0.5889368", "0.5878626", "0.587578", "0.5862244", "0.5861993", "0.58575135", "0.58515143", "0.5848045", "0.5840225", "0.5835227", "0.58291364", "0.5827823" ]
0.7291966
6
=> 14.0 A more elegant approach
def elegant_calc(expr) expr.split.each_with_object([]) { |e, a| if e.match(/\d+/) a << e.to_f else y, x = a.pop, a.pop a << x.send(e, y) end }.last || 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def verdi; end", "def vat_number; end", "def __numval_optkeys\n super() + ['closeenough']\n end", "def _reduce_479(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def default_v_score ; raise 'not implemented'; end", "def _reduce_21(val, _values, result)\n n = val[0]; result = n.count('.') > 0 ? n.to_f : n.to_i \n result\nend", "def _reduce_436(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def prec_i() end", "def v10_14\n return @v10_14\n end", "def terpene; end", "def major=(_arg0); end", "def precision; end", "def dv; end", "def _reduce_522(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n\n result\nend", "def calculated; end", "def minor; end", "def minor; end", "def minor; end", "def fast_ready_bonus\n [100, features_sum(:fast_ready)].min / 100.0\n end", "def anchored; end", "def target_version; end", "def conversion_precision; end", "def version_mismatch_detected\n end", "def villian; end", "def minimum_strictness; end", "def test_that_px_return_is_accurate\n end", "def target_version=(_arg0); end", "def _reduce_478(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def private; end", "def version\na = unpack\nv = (a[2] & 0xF000).to_s(16)[0].chr.to_i\nreturn v if (1..5).include? v\nreturn nil\nend", "def prec_f() end", "def suitable_halfs\n required_amount\n end", "def _reduce_590(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\nend", "def alternatives; end", "def calculate_versions\n tags = `git for-each-ref --sort='*authordate' --format='%(refname:short)' refs/tags/`.split(\"\\n\")\n @last = tags.select {|l| l =~ /(^#{@prefix}-|\\.0$)/ }.last.gsub(/^#{@prefix}-/, '')\n @current = @last\n\n pemajor, major, minor = @last.split('.')\n minor = minor.to_i + 1\n quarter = major.to_i + 1\n @next = \"#{pemajor}.#{major}.#{minor}\"\n @quarter = \"#{pemajor}.#{quarter}.0\"\nend", "def completeness\n return 1.0 if main?\n \n main_translations_count = Locale.find_main_cached.translations.count\n main_translations = Locale.find_main_translations\n local_translations = translations.inject({}) { |memo, tr| memo[\"#{tr.namespace}/#{tr.tr_key}\"] = tr; memo }\n \n outdated = 0\n main_translations.each do |key, main_tr|\n if !local_translations[key] || (local_translations[key].updated_at && main_tr.updated_at && local_translations[key].updated_at < main_tr.updated_at)\n outdated += 1\n end\n end\n (main_translations_count - outdated).to_f / main_translations_count\n end", "def major; end", "def major; end", "def major; end", "def v13_0\n return @v13_0\n end", "def minor=(_arg0); end", "def method_731(base); end", "def low_toms\n [43]\n end", "def _reduce_461(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_461(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_461(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_461(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_461(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_696(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\nend", "def palladius_version\n\t:TODO\nend", "def utilityF(delta)\n\treturn 1.0 if delta <= 0\n\treturn 2.0 ** (-delta / 30.0)\nend", "def _reduce_520(val, _values, result)\n result = @builder.accessible(val[0])\n \n result\nend", "def diff1; end", "def _reduce_336(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_336(val, _values, result)\n result = val[1]\n \n result\nend", "def float_platform(votes)\n tot_pos = tot_neg = saldo = platform = prev_saldo = 0\n prev_time = last_pivot = nil\n\n votes.each_with_index do |vote|\n saldo += vote.vector\n tot_pos += vote.vector if vote.vector > 0\n tot_neg -= vote.vector if vote.vector < 0\n\n if saldo == 0 or prev_time.nil?\n platform = 0\n else\n duration = vote.casted_at - prev_time\n if (prev_saldo <=> 0) == (saldo <=> 0) # if we do not cross (or touch) the time axis\n platform += calculate_surface(duration, prev_saldo, vote.vector)\n else\n duration_till_crossing = -prev_saldo / ((saldo - prev_saldo) / duration)\n platform = 0.5 * saldo * (duration - duration_till_crossing)\n end\n end\n\n puts \"#{i} - #{vote.casted_at} - float_platform: #{\"%.2f\" % platform}, pos-neg: #{tot_pos}-#{tot_neg} (#{\"%.2f\" % (saldo.to_f/(tot_pos+tot_neg))}), last pivot at: #{last_pivot or '<never>'}\"\n\n prev_time, prev_saldo = vote.casted_at, saldo\n end\n platform\nend", "def _reduce_501(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def _reduce_501(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def _reduce_501(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def _reduce_501(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def _reduce_581(val, _values, result)\n result = val[1]\n\n result\nend", "def suivre; end", "def _reduce_524(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n\n result\nend", "def user_os_complex\r\n end", "def v10_13\n return @v10_13\n end", "def major_version; end", "def _reduce_569(val, _values, result)\n result = :\"**#{val[1]}\"\n \n result\nend", "def positive; end", "def positive; end", "def schumann; end", "def _reduce_545(val, _values, result)\n result = @builder.accessible(val[0])\n\n result\nend", "def _reduce_593(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\nend", "def _reduce_712(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\nend", "def _reduce_441(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_441(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_441(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_441(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_441(val, _values, result)\n result = val[1]\n \n result\nend", "def joltageDiff(input)\n # add my input device with rating +3\n input.append(input.max + 3)\n arr = input\n .sort\n .reverse\n \n diffs = arr\n .map.with_index{ |n, i|\n if i < arr.size - 1\n n - arr[i+1]\n end\n }\n diffs.pop # remove last element\n # puts diffs.sort\n counts = [0, 0, 0]\n counts[0] = diffs.select{ |n| n == 1 }.size + 1 # fuck knows why this is here.. #dirtyhack\n counts[1] = diffs.select{ |n| n == 2 }.size\n counts[2] = diffs.select{ |n| n == 3 }.size\n #puts counts\n return counts\nend", "def _reduce_248(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_248(val, _values, result)\n result = val[0]\n \n result\nend", "def weight; end", "def _reduce_563(val, _values, result)\n _, v1 = val\n\n result = s(:dot2, nil, v1).line v1.line\n\n result\nend", "def v6_0\n return @v6_0\n end", "def _reduce_542(val, _values, result)\n _, v1 = val\n\n result = s(:dot2, nil, v1).line v1.line\n\n result\nend", "def diff2; end", "def feature_version(feature); end", "def probers; end", "def cop_to_kw_per_ton(cop)\n \n return 3.517/cop\n \nend", "def key_for_min_value\n end", "def _reduce_728(val, _values, result)\n result = [:dot, val[0][1]]\n\n result\nend", "def _reduce_437(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def _reduce_437(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend", "def _reduce_518(val, _values, result)\n result = @builder.accessible(val[0])\n \n result\nend", "def _reduce_473(val, _values, result)\n result = s(:lasgn, val[0])\n \n result\nend", "def _reduce_717(val, _values, result)\n result = val[1]\n \n result\nend", "def version_helper=(_arg0); end", "def version_helper=(_arg0); end", "def version_helper=(_arg0); end", "def conversion_precision=(_arg0); end", "def _reduce_118(val, _values, result)\n result = @builder.symbol_internal(val[0])\n \n result\nend" ]
[ "0.5340474", "0.52942824", "0.52820003", "0.5267194", "0.52660584", "0.5245146", "0.5239247", "0.51868105", "0.51832074", "0.5180995", "0.5165528", "0.5160624", "0.51514214", "0.5136787", "0.51276714", "0.512177", "0.512177", "0.512177", "0.51167417", "0.5091326", "0.5088698", "0.5085786", "0.50835913", "0.50557476", "0.50556594", "0.5053897", "0.50463337", "0.5045184", "0.50328743", "0.50224715", "0.50140595", "0.5007827", "0.50071526", "0.49988198", "0.49948433", "0.49891558", "0.4986454", "0.4986454", "0.4986454", "0.49853426", "0.49834242", "0.49804598", "0.49794868", "0.49790573", "0.49790573", "0.49790573", "0.49790573", "0.49790573", "0.49780098", "0.49757135", "0.49753252", "0.49750087", "0.49747282", "0.49617884", "0.49617884", "0.49573988", "0.49560407", "0.49560407", "0.49560407", "0.49560407", "0.49518374", "0.4950985", "0.49497923", "0.49457252", "0.49402174", "0.49399853", "0.49382514", "0.493471", "0.493471", "0.49346492", "0.49327466", "0.49327153", "0.4930236", "0.49298853", "0.49298853", "0.49298853", "0.49298853", "0.49298853", "0.49298242", "0.49278954", "0.49278954", "0.49243188", "0.49234876", "0.49231797", "0.49223968", "0.49220273", "0.4920096", "0.49168038", "0.4914219", "0.49093318", "0.4907713", "0.4906128", "0.4906128", "0.49018705", "0.49002615", "0.48999232", "0.48985046", "0.48985046", "0.48985046", "0.48935792", "0.4891153" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_place_permission @place_permission = PlacePermission.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_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 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 action; end", "def action; end", "def action; end", "def action; end", "def action; 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 before_dispatch(env); end", "def process_action(...)\n send_action(...)\n 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 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 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 setup\n @setup_proc.call(self) if @setup_proc\n end", "def config(action, *args); 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 before_action \n end", "def action\n end", "def setup\n # override this if needed\n end", "def matt_custom_action_begin(label); 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 setup_signals; 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 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 setup\n #implement in subclass;\n end", "def initialize(*args)\n super\n @action = :set\nend", "def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end", "def lookup_action; 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 setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def action_target()\n \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 setup(&blk)\n @setup_block = blk\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 callback_phase\n super\n end", "def advice\n end", "def call\n setup_context\n super\n end", "def _handle_action_missing(*args); end", "def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end", "def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend", "def duas1(action)\n action.call\n action.call\nend" ]
[ "0.6162554", "0.60452986", "0.5945278", "0.59169763", "0.58877826", "0.5834763", "0.5775349", "0.5704972", "0.5704972", "0.56543803", "0.5621491", "0.5427202", "0.54093206", "0.54093206", "0.54093206", "0.53975695", "0.53776276", "0.53562194", "0.5340594", "0.5337824", "0.5328757", "0.5310255", "0.5300339", "0.5298796", "0.5295774", "0.5256034", "0.5243039", "0.5236007", "0.5235239", "0.5235239", "0.5235239", "0.5235239", "0.5235239", "0.52321917", "0.5227032", "0.52216744", "0.5216349", "0.52161187", "0.5210265", "0.5207244", "0.5177388", "0.5177142", "0.51747334", "0.516293", "0.51629275", "0.5155534", "0.51540613", "0.515197", "0.5151636", "0.5145279", "0.51380795", "0.5135777", "0.5117378", "0.5115066", "0.5115066", "0.5110235", "0.5106418", "0.50917816", "0.50909185", "0.50855017", "0.5082105", "0.506359", "0.5055345", "0.50546116", "0.50523037", "0.50523037", "0.50327307", "0.5024364", "0.5021113", "0.50174654", "0.50163317", "0.5000553", "0.50002855", "0.49991882", "0.49905527", "0.49905527", "0.49849054", "0.4982546", "0.4980941", "0.4979153", "0.49693102", "0.4967172", "0.49594432", "0.49564302", "0.49552485", "0.49533385", "0.49506924", "0.49452737", "0.49442786", "0.49347955", "0.49341312", "0.49295264", "0.49261844", "0.4925649", "0.49251428", "0.4920729", "0.49177617", "0.4916373", "0.49158472", "0.4915794", "0.49156648" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def place_permission_params params.fetch(:place_permission, {}).permit(:user_id, :role).merge(:place => @place) 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
def about render 'about' => if the only logic in an action can be done implicitly, the whole action can be implied end GET /pets
def index @pets = Pet.all # render 'index' => where render is a method call and 'index' is an argument # rails will implicitly try to render a view template with the same name as the action end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def about; render; end", "def about\n respond_to do |format|\n format.html { render :about }\n end\n end", "def about\n\t\tabout_post = Post.of_type(Post::POST_TYPE_ABOUT)\n\t\tif about_post.present?\n\t\t\tgon.post = about_post.as_json\n\t\t\trender :show\n\t\telse\n\t\t\tredirect_to :root\n\t\tend\n\tend", "def about\n\tend", "def about\n\tend", "def about\n # Static Page\n end", "def about\n\n end", "def about\n\n end", "def about\n\n end", "def about\n\n end", "def about\r\n end", "def about\n end", "def about\n end", "def about\n end", "def about\n end", "def about\n end", "def about\n end", "def about\n end", "def about\n end", "def about\n end", "def about\n end", "def about\n end", "def about\n end", "def about\n end", "def about\n end", "def about\n end", "def about\n end", "def about\n end", "def about\n end", "def about\n end", "def about_us\n render(:about_us, layout:false) and return\n end", "def about\n\n \tend", "def about\n @about_object = instance_variable_get(\"@#{controller_name.singularize}\")\n render template: \"/dash/base/about\"\n end", "def about\n end", "def about\n \n end", "def about\n respond_to do |format|\n format.html # about.html.erb\n format.xml { render :xml => nil }\n end\n end", "def about\n render :template =>\"bodysize/about\"\n end", "def about; end", "def about; end", "def app_about\n end", "def about\n\t\tcontent = Content.first.about_content\n\t\tif content.present?\n\t\t# response to the JSON\n \t render json: { success: true, response: {about_content: content.as_json} },:status=> 200\n\t else\n\t render :json=> { success: false, message: \"About Content is not present\" },:status=> 203\n\t end \n\tend", "def about\n @current_nav_identifier = :about\n params[:name] = @current_nav_identifier\n set_page\n render 'show'\n end", "def about\n # STUB\n end", "def about\n @title = \"about\"\n end", "def help\n \n render :patial=>\"_help\"\n end", "def introduction\n #DEFAULT ROUTE DO NOT DELETE\n render 'layouts/application'\n end", "def about\n\t\tunless params[:result].nil?\n\t\t\t@result = params[:result]\n\t\tend\n\n\t\t@about = Static.where(\"title = ?\", \"about\").first\n\tend", "def show\n # render plain: params\n @owner = User.find_by_id(params[:id])\n # render plain: @owner.first_name\n @owner_pet =@owner.pets\n # if @owner_pet.exists?\n # render plain: @owner_pet[0].name\n # else\n # render plain: \"This user has no pets :(\"\n # end\n end", "def helpGeneral\n \n render :patial=>\"helpGeneral\"\n \n end", "def index\n render :index if @people\n render :index_for_patrons if @patrons\n end", "def about\n @user = current_user\n @content = UserContent.find_by_user_id(@user.id) # Originally created on 'User' creation. Check 'User' Model.\n # @content = current_user.user_contents\n \n respond_to do |format| \n if params[:ajax] == \"true\" # Request came from ajax. Respond without layout.\n format.html { render :layout => false } # about.html.erb\n else\n format.html # about.html.erb WITH layout\n end\n end\n end", "def restrict_access\n render :\"/home/http_404\" unless @pet && @pet.user == current_user\n end", "def echo_action\n endpoint = get_end_point request.method, request.path\n if endpoint\n endpoint_response = prepare_response endpoint\n render json: endpoint_response.first, status: endpoint_response.second\n else\n render json: { errors:[\n {\n \"code\": \"not_found\",\n \"detail\": \"Requested page `#{request.path}` does not exist\"\n }\n ]\n } , status: :not_found\n end\n \n end", "def help\n #render(text: \"Help method in StaticPages controller class\");\n end", "def show\n @resource = @pet\n @menu_tpl = 'menu'\n respond_to do |format|\n format.html do\n @card_sections = {\n sidebar: [\n { tpl: 'avatar' },\n { tpl: 'banner' }\n ],\n body: [\n { tpl: 'pets/info_title' },\n { tpl: 'pets/info_text' },\n { tpl: 'pets/advert_brief' },\n { tpl: 'about', title: 'About me' }\n # { title: 'My pedigree', tpl: 'bcards', opt: { resource: @user.pets, size: 'md'} },\n # { title: 'My dignities', tpl: 'bcards', opt: { resource: @user.pets, size: 'lg'} },\n # { title: 'My awards', tpl: 'bcards', opt: { resource: @user.pets, size: 'lg'} },\n ]\n }\n render 'card'\n end\n format.json { render :show }\n end\n end", "def about_me\n\tend", "def about\n render :layout => 'centered_page'\n end", "def show\n @pet = Pet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @pet }\n end\n end", "def show\n\n if !params[:id].nil?\n pet = Pet.find_by_id(params[:id])\n if pet\n render json: pet, include: :user, status: :ok\n else\n render json: {message: 'Pet doesn\\'t exist'}, status: :bad_request\n end\n else\n render json: {message: 'There was an error getting pet detail, please try it again'}, status: :bad_request\n end\n end", "def tos_faq \n render :action => \"tos_faq\", :layout => \"application\"\n end", "def tos_faq \n render :action => \"tos_faq\", :layout => \"application\"\n end", "def tos_faq \n render :action => \"tos_faq\", :layout => \"application\"\n end", "def before_GET(req)\n super\n @subsection = 'vehicle-list'\n @title = \"Welcome back #{dealership(req).name}\"\n end", "def show\n index\n render :index\n return false\n #redirect_to faqs_path\n end", "def show\n @pet = Pet.find_by(id: params[:id])\n if @pet\n render json: @pet\n else\n render json: {}, status: 404\n end\n end", "def show\n render params[:id]\n rescue ActionView::MissingTemplate\n raise ActionController::RoutingError, 'Help not found.'\n end", "def about_us\n\n\tend", "def about?\n env[\"SCRIPT_NAME\"] == '/about'\n end", "def show\n# Following is an example of a reliable render/redirect\n=begin\n @cars = Car.find(:make)\n if @car.nil?\n @car = Car.all\n flash.now[:alert] = \"The car is not found\"\n render :index\n end\n=end\n end", "def question\n \t\trender 'question'\n \tend", "def show\n @pet = Pet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pet }\n end\n end", "def show\n @pet = Pet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pet }\n end\n end", "def about\n\t\t\tputs \"Here is our potential Santa for the season.\"\n\t\t\tputs \"They have changed their name to #{@name}.\"\n\t\t\tputs \"They identify themself as #{@gender}\"\n\t\t\tputs \"They are #{age} years young\"\n\t\t\tputs \"Soon they will be celebrating their #{celebrate_birthday(100)}th birthday,\"\n\t\tend", "def show\n @title = @pet.name + ' | Mascotas' \n @owner = User.find(@pet.user_id)\n end", "def set_about\n @about = about.find(params[:id])\n end", "def about\n\t\tputs \"Make: \" + @make\n\t\tputs \"Model: \" + @model\n\t\tputs \"Miles: \" + @miles.to_s\n\t\tputs \"Type: \" + @type\n\t\tputs \"Color: \" + @color\n\t\tputs \"Year: \" + @year.to_s\n\t\tif @used\n\t\t\tputs \"The #{@make} #{@model} is used.\"\n\t\telse\n\t\t\tputs \"The #{@make} #{@model} is new\"\n\t\tend\n\tend", "def index\n list #call the action\n render('list') #render the correct template not 'index'\n end", "def about_us\n end", "def about_us\n end", "def show\n @pet = Pet.find(params[:id])\n end", "def show\n @thing = Thing.find(params[:id])\n @thing.description = Redcarpet::Markdown.new(Redcarpet::Render::HTML, :autolink => true, :space_after_headers => true).render(@thing.description)\n page_title \"About the \" + @thing.name + \" thing\"\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @thing }\n end\n end", "def about\n\t\t@user = current_user\n\tend", "def create\n flash[:notice] = 'About Created' if @about.save\n respond_with @about\n end", "def show\n @post.increase_view\n @related = @post.related_posts\n puts @related.inspect\n case params[:cat]\n when 'gestores'\n @cat = 'gestores'\n render 'show_gestores'\n when 'mobilizadores'\n @cat = 'mobilizadores'\n render 'show_mobilizadores'\n when 'familias'\n @cat = 'familias'\n render 'show_familias'\n when 'professores'\n @cat = 'professores'\n render 'show_professores' \n end\n \n end", "def about\n @toc_id = 'about'\n end", "def url_for_me(action)\n if action == 'show'\n \"/articles/#{to_param}\"\n else\n \"/articles/#{to_param}/#{action}\"\n end\n end", "def show\n @recipes = @diet.recipes.reorder(diet_order_by(\"recipes\")).paginate(page: params[:page], per_page: 2)\n @title = \"Recipes using: \" + @ingredient.name\n # goto render /views/diets/show.html.erb using /shared/_show_recipes using @recipes, @title\n end", "def show\n if can? :read, @status\n render action: :show\n else\n render file: 'public/pleaseregister'\n end\n end", "def companie\n \tflash[:notice] = \"Learn to spell!!!!\"\n \tredirect_to :controller => 'about', :action => 'company'\n end", "def index\n # if its a nested route \n # render nester resource data \n # else \n\n if params[:genre_id] && @genre = Genre.find_by_id(params[:genre_id]) # to know its nested \n # @genre = Genre.find_by_id(params[:genre_id])\n @animes = @genre.animes\n elsif params[:user_id] && @user = User.find_by_id(params[:user_id])\n @animes = @user.animes\n else \n @error = \"That genre does not exist yet.\" if params[:genre_id] \n @error1 = \"That user does not exist yet.\" if params[:user_id]\n @animes = Anime.alpha\n end \n end", "def me\n render :show, status: :ok\n end", "def set_about\n @about = About.find(params[:id])\n end", "def index\n @people = Person.all #this function calls selects all from people in the people database\n # one of two things we need to do in ruby, render code or redirect, making a views page of the index.html.erb, has to be a file that can be rendered\n #render\n #redirect\n end", "def about\n @abouts = Accesory.where(acc_type: \"About\")\n end", "def set_about\n @about = About.find(params[:id])\n end", "def set_about\n @about = About.find(params[:id])\n end", "def about_us\n # it's deliberate that there's no code in here... but we should have a helpful error when we request the URL again\n end", "def show\n @about_page = AboutPage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @about_page }\n end\n end", "def show\n \tif !@person\n \t\tflash[:message] = \"Person not found\"\n \tend\n \trender action: \"edit\"\n end", "def show\n\t\t#show now run by find_book and before_action\n\t\t#keeps code dry\n\tend" ]
[ "0.7644059", "0.6880763", "0.6832566", "0.6722207", "0.6722207", "0.6699893", "0.66456723", "0.66456723", "0.66456723", "0.6621492", "0.6586283", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.6582862", "0.658155", "0.6559732", "0.65248626", "0.64814335", "0.64754075", "0.6340841", "0.6323653", "0.622679", "0.622679", "0.62151587", "0.6190202", "0.61795914", "0.6052913", "0.59985244", "0.59919757", "0.59658545", "0.59024733", "0.5893116", "0.5818235", "0.5798321", "0.57717496", "0.57640636", "0.5761265", "0.5720888", "0.5692879", "0.56668204", "0.56373316", "0.56309974", "0.56126684", "0.5610801", "0.5610801", "0.5610801", "0.56032956", "0.5584751", "0.5572739", "0.5571593", "0.5570483", "0.5567351", "0.55570036", "0.554881", "0.5543711", "0.5543711", "0.5541754", "0.5532657", "0.55192083", "0.55150175", "0.5513785", "0.5496873", "0.5496873", "0.54864746", "0.54854596", "0.54841924", "0.548192", "0.5468747", "0.546846", "0.54670674", "0.54648685", "0.5461189", "0.5453556", "0.54531157", "0.54476476", "0.5445527", "0.5445462", "0.54358727", "0.54356253", "0.54356253", "0.5435522", "0.54296064", "0.54294723", "0.5423502" ]
0.6040009
43
strong params that take advantage of Rails security features to prevent e.g. SQL injection attacks
def pet_params params.require(:pet).permit(:name, :species, :year_of_birth, :good_with_kids) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def user_strong_params\n html_safe(params[:user]).strip\n end", "def quote_params\n params.permit!\n end", "def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def student_params(*args) #is the helper method \n\n\t\tparams.require(:student).permit(*args)\n\t\t#uses .require and .permit methods as stronger params to prevent hacks through inspect element right click edit html \n\t\t#require restricts, permit allows, and *args is for the custom arguments\n\tend", "def safe_params\n safe_attributes = %i[name key]\n params.require(:role).permit(safe_attributes)\n end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "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 quote_params(params); end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def quotation_params\n params[:quotation].permit!\n end", "def strong_params\n params.require(:community).permit(param_whitelist)\n 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 sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def secret_params\n params.require(:secret).permit(:name, :value)#.merge(user_id: current_user.id)\n end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end", "def activity_params \n \n raw_parameters = { \n :activity_Name => \"#{params[:activity_name]}\",\n :active => \"#{params[:active]}\",\n :activity_description => \"#{params[:activity_description]}\",\n :is_page => \"#{params[:is_page]}\"\n }\n parameters = ActionController::Parameters.new(raw_parameters)\n parameters.permit( :activity_Name, :active, :activity_description, :is_page)\n \n end", "def strong_params_keys\n [key]\n end", "def some_thing_params\n params.require(:some_thing).permit(:val)\n end", "def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end", "def safe_params\n params.require(:youtube_search).permit(:search_terms, :alert_on_new_result)\n end", "def engagement_params\n #params.require(:branch).permit(:name, :active, :user_id)\n\n raw_parameters = { :name => \"#{params[:name]}\", :active => \"#{params[:active]}\", :user_id => \"#{params[:user_id]}\", :description => \"#{params[:description]}\" }\n parameters = ActionController::Parameters.new(raw_parameters)\n parameters.permit(:name, :active, :description, :user_id)\n \n end", "def user_params\n\t\tparams.permit(:food_store_id, :foodquality, :pricing, :service, :ambience, :comment)\n end", "def good_params\n params.permit(:title)\n end", "def query_params\n # Require auth here: ex params.require(:auth)\n params.permit(:id,:yelp_user_id)\n end", "def backend_user_params\n params.permit!\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def safe_params\n params.require(:safe).permit(:game_id, :sTime, :player_id)\n end", "def strong_parameters\n\t\t\tattrs = self.attribute_names - [\"created_at\", \"updated_at\", \"id\"]\n\t\t\tattrs.push(:_color) if colored? # add the color attribute to the permitted attributes if the object is colorable\n\t\t\tif is_encrypted? # add the color attribute to the permitted attributes if the object is colorable\n\t\t\t\tattrs.push(:_inki_password) \n\t\t\t\tattrs.push(:_inki_password_confirmation) \n\t\t\tend\n\t\t\tattrs.collect do |a|\n\t\t\t\ta.to_sym\n\t\t\tend\n\t\tend", "def strong_params\n params.require(:applicant).permit(\n :first_name,\n :last_name,\n :email,\n :resume,\n :website_url,\n :linkedin_url,\n :phone_number\n )\n end", "def squeak_params\n # {controller=>\"squeaks\", action=>\"create\", id=>3, squeak=>{body=>\"this is the body\", author_id=>7}}\n params.require(:squeak).permit(:body, :author_id)#with authentification, you wouldn't put author_id here\n # what this means:\n # top level of key in the hash, pointing to antoher hash of key of body and author_id pointing to corresponding values\n # params:\n # <ActionController::Parameters {\"squeak\"=>{\"body\"=>\"I am a squeak\", \"author_id\"=>\"1\"}, \"controller\"=>\"squeaks\", \"action\"=>\"create\"} permitted: false>\n # squeak_params:\n # <ActionController::Parameters {\"body\"=>\"I am a squeak\", \"author_id\"=>\"1\"} permitted: true>\n # \n end", "def foo_params\n params.require(:foo).permit(:text, :user_id)\n end", "def query_params\n params.permit(:aql)\n end", "def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end", "def update_sanitized_params\n\t\t\tdevise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:name, :email, :password, :password_confirmation)}\n\t\tend", "def sample_params\n\t\t params.permit(\n\t\t \t:user_id,\n\t\t \t:contact_id, \n\t\t \t:company_id, \n\t\t \t:inquiry_id, \n\t\t \t:quote_id, \n\t\t \t:product_id, \n\t\t \t:name, \n\t\t \t:status, \n\t\t \t:note_to_receiver, \n\t\t \t:note_to_sales, \n\t\t \t:price, \n\t\t \t:lead_time, \n\t\t \t:street, \n\t\t \t:suite,\n\t\t \t:city, \n\t\t \t:state, \n\t\t \t:zip_code, \n\t\t \t:shipping_method, \n\t\t \t:drop_ship, \n\t\t \t:custom_color, \n\t\t \t:custom_length, \n\t\t \t:custom_width, \n\t\t \t:custom_other, \n\t\t \t)\n\t\t end", "def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end", "def will_params\n wills = params.select { |k, _v| k.starts_with?(\"vault_entry_\") }\n permitted_params = {}\n wills.keys.each do |will|\n permitted_params[will] = [:id, :title, :executor_id, :notes, :agent_ids, :document_id, primary_beneficiary_ids: [], secondary_beneficiary_ids: [], share_ids: [], share_with_contact_ids: []]\n end\n wills.permit(permitted_params)\n end", "def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def user_params\n params.permit(\"name\", \"email_id\", \"password\", \"password_confirmation\",\"id\",\"remember\")\n end", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def catch_phrase_params(*args)\n params.require(:catch_phrase).permit(*args)\n end", "def secure_params\n params.require(:chat_room).permit(:name, :tagline)\n end", "def resource_params\n params.require(model_name.underscore.intern).permit(*@model.column_names.map(&:intern))\n end", "def post_params\n params.require(:post).permit(:title, :body, :author, :public) #allows a post to only be submitted with these params - can break the parentheses into multiple lines\n end", "def sanitize_params\n # @where[/\\w*=\\'(.*)\\'/].gsub(/\\'/, \"''\")\n # @where.sub!(/\\w*=\\'(.*)\\'/, { |s| puts s })\n end", "def quotation_params\n params.require(:quotation).permit!\n end", "def handle_query_param\n if params[:query].is_a? ActionController::Parameters \n params[:query].permit!\n params[:query].to_h\n else\n params[:query]\n end\n end", "def escape_params\n params.require(:escape).permit(:user_id, :rescue_title, :dollar_amount, :location, :description, :requirements)\n end", "def user_params #este metodo SE PUEDE LLAMAR COMO QUIERAS, pero es necesario para que al crear un objeto se autorice su creacion (porque si no nos podrían meter codigo malicioso)\n\t\tparams.require(:user).permit(:name, :email, :password)\n\tend", "def user_params\n allowed_params = [:username, :email, :jabber_id, :jabber_otr_fingerprint, :avatar]\n allowed_params << [:password, :password_confirmation] unless params[:user][:password].blank?\n allowed_params << [:role] if current_user.moderator_or_admin?\n allowed_params << [:tenant_ids => []] if current_user.admin?\n allowed_params << [:user_ids => []] if current_user.moderator_or_admin?\n params.require(:user).permit(allowed_params)\n end", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def sanitize_params\n if params[:transaction].present?\n %w[user_id year].each { |atr| params[:transaction].delete(atr) }\n end\n end", "def less_active_member_params\n clean_params = params.require(:less_active_member).permit(:surname, :given_name, :current_address, :new_address, :new_phone, :reference, :new_note, :resources, tag_list: [])\n clean_params.merge!({current_user_id: current_user.id}) unless current_user.nil?\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\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 user_params\n params.permit(\n :username,\n :password\n )\n end", "def billable_params\n #params.require(:branch).permit(:name, :active, :user_id)\n\n raw_parameters = { :name => \"#{params[:name]}\", :description => \"#{params[:description]}\", :active => \"#{params[:active]}\" }\n parameters = ActionController::Parameters.new(raw_parameters)\n parameters.permit(:name, :description, :active)\n \n end", "def opp_params #Purpose of the opp params is for security purposes against hackers these are strong parameters\n\t\tparams.require(:opp).permit(:title, :text)\n\tend", "def model_params\n \tparams.require(:school).permit(\n \t\t:school_name,\n \t\t:user_name,\n \t\t:password,\n \t\t:address_line_1,\n \t\t:address_line_2,\n \t\t:city,\n \t\t:state,\n \t\t:zip,\n \t\t:phone,\n \t\t:teachers_attending\n \t)\n end", "def secret_code_params\n params.require(:secret_code).permit(:secret_code, :user_id)\n end", "def user_pleasure_params\n params.permit(:title)\n end", "def csrfattack_params\n params.require(:csrfattack).permit(:professor, :vote)\n end", "def assessor_params\n params.require(:assessor).permit!\n end", "def form_params\n # Remove role and privilege ids as these are managed by the app not by\n # the active record associations\n params[:user].delete :role_ids\n params[:user].delete :privilege_ids\n params.require(:user).permit(user_allowable_params)\n end", "def active_code_params\n params[:active_code].permit\n end", "def permitted_params\n params.permit user: [:email, :password, :password_confirmation, :remember_me, :barcode, :alt_barcodes, :first_name, \n :last_name, :alt_email, :school_id]\n end", "def secure_params\n { message: params[:new_message], user: current_user, chat_room: active_room }\n end", "def account_params\n params_syms = %I[\n id\n first_name\n last_name email\n phone_number\n address1\n address2\n city\n state\n zip\n ]\n\n params.require(:account).permit(*params_syms).reject{ |_, v| v.blank? }\n end", "def blog_params\n blog = params.require(:blog).permit(:raw_title, :raw_body)\n blog[:user_id] = current_user.id\n blog\n end", "def user_params\n\t\tparams.permit(:facebook_id, :email, :password, :password_confirmation, :role, :first_name, :last_name, :gender, :age)\n\tend", "def params_permit\n params.permit(:id)\n end", "def pointless_params\n params.require(:pointless).permit(:title, :content)\n end", "def user_params\n unless params[:user][:admin_passphrase].blank?\n params[:user][:admin_passphrase_digest] =\n Digest::SHA2.hexdigest(params[:user][:admin_passphrase])\n end\n params.require(:user).permit(:firstname, :lastname, :email, :is_female,\n :phone, :birth_date, :password, :password_confirmation,\n :postcode, :address_line_1, :address_line_2, :country,\n :admin, :admin_passphrase_digest)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def event_params\n params[:title] = encrypt_param params[:title]\n params.permit(:title, :from, :frequency, :completed, :user_id)\n end", "def student_params\n params.require(:student).permit(:fname, :lname, :email, :password, :isAdmin)\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def permit(*permitted)\n hardened_params = params.dup\n\n hardened_params.keep_if { |k, _v| permitted.flatten.include?(k.to_sym) }\n\n hardened_params.symbolize_keys\n end", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def capsule_params #strong params\n params.require(:capsule).permit(:name) # param requires a key of capsule and within that key permit a key of name \n #permit a key of name\n end", "def business_params\n #params.require(:branch).permit(:name, :active, :user_id)\n\n raw_parameters = { :name => \"#{params[:name]}\", :active => \"#{params[:active]}\", :user_id => \"#{params[:user_id]}\", :description => \"#{params[:description]}\" }\n parameters = ActionController::Parameters.new(raw_parameters)\n parameters.permit(:name, :active, :description, :user_id)\n \n end", "def user_params\n params.require(:user).permit(%i[email password role full_name phone_number company_name company_address])\n end", "def my_sql_params\n params.require(:my_sql).permit(:title, :Content)\n end", "def params_user_define\n params.permit(\n :user_id,\n :name,\n :drink_id,\n :ingredient_volume_alcohol,\n :ratio\n )\n end", "def sanitize_params(params = params)\n params = walk_hash(params) if params\n end", "def user_params\n params.require(:data).permit!\n end", "def user_params\n params.require(:user).permit!\n end", "def user_params\n params.require(:user).permit!\n end", "def user_params\n params.require(:user).permit!\n end", "def mytbl_params\n params.require(:mytbl).permit(:email, :paswword, :hobby)\n end" ]
[ "0.726364", "0.72509843", "0.7165954", "0.7023828", "0.68842524", "0.68697464", "0.68058985", "0.6786618", "0.6765251", "0.6735566", "0.6719693", "0.66753376", "0.66280156", "0.66228265", "0.6579734", "0.6567968", "0.6559923", "0.6532757", "0.6505881", "0.6501059", "0.64659244", "0.64653987", "0.6455337", "0.64211786", "0.64098024", "0.6398044", "0.6393328", "0.6390225", "0.6382816", "0.63673556", "0.63621783", "0.63616914", "0.6348148", "0.63438886", "0.63291615", "0.632524", "0.6308905", "0.62912464", "0.62875384", "0.625558", "0.62525815", "0.62486786", "0.6248024", "0.6234732", "0.62334967", "0.6231175", "0.6228943", "0.62286675", "0.6221531", "0.62187785", "0.62112224", "0.62105244", "0.62078434", "0.6205567", "0.6205106", "0.61963165", "0.61838937", "0.61825556", "0.61765933", "0.61753124", "0.6173519", "0.6172952", "0.6161719", "0.6160687", "0.61507034", "0.61482996", "0.6143457", "0.6143087", "0.61420137", "0.614022", "0.6136768", "0.6124673", "0.6115331", "0.6110573", "0.6108868", "0.6106957", "0.61007077", "0.6100639", "0.60982466", "0.60979074", "0.60956496", "0.6088304", "0.6085008", "0.6084697", "0.6080086", "0.6076084", "0.6074251", "0.60700864", "0.60677105", "0.60627997", "0.606226", "0.6059627", "0.60575163", "0.60559976", "0.6054875", "0.6053775", "0.605083", "0.6048065", "0.6048065", "0.6048065", "0.60476893" ]
0.0
-1
look up how to do this without copy/pasting other method
def average_credit_rating if average_credit_score > 760 "excellent" elsif average_credit_score > 725 "great" elsif average_credit_score > 660 "good" elsif average_credit_score > 560 "mediocre" else "bad" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def probers; end", "def anchored; end", "def schubert; end", "def suivre; end", "def offences_by; end", "def formation; end", "def stderrs; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def terpene; end", "def who_we_are\r\n end", "def malts; end", "def operations; end", "def operations; end", "def villian; end", "def offences_by=(_arg0); end", "def custom; end", "def custom; end", "def same; end", "def transformations; end", "def ignores; end", "def pos() end", "def pos() end", "def pos() end", "def pos() end", "def apply\n\t\t\n\tend", "def apply\n\t\t\n\tend", "def calculated; end", "def trd; end", "def identify; end", "def isolated; end", "def isolated; end", "def rassoc(p0) end", "def celebration; end", "def probers=(_arg0); end", "def parts; end", "def parts; end", "def parts; end", "def weber; end", "def berlioz; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def pos; end", "def transform; end", "def jack_handey; end", "def intensifier; end", "def ravel; end", "def flag; end", "def schumann; end", "def strain; end", "def surge; end", "def gounod; end", "def ismn; end", "def spice; end", "def bs; end", "def silly_adjective; end", "def first; end", "def first; end", "def calls; end", "def calls; end", "def spouse; end", "def invention; end", "def r; end", "def r; end", "def original_result; end", "def original; end", "def returns; end", "def verdi; end", "def sub_d\n end", "def apply; nil; end", "def starship; end", "def extra; end", "def operation; end", "def refutal()\n end", "def king_richard_iii; end", "def placebo?; false end", "def herald; end", "def alternatives; end", "def transforms; end", "def getc() end", "def getc() end", "def getc() end", "def alt; end", "def processor; end", "def expanded; end", "def deco_pos; end", "def skips; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end", "def position; end" ]
[ "0.6463675", "0.6371908", "0.62604", "0.6120137", "0.6048225", "0.5922335", "0.59012616", "0.5839975", "0.58262706", "0.58262706", "0.58262706", "0.58262706", "0.57962567", "0.5721782", "0.5714384", "0.56867284", "0.56867284", "0.5673827", "0.5632865", "0.5619114", "0.5619114", "0.5580482", "0.5563417", "0.55621684", "0.554413", "0.554413", "0.554413", "0.554413", "0.5537122", "0.5537122", "0.551648", "0.55135053", "0.5512413", "0.54959804", "0.54959804", "0.5490659", "0.548914", "0.54567623", "0.54228866", "0.54228866", "0.54228866", "0.54127336", "0.5411949", "0.54093266", "0.54093266", "0.54093266", "0.54093266", "0.54093266", "0.54093266", "0.54057354", "0.54038686", "0.54035246", "0.5392274", "0.53796977", "0.5373642", "0.5371916", "0.5368067", "0.53669506", "0.53596866", "0.5348639", "0.53423154", "0.53368706", "0.53278995", "0.53278995", "0.5321649", "0.5321649", "0.5309899", "0.5298291", "0.52977854", "0.52977854", "0.5295129", "0.5285113", "0.5280731", "0.5269179", "0.5268501", "0.5268101", "0.52620035", "0.52609956", "0.525145", "0.52478224", "0.52462536", "0.52462536", "0.52460945", "0.5237515", "0.5230472", "0.52287894", "0.52287894", "0.52287894", "0.5227663", "0.52212995", "0.52173996", "0.52153534", "0.52072906", "0.52048117", "0.52048117", "0.52048117", "0.52048117", "0.52048117", "0.52048117", "0.52048117", "0.52048117" ]
0.0
-1
Extract the connection string for the rabbitmq service from the service information provided by Cloud Foundry in an environment variable.
def amqp_url if not ENV['VCAP_SERVICES'] return { :host => "172.16.32.11", :port => 5672, :username => "guest", :password => "guest", :vhost => "/", } end services = JSON.parse(ENV['VCAP_SERVICES'], :symbolize_names => true) url = services.values.map do |srvs| srvs.map do |srv| if srv[:label] =~ /^rabbitmq-/ srv[:credentials] else [] end end end.flatten!.first end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def amqp_url\n if not ENV['VCAP_SERVICES']\n return {\n :host => \"localhost\",\n :port => 5672,\n :username => \"guest\",\n :password => \"guest\",\n :vhost => \"/\",\n }\n end\n\n services = JSON.parse(ENV['VCAP_SERVICES'], :symbolize_names => true)\n url = services.values.map do |srvs|\n srvs.map do |srv|\n if srv[:label] =~ /^rabbitmq-/\n srv[:credentials]\n srv[:credentials][:heartbeat] = 20\n return srv[:credentials]\n else\n []\n end\n end\n end.flatten!.first\nend", "def myservices_environment_details_host\n ENV['ENV_DETAILS'].nil? ? 'esu2v871:9080' : ENV['ENV_DETAILS']\n end", "def url\n @@url ||= (ENV[\"AMQP_URL\"] || \"amqp://guest:guest@localhost/\")\n end", "def pull_request_host\n\t\tpull_request_where == 'jackrabbit' ? ALF_CFG['host'] : ALF_CFG[\"cedar_host\"]\n\tend", "def bc_client_id\n ENV['BC_CLIENT_ID']\nend", "def connection_string\n return @connection_params.values.compact.join(';')\n end", "def read_env_address_and_port\n @sensu_address = ENV['SENSU_SOCKET_ADDRESS'] \\\n if ENV.key?('SENSU_SOCKET_ADDRESS')\n @sensu_port = ENV['SENSU_SOCKET_PORT'].to_i \\\n if ENV.key?('SENSU_SOCKET_PORT')\n end", "def config\n uri = URI.parse(url)\n {\n :vhost => uri.path,\n :host => uri.host,\n :user => uri.user,\n :port => (uri.port || 5672),\n :pass => uri.password\n }\n rescue Object => e\n raise(\"invalid AMQP_URL: #{uri.inspect} (#{e})\")\n end", "def container_env(engine)\n env = if @cluster.env_variables['PLATFORM'].include?('aws')\n {\n 'KUBECONFIG' => '/kubeconfig',\n\n 'BRIDGE_AUTH_USERNAME' => @cluster.config_file.admin_credentials[0],\n 'BRIDGE_AUTH_PASSWORD' => @cluster.config_file.admin_credentials[1],\n 'BRIDGE_BASE_ADDRESS' => 'https://' + @cluster.tectonic_console_url,\n 'BRIDGE_BASE_PATH' => '/'\n }\n else\n {\n 'KUBECONFIG' => '/kubeconfig',\n\n 'BRIDGE_AUTH_USERNAME' => @cluster.tectonic_admin_email,\n 'BRIDGE_AUTH_PASSWORD' => @cluster.tectonic_admin_password,\n 'BRIDGE_BASE_ADDRESS' => 'https://' + @cluster.tectonic_console_url,\n 'BRIDGE_BASE_PATH' => '/'\n }\n end\n\n return env.map { |k, v| \"-e #{k}='#{v}'\" }.join(' ').chomp if engine == 'docker'\n return env.map { |k, v| \"--set-env #{k}='#{v}'\" }.join(' ').chomp if engine == 'rkt'\n raise 'unknown container engine'\n end", "def env_str\n @env_str ||= begin\n env = Rails.env\n env.include?('production') ? '' : env\n end\n end", "def env_str\n @env_str ||= begin\n env = Rails.env\n env.include?('production') ? '' : env\n end\n end", "def host\n ENV['CA_HOST'] || DEFAULT_HOST\n end", "def connection_info\n ENV['DATABASE_URL']\n end", "def haystack\n ENV['HUBBLE_ENDPOINT'] || config['haystack']\n end", "def get_connection_string(url)\n conn = Utils.parse_connection_url(url)\n str = \"host=#{conn[:host]} dbname=#{conn[:db]}\"\n str << \" port=#{conn[:port]}\" if conn[:port].present?\n str << \" user=#{conn[:user]}\" if conn[:user].present?\n str << \" password=#{conn[:pass]}\" if conn[:pass].present?\n str\n end", "def get_env_var key\n key = key.to_s\n exec(Beaker::Command.new(\"env | grep ^#{key}=\"), :accept_all_exit_codes => true).stdout.chomp\n end", "def get_env_info\n sub = nil\n\n if ENV['AZURE_MANAGEMENT_CERTIFICATE'] ||\n ENV['AZURE_MANAGEMENT_ENDPOINT'] ||\n ENV['AZURE_SUBSCRIPTION_ID']\n then\n sub = Subscription.new\n sub.subscription_id = ENV['AZURE_SUBSCRIPTION_ID']\n sub.management_certificiate = ENV['AZURE_MANAGEMENT_CERTIFICATE']\n sub.management_endpoint = ENV['AZURE_MANAGEMENT_ENDPOINT']\n sub.source = \"environment variables\"\n end\n\n sub\n end", "def calculate_dbhost\n owncloud_cookbook_config['dbhost'] =\n [\n owncloud_cookbook_config['dbhost'], owncloud_cookbook_config['dbport']\n ].join(':')\n end", "def connection_url(connection)\n user_pass = connection.user ? \"#{connection.user}:XXXXXX@\" : \"\"\n protocol = params[\"ssl\"] ? \"amqps\" : \"amqp\"\n \"#{protocol}://#{user_pass}#{connection.host}:#{connection.port}#{connection.vhost}\"\n end", "def connection_url(connection)\n user_pass = connection.user ? \"#{connection.user}:XXXXXX@\" : \"\"\n protocol = params[\"ssl\"] ? \"amqps\" : \"amqp\"\n \"#{protocol}://#{user_pass}#{connection.host}:#{connection.port}#{connection.vhost}\"\n end", "def service\n URI.parse(@config.split('<')[0].split('->')[1])\n end", "def envvar\n CircleCi.request(conf, \"#{base_path}/envvar\").get\n end", "def read_rabbit_mq_service(opts = {})\n data, _status_code, _headers = read_rabbit_mq_service_with_http_info(opts)\n return data\n end", "def storage_queue_host\n ENV['AZURE_STORAGE_QUEUE_HOST']\n end", "def determine_url\n ENV[\"DATABASE_URL\"] || database_url_from_database_yml\n end", "def storage_queue_host\n ENV[\"AZURE_STORAGE_QUEUE_HOST\"]\n end", "def shell_environment\n { 'HOME' => ENV.fetch('HOME', '/var/lib/rabbitmq') }\nend", "def config_for(environment=:development)\n if self.config.present?\n env_config = self.config[environment.to_s]\n else\n env_config = {\n 'host' => ENV['RIAK_HOST'],\n 'http_port' => ENV['RIAK_HTTP_PORT'],\n 'pb_port' => ENV['RIAK_PB_PORT']\n }\n end\n env_config\n end", "def remote_database_config(db)\n env = rails_env || db\n config = capture \"cat #{latest_release}/config/database.yml\"\n database = YAML::load(config)\n return database[\"#{env}\"]['username'], database[\"#{env}\"]['password'], database[\"#{env}\"]['database'], database[\"#{env}\"]['host']\n end", "def service_uri\n \"#{host}#{service_path}\"\n end", "def db_config\n @db_config ||= begin \n raise \"ENV['#{env_prefix}_DATABASE_URL'] expected but not found!\" unless ENV[\"#{env_prefix}_DATABASE_URL\"]\n config = parse_db_uri(ENV[\"#{env_prefix}_DATABASE_URL\"])\n \n if ENV[\"#{env_prefix}_DATABASE_CA\"]\n config.merge!(db_configuration({\n :sslca => ENV[\"#{env_prefix}_DATABASE_CA\"],\n :sslcert => ENV[\"#{env_prefix}_DATABASE_CERT\"],\n :sslkey => ENV[\"#{env_prefix}_DATABASE_KEY\"],\n }))\n end\n \n config\n end\n end", "def sql_database_management_endpoint\n ENV['AZURE_SQL_DATABASE_MANAGEMENT_ENDPOINT'] || \"#{SERVICE_MANAGEMENT_ENDPOINT}:8443/\"\n end", "def test_url_from_environment\n pool_config = resolve_db_config :production, \"production\" => \"abstract://foo?encoding=utf8\"\n\n assert_equal({\n adapter: \"abstract\",\n host: \"foo\",\n encoding: \"utf8\"\n }, pool_config.configuration_hash)\n end", "def getEnvVar\n if ENV['ENV'].nil?\n UI.user_error!(\"No 'ENV' environment variable set. Set it using `awsenv` config file. Must contain 'dev', 'qa' or 'prod' in value.\")\n end\n\n env_raw = /(dev|qa|prod)/.match(ENV.fetch('ENV', nil))[1]\n UI.important(\"ENVIRONMENT: #{env_raw}\")\n\n if env_raw.nil? || env_raw.length == 0\n UI.user_error!(\"Your 'ENV' environment variable is set but doesn't contain 'dev', 'qa' or 'prod' as value.\")\n end\n\n return env_raw\nend", "def config\n $VHOST.config\n end", "def host; config[:host]; end", "def storage_connection_string\n ENV[\"AZURE_STORAGE_CONNECTION_STRING\"]\n end", "def find_local\n find_connection(\"#{BackgrounDRb::BDRB_CONFIG[:backgroundrb][:ip]}:#{BackgrounDRb::BDRB_CONFIG[:backgroundrb][:port]}\")\n end", "def configured_hostname\n running_config.scan(/hostname\\s*(\\S+)/).flatten.first\n end", "def host\n @host ||= Chimps.config[:catalog][:host]\n end", "def connection_string\n instance.primary_ip.split('://')[0] == 'unix' ? instance.primary_ip : \"tcp://#{instance.primary_ip}:2376\"\n end", "def db_uri\n unless @db_uri # get the config from command line\n @db_uri = self.conf['db_url']\n end\n @db_uri\n end", "def redis_host_name\n if is_zz?\n return app_config[:redis_host]\n end\n\n return @redis_host_name if @redis_host_name != nil\n\n instances = ey['environment']['instances']\n # assume solo machine\n @redis_host_name = this_host_name\n\n # not solo so see if we are db_master which\n # is where we host redis\n instances.each do |instance|\n if instance['role'] == 'db_master'\n @redis_host_name = instance['private_hostname']\n break\n end\n end\n @redis_host_name\n end", "def bc_api_url\n ENV['BC_API_ENDPOINT'] || 'https://api.bigcommerce.com'\nend", "def lookup_service_host\n # Allow manual overrides\n return config[:lookup_service_host] unless config[:lookup_service_host].nil?\n\n # Retrieve SSO service via RbVmomi, which is always co-located with the Lookup Service.\n vim = RbVmomi::VIM.connect @connection_options\n vim_settings = vim.serviceContent.setting.setting\n sso_url = vim_settings.select { |o| o.key == \"config.vpxd.sso.sts.uri\" }&.first&.value\n\n # Configuration fallback, if no SSO URL found for some reason\n ls_host = sso_url.nil? ? config[:vcenter_host] : URI.parse(sso_url).host\n debug(\"Using Lookup Service at: \" + ls_host)\n\n ls_host\n end", "def uri_info\n services.map do |s|\n opts = s[:connection].connection\n {\n host: opts[:host],\n port: opts[:port],\n scheme: 'redis'\n }\n end\n end", "def client_config\n cc = Settings.dig(:connection, connection_type)\n return cc unless host\n\n uhost = URI(host)\n cc.host = uhost.hostname\n cc.port = uhost.port\n cc.scheme = uhost.scheme\n cc\n end", "def envvar\n CircleCi.request(@conf, \"/project/#{username}/#{project}/envvar\").get\n end", "def get_config(config_name)\n raise ConfigNotFound, \"Environment variable #{config_name} not found !\" unless ENV[config_name]\n ENV[config_name]\n end", "def env\n image = options[:image] || app\n config = api.get_config_vars(app).body\n\n config.keys.sort.each do |key|\n puts \"#{key}=#{config[key]}\"\n end\n end", "def subdomain\n env[\"SERVER_NAME\"].match(/(.+)\\.#{::Service.this.domain}/)\n $1\n rescue Vidibus::Service::ConfigurationError\n unless env['PATH_INFO'] == '/connector'\n raise(ServiceError, 'This service has not been configured yet')\n end\n end", "def docker_compose_container\n get_config(:docker_compose_container).to_s\n end", "def environment_name(url = nil)\n url ||= self.url\n uri = URI(url)\n\n if (uri.host == 'localhost')\n if uri.port.nil?\n uri.host;\n else\n \"#{uri.host}:#{uri.port}\"\n end\n else\n name = case uri.host\n when /(?:origin-)?www\\d?(?:\\.pos)?(?:\\.siteb)?\\.([^\\.]+)(?:\\.fds)?\\.com/,\n /(?:m|m2qa1|mdev1|mockmacys|local)\\.([^\\.]+)(?:\\.fds)?\\.com/, # mobile env\n /([^\\.]+)\\.\\w+\\.\\w+\\.griddynamics\\.net/, # partial env\n /([^\\.]+)\\.stage2\\.cistages\\.fds/, # stage 2 env\n /([^\\-]+)-staging.bloomingdales\\.com/, #BCOM Heroku Staging Env\n /([^\\.]+).bloomingdales\\.com/, #BCOM Heroku Production Env\n /([^\\.]+)\\.cistages\\.fds/,\n /([^\\.]+)\\.macysbackstage\\.com/,\n /([^\\.]+)\\.herokuapp\\.com/,\n /([^\\.]+)\\.c4d\\.devops\\.fds\\.com/,\n /sstportal/\n Regexp.last_match.captures.first\n else\n raise URI::InvalidURIError, \"URI was not recognized: '#{url}'.\"\n end\n name\n end\n end", "def environment\n @environment ||= ENV['HUBBLE_ENV'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'\n end", "def config\n system_config.send(service_name.to_sym) || []\n end", "def get_environment ()\n service_data = query_for_services()\n return service_data[\"environment\"]\n end", "def service_name\n if settings && settings[\"service_name\"].present?\n settings[\"service_name\"]\n else\n APP_CONFIG.global_service_name || \"Sharetribe\"\n end\n end", "def service_name\n if settings && settings[\"service_name\"].present?\n settings[\"service_name\"]\n else\n APP_CONFIG.global_service_name || \"Sharetribe\"\n end\n end", "def rabbitmq_id\n name\n end", "def sb_namespace\n ENV['AZURE_SERVICEBUS_NAMESPACE']\n end", "def env_config; end", "def env_config; end", "def env_config; end", "def env_config; end", "def get_environment\n if @environment.empty?\n \":\"\n else\n env = @environment.map { |key, value| %(#{key}=\"#{value}\") }\n \"export #{env.join(' ')}\"\n end\n end", "def remote_database_config( db )\n remote_config = capture(\"cat #{shared_path}/config/database.yml\")\n database = YAML::load( remote_config )\n return database[\"#{db}\"]['username'], database[\"#{db}\"]['password'], database[\"#{db}\"]['database'], database[\"#{db}\"]['host']\n end", "def setup_database_url_env\n ENV[\"DATABASE_URL\"] ||= begin\n # need to use a dummy DATABASE_URL here, so rails can load the environment\n scheme =\n if gem_is_bundled?(\"pg\")\n \"postgres\"\n elsif gem_is_bundled?(\"mysql\")\n \"mysql\"\n elsif gem_is_bundled?(\"mysql2\")\n \"mysql2\"\n elsif gem_is_bundled?(\"sqlite3\") || gem_is_bundled?(\"sqlite3-ruby\")\n \"sqlite3\"\n end\n \"#{scheme}://user:pass@127.0.0.1/dbname\"\n end\n end", "def get\n unless key = shift_argument\n error(\"Usage: heroku config:get KEY\\nMust specify KEY.\")\n end\n validate_arguments!\n\n vars = api.get_config_vars(app).body\n key, value = vars.detect {|k,v| k == key}\n if options[:shell] && value\n out = $stdout.tty? ? Shellwords.shellescape(value) : value\n display(\"#{key}=#{out}\")\n else\n display(value.to_s)\n end\n end", "def get_env(key)\n\n end", "def ca_cert_string\n @ca_cert_string ||= begin\n return nil if ENV['VCAP_SERVICES'].blank?\n\n JSON.parse(ENV['VCAP_SERVICES'])['a9s-elasticsearch'].first['credentials']['cacrt']\n end\n end", "def env(key) \n str = key.to_s \n env?(str) ? ENV[str] : nil\n end", "def get_remote_database(print_to_stdout)\n cleardb = api.get_config_vars(app).body[\"CLEARDB_DATABASE_URL\"]\n jawsdb = api.get_config_vars(app).body[\"JAWSDB_URL\"]\n\n if @@db == 'cleardb'\n puts \"Using ClearDB\" if print_to_stdout\n return cleardb\n elsif @@db == 'jawsdb'\n puts \"Using JawsDB\" if print_to_stdout\n return jawsdb\n elsif jawsdb && cleardb\n puts \"Error. Both CLEARDB_DATABASE_URL and JAWSDB_URL config vars are found. Please indicate which database to use with the --db parameter (values accepted: cleardb or jawsdb)\"\n return nil\n elsif cleardb\n puts \"Using ClearDB\" if print_to_stdout\n return cleardb\n elsif jawsdb\n puts \"Using JawsDB\" if print_to_stdout\n return jawsdb\n end\n\n return nil\n end", "def drb_host\n instance.options[:drb_host]\n end", "def drb_host\n instance.options[:drb_host]\n end", "def get_information(env)\n connection_info = read_from_yaml_file(env)\n\n # is the user owns a hosting account, then use his credentials\n # to create a new site.\n if connection_info.nil? && env == 'hosting'\n connection_info = read_from_hosting\n end\n\n if connection_info.nil?\n raise \"No #{env.to_s} environment found in the config/deploy.yml file\"\n end\n\n connection_info = connection_info.with_indifferent_access\n\n if connection_info[:ssl] && !connection_info[:host].start_with?('https')\n connection_info[:host] = 'https://' + connection_info[:host]\n end\n\n connection_info\n end", "def get_connection_hash\n case ENV.fetch(\"FUZZILY_ADAPTER\", \"sqlite3\")\n when \"postgresql\"\n {\n adapter: \"postgresql\",\n database: \"fuzzily_test\",\n host: \"127.0.0.1\",\n min_messages: \"warning\",\n username: \"postgres\",\n password: \"postgres\",\n }\n when \"mysql\"\n {\n adapter: \"mysql2\",\n database: \"fuzzily_test\",\n host: \"127.0.0.1\",\n username: \"root\"\n }\n when \"sqlite3\"\n {\n adapter: \"sqlite3\",\n database: DATABASE.to_s\n }\n end\nend", "def consumer_nsqds\n @consumer_nsqds ||= ENV.fetch(\"NSQD_CONSUMERS\", \"\").split(/, ?|\\s+/).map(&:strip)\n end", "def client_port\n host_settings['client_port']\nend", "def docker_compose_project_name\n compose_project_name = ENV['COMPOSE_PROJECT_NAME']\n if compose_project_name.nil? || compose_project_name.empty?\n compose_project_name = \"rhd_#{ENV['rhd_test']}_testing\"\n end\n compose_project_name\n end", "def docker_compose_project_name\n compose_project_name = ENV['COMPOSE_PROJECT_NAME']\n if compose_project_name.nil? || compose_project_name.empty?\n compose_project_name = \"rhd_#{ENV['rhd_test']}_testing\"\n end\n compose_project_name\n end", "def get_box_hostname_from_config(node_config)\n \n box_hostname = concat_array( \n [\n node_config['lib']['key'],\n node_config['lib']['namespace'],\n node_config['variables'] && node_config['variables']['domain'] ? node_config['variables']['domain'] : ''\n ]\n )\n return box_hostname\nend", "def get_value_from_dotenv(var)\n line=open('./.env') { |f| f.lines.find { |line| line.include?(var) } }\n line=line.chomp\n return line.split(\"=\").last.split(' ').first.tr('\"','')\nend", "def remote_database_config(db)\n remote_config = capture(\"cat #{shared_path}/config/#{fetch(:db_file, 'mongoid.yml')}\")\n database = YAML::load(remote_config)\n return database[\"#{db}\"]['clients']['default']['username'], database[\"#{db}\"]['clients']['default']['password'], database[\"#{db}\"]['clients']['default']['database'], database[\"#{db}\"]['clients']['default']['hosts'][0]\n end", "def get_client_name\n client_name = nil\n if env.present?\n Webmetrics::Config.client_matchers.each do |key, matcher|\n if matcher.respond_to?(:call) and matcher.call(env)\n client_name = key\n break\n end\n end\n end\n\n # return client name\n client_name || Webmetrics::Config.default_client\n end", "def get_host\n @host\n end", "def get(key)\n key = key.to_s\n %w(local_config app_config m2mhub_config).each do |config_key|\n if (config = @yaml_config[config_key])\n if config_key == 'app_config'\n next unless config = config[Rails.env.downcase]\n end\n if config.member?(key)\n return config[key]\n end\n end\n end\n nil\n end", "def remote_database_config(db = rails_env)\n remote_config = capture(\"cat #{sync_db_remote_config}\")\n database = YAML::load(remote_config)\n database and database[\"#{db}\"]\n end", "def env_key; end", "def kestrel_config_by_name(name)\n connections = swiftype_config['kestrel_brokers'] || {}\n config = connections[name]\n critical(\"Unknown Kestrel broker: #{name}\") unless config\n return config.symbolize_keys\n end", "def zookeeper_helper(url)\n # z = Zookeeper.new(\"149.165.170.7:2181\")\n # host_details= z.get(:path => url)\n # host_details=host_details[:data]\n # host_details=host_details.split(\":\")\n host_details=[ENV[\"RECOENGINE_SERVICE_PORT_8001_TCP_ADDR\"], ENV[\"RECOENGINE_SERVICE_PORT_8001_TCP_PORT\"]]\n host_details\n end", "def get_docker_ip_address\n # first try to get the ip from docker-ip env\n if !ENV['DOCKER_IP'].to_s.empty?\n return ENV['DOCKER_IP']\n end\n\n if !ENV['DOCKER_HOST'].to_s.empty?\n \t\t# dockerhost set\n \t\thost = ENV['DOCKER_HOST'].dup\n \t\thost.gsub!(/tcp:\\/\\//, '')\n \t\thost.gsub!(/:\\d+/,'')\n\n \t\treturn host\n else\n return '127.0.0.1'\n \tend\n end", "def host\n return @@nfg_urls['sandbox']['host'] if @use_sandbox\n @@nfg_urls['production']['host']\n end", "def host\n @config.db_hostname\n end", "def get_binding(keyset)\n environment = $environment\n myPublicIp = $myPublicIp\n myRoot = $myRoot\n myAZ = $myAZ\n myRegion = $myRegion\n myAppName = $myAppName\n credentials = @default_credentials ? @default_credentials : \"default\"\n\n# return MU::Config.global_bindings[keyset] if MU::Config.global_bindings[keyset]\n MU::Config.global_bindings[keyset] = binding\n MU::Config.global_bindings[keyset]\n end", "def get_db_conf(env='development')\n Rails.configuration.database_configuration[env]\nend", "def host\n conf['api']['host']\n end", "def get_env(format, app, node = self.node)\n return '' unless node.attribute?(app)\n\n if node[app]['env'].nil?\n Chef::Log.info(\"Attribute 'env' for application '#{app}' is not defined!\")\n return ''\n end\n\n appenv = streamline_appenv(node[app]['env'])\n generate_config_part(format, 'settings', appenv)\n end", "def node_environment(node_config)\n env = node_config['environment']\n (env.nil? || env.empty?) ? 'production' : env\nend", "def config_value_for(key)\n heroku = get_heroku config_value_str(key), hide_stderr: true\n value = `#{heroku.command}`.strip\n value = nil if value == ''\n value\n end", "def concierge_host\n context[:host]\n end" ]
[ "0.7228656", "0.64117", "0.60329986", "0.5871954", "0.58560705", "0.57894254", "0.57065386", "0.5627882", "0.55615014", "0.5546482", "0.5546482", "0.55334806", "0.55314684", "0.55079055", "0.5474078", "0.54584104", "0.544193", "0.54413456", "0.542486", "0.542486", "0.54162025", "0.53938746", "0.53937805", "0.53807044", "0.5378692", "0.5351806", "0.5341503", "0.5329901", "0.5323146", "0.5309613", "0.52988595", "0.5290769", "0.5279869", "0.5274314", "0.5271219", "0.5255788", "0.5249704", "0.52365315", "0.52007025", "0.51945525", "0.51937574", "0.5187434", "0.5186652", "0.51788133", "0.5166912", "0.51543933", "0.51514333", "0.51384676", "0.51342374", "0.51295114", "0.50990224", "0.5082804", "0.5079894", "0.5076858", "0.5072085", "0.5057948", "0.5054015", "0.5054015", "0.50480956", "0.504182", "0.5037762", "0.5037762", "0.5037762", "0.5037762", "0.5025813", "0.5024832", "0.50227", "0.5011131", "0.50098246", "0.5002398", "0.49989486", "0.49978018", "0.4996163", "0.4996163", "0.49867636", "0.49848464", "0.4983812", "0.49825305", "0.49715048", "0.49706998", "0.49685428", "0.49667335", "0.49614653", "0.49457577", "0.4943211", "0.4941748", "0.4940697", "0.49371535", "0.49349356", "0.49321568", "0.49318907", "0.49317923", "0.49184874", "0.491699", "0.49168438", "0.4912033", "0.49049908", "0.48965514", "0.48958856", "0.48952046" ]
0.744864
0
Opens a client connection to the RabbitMQ service, if one isn't already open. This is a class method because a new instance of the controller class will be created upon each request. But AMQP connections can be longlived, so we would like to reuse the connection across many requests.
def client unless $client u = amqp_url puts u c = Bunny.new(u) c.start $client = c # We only want to accept one un-acked message $client.qos :prefetch_count => 1 end $client end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def client\n unless $client\n u = amqp_url\n conn = Bunny.new(u)\n conn.start\n $client = conn.create_channel\n\n # We only want to accept one un-acked message\n $client.prefetch(1)\n end\n $client\nend", "def client\n set_connection unless @client\n @client\n end", "def connect\n @client = @client_class.new\n @client.connect\n \n begin\n yield\n ensure\n @client.close\n ActiveRecord::Base.verify_active_connections!\n end\n end", "def connect\n # backwards compatible code\n @host ||= ::Ragnar::Config.host\n @port ||= ::Ragnar::Config.port\n @connection = ::AMQP.connect({:host => @host, :port => @port})\n end", "def start\n @stopped = false\n Thread.new(connect(read_loop_thread: false)) do |conn|\n Thread.abort_on_exception = true # Raising an unhandled exception is a bug\n loop do\n break if @stopped\n\n conn ||= connect(read_loop_thread: false)\n Thread.new do\n # restore connection in another thread, read_loop have to run\n conn.channel(1) # reserve channel 1 for publishes\n @subscriptions.each do |queue_name, no_ack, prefetch, wt, args, blk|\n ch = conn.channel\n ch.basic_qos(prefetch)\n ch.basic_consume(queue_name, no_ack: no_ack, worker_threads: wt, arguments: args, &blk)\n end\n @connq << conn\n end\n conn.read_loop # blocks until connection is closed, then reconnect\n rescue Error => e\n warn \"AMQP-Client reconnect error: #{e.inspect}\"\n sleep @options[:reconnect_interval] || 1\n ensure\n conn = nil\n end\n end\n self\n end", "def connection\r\n @connectoin ||= HTTPClient.new\r\n end", "def open(options={}, &block)\n begin\n # Call the appropriate client's open method.\n if self.client\n self.client.open(options)\n else\n if self.uri\n raise Retrieve::NoClientError,\n \"No client was registered to handle the \" +\n \"'#{self.uri.scheme}' scheme.\"\n else\n raise Retrieve::NoClientError,\n \"Cannot find a client without a URI scheme.\"\n end\n end\n if block\n # If we were supplied a block, yield to it, then close.\n yield self\n else\n self\n end\n ensure\n # Make sure we close if there's a block.\n self.close if block rescue nil\n end\n end", "def client\n @client ||= client_for_host(brine_root_url || 'http://localhost:8080',\n logging: ENV['BRINE_LOG_HTTP'])\n end", "def amqp_connect\n\n ocon = opt('connection')\n\n if BOSS.connection && ( ! ocon)\n BOSS.connection\n else\n Bunny.new(Ruote.keys_to_sym(ocon || {}))\n end\n end", "def connect_amqp!\n username = config['rabbitmq']['username']\n password = config['rabbitmq']['password']\n host = config['rabbitmq']['host']\n port = config['rabbitmq']['port']\n vhost = config['rabbitmq']['vhost']\n\n puts \"connecting to amqp://#{username}:#{password}@#{host}:#{port}/#{vhost}\"\n connection = AMQP.connect(\"amqp://#{username}:#{password}@#{host}:#{port}/#{vhost}\")\n self.channel = AMQP::Channel.new(connection)\n\n # RingBase -> Invoca control queue\n control_channel_queue_name = config['control_channel_queue_name']\n self.control_queue = channel.queue(control_channel_queue_name, auto_delete: true)\n\n\n # Invoca -> RingBase update exchange\n update_exchange_name = config['update_exchange_name']\n self.update_exchange = channel.fanout(update_exchange_name)\n self.update_queue = channel.queue('', exclusive: true)\n update_queue.bind(update_exchange)\n end", "def initialize\n @connection = Bunny.new(ENV['CLOUDAMQP_URL'] || ENV['AMQP_HOST'])\n @connection.start\n @channel = connection.create_channel\n @exchange = channel.topic(ENV['AMQP_EXCHANGE'] || ENV['SERVICE_NAME'])\n end", "def client\n @client ||= Client.new\n end", "def http_connection\n if @in_session\n establish_shared_connection\n else\n create_http_connection\n end\n end", "def connection\n client.send(:connection)\n end", "def client\n @@client ||= Orchestrate::Application::Connect.client\n end", "def client\n @client || Client.connection\n end", "def connection\n @connection = create_connection! unless connected?\n @connection\n end", "def aquire_connection\n conn = if @connection_pool\n @connection_pool.aquire_connection\n else\n @connection\n end\n @status = nil unless conn.connected?\n conn\n end", "def connection\n @connection ||= RestClient::Resource.new(api_uri.to_s)\n end", "def create_channel\n AMQP::Channel.new(@amqp_client)\n end", "def connect opts={}\n unless EM.reactor_running?\n Thread.new { EventMachine.run }\n sleep 0.5\n end\n @connection = AMQP.connect(opts)\n end", "def start\n return if active?\n begin\n @subject.start\n rescue Errno::ECONNRESET\n raise EventSource::Protocols::Amqp::Error::ConnectionError,\n \"Connection failed. network error to: #{connection_params}\"\n rescue Bunny::TCPConnectionFailed\n raise EventSource::Protocols::Amqp::Error::ConnectionError,\n \"Connection failed to: #{connection_params}\"\n rescue Bunny::PossibleAuthenticationFailureError\n raise EventSource::Protocols::Amqp::Error::AuthenticationError,\n \"Likely athentication failure for account: #{@subject.user}\"\n rescue StandardError\n raise EventSource::Protocols::Amqp::Error::ConnectionError,\n \"Unable to connect to: #{connection_params}\"\n else\n sleep 1.0\n logger.info \"Connection #{connection_uri} started.\" if active?\n active?\n end\n end", "def new_connection\n Connection.new(Backburner.configuration.beanstalk_url) { |conn| Backburner::Hooks.invoke_hook_events(self, :on_reconnect, conn) }\n end", "def connect\n rabbit.transaction_short do\n choose_queue\n yield\n end\n end", "def run\n logger.debug \"[Cottontail] Connecting to client\"\n @client = Bunny.new( *settings(:client) )\n @client.start\n\n logger.debug \"[Cottontail] Declaring exchange\"\n exchange = @client.exchange( *settings(:exchange) )\n\n logger.debug \"[Cottontail] Declaring queue\"\n queue = @client.queue( *settings(:queue) )\n\n routes.keys.each do |key| \n logger.debug \"[Cottontail] Binding #{key.inspect} to exchange\"\n queue.bind( exchange, :key => key )\n end\n\n logger.debug \"[Cottontail] Entering subscribe loop\"\n subscribe! queue\n rescue => e\n @client.stop if @client\n reset!\n\n logger.error \"#{e.class}: #{e.message}\\n\\t#{e.backtrace.join(\"\\n\\t\")}\"\n\n # raise when no retries are defined\n raise( e, caller ) unless settings(:retries)\n\n logger.debug \"[Cottontail] Going to retry in #{settings(:delay_on_retry)} seconds...\"\n sleep settings(:delay_on_retry) if settings(:delay_on_retry)\n retry\n end", "def connection\n @connection ||= make_connection\n end", "def connection\n # Establish connection (if not established yet).\n if not @conn then\n # Connect.\n @conn =\n if use_secure_connection? then Socket_IO.open(\"https://socketio.mtgox.com/socket.io\")\n else Socket_IO.open(\"http://socketio.mtgox.com/socket.io\"); end\n # Subscribe to ticker.\n @conn.send Socket_IO::JSONMsg[\n \"op\" => \"mtgox.subscribe\",\n \"type\" => \"ticker\"\n ]\n end\n #\n return @conn\n end", "def connect\n connection = Bunny.new(connection_attributes.\n merge(:pass => connection_attributes[:password]))\n connection.start\n \n # NOTE: This is a super undocumented feature that you will probably know\n # about only from reading AMQP specs. If we want to subscribe, but abort\n # subscription before all messages are read, we need to turn this on,\n # otherwise the server will go on and deliver all remaining messages in\n # turn. See also the :ack => true flag in ServerTransport... 23Dez09, ksc\n connection.qos\n\n connection\n end", "def client\n @client ||= Client.new(configuration)\n end", "def attempt_connection\n @connection_future = Concurrent::Future.new do\n Roby::DRoby::Logfile::Client.new(host, port)\n end\n connection_future.execute\n end", "def client\n @client ||= self.class.client\n end", "def conn\n @conn ||= connect\n if block_given?\n yield @conn\n else\n @conn\n end\n rescue *HttpExceptions\n @conn = connect\n return if defined?(once)\n once = true && retry\n end", "def connect\n @connection_pool.get_connection\n end", "def connect\n Connection.new\n end", "def client\n @client = Gluby::Client.instance unless @client\n @client\n end", "def client\n @client ||= Client.current\n end", "def open_connection\n if @sslca then\n @db = Mysql2::Client.new(\n host: @host, \n username: @username, \n password: @password, \n port: @port, \n database: @database_name,\n sslca: @sslca)\n else\n @db = Mysql2::Client.new(\n host: @host, \n username: @username, \n password: @password, \n port: @port, \n database: @database_name)\n end\n end", "def connection\n @connection ||= begin\n Faraday.new(:url => \"http://#{configuration.server}:#{configuration.port}\", &connection_block)\n end\n end", "def http_connection\n (@shared_tcp_connection ||\n (@in_session && establish_shared_connection) ||\n create_http_connection)\n end", "def open\n @socket = TCPSocket.new(@uri.host, @uri.port)\n\n @ssl = OpenSSL::SSL::SSLSocket.new(@socket, @ssl_context)\n @ssl.sync_close = true\n @ssl.hostname = @uri.hostname\n @ssl.connect\n\n @http = HTTP2::Client.new\n @http.on(:frame) do |bytes|\n @ssl.print(bytes)\n @ssl.flush\n end\n\n @main_queue = Threading::DispatchQueue.new\n @work_queue = Threading::DispatchQueue.new\n @requests = Threading::Counter.new\n @exceptions = Queue.new\n @worker_thread = start_worker_thread!\n end", "def connection_for(client_name)\n connect unless connection\n return nil if client_name == :all\n @clients[client_name] ||= case client_name\n when :resque\n connect_for_resque\n else\n connect_for_any\n end\n end", "def prepare_connection(env)\n env.trace 'init connection'\n @env = env\n init_queue\n initialize_connection env # Defined in each endpoint\n @application.stat_connection_open\n @channel = env.params['channel']\n logger.debug \"Connected to channel #{@channel}\"\n subscribe @channel\n end", "def ensure_connected\n client = @connection.client(self)\n \n # If this connection has expired somehow, try to get another one.\n unless connected?(client)\n @connection.drop(self)\n client = @connection.client(self)\n end\n\n fail \"Bad Connection\" unless connected?(client)\n\n client\n end", "def establish_connection\n end", "def connection\n @connection ||= if authenticated?\n RestClient::Resource.new(api_uri.to_s, @username, @password)\n else\n RestClient::Resource.new(api_uri.to_s)\n end\n end", "def client\n Exchange::GemLoader.new('redis').try_load unless defined?(::Redis)\n @client ||= ::Redis.new(:host => config.host, :port => config.port)\n end", "def request(*args, &blk)\n (@client ||= connect).request(*args, &blk)\n end", "def set_up_channel\n amqp_conn = Bunny.new\n amqp_conn.start\n channel = amqp_conn.create_channel\nend", "def connection\n client.connection\n end", "def spawn_connection\n connect\n end", "def connection\n @connection ||= Faraday.new(url: PriceHubble.configuration.base_url,\n &method(:configure))\n end", "def get_client(client_class = ::Elarian::BaseClient)\n @default_client ||= client_class.new(connection_credentials)\n on_error = lambda do |error|\n puts \"Error occurred #{error}\"\n disconnect_and_stop_loop\n end\n @default_client.on(:error, on_error)\n connect(@default_client)\n @default_client\n end", "def initialize(prefetch: nil, connection_name: nil)\n @configuration = Pwwka.configuration\n connection_options = {automatically_recover: false}.merge(configuration.options)\n connection_options = {client_properties: {connection_name: connection_name}}.merge(connection_options) if connection_name\n\n begin\n @connection = Bunny.new(configuration.rabbit_mq_host, connection_options)\n @connection.start\n rescue => e\n logf \"ERROR Connecting to RabbitMQ: #{e}\", at: :error\n\n @connection.close if @connection\n raise e\n end\n\n begin\n @channel = @connection.create_channel\n @channel.on_error do |ch, method|\n logf \"ERROR On RabbitMQ channel: #{method.inspect}\"\n end\n rescue => e\n logf \"ERROR Opening RabbitMQ channel: #{e}\", at: :error\n @connection.close if @connection\n raise e\n end\n\n if prefetch\n @channel.prefetch(prefetch.to_i)\n end\n end", "def connect\n @connection_manager.connect\n return self\n end", "def initialize(params = {})\n @params = params\n @bunny_options = RabbitMQOptions.new(params)\n @rabbit = RabbitMQClient.new(@bunny_options.to_hash)\n\n end", "def open_connection\n # FIXME il timeout serve solamente nella versione tcp\n # FIXME perchè utilizzare un'istanza di classe? non sarebbe meglio avere un metodo che genera il transport\n # e successivamente viene utilizzato sempre quello?\n Timeout.timeout @timeout do\n case @transport\n when :tcp\n @connection = KonoEppClient::Transport::TcpTransport.new(server, port)\n when :http\n @connection = KonoEppClient::Transport::HttpTransport.new(server, port,\n ssl_version: ssl_version,\n cookie_file: \"#{@tag.downcase}.cookies.pstore\"\n )\n end\n end\n end", "def connection_manager\n @connection_manager ||= TOAMQP::ConnectionManager.new\n end", "def connect\n @connection.open\n end", "def connect\n EM.run do\n client = Faye::WebSocket::Client.new(@url)\n reconnect_url = nil\n\n client.on :message do |msg|\n message_received(client, msg)\n end\n\n client.on :open do |e|\n OutputLogger.logger.info 'Connection Opened!'\n end\n\n client.on :close do |e|\n OutputLogger.logger.info 'Connection closed, trying to reconnect.'\n\n reconnect\n end\n\n client.on :error do |e|\n OutputLogger.logger.error e.inspect\n end\n\n client.on 'transport:down' do |e|\n OutputLogger.logger.info 'Connection down.'\n end\n\n client.on 'transport:up' do |e|\n OutputLogger.logger.info 'Connection back up, trying to reconnect.'\n\n reconnect\n end\n end\n end", "def connect!\n start_em\n @client.ensure_connect\n end", "def conn\n @conn ||= Faraday.new(:url => uri.to_s) do |builder|\n builder.adapter self.class.adapter\n end\n end", "def client\n @client ||= Client.new(config[:credentials], config[:end_point])\n end", "def new\n @client = Client.new\n end", "def new\n @client = Client.new\n end", "def new\n @client = Client.new\n end", "def with_connection\n connection_id = current_connection_id\n fresh_connection = true unless active_connection?\n yield connection\n ensure\n release_connection(connection_id) if fresh_connection\n end", "def open(handler)\n puts '! Connection established' if handler.bot.debug\n end", "def with_connection\n connection_id = current_connection_id\n fresh_connection = true unless active_connection?\n yield connection\n ensure\n release_connection(connection_id) if fresh_connection\n end", "def with_connection\n connection_id = current_connection_id\n fresh_connection = true unless active_connection?\n yield connection\n ensure\n release_connection(connection_id) if fresh_connection\n end", "def connection\n @connection ||= Bunny.new RabidMQ::Config.load_config\n end", "def open()\n begin\n @my = Mysql.connect(@host, @user, @pw, @db)\n # Set the MySQL 'reconnect' flag -> Connection to the database will be\n # automatically maintained even if the Server closes it due to timed-out idle period\n @my.reconnect = true\n debug \" - Open Connection to MYSQL server - reconnect=#{@my.reconnect}\"\n @connected = true\n rescue MysqlError => e\n debug \"SQL error message: #{e.error}.\"\n end\n end", "def client\r\n @client ||= APIController.new config\r\n end", "def attempt_connection\n @connection_future = Concurrent::Future.new do\n connection_method.call\n end\n connection_future.execute\n end", "def client_connection\n if respond_to?(:valid_raw_connection)\n valid_raw_connection\n elsif instance_variable_defined?(:@raw_connection)\n @raw_connection\n else\n @connection\n end\n end", "def client\n @@client\n end", "def on_open client\n c = controller(client)\n c.instance_variable_set(CLIENT_NAME, client)\n if client.protocol == :sse\n c.on_sse\n else\n c.on_open\n end\n end", "def connection\n reconnect unless connected?\n if block_given?\n begin\n yield conn\n rescue Errno::ECONNRESET\n reconnect\n yield conn\n end\n else\n conn\n end\n end", "def with(&client_block)\n @connection_block.call(client_block)\n end", "def client\n @client_ ||= Libmagellan.new(MAGELLAN_HTTP_SERVER,\n consumer_key: MAGELLAN_CONSUMER_KEY,\n consumer_secret: MAGELLAN_CONSUMER_SECRET,\n client_version: MAGELLAN_CLIENT_VERSION,\n mqtt_host: MAGELLAN_MQTT_SERVER_HOST,\n mqtt_port: MAGELLAN_MQTT_SERVER_PORT)\n end", "def connection\n @connection ||= Connection.new(nil)\n end", "def new_connection; end", "def connection\n @connection.connect\n end", "def connection\n @connection ||= build_connection\n end", "def init_client(uri, &on_init)\n connection = nil\n @connections_lock.synchronize {\n connection = @connections.find { |c|\n c.url == uri\n }\n if connection.nil?\n connection = EventMachine::WebSocketClient.connect(uri)\n connection.callback do\n on_init.call(connection)\n end\n @connections << connection\n # TODO sleep until connected?\n else\n on_init.call(connection)\n end\n }\n connection\n end", "def open()\n begin\n @my = Mysql.connect(@host, @user, @pw, @db)\n # Set the MySQL 'reconnect' flag -> Connection to the database will be \n # automatically maintained even if the Server closes it due to timed-out idle period\n @my.reconnect = true\n debug \" - Open Connection to MYSQL server - reconnect=#{@my.reconnect}\"\n rescue MysqlError => e\n debug \"SQL error message: #{e.error}.\"\n end\t\n end", "def client\n @client ||= Curl::Easy.new\n end", "def recreate_client\n @http.close\n create_client\n end", "def connect\r\n if @opts[:threadsafe]\r\n @conns = Knj::Threadhandler.new\r\n \r\n @conns.on_spawn_new do\r\n self.spawn\r\n end\r\n \r\n @conns.on_inactive do |data|\r\n data[:obj].close\r\n end\r\n \r\n @conns.on_activate do |data|\r\n data[:obj].reconnect\r\n end\r\n else\r\n @conn = self.spawn\r\n end\r\n end", "def connect\n connection.tap do |c|\n c.start\n end\n end", "def session(&block)\n raise ArgumentError, \"#{self.class}#shared_connection must be passed a block\" unless block_given?\n\n # Immediately open a TCP connection to the server and leave it open for\n # multiple requests.\n begin\n t0 = Time.now\n @in_session = true\n establish_shared_connection\n block.call\n rescue Timeout::Error\n elapsed = Time.now - t0\n ::NewRelic::Agent.logger.warn \"Timed out opening connection to collector after #{elapsed} seconds. If this problem persists, please see http://status.newrelic.com\"\n raise\n ensure\n @in_session = false\n close_shared_connection\n end\n end", "def websocket_client\n @websocket_client ||= Faye::WebSocket::Client.new(rtm_start.websocket_url)\n end", "def connect\n require 'osc-ruby' unless defined?(::OSC)\n port = additional_params[:port] || 3333\n @client = OSC::Server.new(port)\n super\n end", "def new\n\t\t@client = Client.new\n\tend", "def connect(options = {})\n @connection ||= ::RbRouting::Connection.new(options)\n end", "def connect\n rabbit.transaction_short do\n @publisher = Rabbit::Publisher::Admin.new(rabbit.channel)\n yield\n end\n end", "def connection(&blk)\n @connection ||= Connection.build endpoint.secret, &blk\n end", "def open_connection\n # DataObjects::Connection.new(uri) will give you back the right\n # driver based on the DataObjects::URI#scheme\n connection = connection_stack.last || DataObjects::Connection.new(normalized_uri)\n connection_stack << connection\n connection\n end", "def connection\n @connection || Connection.new\n end", "def connection\n raise ConnectionNotEstablished unless @@connection\n return @@connection\n end", "def create_tcp_client_channel(params)\n begin\n channel = SocketSubsystem::TcpClientChannel.open(client, params)\n if channel != nil\n return channel.lsock\n end\n return nil\n rescue ::Rex::Post::Meterpreter::RequestError => e\n case e.code\n when 10000 .. 10100\n raise ::Rex::ConnectionError.new\n end\n raise e\n end\n end" ]
[ "0.66360945", "0.6550528", "0.64999807", "0.6062877", "0.5976772", "0.5913682", "0.5913102", "0.591306", "0.58838266", "0.58361375", "0.5823498", "0.5796797", "0.5780779", "0.5761988", "0.57447934", "0.57340795", "0.5719682", "0.5711008", "0.57009107", "0.565251", "0.5641438", "0.5638724", "0.56380415", "0.56298304", "0.5623353", "0.56067634", "0.5601653", "0.56005114", "0.5595114", "0.5581073", "0.5568354", "0.55655843", "0.55652004", "0.55623126", "0.556129", "0.555482", "0.5541649", "0.5537897", "0.5537412", "0.5518684", "0.55175257", "0.55138683", "0.5502241", "0.5498151", "0.549506", "0.5490833", "0.54902864", "0.5486741", "0.5486233", "0.5477955", "0.5476698", "0.5471765", "0.5440231", "0.54364806", "0.5435168", "0.5431906", "0.54318273", "0.5430745", "0.5428172", "0.5424909", "0.54182065", "0.54173964", "0.54113966", "0.54113966", "0.54113966", "0.54071164", "0.5403605", "0.54012764", "0.54012764", "0.5393237", "0.53931016", "0.53861254", "0.53803796", "0.5371293", "0.53681934", "0.5356683", "0.5347683", "0.53461814", "0.5345496", "0.53413975", "0.5339644", "0.5337306", "0.5327404", "0.53258646", "0.53250396", "0.53234786", "0.5318829", "0.5317027", "0.5316314", "0.53157705", "0.53110397", "0.53072125", "0.529017", "0.52900976", "0.5287577", "0.527802", "0.5276093", "0.5271918", "0.5268806", "0.52676487" ]
0.64861387
3
Register a card that has been duplicated so it can be remapped
def register_duplicated_card(original_card_id:, to_card_id:) Cache.hash_set("#{@batch_id}_duplicated_cards", original_card_id, to_card_id) remapper = CardDuplicatorMapper::RemapLinkedCards.new( batch_id: @batch_id, ) # remap the card that was just duplicated remapper.remap_cards(original_card_id, to_card_id) # if all have completed, then we run through them all, basically a last pass # to ensure we match any links that were created later than the duplicates, etc. # TODO: How to ensure all cards were mapped or if duplication failed? return unless all_cards_mapped? remapper.call end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def addCard(givenCard)\n \tcards_users.create(card_id: givenCard.id, is_shared: false)\n end", "def add_card card\n card.deck = self\n @cards[card.id] = card\n end", "def add_card(card)\n \t@cards << card\n end", "def addSharedCard(givenCard)\n \tcards_users.create(card_id: givenCard.id, is_shared: true)\n end", "def add_card(card)\n @cards << card\n end", "def add_card(card)\n @cards << card\n end", "def take_card(card)\n @cards << card\n end", "def add_card(new_card)\n self.cards.append(new_card)\n end", "def add_card(card)\n raise \"invalid placement!\" unless valid_placement?(card)\n @store << card\n end", "def add_card(new_card)\n cards.push(new_card)\n end", "def add card\n @card_list.add card\n end", "def add card\n @card_list.add card\n end", "def add card\n @card_list.add card\n end", "def add card\r\n @card_list.add card\r\n end", "def add_card(card)\n @cards.push(card)\n end", "def replace_card_with_new(player, card)\n @deck << card\n @deck.shuffle!\n new_card = @deck.shift\n return if new_card == card\n # This will raise if player didn't have the old card\n player.replace_cards(@main_token, [card], [new_card])\n @output_streams.each { |os| os.new_cards(player.user) }\n end", "def add_hash_card(card)\n card[:type] = 'Simple' if card[:type].nil?\n @card = card\n @card\n end", "def add_card(card)\n @addhand = @addhand + card\n end", "def add_card card_uri\n self.card_uri = card_uri\n save\n end", "def add_card(card)\n card.save if card.kind_of?(Balanced::Card) && card.hash.nil?\n self.card_uri = Balanced::Utils.extract_uri_from_object(card)\n save\n end", "def add_card(card)\n @cards.push\n end", "def create_account_card\n tmp = Card.create! name: \"Company+scratch\"\n tmp.update! name: \"Company+*account\"\n end", "def addCardToHand(card)\n @hand << card\n end", "def setCard(newCard)\n\t\t#add the card to this players hand\n\t\t@hand[newCard.value] = newCard\n\n\t\t#delete the card from the not seen list\n\t\tif newCard.type == :person\n\t\t\t@suspectsNotSeen.delete(newCard)\n\t\telsif newCard.type == :place\n\t\t\t@locationsNotSeen.delete(newCard)\n\t\telse \n\t\t\t@weaponsNotSeen.delete(newCard)\n\t\tend\n\tend", "def hit(card)\n @cards[@cards.length] = card\n end", "def get_card(card)\n @hand.append(card)\n end", "def receive_card(a_card)\n @cards_in_hand << a_card\n end", "def add_card(card)\n @deck.add(card, :back)\n end", "def draw_card(card)\r\n\t\thand.add_card(card)\r\n\tend", "def addCard(card)\n \tif @can_get_cards\n \t @cards.push(card)\n else\n raise ArgumentError, \"Cards cannot be added to this hand anymore.\"\n \tend\n end", "def add(card)\n\t\t@hand_contents.push(card)\n\tend", "def include_card(name)\n raise \"Card '#{name}' not found.\" unless card = Cardlike.the_card(name)\n self << card\n end", "def << new_cards\n if new_cards.is_a?(PokerHand)\n new_cards = new_cards.to_a\n elsif new_cards.is_a?(Card) || new_cards.is_a?(String)\n new_cards = [new_cards]\n end\n \n #debugger\n new_cards.each do |nc|\n unless @@allow_duplicates\n raise \"A card with the value #{nc} already exists in this hand. Set PokerHand.allow_duplicates to true if you want to be able to add a card more than once.\" if self =~ /#{nc}/\n end\n \n @hand << Card.new(nc)\n end\n end", "def <<(card)\n @cards << card\n end", "def hit(card)\n @cards << card\n end", "def add_cards_to_deck(card)\n @game_deck.deck << card\n end", "def add card\n @cards.push card\n end", "def add card\r\n # Unlucky for some !\r\n # Sometimes Moody Players won't play.\r\n if rand(40)==13\r\n puts \"Moody player didn't play!\"\r\n else\r\n @card_list.add card\r\n end\r\n end", "def setCard( newCard )\n @cardsInHand.push(newCard)\n \n # since the computer player doesn't make bad guess, \n # we delete the card just received from the lists of potential right cards.\n i = 0\n while( i < @listOfAllSuspects.length )\n if( @listOfAllSuspects[i].value == newCard.value && @listOfAllSuspects[i].type == newCard.type )\n @listOfAllSuspects.delete_at(i)\n else\n i = i + 1\n end\n end\n \n i = 0\n while( i < @listOfAllLocations.length )\n if( @listOfAllLocations[i].type == newCard.type && @listOfAllLocations[i].value == newCard.value )\n @listOfAllLocations.delete_at(i)\n else\n i = i + 1\n end\n end\n \n i = 0\n while( i < @listOfAllWeapons.length )\n if( @listOfAllWeapons[i].type == newCard.type && @listOfAllWeapons[i].value == newCard.value )\n @listOfAllWeapons.delete_at(i)\n else\n i = i + 1\n end\n end\n end", "def dup\n Card.new @value, @suit\n end", "def save_card(card, type)\n card.each do |i|\n @cards.push(Card.new((i['number'].to_s + type.to_s), i['number'].to_s,\n type.to_s, i['value'].to_s))\n end\n end", "def add card\n if card.is_a? Card\n @hand.push card\n else\n @hand.push Card.new(card)\n end\n\n @analysis = analyse @hand\n end", "def create_card(address_book_id, card_uri, card_data)\n end", "def add(card)\n return unless card.is_a? Card\n # only allow cards to be added\n @cards << card\n end", "def add_a_card(card)\n if is_full?\n puts \"Deck is full.You can't add a card\"\n return false\n elsif empty?\n @deck << card\n @added_cards << card\n cards_left\n elsif !find_card(card)\n random = rand(cards_left)\n insert_card(random, card)\n @added_cards << card\n random\n else\n puts \"Can't add a duplicate card to the Deck\"\n return false\n end\n end", "def addCard(card)\n\t\t@cards << card\n\t\t@value += getValue(card.rank)\n\t\tif card.rank == 'Ace'\n\t\t\t@hasAce = true\n\t\tend\n\t\tif @cards.length == 2 and @value == 21 and @hasAce # updates should be in different method\n\t\t\t@blackjack = true\n\t\tend\n\t\tif @value > 21 and @hasAce\n\t\t\t@value -= 10\n\t\t\t@hasAce = false\n\t\tend\n\tend", "def add_to_hand(card)\n # add the new card to each \"hand\"\n @values = @values.map { |val| val + card.rank }\n\n # change accordngly if there is an ace\n update_for_ace if card.rank.eql?(1)\n\n @cards.push(card)\n end", "def register\n cc = 0\n end", "def find_card\n @client.remove_cards\n card = PayuLatam::Card.new(@client) # info de payu\n card.load( PayuCard.find(@selected_card).token )\n @client.add_card({token: card.resource['token']})\n end", "def create_card_from_hash(c)\n card = set_card_details(Card.new, c)\n card.save!\n card\nend", "def add_card_to_hand(curr_hand)\n curr_hand.push(get_rand_card)\n end", "def add_card(c)\n @cards_showing.push(c)\n @table_size += 1\n end", "def buy_card(card_name)\n mapping = Cardmapping.find_by(name: card_name)\n current_player.discard.cards.create!( cardmapping_id: mapping.id ) \n decrement_supply_count(card_name, 1)\n update_attributes(buys: buys - 1, treasure: treasure - mapping.cost )\n end", "def add_card_without_revealing_details(card)\n player.add_card_to_hand(card)\n message = \"#{player.name} drew a card from the center.\"\n game.players.each {|player| player.send_message_to_user(message)}\n end", "def insert_random(card)\n @cards.insert(Random.new().rand(0...@cards.count), card)\n end", "def add_card(name, suit, rank)\r\n card = Card.new(name, suit, rank)\r\n @cards << card\r\n @order << card.to_s\r\n end", "def add_card(rank)\n @cards << Card.new(rank)\n end", "def create_card\n card = customer.sources.create(source: \"tok_amex\")\n self.stripe_card_id = card.id\n self.save\n card\n end", "def generate_card_number\n self.number = set_card_number\n generate_card_number if Card.exists?(number: self.number)\n end", "def create\n @card = Card.new(card_params)\n # todo violation\n @wallet.cards << @card\n respond_to do |format|\n if @wallet.save\n format.html { redirect_to wallet_path, notice: 'Card was successfully created.' }\n format.json { render json: @wallet, status: :ok, location: wallet_path }\n else\n format.html { render :new }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def give_card_to_player(card,player)\n\t\t#player is another player object\n\t\t@cards[card].times do\n\t\t\tplayer.add_card(card)\n\t\tend\n\n\n\t\t#remove cards from hand if selected by another player\n\t\tself.remove_set_from_hand(card)\n\tend", "def receive_revealed_card(position, value)\n # debugger\n @known_cards[position] = value\n end", "def add_card(card)\r\n\t\tcards << card\r\n\t\tcalc_value\r\n\tend", "def place(card)\n end", "def create\n @card = Card.new(params[:card])\n @card.user_id = session[:user_id]\n\n respond_to do |format|\n if @card.save\n listingcard = ListingCard.new do |m|\n m.memoword_id = session[:memoword_id]\n m.card_id = @card.id\n m.memorized = false\n end\n listingcard.save\n #format.html {render action: \"new\" }\n format.html { redirect_to new_card_url, notice: 'カードは作成されBookに登録されました' }\n format.json { render json: @card, status: :created, location: @card }\n else\n format.html { render action: \"new\" }\n format.json { render json: @card.errors, status: :unprocessable_entity }\n end\n end\n end", "def save_payment_card(card_name, token, exp)\n card = user.payment_cards.where(kind: payment_kind, last4: last4, name: card_name, exp: exp).first_or_create!(customer_id: token)\n self.payment_card = card\n start_recurring_payment if save\n end", "def register_for(id); end", "def set_card\n @card = LegacyCard.find(params[:id])\n end", "def receive_revealed_card(position, value)\n @known_cards[position] = value\n end", "def register(object)\n object_id = SecureRandom.uuid\n @objects[object_id] = object\n object_id\n end", "def receive_revealed_card(pos, value)\n @known_cards[pos] = value\n end", "def card_identifier\n raise 'card_identifier must be overwritten by the child class'\n end", "def return_card( card )\n @deck.unshift( card )\n end", "def add_creditcard(request, creditcard)\r\n\r\n cardNo = creditcard.number\r\n cardNo.strip!\r\n if ((cardNo.length == 44) || (cardNo =~ /[A-Z]/i) || (cardNo =~ /\\+/) || (cardNo =~ /\\=/))\r\n request.Set(RocketGate::GatewayRequest::CARD_HASH, creditcard.number)\r\n else\r\n request.Set(RocketGate::GatewayRequest::CARDNO, creditcard.number)\r\n request.Set(RocketGate::GatewayRequest::CVV2, creditcard.verification_value)\r\n request.Set(RocketGate::GatewayRequest::EXPIRE_MONTH, creditcard.month)\r\n request.Set(RocketGate::GatewayRequest::EXPIRE_YEAR, creditcard.year)\r\n request.Set(RocketGate::GatewayRequest::CUSTOMER_FIRSTNAME, creditcard.first_name)\r\n request.Set(RocketGate::GatewayRequest::CUSTOMER_LASTNAME, creditcard.last_name)\r\n end\r\n end", "def set_namecard\n @namecard = Namecard.find(params[:id])\n end", "def register\r\n \r\n end", "def generate_new_card\n new_card = @my_deck.grab_single_card\n old_card = @old_card\n user_guess = @guess\n puts \"\"\n puts new_card\n puts \"\"\n compare_cards(new_card, old_card, user_guess)\n end", "def register\n \n end", "def card(name, &block)\n c = Cardlike.card(name, &block)\n self << c\n c\n end", "def set_name_card\n @name_card = NameCard.find(params[:id])\n end", "def card(address_book_id, card_uri)\n end", "def register\n puts \"register\"\n ApiBase.client.put(\"/device/#{self.id}\", self.to_json)\n end", "def deal(card)\n\t\t@hand.push(card)\n\tend", "def newCard\n\t@card = Cards.new\n \t@card.random\n end", "def set_card\n # @card = Card.find(params[:id])\n end", "def registerCard\n parameters={user_id: (@current_user[\"id\"]).to_i, number: (params[:number]).to_i, amount: (params[:amount]).to_i, expiration_month: (params[:expiration_month]).to_i, expiration_year: (params[:expiration_year]).to_i}\n puts (parameters)\n options = {\n :body => parameters.to_json,\n :headers => {\n 'Content-Type' => 'application/json'\n }\n }\n results = HTTParty.post(\"http://192.168.99.104:3003/credit_cards\", options)\n if results.code == 201\n head 201\n else\n render json: results.parsed_response, status: results.code\n end\n end", "def addCardsToHand(cards)\n @hand.concat(cards)\n end", "def set_card_id\n\t\tself.card_id = self.deck.flashcards.count + 1\n\tend", "def add_commander_to_card(commander, card)\n card.add_member(commander) if commander\n end", "def push(card)\n error_unless_param_is_a_card card, \"push\"\n @stack.push(card)\n end", "def publish_as_global_card(card)\n request = card.to_request\n create_card_from_signed_request(request)\n end", "def duplicated_cards\n Cache.hash_get_all(\"#{@batch_id}_duplicated_cards\").presence || {}\n end", "def get_new_card\n \n #Assign a random number between 1 and 13 as the value of the card being \n #created\n card = 1 + rand(13)\n \n #A value of 1 is an ace, so reassign the card a value of 11\n return 11 if card == 1 \n\n #A value of 10 or more equals a face card so reassign the card a value\n #of 10 \n return 10 if card >= 10\n \n return card #Return the value assigned to the new card\n \n end", "def set_card_rack\n @card_rack = CardRack.find(params[:id])\n end", "def add_card_with_inversion card\n add_card card\n add_card card.invert\n end", "def set_card_instance\n @card_instance = CardInstance.find(params[:id])\n end", "def set_card_instance\n @card_instance = CardInstance.find(params[:id])\n end", "def create\n @reg_card = RegCard.new(params[:reg_card])\n\n respond_to do |format|\n if @reg_card.save\n flash[:success] = \"Card Created Successfully!\"\n format.html { redirect_to group_path(@reg_card.group) }\n format.json { render json: @reg_card, status: :created, location: @reg_card }\n else\n format.html { redirect_to group_path(@reg_card.group) }\n format.json { render json: @reg_card.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_card(name)\n card = Card.new(:name => name)\n card.url, page = goto_url(card_url(name))\n uri = page.scan(IMAGE_REGEXP)[0]\n\n if page && uri\n card.image_url = \"http://magiccards.info\" + uri[0]\n @db.insert(card.to_hash)\n card\n else\n nil\n end\n end", "def register_with_system(name)\n @unique_id = name.object_id\n end" ]
[ "0.67919964", "0.67069805", "0.66378534", "0.66062117", "0.65801567", "0.65801567", "0.6567602", "0.65265167", "0.6503379", "0.64770275", "0.63998014", "0.63998014", "0.63998014", "0.63933533", "0.63773215", "0.63613427", "0.63472915", "0.6335032", "0.6329207", "0.6318804", "0.63137114", "0.62845546", "0.6189468", "0.6183548", "0.61621565", "0.6159102", "0.6141546", "0.60968477", "0.6095455", "0.60719603", "0.60608006", "0.6030011", "0.6014473", "0.5999933", "0.5974607", "0.5964941", "0.59502816", "0.5941806", "0.5918686", "0.5907523", "0.5902672", "0.5898901", "0.58842397", "0.5877074", "0.5861741", "0.58592856", "0.5855865", "0.5852526", "0.5843803", "0.5837969", "0.58311087", "0.5827756", "0.5822345", "0.58016974", "0.5801104", "0.57927114", "0.57906026", "0.57778794", "0.57600385", "0.5742074", "0.5723386", "0.57128775", "0.5676522", "0.56688553", "0.56674427", "0.5661406", "0.56447405", "0.562899", "0.5621609", "0.5620436", "0.5609979", "0.5582955", "0.55686307", "0.55546916", "0.5536347", "0.55204093", "0.5516486", "0.55141056", "0.5512671", "0.54997367", "0.5491014", "0.5488077", "0.5481009", "0.5479194", "0.54758203", "0.546087", "0.54574126", "0.5452717", "0.5447688", "0.5441059", "0.5439363", "0.5436957", "0.54353803", "0.5434085", "0.54313976", "0.5429119", "0.5429119", "0.5428393", "0.5415374", "0.5403441" ]
0.7502256
0
A hash of all cards that have been marked that they may need to be updated after duplication is complete
def linked_cards Cache.hash_get_all("#{@batch_id}_linked_cards").presence || {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def duplicated_cards\n Cache.hash_get_all(\"#{@batch_id}_duplicated_cards\").presence || {}\n end", "def hash\n super() ^ @hidden_cards.hash\n end", "def hash\n # Memoizing such a simple hash value seems silly, however the\n # profiler showed the Card#hash method as having 22% of the runtime. My\n # memoizing the hash value that was reduced to 12%.\n return @hash unless @hash.nil?\n @hash = @value.hash ^ @suit.hash\n end", "def hash\n [created_time, last_modified_time, token, user_token, card_product_token, last_four, pan, expiration, expiration_time, cvv_number, chip_cvv_number, barcode, pin_is_set, state, state_reason, fulfillment_status, reissue_pan_from_card_token, fulfillment, bulk_issuance_token, translate_pin_from_card_token, activation_actions, instrument_type, expedite, metadata, contactless_exemption_counter, contactless_exemption_total_amount].hash\n end", "def hash\n [id, id_account, webid, application_date, date, value, gross_value, nature, original_wording, simplified_wording, stemmed_wording, wording, id_category, state, date_scraped, rdate, vdate, bdate, coming, active, id_cluster, comment, last_update, deleted, original_value, original_gross_value, original_currency, commission, commission_currency, country, counterparty, card].hash\n end", "def card_in_game\n (2..14).each {|r| (1..4).each { |i| @pack_of_card << [i, r] }}\n @cards = @pack_of_card.shuffle.take(7)\n # @hash_7_card is hash prepared for analyze combinations and the highest combination to win\n $hash_7_card = array_suit_rank\n end", "def hash\n @rank.hash ^ @suit.hash\n end", "def hash\n [color, cards, address_placement, custom_envelope, double_sided, extra_service, mail_type, return_envelope, bleed, file_original_url].hash\n end", "def hash\n # TODO: Produce a hash (using default hash method) of the credit card's\n # serialized contents.\n # Credit cards with identical information should produce the same hash.\n self.to_s.hash\nend", "def hash\n [rank, suit].hash\n end", "def hash\n [cardtransaction_id, card_id, wallet_id, acquirer_id, wallet_currency, merchant_id, merchant_name, merchant_city, merchant_country, mcc_code, payment_local_time, public_token, payment_amount, payment_currency, fees, payment_country, payment_id, payment_status, payment_local_amount, pos_cardholder_presence, pos_postcode, pos_country, pos_terminal_id, pos_card_presence, pan_entry_method, authorization_note, authorization_response_code, authorization_issuer_id, authorization_issuer_time, authorization_mti, authorized_balance, limit_atm_year, limit_atm_month, limit_atm_week, limit_atm_day, limit_atm_all, limit_payment_year, limit_payment_month, limit_payment_week, limit_payment_day, limit_payment_all, total_limit_atm_year, total_limit_atm_month, total_limit_atm_week, total_limit_atm_day, total_limit_atm_all, total_limit_payment_year, total_limit_payment_month, total_limit_payment_week, total_limit_payment_day, total_limit_payment_all, total_rows].hash\n end", "def hash\n [commseq_postcard_uuid, commseq_step_uuid, commseq_uuid, conversion_dts, cost, customer_uuid, delivered_dts, from_address_line1, from_address_line2, from_city, from_name, from_state, from_zip, mailed_dts, order_id, postcard_tracking_uuid, status, submit_dts, to_address_line1, to_address_line2, to_city, to_name, to_state, to_zip, tracking_description].hash\n end", "def straight_flush_wake(array)\n #to initialize the hash use '.new'\n hash = Hash.new(0)\n suit = array.first.suit\n #to get suit to increment\n array.each{|card| hash[card.suit] +=1}\n hash.keys.length == 1 && hash [suit] == 5\nend", "def hash\n [bin_commercial, bin_corporate, bin_country_issued, bin_credit, bin_currency, bin_debit, bin_description, bin_eu, card_id, card_status, default, expmonth, expyear, label, label2, last4digits, scheme, token].hash\n end", "def valid_table(cards_showing)\n\n # make hash of all table cards\n # id is the key, location is the value\n table_hash = Hash.new\n return [] if cards_showing.length < 1\n\n (0...cards_showing.length).each {|i| table_hash[cards_showing[i].id] = i}\n\n (0...cards_showing.length).each do |card1|\n (1...cards_showing.length).each do |card2|\n if card1 == card2 #skip if same card\n next\n end\n\n # Find attributes of the last card needed\n # Using the attributes of any two cards, you can determine what the final card would be that would make a set\n # This finds the attributes of that last card, which is later used to see if that card is available\n card_to_find = 27 * ((6- cards_showing[card1].number - cards_showing[card2].number) % 3)\n card_to_find += 9 * ((6- cards_showing[card1].color - cards_showing[card2].color) %3)\n card_to_find += 3 * ((6- cards_showing[card1].shape - cards_showing[card2].shape) %3)\n card_to_find += (6-cards_showing[card1].shade - cards_showing[card2].shade) %3\n\n # cardToFind is now the card ID for the last card\n return [card1, card2, table_hash[card_to_find]] if table_hash.include? card_to_find\n\n end\n end\n\n return []\n end", "def hash\n [id, merchant_id, capacity, area_id, date_time, order_id, extra_info, promo_code, credit_card_vault_settings_id, recurring_card_detail_id, deals].hash\n end", "def deck_of_cards\n deck_hash = {h2: 2, h3: 3, h4: 4, h5: 5, h6: 6, h7: 7, h8: 8, h9: 9, h10: 10, hj: 10, hq: 10, hk: 10, ha: 11,\n d2: 2, d3: 3, d4: 4, d5: 5, d6: 6, d7: 7, d8: 8, d9: 9, d10: 10, dj: 10, dq: 10, dk: 10, da: 11,\n s2: 2, s3: 3, s4: 4, s5: 5, s6: 6, s7: 7, s8: 8, s9: 9, s10: 10, sj: 10, sq: 10, sk: 10, sa: 11,\n c2: 2, c3: 3, c4: 4, c5: 5, c6: 6, c7: 7, c8: 8, c9: 9, c10: 10, cj: 10, cq: 10, ck: 10, ca: 11}\nend", "def flush_cards(cards)\n\t\thsh = {}\n\t\tcards.each {|c| hsh[c.suit] ||= []; hsh[c.suit] << c}\n\t\tret = []\n\t\thsh.each {|suit, suit_cards| ret = suit_cards if suit_cards.size > ret.size}\n\t\tret.sort_by {|x| x.sort_value}\n\tend", "def full_card_map\n return @@full_card_map if defined? @@full_card_map\n @@full_card_map ||= Hash[card_json_data.map {|card|\n [card['id'], card]\n }]\n end", "def hash\n [lac, cid, radio, mcc, mnc, signal, psc, asu, ta].hash\n end", "def unique_checkouts(books)\n unique_members = Hash.new { 0 }\n books.each do |book|\n book.checkouts.each do |checkout|\n unique_members[checkout.name] += 1\n end\n end\n unique_members.keys.count\nend", "def color_changing_cards(card)\n @prob_cache[4000 + card.code] ||= @stack.select { |c| (c.figure == card.figure && c.color != card.color) || c.special_card? }.length\n end", "def history_card_ids\n field_card_ids << id\nend", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash\n [airline_data, amount, avs_postcode_policy, bill_to, card_holder_name, cardnumber, csc, csc_policy, currency, duplicate_policy, expmonth, expyear, external_mpi, identifier, match_avsa, mcc6012, merchantid, sdk, ship_to, threedsecure, trans_info, trans_type].hash\n end", "def digestable_hash\n @item.slice(CLASS, QUEUE, LOCK_ARGS, APARTMENT).tap do |hash|\n hash.delete(QUEUE) if unique_across_queues?\n hash.delete(CLASS) if unique_across_workers?\n end\n end", "def flush\n fl=Hash.new\n @hash_7_card.each {|s, r|\n next unless r.length >= 5 #если более либо равно 5 карт в масти то сравнивается массив масти и все комбинации этой номинации\n fl[s] = r[0..4]\n return fl\n }\n nil\n end", "def high_card\n (0..12).each { |i|\n fok = Hash.new(nil)\n @hash_7_card.each { |s, _r|\n next unless [14 - i] & @hash_7_card[s] == [14 - i]\n fok[s] = [14 - i]\n return fok\n }\n }\n nil\n end", "def digest_card_data\n @sha256 = self.class.set_digest\n\n self.card_number = @sha256.base64digest(@card_number_undigest) if @card_number_undigest.present?\n self.cvv = @sha256.base64digest(@cvv_undigest) if @cvv_undigest.present?\n\n @cvv_undigest = nil\n @card_number_undigest = nil\n end", "def matched_cards\n result = {}\n for card in @cards do\n if card.wild? ## wild cards belong to all ranks \n for rank in Rank::RANKS do\n result[rank] ||= []\n result[rank] << card\n end \n else \n result[card.rank] ||= []\n result[card.rank] << card\n end \n end\n return result\n end", "def flush(hand)\n suits = hand.map { |card| card[1] }\n return suits.uniq.one?\nend", "def sharedCards\n \tcus_shared_with_user = cards_users.where(user_id: self.id, is_shared: true)\n\n \t# Have a list of CardsUsers, but want a list of Shared Cards\n \tshared_cards = []\n \tcus_shared_with_user.each do | cu |\n \t\tcard = Card.find(cu.card_id)\n \t\tshared_cards.push(card)\n \tend\n \tshared_cards\n end", "def hash\n [class_id, object_type, acs_control_gpu1state, acs_control_gpu2state, acs_control_gpu3state, acs_control_gpu4state, acs_control_gpu5state, acs_control_gpu6state, acs_control_gpu7state, acs_control_gpu8state, acs_control_slot11state, acs_control_slot12state, acs_control_slot13state, acs_control_slot14state, adjacent_cache_line_prefetch, advanced_mem_test, all_usb_devices, altitude, aspm_support, assert_nmi_on_perr, assert_nmi_on_serr, auto_cc_state, autonumous_cstate_enable, baud_rate, bme_dma_mitigation, boot_option_num_retry, boot_option_re_cool_down, boot_option_retry, boot_performance_mode, burst_and_postponed_refresh, c1auto_demotion, c1auto_un_demotion, cbs_cmn_apbdis, cbs_cmn_cpu_cpb, cbs_cmn_cpu_gen_downcore_ctrl, cbs_cmn_cpu_global_cstate_ctrl, cbs_cmn_cpu_l1stream_hw_prefetcher, cbs_cmn_cpu_l2stream_hw_prefetcher, cbs_cmn_cpu_smee, cbs_cmn_cpu_streaming_stores_ctrl, cbs_cmn_determinism_slider, cbs_cmn_efficiency_mode_en, cbs_cmn_fixed_soc_pstate, cbs_cmn_gnb_nb_iommu, cbs_cmn_gnb_smu_df_cstates, cbs_cmn_gnb_smucppc, cbs_cmn_mem_ctrl_bank_group_swap_ddr4, cbs_cmn_mem_map_bank_interleave_ddr4, cbs_cmnc_tdp_ctl, cbs_cpu_ccd_ctrl_ssp, cbs_cpu_core_ctrl, cbs_cpu_smt_ctrl, cbs_dbg_cpu_snp_mem_cover, cbs_dbg_cpu_snp_mem_size_cover, cbs_df_cmn_acpi_srat_l3numa, cbs_df_cmn_dram_nps, cbs_df_cmn_mem_intlv, cbs_df_cmn_mem_intlv_size, cbs_sev_snp_support, cdn_enable, cdn_support, channel_inter_leave, cisco_adaptive_mem_training, cisco_debug_level, cisco_oprom_launch_optimization, cisco_xgmi_max_speed, cke_low_policy, closed_loop_therm_throtl, cmci_enable, config_tdp, config_tdp_level, console_redirection, core_multi_processing, cpu_energy_performance, cpu_frequency_floor, cpu_perf_enhancement, cpu_performance, cpu_power_management, cr_qos, crfastgo_config, dcpmm_firmware_downgrade, demand_scrub, direct_cache_access, dram_clock_throttling, dram_refresh_rate, dram_sw_thermal_throttling, eadr_support, edpc_en, enable_clock_spread_spec, enable_mktme, enable_sgx, enable_tme, energy_efficient_turbo, eng_perf_tuning, enhanced_intel_speed_step_tech, epoch_update, epp_enable, epp_profile, execute_disable_bit, extended_apic, flow_control, frb2enable, hardware_prefetch, hwpm_enable, imc_interleave, intel_dynamic_speed_select, intel_hyper_threading_tech, intel_speed_select, intel_turbo_boost_tech, intel_virtualization_technology, intel_vt_for_directed_io, intel_vtd_coherency_support, intel_vtd_interrupt_remapping, intel_vtd_pass_through_dma_support, intel_vtdats_support, ioh_error_enable, ioh_resource, ip_prefetch, ipv4http, ipv4pxe, ipv6http, ipv6pxe, kti_prefetch, legacy_os_redirection, legacy_usb_support, llc_alloc, llc_prefetch, lom_port0state, lom_port1state, lom_port2state, lom_port3state, lom_ports_all_state, lv_ddr_mode, make_device_non_bootable, memory_bandwidth_boost, memory_inter_leave, memory_mapped_io_above4gb, memory_refresh_rate, memory_size_limit, memory_thermal_throttling, mirroring_mode, mmcfg_base, network_stack, numa_optimized, nvmdimm_perform_config, onboard10gbit_lom, onboard_gbit_lom, onboard_scu_storage_support, onboard_scu_storage_sw_stack, operation_mode, os_boot_watchdog_timer, os_boot_watchdog_timer_policy, os_boot_watchdog_timer_timeout, out_of_band_mgmt_port, package_cstate_limit, panic_high_watermark, partial_cache_line_sparing, partial_mirror_mode_config, partial_mirror_percent, partial_mirror_value1, partial_mirror_value2, partial_mirror_value3, partial_mirror_value4, patrol_scrub, patrol_scrub_duration, pc_ie_ras_support, pc_ie_ssd_hot_plug_support, pch_usb30mode, pci_option_ro_ms, pci_rom_clp, pcie_ari_support, pcie_pll_ssc, pcie_slot_mraid1link_speed, pcie_slot_mraid1option_rom, pcie_slot_mraid2link_speed, pcie_slot_mraid2option_rom, pcie_slot_mstorraid_link_speed, pcie_slot_mstorraid_option_rom, pcie_slot_nvme1link_speed, pcie_slot_nvme1option_rom, pcie_slot_nvme2link_speed, pcie_slot_nvme2option_rom, pcie_slot_nvme3link_speed, pcie_slot_nvme3option_rom, pcie_slot_nvme4link_speed, pcie_slot_nvme4option_rom, pcie_slot_nvme5link_speed, pcie_slot_nvme5option_rom, pcie_slot_nvme6link_speed, pcie_slot_nvme6option_rom, pcie_slots_cdn_enable, pop_support, post_error_pause, post_package_repair, processor_c1e, processor_c3report, processor_c6report, processor_cstate, psata, pstate_coord_type, putty_key_pad, pwr_perf_tuning, qpi_link_frequency, qpi_link_speed, qpi_snoop_mode, rank_inter_leave, redirection_after_post, sata_mode_select, select_memory_ras_configuration, select_ppr_type, serial_port_aenable, sev, sgx_auto_registration_agent, sgx_epoch0, sgx_epoch1, sgx_factory_reset, sgx_le_pub_key_hash0, sgx_le_pub_key_hash1, sgx_le_pub_key_hash2, sgx_le_pub_key_hash3, sgx_le_wr, sgx_package_info_in_band_access, sgx_qos, sha1pcr_bank, sha256pcr_bank, single_pctl_enable, slot10link_speed, slot10state, slot11link_speed, slot11state, slot12link_speed, slot12state, slot13state, slot14state, slot1link_speed, slot1state, slot2link_speed, slot2state, slot3link_speed, slot3state, slot4link_speed, slot4state, slot5link_speed, slot5state, slot6link_speed, slot6state, slot7link_speed, slot7state, slot8link_speed, slot8state, slot9link_speed, slot9state, slot_flom_link_speed, slot_front_nvme10link_speed, slot_front_nvme10option_rom, slot_front_nvme11link_speed, slot_front_nvme11option_rom, slot_front_nvme12link_speed, slot_front_nvme12option_rom, slot_front_nvme13option_rom, slot_front_nvme14option_rom, slot_front_nvme15option_rom, slot_front_nvme16option_rom, slot_front_nvme17option_rom, slot_front_nvme18option_rom, slot_front_nvme19option_rom, slot_front_nvme1link_speed, slot_front_nvme1option_rom, slot_front_nvme20option_rom, slot_front_nvme21option_rom, slot_front_nvme22option_rom, slot_front_nvme23option_rom, slot_front_nvme24option_rom, slot_front_nvme2link_speed, slot_front_nvme2option_rom, slot_front_nvme3link_speed, slot_front_nvme3option_rom, slot_front_nvme4link_speed, slot_front_nvme4option_rom, slot_front_nvme5link_speed, slot_front_nvme5option_rom, slot_front_nvme6link_speed, slot_front_nvme6option_rom, slot_front_nvme7link_speed, slot_front_nvme7option_rom, slot_front_nvme8link_speed, slot_front_nvme8option_rom, slot_front_nvme9link_speed, slot_front_nvme9option_rom, slot_front_slot5link_speed, slot_front_slot6link_speed, slot_gpu1state, slot_gpu2state, slot_gpu3state, slot_gpu4state, slot_gpu5state, slot_gpu6state, slot_gpu7state, slot_gpu8state, slot_hba_link_speed, slot_hba_state, slot_lom1link, slot_lom2link, slot_mezz_state, slot_mlom_link_speed, slot_mlom_state, slot_mraid_link_speed, slot_mraid_state, slot_n10state, slot_n11state, slot_n12state, slot_n13state, slot_n14state, slot_n15state, slot_n16state, slot_n17state, slot_n18state, slot_n19state, slot_n1state, slot_n20state, slot_n21state, slot_n22state, slot_n23state, slot_n24state, slot_n2state, slot_n3state, slot_n4state, slot_n5state, slot_n6state, slot_n7state, slot_n8state, slot_n9state, slot_raid_link_speed, slot_raid_state, slot_rear_nvme1link_speed, slot_rear_nvme1state, slot_rear_nvme2link_speed, slot_rear_nvme2state, slot_rear_nvme3link_speed, slot_rear_nvme3state, slot_rear_nvme4link_speed, slot_rear_nvme4state, slot_rear_nvme5state, slot_rear_nvme6state, slot_rear_nvme7state, slot_rear_nvme8state, slot_riser1link_speed, slot_riser1slot1link_speed, slot_riser1slot2link_speed, slot_riser1slot3link_speed, slot_riser2link_speed, slot_riser2slot4link_speed, slot_riser2slot5link_speed, slot_riser2slot6link_speed, slot_sas_state, slot_ssd_slot1link_speed, slot_ssd_slot2link_speed, smee, smt_mode, snc, snoopy_mode_for2lm, snoopy_mode_for_ad, sparing_mode, sr_iov, streamer_prefetch, svm_mode, terminal_type, tpm_control, tpm_pending_operation, tpm_support, tsme, txt_support, ucsm_boot_order_rule, ufs_disable, uma_based_clustering, upi_link_enablement, upi_power_management, usb_emul6064, usb_port_front, usb_port_internal, usb_port_kvm, usb_port_rear, usb_port_sd_card, usb_port_vmedia, usb_xhci_support, vga_priority, virtual_numa, vmd_enable, vol_memory_mode, work_load_config, xpt_prefetch, xpt_remote_prefetch, organization, profiles].hash\n end", "def hash\n [id, sender, receiver, text, status, contact_id, session_id, message_time, avatar, deleted, charset, charset_label, first_name, last_name, country, phone, price, parts_count, from_email, from_number].hash\n end", "def unique_collection_card\n !!!Collection.find_by(\n card_id: self.card_id,\n user_id: self.user_id,\n magic_set_id: self.magic_set_id,\n premium: self.premium,\n wishlist: self.wishlist,\n condition: self.condition\n )\n end", "def fingerprint\n self.all_tags.to_s.md5\n end", "def hash\n size.hash ^ rank.hash\n end", "def git_checksum_hash(tree, prefix=nil)\n\n tree.contents.each do |obj|\n if obj.class == Grit::Blob\n item = [prefix, obj.name].join\n @currenthash[item] = Digest::MD5.hexdigest(obj.data)\n #puts \"#{item} : \" + @currenthash[item]\n else\n git_checksum_hash(obj, [prefix, obj.name, \"/\"].join)\n end\n end\n\n return @currenthash\n end", "def card_map\n return @@card_map if defined? @@card_map\n @@card_map ||= Hash[card_json_data.map {|card|\n [card['id'], card_data(card)]\n }]\n end", "def hash\n [currency_code, memo, partial_auth, transaction_type, description, transaction_category_id, use_audit_log, merchant_category_code, card_id, transaction_category, cleanse_data, auth_type, mid, transaction_status_scope, location, merchant, amount, date, merchant_id].hash\n end", "def pseudo_chalkler_bookings\n \n h = Hash.new {|h, c| h[c] = @booking_set.bookings.select{|b| b.pseudo_chalkler_email == c } }\n @booking_set.bookings.collect(&:pseudo_chalkler_email).uniq.compact.map {|c| h[c] }\n h\n end", "def hash\n self.atoms.hash\n end", "def hash\n [deleted, edited_by_user, email_communication_sequence_email_uuid, email_communication_sequence_uuid, email_container_cjson, email_container_cjson_last_modified_dts, email_template_vm_path, filter_profile_equation_json, individually_render, library_item_oid, magic_link, merchant_id, pending_review, preview_text, rejected, requires_review, screenshot_large_full_url, screenshot_large_viewport_url, screenshot_small_full_url, screenshot_small_viewport_url, smart_sending, storefront_oid, subject, suspended_for_spam, transactional_email, version].hash\n end", "def hash\n [id, banco, agencia, conta_corrente, especie, numero_convenio, carteira, codigo_cedente, especie_tipo, especie_documento, aceite, instrucoes, local_pagamento1, local_pagamento2, endereco_cobranca_emissor, nome_beneficiario, cnpj_beneficiario, operador, data, maquina].hash\n end", "def armors_hash()\n return @armors\n end", "def calculate_unique_hash\n unique = ''\n unique += self.content if self.content.present?\n unique += self.summary if self.summary.present?\n unique += self.title if self.title.present?\n self.unique_hash = Digest::MD5.hexdigest unique\n end", "def unique_cards(game_deck, faces, suits)\n faces.each do |face|\n suits.each do |suit|\n c = Card.new(face,suit)\n card_value_determiner(c)\n game_deck.deck << c\n end\n end\nend", "def rehash() end", "def budget_cards(budget)\n budget.cards.uniq\n end", "def hash; map{|el| \"#{el.name} @ #{el.hash}\"}; map(&:hash).reduce(:+) % 2**32; end", "def hash\n [serial_number, timestamp, description, controller_id, device_id, subdevice_id, segment_id, event_type, event_subtype, event_text, badge_id, badge_id_str, badge_extended_id, badge_issue_code, asset_id, cardholder_key, alarm_priority, alarm_ack_blue_channel, alarm_ack_green_channel, alarm_ack_red_channel, alarm_blue_channel, alarm_green_channel, alarm_red_channel, access_result, cardholder_entered, duress, controller_name, event_source_name, cardholder_first_name, cardholder_last_name, device_name, subdevice_name, must_acknowledge, must_mark_in_progress].hash\n end", "def hash\n [mcc, uf, id_antecipacao_simulada, id_conta, id_compra, id_tipo_transacao, quantidade_parcelas_antecipaveis, valor_parcela, data_hora_simulacao, taxa_antecipacao_ano, nome_estabelecimento, status, data_compra, tipo_origem_transacao, cidade, pais, latitude, longitude, id_grupo_mcc, descricao_grupo_mcc, id_produto, descricao_produto, descricao_estabelecimento, nome_fantasia_estabelecimento, detalhes].hash\n end", "def hash()\n #This is a stub, used for indexing\n end", "def hash\n [id, user_id, input_audio_id, output_audio_id, output_video_id, reference_audio_id, mode, status, failure_reason, target_loudness_mode, target_loudness, output_format, preset, bit_depth, sample_rate, review_comment, review_score, mastering_matching_level, progression, bass_preservation, mastering, mastering_algorithm, preserved, retry_count, mastering_reverb, mastering_reverb_gain, low_cut_freq, high_cut_freq, ceiling, ceiling_mode, oversample, limiting_error, video_title, video_status, expire_at, created_at, updated_at].hash\n end", "def hash\n [additional_contact_billing_id, additional_contact_billing_is_primary, additional_contact_billing_name, additional_contact_executive_sponsor_id, additional_contact_executive_sponsor_is_primary, additional_contact_executive_sponsor_name, additional_contact_hiring_manager_id, additional_contact_hiring_manager_is_primary, additional_contact_hiring_manager_name, additional_contact_internal_recruiter_id, additional_contact_internal_recruiter_is_primary, additional_contact_internal_recruiter_name, additional_contact_other_id, additional_contact_other_is_primary, additional_contact_other_name, attachments, created_by_id, created_by_name, created_on, expected_value, external_email_address, id, job_code, last_activity_date, last_engagement_date, modified_by_id, modified_by_name, modified_on, owners, status_id, status_name, time_to_close, actual_value, additional_contact_client_first_name, additional_contact_client_id, additional_contact_client_is_primary, additional_contact_client_last_name, address_business_city, address_business_country, address_business_is_primary, address_business_line1, address_business_state, address_business_zip_code, address_other_city, address_other_country, address_other_is_primary, address_other_line1, address_other_state, address_other_zip_code, bill_rate, bonus, commission, company_id, company_name, compensation, compensation_details, custom_field1, custom_field10, custom_field11, custom_field12, custom_field13, custom_field14, custom_field15, custom_field16, custom_field17, custom_field18, custom_field19, custom_field2, custom_field20, custom_field21, custom_field22, custom_field23, custom_field24, custom_field25, custom_field26, custom_field27, custom_field28, custom_field29, custom_field3, custom_field30, custom_field4, custom_field5, custom_field6, custom_field7, custom_field8, custom_field9, description, discount, estimated_close_date, external_primary_key, fee, fee_percent, hourly_rate, is_lead, is_on_hold, job_title_id, job_title_name, job_types, lead_source_id, lead_source_name, margin, name, number_of_openings, opportunity_type_id, opportunity_type_name, parent_job_id, parent_job_name, pay_rate, potential_value, priority_id, priority_name, probability, salary, start_date, tags, total_hours, website_description, website_description_is_primary, website_other, website_other_is_primary].hash\n end", "def card_tags\n select('id, hostname').inject({}) do |hash, s|\n hash[s.hostname] = { server_id: s.id }\n hash\n end.with_indifferent_access\n end", "def cards_by_suit\n @cards_by_suit ||= @cards.group_by(&:suit)\n end", "def key(card_json); [card_json['set_name'], card_json['collector_num']]; end", "def hash\n [sequence_number, corporate_number, process, correct, update_date, change_date, name, name_image_id, kind, prefecture_name, city_name, street_number, address_image_id, prefecture_code, city_code, post_code, address_outside, address_outside_image_id, close_date, close_cause, successor_corporate_number, change_cause, assignment_date, latest, en_name, en_prefecture_name, en_city_name, en_address_outside, furigana, hihyoji].hash\n end", "def hash\n [is_blueprint_copy, is_included, item_id, material_efficiency, quantity, record_id, runs, time_efficiency, type_id].hash\n end", "def hash\n Zlib.crc32(to_a.map(&:to_s).sort.to_s)\n end", "def hash_code; end", "def hash\n [mandate_id, title, legal_informations, unique_mandate_reference, mandate_status, user_id, debtor_name, debtor_address, debtor_city, debtor_zip_code, debtor_country, debtor_iban, debtor_bic, sequence_type, creditor_name, sepa_creditor_identifier, creditor_address, creditor_city, creditor_zip_code, creditor_country, signature_date, debtor_signature_ip, signed, debtor_identification_code, debtor_reference_party_name, debtor_reference_identification_code, creditor_reference_party_name, creditor_reference_identification_code, contract_identification_number, contract_description, is_paper, sdd_type, revocation_signature_date, created_ip, created_date, modified_date, user_id_ultimate_creditor].hash\n end", "def hash\n [apm_scanned_bytes, events_scanned_bytes, hour, logs_scanned_bytes, org_name, public_id, rum_scanned_bytes, total_scanned_bytes].hash\n end", "def card_on_file(card)\n all_cards = cards.map(&:card)\n end", "def matched_suits\n per_suit = {}\n # Count how many there are of each suit \n aid = @cards.each do |card| \n # Wildcards belong to all suits \n if card.wild?\n for suit in Suit::SUITS\n per_suit[suit] ||= 0\n per_suit[suit] += 1\n end\n else\n per_suit[card.suit] ||= 0\n per_suit[card.suit] += 1\n end\n end\n return per_suit\n end", "def hash\n @vbits.hash\n end", "def repeats\n cards.group_by &:value\n end", "def hash # :nodoc:\n identifier.hash ^ requirement.hash\n end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def hash; end", "def consistent_hash\n Zlib.crc32(self.to_yaml, 0)\n end", "def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end", "def hash\n @list.each_slice(16).map do |sub|\n \"%02x\" % sub.reduce(:^)\n end.join\n end", "def hash\n @__set.to_a.hash\n end", "def possible_duplicates\n @duplicates = {}\n check_last_name_duplicates if last_name.present?\n check_email_duplicates if email_address.present?\n check_phone_number_duplicates if phone_number.present?\n check_address_duplicates if address_1.present?\n @duplicates\n end", "def hash\n [oct, pc].hash\n end", "def collect_cards\n card = detect_in(@areas, :card) { |card| card.hit?(@mouse_pos) }\n return card unless card\n\n n = @pile.size - @pile.cards.index(card)\n tail_cards = @pile.cards.last(n)\n Hash[*tail_cards.map { |card| [card, card.pos] }.flatten]\n end", "def hash\n return super unless has_size?\n\n res = 0\n each do |el|\n res += el.hash\n end\n return res\n end", "def hash(*) end", "def hash\r\n a = 0\r\n @id.each_byte {|c| a += c.to_i}\r\n (a + @paired.to_i) * HASH_PRIME\r\n end", "def same_or_dif? card_arr\n card_arr.uniq.size != 2\nend", "def full_house\n (0..12).each { |i|\n fok = {}\n num = 0\n @hash_7_card.each { |s, _r|\n next unless [14 - i] & @hash_7_card[s] == [14 - i]\n fok[s] = [14 - i]\n num += 1\n next unless num==3\n (0..12).each { |j|\n fok_1 = Hash.new(nil)\n num_1 = 0\n @hash_7_card.each { |su, _ra|\n next unless [14 - j] & @hash_7_card[su] == [14 - j]\n fok_1[su] = [14 - j]\n num_1 += 1\n return fok,fok_1 if (num_1==2)&&(fok[su]!=fok_1[su])\n }\n }\n }\n }\n nil\n end", "def is_a_set?(cards)\n result = [false, 0]\n (0..(NB_CARAC-1)).inject(true) do |result[0], carac|\n nb_uniq = cards.map{|card|CARDS[card][carac]}.uniq.size\n result[1] += (nb_uniq == NB_ETAT ? 1 : 0)\n result[0] &&= nb_uniq == 1 || nb_uniq == NB_ETAT\n end\n result\n end", "def cards\n RecipeCard.all.select do |recipe_card|\n recipe_card.user == self\n end\n end", "def uniq() end" ]
[ "0.7276199", "0.68572944", "0.62788683", "0.6125981", "0.61204976", "0.6001791", "0.5956916", "0.5943199", "0.58915186", "0.5858628", "0.5857005", "0.5826576", "0.5824386", "0.58186543", "0.580839", "0.57961667", "0.5751639", "0.57414544", "0.57371646", "0.5718707", "0.5699936", "0.5694524", "0.56924033", "0.56859636", "0.56859636", "0.56859636", "0.56859636", "0.56859636", "0.56859636", "0.56859636", "0.5676721", "0.5670408", "0.5656989", "0.56566006", "0.5651107", "0.5645712", "0.5601668", "0.5595477", "0.55934596", "0.55621713", "0.5553948", "0.5547772", "0.5539461", "0.5535957", "0.5528078", "0.552646", "0.5522307", "0.55108917", "0.5508708", "0.55043983", "0.54956305", "0.5492017", "0.549195", "0.54780453", "0.5472248", "0.5464062", "0.5460811", "0.5451462", "0.5447258", "0.54470396", "0.5442406", "0.5440871", "0.5437937", "0.54308474", "0.5426738", "0.54259", "0.5423131", "0.5415893", "0.5412143", "0.54088324", "0.539254", "0.53899026", "0.53815055", "0.5380629", "0.5373796", "0.5369902", "0.5369902", "0.5369902", "0.5369902", "0.5369902", "0.5369902", "0.5369902", "0.5369902", "0.5369902", "0.5369902", "0.5369855", "0.5367177", "0.5367177", "0.5358982", "0.5358309", "0.5350103", "0.5347774", "0.53424394", "0.53414565", "0.53357184", "0.53332657", "0.5332625", "0.53255564", "0.53252673", "0.5322578" ]
0.60833347
5
A hash that maps from the original card id to the duplicated card id
def duplicated_cards Cache.hash_get_all("#{@batch_id}_duplicated_cards").presence || {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def register_duplicated_card(original_card_id:, to_card_id:)\n Cache.hash_set(\"#{@batch_id}_duplicated_cards\", original_card_id, to_card_id)\n\n remapper = CardDuplicatorMapper::RemapLinkedCards.new(\n batch_id: @batch_id,\n )\n # remap the card that was just duplicated\n remapper.remap_cards(original_card_id, to_card_id)\n\n # if all have completed, then we run through them all, basically a last pass\n # to ensure we match any links that were created later than the duplicates, etc.\n # TODO: How to ensure all cards were mapped or if duplication failed?\n return unless all_cards_mapped?\n\n remapper.call\n end", "def card_map\n return @@card_map if defined? @@card_map\n @@card_map ||= Hash[card_json_data.map {|card|\n [card['id'], card_data(card)]\n }]\n end", "def full_card_map\n return @@full_card_map if defined? @@full_card_map\n @@full_card_map ||= Hash[card_json_data.map {|card|\n [card['id'], card]\n }]\n end", "def hash\n [id, id_account, webid, application_date, date, value, gross_value, nature, original_wording, simplified_wording, stemmed_wording, wording, id_category, state, date_scraped, rdate, vdate, bdate, coming, active, id_cluster, comment, last_update, deleted, original_value, original_gross_value, original_currency, commission, commission_currency, country, counterparty, card].hash\n end", "def hash\n # TODO: Produce a hash (using default hash method) of the credit card's\n # serialized contents.\n # Credit cards with identical information should produce the same hash.\n self.to_s.hash\nend", "def hash\n super() ^ @hidden_cards.hash\n end", "def hash\n # Memoizing such a simple hash value seems silly, however the\n # profiler showed the Card#hash method as having 22% of the runtime. My\n # memoizing the hash value that was reduced to 12%.\n return @hash unless @hash.nil?\n @hash = @value.hash ^ @suit.hash\n end", "def hash\n [id, merchant_id, capacity, area_id, date_time, order_id, extra_info, promo_code, credit_card_vault_settings_id, recurring_card_detail_id, deals].hash\n end", "def hash\n \tcustom_unique_id.hash\n end", "def hash\n [rank, suit].hash\n end", "def hash\n [commseq_postcard_uuid, commseq_step_uuid, commseq_uuid, conversion_dts, cost, customer_uuid, delivered_dts, from_address_line1, from_address_line2, from_city, from_name, from_state, from_zip, mailed_dts, order_id, postcard_tracking_uuid, status, submit_dts, to_address_line1, to_address_line2, to_city, to_name, to_state, to_zip, tracking_description].hash\n end", "def hash\n [lac, cid, radio, mcc, mnc, signal, psc, asu, ta].hash\n end", "def history_card_ids\n field_card_ids << id\nend", "def hash\n @rank.hash ^ @suit.hash\n end", "def hash\n @id.hash\n end", "def hash\n [airline_data, amount, avs_postcode_policy, bill_to, card_holder_name, cardnumber, csc, csc_policy, currency, duplicate_policy, expmonth, expyear, external_mpi, identifier, match_avsa, mcc6012, merchantid, sdk, ship_to, threedsecure, trans_info, trans_type].hash\n end", "def hash\n [cardtransaction_id, card_id, wallet_id, acquirer_id, wallet_currency, merchant_id, merchant_name, merchant_city, merchant_country, mcc_code, payment_local_time, public_token, payment_amount, payment_currency, fees, payment_country, payment_id, payment_status, payment_local_amount, pos_cardholder_presence, pos_postcode, pos_country, pos_terminal_id, pos_card_presence, pan_entry_method, authorization_note, authorization_response_code, authorization_issuer_id, authorization_issuer_time, authorization_mti, authorized_balance, limit_atm_year, limit_atm_month, limit_atm_week, limit_atm_day, limit_atm_all, limit_payment_year, limit_payment_month, limit_payment_week, limit_payment_day, limit_payment_all, total_limit_atm_year, total_limit_atm_month, total_limit_atm_week, total_limit_atm_day, total_limit_atm_all, total_limit_payment_year, total_limit_payment_month, total_limit_payment_week, total_limit_payment_day, total_limit_payment_all, total_rows].hash\n end", "def hash\r\n a = 0\r\n @id.each_byte {|c| a += c.to_i}\r\n (a + @paired.to_i) * HASH_PRIME\r\n end", "def hash_dup\n save\n end", "def hash\r\n id.hash\r\n end", "def hash_code; end", "def hash\n return @id.hash\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n @id\n end", "def card_tags\n select('id, hostname').inject({}) do |hash, s|\n hash[s.hostname] = { server_id: s.id }\n hash\n end.with_indifferent_access\n end", "def hash\n [oct, pc].hash\n end", "def hash\n id.hash + 32 * bs_request.hash\n end", "def hash\n type.hash ^ (id.hash >> 1)\n end", "def card_id\n card.id\n end", "def hash\n id.hash\n end", "def hash\n id.hash\n end", "def hash\n id\n end", "def rehash() end", "def hash\n [color, cards, address_placement, custom_envelope, double_sided, extra_service, mail_type, return_envelope, bleed, file_original_url].hash\n end", "def hash\n id.hash\n end", "def hash\n __record_id.hash\n end", "def hash\n [sequence_number, corporate_number, process, correct, update_date, change_date, name, name_image_id, kind, prefecture_name, city_name, street_number, address_image_id, prefecture_code, city_code, post_code, address_outside, address_outside_image_id, close_date, close_cause, successor_corporate_number, change_cause, assignment_date, latest, en_name, en_prefecture_name, en_city_name, en_address_outside, furigana, hihyoji].hash\n end", "def hash_code\n hash_code = {}\n self.seq.each do |letter|\n hash_code.keys.include?(letter) ? hash_code[letter] += 1 : hash_code[letter] = 1\n end\n hash_code\n end", "def hash_id\n @hid\n end", "def hash\n [self.class, id].hash\n end", "def hash\n\t\t[@id].hash\n\tend", "def hash\n [id, alternate_id, type, first_name, surname, date_of_brith, date_of_birth, shipping_address, mailing_address, home_phone, mobile_phone, email_address, mailing_address_active, accounts, classifications, member_photo, gender, receive_email, receive_sms, password].hash\n end", "def hash\n @id\n end", "def hash\n [id, sender, receiver, text, status, contact_id, session_id, message_time, avatar, deleted, charset, charset_label, first_name, last_name, country, phone, price, parts_count, from_email, from_number].hash\n end", "def hash\n object_id\n end", "def add_hash_card(card)\n card[:type] = 'Simple' if card[:type].nil?\n @card = card\n @card\n end", "def hash\n [currency_code, memo, partial_auth, transaction_type, description, transaction_category_id, use_audit_log, merchant_category_code, card_id, transaction_category, cleanse_data, auth_type, mid, transaction_status_scope, location, merchant, amount, date, merchant_id].hash\n end", "def hash\n [bin_commercial, bin_corporate, bin_country_issued, bin_credit, bin_currency, bin_debit, bin_description, bin_eu, card_id, card_status, default, expmonth, expyear, label, label2, last4digits, scheme, token].hash\n end", "def fingerprint\n to_h(persist: true).except(:_id)\n end", "def hash\n [created_time, last_modified_time, token, user_token, card_product_token, last_four, pan, expiration, expiration_time, cvv_number, chip_cvv_number, barcode, pin_is_set, state, state_reason, fulfillment_status, reissue_pan_from_card_token, fulfillment, bulk_issuance_token, translate_pin_from_card_token, activation_actions, instrument_type, expedite, metadata, contactless_exemption_counter, contactless_exemption_total_amount].hash\n end", "def hash\n [id, banco, agencia, conta_corrente, especie, numero_convenio, carteira, codigo_cedente, especie_tipo, especie_documento, aceite, instrucoes, local_pagamento1, local_pagamento2, endereco_cobranca_emissor, nome_beneficiario, cnpj_beneficiario, operador, data, maquina].hash\n end", "def hash\n [id, data_vencimento_fatura_atraso, quantidade_dias_atraso, data_vencimento_acordo, quantidade_dias_atraso_corrigido, valor_saldo_devedor, taxa_correcao, valor_correcao, valor_iof, valor_saldo_corrigido, id_status_conta, descricao_status_conta, id_status_acordo, descricao_status_acordo, id_escritorio_cobranca, nome_escritorio_cobranca, email_pessoa_conta].hash\n end", "def hash\n size.hash ^ rank.hash\n end", "def hash\n [id, numero_estabelecimento, flag_matriz, id_grupo_economico, numero_receita_federal, nome, descricao, nome_fantasia, cep, nome_logradouro, numero_endereco, bairro, cidade, complemento, uf, cep2, nome_logradouro2, numero_endereco2, bairro2, cidade2, complemento2, uf2, obs, contato, email, flag_arquivo_secr_fazenda, flag_cartao_digitado, inativo, id_moeda, id_pais, associado_spc_brasil, mcc, id_tipo_estabelecimento, correspondencia, cargo_contato, tipo_pagamento, consulta, consulta2, consulta3, terminal, data_cadastramento, usuario].hash\n end", "def hash\n [mcc, uf, id_antecipacao_simulada, id_conta, id_compra, id_tipo_transacao, quantidade_parcelas_antecipaveis, valor_parcela, data_hora_simulacao, taxa_antecipacao_ano, nome_estabelecimento, status, data_compra, tipo_origem_transacao, cidade, pais, latitude, longitude, id_grupo_mcc, descricao_grupo_mcc, id_produto, descricao_produto, descricao_estabelecimento, nome_fantasia_estabelecimento, detalhes].hash\n end", "def set_id_to_cache_key_map\n @ids.each do |id|\n @id_to_cache_key_map[id] = {\n kit: get_kit_cache_key(id),\n saas: get_saas_cache_key(id)\n }\n end\n end", "def deck_of_cards\n deck_hash = {h2: 2, h3: 3, h4: 4, h5: 5, h6: 6, h7: 7, h8: 8, h9: 9, h10: 10, hj: 10, hq: 10, hk: 10, ha: 11,\n d2: 2, d3: 3, d4: 4, d5: 5, d6: 6, d7: 7, d8: 8, d9: 9, d10: 10, dj: 10, dq: 10, dk: 10, da: 11,\n s2: 2, s3: 3, s4: 4, s5: 5, s6: 6, s7: 7, s8: 8, s9: 9, s10: 10, sj: 10, sq: 10, sk: 10, sa: 11,\n c2: 2, c3: 3, c4: 4, c5: 5, c6: 6, c7: 7, c8: 8, c9: 9, c10: 10, cj: 10, cq: 10, ck: 10, ca: 11}\nend", "def hash\n [@creditor_id, @creditor_name, @debt_positions].hash\n end", "def hash\n @hash ||= @trace_id.hash ^ @is_new.hash ^ @span_id.hash ^\n @sampled.hash ^ @capture_stack.hash\n end", "def hash\n value_id.hash\n end", "def hash() source.hash ^ (target.hash+1); end", "def hash() source.hash ^ (target.hash+1); end", "def to_hash\n { :id => @id }\n end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def hash() end", "def one_pair\n (0..12).each { |i|\n fok = Hash.new(nil)\n num = 0\n @hash_7_card.each { |s, _r|\n next unless [14 - i] & @hash_7_card[s] == [14 - i]\n fok[s] = [14 - i]\n num += 1\n next unless num==2\n return fok\n }\n }\n nil\n end", "def hash(*) end", "def hash\n guid.hash\n end", "def hash\n [additional_contact_billing_id, additional_contact_billing_is_primary, additional_contact_billing_name, additional_contact_executive_sponsor_id, additional_contact_executive_sponsor_is_primary, additional_contact_executive_sponsor_name, additional_contact_hiring_manager_id, additional_contact_hiring_manager_is_primary, additional_contact_hiring_manager_name, additional_contact_internal_recruiter_id, additional_contact_internal_recruiter_is_primary, additional_contact_internal_recruiter_name, additional_contact_other_id, additional_contact_other_is_primary, additional_contact_other_name, attachments, created_by_id, created_by_name, created_on, expected_value, external_email_address, id, job_code, last_activity_date, last_engagement_date, modified_by_id, modified_by_name, modified_on, owners, status_id, status_name, time_to_close, actual_value, additional_contact_client_first_name, additional_contact_client_id, additional_contact_client_is_primary, additional_contact_client_last_name, address_business_city, address_business_country, address_business_is_primary, address_business_line1, address_business_state, address_business_zip_code, address_other_city, address_other_country, address_other_is_primary, address_other_line1, address_other_state, address_other_zip_code, bill_rate, bonus, commission, company_id, company_name, compensation, compensation_details, custom_field1, custom_field10, custom_field11, custom_field12, custom_field13, custom_field14, custom_field15, custom_field16, custom_field17, custom_field18, custom_field19, custom_field2, custom_field20, custom_field21, custom_field22, custom_field23, custom_field24, custom_field25, custom_field26, custom_field27, custom_field28, custom_field29, custom_field3, custom_field30, custom_field4, custom_field5, custom_field6, custom_field7, custom_field8, custom_field9, description, discount, estimated_close_date, external_primary_key, fee, fee_percent, hourly_rate, is_lead, is_on_hold, job_title_id, job_title_name, job_types, lead_source_id, lead_source_name, margin, name, number_of_openings, opportunity_type_id, opportunity_type_name, parent_job_id, parent_job_name, pay_rate, potential_value, priority_id, priority_name, probability, salary, start_date, tags, total_hours, website_description, website_description_is_primary, website_other, website_other_is_primary].hash\n end", "def hash(key); end", "def card_in_game\n (2..14).each {|r| (1..4).each { |i| @pack_of_card << [i, r] }}\n @cards = @pack_of_card.shuffle.take(7)\n # @hash_7_card is hash prepared for analyze combinations and the highest combination to win\n $hash_7_card = array_suit_rank\n end", "def hash_record! ht, rec, duplicate_type\n case duplicate_type\n when 1 # whole header match\n unless ht.has_key? rec.header\n ht[rec.header] = rec\n end\n when 2 # header ID match\n unless ht.has_key? rec.id\n ht[rec.id] = rec\n end\n when 3 # whole seq match\n unless ht.has_key? rec.seq\n ht[rec.seq] = rec\n end\n when 4 # whole seq + whole header\n key = \"#{rec.header}#{rec.seq}\"\n unless ht.has_key? key\n ht[key] = rec\n end\n when 5 # whole seq + hedaer ID\n key = \"#{rec.id}#{rec.seq}\"\n unless ht.has_key? key\n ht[key] = rec\n end\n end\nend", "def hash\n [id, rfc, legal_name, commercial_name, credit_days, credit_amount, payment_method, creation_date, status, sales_contact, credit_contact, loctaion, comments, price_list, payment_term_type, email, telephones, number, account_number, default_discount, client_source, account, addresses].hash\n end", "def identifiers_hash\n @identifiers_hash ||= {:default => [:uuid]}\n end", "def camera_ids\n return Hash[1 => '101', 2 => '201', 3 => '201']\n end", "def id\n Digest::SHA256.hexdigest(instance_variable_get(:@original_attributes).to_json)\n end", "def id\n Digest::SHA256.hexdigest(instance_variable_get(:@original_attributes).to_json)\n end", "def hash\n [serial_number, timestamp, description, controller_id, device_id, subdevice_id, segment_id, event_type, event_subtype, event_text, badge_id, badge_id_str, badge_extended_id, badge_issue_code, asset_id, cardholder_key, alarm_priority, alarm_ack_blue_channel, alarm_ack_green_channel, alarm_ack_red_channel, alarm_blue_channel, alarm_green_channel, alarm_red_channel, access_result, cardholder_entered, duress, controller_name, event_source_name, cardholder_first_name, cardholder_last_name, device_name, subdevice_name, must_acknowledge, must_mark_in_progress].hash\n end", "def hash\n @orig.hash\n end", "def hash\n @orig.hash\n end", "def hash\n @orig.hash\n end", "def color_changing_cards(card)\n @prob_cache[4000 + card.code] ||= @stack.select { |c| (c.figure == card.figure && c.color != card.color) || c.special_card? }.length\n end", "def shard_key(unmatched)\n if Hash === unmatched\n h = unmatched.dup\n h.delete(\"_id\")\n h.delete(:_id)\n h.map{|k,v| \"#{k}: #{v}\" }.join(\", \")\n end\n end", "def patch_duplicated_ref_ids(element,candidate_ref_id)\n flagged_standard_domain_ref_ids = ['7CB154907B5743c7B97BFCFF452D7977','F053D3437D1E4338A2C18B25DACBED85']\n flagged_cluster_ref_ids = ['B1AC98EADE4145689E70EEEBD9B8CC18','834B17E279C64263AA83F7625F5D2993','91FABAB899814C55851003A0EE98F8FB']\n flagged_duplicated_stadard_ref_ids = ['FBCBB7C696FE475695920CA622B1C857']\n if candidate_ref_id == 'F053D3437D1E4338A2C18B25DACBED85' and element.is_a?(Standard)\n return \"Standard:DUPLICATEDREF_ID:#{candidate_ref_id}\"\n elsif candidate_ref_id == 'F053D3437D1E4338A2C18B25DACBED85' and element.is_a?(Domain)\n return \"Domain:DUPLICATEDREF_ID:#{candidate_ref_id}\"\n elsif flagged_standard_domain_ref_ids.include?(candidate_ref_id) and element.is_a?(Standard)\n return \"Standard:DUPLICATEDREF_ID:#{candidate_ref_id}\"\n elsif flagged_cluster_ref_ids.include?(candidate_ref_id) and element.is_a?(Cluster)\n return \"Cluster:DUPLICATEDREF_ID:#{candidate_ref_id}:#{element.code}\"\n elsif flagged_duplicated_stadard_ref_ids.include?(candidate_ref_id) and element.is_a?(Standard)\n return \"Standard:DUPLICATEDREF_ID:#{candidate_ref_id}:#{element.code}\"\n else\n return candidate_ref_id\n end\n end", "def generate_card_number\n self.number = set_card_number\n generate_card_number if Card.exists?(number: self.number)\n end", "def hash; map{|el| \"#{el.name} @ #{el.hash}\"}; map(&:hash).reduce(:+) % 2**32; end" ]
[ "0.6899874", "0.66217256", "0.6553424", "0.6336948", "0.6322116", "0.6262354", "0.6208293", "0.6151167", "0.6149363", "0.6100726", "0.6077612", "0.60733", "0.60646814", "0.6054649", "0.6023997", "0.5946687", "0.59424937", "0.591993", "0.5900293", "0.5875312", "0.5863407", "0.58557874", "0.5833821", "0.5833744", "0.5833744", "0.5833744", "0.5833744", "0.5833744", "0.5833744", "0.5833744", "0.5833744", "0.5833744", "0.5826303", "0.5818645", "0.58033323", "0.57948613", "0.5790605", "0.57862496", "0.5768251", "0.5768251", "0.5766361", "0.57662416", "0.57604223", "0.57499766", "0.5742672", "0.5728391", "0.5724263", "0.57214224", "0.57068324", "0.57039016", "0.5687452", "0.56844944", "0.5638068", "0.5631864", "0.5630768", "0.56304336", "0.56230795", "0.56180674", "0.5610603", "0.560076", "0.5590262", "0.5565624", "0.55590147", "0.5549233", "0.55417335", "0.5534589", "0.5534006", "0.5522879", "0.5516566", "0.55146724", "0.55146724", "0.5500578", "0.54983246", "0.54983246", "0.54983246", "0.54983246", "0.54983246", "0.54983246", "0.54983246", "0.5493894", "0.54671985", "0.546685", "0.54562473", "0.5445677", "0.54431576", "0.5438664", "0.5438643", "0.54302526", "0.5423252", "0.542153", "0.542153", "0.5419041", "0.5418605", "0.5418605", "0.5418605", "0.54079443", "0.54063904", "0.54062444", "0.54016423", "0.53951585" ]
0.7027408
0
converts hand from array of card to array of sorted scores of said cards
def cards_by_score scores = {} @cards.each do |card| scores[card] = card.score end Hash[scores.sort_by { |card, score| -score }] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def hand_score\n cards.map {|a| a.value}.sort {|a,b| a <=> b}.last\n end", "def sort_by_suit\n \tnew_hand = []\n while @cards.size > 0\n \tpos = 0 # position of minimal card\n \tc = @cards[0] # minimal card\n \t@cards.each_with_index do |card, index|\n \t\tc1 = card\n # puts \"c: #{c.inspect} and c1: #{c1.inspect}\"\n # puts \" and c1.suit: #{c1.suit}\"\n \t\tif (c1.suit < c.suit || (c1.suit == c.suit && c1.value < c.value) )\n \t\t\tpos = index\n \t\t\tc = c1\n \t end\n \tend\n\n \tremove_card_at(pos)\n \tnew_hand << c\n end\n\n @cards = new_hand\n end", "def array_suit_rank\n h = []; d = []; c = []; s = []\n (0..6).each { |i|\n h << (@cards[i][1]) if @cards[i][0] == 1\n d<<(@cards[i][1]) if @cards[i][0] == 2\n c<<(@cards[i][1]) if @cards[i][0] == 3\n s<<(@cards[i][1]) if @cards[i][0] == 4 }\n # sort rank in any suit\n { :suit_H => h, :suit_D => d, :suit_C => c, :suit_S => s }.each { |suit, rank|\n rank.sort! { |first, second| second <=> first } }\n end", "def sort_by_value\n \tnew_hand = []\n \twhile @cards.size > 0\n \t\tpos = 0\n \t\tc = @cards[0]\n \t\t@cards.each_with_index do |card, index|\n \t\t\tc1 = card\n \t\t\tif (c1.value < c.value || (c1.suit == c.suit && c1.suit < c.suit) )\n pos = index\n c = c1\n end\n end\n\n remove_card_at(pos)\n new_hand << c\n end\n @cards = new_hand\n\n end", "def sort\n @cards.sort_by {|card| card.poker_value}\n end", "def sort_cards\n hearts = []\n spades = []\n clubs = []\n diamonds = []\n\n # Sort each card into its corresponding suit array\n @cards.each do |card|\n case card.suit\n when :hearts\n hearts << card\n when :spades\n spades << card\n when :clubs\n clubs << card\n when :diamonds\n diamonds << card\n end\n end\n\n # Cards need to be in descending order, so sort\n # then reverse the arrays\n hearts.sort!.reverse!\n spades.sort!.reverse!\n clubs.sort!.reverse!\n diamonds.sort!.reverse!\n\n # Combine all suit arrays in order\n @cards = hearts + spades + clubs + diamonds\n end", "def sort\n @cards.sort\n end", "def hand_value(cards)\n value = 0\n val_arr = []\n cards.each do |sub_array|\n val_arr << sub_array.last\n val_arr.sort!\n end\n val_arr.each do |val|\n if val == 11 && value > 10\n value = value + 1 \n else\n value = value + val\n end\n end\n return value\nend", "def order_by_value\n @hand = @hand.sort_by{|card| card.point }\n end", "def score\n @score = [straight_flush, four_of_a_kind, full_house, flush, straight, three_of_a_kind, two_pair, one_pair, high_card]\n end", "def sort_scores(unsorted_scores, highest_possible_score)\n array = []\n array << highest_possible_score\n unsorted_scores.sort.reverse.each { |score| array << score }\nend", "def play_hand( hand )\n\tscore = Array.new( 10 )\n\n\tscore[ 0 ] = [ is_royal_flush( hand ) ]\n\tscore[ 1 ] = [ is_straight_flush( hand ) ]\n\tscore[ 2 ] = [ is_four_of_a_kind( hand ) ]\n\tscore[ 3 ] = [ is_full_house( hand ) ]\n\tscore[ 4 ] = [ is_flush( hand ) ]\n\tscore[ 5 ] = [ is_straight( hand ) ]\n\tscore[ 6 ] = is_three_of_a_kind( hand )\n\tscore[ 7 ] = is_two_pair( hand )\n\tscore[ 8 ] = [ is_one_pair( hand ) ]\n\tscore[ 9 ] = [ is_high_card( hand ) ]\n\t\n\treturn score\nend", "def possible_scores(cards)\n scores = [0]\n\n cards.each do |card|\n if card.face != 'Ace'\n scores.map! {|score| score + card.value} \n else\n new_scores = Array.new\n scores.each do |score|\n new_scores << score + 1\n new_scores << score + 11\n end\n scores = new_scores\n end\n end\n\n return scores.uniq.select {|score| score < 22}\nend", "def getScoreCard()\n\t#create array A to Z\n\tcard = [*('A'..'Z')]\n\t#convert array to Hash\n\tcard = Hash[card.map.with_index.to_a]\n\t#return hash\n\treturn card\nend", "def sort_scores_arr(unsorted_scores, highest_possible_score)\n score_counts = [0] * (highest_possible_score + 1)\n\n unsorted_scores.each do |score|\n score_counts[score] += 1\n end\n\n sorted_scores = []\n\n i = HIGHEST_POSSIBLE_SCORE\n\n while i >= 0\n count = score_counts[i]\n unless count > 0\n i = i - 1\n end\n count.times { sorted_scores << i }\n i = i - 1\n end\n\n sorted_scores\nend", "def get_score (cards)\n\t\tscore = 0\n\t\tcards.each do |card|\n\t\t\tmeasure = card[0]\n\t\t\tscore += @score[measure]\n\t\tend\n\t\tscore\n\tend", "def score\n # make a local array that will disappear when not in this method\n tally = []\n # for each of the cards in the hand, add their score to the tally from points\n @hand.each do |card|\n tally.push(@points[card])\n end\n # return the tally of the scores\n return tally.sum\nend", "def initialize (cards)\n #sort the cards and store them in @cards\n @cards = Array.new\n cards.each do |card|\n @cards << Card.new(card)\n end\n @cards.sort!\n \n #determine the rank of the hand\n @rank = 0\n \n #see if at least one pair exists\n if @cards[0] == @cards[1] or @cards[1] == @cards[2] or @cards[2] == @cards[3] or @cards[3] == @cards[4]\n @handStart = @cards[0] == @cards[1] ? 0 : @cards[1] == @cards[2] ? 1 : @cards[2] == @cards[3] ? 2 : 3\n @rank = 1 #one pair\n #see if it's part of a three of a kind\n if @cards[0] == @cards[2] or cards[1] == @cards[3] or cards[2] == @cards[4]\n #see if hand is a full house\n if (@cards[0] == @cards[1] and @cards[2] == @cards[3] and @cards[2] == @cards[4]) or (@cards[0] == @cards[1] and @cards[0] == @cards[2] and @cards[3] == @cards[4])\n @handSubstart = @cards[2] == @cards[4] ? 2 : 3\n @rank = 6 #full house\n else\n @rank = 3 #three of a kind\n \n #see if it's part of a four of a kind\n if @cards[0] == @cards[3] or @cards[1] == @cards[4]\n @rank = 7 #four of a kind\n end\n end\n else\n #see if there are two pairs\n if (@cards[0] == @cards[1] and @cards[2] == @cards[3]) or (@cards[1] == @cards[2] and @cards[3] == @cards[4]) or (@cards[0] == @cards[1] and @cards[3] == @cards[4])\n @rank = 2 #two pairs\n @handSubstart = @cards[2] == @cards[4] ? 2 : 3\n end\n end\n else\n #check for straight\n inorder = true\n 0.upto(@cards.count - 2) do |x|\n if @cards[x].face and !@cards[x+1].face\n inorder = false\n break\n elsif !@cards[x].face and !@cards[x+1].face\n unless @cards[x].value + 1 == @cards[x+1].value\n inorder = false\n break\n end\n else\n unless @cards[x+1].value == \"J\"\n inorder = false\n break\n end\n end\n end\n if inorder\n @rank = 4 #straight\n end\n end\n \n #check for flush, straight flush and royal flush\n flush = true\n suit = @cards[0].suit\n @cards.each do |card|\n unless card.suit == suit\n flush = false\n break\n end\n end\n if flush\n if @rank == 4\n @rank = 8 #straight flush\n elsif @cards[1].face and @cards[2].face and @cards[3].face and @cards[4].face\n @rank = 9 #royal flush\n elsif @rank < 6\n @rank = 5 #flush\n end\n end\n end", "def tie_breaker_cards\n matched = self.matched_cards\n sorted = @cards.sort.reverse\n # sorted so the card with highest value is first \n if five_of_a_kind? \n # All cards break the tie\n return sorted \n elsif flush?\n # All cards break the tie\n return sorted \n elsif four_of_a_kind?\n four = matched.find{ |rank, cards| cards.size == 4}\n # quads break the tie first, then the other card \n return four + [(sorted - four).first] \n elsif full_house?\n three = matched.find{ |rank, cards| cards.size == 3}\n two = matched.find{ |rank, cards| cards.size == 2}\n return three + two\n elsif straight?\n # Special case for ace, 2, 3, 4 ,5 straight, which sorts as\n # 2,3,4,5,A \n if sorted.first.rank == Rank::Ace && sorted.last.rank == Rank::Two \n ace = sorted.pop \n sorted.unshift(ace) # put ace at the back\n return [ sorted.first ] # should be the 5 now \n else\n return [ sorted.first ] \n end\n elsif three_of_a_kind?\n three = matched.find{ |rank, cards| cards.size == 3} \n return three + (sorted - three).first(2)\n elsif two_pair?\n pairs = [] \n matched.each{ |rank, cards| pairs << cards if cards.size == 2 } \n two_pair = pairs[0] + pairs[1]\n two_pair + [(sorted - two_pair).first]\n elsif pair?\n two = matched.find{ |rank, cards| cards.size == 2} \n two + (sorted - two).first(3)\n else\n sorted.first(5)\n end\n end", "def sort_scores(unsorted_scores, highest_possible_score)\n arr = []\n unsorted_scores.each do |score|\n if arr[score]\n arr[score] += 1\n else\n arr[score] = 1\n end\n end\n \n output = []\n arr.each_with_index do |num, idx|\n if num\n num.times { |_| output.unshift(idx)}\n end\n end\n output\nend", "def cards_by_rank\n @cards_by_rank ||= @cards.group_by(&:rank).sort do |b,a|\n cmp_key_a, cmp_key_b = [a, b].map {|entry| entry[1]}\n\n cmp = cmp_key_a.count <=> cmp_key_b.count\n cmp.zero? ? cmp_key_a.first <=> cmp_key_b.first : cmp\n end.to_h\n end", "def sort_scores(unsorted_scores, highest_possible_score)\n\n # array of 0s at indices 0..highest_possible_score\n score_counts = [0] * (highest_possible_score+1)\n\n # populate score_counts\n unsorted_scores.each do |score|\n score_counts[score] += 1\n end\n\n # populate the final sorted array\n sorted_scores = []\n\n # for each item in score_counts\n score_counts.each_with_index do |count, score|\n\n # for the number of times the item occurs\n (0...count).each do |time|\n\n # add it to the sorted array\n sorted_scores.push(score)\n end\n end\n\n return sorted_scores\nend", "def determine_high_card hsh,num\n arr = []\n num1 = 2\n\n hsh.each_value {|card| arr << card}\n arr.flatten!\n arr.sort! {|x,y| y.number <=> x.number}\n while arr.length > num\n arr.pop\n end\n return arr\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 sort(unsorted, highest)\n\t# create a hash for each unsorted score\n scores_occurances = {}\n # result array\n sorted_scores = []\n # walk over the unsorted array and add 1 to our hash for each occurance\n unsorted.each do |score| \n \tif(scores_occurances.has_key?(score))\n\t \tscores_occurances[score] += 1\n\t else\n\t \tscores_occurances[score] = 1 \n\t end\n end\n\n (1..highest).each do |int|\n \tif(scores_occurances.has_key?(int))\n scores_occurances[int].times { sorted_scores.push(int) }\n end\n end\n \n sorted_scores\nend", "def initialize(cards)\n raise \"Invalid hand size - #{cards.length}\" unless cards.length == 5\n @cards = cards.map {|c| Card.new(c)}.sort\n @by_value = {}\n @by_suit = {}\n @cards.each do |c|\n @by_value[c.value] ||= []\n @by_suit[c.suit] ||= []\n @by_value[c.value] << c\n @by_suit[c.suit] << c\n end\n\n if @cards[4].value+1 == @cards[3].value &&\n @cards[3].value+1 == @cards[2].value &&\n @cards[2].value+1 == @cards[1].value &&\n @cards[1].value+1 == @cards[0].value\n end\n # Is it a straight\n @straight = true\n @cards.reduce do |p,c|\n if p.value != c.value + 1\n @straight = false\n break\n end\n c\n end\n value = [0]\n if @straight # Is it a straight\n value = [500, @cards.first.value]\n end\n # Is it a flush\n if @flush = @by_suit.find {|k,v| v.length == 5}\n if @straight\n value = [900, @cards.first.value]\n else\n value = [600, @cards.first.value]\n end\n end\n if value[0] < 700\n if (a = @by_value.find {|k,v| v.length == 3 }) &&\n (b = @by_value.find {|k,v| v.length == 2 })\n value = [700, a[0], b[0]]\n elsif a = @by_value.find {|k,v| v.length == 4 }\n value = [800, a[0]] # Is it 4 of a kind\n end\n end\n if value[0] < 500 && (a = @by_value.find {|k,v| v.length == 3 })\n value = [400, a[0]] # Is it 3 of a kind\n end\n if value[0] < 400 \n if (a = @by_value.select {|k,v| v.length == 2}).length > 0\n if a.length == 2\n hi,low = a[a.keys.max], a[a.keys.min]\n high = @cards - hi - low\n value = [300,hi.first.value, low.first.value, high.first.value]\n else\n pair = a[a.keys.first]\n high = (@cards - pair).first\n value = [200,pair.first.value, high.value]\n end\n else\n value = [100, @cards.first.value]\n end\n end\n @value = value\n end", "def values\n cards.map(&:value).sort\n end", "def hand_value cards\n values = cards.map{|c| $value_map[c[0]]}\n suits = cards.map{|c| c[1]}\n is_flush = false\n # check for flush\n if suits.uniq.size == 1\n is_flush = true\n end\n # check for straight\n is_straight = true\n sorted_values = values.sort\n for v in 0..(values.size-2)\n unless sorted_values[v]+1 == sorted_values[v+1]\n is_straight = false\n break\n end\n end\n if is_straight\n if is_flush\n # royal flush\n return {rank: 9, secondary: 10} if sorted_values[0] == 10\n # straight flush\n return {rank: 8, secondary: sorted_values[0]}\n end\n end\n # check for four of a kind\n if sorted_values[0] == sorted_values[3] || sorted_values[1] == sorted_values[4]\n return {rank: 7, secondary: sorted_values[1]}\n end\n # check for three of a kind or full house\n if sorted_values[0] == sorted_values[2]\n return {rank: 6, secondary: sorted_values[0]} if sorted_values[3] == sorted_values[4]\n return {rank: 3, secondary: sorted_values[0]}\n end\n if sorted_values[2] == sorted_values[4]\n return {rank: 6, secondary: sorted_values[2]} if sorted_values[0] == sorted_values[1]\n return {rank: 3, secondary: sorted_values[2]}\n end\n # check for three of a kind (case where full house is not possible)\n if sorted_values[1] == sorted_values[3]\n return {rank: 3, secondary: sorted_values[1]}\n end\n # return for flush (fine since three of a kind/full house and flush are mutually exclusive)\n return {rank: 5, secondary: sorted_values.last} if is_flush\n # return for straight (fine since three of a kind/full house and straight are mutually exclusive)\n return {rank: 4, secondary: sorted_values[0]} if is_straight\n # check for two pairs\n if sorted_values[0] == sorted_values[1] && sorted_values[2] == sorted_values[3]\n return {rank: 2, secondary: (sorted_values[0] > sorted_values[2] ? sorted_values[0] : sorted_values[2])}\n end\n if sorted_values[0] == sorted_values[1] && sorted_values[3] == sorted_values[4] \n return {rank: 2, secondary: (sorted_values[0] > sorted_values[3] ? sorted_values[0] : sorted_values[3])}\n end\n if sorted_values[1] == sorted_values[2] && sorted_values[3] == sorted_values[4] \n return {rank: 2, secondary: (sorted_values[1] > sorted_values[3] ? sorted_values[1] : sorted_values[3])}\n end\n # check for pairs\n return {rank: 1, secondary: sorted_values[0]} if sorted_values[0] == sorted_values[1]\n return {rank: 1, secondary: sorted_values[1]} if sorted_values[1] == sorted_values[2]\n return {rank: 1, secondary: sorted_values[2]} if sorted_values[2] == sorted_values[3]\n return {rank: 1, secondary: sorted_values[3]} if sorted_values[3] == sorted_values[4]\n # otherwise high card\n return {rank: 0, secondary: sorted_values.last}\nend", "def card_ranks(cards)\n ranks = cards.map { |card| '--23456789TJQKA'.index(card[0]) }\n ranks.sort! { |a, b| b <=> a }\n if ranks == [14, 5, 4, 3, 2]\n [5, 4, 3, 2, 1]\n else\n ranks\n end\nend", "def sort\n @hits = all.sort {|x,y| y.score <=> x.score }\n end", "def high_card\n valueInt = {\"A\" => 14, \"K\"=> 13, \"Q\"=> 12, \"J\"=> 11}\n results=[]\n\n [@hand1Values, @hand2Values].each do |handV|\n maxValue = 0\n handV.each do |h|\n value = valueInt[h] ? valueInt[h] : h\n maxValue = value.to_i if value.to_i > maxValue \n end\n results << maxValue\n end\n\n results\n end", "def hand_rank(hand)\n ranks = card_ranks(hand) # card_ranks return the ranks in sorted order\n\n if straight(ranks) && flush(hand)\n return [8, ranks.max] # 2 3 4 5 6 => [8, 6], 6 7 8 9 T => [8, T]\n elsif kind(4, ranks)\n return [7, kind(4, ranks), kind(1, ranks)] # 9 9 9 9 3 => [7, 9, 3]\n elsif kind(3, ranks) && kind(2, ranks) # 8 8 8 K K => [6, 8, 13]\n return [6, kind(3, ranks), kind(2, ranks)]\n elsif flush(hand)\n return [5, ranks]\n elsif straight(ranks)\n return [4, ranks.max]\n elsif kind(3, ranks)\n return [3, kind(3, ranks), ranks]\n elsif two_pair(ranks)\n return [2, kind(2, ranks), ranks]\n elsif kind(2, ranks)\n return [1, kind(2, ranks), ranks]\n else\n return [0, ranks]\n end\nend", "def score\n score = 0\n aces_count = 0\n @hand_contents.each do |card|\n if card.type == :face\n score += 10\n elsif card.type == :ace\n aces_count += 1\n score += 11\n elsif card.type == :number\n score += card.rank.to_i\n end\n end\n\n while score > 21 && aces_count > 0\n score -= 10\n aces_count -= 1\n end\n score\n end", "def high_ranking_cards\n\n array_high_cards = []\n\n cards.each do |card|\n\n if card.rank >= 11\n array_high_cards << card\n end\n\n end\n\n array_high_cards\n\n end", "def flush_cards(cards)\n\t\thsh = {}\n\t\tcards.each {|c| hsh[c.suit] ||= []; hsh[c.suit] << c}\n\t\tret = []\n\t\thsh.each {|suit, suit_cards| ret = suit_cards if suit_cards.size > ret.size}\n\t\tret.sort_by {|x| x.sort_value}\n\tend", "def count_score(array)\n total = 0\n sorted_hand = array.sort_by { |x| value(x) }\n sorted_hand.each do |x|\n if value(x) == 11 && total >= 11\n total += 1\n else\n total += value(x)\n end\n end\n total\nend", "def initialize(array)\n @val = []\n array.each do |arr|\n @val << (arr.is_a?(Card) ? arr : Card.new(arr))\n end\n @val.sort_by!(&:rank)\n end", "def initialize(codes)\n\t\t@cards = codes.split(\" \").map { |s| Card.new(s) }.sort {|a,b| a <=> b}.reverse\n\t\t\n\t\tdistinct_suits = Set.new.merge @cards.map{|card| card.suit}\n\n\t\tis_straight =\n\t\t\t@cards[0].value-1 == @cards[1].value &&\n\t\t\t@cards[0].value-2 == @cards[2].value &&\n\t\t\t@cards[0].value-3 == @cards[3].value &&\n\t\t\t@cards[0].value-4 == @cards[4].value\n\n\t\tif @is_straight && @cards[0].value == 14 && distinct_suits.size == 1\n\t\t\t@hand = 'ROYAL_FLUSH'\n\t\t\treturn\n\t\tend\n\n\t\tif is_straight && distinct_suits.size == 1\n\t\t\t@hand = 'STRAIGHT_FLUSH'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\n\t\t# Four of a kind\n\t\tif equal_values([0,1,2,3])\n\t\t\t@hand = 'FOUR_OF_KIND'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2,3,4])\n\t\t\t@hand = 'FOUR_OF_KIND'\n\t\t\tset_ranking_cards([1])\n\t\t\treturn\n\t\tend\n\t\t\n\t\t# Full house\n\t\tif equal_values([0,1,2],[3,4])\n\t\t\t@hand = 'FULL_HOUSE'\n\t\t\t@ranking_cards = [@cards[0]]\n\t\t\treturn\n\t\tend\n\t\tif equal_values([0,1],[2,3,4])\n\t\t\t@hand = 'FULL_HOUSE'\n\t\t\tset_ranking_cards([2])\n\t\t\treturn\n\t\tend\n\n\t\t# Flush\n\t\tif distinct_suits.size == 1\n\t\t\t@hand = 'FLUSH'\n\t\t\tset_ranking_cards([0,1,2,3,4])\n\t\t\treturn\n\t\tend\n\n\t\t# Straight\n\t\tif is_straight\n\t\t\t@hand = 'STRAIGHT'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\n\t\t# 3 of a kind\n\t\tif equal_values([0,1,2])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([0,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2,3])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([1,0,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([2,3,4])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([2,0,1])\n\t\t\treturn\n\t\tend\n\n\n\t\t# 2 pair\n\t\tif equal_values([0,1],[2,3])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([0,2,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([0,1],[3,4])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([0,3,2])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2],[3,4])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([1,3,0])\n\t\t\treturn\n\t\tend\n\n\t\t# pair\n\t\tif equal_values([0,1])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([0,2,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([1,0,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([2,3])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([2,0,1,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([3,4])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([3,0,1,2])\n\t\t\treturn\n\t\tend\n\n\t\t@hand = 'HIGH_CARD'\n\t\tset_ranking_cards([0,1,2,3,4])\n\n\tend", "def hand_score(hand)\n\tcards= {\"A\"=>4, \"K\"=>3, \"Q\"=>2, \"J\"=>1}\n \tscore = 0\n \thand.each_char { |char| score += cards[char.upcase] }\n \treturn score\nend", "def add_card(aCard)\n @cards << aCard\n @cards.sort!() {|card1, card2| card1.rank <=> card2.rank}\n @rank_histogram[aCard.rank] += 1\n @suit_histogram[aCard.suit] += 1\n @evaluation = nil\n @score = 0\nend", "def cards_sorted_ace_high\n @cards_sorted_ace_high ||= @cards.sort!.reverse!\n end", "def sort_cards_by_same_value()\r\n\t\tresult=Array.new\r\n\t\tfor i in 2..14\r\n\t\t\tresult[i]=CardList.new\r\n\t\tend\r\n\t\t@list.each{|x| result[x.get_value].add_card(x)}\r\n\t\treturn result\r\n\tend", "def get_hand_score\n score = 0\n \n # Add up score of non-aces\n values = hand.map{|card| card.value}\n values.each do |val|\n if Array(2..10).include?(val.to_i)\n score += val.to_i\n elsif [\"J\", \"Q\", \"K\"].include?(val)\n score += 10\n end\n end\n\n # deal with the aces\n values.count(\"A\").times do\n if score + 11 <= 21\n score += 11\n else\n score += 1\n end\n end\n\n return score\n end", "def score(cards)\n\nend", "def possible_scores\n card_values.inject([0]) do |memo, item|\n if ace_value?(item)\n added_one = memo.map { |score| score + 1 }\n added_one << (added_one.last + 10)\n else\n memo.map { |number| number + item.first }\n end\n end\n end", "def card_scores\n card_scores = {\n \"JOKER\" => 13, \"J♠\" => 12, \"J♣\" => 11, \"A♠\" => 10, \"K♠\" => 9, \"Q♠\" => 8,\n \"10♠\" => 7, \"9♠\" => 6, \"8♠\" => 5, \"7♠\" => 4, \"6♠\" => 3, \"5♠\" => 2\n }\n card_scores.default = 0\n\n card_scores\n end", "def decode_quiz_scores(scores)\n\n result = Array.new\n\n scores.each do | key, val |\n q_number = val / 100\n ans = val - (100 * q_number)\n result << {question: q_number, answer: ans, value: 1}\n end\n\n result\n end", "def cards_to_score(cards)\n \n total = 0\n cards_num = []\n\n cards.each { |card| cards_num.push(card % 13) }\n\n cards_num.sort.reverse.each do |num|\n if num >= 9 #9, 10, 11, 12 means 10, J, Q, K\n total = total + 10\n elsif num > 0 #which means 2, 3, 4, 5, 6, 7, 8, 9\n total = total + num + 1\n end\n end\n\n a_count = cards_num.count(0)\n\n total = total + a_count\n\n a_count.times do\n total = total + 10 if total <= 11\n end\n\n return total\nend", "def create_leaderboard(team_scorecard)\n #sort scorecard first by wins in decending order\n #sort scorecard then by ties in decending order\n #sort scorecard last by losses in ascending order\n team_scorecard.sort_by {|team_info| [-team_info[1][:wins], -team_info[1][:ties], team_info[1][:losses]]}\nend", "def sort_using_rank\n score[1]\n end", "def score\n @cards.map(&:value).inject(:+)\n end", "def by_suit\n PokerHand.new(@hand.sort_by { |c| [c.suit, c.face] }.reverse)\n end", "def sorted_scores(unsorted_scores, highest_score)\n score_counts = Array.new(101, 0) # 101 because it has to be inclusive of 100\n\n unsorted_scores.each do |score|\n score_counts[score] += 1\n end\n\n sorted_scores = []\n\n highest_score.downto(0) do |score|\n count = score_counts[score]\n\n count.times do |_time|\n sorted_scores.push(score)\n end\n end\n\n sorted_scores\nend", "def values\n hand = @hand.dup\n\n # Strip away cards' suits\n hand = hand.gsub(/(S|H|D|C)/, '')\n\n # Replace ace through ten cards with their numerical values\n hand = hand.gsub(/[AKQJT]/, 'A'=>'14', 'K'=>'13', 'Q'=>'12', 'J'=>'11', 'T'=>'10')\n\n # Return an array of integer values\n hand.split.map(&:to_i)\n end", "def compare_cards(cards1, cards2)\n\t\tcards1.each_index do |i| \n\t\t\tsort_score = (cards1[i] <=> cards2[i])\n\t\t\treturn sort_score unless sort_score.zero?\n\t\tend\n\t\t\n\t\t0\n\tend", "def create_leaderboard(team_scorecard)\n #sort scorecard first by wins in decending order\n #sort scorecard then by ties in decending order\n #sort scorecard last by losses in ascending order\n team_scorecard.sort_by! {|team_info| [team_info[1][:wins], team_info[1][:ties], -team_info[1][:losses]]}.reverse!\nend", "def high_ranking_cards\n cards.map do |card|\n if card.rank >= 11\n high_cards << card\n end\n end\n high_cards\n end", "def sort_player_cards(player)\n p_cards = player.get_player_cards\n p_cards.sort! { |a,b| a.card_weight <=> b.card_weight }\n p_cards.each_with_index do |card, index|\n if self.trump_card.card_type.name == card.card_type.name\n p_cards.delete_at(index)\n p_cards.push(card)\n end\n end\n player.player_cards = p_cards\n send_update\n end", "def scores\n @raw.map(&:score)\n end", "def sort(&block)\n if block\n sorted = self.cards.sort(&block) \n return Hand.new(sorted)\n else \t\n sorted = quicksort(@cards) # self.cards.sort\n return Hand.new(sorted)\n end\n end", "def sort_cards_by_value!()\r\n\t\taucun_echange=false\r\n\t\twhile aucun_echange==false\r\n\t\t\taucun_echange=true\r\n\t\t\tlen=@list.length-2\r\n\t\t\tfor i in 0..len\r\n\t\t\t\tif !@list[i].nil? and !@list[i+1].nil?\r\n\t\t\t\t\tif @list[i].get_value<@list[i+1].get_value\r\n\t\t\t\t\t\ttemp=@list[i]\r\n\t\t\t\t\t\t@list[i]=@list[i+1]\r\n\t\t\t\t\t\t@list[i+1]=temp\r\n\t\t\t\t\t\taucun_echange=false\r\n\t\t\t\t\t\tbreak\r\n\t\t\t\t\telsif @list[i].get_value == @list[i+1].get_value\r\n\t\t\t\t\t\t@list.delete_at(i)\r\n\t\t\t\t\t\taucun_echange=false\r\n\t\t\t\t\t\tbreak\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend\r\n\tend", "def calculate_total hand\n\ttotal=0\n\tarray = hand.map {|e| e[1]}\n\tarray.each do |card|\n\t\t## face card \n\t\tif card == \"10\" || card ==\"J\" || card ==\"K\" || card ==\"Q\"\n\t\t\ttotal +=10\n\t\t## Ace card\t\n\t\telsif card ==\"A\"\n\t\t\ttotal += 11\n\t\telse \n\t\t\ttotal += card.to_i\n\t\tend\n\tend\n\thand.collect {|e| e[1]}.each do |card|\n\t\tif total >21 && card == \"A\"\n\t\t\ttotal -= 10\n\t\tend\n\tend\n\n\treturn total \nend", "def high_ranking_cards\n high_cards = []\n @cards.each do|card|\n if card.rank >= 11\n high_cards << card\n end\n end\n high_cards\n end", "def sum_of_cards(hand)\n card_values = hand.map do |card|\n if card[0] == 1\n card[0] = 11\n elsif card[0] >= 11\n card[0] = 10\n else\n card[0]\n end\n end\n sum = 0\n card_values.each do |card|\n sum += card[0]\n end\n sum\n end", "def answer(unsorted_scores, highest_possible_score)\n score_counts = [0] * (highest_possible_score + 1) # array of 0's at indices 0..highest_possible_score\n unsorted_scores.each { |score| score_counts[score] += 1 } # populate score_counts\n sorted_scores = [] # populate the final sorted_scores\n highest_possible_score.downto(0) do |score|\n count = score_counts[score]\n (0...count).each { |time| sorted_scores << score }\n end\n return sorted_scores\nend", "def by_face\n PokerHand.new(@hand.sort_by { |c| [c.face, c.suit] }.reverse)\n end", "def calculate_hand_total_value(hand_array)\n total_value = 0\n is_there_an_ace = false\n\n hand_array.each do |card|\n if card[:rank] === \"A\"\n is_there_an_ace = true\n end\n\n card_value = card[:value]\n total_value += card_value\n\n end\n\n if is_there_an_ace\n return [total_value, total_value + 10]\n\n else\n return [total_value, 999]\n\n end\n\nend", "def smart_aces hand\n# Adjusts the value of \"Ace\" elements to be either 1 or 11 depending on the hand total\n\thand_total = hand.reduce :+\n\tif hand_total < 12 && hand_total > 2\n\t\thand.map! do |card|\n\t\t\tif card == 1\n\t\t\t\t11\n\t\t\telse\n\t\t\t\tcard\n\t\t\tend\n\t\tend\n\telsif hand_total > 21\n\t\thand.map! do |card|\n\t\t\tif card == 11\n\t\t\t\t1\n\t\t\telse\n\t\t\t\tcard\n\t\t\tend\n\t\tend\n\telsif hand_total == 2\n\t\thand[0] = 11\n\tend\n\nend", "def calcScore(hand)\n return hand.inject(0) { |sum, n| sum + n.points }\nend", "def sort_scores_hash(unsorted_scores, highest_possible_score)\n score_counts = {}\n unsorted_scores.each do |score|\n score_counts[score] = 0 unless score_counts[score]\n score_counts[score] += 1\n end\n\n sorted_scores = []\n i = HIGHEST_POSSIBLE_SCORE\n while i >= 0\n unless score_counts[i]\n i = i - 1\n next\n end\n\n score_counts[i].times { sorted_scores << i }\n i = i - 1\n end\n\n sorted_scores\nend", "def sort_cards\n return @cards.sort_by(&:color)\n self\n end", "def sort_cards_by_value_bis!()\r\n\t\taucun_echange=false\r\n\t\twhile aucun_echange==false\r\n\t\t\taucun_echange=true\r\n\t\t\tlen=@list.length-2\r\n\t\t\tfor i in 0..len\r\n\t\t\t\tif !@list[i].nil? and !@list[i+1].nil?\r\n\t\t\t\t\tif @list[i].get_value_bis<@list[i+1].get_value_bis\r\n\t\t\t\t\t\ttemp=@list[i]\r\n\t\t\t\t\t\t@list[i]=@list[i+1]\r\n\t\t\t\t\t\t@list[i+1]=temp\r\n\t\t\t\t\t\taucun_echange=false\r\n\t\t\t\t\t\tbreak\r\n\t\t\t\t\telsif @list[i].get_value_bis == @list[i+1].get_value_bis\r\n\t\t\t\t\t\t@list.delete_at(i)\r\n\t\t\t\t\t\taucun_echange=false\r\n\t\t\t\t\t\tbreak\r\n\t\t\t\t\tend\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\tend\r\n\tend", "def pair(hand)\n\t\thand_num = check_num(hand)\n\t\ti = 0\n\t\thand_aux = Array.new()\n\t\twhile i < hand_num.size\n\t\t\thand_aux[i] = hand_num.count(hand_num[i])\n\t\t\ti += 1\n\t\tend\n\n\t\tsum = 0\n\t\tfor twos in hand_aux\n\t\t\tif twos == 2\n\t\t\t\tsum += 2\n\t\t\tend\n\t\tend\n\t\treturn sum / 4\n\tend", "def value()\n sum = 0\n # Partition the array by string and integer then reverse to put aces at back\n @cards.partition{|x| x.is_a? String}.map(&:sort).flatten.reverse_each do |i|\n if [\"Q\", \"J\", \"K\"].include?(i)\n sum += 10\n elsif i == \"A\"\n if sum + 11 > 21\n sum += 1\n else\n sum += 11\n end\n else \n sum += i\n end\n end \n return sum\n end", "def hand_score(hand)\n points = {\n \"A\"=>4,\n \"K\"=>3,\n \"Q\"=>2,\n \"J\"=>1\n }\n\n score = 0\n hand.each_char { |char| score += points[char.upcase] }\n return score\nend", "def determine_winner\n cards = deal\n hands = cards.sort_by do |hand, i|\n hand[:card][2] #limits the hand with two arrays\n end\n winner = hands.last[:player]\n winnerCard = hands.last[:card]\n winnerCard = winnerCard.join(\" of \") #ROADBLOCK: I can't seem to figure this part out. I want to just return the rank and the suit, and return the index for score. Example, 7 of hearts instead of 7 of hearts of 6. I don't want the 6 there.\n\n # score = hands.last[:card].split(\"\")\n\n puts \"#{winner} drew the card, #{winnerCard}\"\n\n # puts \"#{winner}'s score is #{score}'\"\n #ROADBLOCK: I want the index to print out for the score here\n\n puts \"#{winner} wins!\"\nend", "def sorted_scores\n self.object.teams.map {|team| team.score}.sort.reverse\n end", "def scores\n return Game.score(self.card_numbers self.user_id), Game.score(self.card_numbers nil)\n end", "def aces_low_values\n cards.map(&:value).map { |v| v == ACE_HIGH ? ACE_LOW : v }.sort\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 high_card_winner\n\n\t # find high card winner card from numerical representation\n\t for i in 0..@best_hand_value_1.length-1 do \n\t if @best_hand_value_1[i] <= 10\n\t @high_card_winner_1[i] = @best_hand_value_1[i]\n\t elsif @best_hand_value_1[i] == 11\n\t @high_card_winner_1[i] = 'J'\n\t elsif @best_hand_value_1[i] == 12\n\t @high_card_winner_1[i] = 'Q'\n\t elsif @best_hand_value_1[i] == 13\n\t @high_card_winner_1[i] = 'K'\n\t elsif @best_hand_value_1[i] == 14\n\t @high_card_winner_1[i] = \"A\"\n\t end \n\t if @best_hand_value_2[i]<=10\n\t @high_card_winner_2[i] = @best_hand_value_2[i]\n\t elsif @best_hand_value_2[i] == 11\n\t @high_card_winner_2[i] = 'J'\n\t elsif @best_hand_value_2[i] == 12\n\t @high_card_winner_2[i] = 'Q'\n\t elsif @best_hand_value_2[i] == 13\n\t @high_card_winner_2[i] = 'K'\n\t elsif @best_hand_value_2[i] == 14\n\t @high_card_winner_2[i] = \"A\"\n\t end \n\t end\n\tend", "def get_high_cards(cards)\n @cards_by_score.each_key do |card|\n if cards.length < 5 && !cards.include?(card)\n cards << card\n end\n end\n end", "def get_expected_scores \n answer = [] \n scores = self.expected_score\n i = 0\n while i < scores.length\n s = scores[i, 4]\n answer.push(s.unpack('4f')[0])\n i += 4\n end \n return answer \n end", "def getListPosScore(letScoreArray)\n\t#initialize finalArr array\n\tfinalArr = []\n\t#for each letter score in array\n\tfor i in 0..letScoreArray.length-1\n\t\t#add letterScore * position to finalArr\n\t\tfinalArr << (i+1) * letScoreArray[i]\n\tend\n\t#return finalArr array\n\treturn finalArr\t\nend", "def card_in_game\n (2..14).each {|r| (1..4).each { |i| @pack_of_card << [i, r] }}\n @cards = @pack_of_card.shuffle.take(7)\n # @hash_7_card is hash prepared for analyze combinations and the highest combination to win\n $hash_7_card = array_suit_rank\n end", "def rank_starting_hand\r\n sorted_hand = @hole_cards.sort_by { |card| card.rank } # [4,2] => [2,4]\r\n\r\n # Shorthand variables for two cards in hand\r\n (first,second) = [sorted_hand[0],sorted_hand[1]]\r\n\r\n suited = first.suit == second.suit # True if cards have same suit\r\n paired = first.rank == second.rank # True if cards have same rank\r\n connected = first.rank + 1 == second.rank # True if cards have consecutive ranks\r\n\r\n # Check for playable hands and return their rank\r\n # (Some of these checks aren't necessary but are included for readibility)\r\n case first.rank\r\n when 8 then return 14 if paired # Pocket Eights\r\n when 9 then return 9 if paired # Pocket Nines\r\n when 10\r\n return 6 if paired # Pocket Tens\r\n return 20 if second.rank == 12 and suited # Queen-Ten Suited\r\n return 16 if second.rank == 13 and suited # King-Ten Suited\r\n return 12 if second.rank == 14 and suited # Ace-Ten Suited\r\n when 11\r\n return 4 if paired # Pocket Jacks\r\n return 17 if second.rank == 12 and suited # Queen-Jack Suited\r\n return 15 if second.rank == 13 and suited # King-Jack Suited\r\n if second.rank == 14\r\n return suited ? 10 : 18 # Ace-Jack Suited/Offsuit\r\n end\r\n when 12\r\n return 3 if paired # Pocket Queens\r\n if second.rank == 13\r\n return suited ? 11 : 19 # King-Queen Suited/Offsuit\r\n elsif second.rank == 14\r\n return suited ? 8 : 13 # Ace-Queen Suited/Offsuit\r\n end\r\n when 13\r\n return 2 if paired # Pocket Kings\r\n if second.rank == 14\r\n return suited ? 5 : 7 # Ace-King Suited/Offsuit\r\n end\r\n when 14 then return 1 if paired # Pocket Aces\r\n end\r\n # Still played if the hand is suited, paired, or connected, otherwise not played\r\n return (suited or paired or connected) ? 21 : -1\r\n end", "def solve(hands, fileflag=false)\n\thand1wins, hand2wins, games = 0, 0, 0\n\n\thands = File.open(hands, \"r\") if fileflag\n\n\thands.each_line do |line|\n\t\thand1, hand2 = Hand.new(line[0, 14]), Hand.new(line[15, 29])\n\t\thandarray = [ \t[hand1.ranking, hand2.ranking], \t\t\t# Our hand ranking ( 1 == High Card, 10 == Royal Flush)\n\t\t\t\t\t\t[hand1.rankingcard, hand2.rankingcard], \t# Our ranking's main card (eg. 8 in an 8-high straight)\n\t\t\t\t\t\t[hand1.tiebreaker, hand2.tiebreaker], \t\t# The kicker (Jack, numerically 11, in \"4C 4D JH 2D 5C\")\n\t\t\t\t\t\t[hand1.tiebreaker2, hand2.tiebreaker2], \t# and so on.\n\t\t\t\t\t\t[hand1.tiebreaker3, hand2.tiebreaker3]\n\t\t\t\t\t]\n\n\t\tgames += 1\n\t\t\n\t\t# Iterate through our array of arrays. For each one, compare v1 with v2. If there is a clear winner, add the point.\n\t\t# Otherwise, cycle through to the next round, and repeat until a winner is found.\n\t\thandarray.each do |arr|\n\t\t\tif arr[0] > arr[1]\n\t\t\t\thand1wins += 1\n\t\t\t\tbreak\n\t\t\telsif arr[0] < arr[1]\n\t\t\t\thand2wins += 1\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\tend\n\n\t# Return format: [number of wins, number of rounds, win percentage]\n\treturn [hand1wins.to_s, games.to_s, (hand1wins.to_f / games * 100).round]\nend", "def game\nranks = [2, 3, 4, 5, 6, 7, 8, 9, 10, \"J\", \"Q\", \"K\", \"A\"]\nsuits = [ \"hearts\", \"spades\", \"clubs\", \"diamonds\" ]\ndeck = []\npoints = []\n\nranks.each_with_index do |rank, score|\n suits.each do |suit|\n deck.push({\n points: points,\n ranks: rank,\n suits: suit\n })\n\n end\n end\n\n return deck.shuffle\nend", "def high_card\n [1, values, \"#{best_card}-#{card_names(values)[1]} High Card\"]\n end", "def cards_by_suit\n @cards_by_suit ||= @cards.group_by(&:suit)\n end", "def value_of_hand(array_of_cards)\n faces = {\"A\" =>11,\n \"2\" => 2, \n \"3\" => 3,\n \"4\" => 4,\n \"5\" => 5,\n \"6\" => 6,\n \"7\" => 7,\n \"8\" => 8,\n \"9\" => 9,\n \"10\" => 10,\n \"J\" => 10,\n \"Q\" => 10,\n \"K\" => 10\n }\n total_value = 0\n num_aces = 0\n array_of_cards.each do |c|\n #cards are in string format, e.g. \"J of diamonds\"\n face = c.split[0]\n value = faces[face]\n total_value += value\n num_aces += 1 if face == \"A\"\n end\n #correct for Aces -- BORROWED THIS LOGIC FROM TEACHER'S CODE\n num_aces.times do\n total_value -= 10 if total_value > 21\n end\n return total_value\nend", "def sort\n byebug\n deck = Deck.find(params[:deck])\n cards = deck.cards\n @result = []\n # face_values = {\n # :ace => 1,\n # :jack => 11,\n # :queen => 12,\n # :king => 13\n # }\n\n # steps: \n # Step 1: takes the key and runs it through the face values hash \n # Step 2: if it exist return the value of that key, if doesn't then return the value of the card\n\n # cards.each_key do |card| \n # each_card = card[:value]\n # if each_card\n # #if card \n # else\n # #normal number card\n # end\n \n if params[:sort_suit] && params[:sort_value]\n sort_all = cards.sort_by{|key, value| [value, key]}\n @result << sort_all\n\n elsif params[:sort_suit]\n sort_suit = cards.sort_by{|key, value| value}\n @result << sort_suit\n\n elsif params[:sort_value]\n sort_value = cards.sort_by{|key, value| key}\n @result << sort_value\n end\n render json: @result\n end", "def scores\n {\n 'a' => 1, 'e' => 1, 'i' => 1, 'o' => 1,\n 'u' => 1, 'l' => 1, 'n' => 1, 'r' => 1,\n 's' => 1, 't' => 1, 'd' => 2, 'g' => 2,\n 'b' => 3, 'c' => 3, 'm' => 3, 'p' => 3,\n 'f' => 4, 'h' => 4, 'v' => 4, 'w' => 4,\n 'y' => 4, 'k' => 5, 'j' => 8, 'x' => 8,\n 'q' => 10, 'z' => 10\n }\nend", "def compare_further p1hand, p2hand, rank, secondary\n p1values = p1hand.map{|c| $value_map[c[0]]}.sort\n p2values = p2hand.map{|c| $value_map[c[0]]}.sort\n # no further comparison if it's a straight\n return 0 if rank == 9 || rank == 8 || rank == 4\n if rank == 7 # four of a kind\n comp1 = (p1values[0] == secondary ? p1values[4] : p1values[0])\n comp2 = (p2values[0] == secondary ? p2values[4] : p2values[0])\n return 1 if comp1 > comp2\n return 2 if comp2 > comp1\n return 0\n end\n if rank == 6 # full house\n comp1 = (p1values - [secondary]).uniq[0]\n comp2 = (p2values - [secondary]).uniq[0]\n return 1 if comp1 > comp2\n return 2 if comp2 > comp1\n return 0\n end\n if rank <= 5 # all remaining ranks\n comp1 = (p1values - [secondary]).uniq.reverse\n comp2 = (p2values - [secondary]).uniq.reverse\n comp1.each_with_index do |e,i|\n return 1 if e > comp2[i]\n return 2 if comp2[i] > e\n end\n return 0\n end\nend", "def look_at_tie(hand1,hand2)\n\t# Empty face_value1 array created for hand1 faces\n\tface_value1 = []\n\t# Empty face_value2 array created for hand2 faces\n\tface_value2 = []\n\n\thand1.each do |card|\n\t\t# Pushing the face of each card into the empty array and grabbing it by the first index. Ex: \"Kd\" => \"K\" (\"[0][1]\")\n\t\tface_value1 << card[0]\n\tend \n\t# Setting the face_changer function equal to the hand1_faces variable\n\thand1_faces = face_changer(face_value1)\n\t# Sorting the array of faces(after they go through facechanger they turn into integers)\n \tsorted_faces1 = hand1_faces.sort\n \tsorted_faces_sum1 = sorted_faces1.sum\n \t# new_hand1 puts non-duplicated elements into an array\n \tnew_hand1 =\tsorted_faces1.group_by { |card| card }.select { |k, v| v.size.eql? 1 }.keys\n \t# Finds the duplicates and returns one\n \thand1_dupes = sorted_faces1.select{|item| sorted_faces1.count(item) > 1}.uniq\n \t# Adds duplicates together\n \thand1_dupes_sum = hand1_dupes.sum\n \tnext_kicker1 = new_hand1.pop\n\thand2.each do |card|\n\t\tface_value2 << card[0]\n\tend\n\thand2_faces = face_changer(face_value2)\n \tsorted_faces2 = hand2_faces.sort\n \tsorted_faces_sum2 = sorted_faces2.sum\n \tnew_hand2 = sorted_faces2.group_by { |card| card }.select { |k, v| v.size.eql? 1 }.keys\n \thand2_dupes = sorted_faces2.select{|item| sorted_faces2.count(item) > 1}.uniq\n \thand2_dupes_sum = hand2_dupes.sum\n \tnext_kicker2 = new_hand2.pop\n\n \t# If hand1's duplicate sum is greater than hand2's duplicate sum then return the \"hand1 wins string\"\n\tif hand1_dupes_sum > hand2_dupes_sum \n\t\t\"Player One(hand1) wins!\" \n \t# If hand1's duplicate sum is less than hand2's duplicate sum then return the \"hand2 wins string\"\n\telsif hand1_dupes_sum < hand2_dupes_sum\n\t \t \"Player Two(hand2) wins!\"\n \t# If hand1's duplicate sum is equal to hand2's duplicate sum then go to next conditional\n\telse \n \tsplit_the_pot(hand1,hand2)\n end\nend", "def is_two_pair( hand )\n\tpair = check_pair( 2, hand )\n\treturn 2 == pair.length ? pair.map{ | e | card_value( e ) }.sort.reverse :\n\t\t\t\t\t\t\t [ 0 ]\nend", "def sort(array:)\n return [] unless array.present? && array.is_a?(Array)\n\n # Sort the results by score + weight + name\n array.sort do |a, b|\n # left = [a[:weight], a[:score], a[:sort_name]]\n # right = [b[:weight], b[:score], b[:sort_name]]\n [a[:weight], a[:sort_name]] <=> [b[:weight], b[:sort_name]]\n end\n end", "def poorly_written_ruby(*arrays)\n combined_array = []\n\n arrays.each do |array|\n combined_array.concat(array)\n end\n \n def quick_sort(collection)\n return collection if collection.length <= 1\n pivot = collection.sample\n\n left = Array.new\n right = Array.new\n\n collection.each do |x|\n if x <= pivot\n left << x\n else\n right << x\n end\n end\n\n quick_sort(left) + quick_sort(right)\n\n end\n\n def buckethash_sort(collection)\n\n buckets = Hash.new\n\n (\"A\"..\"Z\").each do |x|\n buckets[x] = Array.new\n end\n\n collection.each do |x|\n if buckets.key?(x[0])\n buckets[x[0]] << x\n end\n end\n\n buckets.each_key do |key|\n buckets[key] = quick_sort(buckets[key])\n end\n\n buckets.values.flatten\n\n end\n\n buckethash_sort(combined_array)\n\nend", "def initialize (hand = [], score = 0)\n @hand = hand\n @score = score\n end", "def score_hand\n\n end" ]
[ "0.7948034", "0.7014165", "0.7000303", "0.6928356", "0.68609774", "0.6820641", "0.6737521", "0.6714905", "0.66206586", "0.6574508", "0.6560887", "0.6517915", "0.6503766", "0.6470747", "0.6426299", "0.6387371", "0.636609", "0.635723", "0.63561314", "0.6342808", "0.63078564", "0.6277119", "0.62621945", "0.6253244", "0.6245575", "0.62409496", "0.6240839", "0.6231721", "0.6219395", "0.6214129", "0.62099886", "0.6195766", "0.6195461", "0.6182697", "0.6177366", "0.6165602", "0.6152955", "0.61305463", "0.6113914", "0.6113188", "0.6112828", "0.61036587", "0.6089931", "0.60855794", "0.60739887", "0.605551", "0.60533226", "0.6053011", "0.604043", "0.6033769", "0.603054", "0.60234654", "0.6021875", "0.59893245", "0.598347", "0.5965898", "0.595312", "0.5926171", "0.591204", "0.59116995", "0.5884465", "0.58690107", "0.58614516", "0.583967", "0.583397", "0.582691", "0.5813875", "0.58102447", "0.58073854", "0.5806713", "0.57897425", "0.5761302", "0.5754731", "0.5752592", "0.5749717", "0.57428074", "0.572708", "0.57258487", "0.57183766", "0.5716421", "0.5707151", "0.5696688", "0.5675581", "0.5668748", "0.5649928", "0.5645136", "0.5641073", "0.5635428", "0.5619715", "0.5618724", "0.56067246", "0.5595846", "0.55956984", "0.558896", "0.5581748", "0.5574102", "0.5563295", "0.55576754", "0.5553016", "0.55472696" ]
0.7296949
1
check if only 5 cards in hand already
def hand? @cards_by_score.length == 5 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def full_house?\n return unless size >= 5\n\n the_cards = cards_by_rank.values\n the_cards[0].count >= 3 && the_cards[1].count >= 2\n end", "def complete?\n @cards.length == 5\n end", "def six_cards?(player_check)\n if (player_check.hand.length == 6) && (player_check.hand_total < 21)\n return true\n else\n return false\n end\n end", "def flush?\n per_suit = matched_suits\n for suit, count in per_suit do\n return true if count >= 5\n end \n return false \n end", "def deal5cards (n)", "def flush?\n cards_by_suit.any? {|_, v| v.count >= cards_needed}\n end", "def can_deal?\n size() >= 6\n end", "def blackjack(hand)\n value(hand) == 21 && hand.length == 2\n end", "def blackjack?; value == 21 && @cards.length == 2; end", "def busted?(cards)\n\nend", "def shouldHit\n # If 17 or above, lock the hand so it cannot receive any more cards\n \tif @hands[0].checkHand > 16 or @hands[0].checkHand < 0\n \t @hands[0].lock\n \tend\n \t@hands[0].canGetCards\n end", "def high_card?\n cards_by_rank.count == @size\n end", "def eval_7_card_hand( cards )\n 1\n end", "def snap?\n if @cards.length < 2\n false\n # check for snap!\n elsif @cards[-1].suit == @cards[-2].suit\n true\n else\n false\n end\n end", "def flush\n my_hand.group_by(&:suit).select { |_, hand_of_suit| hand_of_suit.count == 5 }.values.flatten\n end", "def five_of_a_kind?\n # Get all cards of the same rank as the first one, and \n # checks if there are five of them.\n # However, we have to skip any wildcards, since they're always true\n given = self.first_not_wild\n # If all cards are wild, it's a five of a kind\n # This could only happen if there are 5 or more wild cards\n # defined\n return true unless given \n same = find_same_rank(given)\n # It has to be >= in case the hand has 6 or more cards\n # and some wildcards in them.\n # In the face of wildcards, it possibe to have any amount of \"same\" \n # cards in a hand\n return same.size >= 5 \n end", "def isOver?\n @deck.cardsRemaining < MIN_CARDS\n end", "def cards_needed\n [@size, 5].min\n end", "def four_of_a_kind?\r\n players_cards.each do |card_obj|\r\n return card_obj.value if players_cards.count {|card| card.value == card_obj.value} == 4\r\n end\r\n false \r\n end", "def get_high_cards(cards)\n @cards_by_score.each_key do |card|\n if cards.length < 5 && !cards.include?(card)\n cards << card\n end\n end\n end", "def n_and_m_of_a_kind? n, m\n hand = values\n values.each do |card|\n if hand.count(card) >= n\n hand.delete(card)\n hand.each { |card2| return true if hand.count(card2) >= m }\n end\n end\n false\n end", "def lost?\n @deck.cards.length == 0\n end", "def four_of_a_kind?\n cards_by_rank.values.first.count == 4\n end", "def is_flush?\n suits_of_values = {\n 0 => [],\n 1 => [],\n 2 => [],\n 3 => []\n }\n\n @sorted_cards.each do |card|\n suits_of_values[card.suit] << card.value\n\n if suits_of_values[card.suit].size >= 5\n @sorted_flush_values = suits_of_values[card.suit].last(5)\n end\n end\n\n if @sorted_flush_values && @sorted_flush_values.size >= 5\n return true \n end\n\n return false\n end", "def check_if_complete(card)\t\n\t\tif @cards.has_value?(4)\n\t\t\tcompleted_card = card\n\t\t\t@complete_sets.push(completed_card)\n\t\t\tremove_set_from_hand(completed_card)\n\t\tend\n\n\tend", "def check_all_cards\n all_cards = @cpu_hand.cards + @player_hand.cards\n\n if all_cards.length == 0\n complete\n elsif !all_cards.any? { |c| @total + c.value <= 31 }\n # There was no way to continue with the previous set, start a new one with\n # the other player.\n\n @scorer.peg_player( @turn, 1, 'a Go' )\n\n start_set\n\n @turn = other_player @turn\n end\n\n @engine.delay_update( 1 ) if @turn == :cpu\n end", "def keepable_hand\n keepable = false\n if @hand.count('land') >= 3 && @hand.count('land') <= 4 && @hand.size > 5\n keepable = true\n elsif\n @hand.count('land') >= 3 && @hand.count('low_curve') >= 1 && @hand.size >= 5\n keepable = true\n elsif\n @hand.count('land') >= 2 && @hand.count('ramp') >= 1 && @hand.size >= 5\n end\n keepable\n end", "def is_flush( hand )\n\treturn 1 == hand.map { | e | card_suit( e ) }.uniq.length ? 1 : 0\nend", "def three_of_a_kind?\n cards_by_rank.values.first.count >= 3\n end", "def cards_left_to_collect\n card_ids = UserCard.select {|card| card[\"user_id\"] == self.id}\n remaining = Card.all.count - card_ids.map { |card| card[\"card_id\"] }.uniq.count\n if remaining == 0\n puts \"=====================================================================\"\n puts \"Congratulations, you have completed the Superhero card album!!\"\n puts \"=====================================================================\"\n else\n puts \"=====================================================================\"\n puts \"You still have #{remaining} cards left to collect...\"\n puts \"=====================================================================\"\n end\n end", "def valid_for_double_down\n if @hand_cards.size == 2\n return true\n else\n return false\n end\n end", "def card_in_game\n (2..14).each {|r| (1..4).each { |i| @pack_of_card << [i, r] }}\n @cards = @pack_of_card.shuffle.take(7)\n # @hash_7_card is hash prepared for analyze combinations and the highest combination to win\n $hash_7_card = array_suit_rank\n end", "def blackjack?\n\t\treturn (hand.length == 2 and hand_value == BustLimit)\n\tend", "def check\n containAce = false\n i = 0\n sum = 0\n while i < @hand.length\n if 1 == num_to_value(@hand[i])\n containAce = true\n end\n sum += num_to_value(@hand[i])\n i += 1\n end\n\n if containAce\n if sum < 7\n @value = sum + 10\n elsif sum < 11\n @value = sum + 10\n @status = \"finished\"\n elsif 11 == sum\n if 2 == @hand.length \n @value = 50 # 50 means it's BLACKJACK\n @status = \"finished\"\n else\n @value = 21\n @status = \"finished\"\n end\n elsif sum < 17\n @value = sum\n else sum <= 21\n @value = sum\n @status = \"finished\"\n end\n else\n if sum < 17\n @value = sum\n else\n @value = sum\n @status = \"finished\"\n end\n end\n end", "def eval_5_cards( c1, c2, c3, c4, c5)\n 1\n end", "def flush(hand)\n\t\thand_num = check_num(hand)\n\t\tif !check_consecutive(hand_num) and same_suit(hand)\n\t\t\treturn 5\n\t\tend\n\t\treturn 0\n\tend", "def count_ok?\n\t\tcount <= 5\n\tend", "def has_lost?\n @deck.cards == []\n end", "def check_straight(cards)\n last = nil\n cards.each { |c|\n if last.nil? then\n last = c.face_value\n next\n end\n return false if c.face_value != last + 1\n last = c.face_value\n }\n return true\n end", "def has_unplayed_hands()\n @current_hand < @hands.length\n end", "def won?\n !@grid.flatten.any? do |card|\n !card.face_up\n end\n end", "def eval_5_cards(c1, c2, c3, c4, c5)\n begin\n index = PTable[c1]*PTable[c2]*PTable[c3]*PTable[c4]*PTable[c5]\n if FlushTable[FlushTable[FlushTable[FlushTable[FlushTable[0][c1]][c2]][c3]][c4]][c5] == 5\n EqClLookup[index].nonflush\n else\n EqClLookup[index].flush\n end\n rescue\n NULL_EQ_CLASS\n end\n end", "def pair?\n cards_by_rank.values.first.count >= 2\n end", "def flush(hand)\n suits = hand.map { |card| card[1] }\n return suits.uniq.one?\nend", "def two_pair?\n return unless size >= 4\n\n the_cards = cards_by_rank.values\n the_cards[0].count >= 2 && the_cards[1].count >= 2\n end", "def deal_hand no_of_cards\n @card_list.deal_hand no_of_cards\n end", "def bust?(hand)\n return hand_total( hand ) > WIN_VALUE \n\n end", "def has_lost?\n return false if @deck.cards.length != 0\n true\n end", "def deal_hand no_of_cards\r\n @card_list.deal_hand no_of_cards\r\n end", "def blackjack?(cards)\n\nend", "def full_dance_card\n\t\tif @card.length > 5\n\t\t\tputs \"Your dance card is full! You have to dance with #{@card[0]} before you can add #{@card[-1]}\"\n\t\t\t@card.delete_at(-1)\n\t\tend\n\t\t@card\n\tend", "def hand_check(player_check)\n if player_check.hand_total > 21\n player_check.bust = true\n puts \"#{player_check.name} busted with #{player_check.hand_total}\"\n winner\n elsif player_check.hand_total == 21\n winner\n elsif six_cards?(player_check) == true\n puts \"~~~Six cards! #{player_check.name} wins!~~~\" ; player_check.score += 1\n show_hands_final\n again?\n end\n end", "def highest_card?\n single_cards = Array.new(5, -1)\n single_count = 0\n (12).downto(0) do |i|\n if @ranks[i] == 1 and single_count < 5\n single_cards[single_count] = i\n single_count += 1\n end\n end\n return [1] + single_cards\n end", "def restock_hand!\n return if Bot::CONFIG.hand_size == unplayed_cards.count\n (Bot::CONFIG.hand_size - unplayed_cards.count).times do\n add_player_card PlayerCard.create(answer: game.available_answers.sample)\n end\n end", "def opponent_exhausted_winnings_and_base_cards?\n @opponent.no_base_cards_remaining?\n end", "def check_cards_for_warnings\n # Check for two or more cards with the same name\n duplicate_names = card_templates.select(:name).group(:name).count.select { |name, count| count > 1 }.map(&:first)\n add_warning_on_cards('duplicate_cards', duplicate_names.sort)\n end", "def discount5\n\t\tif @number_items>=5\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend", "def check_card\r\n double_every_other\r\n @double_array.inject(0) { |initial, number| initial + number.to_i } % 10 == 0\r\n end", "def is_a_set?(cards)\n result = [false, 0]\n (0..(NB_CARAC-1)).inject(true) do |result[0], carac|\n nb_uniq = cards.map{|card|CARDS[card][carac]}.uniq.size\n result[1] += (nb_uniq == NB_ETAT ? 1 : 0)\n result[0] &&= nb_uniq == 1 || nb_uniq == NB_ETAT\n end\n result\n end", "def straight?\n hand = values.sort\n hand.uniq.length == 5 && hand[4] - hand[0] == 4\n end", "def flush?(cards)\n suit = cards[0].suit\n cards.each do |card|\n return false if card.suit != suit\n end\n true\n end", "def rule_3 *cards\n if cards.all?(&:face?)\n puts \"Upping the anti! #{cards.map(&:face?)}\"\n cards.raw_integer_value + 50\n end\n end", "def straight?\n sorted = @cards.sort # sorted by value\n result = false\n # First try for the normal case. \n count = 1\n old = sorted.shift\n # Go over the cards and see if the next_rank chain can be maintained. \n for card in sorted.each do\n break if !(old.next_rank?(card))\n count += 1 \n old = card\n end\n return true if count == 5 \n # But what if the top card is an ace?\n # Try again by using that first \n sorted = @cards.sort # sorted by value\n result = false\n # First try for the normal case. \n count = 1\n old = sorted.pop\n # Go over the cards and see if the next_rank chain can be maintained. \n for card in sorted.each do\n break if !(old.next_rank?(card))\n count += 1 \n old = card\n end\n # If we have 5 cards that follow each other it's a straight.\n return true if count == 5\n return false\n end", "def non_trump_cards\n @cards.select {|c| c.suit != @trump_suit}\n end", "def is_empty?\n return cards.length <= 0\n end", "def take_from_deck(number_of_cards)\n @deck_position ||= @deck.each\n cards_taken = 0\n # @hand += @deck_position.take(number_of_cards)\n begin\n number_of_cards.times do |i| \n @hand << @deck_position.next \n cards_taken += 1\n end\n rescue StopIteration => e\n # not good, i know, but there is nothing to do here\n end\n cards_taken\n end", "def pair?\n @card_scores.uniq.length == (@card_scores.length - 1)\n end", "def royal_flush(hand)\nsuit_value = []\nface_value = []\n\thand.each do |card|\n\t\tface_value << card[0]\n\t\tsuit_value << card[1]\n\tend\n\t# suit_value = card_separator(hand)\n\t# If statement checking length of the suit value after suits are separated from royal flush => should all be \"d\" for diamonds(uniq removes all duplicates making the length 1)\n\tif suit_value.uniq.length == 1\n\t\t# Then if face_value inlcudes the [\"A\", \"K\", \"Q\", \"J\", \"T\"] faces, the hand1 value will return true\n\t\ttrue if face_value.include?(\"A\") && face_value.include?(\"K\") && face_value.include?(\"Q\") && face_value.include?(\"J\") && face_value.include?(\"T\")\n\tend\nend", "def is_a_set?(cards)\n # The sum when adding one number 3 times or adding 3 consecutive numbers is divisible by 3.\n # This represents having all the same attribute or all different attributes.\n # Adding any other 3 number combo of 1,2,3 will result in a value not divisible by 3, failing to be a set.\n isSet = (cards[0].number + cards[1].number + cards[2].number) % 3 == 0 &&\n (cards[0].color + cards[1].color + cards[2].color) % 3 == 0 &&\n (cards[0].shape + cards[1].shape + cards[2].shape) % 3 == 0 &&\n (cards[0].shade + cards[1].shade + cards[2].shade) % 3 == 0\nend", "def push?\n (session[:player].hand_total == session[:dealer].hand_total) && !( !session[:player].blackjack? && session[:dealer].blackjack? )\n end", "def play_card(discard_pile, color, number)\n @cards.length.times do |i|\n unless @cards[i].color == color && @cards[i].number == number\n next\n end\n\n discard_pile.cards << @cards[i]\n @last_action = number\n if number == \"Pickup 2\"\n discard_pile.pickup_2_count += 2\n end\n if number == \"Pickup 4\"\n discard_pile.pickup_4_count += 4\n end\n @cards.delete_at(i)\n return true\n end\n puts \"unexpected error, didn't play card\" # given validation, this should not be seen\n self\n end", "def repetitions(n)\n @hand.group_by{ |card| card.point }.select { |k, v| v.count == n }\n end", "def can_play(player_cnt)\n if @cards.length >= player_cnt * AVERAGE_HAND_SIZE\n return 1\n end\n return nil\n end", "def out_of_cards\n display(\"---Dealer ran out of cards this round!---\\n\\n\")\n end", "def full_house?\n @card_value_hash.value?(3) && @card_value_hash.value?(2)\n end", "def card_exists?(user)\n all_cards = user.cards.all.count\n all_cards >= 0\n end", "def valid_for_split\n if @hand_cards.size == 2\n if @hand_cards[0].symbol == @hand_cards[1].symbol\n return true\n end\n end\n return false\n end", "def checkHand\n possible_hands = possibleHandValues\n if possible_hands.include?(21)\n return BLACKJACK\n elsif possible_hands.empty?\n return LOST\n else\n return possible_hands.max\n end\n end", "def same_suit(hand)\n\t\tsuit = hand[0][1]\n\t\tcounter = 0\n\t\tfor digit in hand[1..-1]\n\t\t\tif digit[1] == suit\n\t\t\t\tcounter += 1\n\t\t\tend\n\t\tend\n\n\t\tif counter == hand.length() - 1\n\t\t\treturn true\n\t\tend\n\t\treturn false\n\tend", "def check_blackjack()\n hand = @hands[0]\n if hand.is_blackjack()\n print_player_hands()\n puts \"Player #{@position} has a blackjack. You win 3:2!\"\n add_winnings(hand, blackjack=true) # Add the winnings of the bet to the player\n @current_hand += 1\n end\n end", "def deal_hand no_of_cards\n hand = Hand.new\n no_of_cards.times do\n hand.add pick_random\n end\n hand\n end", "def same_suits?\n first_suit = @cards[0].suit\n @cards.each do |card|\n return false if card.suit != first_suit\n end\n return true \n end", "def must_hit\n return true if @hand.point != \"Blackjack\" && @hand.point <= 16\n return false\n end", "def check_card\n \t@card.map!.with_index do |element,index|\n\t\t\tif index.even? == true\n\t\t\t\telement * 2\n \telse\n\t\t\t\telement\n\t\t\tend\n \tend\n \t# using the reduce method instead of inject may be a bit easier to read\n \tsum = @card.join.chars.map(&:to_i).reduce(:+)\n \t# just like the puts statements we use in driver code, it's enough to try to evaluate the statement\n \t# and it will return true or false.\n \treturn sum % 10 == 0\n end", "def trump_cards\n @cards.select {|c| c.suit == @trump_suit}\n end", "def full?\n turn_count == 9\n end", "def can_split()\n hand = @hands[@current_hand]\n if hand.can_be_split() && @hands.length < 4\n if @total_money - hand.bet >= 0\n return true\n end\n end\n return false\n end", "def check\n curhand = \"hand ##{@cur+1} contains: \"\n containAce = false;\n sum = 0\n i = 0\n while i<@hands[@cur].length\n if 1 == num_to_value(@hands[@cur][i])\n containAce = true\n end\n sum += num_to_value(@hands[@cur][i])\n curhand += num_to_rank(@hands[@cur][i]) + \" \"\n i += 1\n end\n\n puts \"---------------------------------------------------------\"\n puts curhand\n\n if containAce\n if sum < 11\n puts \"hand ##{@cur+1} value: #{sum}/#{sum+10}\"\n @values[@cur] = sum + 10 # store the higher value which benefits the player\n elsif 11 == sum \n if 2 == @hands[@cur].length && 1 == @hands.length # a blackjack!! no split and only contain two cards\n puts \"hand ##{@cur+1} value: BLACKJACK!!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 50 # use 50 to represent a blackjack\n else\n puts \"hand ##{@cur+1} value: 21\"\n @values[@cur] = 21\n @hands_status[@cur] = \"finished\"\n end\n elsif sum < 21\n puts \"hand ##{@cur+1} value: #{sum}\"\n @values[@cur] = sum\n elsif 21 == sum\n puts \"hand ##{@cur+1} value: 21\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 21\n else\n puts \"hand ##{@cur+1} value: #{sum} busted!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = sum \n end\n else\n if sum < 21\n puts \"hand ##{@cur+1} value: #{sum}\"\n @values[@cur] = sum\n elsif 21 == sum\n puts \"hand ##{@cur+1} value: 21\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 21\n else\n puts \"hand ##{@cur+1} value: #{sum} busted!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = sum\n end\n end\n\n\n puts \"bets for hand ##{@cur+1}: #{@bets[@cur]}\"\n puts \"---------------------------------------------------------\"\n\n if \"finished\" == @hands_status[@cur] \n puts \"hand ##{@cur+1} finished\"\n puts \"\"\n if @cur < @hands.length - 1\n @cur += 1 \n self.check # this recursion is to output the information about newly splitted hand's initial status\n end\n end\n\n end", "def straight_flush?\n relevant_ranks = cards_by_suit.values.find {|suited| suited.count >= cards_needed}\n\n return unless relevant_ranks\n\n relevant_ranks = relevant_ranks.sort!.map(&:rank).reverse!\n\n return true if relevant_ranks.include?(:ace) &&\n relevant_ranks.to_set.superset?(Card::ranks.take(cards_needed - 1).to_set)\n\n relevant_ranks.each_cons(cards_needed).any? do |cons|\n Card::rank_index(cons.first) - Card::rank_index(cons.last) == cards_needed - 1\n end\n end", "def poker?\n cuantos_pares == 2 && @pares.group_by{|k, v| k}.size == 1\n end", "def straight_flush_wake(array)\n #to initialize the hash use '.new'\n hash = Hash.new(0)\n suit = array.first.suit\n #to get suit to increment\n array.each{|card| hash[card.suit] +=1}\n hash.keys.length == 1 && hash [suit] == 5\nend", "def empty?\n cards.empty?\n end", "def has_max_hands\n return 1 if @hands.length == MAX_HANDS\n return nil\n end", "def split_hand?(hand)\n return @hands.include?(hand) && hand.split? && @hands.length <= MAX_SPLITS && @cash - hand.bet >= 0\n end", "def valid_numbers(num_cards, num_players)\n if (num_cards * num_players > 52 || num_cards < 1 || num_players < 2)\n\t\treturn false\n\telse\n\t\treturn true\n\tend\nend", "def full_house?\n matched = self.matched_cards\n found_pair = false\n found_three = false\n for rank, matches in matched do\n found_pair = true if matches.count == 2\n found_three = true if matches.count == 3\n end\n return found_pair && found_three \n end", "def check_discards_in_hand?(player, turn, done)\n expected_hand = expected_hand(player, turn)\n\n discard_list = done.discards.map{|squad|\n squad.list_of_cards\n }.flatten\n \n if !discard_list.all?{|card| expected_hand.include?(card)}\n raise Cheating, \"Player is discarding cards not in his/her hand!\"\n else\n true\n end\n end", "def eval_n_cards(cards)\n cards.combination(5).inject(EqClTable.last.code) do |best_code, comb|\n q=eval_5_cards(*comb)\n if q<best_code then q; else best_code; end\n end\n end", "def has_multiple_hands\n return 1 if @hands.length > 1\n return nil\n end", "def is_complete?\n if empty?\n puts \"Deck is empty\"\n return false\n elsif !is_full?\n puts \"Deck is missing some cards\"\n return false\n else\n myhash = {}\n @deck.each do |x|\n myhash[x.suit.value] ||= []\n myhash[x.suit.value] << x.value\n end\n\n Suit::VALID_SUIT.each do |suit|\n return false if myhash[suit].length != 13\n end\n return true\n\n end\n\n end" ]
[ "0.77190894", "0.7696931", "0.7544853", "0.7426773", "0.7379774", "0.71706223", "0.7072673", "0.7059381", "0.6965509", "0.69097555", "0.68847656", "0.6856932", "0.68359697", "0.68305546", "0.68256474", "0.6815574", "0.6785656", "0.67349523", "0.67292315", "0.67136276", "0.6705756", "0.6692552", "0.66919357", "0.6680119", "0.6666309", "0.6655562", "0.66268396", "0.6600049", "0.659885", "0.6576421", "0.6549506", "0.654027", "0.6528977", "0.6526498", "0.65194756", "0.651244", "0.65096134", "0.6506501", "0.64968824", "0.6474733", "0.64719206", "0.64701456", "0.64483374", "0.6447967", "0.64456683", "0.6409659", "0.640216", "0.6401261", "0.63994634", "0.6396764", "0.6383346", "0.6378912", "0.6377188", "0.6363076", "0.63582605", "0.63574934", "0.63572377", "0.6354835", "0.6348616", "0.63398117", "0.6321696", "0.6320203", "0.6318737", "0.6315952", "0.63136446", "0.6305792", "0.6303959", "0.6300373", "0.6286985", "0.6274787", "0.6261255", "0.62510353", "0.62254965", "0.62187374", "0.62153983", "0.62071466", "0.6205717", "0.619676", "0.61961985", "0.61923903", "0.6190317", "0.6176284", "0.6168702", "0.6162142", "0.61607915", "0.6158667", "0.6155674", "0.6154704", "0.6153579", "0.614921", "0.61448556", "0.6135458", "0.61346006", "0.6134406", "0.6127711", "0.6123612", "0.61211985", "0.61155653", "0.6113781", "0.61122406" ]
0.80713946
0
determines what exists in hands
def pair? @card_scores.uniq.length == (@card_scores.length - 1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_multiple_hands\n return 1 if @hands.length > 1\n return nil\n end", "def has_a_hand\n return 1 if @hands.length > 0\n return nil\n end", "def hand\n hands.first\n end", "def has_hands\n return @hands.select{|hands| hands.status == HandStatus::PLAY} != []\n end", "def hands\n @game_stats['hands']\n end", "def checkHand\n possible_hands = possibleHandValues\n if possible_hands.include?(21)\n return BLACKJACK\n elsif possible_hands.empty?\n return LOST\n else\n return possible_hands.max\n end\n end", "def main_hand\n if has_hands\n return @hands[0]\n else\n return false\n end\n end", "def analyze_hand\n pairs = 0\n straight = 0\n flush = 0\n\n # for now be conservative\n @play = 3\n\n # check for pairs\n\n\n # check for flush\n\n # check for straight\n\n\n\n # check for special hands\n #full house\n #royal flush\n #straight flush\n \n end", "def full_house(hand)\n\t\tif (pair(hand) > 0 and three_of_a_kind(hand) > 0)\n\t\t\treturn 6\n\t\tend\n\t\treturn 0\n\tend", "def has_max_hands\n return 1 if @hands.length == MAX_HANDS\n return nil\n end", "def is_full_house( hand )\n\treturn ( is_three_of_a_kind( hand ) && is_one_pair( hand ) ) ? 1 : 0\nend", "def has_unplayed_hands()\n @current_hand < @hands.length\n end", "def getResult\n \t@hands[0].checkHand\n end", "def hand\n return @hands[0] if self.has_a_hand\n return nil\n end", "def process_hands(hands)\n if hands.length != 2\n puts \"#{hands.length} hands detected\" if hands.length > 2\n return\n end\n \n # check if these hands already exist, if not trigger right left detection\n @new_hands = false\n hand_diff = (@hand_list.keys - hands.collect(&:id)) + (hands.collect(&:id) - @hand_list.keys)\n if hand_diff.length > 0\n @new_hands = true\n end\n \n directions = {}\n directions = detect_hands(hands) if @new_hands\n hand_diff.each do |hid|\n @hand_list.delete(hid)\n end\n \n hands.each do |hand|\n process_hand(hand, directions[hand.id])\n end\n\n end", "def have_suit?(player,suit)\n h = hand(player)\n h.each do |c|\n if c.suit == suit \n return true\n end\n end\n false\n end", "def return *hands\n hands.each do |hand_or_cards|\n cards = (hand_or_cards.is_a?(CardDecks::Hand) ? hand_or_cards.cards : Array.wrap(hand_or_cards))\n @used += cards\n @inhand.delete_if {|c| cards.include?(c) }\n @hands.each {|h| h.cards.delete_if {|c| cards.include?(c) } }\n end\n end", "def get_hand\n return @cards_in_hand\n end", "def can_split_hand(hand)\n return nil\n end", "def example4 poker_hands\n deck = PokerDeck.new\n deck.shuffle!\n hand = deck.hand\n num = 1\n while !poker_hands.include?(hand.poker_hand) do\n num += 1\n deck.shuffle!\n hand = deck.hand\n puts \"[#{num}] #{hand.coded_info}\"\n end\n puts '----'\n hand.order!\n puts \"The hand, coded and ordered: #{hand.coded_info}\"\n puts \"Same hand, ordered: #{hand}\"\n puts \"Poker hand type: #{hand.poker_hand}\"\n end", "def is_flush( hand )\n\treturn 1 == hand.map { | e | card_suit( e ) }.uniq.length ? 1 : 0\nend", "def royal_flush(hand)\nsuit_value = []\nface_value = []\n\thand.each do |card|\n\t\tface_value << card[0]\n\t\tsuit_value << card[1]\n\tend\n\t# suit_value = card_separator(hand)\n\t# If statement checking length of the suit value after suits are separated from royal flush => should all be \"d\" for diamonds(uniq removes all duplicates making the length 1)\n\tif suit_value.uniq.length == 1\n\t\t# Then if face_value inlcudes the [\"A\", \"K\", \"Q\", \"J\", \"T\"] faces, the hand1 value will return true\n\t\ttrue if face_value.include?(\"A\") && face_value.include?(\"K\") && face_value.include?(\"Q\") && face_value.include?(\"J\") && face_value.include?(\"T\")\n\tend\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 expected_hand(player, turn)\n my_player = @playerstates.detect{|playerstate| playerstate.name == player.player_name}\n expected_hand = my_player.hand.hand_to_list\n cardsfrom = turn.turn_end\n if cardsfrom.from_deck?\n new_cards = [turn.deck.take]\n elsif cardsfrom.from_stack?\n new_cards = turn.stack.take(cardsfrom.how_many_cards?)\n end\n expected_hand = expected_hand + new_cards\n end", "def in_this_hand?\n\t\t\t@state_hash['state']['players'].any? {|p| p['id'] == @player_id}\n\t\tend", "def in_this_hand?\n\t\t\t@state_hash['state']['players'].any? {|p| p['id'] == @player_id}\n\t\tend", "def index_has_not_been_played(hands)\n hands.index { |hand| hand.has_been_played == false }\n end", "def currentHand #finds current hand during game\n self.hands.last\n end", "def show_hands_initial\n player.show_hand\n dealer.show_hand\n end", "def find_pair\n @hand_hash.values.any? { |value| value == 2 }\n end", "def poker hands\n raise NoHandError if hands.empty?\n allmax(hands, method(:hand_rank))\nend", "def split_hand?(hand)\n return @hands.include?(hand) && hand.split? && @hands.length <= MAX_SPLITS && @cash - hand.bet >= 0\n end", "def can_split_hand(hand)\n if hand.can_split and not self.has_max_hands\n return 1\n end\n return nil\n end", "def flush(hand)\n suits = hand.map { |card| card[1] }\n return suits.uniq.one?\nend", "def show_hands_final\n player.show_hand\n dealer.show_hand_for_turn\n end", "def find_hand_category(hand)\r\n \t\tif hand.size == 7\r\n \t\t\t# really not good!! have to put royal flush, straight flush\r\n \t\t\t# and straigh together! \r\n \t\t\tif num_suits(hand).max >= 5 && num_faces(hand)[0..4] == Array.new(5,1) \r\n \t\t\t\t@hand_category = \"Royal Flush\"\r\n \t\t\telsif num_faces(hand).max >= 4\r\n \t\t\t\t@hand_category = \"Four of a kind\"\r\n \t\t\telsif num_faces(hand).max == 3\r\n \t\t\t\t@hand_category = \"Three of a kind\"\r\n \t\t\telsif num_faces(hand).max == 2\r\n \t\t\t\t@hand_category = \"pair\"\r\n \t\t\telsif num_faces(hand).sort.last>=3 && num_faces(hand).sort[12]>=2\r\n \t\t\t\t@hand_category = \"Full House\"\r\n \t\t\telsif num_faces(hand).sort.last == 2 && num_faces(hand).sort[12]==2\r\n \t\t\t\t@hand_category = \"two pairs\"\r\n \t\t\tend \r\n \t\tend\r\n \t\treturn @hand_category\r\n \tend", "def best_hand\n case\n when hand?\n return @cards\n when pair? && !hand?\n get_pairs\n when two_pair? && !hand?\n get_pairs\n when three_of_a_kind? && !full_house? && !hand?\n get_three_of_a_kind\n when straight? && !straight_flush? && !hand?\n get_straight\n when flush? && !straight_flush? && !hand?\n get_flush\n when full_house? && !hand?\n get_full_house\n when four_of_a_kind? && !hand?\n get_four_of_a_kind\n when straight_flush? && !hand?\n get_straight_flush\n else\n get_high_card\n end\n end", "def winning_hand\n if !(@player.hand.bust)\n if @player.hand.value > @dealer.hand.value\n player_win\n elsif @player.hand.value == @dealer.hand.value\n if @player.hand.blackjack? && !@dealer.hand.blackjack?\n player_win\n else\n puts \"The hand pushed\"\n @player.push_bet\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n else\n puts \"You lost the hand\"\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n else\n puts \"You busted\"\n puts \"You have #{@player.chips_remaining} remaining\"\n end\n end", "def hand_value\n @hand_value = []\n if straight_flush?\n @hand_value << 9 << straight_flush?\n elsif four_of_a_kind?\n @hand_value << 8 << four_of_a_kind?\n elsif full_house?\n @hand_value << 7 << full_house?\n elsif flush?\n @hand_value << 6 << flush?\n elsif straight?\n @hand_value << 5 << straight?\n elsif three_of_a_kind?\n @hand_value << 4 << three_of_a_kind?\n elsif two_pair?\n @hand_value << 3 << two_pair?\n elsif pair?\n @hand_value << 2 << pair?\n else\n @hand_value << 1 << points[0]\n end\n\n end", "def bot_hand(player_hand)\n @elements.keys.sample\n end", "def rank_starting_hand\r\n sorted_hand = @hole_cards.sort_by { |card| card.rank } # [4,2] => [2,4]\r\n\r\n # Shorthand variables for two cards in hand\r\n (first,second) = [sorted_hand[0],sorted_hand[1]]\r\n\r\n suited = first.suit == second.suit # True if cards have same suit\r\n paired = first.rank == second.rank # True if cards have same rank\r\n connected = first.rank + 1 == second.rank # True if cards have consecutive ranks\r\n\r\n # Check for playable hands and return their rank\r\n # (Some of these checks aren't necessary but are included for readibility)\r\n case first.rank\r\n when 8 then return 14 if paired # Pocket Eights\r\n when 9 then return 9 if paired # Pocket Nines\r\n when 10\r\n return 6 if paired # Pocket Tens\r\n return 20 if second.rank == 12 and suited # Queen-Ten Suited\r\n return 16 if second.rank == 13 and suited # King-Ten Suited\r\n return 12 if second.rank == 14 and suited # Ace-Ten Suited\r\n when 11\r\n return 4 if paired # Pocket Jacks\r\n return 17 if second.rank == 12 and suited # Queen-Jack Suited\r\n return 15 if second.rank == 13 and suited # King-Jack Suited\r\n if second.rank == 14\r\n return suited ? 10 : 18 # Ace-Jack Suited/Offsuit\r\n end\r\n when 12\r\n return 3 if paired # Pocket Queens\r\n if second.rank == 13\r\n return suited ? 11 : 19 # King-Queen Suited/Offsuit\r\n elsif second.rank == 14\r\n return suited ? 8 : 13 # Ace-Queen Suited/Offsuit\r\n end\r\n when 13\r\n return 2 if paired # Pocket Kings\r\n if second.rank == 14\r\n return suited ? 5 : 7 # Ace-King Suited/Offsuit\r\n end\r\n when 14 then return 1 if paired # Pocket Aces\r\n end\r\n # Still played if the hand is suited, paired, or connected, otherwise not played\r\n return (suited or paired or connected) ? 21 : -1\r\n end", "def test_straight_flush_high_card\n p = Hand.new(SF)\n assert p.find_hand_rank == [\"Straight Flush\", \"High Card : 10C\"]\n end", "def first_hand?\n\t\treturn @first_hand\n\tend", "def decide(hand)\n value(hand) >= 17 && :stand || :hit\nend", "def face_card?\n [:jack,:queen,:king].include? @identifier\n end", "def blackjack(hand)\n value(hand) == 21 && hand.length == 2\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 total_hands\n return @@total_hands\n end", "def straight_flush_wake(array)\n #to initialize the hash use '.new'\n hash = Hash.new(0)\n suit = array.first.suit\n #to get suit to increment\n array.each{|card| hash[card.suit] +=1}\n hash.keys.length == 1 && hash [suit] == 5\nend", "def getHand()\n return @hand\n end", "def is_high_card( hand )\n\treturn hand.map { | e | card_value( e ) }.max\nend", "def hand_value cards\n values = cards.map{|c| $value_map[c[0]]}\n suits = cards.map{|c| c[1]}\n is_flush = false\n # check for flush\n if suits.uniq.size == 1\n is_flush = true\n end\n # check for straight\n is_straight = true\n sorted_values = values.sort\n for v in 0..(values.size-2)\n unless sorted_values[v]+1 == sorted_values[v+1]\n is_straight = false\n break\n end\n end\n if is_straight\n if is_flush\n # royal flush\n return {rank: 9, secondary: 10} if sorted_values[0] == 10\n # straight flush\n return {rank: 8, secondary: sorted_values[0]}\n end\n end\n # check for four of a kind\n if sorted_values[0] == sorted_values[3] || sorted_values[1] == sorted_values[4]\n return {rank: 7, secondary: sorted_values[1]}\n end\n # check for three of a kind or full house\n if sorted_values[0] == sorted_values[2]\n return {rank: 6, secondary: sorted_values[0]} if sorted_values[3] == sorted_values[4]\n return {rank: 3, secondary: sorted_values[0]}\n end\n if sorted_values[2] == sorted_values[4]\n return {rank: 6, secondary: sorted_values[2]} if sorted_values[0] == sorted_values[1]\n return {rank: 3, secondary: sorted_values[2]}\n end\n # check for three of a kind (case where full house is not possible)\n if sorted_values[1] == sorted_values[3]\n return {rank: 3, secondary: sorted_values[1]}\n end\n # return for flush (fine since three of a kind/full house and flush are mutually exclusive)\n return {rank: 5, secondary: sorted_values.last} if is_flush\n # return for straight (fine since three of a kind/full house and straight are mutually exclusive)\n return {rank: 4, secondary: sorted_values[0]} if is_straight\n # check for two pairs\n if sorted_values[0] == sorted_values[1] && sorted_values[2] == sorted_values[3]\n return {rank: 2, secondary: (sorted_values[0] > sorted_values[2] ? sorted_values[0] : sorted_values[2])}\n end\n if sorted_values[0] == sorted_values[1] && sorted_values[3] == sorted_values[4] \n return {rank: 2, secondary: (sorted_values[0] > sorted_values[3] ? sorted_values[0] : sorted_values[3])}\n end\n if sorted_values[1] == sorted_values[2] && sorted_values[3] == sorted_values[4] \n return {rank: 2, secondary: (sorted_values[1] > sorted_values[3] ? sorted_values[1] : sorted_values[3])}\n end\n # check for pairs\n return {rank: 1, secondary: sorted_values[0]} if sorted_values[0] == sorted_values[1]\n return {rank: 1, secondary: sorted_values[1]} if sorted_values[1] == sorted_values[2]\n return {rank: 1, secondary: sorted_values[2]} if sorted_values[2] == sorted_values[3]\n return {rank: 1, secondary: sorted_values[3]} if sorted_values[3] == sorted_values[4]\n # otherwise high card\n return {rank: 0, secondary: sorted_values.last}\nend", "def shouldHit\n # If 17 or above, lock the hand so it cannot receive any more cards\n \tif @hands[0].checkHand > 16 or @hands[0].checkHand < 0\n \t @hands[0].lock\n \tend\n \t@hands[0].canGetCards\n end", "def initialize (cards)\n #sort the cards and store them in @cards\n @cards = Array.new\n cards.each do |card|\n @cards << Card.new(card)\n end\n @cards.sort!\n \n #determine the rank of the hand\n @rank = 0\n \n #see if at least one pair exists\n if @cards[0] == @cards[1] or @cards[1] == @cards[2] or @cards[2] == @cards[3] or @cards[3] == @cards[4]\n @handStart = @cards[0] == @cards[1] ? 0 : @cards[1] == @cards[2] ? 1 : @cards[2] == @cards[3] ? 2 : 3\n @rank = 1 #one pair\n #see if it's part of a three of a kind\n if @cards[0] == @cards[2] or cards[1] == @cards[3] or cards[2] == @cards[4]\n #see if hand is a full house\n if (@cards[0] == @cards[1] and @cards[2] == @cards[3] and @cards[2] == @cards[4]) or (@cards[0] == @cards[1] and @cards[0] == @cards[2] and @cards[3] == @cards[4])\n @handSubstart = @cards[2] == @cards[4] ? 2 : 3\n @rank = 6 #full house\n else\n @rank = 3 #three of a kind\n \n #see if it's part of a four of a kind\n if @cards[0] == @cards[3] or @cards[1] == @cards[4]\n @rank = 7 #four of a kind\n end\n end\n else\n #see if there are two pairs\n if (@cards[0] == @cards[1] and @cards[2] == @cards[3]) or (@cards[1] == @cards[2] and @cards[3] == @cards[4]) or (@cards[0] == @cards[1] and @cards[3] == @cards[4])\n @rank = 2 #two pairs\n @handSubstart = @cards[2] == @cards[4] ? 2 : 3\n end\n end\n else\n #check for straight\n inorder = true\n 0.upto(@cards.count - 2) do |x|\n if @cards[x].face and !@cards[x+1].face\n inorder = false\n break\n elsif !@cards[x].face and !@cards[x+1].face\n unless @cards[x].value + 1 == @cards[x+1].value\n inorder = false\n break\n end\n else\n unless @cards[x+1].value == \"J\"\n inorder = false\n break\n end\n end\n end\n if inorder\n @rank = 4 #straight\n end\n end\n \n #check for flush, straight flush and royal flush\n flush = true\n suit = @cards[0].suit\n @cards.each do |card|\n unless card.suit == suit\n flush = false\n break\n end\n end\n if flush\n if @rank == 4\n @rank = 8 #straight flush\n elsif @cards[1].face and @cards[2].face and @cards[3].face and @cards[4].face\n @rank = 9 #royal flush\n elsif @rank < 6\n @rank = 5 #flush\n end\n end\n end", "def start_hand\n @hands[0] = DealerHand.new\n @hands[0].hit_soft_17 = @hit_soft_17\n return @hands[0]\n end", "def update_hands\n\t\tplayers.each do |player|\n\t\t\tnext if player.folded?\n\t\t\tdiscard_idx = player.get_discard\n\t\t\tplayer.update_hand(discard_idx, @deck)\n\t\tend\n\tend", "def start_hand\n @num_hands += 1\n @@total_hands += 1\n i = @hands.length\n @hands[i] = Hand.new\n self.place_bet(@hands[i])\n return @hands[i]\n end", "def play_hand( hand )\n\tscore = Array.new( 10 )\n\n\tscore[ 0 ] = [ is_royal_flush( hand ) ]\n\tscore[ 1 ] = [ is_straight_flush( hand ) ]\n\tscore[ 2 ] = [ is_four_of_a_kind( hand ) ]\n\tscore[ 3 ] = [ is_full_house( hand ) ]\n\tscore[ 4 ] = [ is_flush( hand ) ]\n\tscore[ 5 ] = [ is_straight( hand ) ]\n\tscore[ 6 ] = is_three_of_a_kind( hand )\n\tscore[ 7 ] = is_two_pair( hand )\n\tscore[ 8 ] = [ is_one_pair( hand ) ]\n\tscore[ 9 ] = [ is_high_card( hand ) ]\n\t\n\treturn score\nend", "def is_flush?\n @hand.all? {|card| card.suit == @hand[0].suit}\n end", "def show_hand hand=@hand\n\t\t#Output the title\n\t\tputs \"#\".center(5)+\"Color\".ljust(8)+\"Shading\".ljust(10)+\"Symbol\".ljust(10)+\"Number\"\n\t\tputs \"----------------------------------------\"\n\n\t\t#Output the cards\n\t\thand.length.times{ |card|\n\t\t\tputs \"#{card}\".rjust(3)+\": \"+\"#{hand[card].color}\".ljust(8)+\"#{hand[card].shading}\".ljust(10)+\"#{hand[card].symbol}\".ljust(10)+\" #{hand[card].number}\".rjust(3)\n\t\t}\n\n\t\t#Gives hint for easy development/testing\n\t\t# hint = []\n\t\t# find_set.each do |card| hint.push(@hand.index(card)) end\n\t\t# puts hint.to_s\n\tend", "def addHand(hand)\n if @hands.empty?\n super\n end\n end", "def show_hands\n puts \"\\nDealer hand: #{@dealer_hand}\" \" | Hand Value: #{hand_value(@dealer_hand)}\"\n puts \"\\nYour hand: #{@player_hand}\" \" | Hand Value: #{hand_value(@player_hand)}\"\n end", "def full_house?\n return unless size >= 5\n\n the_cards = cards_by_rank.values\n the_cards[0].count >= 3 && the_cards[1].count >= 2\n end", "def homme?\n !identified? || sexe == 'H'\n end", "def show_hands(players)\n for player in players\n for hand in player.hands\n puts \"#{player.to_s} ------ #{hand.to_s}\"\n end\n end\n end", "def who_wins\n\n bj = false\n bust = false\n #//Check for dealer status after the showing hands\n if @dealer.busted?\n @ui.message(\"dealer loses\")\n bust=true\n else\n if @dealer.get_value == 21 && @dealer.num_cards == 2\n bj=true\n end\n end\n\n #//Check for player status after showing hands\n\n for player in @players\n hand_index = 0\n while hand_index < player.num_hands\n if player.busted?(hand_index)\n ui.message(player.name+\"loses on hand\"+ (hand_index+1).to_s)\n else\n if player.get_value(hand_index) == 21 && player.num_cards(hand_index) == 2 && !player.split?\n if BJ == true\n @ui.message(player.name+\" and dealer has a black jack!!! its a push on hand\"+ (hand_index+1).to_s)\n @ui.message(player.name+\"gets back \"+ player.push(hand_index).to_s)\n else\n @ui.message(\" its a black jack!!!\"+player.name+\" wins on hand\"+ (hand_index+1).to_s)\n @ui.message(player.name+\"gets \"+player.win(hand_index,true).to_s)\n end\n else\n if !bust\n if player.get_value(hand_index) > @dealer.get_value\n @ui.message(player.name+\" wins on hand\"+ (hand_index+1).to_s+\"!!!\")\n @ui.message(player.name+\"gets \"+player.win(hand_index,false).to_s)\n elsif player.get_value(hand_index) == dealer.get_value\n @ui.message(\"Its a push on hand\"+ (hand_index+1).to_s+\"!!!\"+player.name+\" and dealer has same value.\")\n @ui.message(player.name+\"gets back \"+ player.push(hand_index).to_s)\n else\n @ui.message(player.name+\" loses on hand\"+ (hand_index+1).to_s)\n end\n else\n @ui.message(player.name+\" wins on hand\"+ (hand_index+1).to_s+\"!!!\")\n @ui.message(player.name+\"gets \"+player.win(hand_index,false).to_s)\n end\n end\n end\n hand_index+=1\n end\n end\n end", "def card_played_onhand(mano_count,card_ontable_pos)\r\n mano_hash = @cards_withmano_table[mano_count]\r\n card = mano_hash[card_ontable_pos]\r\n return card.to_sym \r\n end", "def find_poker_subsets\n # calls other poker subset methods\n update_hand_hash\n return 8 if find_straight_flush\n return 7 if find_quad\n return 6 if find_full_house\n return 5 if find_flush\n return 4 if find_straight\n return 3 if find_triple\n return 2 if find_two_pair\n return 1 if find_pair\n return 0 if find_high_card(@cards)\n end", "def print_current_hands\n p \"#{@player.name}'s current hand: #{@player.hand}, and the sum is #{get_hand_sum(@player.hand)}\"\n p \"#{@house.name} current hand: #{@house.hand}, and the sum is #{get_hand_sum(@house.hand)}\"\n end", "def keepable_hand\n keepable = false\n if @hand.count('land') >= 3 && @hand.count('land') <= 4 && @hand.size > 5\n keepable = true\n elsif\n @hand.count('land') >= 3 && @hand.count('low_curve') >= 1 && @hand.size >= 5\n keepable = true\n elsif\n @hand.count('land') >= 2 && @hand.count('ramp') >= 1 && @hand.size >= 5\n end\n keepable\n end", "def play_like_a_dummy\r\n # very brutal algorithm , always play the first card\r\n #card = @cards_on_hand.pop\r\n #p @cards_on_hand.size\r\n card = @cards_on_hand[0]\r\n if card\r\n # check if the played card take something\r\n #@table_cards\r\n \r\n #@log.debug \"Alg: cards on table #{@table_cards}\"\r\n list = @core_game.which_cards_pick(card, @table_cards)\r\n #p \"which cards pick: card #{card}, table #{@table_cards.join(\",\")}, list #{list.size}\"\r\n result = [card, list[0]].flatten\r\n return result\r\n end\r\n raise \"Error cards on hand #{@cards_on_hand.join(',')}\" \r\n end", "def init_player_hands\n\n @player1_hand = []\n @player2_hand = []\n @player3_hand = []\n @player4_hand = []\n\n end", "def eval_7_card_hand( cards )\n 1\n end", "def hands\n dealer.hand = []\n player.hand = []\n end", "def show_hand\n if @hand.point == \"Blackjack\" # the dealer should reveal both cards when it has blackjack\n @hand.turn_all_cards_up\n puts \" #{@hand.to_s} Blackjack\\n\" \n else\n puts \" #{@hand.to_s}\\n\"\n end\n end", "def hand?\n @cards_by_score.length == 5\n end", "def hall_of_famer?\n return false unless self.profile[\"levels_unlocked\"]\n Set.new(self.profile[\"levels_unlocked\"]).count == 65\n end", "def starting_hands\n @dealer_hand.push(random_card)\n @player_hand.push(random_card, random_card)\n end", "def print_player_hands()\n puts \"--- Player #{@position} --- \"\n @hands.each do |hand| # The player might have multiple hands, if splitting was used\n puts hand.to_s() # Print the details of the hand\n end\n end", "def hand_value(hand) #calling upon function \"hand_value\". Getting hand (made up var. at the moment) \n value = 0\n for card in hand #do is a method. calling upon each card in the hand\n if $deck_values.keys.include?(card) # IF the keys of deck_values are included in the card, then..\n value += $deck_values[card] #value is equal to the card within deck_values\n else #otherwise, if value is NOT equal to the keys of deck_values, then value is equal to card\n value += card \n end\n end\n return value\nend", "def check\n curhand = \"hand ##{@cur+1} contains: \"\n containAce = false;\n sum = 0\n i = 0\n while i<@hands[@cur].length\n if 1 == num_to_value(@hands[@cur][i])\n containAce = true\n end\n sum += num_to_value(@hands[@cur][i])\n curhand += num_to_rank(@hands[@cur][i]) + \" \"\n i += 1\n end\n\n puts \"---------------------------------------------------------\"\n puts curhand\n\n if containAce\n if sum < 11\n puts \"hand ##{@cur+1} value: #{sum}/#{sum+10}\"\n @values[@cur] = sum + 10 # store the higher value which benefits the player\n elsif 11 == sum \n if 2 == @hands[@cur].length && 1 == @hands.length # a blackjack!! no split and only contain two cards\n puts \"hand ##{@cur+1} value: BLACKJACK!!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 50 # use 50 to represent a blackjack\n else\n puts \"hand ##{@cur+1} value: 21\"\n @values[@cur] = 21\n @hands_status[@cur] = \"finished\"\n end\n elsif sum < 21\n puts \"hand ##{@cur+1} value: #{sum}\"\n @values[@cur] = sum\n elsif 21 == sum\n puts \"hand ##{@cur+1} value: 21\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 21\n else\n puts \"hand ##{@cur+1} value: #{sum} busted!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = sum \n end\n else\n if sum < 21\n puts \"hand ##{@cur+1} value: #{sum}\"\n @values[@cur] = sum\n elsif 21 == sum\n puts \"hand ##{@cur+1} value: 21\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = 21\n else\n puts \"hand ##{@cur+1} value: #{sum} busted!\"\n @hands_status[@cur] = \"finished\"\n @values[@cur] = sum\n end\n end\n\n\n puts \"bets for hand ##{@cur+1}: #{@bets[@cur]}\"\n puts \"---------------------------------------------------------\"\n\n if \"finished\" == @hands_status[@cur] \n puts \"hand ##{@cur+1} finished\"\n puts \"\"\n if @cur < @hands.length - 1\n @cur += 1 \n self.check # this recursion is to output the information about newly splitted hand's initial status\n end\n end\n\n end", "def full_house?\n if three_of_a_kind?\n triple_high = three_of_a_kind?[1]\n (12).downto(0) do |i|\n if @ranks[i] >= 2\n if i != triple_high\n return [7, triple_high, i, -1, -1, -1]\n end\n end\n end\n end\n return false\n end", "def possibleHandValues\n \thand_values = Set.new [0] # start with value 0\n \t@cards.each do |card| # for each card in the hand\n \t card_values = card.getValue\n \t new_hand_values = Set.new # add its value to all the possible\n \t hand_values.each do |total| # values for each of the previous\n \t \tcard_values.each do |card_value| # cards\n new_hand_values << total+card_value\n end\n end\n # Swap variable names. This makes the loop simpler\n new_hand_values, hand_values = hand_values, new_hand_values\n new_hand_values.clear\n end\n # Get the values that are below 21\n hand_values.delete_if do |value|\n if value > BLACKJACK\n true\n end\n end\n hand_values # Return set of possible values\n end", "def determine_playable_cards\n playable_cards = []\n hand.each do |card_in_hand|\n if card_in_hand[\"cost\"] <= @mana_available\n playable_cards.push(card_in_hand)\n end \n end\n if mana_available >= 2\n playable_cards.push(\"hero ablity\")\n end\n playable_cards\n end", "def poker_hand\n # If a hand hasn't been played yet, display a welcome message with some key information.\n welcome_message(@player_positions) unless @hand_played\n\n # Do the players want to start a new hand?\n new_hand_check\n\n # If they do, let's play!\n if @game_running\n\n # Resets and reinitializes everything required for the start of a new hand.\n reset_values\n set_blinds\n init_deck\n deal_hole_cards\n system 'clear'\n puts 'Dealing the cards..'\n sleep(2)\n\n # Starts a loop that checks to see whether a winner needs to be determined.\n while @active_players.length > 1 && @stage_of_play < 4\n # Each time it loops back to this point means we've progressed to the next stage of play and cards need to be dealt.\n deal_community_cards\n\n # If a player has gone all in in the last round of betting, sets the maximum amount that player can win this hand.\n @active_players.map do |player|\n next unless player.chip_stack == 0 && player.max_pot != 0\n\n player.max_winnings = (@pot_size - @committed) + (player.max_pot * @active_players.length)\n player.max_pot = 0\n end\n\n # Resets the committed value AFTER max_winnings has been calculated.\n @committed = 0 if @stage_of_play.positive?\n\n loop do\n # If a player has folded they are no longer active in this hand.\n @active_players.map do |player|\n @active_players.delete(player) if player.folded == true\n end\n\n # If a player is still active and has no chips left, they are all in.\n @all_in_players = 0\n @active_players.map do |player|\n @all_in_players += 1 if player.chip_stack.zero?\n end\n\n # If the player is all in and there are players who aren't all in rotate the array to check the next player.\n if @active_players[0].acted == true && @active_players[0].chip_stack.zero? && @active_players.length != @all_in_players\n @active_players.rotate!\n\n # If the player was the initial raiser and they haven't had their bet raised, move onto the next stage of the hand.\n elsif (@active_players[0].acted == true) && (@active_players[0].current_bet == @table_current_bet)\n @stage_of_play += 1\n\n # Resets everyone so they haven't acted for the next round of betting, except for those who are all in.\n @active_players.map do |player|\n if player.current_bet == @table_current_bet\n player.acted = false unless player.chip_stack.zero?\n end\n player.current_bet = 0\n end\n @table_current_bet = 0\n break\n\n else\n # If all of the above conditions fail, it means the player needs to make a move.\n ready_check(@active_players[0])\n player_action\n end\n end\n end\n end\n end", "def pl_high?\n session[:player].hand_total > session[:dealer].hand_total\n end", "def printAskUserInstr(player,dealer,hand)\n puts dealer.printHands(true)\n puts player.printHands\n puts \"Player \" + player.getName + \", what would you like to do on Hand \" + hand.getName + \"?\"\n if hand.isFirstTurn and (player.getHands.length == 1)\n puts \"'dd'=doubledown 'split'=split 'surr'=surrender 'hit'=hit 'stay'=stay\"\n elsif hand.isFirstTurn and player.canSplit\n \tputs \"dd'=doubledown 'split'=split 'hit'=hit 'stay'=stay\"\n elsif hand.isFirstTurn\n puts \"dd'=doubledown 'hit'=hit 'stay'=stay\"\n else\n puts \"'hit'=hit 'stay'=stay\"\n end\nend", "def initialize(cards)\n\n\n #while start waiting to east to start\n @state = :start\n #hand for each player\n @hands = {} \n @hands[:south] = cards.slice(0,10).sort!\n @hands[:east] = cards.slice(10,10).sort!\n @hands[:west] = cards.slice(20,10).sort!\n \n \n #cards played on table\n @played = {}\n # number of tricks taken by each player\n @taken = {}\n\n #sets taken and played\n @@PLAYERS.each do |player|\n @played[player] = nil\n @taken[player] = Array.new\n end \n # hole cards \n @hole_cards = cards.slice(30,2) \n @on_move = :east \n end", "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 is_straight( hand )\n\tcards = hand.map { | e | card_value( e ) }.sort\n\treturn ( 1..cards.length-1 ).all? { | i | cards[ i ]-1 == cards[ i-1 ] } ?\n\t1 : 0\nend", "def compare_hands\r\n\t\tcase @player.hand.hand_value <=> @dealer.hand.hand_value\r\n\t\t\twhen 1 then puts \"#{@player.name} wins!\"\r\n\t\t\twhen -1 then puts \"#{@dealer.name} wins.\"\r\n\t\t\twhen 0 then puts \"It's a push.\"\r\n\t\tend\r\n\tend", "def canAnswer(playerIndex, guess)\n \n cardFound = nil\n\n for i in 0...@cardsInHand.length\n if( @cardsInHand[i].type() == :person )\n if(guess.person.value == @cardsInHand[i].value())\n cardFound = @cardsInHand[i]\n end\n elsif( @cardsInHand[i].type() == :place )\n if(guess.place.value == @cardsInHand[i].value())\n cardFound = @cardsInHand[i]\n end\n elsif( @cardsInHand[i].type() == :weapon )\n if(guess.weapon.value == @cardsInHand[i].value())\n cardFound = @cardsInHand[i]\n end\n end #if\n end #for\n \n #if(cardFound != nil)\n puts \"Asking player #{@indexOfCurrentPlayer}. \"\n #end\n \n return cardFound\n \n end", "def hit_hand(player, hand)\n card = nil\n if @play_god\n card = @io.set_card(@shoe, player, nil)\n else\n card = @shoe.deal_card\n end\n hand.hit(card)\n end", "def lay_card\n @hand.shift\n end", "def pbHasFatefulSpecies?(species)\n if species.is_a?(String) || species.is_a?(Symbol)\n species = getID(PBSpecies,species)\n end\n for pokemon in $Trainer.pokemonParty\n return true if pokemon.species==species && pokemon.obtainMode==4\n end\n return false\nend", "def computer_index\n if turn_count == 0\n return CORNERS.sample\n elsif turn_count == 2\n return CORNERS.sample\n elsif turn_count == 4\n empty = nil\n WIN_COMBINATIONS.each do |combo|\n if @board[combo[0]] == \"X\" && @board[combo[1]] == \"X\" && (@board[combo[2]] == \" \" || @board[combo[2]] == \"\")\n empty = combo[2]\n return combo[2]\n elsif @board[combo[1]] == \"X\" && @board[combo[2]] == \"X\" && (@board[combo[0]] == \" \" || @board[combo[0]] == \"\")\n empty = combo[0]\n return combo[0]\n elsif @board[combo[0]] == \"X\" && @board[combo[2]] == \"X\" && (@board[combo[1]] == \" \" || @board[combo[1]] == \"\")\n empty = combo[1]\n return combo[1]\n elsif @board[combo[0]] == \"O\" && @board[combo[1]] == \"O\" && (@board[combo[2]] == \" \" || @board[combo[2]] == \"\")\n empty = combo[2]\n return combo[2]\n elsif @board[combo[1]] == \"O\" && @board[combo[2]] == \"O\" && (@board[combo[0]] == \" \" || @board[combo[0]] == \"\")\n empty = combo[0]\n return combo[0]\n elsif @board[combo[0]] == \"O\" && @board[combo[2]] == \"O\" && (@board[combo[1]] == \" \" || @board[combo[1]] == \"\")\n empty = combo[1]\n return combo[1]\n end\n end\n return CORNERS.sample if !empty\n elsif turn_count == 6\n empty = nil\n WIN_COMBINATIONS.each do |combo|\n if @board[combo[0]] == \"X\" && @board[combo[1]] == \"X\" && (@board[combo[2]] == \" \" || @board[combo[2]] == \"\")\n empty = combo[2]\n return combo[2]\n elsif @board[combo[1]] == \"X\" && @board[combo[2]] == \"X\" && (@board[combo[0]] == \" \" || @board[combo[0]] == \"\")\n empty = combo[0]\n return combo[0]\n elsif @board[combo[0]] == \"X\" && @board[combo[2]] == \"X\" && (@board[combo[1]] == \" \" || @board[combo[1]] == \"\")\n empty = combo[1]\n return combo[1]\n end\n end\n WIN_COMBINATIONS.each do |combo|\n if @board[combo[0]] == \"O\" && @board[combo[1]] == \"O\" && (@board[combo[2]] == \" \" || @board[combo[2]] == \"\")\n empty = combo[2]\n return combo[2]\n elsif @board[combo[1]] == \"O\" && @board[combo[2]] == \"O\" && (@board[combo[0]] == \" \" || @board[combo[0]] == \"\")\n empty = combo[0]\n return combo[0]\n elsif @board[combo[0]] == \"O\" && @board[combo[2]] == \"O\" && (@board[combo[1]] == \" \" || @board[combo[1]] == \"\")\n empty = combo[1]\n return combo[1]\n end\n end\n return CORNERS.sample if !empty\n else\n @board.each do |space|\n if space == \" \" || space == \"\"\n return @board.index(space)\n end\n end\n end\n end", "def hand_of_poker\n players_in_hand = @players.dup\n @players.each {|player| deal(player, 5)}\n remaining_players = betting_round(players_in_hand)\n unless remaining_players.count == 1\n exchange_cards\n remaining_players = betting_round(remaining_players)\n unless remaining_players.count == 1\n remaining_players = compare_hands(remaining_players)\n end\n end\n winner = remaining_players.first\n puts \"#{winner.name} wins!\"\n print \"\\n\\n\\n\"\n pay_out(winner)\n reset_deck\n end", "def hand_length\n return @cards_in_hand.length\n end", "def is_three_of_a_kind( hand )\n\tkind = check_kind( 3, hand )\n\treturn 0 != kind.length ? kind : [ 0 ]\nend", "def hand_rank(hand)\n ranks = card_ranks(hand) # card_ranks return the ranks in sorted order\n\n if straight(ranks) && flush(hand)\n return [8, ranks.max] # 2 3 4 5 6 => [8, 6], 6 7 8 9 T => [8, T]\n elsif kind(4, ranks)\n return [7, kind(4, ranks), kind(1, ranks)] # 9 9 9 9 3 => [7, 9, 3]\n elsif kind(3, ranks) && kind(2, ranks) # 8 8 8 K K => [6, 8, 13]\n return [6, kind(3, ranks), kind(2, ranks)]\n elsif flush(hand)\n return [5, ranks]\n elsif straight(ranks)\n return [4, ranks.max]\n elsif kind(3, ranks)\n return [3, kind(3, ranks), ranks]\n elsif two_pair(ranks)\n return [2, kind(2, ranks), ranks]\n elsif kind(2, ranks)\n return [1, kind(2, ranks), ranks]\n else\n return [0, ranks]\n end\nend", "def winner\n if finished?\n if fold = @hand_history.all_actions.find(&:fold?)\n winner = (fold.player == small_blind) ? big_blind : small_blind\n else\n winner = if PokerHand.new( small_blind.hole_cards + @community_cards ) > PokerHand.new( big_blind.hole_cards + @community_cards )\n small_blind\n else\n big_blind\n end\n end\n else\n nil\n end\n end" ]
[ "0.72336465", "0.7123592", "0.7041259", "0.70120835", "0.6972605", "0.6804357", "0.677349", "0.6752963", "0.6719292", "0.6710728", "0.659526", "0.6583047", "0.65560097", "0.64660335", "0.6446914", "0.636851", "0.63634807", "0.63504654", "0.6314673", "0.6272187", "0.6265082", "0.62442786", "0.62002534", "0.6190299", "0.6170737", "0.6170737", "0.61578935", "0.6155747", "0.6141715", "0.6133783", "0.6116617", "0.611476", "0.6105484", "0.6096973", "0.60898554", "0.60858274", "0.6073398", "0.60519195", "0.6049677", "0.6047897", "0.6032485", "0.6026424", "0.6025963", "0.6006267", "0.59921134", "0.5979528", "0.59782904", "0.5975144", "0.5973347", "0.5960894", "0.5938897", "0.59359145", "0.59021735", "0.5892708", "0.5891307", "0.58874303", "0.58809084", "0.58788043", "0.5866775", "0.5856619", "0.58548176", "0.5844341", "0.58273995", "0.5815178", "0.58123887", "0.58058363", "0.58052737", "0.579834", "0.57933086", "0.5790246", "0.57729656", "0.57728064", "0.57675004", "0.5766319", "0.5765955", "0.57635725", "0.57607746", "0.5759782", "0.5759335", "0.57377505", "0.5731176", "0.5729814", "0.5712273", "0.57083863", "0.5703155", "0.5702001", "0.57016736", "0.57012296", "0.5698868", "0.56921196", "0.56823564", "0.56759495", "0.5663631", "0.56526965", "0.56444705", "0.56362987", "0.5631118", "0.5622676", "0.56191653", "0.5617748", "0.5616236" ]
0.0
-1
gets best hand with given type
def get_high_cards(cards) @cards_by_score.each_key do |card| if cards.length < 5 && !cards.include?(card) cards << card end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def best_hand\n case\n when hand?\n return @cards\n when pair? && !hand?\n get_pairs\n when two_pair? && !hand?\n get_pairs\n when three_of_a_kind? && !full_house? && !hand?\n get_three_of_a_kind\n when straight? && !straight_flush? && !hand?\n get_straight\n when flush? && !straight_flush? && !hand?\n get_flush\n when full_house? && !hand?\n get_full_house\n when four_of_a_kind? && !hand?\n get_four_of_a_kind\n when straight_flush? && !hand?\n get_straight_flush\n else\n get_high_card\n end\n end", "def hand\n return @hands[0] if self.has_a_hand\n return nil\n end", "def hand\n hands.first\n end", "def best_hand\n raise\n end", "def best type = :rmse\r\n\t\tsafeSort(type).first\r\n\tend", "def find_hand_category(hand)\r\n \t\tif hand.size == 7\r\n \t\t\t# really not good!! have to put royal flush, straight flush\r\n \t\t\t# and straigh together! \r\n \t\t\tif num_suits(hand).max >= 5 && num_faces(hand)[0..4] == Array.new(5,1) \r\n \t\t\t\t@hand_category = \"Royal Flush\"\r\n \t\t\telsif num_faces(hand).max >= 4\r\n \t\t\t\t@hand_category = \"Four of a kind\"\r\n \t\t\telsif num_faces(hand).max == 3\r\n \t\t\t\t@hand_category = \"Three of a kind\"\r\n \t\t\telsif num_faces(hand).max == 2\r\n \t\t\t\t@hand_category = \"pair\"\r\n \t\t\telsif num_faces(hand).sort.last>=3 && num_faces(hand).sort[12]>=2\r\n \t\t\t\t@hand_category = \"Full House\"\r\n \t\t\telsif num_faces(hand).sort.last == 2 && num_faces(hand).sort[12]==2\r\n \t\t\t\t@hand_category = \"two pairs\"\r\n \t\t\tend \r\n \t\tend\r\n \t\treturn @hand_category\r\n \tend", "def checkHand\n possible_hands = possibleHandValues\n if possible_hands.include?(21)\n return BLACKJACK\n elsif possible_hands.empty?\n return LOST\n else\n return possible_hands.max\n end\n end", "def human_type\n SHIPPING_TYPES[self[:type].to_i]\n end", "def priority_hand\n hands.fetch(priority)\n end", "def getHand()\n return @hand\n end", "def by_t(type)\n return self.find_all{|slot| slot.type == type}[0]\n end", "def pick(player)\n case @hand_pick_mode\n when :attached\n raise \"HandPicker couldn't find a hand to pick on the given player.\" unless player[:hand]\n player[:hand]\n when :random\n HANDS.sample(1)[0]\n end\n end", "def type\n\n if @player_1.deck.cards[0].rank != @player_2.deck.cards[0].rank\n return :basic\n elsif @player_1.deck.cards[2].rank == @player_2.deck.cards[2].rank\n return :mutually_assured_destruction\n else\n return :war\n end\n end", "def get_hearing_type hearing_type\n result = Hash.new(\"\")\n result['1'] = \"Central Office\"\n result['2'] = \"Travel Board\"\n result['6'] = \"Video\"\n\n result[hearing_type]\n end", "def choose_wild_pokemon(enc_type, chance_rolls = 1)\r\n if !enc_type || !GameData::EncounterType.exists?(enc_type)\r\n raise ArgumentError.new(_INTL(\"Encounter type {1} does not exist\", enc_type))\r\n end\r\n enc_list = @encounter_tables[enc_type]\r\n return nil if !enc_list || enc_list.length == 0\r\n # Static/Magnet Pull prefer wild encounters of certain types, if possible.\r\n # If they activate, they remove all Pokémon from the encounter table that do\r\n # not have the type they favor. If none have that type, nothing is changed.\r\n first_pkmn = $Trainer.first_pokemon\r\n if first_pkmn && rand(100) < 50\r\n favored_type = nil\r\n case first_pkmn.ability_id\r\n when :STATIC\r\n favored_type = :ELECTRIC if GameData::Type.exists?(:ELECTRIC)\r\n when :MAGNETPULL\r\n favored_type = :STEEL if GameData::Type.exists?(:STEEL)\r\n when :FLASHFIRE\r\n favored_type = :FIRE if GameData::Type.exists?(:FIRE)\r\n when :HARVEST\r\n favored_type = :GRASS if GameData::Type.exists?(:GRASS)\r\n when :LIGHTNINGROD\r\n favored_type = :ELECTRIC if GameData::Type.exists?(:ELECTRIC)\r\n when :STORMDRAIN\r\n favored_type = :WATER if GameData::Type.exists?(:WATER)\r\n end\r\n if favored_type\r\n new_enc_list = []\r\n enc_list.each do |enc|\r\n species_data = GameData::Species.get(enc[1])\r\n t1 = species_data.type1\r\n t2 = species_data.type2\r\n new_enc_list.push(enc) if t1 == favored_type || t2 == favored_type\r\n end\r\n enc_list = new_enc_list if new_enc_list.length > 0\r\n end\r\n end\r\n enc_list.sort! { |a, b| b[0] <=> a[0] } # Highest probability first\r\n # Calculate the total probability value\r\n chance_total = 0\r\n enc_list.each { |a| chance_total += a[0] }\r\n # Choose a random entry in the encounter table based on entry probabilities\r\n rnd = 0\r\n chance_rolls.times do\r\n r = rand(chance_total)\r\n rnd = r if r > rnd # Prefer rarer entries if rolling repeatedly\r\n end\r\n encounter = nil\r\n enc_list.each do |enc|\r\n rnd -= enc[0]\r\n next if rnd >= 0\r\n encounter = enc\r\n break\r\n end\r\n # Get the chosen species and level\r\n level = rand(encounter[2]..encounter[3])\r\n # Some abilities alter the level of the wild Pokémon\r\n if first_pkmn\r\n case first_pkmn.ability_id\r\n when :HUSTLE, :PRESSURE, :VITALSPIRIT\r\n level = encounter[3] if rand(100) < 50 # Highest possible level\r\n end\r\n end\r\n # Black Flute and White Flute alter the level of the wild Pokémon\r\n if Settings::FLUTES_CHANGE_WILD_ENCOUNTER_LEVELS\r\n if $PokemonMap.blackFluteUsed\r\n level = [level + rand(1..4), GameData::GrowthRate.max_level].min\r\n elsif $PokemonMap.whiteFluteUsed\r\n level = [level - rand(1..4), 1].max\r\n end\r\n end\r\n # Return [species, level]\r\n return [encounter[1], level]\r\n end", "def of_type(type)\r\n @pitches.select{|pitch| pitch.pitch_type == type}\r\n end", "def result(hand)\n v = value(hand)\n case v\n when 21 then hand.size == 2 && :natural || 21\n when 17..20 then v\n when 0..16 then raise \"error, illegal resulting hand value\"\n else :bust\n end\nend", "def weams_type\n { \n 'ojt' => ojt?, 'correspondence' => correspondence?, 'flight' => flight?,\n 'foreign' => foreign?, 'public' => public?, 'for profit' => for_profit?,\n 'private' => private?\n }.find { |key, value| value }[0]\n end", "def main_hand\n if has_hands\n return @hands[0]\n else\n return false\n end\n end", "def is_handset? type\n Handset.is_handset? request.user_agent, type\n end", "def pbRoughType(move,user,skill)\r\n ret = move.type\r\n if skill>=PBTrainerAI.highSkill\r\n ret = move.pbCalcType(user)\r\n end\r\n return ret\r\n end", "def currentHand #finds current hand during game\n self.hands.last\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 getResult\n \t@hands[0].checkHand\n end", "def get_game_type\n if :survivor.to_s == self.game_type\n return :survivor\n elsif :anti_survivor.to_s == self.game_type\n return :anti_survivor\n elsif :high_roller.to_s == self.game_type\n return :high_roller\n else\n return nil\n end\n end", "def poker hands\n raise NoHandError if hands.empty?\n allmax(hands, method(:hand_rank))\nend", "def worst type = :rmse\r\n\t\tsafeSort(type).last\r\n\tend", "def bike_type(type)\n if type == 1\n @discipline = \"mountain\"\n @frame = \"mountain\"\n elsif type == 2\n @discipline = \"road\"\n @frame = \"road\"\n else\n @discipline = \"cyclo-cross\"\n @frame = \"cyclo-cross\"\n end\n @discipline\n @frame\n end", "def choose\n case type\n when \"random\"\n move_pool.sample\n when \"unyielding\"\n move_pool[0]\n when \"hustler\"\n num = rand(0..99)\n num < 66 ? move_pool[0] : move_pool[1]\n when \"sore_loser\"\n # For the first move, select randomly\n if move_pool.length < 2\n mv = Move::VALUES.sample\n return Move.new(mv)\n end\n # For all other moves, use the human player's previous move choice\n move_pool[-2]\n else # It's a cheater personality\n # The cheater looks into the human's current choice\n # and create a move that beat human's choice\n mv = Move::WINNING_CHOICES[move_pool[-1].value].sample\n Move.new(mv)\n end\n end", "def four_of_a_kind(hand)\n\t\thand_num = check_num(hand)\n\t\ti = 0\n\t\twhile i < hand_num.size\n\t\t\tif hand_num.count(hand_num[i]) == 4\n\t\t\t\treturn 7\n\t\t\tend\n\t\t\ti += 1\n\t\tend\n\t\treturn 0\n\tend", "def three_of_a_kind(hand)\n\t\thand_num = check_num(hand)\n\t\ti = 0\n\t\twhile i < hand_num.size\n\t\t\tif hand_num.count(hand_num[i]) == 3\n\t\t\t\treturn 3\n\t\t\tend\n\t\t\ti += 1\n\t\tend\n\t\treturn 0\n\tend", "def deck_weak_against(type)\n load_decks_data['weak_against'][load_decks_data['overlord_types'][type]]\n end", "def find_pickaxe\r\n weapon = mob.get_equipment.get Equipment::WEAPON\r\n if !weapon.nil?\r\n PICKAXES.each do |name, pickaxe|\r\n return pickaxe if (weapon.id == pickaxe.item_id && get_mining_lvl >= pickaxe.lvl_req)\r\n end\r\n end\r\n best_pickaxe = nil\r\n PICKAXES.each do |name, pickaxe|\r\n next if(!best_pickaxe.nil? && pickaxe.speed < best_pickaxe.speed)\r\n (best_pickaxe = pickaxe) if (mob.get_inventory.slot_of(pickaxe.item_id) > -1 && get_mining_lvl >= pickaxe.lvl_req)\r\n end\r\n best_pickaxe\r\n end", "def type\n types.first\n end", "def my_type(type)\n case type\n when /bond/i\n \"Bonds\"\n when /stock/i\n \"Stocks\"\n when /alternative/i\n \"Alternatives\"\n else\n \"Unclassified\"\n end\n end", "def lf_type(type)\n type = type.downcase.gsub(' ', '_').intern if type.class == String\n\n case type\n when :normal\n retval = self.lf\n when :rot\n retval = self.lf\n when :best_in_slot\n retval = self.bislf\n when :bis\n retval = self.bislf\n when :situational\n retval = self.sitlf\n when :sit\n retval = self.sitlf\n end\n end", "def get_wielded(hand = nil)\n if hand\n case hand\n when \"left\"\n hand = :left_wield\n when \"right\"\n hand = :right_wield\n when \"dual\"\n hand = :dual_wield\n else\n return get_wielded\n end\n\n item = ((@equipment[hand] && @equipment[hand][0]))\n else\n item = ((@equipment[:left_wield] and @equipment[:left_wield][0]) || (@equipment[:right_wield] and @equipment[:right_wield][0]) || (@equipment[:dual_wield] and @equipment[:dual_wield][0]))\n end\n\n if item\n @inventory[item]\n else\n nil\n end\n end", "def decide(hand)\n value(hand) >= 17 && :stand || :hit\nend", "def type\n if rank_test(0) && rank_test(2)\n :mutually_assured_destruction\n elsif rank_test(0)\n :war\n else\n :basic\n end\n end", "def type\n return :basic if @is_basic\n return :platinum if @is_platinum\n return :centurion if @is_centurion\n return :premium if @is_premium\n :unknown\n end", "def type\n types.first\n end", "def high_card(hand)\n\t\thand_num = check_num(hand)\n\t\treturn hand_num.max\n\tend", "def start_hand\n @hands[0] = DealerHand.new\n @hands[0].hit_soft_17 = @hit_soft_17\n return @hands[0]\n end", "def chose_weapon\n if @class == 'Water'\n chosen_weapon = Weapon.new \n return chosen_weapon.water_weapons\n end\n end", "def get_hand\n return @cards_in_hand\n end", "def get_handset(id)\n return @handsets[id]\n end", "def find_max_type(rank, type, tabs, mappack = nil, board = 'hs')\n # Filter scores by type and tabs\n if !mappack.nil?\n type = \"Mappack#{type.to_s}\".constantize unless type.to_s[0..6] == 'Mappack'\n query = type.where(mappack: mappack)\n else\n query = type\n end\n query = query.where(tab: tabs) if !tabs.empty?\n\n # Distinguish ranking type\n case rank\n when :points\n query.count * 20\n when :avg_points\n 20\n when :avg_rank\n 0\n when :maxable\n Highscoreable.ties(type, tabs, nil, false, true).size\n when :maxed\n Highscoreable.ties(type, tabs, nil, true, true).size\n when :clean\n 0.0\n when :score\n klass = mappack.nil? ? Score : MappackScore.where(mappack: mappack)\n rfield = mappack.nil? ? :rank : \"rank_#{board}\".to_sym\n sfield = mappack.nil? ? :score : \"score_#{board}\".to_sym\n scale = !mappack.nil? && board == 'hs' ? 60.0 : 1.0\n query = klass.where(highscoreable_type: type.to_s, rfield => 0)\n query = query.where(tab: tabs) if !tabs.empty?\n query = query.sum(sfield) / scale\n !mappack.nil? && board == 'sr' ? query.to_i : query.to_f\n else\n query.count\n end\nend", "def most_specific_type(from_magic_type, fallback_type); end", "def most_specific_type(from_magic_type, fallback_type); end", "def get_type(type)\n TYPES[type.downcase]\n end", "def get_type\n case self[:type]\n when /pe/\n :pe\n else\n :foss\n end\n end", "def type\n\n if (@player1.deck.cards.count < 3 || @player2.deck.cards.count < 3)\n if @player1.deck.cards.count < 3\n @player1.has_lost?(true)\n else\n @player2.has_lost?(true)\n end\n else\n if @player1.deck.cards[0].rank != @player2.deck.cards[0].rank\n :basic\n elsif\n (@player1.deck.cards[0].rank == @player2.deck.cards[0].rank) &&\n (@player1.deck.cards[2].rank == @player2.deck.cards[2].rank)\n :mutually_assured_destruction\n else\n :war\n end\n end\n end", "def get_type_in_french\n type = ''\n if !self.achievement_type.nil?\n if self.achievement_type.downcase == 'weight'\n type = 'Poids'\n elsif self.achievement_type.downcase == 'time'\n type = 'Temps'\n elsif self.achievement_type.downcase == 'kilometer'\n type = 'Kilomètre'\n end\n else\n type = 'kilometer'\n end\n\n type\n end", "def highest_non_bust_hand_value\n hands.select {|hand| !hand.bust? }.map {|hand| hand.value }.max\n end", "def kind\n # returns nil, overridden and returning :question, :problem, etc. in sublcass\n end", "def computer_ai_3\n rock = 0\n paper = 0\n scissors = 0\n most_played = \"r\"\n choice = \"p\"\n\n # Find which moves have been played the most.\n \n @human_moves.each do |move|\n if move == 'r'\n rock = rock + 1\n elsif move == 'p'\n paper = paper + 1\n elsif move == 's'\n scissors = scissors + 1\n end\n end\n\n if rock > paper && rock > scissors\n most_played = \"r\"\n elsif paper > rock && paper > scissors\n most_played = \"p\"\n elsif scissors > paper && scissors > rock \n most_played = \"s\"\n else\n #choose random if they tie\n choices =['r', 'p', 's']\n most_played = choices.sample\n end\n\n #play the hand that beats the human move.\n if most_played == 'r'\n choice = 'p'\n elsif most_played == 'p'\n choice = 's'\n elsif most_played == 's'\n choice = 'r'\n end\n\n return choice\n end", "def find_model(type)\n if type == \"liti_types\"\n modeltype = TypesLiti\n elsif type == \"nonliti_types\"\n modeltype = TypesNonLiti\n elsif type == \"activity_types\"\n modeltype = Physical::Timeandexpenses::ActivityType\n elsif type == \"expense_types\"\n modeltype = Physical::Timeandexpenses::ExpenseType\n else\n modeltype = type.singularize.camelize.constantize\n end\n return modeltype\n end", "def hand_rank(hand)\n ranks = card_ranks(hand) # card_ranks return the ranks in sorted order\n\n if straight(ranks) && flush(hand)\n return [8, ranks.max] # 2 3 4 5 6 => [8, 6], 6 7 8 9 T => [8, T]\n elsif kind(4, ranks)\n return [7, kind(4, ranks), kind(1, ranks)] # 9 9 9 9 3 => [7, 9, 3]\n elsif kind(3, ranks) && kind(2, ranks) # 8 8 8 K K => [6, 8, 13]\n return [6, kind(3, ranks), kind(2, ranks)]\n elsif flush(hand)\n return [5, ranks]\n elsif straight(ranks)\n return [4, ranks.max]\n elsif kind(3, ranks)\n return [3, kind(3, ranks), ranks]\n elsif two_pair(ranks)\n return [2, kind(2, ranks), ranks]\n elsif kind(2, ranks)\n return [1, kind(2, ranks), ranks]\n else\n return [0, ranks]\n end\nend", "def deck_faction(type)\n load_decks_data['overlord_types'][type]\n end", "def type\n rank.first\n end", "def winner(returned_type)\n if returned_type == :basic\n if @player1.deck.cards[0].rank > @player2.deck.cards[0].rank\n @player1\n else\n @player2\n end\n elsif returned_type == :war\n if @player1.deck.cards[2].rank > @player2.deck.cards[2].rank\n @player1\n else\n @player2\n end\n else\n \"No Winner\"\n end\n end", "def add_hand(hand)\n @hands << hand\n return @hands[-1]\n end", "def best_candidate\n self.by_quality.first\n end", "def <=> hand2\n ranks = ['royal_flush?', 'straight_flush?', 'four_of_a_kind?', 'full_house?', 'flush?', 'straight?', 'three_of_a_kind?', 'two_pair?', 'one_pair?']\n ranks.each do |rank|\n if send(rank)\n if hand2.send(rank)\n return tie_breaker_single hand2 if rank.include?('flush') || rank.include?('straight')\n return tie_breaker_multi hand2\n end\n return 1\n end\n return -1 if hand2.send(rank)\n end\n tie_breaker_single hand2\n end", "def by_suit\n PokerHand.new(@hand.sort_by { |c| [c.suit, c.face] }.reverse)\n end", "def get_shower_type\n self.shower_type ? self.shower_type.i18n_description : '?'\n end", "def is_high_card( hand )\n\treturn hand.map { | e | card_value( e ) }.max\nend", "def type\n fetch('computer.type')\n end", "def get_object_code_of_type(type)\n case type\n when 'Operating Expense'\n get_kuali_business_object('KFS-COA', 'ObjectCode', \"universityFiscalYear=#{get_aft_parameter_value(ParameterConstants::CURRENT_FISCAL_YEAR)}&financialObjectSubTypeCode=OE&financialObjectTypeCode=EX&financialObjectLevelCode=SMAT&chartOfAccountsCode=#{get_aft_parameter_value(ParameterConstants::DEFAULT_CHART_CODE)}\")['financialObjectCode'][0]\n when 'Capital Asset'\n fetch_random_capital_asset_object_code\n when 'Accounts Receivable Asset'\n get_kuali_business_object('KFS-COA', 'ObjectCode', \"universityFiscalYear=#{get_aft_parameter_value(ParameterConstants::CURRENT_FISCAL_YEAR)}&financialObjectTypeCode=AS&financialObjectLevelCode=AROT&chartOfAccountsCode=#{get_aft_parameter_value(ParameterConstants::DEFAULT_CHART_CODE)}\")['financialObjectCode'][0]\n when 'Income-Cash'\n get_kuali_business_object('KFS-COA', 'ObjectCode', \"universityFiscalYear=#{get_aft_parameter_value(ParameterConstants::CURRENT_FISCAL_YEAR)}&financialObjectSubTypeCode=ID&financialObjectTypeCode=IN&financialObjectLevelCode=IDRV&chartOfAccountsCode=#{get_aft_parameter_value(ParameterConstants::DEFAULT_CHART_CODE)}\")['financialObjectCode'][0]\n else\n nil\n end\n rescue RuntimeError => re\n nil\n end", "def type\n read_attribute(:type) || Figaro.env.meal_types.split.first\n end", "def test_straight_flush_high_card\n p = Hand.new(SF)\n assert p.find_hand_rank == [\"Straight Flush\", \"High Card : 10C\"]\n end", "def hand_rating\n OPS.map { |op|\n (method(op[1]).call()) ? op[0] : false\n }.find { |v| v }\n end", "def get_random_type(entropy = 0)\n entropy ||= 21\n dice = rand(0..100)\n\n return 2 if dice < entropy / 3\n\n return 3 if dice < entropy / 3 * 2\n\n return 4 if dice < entropy\n\n 1\n end", "def get_type\n\n end", "def find_by_type(medium, *args)\n path = \"medium/#{medium}\"\n Rdigg.fetch(path, @@type, args)\n end", "def get_by_type(type)\r\n facts2typerule = {:methodcall => [:cant_access, :can_access],\r\n :inheritance => [:cant_extend, :can_extend],\r\n :objcreation => [:cant_create, :can_create]}\r\n\r\n find_all { |x| facts2typerule[type].index(x.type_interaction) != nil }\r\n end", "def by_face\n PokerHand.new(@hand.sort_by { |c| [c.face, c.suit] }.reverse)\n end", "def is_three_of_a_kind( hand )\n\tkind = check_kind( 3, hand )\n\treturn 0 != kind.length ? kind : [ 0 ]\nend", "def human_type\n Core::TYPES_DESC[type]\n end", "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 unit_type\n return Game_Actor if battler.is_a?(Game_Actor)\n return Game_Enemy if battler.is_a?(Game_Enemy)\n return nil\n end", "def hand_value cards\n values = cards.map{|c| $value_map[c[0]]}\n suits = cards.map{|c| c[1]}\n is_flush = false\n # check for flush\n if suits.uniq.size == 1\n is_flush = true\n end\n # check for straight\n is_straight = true\n sorted_values = values.sort\n for v in 0..(values.size-2)\n unless sorted_values[v]+1 == sorted_values[v+1]\n is_straight = false\n break\n end\n end\n if is_straight\n if is_flush\n # royal flush\n return {rank: 9, secondary: 10} if sorted_values[0] == 10\n # straight flush\n return {rank: 8, secondary: sorted_values[0]}\n end\n end\n # check for four of a kind\n if sorted_values[0] == sorted_values[3] || sorted_values[1] == sorted_values[4]\n return {rank: 7, secondary: sorted_values[1]}\n end\n # check for three of a kind or full house\n if sorted_values[0] == sorted_values[2]\n return {rank: 6, secondary: sorted_values[0]} if sorted_values[3] == sorted_values[4]\n return {rank: 3, secondary: sorted_values[0]}\n end\n if sorted_values[2] == sorted_values[4]\n return {rank: 6, secondary: sorted_values[2]} if sorted_values[0] == sorted_values[1]\n return {rank: 3, secondary: sorted_values[2]}\n end\n # check for three of a kind (case where full house is not possible)\n if sorted_values[1] == sorted_values[3]\n return {rank: 3, secondary: sorted_values[1]}\n end\n # return for flush (fine since three of a kind/full house and flush are mutually exclusive)\n return {rank: 5, secondary: sorted_values.last} if is_flush\n # return for straight (fine since three of a kind/full house and straight are mutually exclusive)\n return {rank: 4, secondary: sorted_values[0]} if is_straight\n # check for two pairs\n if sorted_values[0] == sorted_values[1] && sorted_values[2] == sorted_values[3]\n return {rank: 2, secondary: (sorted_values[0] > sorted_values[2] ? sorted_values[0] : sorted_values[2])}\n end\n if sorted_values[0] == sorted_values[1] && sorted_values[3] == sorted_values[4] \n return {rank: 2, secondary: (sorted_values[0] > sorted_values[3] ? sorted_values[0] : sorted_values[3])}\n end\n if sorted_values[1] == sorted_values[2] && sorted_values[3] == sorted_values[4] \n return {rank: 2, secondary: (sorted_values[1] > sorted_values[3] ? sorted_values[1] : sorted_values[3])}\n end\n # check for pairs\n return {rank: 1, secondary: sorted_values[0]} if sorted_values[0] == sorted_values[1]\n return {rank: 1, secondary: sorted_values[1]} if sorted_values[1] == sorted_values[2]\n return {rank: 1, secondary: sorted_values[2]} if sorted_values[2] == sorted_values[3]\n return {rank: 1, secondary: sorted_values[3]} if sorted_values[3] == sorted_values[4]\n # otherwise high card\n return {rank: 0, secondary: sorted_values.last}\nend", "def action(type, amount, player)\n @player = Player.find(player.to_i)\n amount = amount.to_i\n case type\n when 'fold'\n @player.in_hand = false\n when 'bet'\n if amount > @player.money\n amount = @player.money\n end\n if amount + @player.in_pot_current < self.high_bet\n p 'invalid bet'\n else\n put_money(amount, @player)\n end\n when 'raise'\n # If player doesn't have enough money or trying to not raise enough and can't bet enough\n if amount > @player.money || (amount + @player.in_pot_current < 2*self.high_bet && 2*self.high_bet - @player.in_pot_current > @player.money)\n amount = @player.money\n elsif amount + @player.in_pot_current < self.high_bet\n amount = 2*self.high_bet - @player.in_pot_current\n else\n amount = amount + self.high_bet - @player.in_pot_current\n end\n put_money(amount, @player)\n when 'check'\n # do nothing; high better already set to be player after dealer inside of deal()\n when 'call'\n amount = self.high_bet - @player.in_pot_current\n put_money(amount, @player)\n else\n p 'invalid action'\n end\n self.current_player = self.get_next_player(@player.location) # Set next player to current\n\n @player.save\n self.save\n if self.high_better == self.current_player #progress round if you've gone back around to the high better\n # unless no one raises and it's back to big blind, bb should be able to go\n if self.high_bet <= self.big_blind && self.round == 0 && self.high_better == get_next_player(get_next_player(self.dealer))\n self.high_better = get_next_player(get_next_player(get_next_player(self.dealer)))\n else\n set_round((self.round + 1))\n deal(self.round)\n end\n end\n if self.players.where(:in_hand => true).length <= 1\n set_round(4)\n end\n\n @player.save\n self.save\n end", "def type\n return @type if @type != \"unknown\"\n info\n @type\n end", "def update_round(type,dealer,winner,loser,hand)\n # Verify inputs\n if (dealer == nil)\n puts \"Error: Missing dealer's name\"\n return false\n end\n if (hand.empty? || hand.first.empty?) && (type==T_TSUMO || type==T_RON)\n puts \"Error: Missing hand value\"\n return false\n end\n\n dealer_flag = winner.include?(dealer)\n\n # Handle each round type\n case type\n\n when T_TSUMO\n # Tsumo type: loser = everyone else\n losers = @scores.keys\n losers -= winner\n return false if not self.award_bonus(winner.first,losers,dealer_flag)\n if dealer_flag then @bonus += 1 else self.next_round end\n score_h = Scoring.get_tsumo(dealer_flag, hand.first)\n winner.each do |w|\n @scores[w] += if dealer_flag then score_h[\"nondealer\"]*(@mode-1)\n else (score_h[\"dealer\"]+score_h[\"nondealer\"]*(@mode-2)) end\n end\n losers.each do |l|\n @scores[l] -= score_h[l==dealer ? \"dealer\" : \"nondealer\"]\n end\n\n when T_RON\n # Ron type - can have multiple winners off of same loser\n return false if not self.award_bonus(winner.first,loser,dealer_flag)\n if dealer_flag then @bonus += 1 else self.next_round end\n winner.zip(hand).each do |w,h|\n paym = Scoring.get_ron((w==dealer),h)\n @scores[w] += paym\n @scores[loser.first] -= paym\n end\n\n when T_TENPAI\n # Tenpai type: losers = all - winners\n losers = @scores.keys\n losers -= winner\n if dealer_flag then @bonus += 1 else self.next_round end\n if winner.length < @mode\n total = @mode==4 ? Scoring::P_TENPAI_4 : Scoring::P_TENPAI_3\n paym = total / losers.length\n recv = total / winner.length\n winner.each do |w|\n @scores[w] += recv\n end\n losers.each do |l|\n @scores[l] -= paym\n end\n end\n\n when T_NOTEN\n # Noten type: ignore all other params\n self.next_round\n\n when T_CHOMBO\n # Chombo type: loser = chombo player, winner = everyone else\n winners = @scores.keys\n winners -= loser\n dealer_flag = loser.include?(dealer)\n score_h = Scoring.get_chombo(dealer_flag)\n @scores[loser.first] -= if dealer_flag then score_h[\"nondealer\"]*(@mode-1)\n else (score_h[\"dealer\"] + score_h[\"nondealer\"]*(@mode-2)) end\n winners.each do |w|\n @scores[w] += score_h[w==dealer ? \"dealer\" : \"nondealer\"]\n end\n\n when T_RESET\n # Round reset: add bonus stick\n @bonus += 1\n\n else\n printf \"Invalid round result type\\n\", type\n puts nil\n return false\n end\n\n return true\n end", "def piece_type_at(square)\n pieces[square]\n end", "def find_king(color)\n pieces.where(type: 'King', color: color).last\n end", "def full_house(hand)\n\t\tif (pair(hand) > 0 and three_of_a_kind(hand) > 0)\n\t\t\treturn 6\n\t\tend\n\t\treturn 0\n\tend", "def hand_score(hand)\n\nend", "def deck_strong_against(type)\n load_decks_data['strong_against'][load_decks_data['overlord_types'][type]]\n end", "def analyze_hand\n pairs = 0\n straight = 0\n flush = 0\n\n # for now be conservative\n @play = 3\n\n # check for pairs\n\n\n # check for flush\n\n # check for straight\n\n\n\n # check for special hands\n #full house\n #royal flush\n #straight flush\n \n end", "def take_turn( player, hand )\n turn = nil\n case turn = player.take_turn(hand, @dealer.up_card)\n when :hit:\n hand.hit(@deck.take_card)\n\n when :double_down:\n if hand.double_down_allowed?\n hand.double_down(@deck.take_card)\n else\n raise 'Cannot double down!'\n end\n\n when :split:\n if hand.split_allowed?\n hands = hand.split\n\n 2.times do |i|\n hands[i] << @deck.take_card\n player.hands << hands[i]\n end\n else\n raise 'Cannot split!'\n end\n\n when :stand:\n hand.stand # Ha... Kinda funny how that worked out.\n end\n\n turn\n end", "def kind\n type.to_s.underscore[5..-1]\n end", "def expected_hand(player, turn)\n my_player = @playerstates.detect{|playerstate| playerstate.name == player.player_name}\n expected_hand = my_player.hand.hand_to_list\n cardsfrom = turn.turn_end\n if cardsfrom.from_deck?\n new_cards = [turn.deck.take]\n elsif cardsfrom.from_stack?\n new_cards = turn.stack.take(cardsfrom.how_many_cards?)\n end\n expected_hand = expected_hand + new_cards\n end", "def default_game_type\n GameType.game_types.first\n end", "def tie_breaker_cards\n matched = self.matched_cards\n sorted = @cards.sort.reverse\n # sorted so the card with highest value is first \n if five_of_a_kind? \n # All cards break the tie\n return sorted \n elsif flush?\n # All cards break the tie\n return sorted \n elsif four_of_a_kind?\n four = matched.find{ |rank, cards| cards.size == 4}\n # quads break the tie first, then the other card \n return four + [(sorted - four).first] \n elsif full_house?\n three = matched.find{ |rank, cards| cards.size == 3}\n two = matched.find{ |rank, cards| cards.size == 2}\n return three + two\n elsif straight?\n # Special case for ace, 2, 3, 4 ,5 straight, which sorts as\n # 2,3,4,5,A \n if sorted.first.rank == Rank::Ace && sorted.last.rank == Rank::Two \n ace = sorted.pop \n sorted.unshift(ace) # put ace at the back\n return [ sorted.first ] # should be the 5 now \n else\n return [ sorted.first ] \n end\n elsif three_of_a_kind?\n three = matched.find{ |rank, cards| cards.size == 3} \n return three + (sorted - three).first(2)\n elsif two_pair?\n pairs = [] \n matched.each{ |rank, cards| pairs << cards if cards.size == 2 } \n two_pair = pairs[0] + pairs[1]\n two_pair + [(sorted - two_pair).first]\n elsif pair?\n two = matched.find{ |rank, cards| cards.size == 2} \n two + (sorted - two).first(3)\n else\n sorted.first(5)\n end\n end", "def negotiate_best_deal?\n nil\n end", "def retrieve_entry_time_by_type(entry_time_type_code, meeting, event_type, pool_type)\n best_mir = nil\n\n case entry_time_type_code\n when 'U' # Last swam\n best_mir = get_last_mir_for_event(event_type, pool_type)\n when 'G' # Goggle Cup or last swam\n best_mir = nil # TODO: - Use Google cup standard\n best_mir ||= get_last_mir_for_event(event_type, pool_type)\n when 'A' # Previous meeting edition (or Goggle Cup or last swam)\n best_mir = get_best_mir_for_meeting(meeting, event_type, pool_type)\n # TODO: goggle cup if nil\n best_mir ||= get_last_mir_for_event(event_type, pool_type)\n else # Personal best\n best_mir = get_best_mir_for_event(event_type, pool_type)\n end\n\n best_mir\n end", "def determine_item(item_type, item_id)\n case item_type\n \n when \"weapon_id\"\n Weapon.find(item_id) \n when \"armor_id\"\n Armor.find(item_id)\n when \"potion_id\"\n Potion.find(item_id)\n end\n end", "def artifact type \n cheeses=[\"Camembert\",\"Parmesan\",\"Cheddar\",\"Wisconsin\",\"Brie\",\"Stinky\",\"Blue\",\"Gorgonzola\",\"Goat\",\"Gouda\"]\n bones=[\"human\",\"neanderthal\",\"sasquatch\",\"velociraptor\",\"human child\",\"buffalo\",\"alien\"]\n civs=[\"Mayan\",\"Greek\",\"Chinese\",\"Collector's Edition\",\"Persian\",\"Roman\"]\n animals=[\"Aaron the Aardvark\",\"Wile E. Coyote\",\"killer rabbit\",\"Chupacabra\",\"Tobbits the Hobbit\",\"Pikachu\",\"Ling-Ling\"]\n if type==\"cheese\"\n return cheeses[rand(10)] #change to cheeses.length\n elsif type==\"bones\"\n return bones[rand(7)]\n elsif type==\"coin\"\n return civs[rand(6)]\n elsif type==\"animal\"\n return animals[rand(7)]\n end\nend", "def human_type\n self[:type].to_human\n end" ]
[ "0.7461818", "0.66510767", "0.6424252", "0.6400516", "0.63111544", "0.6275096", "0.61452454", "0.6110654", "0.6074439", "0.6067524", "0.5941566", "0.5932318", "0.5813837", "0.5805027", "0.57864434", "0.5785165", "0.57525396", "0.5747556", "0.5745277", "0.5691408", "0.5685435", "0.566061", "0.56579775", "0.56394714", "0.56327", "0.563166", "0.5596519", "0.55842155", "0.55592763", "0.55290705", "0.5525265", "0.5516022", "0.55027103", "0.5502011", "0.550133", "0.5500742", "0.5487544", "0.5451848", "0.54350305", "0.5405332", "0.54046834", "0.54000205", "0.53938437", "0.538158", "0.537151", "0.5368892", "0.5352202", "0.53462726", "0.53462726", "0.53416073", "0.5337426", "0.5334233", "0.53303134", "0.532904", "0.5315951", "0.53068084", "0.52991766", "0.5297638", "0.5295696", "0.5266478", "0.5253876", "0.52497077", "0.5246998", "0.52393925", "0.5230639", "0.5194629", "0.51862764", "0.5184001", "0.51829964", "0.51805055", "0.51768804", "0.51762927", "0.51758736", "0.5172672", "0.51726305", "0.51657283", "0.5155859", "0.5155694", "0.51516753", "0.5146909", "0.5144746", "0.5144739", "0.5140152", "0.5138918", "0.5136089", "0.51231945", "0.5118526", "0.5118282", "0.511654", "0.51092935", "0.51049834", "0.5104732", "0.5103701", "0.5098516", "0.5098418", "0.5093938", "0.50853246", "0.5081914", "0.50794065", "0.5070622", "0.50648206" ]
0.0
-1
returns an array of card with given number of multiples
def get_multiples(number) cards = [] @cards_by_score.each_key do |card| if @card_scores.count(card.score) == number cards << card end end cards end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def collect_multiples(number)\n \n numbers = Array.new(number - 1, 0)\n count = 0\n while count < numbers.length \n numbers[count] = count + 1\n count += 1\n end\n\n numbers.select do |element|\n element % 3 == 0 || element % 5 == 0\n end\n\nend", "def collect_multiples(limit)\n array = []\n (1...limit).each do |num|\n array << num if (num % 3 == 0) || (num % 5 == 0)\n end\n array\nend", "def collect_multiples(limit)\n multiples = []\n (1...limit).each do |num|\n multiples << num if (num % 3 == 0 || num % 5 == 0)\n end\n return multiples\nend", "def collect_multiples(limit)\n multiples = []\n\n for i in 1...limit do\n if (i % 5 == 0 || i % 3 == 0)\n multiples << i\n end\n end\n\n return multiples\n\nend", "def get_cards\n cards = []\n index = 0\n [2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 10, 10, 11].each do |num|\n 24.times do\n cards[index] = num\n index += 1\n end\n end\n shuffle(cards)\n end", "def collect_multiples(limit)\n multiples = []\n numbers = (1..limit.to_i-1).to_a\n numbers.each do |i|\n if i % 3 == 0 || i % 5 == 0\n multiples.push(i)\n end\n end\n multiples \nend", "def multiples_array(integer)\n multiples = []\n for i in 1..integer\n if i % 3 == 0 || i % 5 == 0\n multiples << i\n end\n end\n multiples\nend", "def multiples_of_3_or_5(max)\n multiples = []\n for i in 3...max #two dots are inclusive, three dots are not\n if i % 3 == 0 || i % 5 == 0 then multiples << i end\n end\n multiples\nend", "def multiples(number)\n number_array = Array(1..number)\n multiples_array = []\n\n number_array.each do |num|\n if num % 3 == 0 || num % 5 == 0\n multiples_array << num\n end\n end\n multiples_array.inject(:+)\nend", "def create_deck(number)\n deck = []\n deck_cards = []\n number.times do\n deck_cards << CARDS\n end\n deck_cards.flatten!\n deck = deck_cards.product(SUITES)\nend", "def multiples(number)\n number_array = Array(1..number)\n multiples_array = []\n\n number_array.each do |num|\n if num % 3 == 0 || num % 5 == 0\n multiples_array << num\n end\n end\n multiples_array.sum\nend", "def collect_multiples(limit)\n #numbers = [1..(limit-1)]\n multiple_numbers = []\n (1..(limit-1)).map do |number|\n if number % 3 == 0 || number % 5 == 0\n multiple_numbers << number\n end\n end\n multiple_numbers\nend", "def collect_multiples(num)\n range = (3...num)\n multiples = []\n range.each do |num|\n if num % 3 == 0 || num % 5 == 0\n multiples << num\n end\n end\n multiples\nend", "def collect_multiples(limit)\n (1...limit).to_a.select{|i| i % 3 == 0 || i % 5 == 0}\nend", "def collect_multiples(limit)\n array=*(1...limit)\n array.select {|num| num % 3 == 0 || num % 5 ==0}\nend", "def initialize_cards\n cards = []\n 4.times { cards += (2..14).to_a }\n cards.sample(52)\n end", "def repetitions(n)\n @hand.group_by{ |card| card.point }.select { |k, v| v.count == n }\n end", "def find_multiples(number)\n sum_of_multiples = (3...number).each_with_object([]) do |element, list|\n list << element if element % 3 == 0 || element % 5 == 0\n end.sum\nend", "def multiples(num)\n\tresult = []\n\tsum = 0\n\ti = 1\n\twhile i < num\n\t\tif i % 3 == 0 || i % 5 == 0\n\t\t\tresult << i\n\t\tend\n\t\ti += 1\n\tend\n\tresult.each do |digit|\n\t\tsum += digit\n\tend\n\tsum\t\nend", "def find_multiples(integer)\n arr = (1..integer).to_a\n multiples = []\n\n arr.each do |val|\n if (val % 3).zero? || (val % 5).zero?\n multiples.push(val) # mutates original array\n end\n end\n multiples\nend", "def multiples_x(number, multiple)\n current_multiple = multiple\n multiples = []\n\n while current_multiple <= number\n multiples << current_multiple\n current_multiple += multiple\n end\n\n multiples\nend", "def collect_multiples\n (1..@limit).select{|num| num%3 == 0 || num%5 == 0}\n end", "def get_multiples(max)\n\tmot = (1..max_limit(max, 3)).map { |a| a*3 }\n\tmo5 = (1..max_limit(max, 5)).map { |a| a*5 }\n\t(mot + mo5).uniq.inject(0, :+)\nend", "def create_multipliers(isbn)\n multipliers = [] # initialize an empty array to hold multipliers\n # if the number is isbn10 create an array of integers (1 - 9) to multiply each isbn digit\n # otherwise it's isbn13 so create a 12-element array of alternating 1s and 3s\n output_raw_number(isbn).length == 10 ? (multipliers = (1..9).to_a) : 6.times { multipliers.push(1); multipliers.push(3) }\n return multipliers\nend", "def combos(cards)\n cards.to_a.combination(3).to_a\n end", "def deal5cards (n)", "def collect_multiples(limit)\n (1...limit).select {|e| e%3 == 0 || e%5 ==0}\nend", "def collect_multiples(limit)\n (1...limit).to_a.reject {|num| num unless num % 3 == 0 || num % 5 == 0}\nend", "def multiples_3_5_v1\n\tmultiples = (1...1000).find_all do |i| \n\t\ti % 3 == 0 || i % 5 == 0\n\tend\n\n\tanswer = multiples.inject do |memo, num|\n\t\tmemo + num\n\tend\n\n\treturn answer\nend", "def create_deck\n deck = Array.new\n for number in 0..2\n for color in 0..2\n for shape in 0..2\n for shade in 0..2\n deck.push(Card.new(number,color,shape,shade))\n end\n end\n end\n end\n return deck\nend", "def repeats\n cards.group_by &:value\n end", "def multiples_of_three_and_five(limit)\n arr = []\n i = 1\n\n while i < limit do\n if i % 5 == 0 || i % 3 == 0\n arr << i\n i += 1\n else\n i += 1\n end\n # puts $arr.inspect\n end\n\n arr_size = arr.count\n # puts arr_size\n total = 0\n i = 0\n\n while i < arr_size do\n total += arr[i]\n i += 1\n end\n\n return total\nend", "def my_cards\n index = 0\n @my_cards = []\n @suits.each do |suit|\n (1..13).each do |value|\n card = Card.new(value, suit)\n @my_cards.push(card)\n end\n end\n return @my_cards\n end", "def sequence(number_of_multiples, multiplier)\n result = []\n (1..number_of_multiples).each { |number| result << number * multiplier }\n result\nend", "def multisum(limit)\n multiples = []\n\n for num in 1..limit\n multiples << num if num % 3 == 0 || num % 5 == 0\n end\n\n multiples.inject(:+)\nend", "def multiples\n (1..999).select do |i|\n i % 3 == 0 || i % 5 == 0\n end\nend", "def produce_new_deck\n new_deck = []\n\n USED_DECK_COUNT.times do |x|\n i = 52\n new_deck = new_deck + Array.new(52) {|index| index}\n end\n return new_deck\nend", "def multiples(n)\n (1...n).select do |num|\n num if (num % 3).zero? || (num % 5).zero?\n end.reduce(:+)\nend", "def build_deck\n# This function builds an array of 52 cards made up of 4 copies of fixed nums with values from 1 to 13\n\t@deck = []\n\tfor num in 1..4\n\t\tfor num in 1..13\n\t\t\t@deck.push(num)\n\t\tend\n\tend\nend", "def collect_multiples(limit)\n 1.upto(limit-1).find_all do |i| #limit-1 so it takes range from 1 upto limit, excluding limit (so if limit is 10, range will be 1-9)\n (i % 5 == 0) || (i % 3 == 0)\n end #end loop\nend", "def getMultpiles(range)\n\tmultiples = []\n\tfor i in 3...range\n\t\tif i % 3 == 0 || i % 5 == 0\n\t\t\tmultiples << i\n\t\tend\n\tend\n\treturn multiples\nend", "def multiples(num)\n (1...num).select { |n| n % 3 == 0 || n % 5 == 0 }.inject(:+)\nend", "def take(n)\n if n > self.count \n raise 'not enough cards'\n end \n ncards = [] \n n.times do \n ncards << cards.shift\n end \n return ncards\n end", "def getCards(aDeck)\n\t\treturn 13.times{self << aDeck.next}\t\n\tend", "def multisum(num)\n arr = [*1..num]\n multiples_3_5 = arr.select{ |ele| ele % 3 == 0 || ele % 5 == 0}\n multiples_3_5.sum\nend", "def select_every_n arr, n=1\n ans = []\n arr.each_with_index do |item, i|\n ans.push item if i%n == 0\n end\n ans\nend", "def multiples\n\t\t#select all numbers from 3-999 using iterator i...\n\t\t(3..999).select do |i|\n\t\t\t#...that are divisible by 3 or divisible by 5\n\t\t\ti%3 == 0 || i%5 == 0\n\t\tend\n\tend", "def group\n students = (1...59).to_a\n students.shuffle.each_slice(5).to_a\nend", "def multiples(input)\n (1..input).select { |num| (num % 3).zero? || (num % 5).zero? }.reduce(:+)\nend", "def sum_of_3_or_5_multiples(n)\n n = n.to_i\n #compteur de boucle\n i = 0\n #tableu incluant les multiple de 3 et 5\n result_array = []\n while i < n\n a = i%3\n b = i%5\n if a == 0 || b == 0\n result_array << i\n i+=1\n else\n i+=1\t\n end\n \n end\n sum = 0\n result_array.each do |p|\n \t sum = sum + p\n end\n return sum \nend", "def deal (n, deck)\n cards = []\n n.times {cards << deck.pop}\n cards\nend", "def multiples(i)\n ms = []\n (1..10).each do |j|\n ms << i * j\n end\n ms\nend", "def sequence(number_of_multiples, multiplier)\n return [] if number_of_multiples == 0\n result = []\n current_number = 1\n loop do\n result << current_number * multiplier\n current_number += 1\n break if current_number > number_of_multiples\n end\n result\nend", "def build_shoe(num_of_decks)\n shoe = []\n num_of_decks.times do |_|\n DECK_OF_CARDS.map do |card|\n shoe << card\n end\n end\n shoe\nend", "def multisum(num)\n # 2. Next, since I know I have to store all multiples of 3 and 5, I want to create an empty array\n multiples = []\n # 3. Now I can run the each method on the range of 1 to num\n (1..num).each do |number|\n # 4. If the number is evenly divisible by 3 or 5 I want to store it in the multiples array\n if number % 3 == 0 || number % 5 == 0\n multiples << number\n end\n end\n # 5. Now I simply return the sum of the multiples array\n multiples.sum\nend", "def build_shoe(num_of_decks)\n shoe = []\n num_of_decks.times do |_|\n DECK_OF_CARDS.select do |card|\n shoe << card\n end\n end\n shoe\nend", "def multiples num1, num2, divisor\n x = []\n (num1...num2).each do |i|\n if is_divisible i, divisor\n x << i\n end\n end\n x\n end", "def initialize\n @cards = ((1..6).to_a * 3 + (7..10).to_a * 4 + (11..17).to_a * 2 + (18..25).to_a).shuffle\n end", "def create_deck(num)\r\n suits = ['Heart', 'Diamond', 'Spade', 'Club']\r\n values = ['Ace', 2, 3, 4, 5, 6, 7, 8, 9, 10, 'Jack', 'Queen', 'King']\r\n deck = Array.new\r\n \r\n num.times do\r\n suits.each do |s|\r\n values.each do |v|\r\n card = {suit: s, value: v}\r\n deck.push(card)\r\n end\r\n end\r\n end\r\n deck\r\nend", "def multisum(num)\n multiples = []\n 1.upto(num) do |x| \n if x % 3 == 0 || x % 5 == 0\n multiples << x\n end\n end\n multiples.inject(:+)\nend", "def sum_of_multiples(n)\n multiples_of_3_or_5 = []\n for i in 1..n\n if i % 3 == 0 || i % 5 == 0\n multiples_of_3_or_5 << i\n end\n end\n multiples_of_3_or_5.sum\nend", "def multiples(x)\n array = []\n while x > 0\n x = x - 1\n if (x % 3 == 0) || (x % 5 == 0)\n array << x\n end\n end\n return array.inject{|sum,x| sum + x }\nend", "def create_deck\n\n\tdeck = Array.new\n\tcard_val = Array.new\n\tcard_type = [\"h\",\"d\",\"c\",\"s\"] # Hearts, Diamonds, Clubs, Spades\n\n (2..10).each do |i|\n \tcard_val << i.to_s\n end\n card_val << \"J\" << \"Q\" << \"K\" << \"A\"\n\n for type in card_type\n \tfor val in card_val\n \t\tdeck << val+type\n \tend\n end\n\n return deck\n\nend", "def create_deck\n suit_counter = 0\n value_counter = 0\n deck =[]\n until deck.count == (@valid_suits.count * @valid_values.count)\n deck << Card.new(@valid_suits[suit_counter], @valid_values[value_counter])\n value_counter += 1\n value_counter = 0 if (value_counter == @valid_values.count)\n suit_counter += 1 if (deck.count == (suit_counter + 1) * (@valid_values.count))\n end\n deck\n end", "def multisum(value)\n multiples = []\n value.each { |item| multiples << item if item % 5 == 0 or item % 3 == 0}\n muliples.reduce(&:+)\nend", "def generate_deck\n (1..3).to_a.product(@colors, @shapes, @textures).each{|arr| @deck.push(Card.new(arr[0], arr[1], arr[2], arr[3]))}\n @deck.shuffle!\nend", "def disc_factory(number)\n disc_array = []\n number.times do\n disc_array << Disc.new\n end\n disc_array\n end", "def find_multiples (cap)\n\tsum = 0\n\t(0..(cap-1)).each {|num| sum += num if (num % 3 == 0 || num % 5 == 0) }\n\n\treturn sum\nend", "def accounts(group)\n if group.length % 5 == 0\n return group.shuffle.each_slice(5).to_a\n end\nend", "def sequence(multiple, starting_num)\n return [] if multiple == 0\n counter = 1\n array = []\n loop do\n array << counter * starting_num\n counter += 1\n break if counter > multiple\n end\n array\nend", "def multisum(integer)\n multiples = []\n 1.upto(integer) do |index|\n multiples << index if index % 3 == 0 || index % 5 == 0\n end\n multiples.sum\nend", "def multiples_of(number, upTo)\n result = Array.new\n (0..upTo).step(number) do |n|\n result << n\n end\n puts result.inspect\n result\nend", "def multisum(num)\n numbers = (1..num).to_a\n multiples = numbers.select { |element| element % 3 == 0 || element % 5 == 0 }\n multiples.inject(:+)\nend", "def build_shuffler(deck_count = 1)\n arr = []\n\n for i in 1..deck_count\n for j in 1..52\n arr << rand(MAX_INT)\n end\n end\n arr\n end", "def multiples_of_3_and_5(number)\n (1...number).select{|num| num % 3 == 0 || num % 5 == 0}.inject(:+)\nend", "def groups_of(num)\n collection.each_slice(num).to_a\n end", "def multiple()\n\tresult = 0\n\t\tfor i in 1...1000\n\t\t\tif i%3 == 0 || i%5 == 0\n\tresult += i\n\t\t\tend\n\t\tend\n\treturn result\nend", "def build_deck\n CARD_SUITS.product(CARD_VALUES).shuffle\nend", "def divide(how_many)\n me = self.dup\n (1..how_many).to_a.reverse.inject([]) do |parts,i|\n part,me = me.break((me.size.to_f / i).ceil)\n parts.push(part)\n end\n end", "def multiple_of_three_and_five(limit)\r\n (3...limit).select { |number| number % 3 == 0 || number % 5 ==0 }.inject(:+)\r\nend", "def multisum(number)\n multiples = (1..number).select { |x| (x % 3 == 0) || (x % 5 == 0) }\n multiples.reduce(:+)\nend", "def sum_of_multiples\n list_of_multiples = [ ]\n 1000.times do |number| \n list_of_multiples << number if number % 3 == 0 || number % 5 == 0\n end\n list_of_multiples.inject(&:+)\nend", "def threefive(num)\n\n if num < 1 || num > 100\n return \"Number must be between 1-100\"\n end\n mult_arr = []\n mult_arr << 0\n i = 0\n\n while num > i\n if (i % 3) == 0\n mult_arr << i\n elsif (i % 5) == 0\n mult_arr << i\n end\n i += 1\n end\n return mult_arr.inject{|sum,n| sum + n}\n\nend", "def build_deck(deck_count = 1)\n arr = []\n for i in 1..deck_count\n deck_hash = {}\n ['Clubs', 'Hearts', 'Spades', 'Diamonds'].each do |suit|\n val = 0\n ['A ','2 ','3 ','4 ','5 ','6 ','7 ','8 ','9 ','10 ','J ','Q ','K '].each do |face|\n val += 1 unless val == 10\n deck_hash.merge!({\"#{face}#{suit}\".to_sym => val})\n end\n end\n arr << deck_hash\n end\n arr\n end", "def sequence(number_of_multiples, multiplier)\n result = []\n current_number = 1\n loop do\n break if current_number > number_of_multiples # catches edge case\n result << current_number * multiplier\n current_number += 1\n end\n result\nend", "def cards(card_numbers, api_token)\n EnumerableUtils.batch_reduce([], card_numbers, 165) do |combined_result, card_numbers|\n result = _card(card_number: card_numbers.join(','), token: api_token)\n combined_result += result.collect{|card| Card.new(card)}\n end\n end", "def draw3more(deck)\n for i in 1..3\n @cardsShown << deck.draw\n end\n end", "def multisum(number)\n multiples = (1..number).select do |num|\n num % 3 == 0 || num % 5 == 0\n end\n\n multiples.inject(:+)\nend", "def multisum(number)\n\n mult_array = (1..number).select { |n| n % 3 == 0 || n % 5 == 0 }\n p mult_array\n sum = mult_array.inject(0,:+)\n p sum\nend", "def crazy_nums(max)\n res = []\n idx = 3\n while idx < max\n if (idx % 3 == 0 || idx % 5 == 0) && idx % 15 != 0\n res.push(idx)\n end\n idx += 1\n end\n return res\nend", "def multisum(num)\n counter = 1\n arr = []\n while counter <= num\n if counter % 3 == 0 || counter % 5 == 0\n arr << counter\n end\n counter += 1\n end\n arr.sum\nend", "def initialize_deck\n [\"A\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"J\", \"Q\", \"K\"].product(['S', 'H', 'C', 'D'])\nend", "def initialize_deck\n [\"A\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\", \"9\", \"10\", \"J\", \"Q\", \"K\"].product(['S', 'H', 'C', 'D'])\nend", "def duplicate_elements(n = 2)\n self.inject([]) do |array, current|\n array << [current] * n\n array\n end.flatten\n end", "def multisum(number)\n (1..number).select { |multiple| multiple % 3 == 0 || multiple % 5 == 0 }.inject(:+)\nend", "def collect_multiples(limit)\n numbers = (1..limit-1).to_a\n result= numbers.select do |num|\n num % 5 == 0 || num %3 == 0\n end\n# binding.pry\n result\nend", "def even_multiplies(list_of_numbers)\n even_multiplies_list = []\n list_of_numbers.each do |number|\n if number.even? && number % 5 == 0\n even_multiplies_list << number\n end\n end\n even_multiplies_list\nend", "def group\n students = (1...59).to_a\n students.each_slice(5).to_a\n\nend", "def divisible\n\tarr = []\n\tfor x in 1..101 do\n\t\tif x % 2 == 0 || x % 3 == 0 || x % 5 == 0\n\t\t\tarr << x\n\t\tend\n\tend\n\treturn arr\nend", "def initialize\n\t\t@cards = (1..52).to_a\n\tend" ]
[ "0.7295955", "0.7234427", "0.71736974", "0.71499264", "0.71370065", "0.7105511", "0.7092792", "0.7009756", "0.6929065", "0.6902126", "0.6857695", "0.68308", "0.682126", "0.6779479", "0.6763631", "0.6746046", "0.6718843", "0.66709906", "0.66703296", "0.66694295", "0.6638205", "0.6624936", "0.65796435", "0.6527064", "0.6519743", "0.65157497", "0.65139574", "0.6481202", "0.6459614", "0.6457379", "0.64504784", "0.6447793", "0.64349264", "0.64312667", "0.64045686", "0.63924533", "0.63908595", "0.6368501", "0.63684833", "0.6353516", "0.63418067", "0.6340129", "0.63165694", "0.63152707", "0.6303741", "0.6298653", "0.6296347", "0.62701535", "0.62658477", "0.62478554", "0.6233995", "0.6217162", "0.6203299", "0.6199937", "0.61734027", "0.6161317", "0.6148346", "0.61425304", "0.6141436", "0.6139799", "0.6132818", "0.61301595", "0.61238456", "0.61127603", "0.6110289", "0.6092929", "0.6092301", "0.6087623", "0.6085683", "0.6084571", "0.60802597", "0.60478127", "0.60477984", "0.6027413", "0.60235924", "0.6021256", "0.6020249", "0.60191244", "0.60123295", "0.5997997", "0.5979001", "0.5976166", "0.59711534", "0.59697396", "0.59621644", "0.5959992", "0.5957634", "0.5957374", "0.5932741", "0.5925417", "0.5912818", "0.590447", "0.590447", "0.58973736", "0.58973694", "0.58931196", "0.58886033", "0.5886538", "0.58755934", "0.586249" ]
0.7604125
0
with array of cards and determines the best 5 card hand
def best_hand case when hand? return @cards when pair? && !hand? get_pairs when two_pair? && !hand? get_pairs when three_of_a_kind? && !full_house? && !hand? get_three_of_a_kind when straight? && !straight_flush? && !hand? get_straight when flush? && !straight_flush? && !hand? get_flush when full_house? && !hand? get_full_house when four_of_a_kind? && !hand? get_four_of_a_kind when straight_flush? && !hand? get_straight_flush else get_high_card end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_high_cards(cards)\n @cards_by_score.each_key do |card|\n if cards.length < 5 && !cards.include?(card)\n cards << card\n end\n end\n end", "def tie_breaker_cards\n matched = self.matched_cards\n sorted = @cards.sort.reverse\n # sorted so the card with highest value is first \n if five_of_a_kind? \n # All cards break the tie\n return sorted \n elsif flush?\n # All cards break the tie\n return sorted \n elsif four_of_a_kind?\n four = matched.find{ |rank, cards| cards.size == 4}\n # quads break the tie first, then the other card \n return four + [(sorted - four).first] \n elsif full_house?\n three = matched.find{ |rank, cards| cards.size == 3}\n two = matched.find{ |rank, cards| cards.size == 2}\n return three + two\n elsif straight?\n # Special case for ace, 2, 3, 4 ,5 straight, which sorts as\n # 2,3,4,5,A \n if sorted.first.rank == Rank::Ace && sorted.last.rank == Rank::Two \n ace = sorted.pop \n sorted.unshift(ace) # put ace at the back\n return [ sorted.first ] # should be the 5 now \n else\n return [ sorted.first ] \n end\n elsif three_of_a_kind?\n three = matched.find{ |rank, cards| cards.size == 3} \n return three + (sorted - three).first(2)\n elsif two_pair?\n pairs = [] \n matched.each{ |rank, cards| pairs << cards if cards.size == 2 } \n two_pair = pairs[0] + pairs[1]\n two_pair + [(sorted - two_pair).first]\n elsif pair?\n two = matched.find{ |rank, cards| cards.size == 2} \n two + (sorted - two).first(3)\n else\n sorted.first(5)\n end\n end", "def eval_n_cards(cards)\n cards.combination(5).inject(EqClTable.last.code) do |best_code, comb|\n q=eval_5_cards(*comb)\n if q<best_code then q; else best_code; end\n end\n end", "def best_taken_card(take_it)\r\n @log.debug(\"calculate best_taken_card\") \r\n w_cards = []\r\n take_it.each do |card_lbl|\r\n card_s = card_lbl.to_s # something like '_Ab'\r\n segno = card_s[2,1] # character with index 2 and string len 1\r\n curr_w = 0\r\n curr_w += 200 if card_s[2] == @briscola.to_s[2]\r\n # check if it is an asso or 3\r\n curr_w += 0 if card_s[1] == \"A\"[0]\r\n curr_w += 5 if card_s[1] == \"3\"[0] \r\n if card_s =~ /[24567]/\r\n # liscio value\r\n lisc_val = (card_s[1] - '0'[0]).to_i\r\n curr_w += 70 + lisc_val\r\n end\r\n curr_w += 40 if card_s[1] == \"F\"[0]\r\n # mariazza is possible?, horse and king has a different value\r\n if card_s[1] == \"C\"[0]\r\n if is_mariazz_possible?(segno)\r\n curr_w += 290\r\n else\r\n curr_w += 30\r\n end\r\n end \r\n if card_s[1] == \"R\"[0]\r\n if is_mariazz_possible?(segno)\r\n curr_w += 300\r\n else\r\n curr_w += 20\r\n end\r\n end\r\n w_cards << [card_lbl, curr_w ] \r\n end\r\n # find a minimum\r\n #p w_cards\r\n min_list = w_cards.min{|a,b| a[1]<=>b[1]}\r\n @log.debug(\"Best card to play on best_taken_card is #{min_list[0]}, w_cards = #{w_cards.to_s}\")\r\n return min_list\r\n end", "def hand_score\n cards.map {|a| a.value}.sort {|a,b| a <=> b}.last\n end", "def initialize(cards)\n raise \"Invalid hand size - #{cards.length}\" unless cards.length == 5\n @cards = cards.map {|c| Card.new(c)}.sort\n @by_value = {}\n @by_suit = {}\n @cards.each do |c|\n @by_value[c.value] ||= []\n @by_suit[c.suit] ||= []\n @by_value[c.value] << c\n @by_suit[c.suit] << c\n end\n\n if @cards[4].value+1 == @cards[3].value &&\n @cards[3].value+1 == @cards[2].value &&\n @cards[2].value+1 == @cards[1].value &&\n @cards[1].value+1 == @cards[0].value\n end\n # Is it a straight\n @straight = true\n @cards.reduce do |p,c|\n if p.value != c.value + 1\n @straight = false\n break\n end\n c\n end\n value = [0]\n if @straight # Is it a straight\n value = [500, @cards.first.value]\n end\n # Is it a flush\n if @flush = @by_suit.find {|k,v| v.length == 5}\n if @straight\n value = [900, @cards.first.value]\n else\n value = [600, @cards.first.value]\n end\n end\n if value[0] < 700\n if (a = @by_value.find {|k,v| v.length == 3 }) &&\n (b = @by_value.find {|k,v| v.length == 2 })\n value = [700, a[0], b[0]]\n elsif a = @by_value.find {|k,v| v.length == 4 }\n value = [800, a[0]] # Is it 4 of a kind\n end\n end\n if value[0] < 500 && (a = @by_value.find {|k,v| v.length == 3 })\n value = [400, a[0]] # Is it 3 of a kind\n end\n if value[0] < 400 \n if (a = @by_value.select {|k,v| v.length == 2}).length > 0\n if a.length == 2\n hi,low = a[a.keys.max], a[a.keys.min]\n high = @cards - hi - low\n value = [300,hi.first.value, low.first.value, high.first.value]\n else\n pair = a[a.keys.first]\n high = (@cards - pair).first\n value = [200,pair.first.value, high.value]\n end\n else\n value = [100, @cards.first.value]\n end\n end\n @value = value\n end", "def highest_card?\n single_cards = Array.new(5, -1)\n single_count = 0\n (12).downto(0) do |i|\n if @ranks[i] == 1 and single_count < 5\n single_cards[single_count] = i\n single_count += 1\n end\n end\n return [1] + single_cards\n end", "def best_hand\n @active_players.map do |player|\n # Creates an array storing all possible 5 card combinations.\n @all_combos = (player.hole_cards + @community_cards).combination(5).to_a\n @best_hand = PokerHand.new\n @current_hand = nil\n\n # Loops through every hand combination, comparing the current hand to the best hand. If the current hand is better than the best hand, it becomes the best hand, otherwise it is deleted.\n @all_combos.map do |hand|\n next unless @all_combos.length > 1\n\n @current_hand = PokerHand.new(hand)\n if @current_hand > @best_hand\n @best_hand = @current_hand\n else\n @all_combos.delete(hand)\n end\n end\n\n # After finding the best hand it stores it for the player and outputs it.\n player.strongest_hand = @best_hand\n puts \"#{player.player_name} has #{player.strongest_hand}\"\n sleep(1)\n end\nend", "def deal5cards (n)", "def high_ranking_cards\n\n array_high_cards = []\n\n cards.each do |card|\n\n if card.rank >= 11\n array_high_cards << card\n end\n\n end\n\n array_high_cards\n\n end", "def hand_value(cards)\n value = 0\n val_arr = []\n cards.each do |sub_array|\n val_arr << sub_array.last\n val_arr.sort!\n end\n val_arr.each do |val|\n if val == 11 && value > 10\n value = value + 1 \n else\n value = value + val\n end\n end\n return value\nend", "def determine_dealers_best_total\n # @dealer_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']\n # @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']\n # @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']\n # @dealer_hand = ['king of hearts', '6 of diamonds']\n sum_of_dealers_hand = 0\n number_of_aces_in_hand = 0\n @dealer_hand.each {|x| # begin loop adding dealers hand\n card_value = @deckhash.fetch(x)\n\n if card_value == 1 then # adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end\n sum_of_dealers_hand = sum_of_dealers_hand + card_value\n\n } #end of loop adding dealers hand\n\n if sum_of_dealers_hand > 21 then # must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_dealers_hand = sum_of_dealers_hand - 10\n if sum_of_dealers_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_dealers_hand > 21\n\n # $stdout.write(\"Showing card and value #{sum_of_dealers_hand}, #{number_of_aces_in_hand} \\n\")\n # ### this method returns of the dealer's best hand'\n\n sum_of_dealers_hand = sum_of_dealers_hand + 0\n\n end", "def eval_n_cards_unrolled(cards, has_6_cards=false)\n \tbest=eval_5_cards( cards[0], cards[1], cards[2], cards[3], cards[4] )\n \tif (q=eval_5_cards( cards[0], cards[1], cards[2], cards[3], cards[5] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[0], cards[1], cards[2], cards[4], cards[5] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[0], cards[1], cards[3], cards[4], cards[5] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[0], cards[2], cards[3], cards[4], cards[5] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[1], cards[2], cards[3], cards[4], cards[5] )) < best then best=q; end\n \treturn best if has_6_cards\n \tif (q=eval_5_cards( cards[0], cards[1], cards[2], cards[3], cards[6] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[0], cards[1], cards[2], cards[4], cards[6] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[0], cards[1], cards[2], cards[5], cards[6] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[0], cards[1], cards[3], cards[4], cards[6] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[0], cards[1], cards[3], cards[5], cards[6] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[0], cards[1], cards[4], cards[5], cards[6] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[0], cards[2], cards[3], cards[4], cards[6] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[0], cards[2], cards[3], cards[5], cards[6] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[0], cards[2], cards[4], cards[5], cards[6] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[0], cards[3], cards[4], cards[5], cards[6] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[1], cards[2], cards[3], cards[4], cards[6] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[1], cards[2], cards[3], cards[5], cards[6] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[1], cards[2], cards[4], cards[5], cards[6] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[1], cards[3], cards[4], cards[5], cards[6] )) < best then best=q; end\n \tif (q=eval_5_cards( cards[2], cards[3], cards[4], cards[5], cards[6] )) < best then best=q; end\n \tbest\n\tend", "def high_card_winner\n\n\t # find high card winner card from numerical representation\n\t for i in 0..@best_hand_value_1.length-1 do \n\t if @best_hand_value_1[i] <= 10\n\t @high_card_winner_1[i] = @best_hand_value_1[i]\n\t elsif @best_hand_value_1[i] == 11\n\t @high_card_winner_1[i] = 'J'\n\t elsif @best_hand_value_1[i] == 12\n\t @high_card_winner_1[i] = 'Q'\n\t elsif @best_hand_value_1[i] == 13\n\t @high_card_winner_1[i] = 'K'\n\t elsif @best_hand_value_1[i] == 14\n\t @high_card_winner_1[i] = \"A\"\n\t end \n\t if @best_hand_value_2[i]<=10\n\t @high_card_winner_2[i] = @best_hand_value_2[i]\n\t elsif @best_hand_value_2[i] == 11\n\t @high_card_winner_2[i] = 'J'\n\t elsif @best_hand_value_2[i] == 12\n\t @high_card_winner_2[i] = 'Q'\n\t elsif @best_hand_value_2[i] == 13\n\t @high_card_winner_2[i] = 'K'\n\t elsif @best_hand_value_2[i] == 14\n\t @high_card_winner_2[i] = \"A\"\n\t end \n\t end\n\tend", "def initialize (cards)\n #sort the cards and store them in @cards\n @cards = Array.new\n cards.each do |card|\n @cards << Card.new(card)\n end\n @cards.sort!\n \n #determine the rank of the hand\n @rank = 0\n \n #see if at least one pair exists\n if @cards[0] == @cards[1] or @cards[1] == @cards[2] or @cards[2] == @cards[3] or @cards[3] == @cards[4]\n @handStart = @cards[0] == @cards[1] ? 0 : @cards[1] == @cards[2] ? 1 : @cards[2] == @cards[3] ? 2 : 3\n @rank = 1 #one pair\n #see if it's part of a three of a kind\n if @cards[0] == @cards[2] or cards[1] == @cards[3] or cards[2] == @cards[4]\n #see if hand is a full house\n if (@cards[0] == @cards[1] and @cards[2] == @cards[3] and @cards[2] == @cards[4]) or (@cards[0] == @cards[1] and @cards[0] == @cards[2] and @cards[3] == @cards[4])\n @handSubstart = @cards[2] == @cards[4] ? 2 : 3\n @rank = 6 #full house\n else\n @rank = 3 #three of a kind\n \n #see if it's part of a four of a kind\n if @cards[0] == @cards[3] or @cards[1] == @cards[4]\n @rank = 7 #four of a kind\n end\n end\n else\n #see if there are two pairs\n if (@cards[0] == @cards[1] and @cards[2] == @cards[3]) or (@cards[1] == @cards[2] and @cards[3] == @cards[4]) or (@cards[0] == @cards[1] and @cards[3] == @cards[4])\n @rank = 2 #two pairs\n @handSubstart = @cards[2] == @cards[4] ? 2 : 3\n end\n end\n else\n #check for straight\n inorder = true\n 0.upto(@cards.count - 2) do |x|\n if @cards[x].face and !@cards[x+1].face\n inorder = false\n break\n elsif !@cards[x].face and !@cards[x+1].face\n unless @cards[x].value + 1 == @cards[x+1].value\n inorder = false\n break\n end\n else\n unless @cards[x+1].value == \"J\"\n inorder = false\n break\n end\n end\n end\n if inorder\n @rank = 4 #straight\n end\n end\n \n #check for flush, straight flush and royal flush\n flush = true\n suit = @cards[0].suit\n @cards.each do |card|\n unless card.suit == suit\n flush = false\n break\n end\n end\n if flush\n if @rank == 4\n @rank = 8 #straight flush\n elsif @cards[1].face and @cards[2].face and @cards[3].face and @cards[4].face\n @rank = 9 #royal flush\n elsif @rank < 6\n @rank = 5 #flush\n end\n end\n end", "def hand_value cards\n values = cards.map{|c| $value_map[c[0]]}\n suits = cards.map{|c| c[1]}\n is_flush = false\n # check for flush\n if suits.uniq.size == 1\n is_flush = true\n end\n # check for straight\n is_straight = true\n sorted_values = values.sort\n for v in 0..(values.size-2)\n unless sorted_values[v]+1 == sorted_values[v+1]\n is_straight = false\n break\n end\n end\n if is_straight\n if is_flush\n # royal flush\n return {rank: 9, secondary: 10} if sorted_values[0] == 10\n # straight flush\n return {rank: 8, secondary: sorted_values[0]}\n end\n end\n # check for four of a kind\n if sorted_values[0] == sorted_values[3] || sorted_values[1] == sorted_values[4]\n return {rank: 7, secondary: sorted_values[1]}\n end\n # check for three of a kind or full house\n if sorted_values[0] == sorted_values[2]\n return {rank: 6, secondary: sorted_values[0]} if sorted_values[3] == sorted_values[4]\n return {rank: 3, secondary: sorted_values[0]}\n end\n if sorted_values[2] == sorted_values[4]\n return {rank: 6, secondary: sorted_values[2]} if sorted_values[0] == sorted_values[1]\n return {rank: 3, secondary: sorted_values[2]}\n end\n # check for three of a kind (case where full house is not possible)\n if sorted_values[1] == sorted_values[3]\n return {rank: 3, secondary: sorted_values[1]}\n end\n # return for flush (fine since three of a kind/full house and flush are mutually exclusive)\n return {rank: 5, secondary: sorted_values.last} if is_flush\n # return for straight (fine since three of a kind/full house and straight are mutually exclusive)\n return {rank: 4, secondary: sorted_values[0]} if is_straight\n # check for two pairs\n if sorted_values[0] == sorted_values[1] && sorted_values[2] == sorted_values[3]\n return {rank: 2, secondary: (sorted_values[0] > sorted_values[2] ? sorted_values[0] : sorted_values[2])}\n end\n if sorted_values[0] == sorted_values[1] && sorted_values[3] == sorted_values[4] \n return {rank: 2, secondary: (sorted_values[0] > sorted_values[3] ? sorted_values[0] : sorted_values[3])}\n end\n if sorted_values[1] == sorted_values[2] && sorted_values[3] == sorted_values[4] \n return {rank: 2, secondary: (sorted_values[1] > sorted_values[3] ? sorted_values[1] : sorted_values[3])}\n end\n # check for pairs\n return {rank: 1, secondary: sorted_values[0]} if sorted_values[0] == sorted_values[1]\n return {rank: 1, secondary: sorted_values[1]} if sorted_values[1] == sorted_values[2]\n return {rank: 1, secondary: sorted_values[2]} if sorted_values[2] == sorted_values[3]\n return {rank: 1, secondary: sorted_values[3]} if sorted_values[3] == sorted_values[4]\n # otherwise high card\n return {rank: 0, secondary: sorted_values.last}\nend", "def eval_7hand(hand)\n best = 9999\n subhand = []\n\n (0..20).each do |i|\n (0..4).each do |j|\n subhand[j] = hand[ Arrays::PERM7[i][j] ]\n q = eval_5hand(subhand)\n if q < best\n best = q\n else\n return best\n end\n end\n end\n end", "def high_card\n valueInt = {\"A\" => 14, \"K\"=> 13, \"Q\"=> 12, \"J\"=> 11}\n results=[]\n\n [@hand1Values, @hand2Values].each do |handV|\n maxValue = 0\n handV.each do |h|\n value = valueInt[h] ? valueInt[h] : h\n maxValue = value.to_i if value.to_i > maxValue \n end\n results << maxValue\n end\n\n results\n end", "def get_optimum_hand_score(hand)\n total = 0\n hand.each do |card|\n total += get_card_value(card)\n end\n\n #Count the number of aces we have\n num_aces = (hand.select{|card| get_card_value(card) == 11}).length\n\n #Account fo aces\n while total > 21 && num_aces > 0 do\n total -= 10\n num_aces -= 1\n end\n return total\nend", "def high_ranking_cards\n cards.map do |card|\n if card.rank >= 11\n high_cards << card\n end\n end\n high_cards\n end", "def is_high_card( hand )\n\treturn hand.map { | e | card_value( e ) }.max\nend", "def high_card\n [1, values, \"#{best_card}-#{card_names(values)[1]} High Card\"]\n end", "def initialize(codes)\n\t\t@cards = codes.split(\" \").map { |s| Card.new(s) }.sort {|a,b| a <=> b}.reverse\n\t\t\n\t\tdistinct_suits = Set.new.merge @cards.map{|card| card.suit}\n\n\t\tis_straight =\n\t\t\t@cards[0].value-1 == @cards[1].value &&\n\t\t\t@cards[0].value-2 == @cards[2].value &&\n\t\t\t@cards[0].value-3 == @cards[3].value &&\n\t\t\t@cards[0].value-4 == @cards[4].value\n\n\t\tif @is_straight && @cards[0].value == 14 && distinct_suits.size == 1\n\t\t\t@hand = 'ROYAL_FLUSH'\n\t\t\treturn\n\t\tend\n\n\t\tif is_straight && distinct_suits.size == 1\n\t\t\t@hand = 'STRAIGHT_FLUSH'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\n\t\t# Four of a kind\n\t\tif equal_values([0,1,2,3])\n\t\t\t@hand = 'FOUR_OF_KIND'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2,3,4])\n\t\t\t@hand = 'FOUR_OF_KIND'\n\t\t\tset_ranking_cards([1])\n\t\t\treturn\n\t\tend\n\t\t\n\t\t# Full house\n\t\tif equal_values([0,1,2],[3,4])\n\t\t\t@hand = 'FULL_HOUSE'\n\t\t\t@ranking_cards = [@cards[0]]\n\t\t\treturn\n\t\tend\n\t\tif equal_values([0,1],[2,3,4])\n\t\t\t@hand = 'FULL_HOUSE'\n\t\t\tset_ranking_cards([2])\n\t\t\treturn\n\t\tend\n\n\t\t# Flush\n\t\tif distinct_suits.size == 1\n\t\t\t@hand = 'FLUSH'\n\t\t\tset_ranking_cards([0,1,2,3,4])\n\t\t\treturn\n\t\tend\n\n\t\t# Straight\n\t\tif is_straight\n\t\t\t@hand = 'STRAIGHT'\n\t\t\tset_ranking_cards([0])\n\t\t\treturn\n\t\tend\n\n\t\t# 3 of a kind\n\t\tif equal_values([0,1,2])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([0,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2,3])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([1,0,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([2,3,4])\n\t\t\t@hand = 'THREE_OF_KIND'\n\t\t\tset_ranking_cards([2,0,1])\n\t\t\treturn\n\t\tend\n\n\n\t\t# 2 pair\n\t\tif equal_values([0,1],[2,3])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([0,2,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([0,1],[3,4])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([0,3,2])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2],[3,4])\n\t\t\t@hand = 'TWO_PAIR'\n\t\t\tset_ranking_cards([1,3,0])\n\t\t\treturn\n\t\tend\n\n\t\t# pair\n\t\tif equal_values([0,1])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([0,2,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([1,2])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([1,0,3,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([2,3])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([2,0,1,4])\n\t\t\treturn\n\t\tend\n\t\tif equal_values([3,4])\n\t\t\t@hand = 'PAIR'\n\t\t\tset_ranking_cards([3,0,1,2])\n\t\t\treturn\n\t\tend\n\n\t\t@hand = 'HIGH_CARD'\n\t\tset_ranking_cards([0,1,2,3,4])\n\n\tend", "def eval_7_card_hand( cards )\n 1\n end", "def high_card\n high_value = 0\n @grip.each do |card|\n new_value = FACE_VALUES.find_index(card.value)\n if new_value > high_value\n high_value = new_value\n end\n end\n FACE_VALUES[high_value]\n end", "def card_in_game\n (2..14).each {|r| (1..4).each { |i| @pack_of_card << [i, r] }}\n @cards = @pack_of_card.shuffle.take(7)\n # @hash_7_card is hash prepared for analyze combinations and the highest combination to win\n $hash_7_card = array_suit_rank\n end", "def identify\n \n return if @value > 0 # no need to do it twice!\n return if @cards.size < 5 # need at least 5 cards\n \n @cards.sort!\n \n #puts \"@total_face_value = #{@total_face_value}\"\n \n if is_flush? then \n #puts 'have a flush of some kind...' \n \n if @total_face_value == 60 then\n #puts \"it's a royal flush!\"\n @rank = ROYAL_FLUSH\n @value = @cards.max.face_value\n return\n end\n \n if is_straight? then\n #puts \"it's straight flush!\"\n @rank = STRAIGHT_FLUSH\n @value = @cards.max.face_value\n return\n end\n \n #puts \"it's a regular flush!\"\n @rank = FLUSH\n @value = @cards.max.face_value\n return\n end\n \n #puts 'not a flush'\n \n if is_straight? then\n #puts \"it's a straight!\"\n @rank = STRAIGHT\n @value = @cards.max.face_value\n return\n end\n \n # look for pairs\n (pairs, @unpaired_cards) = find_pairs()\n if pairs.empty? then\n # high card!\n #puts \"high card \" + high_card.to_s\n @rank = HIGH_CARD\n @value = @cards.max.face_value\n return\n end\n \n if pairs.size == 1 then\n paired_cards = pairs[0].size\n @value = pairs[0].max.face_value\n if paired_cards == 2 then\n #puts \"it's a single pair!\"\n @rank = PAIR\n elsif paired_cards == 3 then\n #puts \"it's a three of a kind!\"\n @rank = THREE_KIND\n elsif paired_cards == 4 then\n @rank = FOUR_KIND\n end\n return\n \n elsif pairs.size == 2 then\n paired_cards = pairs[0].size + pairs[1].size\n a = pairs[0].max.face_value\n b = pairs[1].max.face_value\n if a > b then\n @value = a\n elsif b > a then\n @value = b\n else\n # should never happen since it means the\n # pairs are of the same face value\n # e.g., two pairs of 6s\n @value = a\n end\n if paired_cards == 4 then\n #puts \"it's two pair!\"\n @rank = TWO_PAIR\n elsif paired_cards == 5 then\n #puts \"it's a full house!\"\n @rank = FULL_HOUSE\n # add faces of each pair for value\n if a > b then\n @value = a * 100 + b\n elsif b > a then\n @value = b * 100 + a\n end\n end\n return\n \n end\n \n # should never get here\n raise \"oh no, should never have come to this!\"\n \n end", "def high_ranking_cards\n high_cards = []\n @cards.each do|card|\n if card.rank >= 11\n high_cards << card\n end\n end\n high_cards\n end", "def determine_high_card hsh,num\n arr = []\n num1 = 2\n\n hsh.each_value {|card| arr << card}\n arr.flatten!\n arr.sort! {|x,y| y.number <=> x.number}\n while arr.length > num\n arr.pop\n end\n return arr\n end", "def possible_scores(cards)\n scores = [0]\n\n cards.each do |card|\n if card.face != 'Ace'\n scores.map! {|score| score + card.value} \n else\n new_scores = Array.new\n scores.each do |score|\n new_scores << score + 1\n new_scores << score + 11\n end\n scores = new_scores\n end\n end\n\n return scores.uniq.select {|score| score < 22}\nend", "def play_like_a_dummy\r\n # very brutal algorithm , always play the first card\r\n #card = @cards_on_hand.pop\r\n #p @cards_on_hand.size\r\n card = @cards_on_hand[0]\r\n if card\r\n # check if the played card take something\r\n #@table_cards\r\n \r\n #@log.debug \"Alg: cards on table #{@table_cards}\"\r\n list = @core_game.which_cards_pick(card, @table_cards)\r\n #p \"which cards pick: card #{card}, table #{@table_cards.join(\",\")}, list #{list.size}\"\r\n result = [card, list[0]].flatten\r\n return result\r\n end\r\n raise \"Error cards on hand #{@cards_on_hand.join(',')}\" \r\n end", "def determine_players_best_total(current_player)\n # @player1_hand = ['ace of spades', '5 of spades', '4 of spades', 'ace of diamonds']\n # @player1_hand = ['3 of spades', 'ace of hearts', '4 of spades', 'ace of clubs']\n # @player1_hand = ['ace of clubs', '2 of clubs', 'ace of hearts', '4 of hearts']\n sum_of_players_hand = 0\n number_of_aces_in_hand = 0\n if current_player == 1 then\n @player1_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n\n sum_of_players_hand = sum_of_players_hand - 10\n\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 1\n\n if current_player == 2 then\n @player2_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 2\n\n if current_player == 3 then\n @player3_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n# $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 3\n\n if current_player == 4 then\n @player4_hand.each {|x| #begin loop adding players hand\n card_value = @deckhash.fetch(x)\n if card_value == 1 then #adjust aces to a value of 11\n card_value = 11\n number_of_aces_in_hand = number_of_aces_in_hand + 1\n end #end of ace adjustment\n sum_of_players_hand = sum_of_players_hand + card_value\n } #end of loop adding players hand\n if sum_of_players_hand > 21 then #must set one or more aces back to one\n loop do\n if number_of_aces_in_hand == 0 then break end\n sum_of_players_hand = sum_of_players_hand - 10\n# $stdout.write(\"sum of players hand #{sum_of_players_hand} :\")\n if sum_of_players_hand < 22 then break end\n number_of_aces_in_hand = number_of_aces_in_hand - 1\n end #end of loop do\n end #end of sum_of_players_hand > 21\n end #end if current player = 4\n # ### This method returns sum of player's best hand\n return sum_of_players_hand\n end", "def best_leaveit_card(leave_it)\r\n @log.debug(\"calculate best_leaveit_card\") \r\n w_cards = []\r\n leave_it.each do |card_lbl|\r\n card_s = card_lbl.to_s # something like '_Ab'\r\n segno = card_s[2,1] \r\n\r\n curr_w = 0\r\n curr_w += 200 if card_s[2] == @briscola.to_s[2]\r\n curr_w += 500 if card_s[1] == \"A\"[0]\r\n curr_w += 400 if card_s[1] == \"3\"[0] \r\n curr_w += 300 if card_s[1] == \"R\"[0] \r\n curr_w += 280 if card_s[1] == \"C\"[0] \r\n curr_w += @deck_info.get_card_info(card_lbl)[:rank]\r\n\r\n w_cards << [card_lbl, curr_w ]\r\n end\r\n min_list = w_cards.min{|a,b| a[1]<=>b[1]}\r\n @log.debug(\"Best card to play on leave it cards is #{min_list[0]}, w_cards = #{w_cards.to_s}\")\r\n return min_list[0]\r\n end", "def high_ranking_cards\n\n cards.select do |card|\n card.rank >= 11\n end\n\n end", "def poker hands\n raise NoHandError if hands.empty?\n allmax(hands, method(:hand_rank))\nend", "def high_card \n\t\tcards.max\n\tend", "def high_card(hand)\n\t\thand_num = check_num(hand)\n\t\treturn hand_num.max\n\tend", "def high_ranking_cards\n\n cards.find_all do |card|\n card.rank >= 11\n end\n end", "def card_value\n card_values = cards.map { |card| card.straight_value }\n [4, 3, 2].each do |num|\n if card_values.any? { |value| card_values.count(value) == num }\n return card_values.select { |value| card_values.count(value) == num }.max\n end\n end\n card_values.max\n end", "def calculate_total hand\n\ttotal=0\n\tarray = hand.map {|e| e[1]}\n\tarray.each do |card|\n\t\t## face card \n\t\tif card == \"10\" || card ==\"J\" || card ==\"K\" || card ==\"Q\"\n\t\t\ttotal +=10\n\t\t## Ace card\t\n\t\telsif card ==\"A\"\n\t\t\ttotal += 11\n\t\telse \n\t\t\ttotal += card.to_i\n\t\tend\n\tend\n\thand.collect {|e| e[1]}.each do |card|\n\t\tif total >21 && card == \"A\"\n\t\t\ttotal -= 10\n\t\tend\n\tend\n\n\treturn total \nend", "def calculate_points(cards_in_hands)\n points = 0\n cards_without_ace = cards_in_hands.select {|card| card[1] != 'A'}\n cards_with_ace = cards_in_hands.select {|card| card[1] == 'A'}\n cards_without_ace.each do |card|\n if card[0].to_i !=0\n points += card[0].to_i\n else\n points += 10\n end\n end\n if cards_with_ace.empty?\n return points\n else\n ace_sets = [11, 1].repeated_permutation(cards_with_ace.length).to_a\n ace_sets_sum_arr = []\n ace_sets.each do |arr|\n arr_sum = 0\n arr.each {|v| arr_sum = arr_sum + v}\n ace_sets_sum_arr.push(arr_sum)\n end\n ace_sets_sum_arr.sort!.uniq!\n ace_sets_sum_arr.map! {|num| num + points}\n if ace_sets_sum_arr.include?(21)\n points = 21\n return points\n else\n lt_21_arr = ace_sets_sum_arr.select {|v| v < 21}\n gt_21_arr= ace_sets_sum_arr.select {|v| v > 21}\n if lt_21_arr.empty?\n points = gt_21_arr.first\n return points\n else\n points = lt_21_arr.last\n return points\n end\n end\n end\nend", "def sort_by_suit\n \tnew_hand = []\n while @cards.size > 0\n \tpos = 0 # position of minimal card\n \tc = @cards[0] # minimal card\n \t@cards.each_with_index do |card, index|\n \t\tc1 = card\n # puts \"c: #{c.inspect} and c1: #{c1.inspect}\"\n # puts \" and c1.suit: #{c1.suit}\"\n \t\tif (c1.suit < c.suit || (c1.suit == c.suit && c1.value < c.value) )\n \t\t\tpos = index\n \t\t\tc = c1\n \t end\n \tend\n\n \tremove_card_at(pos)\n \tnew_hand << c\n end\n\n @cards = new_hand\n end", "def decide(dealer)\n @dealer_card = dealer.visible_card[:value]\n @card_total = hands.last.total\n if values.include?(Ace)\n if (values.include?(2) || values.include?(3)) && [5,6].include?(@dealer_card)\n :doubledown #hit\n elsif values.include?(2) || values.include?(3)\n :hit\n elsif (values.include?(4) || values.include?(5)) && [4,5,6].include?(@dealer_card)\n :doubledown #hit\n elsif values.include?(4) || values.include?(5)\n :hit\n elsif values.include?(6) && [3,4,5,6].include?(@dealer_card)\n :doubledown #hit\n elsif values.include?(6)\n :hit\n elsif values.include?(7) && [2,7,8].include?(@dealer_card)\n elsif values.include?(7) && [3,4,5,6].include?(@dealer_card)\n :doubledown #stand\n elsif values.include?(7)\n :hit\n elsif values.include?(8) || values.include?(9)\n :stand\n elsif values.first == values.last\n :split\n end\n elsif values.first == values.last\n if [2,3,7].include?(values.first) && @dealer_card <= 7\n :split\n elsif [2,3,7].include?(values.first)\n :hit\n elsif values.first == 4 && [5,6].include?(@dealer_card)\n :split\n elsif values.first == 4\n :hit\n elsif values.first == 5 && #dealer_card <= 9\n :doubledown #hit\n elsif values.first == 5 \n :hit\n elsif values.first == 6 && @dealer_card <= 6\n :split\n elsif values.first == 6\n :hit\n elsif values.first == 8\n :split\n elsif values.first == 9 && [2,3,4,5,6,8,9].include?(@dealer_card)\n :split\n elsif values.first == 9\n :stand\n elsif values.first.to_i == 10\n :split\n end\n else\n if (5...8).include?(@card_total)\n :hit\n elsif @card_total == 9 && (3...6).include?(@dealer_card)\n :doubledown #hit\n elsif @card_total == 9\n :hit\n elsif @card_total == 10 && (2...9).include?(@dealer_card)\n :doubledown #hit\n elsif @card_total == 10\n :hit\n elsif @card_total == 11 && ((2...10)+[Jack, Queen, King]).include?(@dealer_card)\n :doubledown #hit\n elsif @card_total == 11\n :hit\n elsif @card_total == 12 && [4,5,6].include?(@dealer_card)\n :stand\n elsif @card_total == 12\n :hit\n elsif (13...16).include?(@card_total) && @dealear_card <= 6\n :stand\n elsif (13...16).include?(@card_total) && (@dealer_card >= 7 || @dealer_card.is_a?(Ace))\n :hit\n elsif @card_total == 17\n :stand\n end\n end\n end", "def high_card\n @cards.sort[-1]\n end", "def calc_hand_total(cards)\r\n total = 0\r\n numbers_only_array = cards.map {|g| g[0]}\r\n numbers_only_array.each do |h|\r\n if h == 'ace'\r\n total += 11\r\n elsif h.to_i == 0\r\n total += 10\r\n else\r\n total += h.to_i\r\n end\r\n end\r\n\r\n numbers_only_array.select {|k| k == \"ace\"}.count.times do\r\n total -= 10 if total > 21 \r\n end\r\n\r\n total\r\nend", "def high_card\n @hand.max_by{|card| card.point}.point.to_i\n end", "def value_of_hand(array_of_cards)\n faces = {\"A\" =>11,\n \"2\" => 2, \n \"3\" => 3,\n \"4\" => 4,\n \"5\" => 5,\n \"6\" => 6,\n \"7\" => 7,\n \"8\" => 8,\n \"9\" => 9,\n \"10\" => 10,\n \"J\" => 10,\n \"Q\" => 10,\n \"K\" => 10\n }\n total_value = 0\n num_aces = 0\n array_of_cards.each do |c|\n #cards are in string format, e.g. \"J of diamonds\"\n face = c.split[0]\n value = faces[face]\n total_value += value\n num_aces += 1 if face == \"A\"\n end\n #correct for Aces -- BORROWED THIS LOGIC FROM TEACHER'S CODE\n num_aces.times do\n total_value -= 10 if total_value > 21\n end\n return total_value\nend", "def bestCand(voterOpinion, candList)\r\n\ttopCands = Array.new # []\r\n\ttopScore = nil\r\n\t\r\n\t# for each element in the candList array, calling the current element cand.\r\n\t#\tthe {/} are the same as the do/end shown in the Main section. \r\n\t#\tIncluded here to show the availabailty for different style choices\r\n\tcandList.each { |cand| \r\n\t\t\t\t\tcurrScore = getCandScore(voterOpinion,cand.drop(1))\r\n\t\t\t\t\tif topScore.nil? then\r\n\t\t\t\t\t\ttopScore = currScore\r\n\t\t\t\t\tend\r\n\t\t\t\t\tunless currScore < topScore # essentially if !(currScore < topScore)\r\n\t\t\t\t\t\t\r\n\t\t\t\t\t\tif currScore == topScore\r\n\t\t\t\t\t\t\ttopCands.push(cand[0])\r\n\t\t\t\t\t\telse # must be greater\r\n\t\t\t\t\t\t\ttopScore = currScore\r\n\t\t\t\t\t\t\ttopCands = [cand[0]]\r\n\t\t\t\t\t\tend\r\n\t\t\t\t\tend\r\n\t\t\t\t}\r\n\t\t\t\t\r\n\treturn topCands\r\nend", "def calculate_score(hand_of_cards)\n card_values = hand_of_cards.map{|card_value| card_value[1]}\n total = 0 \n card_values.each do |card_value| \n if card_value == \"ACE\"\n total+= 11\n elsif card_value.to_i == 0 #For suits ie Jester, Queen\n total+= 10\n else \n total+= card_value.to_i\n end\n end \n\n#adjust for Aces\n card_values.select{|card| card == \"ACE\"}.count.times do \n total-=10 if total > 21\n end \n total\nend", "def eval_5_cards( c1, c2, c3, c4, c5)\n 1\n end", "def card_ranks(cards)\n ranks = cards.map { |card| '--23456789TJQKA'.index(card[0]) }\n ranks.sort! { |a, b| b <=> a }\n if ranks == [14, 5, 4, 3, 2]\n [5, 4, 3, 2, 1]\n else\n ranks\n end\nend", "def cards_needed\n [@size, 5].min\n end", "def tie_breaker_multi hand2\n values1 = values.sort.reverse\n values2 = hand2.values.sort.reverse\n 4.downto(1).each do |num|\n pick1 = values1.select {|card| values1.count(card) == num}\n pick2 = values2.select {|card| values2.count(card) == num}\n return pick1 <=> pick2 if pick1 != pick2\n end\n 0 # hands are identical\n end", "def hand?\n @cards_by_score.length == 5\n end", "def full_house?\n return unless size >= 5\n\n the_cards = cards_by_rank.values\n the_cards[0].count >= 3 && the_cards[1].count >= 2\n end", "def eval_5_cards(c1, c2, c3, c4, c5)\n begin\n index = PTable[c1]*PTable[c2]*PTable[c3]*PTable[c4]*PTable[c5]\n if FlushTable[FlushTable[FlushTable[FlushTable[FlushTable[0][c1]][c2]][c3]][c4]][c5] == 5\n EqClLookup[index].nonflush\n else\n EqClLookup[index].flush\n end\n rescue\n NULL_EQ_CLASS\n end\n end", "def rank_starting_hand\r\n sorted_hand = @hole_cards.sort_by { |card| card.rank } # [4,2] => [2,4]\r\n\r\n # Shorthand variables for two cards in hand\r\n (first,second) = [sorted_hand[0],sorted_hand[1]]\r\n\r\n suited = first.suit == second.suit # True if cards have same suit\r\n paired = first.rank == second.rank # True if cards have same rank\r\n connected = first.rank + 1 == second.rank # True if cards have consecutive ranks\r\n\r\n # Check for playable hands and return their rank\r\n # (Some of these checks aren't necessary but are included for readibility)\r\n case first.rank\r\n when 8 then return 14 if paired # Pocket Eights\r\n when 9 then return 9 if paired # Pocket Nines\r\n when 10\r\n return 6 if paired # Pocket Tens\r\n return 20 if second.rank == 12 and suited # Queen-Ten Suited\r\n return 16 if second.rank == 13 and suited # King-Ten Suited\r\n return 12 if second.rank == 14 and suited # Ace-Ten Suited\r\n when 11\r\n return 4 if paired # Pocket Jacks\r\n return 17 if second.rank == 12 and suited # Queen-Jack Suited\r\n return 15 if second.rank == 13 and suited # King-Jack Suited\r\n if second.rank == 14\r\n return suited ? 10 : 18 # Ace-Jack Suited/Offsuit\r\n end\r\n when 12\r\n return 3 if paired # Pocket Queens\r\n if second.rank == 13\r\n return suited ? 11 : 19 # King-Queen Suited/Offsuit\r\n elsif second.rank == 14\r\n return suited ? 8 : 13 # Ace-Queen Suited/Offsuit\r\n end\r\n when 13\r\n return 2 if paired # Pocket Kings\r\n if second.rank == 14\r\n return suited ? 5 : 7 # Ace-King Suited/Offsuit\r\n end\r\n when 14 then return 1 if paired # Pocket Aces\r\n end\r\n # Still played if the hand is suited, paired, or connected, otherwise not played\r\n return (suited or paired or connected) ? 21 : -1\r\n end", "def get_hand_score\n score = 0\n \n # Add up score of non-aces\n values = hand.map{|card| card.value}\n values.each do |val|\n if Array(2..10).include?(val.to_i)\n score += val.to_i\n elsif [\"J\", \"Q\", \"K\"].include?(val)\n score += 10\n end\n end\n\n # deal with the aces\n values.count(\"A\").times do\n if score + 11 <= 21\n score += 11\n else\n score += 1\n end\n end\n\n return score\n end", "def sort_by_value\n \tnew_hand = []\n \twhile @cards.size > 0\n \t\tpos = 0\n \t\tc = @cards[0]\n \t\t@cards.each_with_index do |card, index|\n \t\t\tc1 = card\n \t\t\tif (c1.value < c.value || (c1.suit == c.suit && c1.suit < c.suit) )\n pos = index\n c = c1\n end\n end\n\n remove_card_at(pos)\n new_hand << c\n end\n @cards = new_hand\n\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 determine_playable_cards\n playable_cards = []\n hand.each do |card_in_hand|\n if card_in_hand[\"cost\"] <= @mana_available\n playable_cards.push(card_in_hand)\n end \n end\n if mana_available >= 2\n playable_cards.push(\"hero ablity\")\n end\n playable_cards\n end", "def top_three_recipes\n recipe_cards.max_by(3) {|recipe_cards| recipe_cards.rating}\n end", "def high_ranking_cards(cut_off = 10)\n high_cards = []\n for card in self.cards\n if card.rank > cut_off\n high_cards.append(card)\n end\n end\n\n return high_cards\n end", "def value_of_hand(hand)\n collection_of_card_values = hand.collect {|index| index[1]}\n card_values = collection_of_card_values.inject{|sum,next_card| sum + next_card }\n if collection_of_card_values.include?(1) && card_values < 12\n card_values += 10\n end\n card_values\nend", "def play_as_master_first\r\n @pending_points = 0\r\n w_cards = []\r\n curr_points_me = @team_mates.inject(0){ |result, name_pl| result + @points_segno[name_pl] }\r\n @cards_on_hand.each do |card_lbl|\r\n card_s = card_lbl.to_s # something like '_Ab'\r\n segno = card_s[2,1] # character with index 2 and string len 1\r\n is_card_lbl_briscola = card_s[2] == @briscola.to_s[2] \r\n curr_w = 0\r\n curr_w += 70 if is_card_lbl_briscola\r\n # check if it is an asso or 3\r\n curr_w += 220 if card_s[1] == \"A\"[0]\r\n curr_w += 200 if card_s[1] == \"3\"[0] \r\n if card_s =~ /[24567]/\r\n # liscio value\r\n lisc_val = (card_s[1] - '0'[0]).to_i\r\n curr_w += 50 + lisc_val\r\n end\r\n curr_w += 60 if card_s[1] == \"F\"[0]\r\n # check horse and king cards\r\n if card_s[1] == \"C\"[0]\r\n if is_mariazz_possible?(segno)\r\n curr_w += 90 + 70\r\n else\r\n curr_w += 30\r\n end\r\n end \r\n if card_s[1] == \"R\"[0]\r\n if is_mariazz_possible?(segno)\r\n curr_w += 100 + 70\r\n else\r\n curr_w += 20\r\n end\r\n end\r\n # penalty for cards wich are not stroz free\r\n curr_w += 10 * @strozzi_on_suite[segno].size\r\n if (curr_points_me + @deck_info.get_card_info(card_lbl)[:points]) > @target_points\r\n curr_w -= (@deck_info.get_card_info(card_lbl)[:points] + 100)\r\n curr_w -= 200 if is_card_lbl_briscola\r\n curr_w -= 1000 if is_card_lbl_briscola and card_s[1] == \"A\"[0]\r\n end\r\n \r\n w_cards << [card_lbl, curr_w ] \r\n end\r\n # find a minimum\r\n #p w_cards\r\n min_list = w_cards.min{|a,b| a[1]<=>b[1]}\r\n @log.debug(\"Play as first: best card#{min_list[0]}, (w_cards = #{w_cards.inspect})\")\r\n return min_list[0]\r\n end", "def high_card?\n cards_by_rank.count == @size\n end", "def get_card\n all_cards = self.deck.cards\n correct_cards = self.guesses.where(correct: true).map { |guess| guess.card }\n (all_cards - correct_cards).shuffle.sample\n end", "def cards_to_score(cards)\n \n total = 0\n cards_num = []\n\n cards.each { |card| cards_num.push(card % 13) }\n\n cards_num.sort.reverse.each do |num|\n if num >= 9 #9, 10, 11, 12 means 10, J, Q, K\n total = total + 10\n elsif num > 0 #which means 2, 3, 4, 5, 6, 7, 8, 9\n total = total + num + 1\n end\n end\n\n a_count = cards_num.count(0)\n\n total = total + a_count\n\n a_count.times do\n total = total + 10 if total <= 11\n end\n\n return total\nend", "def round()\n\t\t#array of used cards\n\t\t@used = []\n\t\t#loop through players array\n\t\tfor i in 0...@num_players\n\t\t\t#reset player variables\n\t\t\t@players[i].reset()\t\n\t\t\t#populate hand\n\t\t\t@players[i].populate(@used,52,5)\n\t\t\t#get hand rank\n\t\t\t@players[i].get_rank()\n\t\t\t#add hand to array of used cards\n\t\t\t@used += @players[i].hand\n\t\tend\n\t\t#increment round number\n\t\t@roundnum += 1 \n\tend", "def calculate_primiera(hand1, hand2)\r\n res = [0,0]\r\n #p hand1\r\n #p hand2\r\n # first get the max card on each suit\r\n max_pt = []\r\n [hand1, hand2].each do |curr_hand|\r\n # reset max\r\n max_pt << {:D => 0, :B => 0, :C => 0, :S => 0 }\r\n curr_hand.each do |lbl|\r\n points = @deck_information.get_card_points(lbl)\r\n suit = @deck_information.get_card_segno(lbl)\r\n if points > max_pt.last[suit]\r\n # max on suit\r\n max_pt.last[suit] = points\r\n end\r\n end\r\n #p max_pt.last\r\n end\r\n # using inject, 0 is the first value of the accumulator sum, tha assume the\r\n # value of the block provided. x assume each value of the max_pt.first\r\n # x becomes a pair like max_pt.first.each{|k,v|}. For example x = [:S, 21]\r\n arr_sum_points = []\r\n max_pt.each do |maxitem|\r\n arr_sum_points << maxitem.inject(0) do |sum, x|\r\n if x[1] > 0 and sum >= 0 \r\n sum + x[1]\r\n else\r\n # this is a particular case, we don't have points on a particular suit\r\n # in this case there is no primiera. Then stay on -1.\r\n sum = -1\r\n end\r\n end\r\n end\r\n #p arr_sum_points\r\n if arr_sum_points[0] > arr_sum_points[1]\r\n #primiera on the first hand\r\n res[0] = 1\r\n res[1] = 0\r\n elsif arr_sum_points[0] == arr_sum_points[1]\r\n # same points, primiera is not assigned\r\n res[0] = 0\r\n res[1] = 0\r\n else\r\n #primiera on the second hand\r\n res[0] = 0\r\n res[1] = 1\r\n end \r\n #p res\r\n return res\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 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 cpu_select\n highest, hidx = 0, 0\n\n @cpu_hand.cards.each_with_index do |c, idx|\n val = c.value\n\n if @total + val <= 31\n add_cpu_card_to_set( idx ) && return if excellent?( c )\n\n highest, hidx = val, idx if val > highest\n end\n end\n\n # No excellent card, so use the highest layable card\n\n add_cpu_card_to_set( hidx )\n end", "def get_score (cards)\n\t\tscore = 0\n\t\tcards.each do |card|\n\t\t\tmeasure = card[0]\n\t\t\tscore += @score[measure]\n\t\tend\n\t\tscore\n\tend", "def get_score\n flush = is_flush?\n straight = is_straight?\n pairs = pairs?\n\n return 45 if pairs.size == 1 && pairs[0][1] == 5\n return 44 if flush && straight\n return 31 + pairs[0][0] - 2 if pairs.size == 1 && pairs[0][1] == 4\n return 30 if pairs.size == 2 && (pairs[0][1] + pairs[1][1]) == 5\n return 29 if flush\n return 28 if straight\n return 15 + pairs[0][0] - 2 if pairs.size == 1 && pairs[0][1] == 3\n return 14 if pairs.size == 2\n return 1 + pairs[0][0] - 2 if pairs.size == 1\n -14 + high_card #high card return\n end", "def calculatetotal(cards) # calculating the total of the two cards dealt, first to player then to dealer\n array = cards.map {|card| card[0]} # using the map method to lay out all the cards which are like so [[\"A\", \"S\"], [\"5\", \"C\"]]\n # We then only take the first element of the array and initialize that to the total\n total = 0 # total at the outset is zero\n array.each do |value|\n if value == \"A\" # in the event you get an ace card. \"A\" is as is unlike the bottom ones below\n total += 11 # total should now increase to 11\n elsif value.to_i == 0 # this is to cover for getting J, K, Q cards which defaults value to integer is zero\n total += 10\n else\n total += value.to_i\n end\nend # finished the array\n\n# Correcting Aces in case there are more than one. It should convert aces to 1 instead of 11 if total is more than 21\narray.select {|card| card.include?(\"A\")}.count.times do\n total -= 10 if total > 21\nend\ntotal # don't forget to include total here before exiting. IMPORTANT!!\nend", "def score\n score = 0\n aces_count = 0\n @hand_contents.each do |card|\n if card.type == :face\n score += 10\n elsif card.type == :ace\n aces_count += 1\n score += 11\n elsif card.type == :number\n score += card.rank.to_i\n end\n end\n\n while score > 21 && aces_count > 0\n score -= 10\n aces_count -= 1\n end\n score\n end", "def top_three_recipes\n self.find_user_recipe_cards.sort_by{|rcard| rcard.rating}.reverse![0..2]\n end", "def winning_player\n played_cards.max_by { |_, card| card_scores[card] }.first\n end", "def cards_sorted_ace_high\n @cards_sorted_ace_high ||= @cards.sort!.reverse!\n end", "def order_by_value\n @hand = @hand.sort_by{|card| card.point }\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 checkHand\n possible_hands = possibleHandValues\n if possible_hands.include?(21)\n return BLACKJACK\n elsif possible_hands.empty?\n return LOST\n else\n return possible_hands.max\n end\n end", "def blackjack_score(hand)\n allowed_cards = %w[ 2 3 4 5 6 7 8 9 10 Jack Queen King Ace ]\n\n# Validate input\n if hand.length > 5\n raise ArgumentError.new(\"Your hand contains more than 5 cards.\")\n end \n\n result = hand.all? {|card| allowed_cards.include?(card)}\n if !result\n raise ArgumentError.new(\"Invalid card value.\")\n end \n\n# Calculate score \n score = 0\n hand.each do |card|\n if card.length <= 2\n points = card.to_i\n score += points\n elsif card.length == 3 \n score += 1\n else \n score += 10 \n end \n end\n\n if score <= 11 && hand.include?(\"Ace\")\n score += 10\n end\n\n# Validate result\n if score > 21\n raise ArgumentError.new(\"#{score} is greater than 21, you lose!\")\n end\n\n return score \nend", "def best_picks\n self.picks.sort_by{|pick| pick.points}.reverse!.first(5)\n end", "def count_score(array)\n total = 0\n sorted_hand = array.sort_by { |x| value(x) }\n sorted_hand.each do |x|\n if value(x) == 11 && total >= 11\n total += 1\n else\n total += value(x)\n end\n end\n total\nend", "def prepare_deck\n (1..104).each do |i|\n v = [1, 2, 3, 5, 7]\n if i == 55\n @deck[i] = v[4]\n elsif (i % 11 == 0.0) && i != 55\n @deck[i] = v[3]\n elsif (i % 10 == 0.0) && i != 55\n @deck[i] = v[2]\n elsif (i % 5 == 0.0) && i != 55\n @deck[i] = v[1]\n else\n @deck[i] = v[0]\n end\n end\n end", "def find_hand_category(hand)\r\n \t\tif hand.size == 7\r\n \t\t\t# really not good!! have to put royal flush, straight flush\r\n \t\t\t# and straigh together! \r\n \t\t\tif num_suits(hand).max >= 5 && num_faces(hand)[0..4] == Array.new(5,1) \r\n \t\t\t\t@hand_category = \"Royal Flush\"\r\n \t\t\telsif num_faces(hand).max >= 4\r\n \t\t\t\t@hand_category = \"Four of a kind\"\r\n \t\t\telsif num_faces(hand).max == 3\r\n \t\t\t\t@hand_category = \"Three of a kind\"\r\n \t\t\telsif num_faces(hand).max == 2\r\n \t\t\t\t@hand_category = \"pair\"\r\n \t\t\telsif num_faces(hand).sort.last>=3 && num_faces(hand).sort[12]>=2\r\n \t\t\t\t@hand_category = \"Full House\"\r\n \t\t\telsif num_faces(hand).sort.last == 2 && num_faces(hand).sort[12]==2\r\n \t\t\t\t@hand_category = \"two pairs\"\r\n \t\t\tend \r\n \t\tend\r\n \t\treturn @hand_category\r\n \tend", "def look_ahead(board, current_hand, ai_hand)\n #n = NegamaxAgent.new(board, current_hand, ai_hand)\n #n_suggested_move = n.invoke\n #n_suggested_card = n_suggested_move.first\n #n_x = n_suggested_move[1]\n #n_y = n_suggested_move[2]\n #n_s = n_suggested_move[3]\n\n #puts \"DEBUG: negamax suggested #{@player_hand.key(n_suggested_card)} @ #{n_x + 1}, #{n_y + 1} with score of #{n_s}\"\n #return\n\n available_cards = current_hand.values.compact\n available_spaces = board.open_spaces\n possible_moves = available_cards.product(available_spaces)\n\n best_moves = []\n value_of_best_move = -10\n\n possible_moves.each do |card, space|\n x, y = space\n value = board.next_state(card, x, y).score\n if value > value_of_best_move\n best_moves = [[card, x, y]]\n value_of_best_move = value\n elsif value == value_of_best_move\n \tbest_moves << [card, x, y]\n end\n end\n\n chosen_move = best_moves.sample\n card, x, y = chosen_move\n\n puts \"HINT: placing #{current_hand.key(card).rstrip} at #{x+1}, #{y+1} gives a good score of #{value_of_best_move}\"\n end", "def initialize\n @cards = ((1..6).to_a * 3 + (7..10).to_a * 4 + (11..17).to_a * 2 + (18..25).to_a).shuffle\n end", "def sort\n @cards.sort_by {|card| card.poker_value}\n end", "def hand_rank(hand)\n ranks = card_ranks(hand) # card_ranks return the ranks in sorted order\n\n if straight(ranks) && flush(hand)\n return [8, ranks.max] # 2 3 4 5 6 => [8, 6], 6 7 8 9 T => [8, T]\n elsif kind(4, ranks)\n return [7, kind(4, ranks), kind(1, ranks)] # 9 9 9 9 3 => [7, 9, 3]\n elsif kind(3, ranks) && kind(2, ranks) # 8 8 8 K K => [6, 8, 13]\n return [6, kind(3, ranks), kind(2, ranks)]\n elsif flush(hand)\n return [5, ranks]\n elsif straight(ranks)\n return [4, ranks.max]\n elsif kind(3, ranks)\n return [3, kind(3, ranks), ranks]\n elsif two_pair(ranks)\n return [2, kind(2, ranks), ranks]\n elsif kind(2, ranks)\n return [1, kind(2, ranks), ranks]\n else\n return [0, ranks]\n end\nend", "def score(cards)\n\nend", "def computer_ai_3\n rock = 0\n paper = 0\n scissors = 0\n most_played = \"r\"\n choice = \"p\"\n\n # Find which moves have been played the most.\n \n @human_moves.each do |move|\n if move == 'r'\n rock = rock + 1\n elsif move == 'p'\n paper = paper + 1\n elsif move == 's'\n scissors = scissors + 1\n end\n end\n\n if rock > paper && rock > scissors\n most_played = \"r\"\n elsif paper > rock && paper > scissors\n most_played = \"p\"\n elsif scissors > paper && scissors > rock \n most_played = \"s\"\n else\n #choose random if they tie\n choices =['r', 'p', 's']\n most_played = choices.sample\n end\n\n #play the hand that beats the human move.\n if most_played == 'r'\n choice = 'p'\n elsif most_played == 'p'\n choice = 's'\n elsif most_played == 's'\n choice = 'r'\n end\n\n return choice\n end", "def play_as_master_second\r\n card_avv_s = @card_played[0].to_s\r\n card_avv_info = @deck_info.get_card_info(@card_played[0])\r\n max_points_take = 0\r\n max_card_take = @cards_on_hand[0]\r\n min_card_leave = @cards_on_hand[0]\r\n min_points_leave = @deck_info.get_card_info(min_card_leave)[:points] + card_avv_info[:points]\r\n take_it = []\r\n leave_it = []\r\n # build takeit leaveit arrays\r\n @cards_on_hand.each do |card_lbl|\r\n card_s = card_lbl.to_s\r\n bcurr_card_take = false\r\n card_curr_info = @deck_info.get_card_info(card_lbl)\r\n if card_s[2] == card_avv_s[2]\r\n # same suit\r\n if card_curr_info[:rank] > card_avv_info[:rank]\r\n # current card take\r\n bcurr_card_take = true\r\n take_it << card_lbl\r\n else\r\n leave_it << card_lbl\r\n end\r\n elsif card_s[2] == @briscola.to_s[2]\r\n # this card is a briscola \r\n bcurr_card_take = true\r\n take_it << card_lbl\r\n else\r\n leave_it << card_lbl\r\n end\r\n # check how many points make the card if it take\r\n points = card_curr_info[:points] + card_avv_info[:points]\r\n if bcurr_card_take\r\n if points > max_points_take\r\n max_card_take = card_lbl\r\n max_points_take = points\r\n end\r\n else\r\n # leave it as minimum\r\n if points < min_points_leave or (points == min_points_leave and\r\n card_curr_info[:rank] < @deck_info.get_card_info(min_card_leave)[:rank] )\r\n min_card_leave = card_lbl\r\n min_points_leave = points\r\n end\r\n end\r\n end\r\n #p min_points_leave\r\n #p min_card_leave\r\n curr_points_me = 0\r\n @team_mates.each{ |name_pl| curr_points_me += @points_segno[name_pl] }\r\n tot_points_if_take = curr_points_me + max_points_take\r\n curr_points_opp = 0\r\n @opp_names.each{ |name_pl| curr_points_opp += @points_segno[name_pl] }\r\n \r\n #p take_it\r\n #p leave_it\r\n #p max_points_take\r\n #p min_points_leave\r\n if take_it.size == 0\r\n #take_it is not possibile, use leave it\r\n @log.debug(\"play_as_master_second, apply R1 #{min_card_leave}\")\r\n return min_card_leave \r\n end\r\n max_card_take_s = max_card_take.to_s\r\n if tot_points_if_take >= @target_points\r\n # take it, we win\r\n @log.debug(\"play_as_master_second, apply R2 #{max_card_take}\")\r\n return max_card_take\r\n end\r\n if @pending_points > 0\r\n card_to_play = best_taken_card(take_it)[0]\r\n @log.debug(\"play_as_master_second, apply R2-decl #{card_to_play}\")\r\n return card_to_play \r\n end\r\n if max_card_take_s[2] == @briscola.to_s[2]\r\n # card that take is briscola, pay attention to play it\r\n if max_points_take >= 20\r\n @log.debug(\"play_as_master_second, apply R3 #{max_card_take}\")\r\n return max_card_take\r\n end\r\n elsif max_points_take >= 10\r\n # take it, strosa!\r\n @log.debug(\"play_as_master_second, apply R4 #{max_card_take}\")\r\n return max_card_take\r\n end\r\n best_leave_it = nil\r\n if leave_it.size > 0\r\n best_leave_it = best_leaveit_card(leave_it)\r\n end\r\n if best_leave_it == nil\r\n card_to_play = best_taken_card(take_it)[0]\r\n @log.debug(\"play_as_master_second, apply R9 #{card_to_play} - force taken\")\r\n return card_to_play\r\n end\r\n points_best_leave = @deck_info.get_card_info(best_leave_it)[:points]\r\n if card_avv_info[:points] == 0 and points_best_leave == 0\r\n @log.debug(\"play_as_master_second, apply R10 #{best_leave_it} \")\r\n return best_leave_it\r\n end\r\n if take_it.size > 0\r\n w_and_best = best_taken_card(take_it)\r\n # we can take it\r\n if curr_points_opp > 29 and max_points_take > 0 and take_it.size > 1\r\n # try to take it\r\n card_to_play = w_and_best[0]\r\n @log.debug(\"play_as_master_second, apply R5 #{card_to_play}\")\r\n return card_to_play\r\n end\r\n if curr_points_opp > 36 and (card_avv_info[:points] > 0 or points_best_leave > 0)\r\n # try to take it\r\n card_to_play = w_and_best[0]\r\n @log.debug(\"play_as_master_second, apply R11 #{card_to_play}\")\r\n return card_to_play\r\n end\r\n if points_best_leave > 2 or min_points_leave > 3 and w_and_best[1] < 320\r\n # I am loosing too many points?\r\n card_to_play = w_and_best[0]\r\n @log.debug(\"play_as_master_second, apply R6 #{card_to_play}\")\r\n return card_to_play\r\n end\r\n end \r\n # leave it\r\n if best_leave_it\r\n @log.debug(\"play_as_master_second, apply R7 #{best_leave_it}\")\r\n return best_leave_it\r\n end\r\n \r\n @log.debug(\"play_as_master_second, apply R8 #{min_card_leave}\")\r\n return min_card_leave \r\n #crash\r\n end", "def evaluate(hand) \n value = 0\n numerical_value = hand.map { |card| card[0]} \n numerical_value.each do |x| \n if ['K', 'Q', 'J'].include?(x)\n value += 10\n elsif x == 'A'\n value += 11\n else\n value += x.to_i\n end\n end\n \n hand.select {|x| x[0] == 'A'}.count.times do \n if value > 21\n value -= 10\n end\n end\n value\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 sort_cards_by_same_value()\r\n\t\tresult=Array.new\r\n\t\tfor i in 2..14\r\n\t\t\tresult[i]=CardList.new\r\n\t\tend\r\n\t\t@list.each{|x| result[x.get_value].add_card(x)}\r\n\t\treturn result\r\n\tend", "def rule_1 *cards\n cards.max + cards.raw_integer_value\n end", "def value()\n sum = 0\n # Partition the array by string and integer then reverse to put aces at back\n @cards.partition{|x| x.is_a? String}.map(&:sort).flatten.reverse_each do |i|\n if [\"Q\", \"J\", \"K\"].include?(i)\n sum += 10\n elsif i == \"A\"\n if sum + 11 > 21\n sum += 1\n else\n sum += 11\n end\n else \n sum += i\n end\n end \n return sum\n end" ]
[ "0.7607686", "0.7482673", "0.7390467", "0.73692095", "0.73263884", "0.7233955", "0.706368", "0.70279825", "0.7026328", "0.692564", "0.6915625", "0.6875506", "0.6858767", "0.68203574", "0.68152577", "0.6812981", "0.68022346", "0.6781045", "0.6765555", "0.6751201", "0.66803753", "0.6672963", "0.6578583", "0.6564463", "0.6554491", "0.6538948", "0.65348047", "0.6533407", "0.6524254", "0.65206516", "0.6474862", "0.64699715", "0.6465026", "0.6460259", "0.6411997", "0.64066637", "0.64003164", "0.63784266", "0.6359544", "0.63547796", "0.63381135", "0.63324267", "0.6321672", "0.6304067", "0.630282", "0.6302282", "0.6282016", "0.62718534", "0.6257517", "0.62553257", "0.6240115", "0.6239048", "0.6221215", "0.6218709", "0.62122995", "0.6209072", "0.6182935", "0.61794466", "0.617875", "0.61689067", "0.6165242", "0.6157517", "0.6140789", "0.6140363", "0.6131569", "0.6127559", "0.6125515", "0.612243", "0.61153567", "0.611507", "0.6105295", "0.6087564", "0.6079665", "0.6074798", "0.60681486", "0.6056181", "0.6043001", "0.6041696", "0.6009474", "0.59977037", "0.5985899", "0.5979557", "0.597776", "0.59623116", "0.5960822", "0.59580594", "0.59537023", "0.5951767", "0.5951573", "0.59467006", "0.5942693", "0.5935654", "0.5934794", "0.5933546", "0.59318256", "0.59278363", "0.59141415", "0.5906799", "0.5899706", "0.5899505" ]
0.70128715
9
TODO: check that this works correctly when creating a member's first photo_album from photos/new
def set_name_as_untitled if name.blank? untitled_count = attachable ? attachable.photo_albums.untitled.size : self.class.without_attachable.untitled.size self.name = "#{UNTITLED_NAME} #{untitled_count + 1}" end true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n \n @album = @user.albums.new(params[:album])\n \n if @album.save\n flash[:notice] = 'User was successfully created.'\n if params[:album][:avatar].blank?\n redirect_to @album\n else\n \n render :action => 'cropping'\n end\n else\n render :action => 'new'\n end\n end", "def create_photo(album_id, photo_id, file, filename)\n \n end", "def create \n \n respond_to do |format|\n @photo_album = current_user.photo_albums.build(params[:photo_album])\n if @photo_album.save\n flash[:notice] = 'Новый альбом создан.'\n format.html {\n # if current_user.photo_albums.size > 1\n # redirect_to(@photo_album)\n # else\n redirect_to(new_photo_path)\n # end\n }\n format.xml { render :xml => @photo_album, :status => :created, :location => @photo_album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @photo_album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @album = current_user.albums.build(album_params)\n \n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end", "def profileAlbum\n aid = self.albums.select{|a| a['name'].include?('Profile')}[0]['id']\n self.fbCall(\"/#{aid}/photos\")\n end", "def store_owner_id\n self.user_id = self.album.user_id\n end", "def create\n file = upload_params;\n file[:album_id]=params[:photo][:album_id];\n @photo = Photo.create(file)\n\n end", "def create\n # photo = photo.create! params.require(:photo)\n @photo = Photo.new(photo_params)\n @photo.album_id = params[:album_id]\n @photo.user_id = current_user.id\n # @photo.pictures.attach(params[:photo][:picture])\n respond_to do |format|\n if @photo.save(validate: false)\n format.html { redirect_to album_photos_path , notice: \"Photo was successfully created.\" }\n format.json { render :show, status: :created, location: @photo }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = current_user.albums.build(params[:album])\n if @album.save\n flash[:notice] = 'Album was successfully created.'\n redirect_to(album_pictures_path(@album))\n else\n render :action => \"new\"\n end\n end", "def set_album_photo\n @album_photo = AlbumPhoto.find(params[:id])\n @album = Admin::Album.find(params[:album_id])\n end", "def create\n @album = current_user.albums.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'You created a #Album. Now share your #album around the internets' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @Album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album_ownership = AlbumOwnership.new\n @album_ownership.album = @album\n @album_ownership.user = current_user\n\n unless @album_ownership.save\n render json: @album_ownership.errors, status: :unprocessable_entity\n end\n end", "def create\n @photo = Photo.new(params[:photo])\n @photo.user_id=session[:user_id]\n @photo.album_id= params[:photo][:album_id]\n respond_to do |format|\n if @photo.save\n format.html { redirect_to @photo, notice: 'Photo was successfully created.' }\n format.json { render json: @photo, status: :created, location: @photo }\n else\n format.html { render action: \"new\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \t@album = Album.find(params[:album_id])\n \t@photo = @album.photos.create!(params[:photo])\n \tredirect_to @album, :notice => 'Photo created'\n end", "def create\n @album = current_user.albums.build(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @photoalbum = Photoalbum.new\n end", "def create\n \t@album = Album.find(params[:album_id])\n @photo = Photo.new(params[:photo])\n @photo.album = @album\n @photo.person = Person.find(current_person.id)\n\n respond_to do |format|\n if @photo.save\n \t@goto_page = @photo.pageForUpdate(:id, 5)\n \tif @goto_page < 1\n \t\t@goto_page = 1\n \tend\n format.html { redirect_to(album_photos_url(@album, :page => @goto_page), :notice => 'Photo was successfully created.') }\n else\n format.html { render :action => \"new\" }\n end\n end\n end", "def create\n @album = Album.find(params[:album_id])\n @photo = @album.photos.new(params[:photo])\n\n respond_to do |format|\n if @photo.save\n format.html { redirect_to album_photo_path(@album,@photo), :notice => 'Photo was successfully created.' }\n format.json { render :json => @photo, :status => :created, :location => @photo }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @photo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(album_params)\n @album.owner = @current_owner\n @album.owner_id = @current_owner.id\n if @album.creation_date.blank?\n @album.creation_date=Date.current#new(year: Time.now.year,day: Time.now.day,month: Time.now.month)\n end\n @album.cover=nil\n if @album.save\n redirect_to @album, notice: 'Альбом успешно создан.'\n else\n render :new\n end\n end", "def create\n @album = Album.find(params[:album_id])\n #@photo = @album.photos.build(params[:photo])\n @photo = @album.photos.create(params[:photo])\n @album.cover_id ||= @photo.id\n @album.add_participator(current_user)\n @photo.exif_read\n\n\n respond_to do |format|\n if @photo.save && @album.save\n format.html { redirect_to @album, notice: 'Photo was successfully created.' }\n format.json { render json: @photo, status: :created, location: @photo }\n format.js \n else\n format.html { render action: \"new\" }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_album\n if token = album_token\n @album = Album.find_or_create_by(token: token)\n else\n @album = Album.find_by(uuid: params[:id])\n end\n end", "def create\n @album = current_user.albums.new(album_params)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'El album a sido creado satisfactoriamente.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_album_photo\n @album_photo = AlbumPhoto.find(params[:id])\n end", "def set_album\n @album = current_user.albums.find(params[:id])\n end", "def album\r\n #prepare_new_album extracted for reuse from spec\r\n prepare_new_album unless @content\r\n end", "def new\n @album = Album.new\n 1.upto(3) { @album.photos.build }\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end", "def new\n \n user = FbGraph::User.new('me', :access_token => User.first.token)\n \n user = user.fetch(:fields => \"picture,cover, photo\")\n \n @profile_picture = user.picture unless user.picture.nil?\n\n @cover_picture = user.raw_attributes[:cover][:source] unless user.raw_attributes[:cover].nil?\n \n #To fetch all friends photos\n @friend_photo= (user.friends).map(&:picture) \n \n @photo=[]\n @album=[]\n \n #~ #TO fetch user tagged photos\n #~ usr=user.photos\n #~ usr.each do |up|\n #~ photo = up.raw_attributes['images'].last\n #~ @photo << photo['source']\n #~ end\n \n #~ #TO fetch user all album photos\n #~ user.albums.each do |ua|\n #~ album=FbGraph::Album.new(ua.raw_attributes[:id])\n #~ album.photos(:access_token => User.first.token, :limit => 100).each do |ap|\n #~ photo = ap.raw_attributes['images'].last\n #~ @album << photo['source']\n #~ end\n #~ end\n #mosaic = Mosaicc.new\n Mosaicc.delay.image_perform\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @album }\n end\n end", "def create_profile_photo\n randomPhotoIndex = 1 + rand(10)\n p = self.profile_photos.create\n p.remote_photo_url = 'http://ragatzi.s3.amazonaws.com/uploads/profile_default_' + randomPhotoIndex.to_s + '.png'\n p.save! \n end", "def set_album_photo\n @album_photo = AlbumPhoto.find(params[:id])\n end", "def create\n\t\t# create Photo from the params\n\t\t@photo = Photo.new(photo_params)\n\t\t@photo.security_setting = SecuritySetting.new\n\n\t\t# set the album if album_id exists in params\n\t\tif params.has_key?(:album_id)\n\t\t\t@photo.album_id = params[:album_id]\n\t\tend\n\t\t\n\t\t# if albums exists then photo inherits albums security level\n\t\tif @photo.album != nil\n\t\t\t@photo.security_setting.securitylevel_id = @photo.album.security_setting.securitylevel_id\n\t\telse\n\t\t# else set security level fromt the params\n\t\t\t@photo.security_setting.securitylevel_id = params[:securitylevel_id]\n\t\tend\n\n\t\t# set the user for the photo\n\t\t@photo.user = current_user\n\t\n\t\trespond_to do |format|\n\t \tif @photo.save\n\t \tActivityFeed.new.createActivityFeed(current_user,@photo,\"created\")\n\t \tif params.has_key?(:album_id)\n\t\t\t\t\tformat.html { redirect_to user_album_photo_path(@user,@photo.album,@photo), notice: 'photo was successfully updated.' }\n\t\t\t\telse\n\t\t\t\t\tformat.html { redirect_to user_photo_path(@user,@photo), notice: 'photo was successfully updated.' }\n\t\t\t\tend\n\t \tformat.json { render :show, status: :created, location: @photo }\n\t \telse\n\t \tformat.html { render :new }\n\t \tformat.json { render json: @photo.errors, status: :unprocessable_entity }\n\t \tend\n\t \tend\n end", "def create\n @photo = Photo.new(photo_params) \n respond_to do |format|\n if @photo.save\n @photo.pet.users.each do |user|\n Notification.create(recipient: user, user: @photo.user, action: \"uploaded\", notifiable: @photo)\n end \n format.html { redirect_to @photo, notice: 'Photo was successfully created.' }\n format.json { render :show, status: :created, location: @photo }\n else\n @albums=[] if @photo.album_id==nil \n format.html { render \"new\"}\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(album_params)\n @album.user_id = current_user.id\n respond_to do |format|\n if @album.save\n if @album.user.locations.any?\n add_location_to_user_albums(@album.user.locations.where(status: 'current').first) if @album.user.locations.where(status: 'current').any?\n end\n create_activity(@album.class.name, @album.id, 'create')\n format.html { \n if album_params.has_key?(:cover)\n render 'crop' \n else \n redirect_to @album, notice: 'Portfolio was successfully created.' \n end \n }\n format.json { render action: 'show', status: :created, location: @album } \n \n else\n format.html { render action: 'new' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @album = current_user.albums.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @album }\n end\n end", "def new\n @album = Album.new\n @album.album_photos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @album }\n end\n end", "def images_select_album_create\n title = params[:title]\n album_name = params[:album_name]\n movie_id = params[:edit_movie_id]\n artist_id = params[:edit_artist_id]\n event_id = params[:edit_event_id]\n user_id = current_user.id\n\n album = Album.create(:album_name => album_name)\n images_ids = params[:images_ids]\n post_to_facebook = params[:post_fb]\n images_ids.split(\" \").each do |image_id|\n AlbumImage.create(:album_id => album.id, :image_id => image_id)\n end\n\n album.cover_image_id = images_ids.split(\" \")[0]\n album.save\n\n post_created = false\n\n if !movie_id.empty? && !post_created\n post = Post.create( :title => title , :posting_id => movie_id, \n :posting_type => \"Movie\" , :postable_type => 'Album',\n :postable_id => album.id, :user_id => current_user.id)\n post_created = true\n end\n\n if !artist_id.empty? && !post_created\n post = Post.create( :title => title , :posting_id => artist_id, \n :posting_type => \"Artist\" , :postable_type => 'Album',\n :postable_id => album.id, :user_id => current_user.id)\n post_created = true\n end\n\n if !event_id.empty? && !post_created\n post = Post.create( :title => title , :posting_id => event_id, \n :posting_type => \"Event\" , :postable_type => 'Album',\n :postable_id => album.id, :user_id => current_user.id)\n end\n Post.mention(post,params[:mention_artist_id],params[:mention_movie_id])\n\n #inserting this particular post to the current user feed\n feed = Feed.create(:user_id => user_id ,:post_id => post.id, :post_created_on => post.created_at )\n\n #user score\n action_score = Score.create(:user_id => current_user.id, :score => 20, :action => \"Post created || Album || post id is #{post.id}\")\n total_score = action_score.score\n current_user.score += total_score\n current_user.save\n\n scrap_hash = {}\n\n PostsWorker.perform_async(post.id,1,scrap_hash)\n PostsWorker.perform_async(post.id,2,scrap_hash)\n redirect_to root_url\n\n end", "def create\n @photo = Photo.new(photo_params)\n @albums = get_current_albums\n\n respond_to do |format|\n if @photo.save\n format.html { redirect_to photos_url, notice: 'Фотография была успешно добавлена.' }\n format.json { render action: 'show', status: :created, location: @photo }\n else\n format.html { render action: 'new' }\n format.json { render json: @photo.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #@picture = Picture.new(picture_params)\n @picture = @album.pictures.build(picture_params) #JRD111115\n\n respond_to do |format|\n if @picture.save\n format.html { redirect_to ([@album, @picture]), notice: 'Picture was successfully created.' }\n format.json { render :show, status: :created, location: @picture}\n else\n format.html { render :new }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_album(person_id, caption, location='', privacy='Everyone')\n @restv9.create_albumv9(person_id, caption, location, privacy)\n end", "def create\n @photo = Photo.new(params[:photo])\n @photo.file = params[:file]\n\n respond_to do |format|\n if @photo.save\n format.html { render :text => \"FILEID:\" + @photo.file.album.url }\n format.json { render :nothing => true }\n else\n format.html { render :text => \"ERRORS:\" + @photo.errors.full_messages.join(\" \"), :status => 500 }\n format.json { render json => @photo.errors, :status => 500 }\n end\n end\n end", "def create\n @photo = Photo.new(params[:photo])\n @photo.album = @album\n @photo.user = @user\n respond_to do |format|\n if @photo.save!\n flash[:notice] = 'Photo was successfully created.'\n format.html { redirect_to user_album_photos_url(@user, @album) }\n format.xml { render :xml => @photo, :status => :created, :location => @photo }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @photo.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(album_params)\n\n not_blank_photos = @album.photos.select do |photo|\n ! photo.title.blank?\n end\n @album.photos = not_blank_photos\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render action: 'show', status: :created, location: @album }\n else\n format.html { render action: 'new' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def photo_album(id)\n backup_photo_albums.find_by_source_album_id(id)\n end", "def create\r\n @album = Album.new(params[:album])\r\n if (params[:album][:coverpage])\r\n tem_coverPage = upload_file(@album.coverpage,\"app/assets/images/album_images\")\r\n @album.coverpage = \"album_images/\"+tem_coverPage\r\n else\r\n @album.coverpage = \"album_images/album_default.jpg\"\r\n end\r\n @album.owner = session[:user_id]\r\n respond_to do |format|\r\n if @album.save\r\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\r\n format.json { render json: @album, status: :created, location: @album }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @album.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def new\r\n @photo = Photo.new\r\n \r\n if params[:id] != nil\r\n @album = Album.find(params[:id])\r\n if @album != nil\r\n @photo.ALBUM_ID = @album.ID\r\n end\r\n end\r\n\r\n @albums = Album.all\r\n @albums_map = {}\r\n @albums.each do |album| \r\n @albums_map[album.TITLE] = album.ID\r\n end\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @photo }\r\n end\r\n end", "def new\n @photo = Photo.new\n @album = Album.find(params[:album_id])\n @person = Person.find(current_person.id)\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end", "def album!(options = {})\n user.album!(options)\n end", "def album!(options = {})\n user.album!(options)\n end", "def create\n @album = Album.new(album_params)\n @album.user_id = current_user.id\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album erfolgreich erstellt.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize! :create, Album\n @album = Album.new(album_params)\n @album.user_id = current_user.id\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to edit_admin_album_path(@album.id), notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @album = current_account.albums.new(params[:album])\n\n respond_to do |format|\n if @album.save\n flash[:notice] = 'album was successfully created.'\n format.html { redirect_to( :action => 'edit', :id => @album.id) }\n format.xml { render :xml => @album, :status => :created, :location => @album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @album = Album.new(params[:album])\n respond_to do |format|\n if @user.albums << @album\n flash[:notice] = 'Album was successfully created.'\n format.html { redirect_to user_albums_path(@user) }\n format.xml { render :xml => @album, :status => :created, :location => @album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n \n @palbum = Palbum.new\n\n \n end", "def new_album(set_albumName, params = {})\n params = { :cmd => 'new-album', :set_albumName => set_albumName }.merge(params)\n send_request(params)\n end", "def create\n @galleries_album = Galleries::Album.new(galleries_album_params)\n @galleries_album.user = current_user\n respond_to do |format|\n if @galleries_album.save\n format.html { redirect_to @galleries_album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @galleries_album }\n else\n format.html { render :new }\n format.json { render json: @galleries_album.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @photoalbum = Photoalbum.new(params[:photoalbum])\n\n respond_to do |format|\n if @photoalbum.save\n format.html { redirect_to edit_photoalbum_path @photoalbum, notice: 'Photoalbum was successfully created.' }\n format.json { render json: @photoalbum, status: :created, location: @photoalbum }\n else\n format.html { render 'new' }\n format.json { render json: @photoalbum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n respond_to do |format|\n @album.user = current_user\n if @album.save\n format.html { redirect_to artist_album_path(@artist,@album), notice: 'album was successfully created.' }\n format.json { render action: 'show', status: :created, location: artist_album_path(@artist,@album) }\n else\n format.html { render action: 'new' }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def album\n alb = super\n if alb.nil?\n alb = Album.new\n alb.title = \"Unknown Album\"\n end\n alb\n end", "def createalbum\n \tredirect_to(\"/photo/createAlbumPage\")\n end", "def create\n @album = @student.albums.new(album_params)\n authorize @album\n if @album.save\n redirect_to new_album_photo_path(@album), notice: 'Album was successfully created.'\n else\n render :new\n end\n end", "def create\n @image = @album.images.build(image_params)\n\n if @image.save\n redirect_to album_path(@image.album.id), notice: \"The image #{@image.name} has been uploaded.\"\n else\n render \"new\"\n end\n end", "def create\n @member = Member.new(member_params)\n @member.avatar.attach(member_params[:avatar]) unless member_params[:avatar].nil?\n respond_to do |format|\n if @member.save\n format.html { redirect_to members_url, notice: 'Member was successfully created.' }\n format.json { render :show, status: :created, location: @member }\n else\n format.html { render :new }\n format.json { render json: @member.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_profile\n Profile.create!(member_id:self.id) if self.profile.nil?\n end", "def new\n @album = Album.new\n @photo = @album.photos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def new\n @photo = Photo.new\n @photo.album_id = params[:album_id]\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def album\n limit = (params[:limit] || 10).to_i\n offset = ((params[:page] || 1).to_i - 1) * limit\n @friend_id = params[:object_id] unless (params[:object_id] == 'null' || params[:object_id].blank?)\n if @friend_id\n friend_data = current_user.facebook_api.get_object(@friend_id)\n @friend_name = friend_data['first_name']\n end\n @photos = current_user.facebook_api.get_connections(\n params[:id],\n \"photos\",\n limit: limit,\n offset: offset,\n fields: FacebookPhoto::PHOTO_FIELDS\n ).map do |fp|\n FacebookPhoto.new_from_api_response(fp)\n end\n # sync doesn't work with facebook! they strip exif metadata from photos. :(\n #@synclink_base = params[:synclink_base] unless params[:synclink_base].blank?\n respond_to do |format|\n format.html do\n render :partial => 'photos/photo_list_form', \n :locals => {\n :photos => @photos, \n :index => params[:index],\n :synclink_base => nil, #@synclink_base,\n :local_photos => false,\n :organized_by_album => true\n }\n end\n end\n end", "def new\n @user = current_user\n @customer = @user.customers.find(params[:customer_id])\n @album = @customer.albums.find(params[:album_id])\n @photo = @album.photos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @photo }\n end\n end", "def create_photos\n end", "def create_photo\r\n if has_login?\r\n if check_album_owner(false)\r\n unless is_limited?(session[:limited])\r\n photo = Photo.new(:swfupload_file => params[:Filedata], :album_id => @album.id, :account_id => session[:account_id])\r\n if photo.save\r\n render(:text => %Q!<a target=\"_blank\" href=\"/photos/#{photo.id}\" title=\"点击查看照片\"><img src=\"#{photo.image.url(:thumb_80)}\" border=\"0\" /></a>!)\r\n else\r\n render :text => \"error\", :layour => false, :status => 500\r\n end\r\n else\r\n render :text => \"帐号处于未激活状态, 不能进行更新操作\", :layout => false\r\n end\r\n else\r\n render :text => \"无权进行上传操作, 请 <a href='/albums'>返回</a>\", :layout => false\r\n end\r\n else\r\n render :text => \"请先 <a href='/accounts/logon'>登录</a>\", :layout => false\r\n end\r\n end", "def create\n @album_owned = AlbumOwned.new(params[:album_owned])\n\n respond_to do |format|\n if @album_owned.save\n format.html { redirect_to @album_owned, notice: 'Album owned was successfully created.' }\n format.json { render json: @album_owned, status: :created, location: @album_owned }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album_owned.errors, status: :unprocessable_entity }\n end\n end\n end", "def upload\n @album = Album.find( params[:album_id].to_i)\n end", "def create\n @picture = Picture.new(params[:picture])\n @picture.user = current_user\n @activity = @picture.album.imageable\n\n respond_to do |format|\n if @picture.save\n format.html { redirect_to [@activity, @picture], notice: 'Picture was successfully created.' }\n format.json { render json: @picture, status: :created, location: @picture }\n else\n format.html { render action: \"new\" }\n format.json { render json: @picture.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @photo = @gallery.photos.new(params[:photo])\n if @photo.save\n flash[:success] = \"Foto #{@photo.filename} do álbum criada com sucesso. Envie outra se quiser.\"\n redirect_to new_admin_gallery_photo_path(@gallery)\n else\n @page_title = \"Novo Foto do álbum\"\n render :action => 'new'\n end\n end", "def album!(options = {})\n response = user.photos.createAlbum(:title => options[:name], :description => options[:message])\n Album.new(response, user)\n end", "def album!(options = {})\n response = user.photos.createAlbum(:title => options[:name], :description => options[:message])\n Album.new(response, user)\n end", "def create\n @album = Album.new(album_params)\n\n @album.pendente = 1 unless current_user.is_admin?\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_album\n @album = Album.includes(:photos, :shares).find(params[:id])\n end", "def album\n @friend_id = params[:object_id] unless (params[:object_id] == 'null' || params[:object_id].blank?)\n if @friend_id\n friend_data = current_user.picasa_client.user(@friend_id)\n @friend_name = friend_data.author.name \n end\n per_page = (params[:limit] ? params[:limit].to_i : 10)\n search_params = {\n :max_results => per_page,\n :start_index => ((params[:page] || 1).to_i * per_page - per_page + 1),\n :picasa_user_id => @friend_id\n }\n @photos = PicasaPhoto.get_photos_from_album(current_user, params[:id], search_params) \n @synclink_base = params[:synclink_base] unless params[:synclink_base].blank?\n respond_to do |format|\n format.html do\n render :partial => 'photos/photo_list_form', \n :locals => {\n :photos => @photos, \n :index => params[:index],\n :synclink_base => nil, \n :local_photos => false,\n :organized_by_album => true\n }\n end\n end\n end", "def album\n @friend_id = params[:object_id] unless (params[:object_id] == 'null' || params[:object_id].blank?)\n if @friend_id\n friend_data = current_user.picasa_client.user(@friend_id)\n @friend_name = friend_data.author.name \n end\n per_page = (params[:limit] ? params[:limit].to_i : 10)\n search_params = {\n :max_results => per_page,\n :start_index => ((params[:page] || 1).to_i * per_page - per_page + 1),\n :picasa_user_id => @friend_id\n }\n @photos = PicasaPhoto.get_photos_from_album(current_user, params[:id], search_params) \n @synclink_base = params[:synclink_base] unless params[:synclink_base].blank?\n respond_to do |format|\n format.html do\n render :partial => 'photos/photo_list_form', \n :locals => {\n :photos => @photos, \n :index => params[:index],\n :synclink_base => nil, \n :local_photos => false,\n :organized_by_album => true\n }\n end\n end\n end", "def create\n if !check_session #Validate if the user session is active\n return #If not force return to trigger the redirect of the check_session function\n end\n @photo_album = PhotoAlbum.new(photo_album_params) #Create a new Photo Album object with the parameters set by the user in the create form\n @photo_album.owner_id = session[:user]['id'] #Set the logged user's id as owner\n @photo_album.creator_id = session[:user]['id'] #Set the logged user's id as creator\n response = @photo_album.save(session[:user]) #Save the new Photo Album object\n if response[0] #Validate if the response was successfull\n flash[:success] = t(:photo_album_creation_success_flash, photo_album: @photo_album.name) #Set the success message for the user\n redirect_to photo_albums_path #Redirect the user to the photo_album list page\n elsif validate_authorized_access(response[1]) #If the response was unsucessful, validate if it was caused by unauthorized access to the app or expired session\n if(response[1].kind_of?(Array)) #If the response was unsucessful, validate if it was caused by an invalid photo album object sent to the model. If so the server would have returned an array with the errors\n flash[:warning] = Util.format_validation_errors(response[1]) #Set the invalid object message for the user\n end\n flash[:danger] = t(:photo_album_creation_error_flash) #Set the error message for the user\n @photo_album = PhotoAlbum.new #Reset the Photo Album object to an empty one\n redirect_to new_photo_album_path #Redirect the user to the Photo Album creation page\n else \n return #If not force return to trigger the redirect of the check_session function\n end\n rescue #Error Handilng code\n general_error_redirection('Controller: '+params[:controller]+'.'+action_name,$!)\n end", "def album\n # @friend_id = params[:object_id] unless (params[:object_id] == 'null' || params[:object_id].blank?)\n # if @friend_id\n # friend_data = current_user.picasa_client.user(@friend_id)\n # @friend_name = friend_data.author.name \n # end\n per_page = (params[:limit] ? params[:limit].to_i : 10)\n search_params = {\n albumId: params[:id],\n pageSize: per_page\n }\n if params[:page_token]\n search_params[:pageToken] = params[:page_token]\n end\n goog = GooglePhotosApi.new( current_user.picasa_identity.token )\n @photos = PicasaPhoto.picasa_request_with_refresh( current_user.picasa_identity ) do\n r = goog.search( search_params )\n @next_page_token = r[\"nextPageToken\"]\n Rails.logger.debug \"[DEBUG] r: #{r}\"\n (r[\"mediaItems\"] || []).map{|mi| PicasaPhoto.new_from_api_response( mi ) }\n end\n # @photos = PicasaPhoto.get_photos_from_album(current_user, params[:id], search_params) \n @synclink_base = params[:synclink_base] unless params[:synclink_base].blank?\n respond_to do |format|\n format.html do\n render :partial => 'photos/photo_list_form', \n :locals => {\n :photos => @photos, \n :index => params[:index],\n :synclink_base => nil, \n :local_photos => false,\n :organized_by_album => true\n }\n end\n end\n end", "def create\n @album = Album.new(allowed_params_album)\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to @album, notice: 'Album was successfully created.' }\n format.json { render :show, status: :created, location: @album }\n else\n format.html { render :new }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @album = Album.new\n end", "def new\n @album = Album.new\n end", "def set_album\n @album = Album.find_by(id: params[:id])\n end", "def set_albumone\n @albumone = Albumone.find(params[:id])\n end", "def create\n @album = Album.new(params[:album])\n\n respond_to do |format|\n if @album.save\n format.html { redirect_to group_url(@album.group), notice: 'Album was successfully created.' }\n format.json { render json: @album, status: :created, location: @album }\n else\n format.html { render action: \"new\" }\n format.json { render json: @album.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_album\n @image = Album.find(params[:album_id])\n end", "def create_album\n @other_user=@login_user\n @albums = @login_user.albums\n @album = Album.new(:name=>params[:album][:name], :user_id=>@login_user.id, :share_type => 0)\n @notice = @album.save ? \"Album created successfully.\": activerecord_error_list(@album.errors)\n\n respond_to do |format|\n format.js\n end\n end", "def create\n @album = Album.new(album_params)\n if @album.save\n redirect_to albums_path\n else \n render 'new'\n end\n end", "def set_album\n @album = Admin::Album.find(params[:id])\n end", "def set_album\n @album = Admin::Album.find(params[:id])\n end", "def photo_name\n if imageable_type == \"Album\"\n self.update(photo_title: \"#{self.imageable.album_name} photo #{self.id}\")\n end\n end", "def new\r\n @album = Album.new\r\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 set_picture\n @picture = @album.pictures.find(params[:id])\n end", "def create\n @album = Album.new(album_params)\n @album.user_id = current_user.id\n\n respond_to do |format|\n if @album.save\n after_create()\n format.html { redirect_to(@album) }\n format.xml { render :xml => @album, :status => :created, :location => @album }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @album.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @album = current_user.albums.find(params[:cover][:album_id])\n @cover = Cover.new(params[:cover])\n if @cover.save\n redirect_to \"/albums/\" + params[:cover][:album_id], :notice => \"Successfully added cover.\"\n else\n @album = current_user.albums.find(params[:cover][:album_id])\n render :action => 'edit'\n end \n end", "def set_album_information\n @album_information = AlbumInformation.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end", "def set_album\n @album = Album.find(params[:id])\n end" ]
[ "0.6716489", "0.6584746", "0.65331537", "0.6481912", "0.6475554", "0.643558", "0.6428309", "0.64254946", "0.6385693", "0.6383643", "0.63700205", "0.63440716", "0.6309707", "0.6305727", "0.62739587", "0.6256663", "0.6256292", "0.62509334", "0.62458843", "0.6242875", "0.6226155", "0.6225844", "0.62141824", "0.6184572", "0.6169945", "0.6169833", "0.61605614", "0.61540914", "0.61376506", "0.60949606", "0.606427", "0.60574985", "0.605709", "0.60433054", "0.60382694", "0.603497", "0.6033064", "0.60268515", "0.6023686", "0.60234433", "0.6021965", "0.6013496", "0.6008635", "0.60061073", "0.59819025", "0.5981795", "0.5981795", "0.5980744", "0.59789443", "0.5976583", "0.5974173", "0.5971865", "0.5962438", "0.59462625", "0.59335077", "0.5927707", "0.59241146", "0.592284", "0.5917503", "0.59139425", "0.59053046", "0.59044755", "0.5903936", "0.5903038", "0.5896434", "0.5895146", "0.5887458", "0.58828545", "0.5860851", "0.58546823", "0.5854131", "0.58445907", "0.5843319", "0.5843319", "0.58391005", "0.5835346", "0.5834543", "0.5834543", "0.58296657", "0.5815283", "0.5811825", "0.58058345", "0.58058345", "0.57977843", "0.5795491", "0.5789696", "0.5788893", "0.5788559", "0.57820946", "0.5779077", "0.5779077", "0.57789063", "0.57784235", "0.57629406", "0.57527584", "0.57424283", "0.57361364", "0.5734186", "0.5733891", "0.5733891", "0.5733891" ]
0.0
-1
TODO how to test this
def get_users_current_votes(user) applicable_ideas = Idea.all.published.where.not(user: user) applicable_versions = Version.where(idea: applicable_ideas) votes = Upvote.where(user: user, version: applicable_versions.ids) return votes end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def private; end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def probers; end", "def schubert; end", "def refutal()\n end", "def weber; end", "def implementation; end", "def implementation; end", "def formation; end", "def identify; end", "def custom; end", "def custom; end", "def suivre; end", "def strategy; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def run; end", "def operations; end", "def operations; end", "def apply\n\t\t\n\tend", "def apply\n\t\t\n\tend", "def who_we_are\r\n end", "def wrapper; end", "def sitemaps; end", "def internal; end", "def processor; end", "def terpene; end", "def spec; end", "def spec; end", "def intensifier; end", "def verdi; end", "def berlioz; end", "def stderrs; end", "def used?; end", "def result; end", "def result; end", "def result; end", "def result; end", "def result; end", "def result; end", "def result; end", "def result; end", "def villian; end", "def r; end", "def r; end", "def isolated; end", "def isolated; end", "def handle; end", "def from; end", "def from; end", "def from; end", "def from; end", "def offences_by; end", "def reflector; end", "def reflector; end", "def original_result; end", "def init; end", "def init; end", "def init; end", "def init; end", "def operation; end", "def anchored; end", "def initialize\n\t\t\n\tend", "def run() end", "def trd; end", "def extra; end", "def private_method\n end", "def initialize\n\n end", "def initialize\n\n end", "def returns; end", "def executor; end", "def executor; end", "def executor; end", "def next() end", "def next() end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def call; end", "def next()\n \n end", "def next()\n \n end", "def initialize\n \n end", "def internship_passed; end", "def zuruecksetzen()\n end", "def initialize\r\n\r\n end", "def context; end", "def context; end", "def context; end" ]
[ "0.7699575", "0.6550803", "0.6550803", "0.6550803", "0.6550803", "0.65251195", "0.64689064", "0.62361383", "0.6185826", "0.61640114", "0.61640114", "0.6056613", "0.6033879", "0.5993173", "0.5993173", "0.5976", "0.59221303", "0.5884436", "0.5884436", "0.5884436", "0.5884436", "0.5884436", "0.5884436", "0.5884436", "0.5884436", "0.5884436", "0.5867887", "0.5867887", "0.5833264", "0.5833264", "0.5815157", "0.5780809", "0.5779566", "0.57546425", "0.5744962", "0.5741173", "0.57292247", "0.57292247", "0.5708565", "0.56949174", "0.5672407", "0.5656578", "0.56426626", "0.5626477", "0.5626477", "0.5626477", "0.5626477", "0.5626477", "0.5626477", "0.5626477", "0.5626477", "0.5608793", "0.5600762", "0.5600762", "0.5598151", "0.5598151", "0.55926484", "0.5592434", "0.5592434", "0.5592434", "0.5592434", "0.55898684", "0.558942", "0.558942", "0.5570625", "0.55658007", "0.55658007", "0.55658007", "0.55658007", "0.55591923", "0.555753", "0.55496335", "0.55469054", "0.55462307", "0.5537355", "0.5536799", "0.5532234", "0.5532234", "0.5526544", "0.55181897", "0.55181897", "0.55181897", "0.5512775", "0.5512775", "0.5508967", "0.5508967", "0.5508967", "0.5508967", "0.5508967", "0.5508967", "0.5508967", "0.5508967", "0.5505192", "0.5505192", "0.5494874", "0.5490739", "0.5483312", "0.54731256", "0.5456042", "0.5456042", "0.5456042" ]
0.0
-1
Action used by nonExt.Direct (Touch) components
def dispatcher endpoint_dispatch(params[:address]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def perform\n $driver.multi_touch @actions\n end", "def click_action\n raise NotImplementedError \"Subclasses must implement this method\"\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def action_hook; end", "def action(event)\n @neko.send event.target[:action]\n end", "def action_target()\n \n end", "def touch_moved(touch); end", "def act\n end", "def action\n end", "def action(unit)\n\tend", "def action_enable\n end", "def action\n trigger :click\n end", "def action\n super\n end", "def actions; end", "def action\n end", "def matt_custom_action_begin(label); end", "def handleAction evt, action, caller\n # DO NOTHING - this method shall be implemented by the children\n return false\n end", "def send_action(*_arg0); end", "def touch\n @repaint_required = true\n end", "def local_action(command, id, action)\n super(command,id,ACTION[action])\n end", "def action\n driver.action\n end", "def action_run\n end", "def _call_action(action)\n send(action)\n end", "def process_action(...)\n send_action(...)\n end", "def perform_action(*args)\n end", "def tick(*action_devices); end", "def fire_action_event\n require 'canis/core/include/ractionevent'\n fire_handler :PRESS, ActionEvent.new(self, :PRESS, text)\n end", "def run_actions; end", "def clicked;end", "def setUserActionText _obj, _args\n \"_obj setUserActionText _args;\" \n end", "def click; end", "def click; end", "def click; end", "def press(point)\n\t\t\t\t\n\t\t\tend", "def action_disable\n super\n end", "def action(name)\n nil\n end", "def check_event_trigger_touch(x, y)\r\n return false\r\n end", "def perform action\n @ref.perform TRANSLATOR.cocoaify action\n end", "def action=(_arg0); end", "def on_click\n\t\tend", "def touch_began(touch); end", "def clicked(e)\n \n end", "def invoke_action(name)\n end", "def invoke_action(name)\n end", "def invoke_action(name)\n end", "def doubleclick(btn = 'left')\n compatible_call :doubleclick, btn\n end", "def click(btn)\n not_supported \"anything other than left clicking\" unless btn == 'left'\n execute_applescript(%Q`\n tell application \"Extra Suites\"\n ES click mouse\n end tell\n `)\n end", "def press(point)\n\t\t\n\tend", "def touch(arg)\r\n# puts(\"#{TEST_TOUCH} #{arg}\")\r\n sys(\"#{TEST_TOUCH} #{arg}\")\r\n end", "def action\n puts \"use command!\\n\\n\"\n end", "def invoke_action(opt = {})\n raise(\"Method not implemented for this class: #{@klass}\")\n end", "def action_missing(*)\n end", "def action _obj, _args\n \"_obj action _args;\" \n end", "def check_event_trigger_touch(x, y)\n return false\n end", "def mco_action\n raise RuntimeError, \"Not implemented\"\n end", "def fire\n #$log.debug \"firing PRESS #{text}\"\n fire_handler :PRESS, ActionEvent.new(self, :PRESS, text)\n end", "def actions\n %w{void}\n end", "def default_action; end", "def action(value)\n l action: value\n raise NotImplementedError, 'Implement in subclass'\n end", "def method_for_action(action_name); end", "def doubleclick(btn)\n not_supported \"anything other than left clicking\" unless btn == 'left'\n execute_applescript(%Q`\n tell application \"Extra Suites\"\n ES click mouse with double click\n end tell\n `)\n end", "def fireAtTarget _obj, _args\n \"_obj fireAtTarget _args;\" \n end", "def pay_button_tap(x=nil, y=nil)\n x = 720 if x==nil\n y = 1421 if y==nil\n Appium::Core::TouchAction.new(self).press( x, y).release.perform\n end", "def touch_ended(touch); end", "def define_action_hook; end", "def react_to *args; end", "def set_action(action)\n return unless action\n\n @action = action\n @ext.set_action(action)\n end", "def action\n args.first\n end", "def context_click(element = T.unsafe(nil), device: T.unsafe(nil)); end", "def tripleclick(btn)\n not_supported \"anything other than left clicking\" unless btn == 'left'\n execute_applescript(%Q`\n tell application \"Extra Suites\"\n ES click mouse\n ES click mouse\n ES click mouse\n end tell\n `)\n end", "def click\n raise \"Must implement custom click method.\"\n end", "def touched\n crash\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def touchesBegan touches, withEvent: _\n\n end", "def tick args\n drtouch = DRTouch.new\n drtouch.init\n drtouch.update\n \n args.outputs.background_color = [ 0, 0, 0, 255 ]\n \n args.outputs.primitives << {\n x: 320,\n y: 16.from_top,\n text: \"TAP AND MOVE YOUR FINGER OVER THE SCREEN\",\n size_enum: 6,\n r: 255,\n g: 255,\n b: 255,\n a: 255,\n }.label\n \n if drtouch.down(0)\n pos = drtouch.pos(0)\n \n args.outputs.primitives << {\n x: pos.x,\n y: pos.y,\n w: 50,\n h: 50,\n r: 34,\n g: 155,\n b: 255,\n a: 255,\n }.solid\n \n args.outputs.primitives << {\n x: 16,\n y: 8.from_top,\n text: \"x1: #{pos.x}, y1: #{pos.y}\",\n size_enum: 2,\n r: 255,\n g: 0,\n b: 0,\n a: 255\n }.label\n end\nend", "def update\n\t\t@controller.buttons_pressed_down if @controller\n\tend", "def onLButtonDown(flags,x,y,view)\n pickpoint=@ip.position\n ParametricCopy::run(pickpoint)\n Sketchup.send_action(\"selectSelectionTool:\")\n end", "def button_down; end", "def process_action(*_arg0); end", "def process_action(*_arg0); end", "def process_action(*_arg0); end", "def check_event_trigger_touch_front\r\r\n d = @direction\r\r\n horz = (d - 1) % 3 - 1\r\r\n vert = 1 - ((d - 1) / 3)\r\r\n pixelstep = CXJ::FREE_MOVEMENT::PIXELS_PER_STEP / 32.0\r\r\n x2 = $game_map.round_x(x + horz * pixelstep)\r\r\n y2 = $game_map.round_y(y + vert * pixelstep)\r\r\n check_event_trigger_touch(x2, y2)\r\r\n end", "def add_actions; end", "def perform_action(data); end", "def _handle_action_missing(*args); end", "def default_action(msg)\n #\n # do nothing.\n #\n end", "def action args = {}\n\t\tend", "def process(action, *args); end", "def right_click()\n right_mouse_down\n right_mouse_up\n stall :right_click\n end", "def playable_action\n raise NotImplementedError\n end", "def question_otto_button_click\n MenuControllerContracts.invariant(self)\n @alert_view = @help_view = Views::OttoInstructionsAlertView.new(@window, self)\n MenuControllerContracts.invariant(self)\n end", "def action_name; end", "def action\n play_decision_se\n send(ACTION_LIST[@image_indexes[@index]])\n end", "def action_start\n proxy_action(:start)\n end", "def swipe(opts)\n start_x = opts.fetch :start_x, 0\n start_y = opts.fetch :start_y, 0\n end_x = opts.fetch :end_x, 0\n end_y = opts.fetch :end_y, 0\n duration = opts.fetch :duration, 2\n\n \n action = Appium::TouchAction.new.press(x: start_x, y: start_y).move_to(x: end_x, y: end_y).release \n action.perform\nend" ]
[ "0.6418835", "0.6414012", "0.63618726", "0.63618726", "0.63618726", "0.63618726", "0.63618726", "0.630119", "0.6270856", "0.61801755", "0.61144507", "0.60913104", "0.60820156", "0.6079153", "0.6072843", "0.6066831", "0.60415614", "0.6028799", "0.60075706", "0.59906316", "0.59902817", "0.5950723", "0.5917606", "0.59151834", "0.59058064", "0.5898635", "0.5834476", "0.580672", "0.57797253", "0.5766991", "0.5756213", "0.5730222", "0.5716697", "0.5699477", "0.5658798", "0.5658798", "0.5658798", "0.5653348", "0.56389606", "0.5638512", "0.56227255", "0.5593448", "0.55719703", "0.5558918", "0.55414414", "0.553546", "0.5534448", "0.5534448", "0.55338156", "0.5524793", "0.5524102", "0.5518534", "0.55129874", "0.5498169", "0.54975015", "0.549504", "0.54837334", "0.5478983", "0.5478215", "0.5475295", "0.546692", "0.54620415", "0.54568654", "0.54547095", "0.5448715", "0.5437126", "0.54346216", "0.54305625", "0.5429402", "0.5427844", "0.5417233", "0.5392801", "0.5392487", "0.53914183", "0.538939", "0.53823286", "0.5380875", "0.5380875", "0.5380875", "0.5369926", "0.5357451", "0.5342565", "0.53422725", "0.53387034", "0.53344816", "0.53344816", "0.53344816", "0.5332967", "0.533017", "0.5326181", "0.53224534", "0.5321695", "0.5320362", "0.53165936", "0.53078645", "0.5307789", "0.53024215", "0.52991575", "0.5298567", "0.52972615", "0.52950114" ]
0.0
-1
Used in development mode for onthefly generation of public/netzke/ext.[js|css]
def ext respond_to do |format| format.js { render :text => Netzke::Core::DynamicAssets.ext_js } format.css { render :text => Netzke::Core::DynamicAssets.ext_css } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def netzke_init(params = {})\n theme = params[:ext_theme] || :default\n [netzke_css_include(theme), netzke_js_include, netzke_js].join(\"\\n\")\n end", "def initial_dynamic_javascript\n res = []\n # res << %(Ext.Ajax.extraParams = {authenticity_token: '#{form_authenticity_token}'}; // Rails' forgery protection)\n res << %{Ext.ns('Netzke');}\n res << %{Ext.ns('Netzke.core');}\n res << %{Netzke.RelativeUrlRoot = '#{ActionController::Base.config.relative_url_root}';}\n res << %{Netzke.RelativeExtUrl = '#{ActionController::Base.config.relative_url_root}/extjs';}\n\n res << %{Netzke.core.directMaxRetries = '#{Netzke::Core.js_direct_max_retries}';}\n\n res.join(\"\\n\")\n end", "def netzke_init(params = {})\n Netzke::Core.platform = params[:platform] || :ext\n theme = params[:theme] || params[:ext_theme] || :default\n raw([netzke_css_include(theme), netzke_css, netzke_js_include, netzke_js].join(\"\\n\"))\n end", "def netzke_js_include\n send :\"netzke_#{Netzke::Core.platform}_js_include\"\n end", "def build_dev\n timer_block(\n 'Start [development] build for *.js files',\n 'JS time: ') do\n all_js_into_one_file\n end\n end", "def netzke_js\n send :\"netzke_#{Netzke::Core.platform}_js\"\n end", "def precompile_assets; end", "def vite_client_src\n prefix_vite_asset('@vite/client') if dev_server_running?\n end", "def ext(name, config = {}) #:doc:\n comp = Netzke::ExtComponent.new(name, config)\n content_for :netzke_on_ready, raw(\"#{comp.js_component_render}\")\n raw(comp.js_component_html)\n end", "def ext(name, config = {}) #:doc:\n comp = Netzke::ExtComponent.new(name, config)\n content_for :netzke_on_ready, raw(\"#{comp.js_component_render}\")\n raw(comp.js_component_html)\n end", "def install_sample_files\n super\n inject_line_before root.join('apps/web/templates/application.html.erb'), '</head>', <<-HTML\n <%= vite_client %>\n <%= vite_javascript 'application' %>\n HTML\n end", "def js\n puts 'Compressing JS files...'\n `java -jar ./_scripts/yuicompressor-2.4.2.jar ../www/_res/js/uncompressed/main.js -o ../www/_res/js/main.js`\n # --nomunge\nend", "def request_debug_assets?; end", "def request_debug_assets?; end", "def add_vendor_files\n say_quietly \"Copying files...\"\n\n %w[auth backend frontend].each do |section|\n template \"vendor/assets/javascripts/archangel/#{section}.js\"\n template \"vendor/assets/stylesheets/archangel/#{section}.css\"\n end\n end", "def to_production_html\n \"<script type='text/javascript' src='%s?%s'></script>\" % [path, mtime.to_i]\n end", "def render_deferred_javascript_files\n #write any deffered javascript files\n return '' if @content_for_javascript_files.blank?\n js_code = \"\\n<!-- DEFFERRED Javascripts -->\\n#{@content_for_javascript_files}\"\n end", "def static_files; end", "def config_js\n [\n src_config_path.join('routes.js').to_s,\n src_config_path.join('router.js').to_s,\n src_config_path.join('app.js').to_s\n ]\n end", "def copy_styles_and_js\n base_dir = @generator.base_dir\n Dir.mkdir(\"#{base_dir}/js\")\n FileUtils.cp(\"#{Amy::BASE_DIR}/views/js/amy.min.js\", \"#{base_dir}/js/amy.js\")\n FileUtils.cp(\"#{Amy::BASE_DIR}/views/js/data.json\", \"#{base_dir}/data.json\") \n Dir.mkdir(\"#{base_dir}/style\")\n FileUtils.cp(\"#{Amy::BASE_DIR}/views/style/style.css\", \"#{base_dir}/style/style.css\")\n end", "def generate()\n\t\tjdc='jekyll_date_chart.js'\n\t\tcopy_file \"lib/#{jdc}\", \"_assets/javascripts/#{jdc}\"\n\n\t\tdirectory 'vendor/assets/javascripts/', '_assets/javascripts/'\n\t\tdirectory 'vendor/assets/stylesheets/', '_assets/stylesheets/'\n\tend", "def generate_files\n copy_file 'who_is_online_channel.rb', \"app/channels/#{name}_channel.rb\"\n copy_file 'who_is_online.coffee', \"app/assets/javascripts/channels/#{name}.coffee\"\n end", "def set_static_includes\r\n @javascripts = [JS_SCRIPTACULOUS_SKOBEE_DEFAULT, JS_SKOBEE_PLANS, JS_DATEPICKER, JS_JSON]\r\n end", "def generate_coffee\n if options.coffee?\n directory \"app/assets/javascripts/kublog\"\n end\n end", "def min_js_file\n build_path.join('scripts.min.js')\n end", "def netzke_css_include(theme)\n send :\"netzke_#{Netzke::Core.platform}_css_include\", theme\n end", "def all_js_into_one_file\n File.open(base_js_file, 'w') do |file|\n js_files.each do |js_file|\n file.write('/* file: ' + js_file + \" */\\n\") if development?\n file.write(File.read(js_file))\n end\n end\n end", "def compile_js_files(file, prod=true)\n\t# use development style options for now, even in production\n\tif prod\n\t\toptions = {:output => {:comments => :none }}\n\t\tFile.open(file, \"w\") { |f| f.write(Uglifier.compile(concat_js_files, options)) }\n\telse\n\t\t#options = {:output => {:comments => :all, :beautify => true, :preserve_line => true}}\n\t\tFile.open(file, \"w\") { |f| f.write(concat_js_files) }\n\tend\n\n\tputs \" \\e[32mwrite #{file}\\e[0m\"\nend", "def netzke_css\n %{\n <style type=\"text/css\" media=\"screen\">\n #{content_for(:netzke_css)}\n </style>} if content_for(:netzke_css).present?\n end", "def generate(site)\n # Current directory is the root-level directory\n js_vendor_dir = 'source/_assets/javascripts/vendor/'\n js_file_name = 'mail-helper.js'\n js_full_name = js_vendor_dir + js_file_name\n\n mail_obfuscate_js = File.read(js_full_name)\n Liquid::Template.register_filter(MReverse)\n output_js = Liquid::Template.parse(mail_obfuscate_js).\n render('site' => site.config)\n File.write(js_full_name, output_js)\n end", "def javascript_include_tag(file_name)\n path_prefix = development? ? '/assets/' : '/js/'\n suffix = development? ? '' : \"-#{Heliom::Labs::VERSION}.min\"\n %(<script src=\"#{path_prefix}#{file_name}#{suffix}.js\"></script>)\nend", "def index_prebuilt!\n Dir.glob(\"#{PREBUILT_DIR}/**/[^_]*.*\") do |filename|\n config.add_page(filename.sub(\"#{PREBUILT_DIR}/\", ''), file: filename, digest: true)\n end\n end", "def asset_handler\n tags = String.new\n tags << tag(:link, rel: \"stylesheet\", href: \"/stylesheets/icons.css\")\n if controller_name == \"rich_subscriptions\"\n tags << content_tag(:script, \"\", src: \"/javascripts/#{fingerprinted_asset('map')}.js\")\n tags << tag(:link, rel: \"stylesheet\", href: \"/stylesheets/leaflet/leaflet.css\")\n tags << tag(:link, rel: \"stylesheet\", href: \"/stylesheets/leaflet/leaflet-slider.css\")\n tags << tag(:link, rel: \"stylesheet\", href: \"/stylesheets/leaflet/L.Control.Locate.min.css\")\n tags << tag(:link, rel: \"stylesheet\", href: \"/stylesheets/#{fingerprinted_asset('map')}.css\")\n else\n tags << content_tag(:script, \"\", src: \"/javascripts/#{fingerprinted_asset('application')}.js\")\n tags << tag(:link, rel: \"stylesheet\", href: \"/stylesheets/#{fingerprinted_asset('application')}.css\")\n end\n tags.html_safe\n end", "def assets_path() = self.class.name.demodulize.delete_suffix('Generator').underscore", "def active_scaffold_javascripts(frontend = :default)\r\n ActiveScaffold::Config::Core.javascripts(frontend).collect do |name|\r\n ActiveScaffold::Config::Core.asset_path(name, frontend)\r\n end\r\n end", "def netzke_js\n js=\"Ext.Ajax.extraParams = {authenticity_token: '#{form_authenticity_token}'}; // Rails' forgery protection\\n\"\n\n\n js << <<-END_OF_JAVASCRIPT if(!ActionController::Base.relative_url_root.blank?)\n // apply relative URL root, if set\n Ext.widgetMixIn.buildApiUrl= function(apip){\n return \"#{ActionController::Base.relative_url_root}/netzke/\" + this.id + \"__\" + apip;\n };\n Ext.BLANK_IMAGE_URL = \"#{ActionController::Base.relative_url_root}/extjs/resources/images/default/s.gif\";\n END_OF_JAVASCRIPT\n\n js << <<-END_OF_JAVASCRIPT\n #{@content_for_netzke_js_classes}\n Ext.onReady(function(){\n #{@content_for_netzke_on_ready}\n });\n END_OF_JAVASCRIPT\n\n javascript_tag js\n \n end", "def assets; end", "def assets; end", "def assets; end", "def jmaki_setup\n\n # Configure global variables as needed\n # FIXME - next three lines are a real hack\n railsURI = request.request_uri # Usually just /controller/action\n requestURI = request.env['REQUEST_URI'] # Entire absolute URI\n webRoot = requestURI[0, (requestURI.length - railsURI.length)]\n result = \"<script type='text/javascript'>\\n\" +\n \" jmaki.webRoot = '\" + webRoot + \"';\\n\" +\n \" jmaki.resourcesRoot = '/resources';\\n\" +\n \" jmaki.xhp = '\" + webRoot + \"/xhp';\\n\" +\n \"</script>\\n\"\n\n # Load global configuration\n global = jmaki_load_global()\n\n # Render glue includes as necessary\n config = global['config']\n if config\n glue = config['glue']\n if glue\n includes = glue['includes']\n if includes\n for i in 0...includes.length\n include = includes[i]\n if include.instance_of?(String)\n result += jmaki_generate_js(include)\n elsif include.instance_of?(Hash)\n lib = include['lib']\n url = include['url']\n if lib && url && jmaki_match_url(url)\n result += jmaki_generate_js(lib)\n end\n end\n end\n end\n end\n if config['globalTheme']\n @jmakiGlobalTheme = config['globalTheme']\n end \n end\n\n # Return the accumulated result\n result\n\n end", "def to_development_html\n hrefs.map { |href| \"<script type='text/javascript' src='#{href}'></script>\" }.join(\"\\n\")\n end", "def set_generated_assets_dir\n ReactOnRails.configuration.generated_assets_dir = Basch::Application.config.generated_frontend_assets_dir\n end", "def output_extension\n if esm?\n 'mjs'\n else\n 'js'\n end\n end", "def set_static_includes\r\n @javascripts = [JS_SCRIPTACULOUS_SKOBEE_DEFAULT, JS_SKOBEE_COMMENTS]\r\n end", "def source\n source = source_compiler['jison.js'].to_s\n source_compiler.each_logical_path do |logical_path|\n next if logical_path == 'jison.js'\n src = source_compiler[logical_path].to_s\n logical_path.sub! /\\.js$/, ''\n source.concat \"require.def('#{logical_path}',{factory:function(require,exports,module){#{src}}});\"\n end\n source + \"var Dock = require('dock').Dock;\"\n end", "def comment_for_phantom_script\n \"# Path to magick.js used to render a web page (using PhantomJS, a headless WebKit)\\n\"\n end", "def build_for_demo \n `elm make elm/Main.elm --output assets/js/elm.js`\n `minify assets/js/elm.js assets/js/elm.min.js`\n FileUtil.cp \"assets/js/elm.js\" \"../demo-elm-doc-builder/assets/js/elm.js\"\n FileUtil.cp \"assets/js/elm.min.js\" \"../demo-elm-doc-builder/assets/js/elm.min.js\"\nend", "def assets\n\n javascript={}\n css={}\n\n Dir.glob(bower_asset_path+'/production/*.html').each { |path|\n next if files_omit.include?(File.basename(path))\n page = Nokogiri::HTML(open(path))\n javascript[path]=[]\n css[path]=[]\n page.css('script').each { |st|\n javascript[path] << st.attr('src').sub('../vendors/', '') if st.attr('src') && st.attr('src').start_with?('../')\n }\n page.css('link').each { |st|\n css[path] << st.attr('href').sub('../vendors/', '') if st.attr('rel') && st.attr('rel') == 'stylesheet'\n }\n }\n\n# Merge the lists of script and css references using array union\n javascript_src=[]\n javascript.values.map { |s| javascript_src = javascript_src | s }\n javascript_src.uniq!\n\n# Omit the references that we won't include in the gem\n javascript_omit.each { |s| javascript_src.delete(s) }\n\n css_src=[]\n css.values.map { |s| css_src = css_src | s }\n css_src.uniq!\n\n css_omit.each { |s| css_src.delete(s) }\n\n {\n javascript: javascript_src,\n css: css_src,\n }\n\nend", "def assets\n unless IO.read(\"app/assets/stylesheets/application.css\").include?(\"Required by SULChrome\")\n insert_into_file \"app/assets/stylesheets/application.css\", :after => \"/*\" do\n %q{\n * Required by SULChrome:\n *= require sul_chrome/sul_chrome_base\n *}\n end\n end\n unless IO.read(\"app/assets/javascripts/application.js\").include?(\"Required by SULChrome\")\n insert_into_file \"app/assets/javascripts/application.js\", :before => \"//= require_tree .\" do\n%q{// Required by SULChrome:\n//= require sul_chrome/sul_chrome_base\n}\n end\n end\n end", "def regenerator; end", "def asset_host; end", "def asset_host; end", "def run_on_modifications(paths = [])\n hash = {}\n \n # Get all files.\n paths = Dir.glob(\"#{@options[:input]}/**/*\").select do |path|\n not File.directory? path\n end\n \n paths.each do |path|\n file = File.read path\n compiled = ::EJS.compile file\n hash[path] = compiled\n \n UI.info \"[Guard::EJS] Compiled #{path}.\"\n end\n \n # Just overwrite the whole thing for now.\n FileUtils.mkdir_p File.dirname(@options[:output])\n \n File.open(@options[:output], 'w+') do |file|\n file.write \"window.#{@options[:namespace]} = window.#{@options[:namespace]} || {}\\n\"\n file.write \"window.#{@options[:namespace]}.templates = {\"\n \n hash.each do |name, template|\n file.write \"\\\"#{name}\\\": #{template},\"\n end\n \n file.write \"}\"\n end\n end", "def js_missing_code(cached = [])\n code = dependency_classes.inject('') do |r, k|\n cached.include?(k.client_class_config.xtype) ? r : r + k.client_class_config.code_with_dependencies\n end\n code.blank? ? nil : Netzke::Core::DynamicAssets.minify_js(code)\n end", "def js_files\n [\n vue_lib_js, mixins_js, filters_js, components_js,\n pages_js, config_js\n ].flatten!\n end", "def output_ext; end", "def output_ext; end", "def output_ext; end", "def prepare_js\n compile_templates\n compile_controllers\n end", "def code(env)\n html_code <<\n css_code <<\n render(js_code,\n :TOKEN => Webconsole::Repl.token,\n :KEY_CODE => Webconsole.key_code,\n :CONTEXT => env['SCRIPT_NAME'] || \"\")\n end", "def concat_js_files\n\tjavascript_compile_list.map { |f| File.read(f) }.join\nend", "def public_file_server; end", "def public_file_server; end", "def copy_public_assets \n generate \"blacklight:assets\"\n end", "def jumble\n command = \"\"\n\n @js_file_paths.each {|item|\n command += '--js \"' + item + '\" '\n }\n\n command += ' --js_output_file \"' + @output_file + '\"'\n \n self.exjar command\n end", "def source_files; end", "def copy_javascripts\n if ::Rails.version[0..2].to_f >= 3.1\n #puts \"The javascripts do not need to be installed since Rails 3.1\"\n else\n copy_file \"../../../../../app/assets/javascripts/on_the_spot_code.js\", \"public/javascripts/on_the_spot.js\"\n copy_file \"../../../../../app/assets/javascripts/jquery.jeditable.js\", \"public/javascripts/jquery.jeditable.js\"\n copy_file \"../../../../../app/assets/javascripts/jquery.jeditable.checkbox.js\", \"public/javascripts/jquery.jeditable.checkbox.js\"\n copy_file \"../../../../../app/assets/stylesheets/on_the_spot.css\", \"public/stylesheets/on_the_spot.css\"\n end\n end", "def allow_production; end", "def javascript_compile_list\n\t[\t\n\t\t# Wordpress distributed JS (not monitored for changes...)\n\t\t#\"../../../wp-includes/js/jquery/jquery-migrate.min.js\",\n\t\t#\"../../../wp-includes/js/jquery/jquery.masonry.min.js\",\n\n\t\t# Theme JS\n\t\t\"js/jquery-1.11.0.js\",\n\t\t\"js/jquery-ui-1.10.4.datepicker.js\",\n\t\t\"js/jquery.cookie.js\",\n\t\t\"js/functions.js\",\n\t\t\"js/imagelightbox.js\",\n\t\t\"js/lightboxinit.js\",\n\t\t\"js/jflickrfeed.js\",\n\t\t\"js/flickrsetup.js\",\n\t\t\"js/vender.js\", \n\t\t\"js/scrollTo.js\",\n\t\t\"js/placeholder.js\",\n\t\t\"js/default.js\",\n\t\t\"js/campus-libraries.js\",\n\t\t\"js/find-a-library.js\",\n\t\t\"js/datepicker.js\",\n\t\t\"js/library.js\",\n\t\t\"js/directory.js\",\n\t\t\"js/liaison.js\",\n\t\t\"js/locations.js\",\n\t\t\"js/ask.js\",\n\t\t\"js/alerts.js\",\n\t\t\"js/google-support.js\",\n\t\t\"js/locate.js\"\n\t]\nend", "def set_generated_assets_dir\n ReactOnRails.configuration.generated_assets_dir = Basch::Application.config.generated_backend_assets_dir\n end", "def install_frontends\n package 'nginx'\n end", "def load_js\n AssetManager.include_contrib_library [:core_ui, :jquery_tab]\n AssetManager.include_local_library [ 'ckeditor/init']\n\n AssetManager.include_css [:blog_global]\n end", "def setup_app_files\n cp HANAMI_TEMPLATES.join('config/hanami-vite.json'), config.config_path\n inject_line_after root.join('config/environment.rb'), 'environment :development do', ' middleware.use(ViteRuby::DevServerProxy, ssl_verify_none: true) if ViteRuby.run_proxy?'\n inject_line_after_last root.join('apps/web/application.rb'), 'include Web::Assets::Helpers', ' include ViteHanami::TagHelpers'\n inject_line_after root.join('apps/web/application.rb'), 'configure :development do', <<-CSP\n # Allow @vite/client to hot reload changes in development\n security.content_security_policy(\n security.content_security_policy\n .sub('script-src', \"script-src 'unsafe-eval'\")\n .sub('connect-src', \"connect-src ws://\\#{ ViteRuby.config.host_with_port }\")\n )\n CSP\n append root.join('Rakefile'), <<~RAKE\n require 'vite_hanami'\n ViteRuby.install_tasks\n RAKE\n end", "def sg_usemin_js(path, options={})\n usemin = SlimGruntHelpers::Models::UseminJs.new\n options = { alt: nil, absolute: false }.merge!(options)\n\n alt = ''\n alt = \"(#{ options[:alt] })\" unless options[:alt].nil?\n\n text = \"\\n<!-- build:js#{ alt } #{ path } -->\\n\"\n yield(usemin)\n usemin.each(options) do |link|\n text << \"#{ link }\\n\"\n end\n text << \"<!-- endbuild -->\\n\"\n end", "def compile_coffee_to_js\n files = ['level_core', 'path_core', 'deadlock_core']\n files.each do |file|\n if File.exist?(\"lib/assets/#{file}.js\")\n File.delete(\"lib/assets/#{file}.js\")\n end\n compile_file_coffee_to_js(\"app/assets/javascripts/game/models/#{file}.js.coffee\", \"lib/assets/#{file}.js\")\n end\nend", "def generate\n return {} if config.empty?\n assets = {}\n config.each do |key, value|\n next if key == \"widgets\" # Widgets are handled separately.\n assets[key] = Array(value).map { |v|\n {\n \"url\" => url(v),\n \"id\" => File.join(@ruhoh.paths.theme, \"javascripts\", v)\n }\n }\n end\n \n assets\n end", "def controller_javascript_tags\n \n lo_files = []\n \n required_cc_files.each do |f|\n fn = [f,\"js\"].join(\".\")\n unless Rails.application.assets.find_asset(fn).nil?\n lo_files << javascript_include_tag(fn)\n end\n end\n\n lo_files.join.html_safe\n\n end", "def precompile_assets=(_arg0); end", "def sync_js\n if self.sync_js_dir(💎.engine.dir('services/web_assets/src/'), \"#{@path_base}src/\")\n self.build_js(true)\n self._sync_js(true)\n end\n\n end", "def set_assets\n\n @custom_csses = []\n @custom_javascripts = []\n\n\n action_hash = {\"create\" => \"new\", \"update\" => \"edit\"}\n file_name = action_hash[action_name] ? action_hash[action_name] : action_name\n root = Rails.root.to_s\n\n @custom_csses << \"compiled/application.css\" # always include the layout css\n @custom_csses << \"compiled/#{controller_name}/#{file_name}.css\" if File.exist?(\"#{root}/public/stylesheets/compiled/#{controller_name}/#{file_name}.css\")\n @custom_csses << \"compiled/#{controller_name}/all.css\" if File.exist?(\"#{root}/public/stylesheets/compiled/#{controller_name}/all.css\")\n\n\n @custom_javascripts << \"#{controller_name}/#{file_name}.js\" if File.exist?(\"#{root}/public/javascripts/#{controller_name}/#{file_name}.js\") # && !(\"#{file_name}.js\" == \"consumer_index.js\")\n @custom_javascripts << \"#{controller_name}/all.js\" if File.exist?(\"#{root}/public/javascripts/#{controller_name}/all.js\")\n\n # a trick to include facebox in the (devise-owned) registrations controller\n include_facebox if controller_name == 'registrations' && action_name == 'edit'\n\n end", "def assets_manifest; end", "def assets_manifest; end", "def active_scaffold_includes\r\n js = ActiveScaffold::Config::Core.javascripts.collect do |name|\r\n javascript_include_tag(ActiveScaffold::Config::Core.asset_path(:javascript, name))\r\n end.join('')\r\n\r\n css = stylesheet_link_tag(ActiveScaffold::Config::Core.asset_path(:stylesheet, \"stylesheet.css\"))\r\n ie_css = stylesheet_link_tag(ActiveScaffold::Config::Core.asset_path(:stylesheet, \"stylesheet-ie.css\"))\r\n\r\n js + \"\\n\" + css + \"\\n<!--[if IE]>\" + ie_css + \"<![endif]-->\\n\"\r\n end", "def build_app_caches(app_name, instance_name)\n Dir.chdir RailsPwnerer::Config[app_name, instance_name][:app_path] do\n if File.exist?('Gemfile')\n Kernel.system 'bundle exec rake assets:precompile RAILS_ENV=production'\n else\n Kernel.system 'rake assets:precompile RAILS_ENV=production'\n end\n end\n end", "def add_jader_views_to_path\n path = Rails.root.join('app','assets','javascripts','apps', @platform, 'templates')\n prepend_view_path path\n end", "def development\r\n\r\n end", "def inject_blacklight_browse_nearby_require\n unless IO.read(\"app/assets/stylesheets/application.css\").include?(\"Required by BlacklightBrowseNearby\")\n insert_into_file \"app/assets/stylesheets/application.css\", :after => \"/*\" do\n %q{\n * Required by BlacklightBrowseNearby:\n *= require blacklight_browse_nearby/blacklight_browse_nearby\n *}\n end\n end\n unless IO.read(\"app/assets/javascripts/application.js\").include?(\"Required by BlacklightBrowseNearby\")\n insert_into_file \"app/assets/javascripts/application.js\", :before => \"//= require_tree .\" do\n%q{// Required by BlacklightBrowseNearby:\n//= require blacklight_browse_nearby/blacklight_browse_nearby\n}\n end\n end\n end", "def build_combined\n\tself.update_aliases\n\t\n\tcompiler = Closure::Compiler.new\n\t\n\toutput = compiler.compile_files(\n\t\t[\"jquery.syntax.js\", \"jquery.syntax.cache.js\"]\n\t)\n\t\n\tFile.open(MINIFIED_FILE, \"w\") do |file|\n\t\tfile.write(LICENSE)\n\t\tfile.write(output)\n\tend\nend", "def assets_to_compile \n return @assets_to_compile if @assets_to_compile \n files = Dir.glob(prefix + \"**/*\").select {|f| File.file?(f)}\n files.collect! { |f| f.gsub(/^#{prefix}\\//, \"\") }\n end", "def compiled_path; end", "def touch\n respond_to do |format|\n format.js {\n render :text => Netzke::Core::DynamicAssets.touch_js\n }\n\n format.css {\n render :text => Netzke::Core::DynamicAssets.touch_css\n }\n end\n end", "def prepare_for_production\n root_glob = combined_app_root_glob(false)\n root_re = combined_app_root_regexp(false)\n\n # Load application modules\n path_re = /#{root_re}(?<path>.*)/\n Dir.glob(File.join(root_glob, '**/*')) do |file|\n if File.directory? file\n file.match(path_re) do |m|\n mod = File.join(file, File.basename(file)) << '.rb'\n if File.file? mod\n require_for_production mod\n else\n Object.const_set_recursive(m[:path].camelize, Module.new)\n end\n end # match\n end # if\n end\n\n # Load templates\n file_re = /#{root_re}(?<path>.*)\\/.*\\.(?<template>.*)\\./\n Dir.glob(File.join(root_glob, \"**/*#{TEMPLATE_EXT}\")) do |file|\n file.match(file_re) do |m|\n ios = StringIO.new\n TemplateCompiler.compile_template(\n ios, File.read(file), m[:path].camelize, m[:template],\n false, @context.timers\n )\n m[:path].camelize.constantize.class_eval(ios.string)\n end # match\n end # glob\n\n # Load CSS\n css = CssCompressor.compress(compile_css(StringIO.new).string)\n Application.use(Rack::FrozenRoute, %r{/bundle.css}, 'text/css', css)\n Application.pull_down(Rack::StaticDir)\n end", "def webpack_dev_server_tag\n if Rails.configuration.webpack.dev_server.enabled\n javascript_include_tag \"http://#{Rails.configuration.webpack.dev_server.host}:#{Rails.configuration.webpack.dev_server.port}/webpack-dev-server.js\"\n end\n end", "def jsx_transform_code\n ::Rails.application.assets[@asset_path].to_s\n end", "def init\t\n\tenable :static\n\tset :statics_folder, 'statics'\n\tset :deep_or_flat_structure, 'flat'\n\n\tset :public_folder, settings.statics_folder\n\n\tset :page_pool, page_pool()\nend", "def init! options = {}\n verify_rails!\n copy_template :rails, :to => :jspec\n vendorize_with_symlink if options.include? :symlink\n vendorize_with_copy if options.include? :freeze\n replace_root\n end", "def ext ext = nil\n @ext = normalize_path(ext.to_s) if ext && configurable?\n @setup[:ext] ||= @ext ||\n (@controller.ctrl.slice.view.ext if @controller) ||\n Presto.view.ext\n end", "def active_scaffold_ie_stylesheets(frontend = :default)\r\n ActiveScaffold::Config::Core.asset_path(\"stylesheet-ie.css\", frontend)\r\n end", "def compile_js_sources(base_dir, definitions)\n chdir(base_dir) do\n definitions.each do |definition|\n\n jscompressor = :uglifyjs\n\n sources = definition['inputs'].join(' ')\n\n sh %{cat #{sources} > #{definition['output']}.tmp}\n sh %{#{jscompressor} #{definition['output']}.tmp > #{definition['output']}}\n rm definition['output'] + '.tmp'\n end\n end\nend", "def output_ext\n end" ]
[ "0.6672198", "0.63841134", "0.62464255", "0.62149256", "0.6169453", "0.61687607", "0.6008034", "0.59936416", "0.59929276", "0.59929276", "0.59812254", "0.59486586", "0.59182674", "0.59182674", "0.5897309", "0.58845794", "0.5853264", "0.5851368", "0.58097774", "0.57962453", "0.57958037", "0.57900935", "0.5743954", "0.5742923", "0.57273316", "0.5726741", "0.5721058", "0.57195383", "0.57106966", "0.5700523", "0.56871605", "0.56408364", "0.56315964", "0.5622716", "0.56113917", "0.56088567", "0.56041545", "0.56041545", "0.56041545", "0.56040967", "0.55985576", "0.5593359", "0.5583817", "0.55770195", "0.55583125", "0.55335546", "0.55234337", "0.5475963", "0.54724765", "0.5469461", "0.54593414", "0.54593414", "0.54567045", "0.5450907", "0.5436026", "0.542839", "0.542839", "0.542839", "0.5416474", "0.5408228", "0.54013294", "0.5397682", "0.5397682", "0.5396015", "0.53718066", "0.5370785", "0.5369752", "0.5366869", "0.5359152", "0.53565246", "0.535466", "0.5344029", "0.53417027", "0.5336447", "0.5333222", "0.5323396", "0.5323342", "0.5308585", "0.53001297", "0.5295575", "0.5284813", "0.5284015", "0.5282469", "0.527991", "0.52764547", "0.5269117", "0.52673584", "0.5264031", "0.5263721", "0.5254717", "0.52526164", "0.52491295", "0.52409697", "0.52391744", "0.52302456", "0.52241987", "0.5222829", "0.5217762", "0.5215836", "0.5212017" ]
0.6852749
0
Used in development mode for onthefly generation of public/netzke/touch.[js|css]
def touch respond_to do |format| format.js { render :text => Netzke::Core::DynamicAssets.touch_js } format.css { render :text => Netzke::Core::DynamicAssets.touch_css } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_dev\n timer_block(\n 'Start [development] build for *.js files',\n 'JS time: ') do\n all_js_into_one_file\n end\n end", "def precompile_assets; end", "def request_debug_assets?; end", "def request_debug_assets?; end", "def js\n puts 'Compressing JS files...'\n `java -jar ./_scripts/yuicompressor-2.4.2.jar ../www/_res/js/uncompressed/main.js -o ../www/_res/js/main.js`\n # --nomunge\nend", "def add_vendor_files\n say_quietly \"Copying files...\"\n\n %w[auth backend frontend].each do |section|\n template \"vendor/assets/javascripts/archangel/#{section}.js\"\n template \"vendor/assets/stylesheets/archangel/#{section}.css\"\n end\n end", "def install_sample_files\n super\n inject_line_before root.join('apps/web/templates/application.html.erb'), '</head>', <<-HTML\n <%= vite_client %>\n <%= vite_javascript 'application' %>\n HTML\n end", "def copy_styles_and_js\n base_dir = @generator.base_dir\n Dir.mkdir(\"#{base_dir}/js\")\n FileUtils.cp(\"#{Amy::BASE_DIR}/views/js/amy.min.js\", \"#{base_dir}/js/amy.js\")\n FileUtils.cp(\"#{Amy::BASE_DIR}/views/js/data.json\", \"#{base_dir}/data.json\") \n Dir.mkdir(\"#{base_dir}/style\")\n FileUtils.cp(\"#{Amy::BASE_DIR}/views/style/style.css\", \"#{base_dir}/style/style.css\")\n end", "def vite_client_src\n prefix_vite_asset('@vite/client') if dev_server_running?\n end", "def generate()\n\t\tjdc='jekyll_date_chart.js'\n\t\tcopy_file \"lib/#{jdc}\", \"_assets/javascripts/#{jdc}\"\n\n\t\tdirectory 'vendor/assets/javascripts/', '_assets/javascripts/'\n\t\tdirectory 'vendor/assets/stylesheets/', '_assets/stylesheets/'\n\tend", "def generate(site)\n # Current directory is the root-level directory\n js_vendor_dir = 'source/_assets/javascripts/vendor/'\n js_file_name = 'mail-helper.js'\n js_full_name = js_vendor_dir + js_file_name\n\n mail_obfuscate_js = File.read(js_full_name)\n Liquid::Template.register_filter(MReverse)\n output_js = Liquid::Template.parse(mail_obfuscate_js).\n render('site' => site.config)\n File.write(js_full_name, output_js)\n end", "def to_production_html\n \"<script type='text/javascript' src='%s?%s'></script>\" % [path, mtime.to_i]\n end", "def generate_coffee\n if options.coffee?\n directory \"app/assets/javascripts/kublog\"\n end\n end", "def generate_files\n copy_file 'who_is_online_channel.rb', \"app/channels/#{name}_channel.rb\"\n copy_file 'who_is_online.coffee', \"app/assets/javascripts/channels/#{name}.coffee\"\n end", "def ext\n respond_to do |format|\n format.js {\n render :text => Netzke::Core::DynamicAssets.ext_js\n }\n\n format.css {\n render :text => Netzke::Core::DynamicAssets.ext_css\n }\n end\n end", "def compile_js_files(file, prod=true)\n\t# use development style options for now, even in production\n\tif prod\n\t\toptions = {:output => {:comments => :none }}\n\t\tFile.open(file, \"w\") { |f| f.write(Uglifier.compile(concat_js_files, options)) }\n\telse\n\t\t#options = {:output => {:comments => :all, :beautify => true, :preserve_line => true}}\n\t\tFile.open(file, \"w\") { |f| f.write(concat_js_files) }\n\tend\n\n\tputs \" \\e[32mwrite #{file}\\e[0m\"\nend", "def copy_javascripts\n if ::Rails.version[0..2].to_f >= 3.1\n #puts \"The javascripts do not need to be installed since Rails 3.1\"\n else\n copy_file \"../../../../../app/assets/javascripts/on_the_spot_code.js\", \"public/javascripts/on_the_spot.js\"\n copy_file \"../../../../../app/assets/javascripts/jquery.jeditable.js\", \"public/javascripts/jquery.jeditable.js\"\n copy_file \"../../../../../app/assets/javascripts/jquery.jeditable.checkbox.js\", \"public/javascripts/jquery.jeditable.checkbox.js\"\n copy_file \"../../../../../app/assets/stylesheets/on_the_spot.css\", \"public/stylesheets/on_the_spot.css\"\n end\n end", "def min_js_file\n build_path.join('scripts.min.js')\n end", "def index_prebuilt!\n Dir.glob(\"#{PREBUILT_DIR}/**/[^_]*.*\") do |filename|\n config.add_page(filename.sub(\"#{PREBUILT_DIR}/\", ''), file: filename, digest: true)\n end\n end", "def asset_handler\n tags = String.new\n tags << tag(:link, rel: \"stylesheet\", href: \"/stylesheets/icons.css\")\n if controller_name == \"rich_subscriptions\"\n tags << content_tag(:script, \"\", src: \"/javascripts/#{fingerprinted_asset('map')}.js\")\n tags << tag(:link, rel: \"stylesheet\", href: \"/stylesheets/leaflet/leaflet.css\")\n tags << tag(:link, rel: \"stylesheet\", href: \"/stylesheets/leaflet/leaflet-slider.css\")\n tags << tag(:link, rel: \"stylesheet\", href: \"/stylesheets/leaflet/L.Control.Locate.min.css\")\n tags << tag(:link, rel: \"stylesheet\", href: \"/stylesheets/#{fingerprinted_asset('map')}.css\")\n else\n tags << content_tag(:script, \"\", src: \"/javascripts/#{fingerprinted_asset('application')}.js\")\n tags << tag(:link, rel: \"stylesheet\", href: \"/stylesheets/#{fingerprinted_asset('application')}.css\")\n end\n tags.html_safe\n end", "def all_js_into_one_file\n File.open(base_js_file, 'w') do |file|\n js_files.each do |js_file|\n file.write('/* file: ' + js_file + \" */\\n\") if development?\n file.write(File.read(js_file))\n end\n end\n end", "def javascript_include_tag(file_name)\n path_prefix = development? ? '/assets/' : '/js/'\n suffix = development? ? '' : \"-#{Heliom::Labs::VERSION}.min\"\n %(<script src=\"#{path_prefix}#{file_name}#{suffix}.js\"></script>)\nend", "def assets; end", "def assets; end", "def assets; end", "def static_files; end", "def netzke_js\n send :\"netzke_#{Netzke::Core.platform}_js\"\n end", "def setup_app_files\n cp HANAMI_TEMPLATES.join('config/hanami-vite.json'), config.config_path\n inject_line_after root.join('config/environment.rb'), 'environment :development do', ' middleware.use(ViteRuby::DevServerProxy, ssl_verify_none: true) if ViteRuby.run_proxy?'\n inject_line_after_last root.join('apps/web/application.rb'), 'include Web::Assets::Helpers', ' include ViteHanami::TagHelpers'\n inject_line_after root.join('apps/web/application.rb'), 'configure :development do', <<-CSP\n # Allow @vite/client to hot reload changes in development\n security.content_security_policy(\n security.content_security_policy\n .sub('script-src', \"script-src 'unsafe-eval'\")\n .sub('connect-src', \"connect-src ws://\\#{ ViteRuby.config.host_with_port }\")\n )\n CSP\n append root.join('Rakefile'), <<~RAKE\n require 'vite_hanami'\n ViteRuby.install_tasks\n RAKE\n end", "def netzke_init(params = {})\n theme = params[:ext_theme] || :default\n [netzke_css_include(theme), netzke_js_include, netzke_js].join(\"\\n\")\n end", "def build_for_demo \n `elm make elm/Main.elm --output assets/js/elm.js`\n `minify assets/js/elm.js assets/js/elm.min.js`\n FileUtil.cp \"assets/js/elm.js\" \"../demo-elm-doc-builder/assets/js/elm.js\"\n FileUtil.cp \"assets/js/elm.min.js\" \"../demo-elm-doc-builder/assets/js/elm.min.js\"\nend", "def assets\n unless IO.read(\"app/assets/stylesheets/application.css\").include?(\"Required by SULChrome\")\n insert_into_file \"app/assets/stylesheets/application.css\", :after => \"/*\" do\n %q{\n * Required by SULChrome:\n *= require sul_chrome/sul_chrome_base\n *}\n end\n end\n unless IO.read(\"app/assets/javascripts/application.js\").include?(\"Required by SULChrome\")\n insert_into_file \"app/assets/javascripts/application.js\", :before => \"//= require_tree .\" do\n%q{// Required by SULChrome:\n//= require sul_chrome/sul_chrome_base\n}\n end\n end\n end", "def compressViews\n data = combineViews\n filename = File.join(Rails.root, 'public/javascripts/generated', \"hamlViewFiles.js\")\n FileUtils.touch(filename)\n File.open(filename, 'w+') do |file|\n file.write data\n end\nend", "def render_deferred_javascript_files\n #write any deffered javascript files\n return '' if @content_for_javascript_files.blank?\n js_code = \"\\n<!-- DEFFERRED Javascripts -->\\n#{@content_for_javascript_files}\"\n end", "def config_js\n [\n src_config_path.join('routes.js').to_s,\n src_config_path.join('router.js').to_s,\n src_config_path.join('app.js').to_s\n ]\n end", "def build_app_caches(app_name, instance_name)\n Dir.chdir RailsPwnerer::Config[app_name, instance_name][:app_path] do\n if File.exist?('Gemfile')\n Kernel.system 'bundle exec rake assets:precompile RAILS_ENV=production'\n else\n Kernel.system 'rake assets:precompile RAILS_ENV=production'\n end\n end\n end", "def development\r\n\r\n end", "def netzke_js_include\n send :\"netzke_#{Netzke::Core.platform}_js_include\"\n end", "def copy_public_assets \n generate \"blacklight:assets\"\n end", "def run_on_modifications(paths = [])\n hash = {}\n \n # Get all files.\n paths = Dir.glob(\"#{@options[:input]}/**/*\").select do |path|\n not File.directory? path\n end\n \n paths.each do |path|\n file = File.read path\n compiled = ::EJS.compile file\n hash[path] = compiled\n \n UI.info \"[Guard::EJS] Compiled #{path}.\"\n end\n \n # Just overwrite the whole thing for now.\n FileUtils.mkdir_p File.dirname(@options[:output])\n \n File.open(@options[:output], 'w+') do |file|\n file.write \"window.#{@options[:namespace]} = window.#{@options[:namespace]} || {}\\n\"\n file.write \"window.#{@options[:namespace]}.templates = {\"\n \n hash.each do |name, template|\n file.write \"\\\"#{name}\\\": #{template},\"\n end\n \n file.write \"}\"\n end\n end", "def sync_js\n if self.sync_js_dir(💎.engine.dir('services/web_assets/src/'), \"#{@path_base}src/\")\n self.build_js(true)\n self._sync_js(true)\n end\n\n end", "def set_generated_assets_dir\n ReactOnRails.configuration.generated_assets_dir = Basch::Application.config.generated_frontend_assets_dir\n end", "def add_jader_views_to_path\n path = Rails.root.join('app','assets','javascripts','apps', @platform, 'templates')\n prepend_view_path path\n end", "def precompiled_assets(clear_cache = T.unsafe(nil)); end", "def precompiled_assets(clear_cache = T.unsafe(nil)); end", "def initial_dynamic_javascript\n res = []\n # res << %(Ext.Ajax.extraParams = {authenticity_token: '#{form_authenticity_token}'}; // Rails' forgery protection)\n res << %{Ext.ns('Netzke');}\n res << %{Ext.ns('Netzke.core');}\n res << %{Netzke.RelativeUrlRoot = '#{ActionController::Base.config.relative_url_root}';}\n res << %{Netzke.RelativeExtUrl = '#{ActionController::Base.config.relative_url_root}/extjs';}\n\n res << %{Netzke.core.directMaxRetries = '#{Netzke::Core.js_direct_max_retries}';}\n\n res.join(\"\\n\")\n end", "def compile_coffee_to_js\n files = ['level_core', 'path_core', 'deadlock_core']\n files.each do |file|\n if File.exist?(\"lib/assets/#{file}.js\")\n File.delete(\"lib/assets/#{file}.js\")\n end\n compile_file_coffee_to_js(\"app/assets/javascripts/game/models/#{file}.js.coffee\", \"lib/assets/#{file}.js\")\n end\nend", "def set_static_includes\r\n @javascripts = [JS_SCRIPTACULOUS_SKOBEE_DEFAULT, JS_SKOBEE_PLANS, JS_DATEPICKER, JS_JSON]\r\n end", "def to_development_html\n hrefs.map { |href| \"<script type='text/javascript' src='#{href}'></script>\" }.join(\"\\n\")\n end", "def assets_manifest; end", "def assets_manifest; end", "def precompile_assets=(_arg0); end", "def javascript_compile_list\n\t[\t\n\t\t# Wordpress distributed JS (not monitored for changes...)\n\t\t#\"../../../wp-includes/js/jquery/jquery-migrate.min.js\",\n\t\t#\"../../../wp-includes/js/jquery/jquery.masonry.min.js\",\n\n\t\t# Theme JS\n\t\t\"js/jquery-1.11.0.js\",\n\t\t\"js/jquery-ui-1.10.4.datepicker.js\",\n\t\t\"js/jquery.cookie.js\",\n\t\t\"js/functions.js\",\n\t\t\"js/imagelightbox.js\",\n\t\t\"js/lightboxinit.js\",\n\t\t\"js/jflickrfeed.js\",\n\t\t\"js/flickrsetup.js\",\n\t\t\"js/vender.js\", \n\t\t\"js/scrollTo.js\",\n\t\t\"js/placeholder.js\",\n\t\t\"js/default.js\",\n\t\t\"js/campus-libraries.js\",\n\t\t\"js/find-a-library.js\",\n\t\t\"js/datepicker.js\",\n\t\t\"js/library.js\",\n\t\t\"js/directory.js\",\n\t\t\"js/liaison.js\",\n\t\t\"js/locations.js\",\n\t\t\"js/ask.js\",\n\t\t\"js/alerts.js\",\n\t\t\"js/google-support.js\",\n\t\t\"js/locate.js\"\n\t]\nend", "def assets\n\n javascript={}\n css={}\n\n Dir.glob(bower_asset_path+'/production/*.html').each { |path|\n next if files_omit.include?(File.basename(path))\n page = Nokogiri::HTML(open(path))\n javascript[path]=[]\n css[path]=[]\n page.css('script').each { |st|\n javascript[path] << st.attr('src').sub('../vendors/', '') if st.attr('src') && st.attr('src').start_with?('../')\n }\n page.css('link').each { |st|\n css[path] << st.attr('href').sub('../vendors/', '') if st.attr('rel') && st.attr('rel') == 'stylesheet'\n }\n }\n\n# Merge the lists of script and css references using array union\n javascript_src=[]\n javascript.values.map { |s| javascript_src = javascript_src | s }\n javascript_src.uniq!\n\n# Omit the references that we won't include in the gem\n javascript_omit.each { |s| javascript_src.delete(s) }\n\n css_src=[]\n css.values.map { |s| css_src = css_src | s }\n css_src.uniq!\n\n css_omit.each { |s| css_src.delete(s) }\n\n {\n javascript: javascript_src,\n css: css_src,\n }\n\nend", "def run\n app, config = @app, @app.config\n return unless app.assets\n\n config.assets.paths.each { |path| app.assets.append_path(path) }\n\n if config.assets.compress\n # temporarily hardcode default JS compressor to uglify. Soon, it will work\n # the same as SCSS, where a default plugin sets the default.\n unless config.assets.js_compressor == false\n js_compressor = config.assets.js_compressor || :uglifier\n app.assets.js_compressor = LazyCompressor.new { Sprockets::Rails::Compressors.registered_js_compressor(js_compressor) }\n end\n\n unless config.assets.css_compressor == false\n css_compressor = config.assets.css_compressor\n app.assets.css_compressor = LazyCompressor.new { Sprockets::Rails::Compressors.registered_css_compressor(css_compressor) }\n end\n end\n\n if config.assets.compile\n app.routes.prepend do\n mount app.assets => config.assets.prefix\n end\n end\n\n if config.assets.digest\n app.assets = app.assets.index\n end\n end", "def netzke_init(params = {})\n Netzke::Core.platform = params[:platform] || :ext\n theme = params[:theme] || params[:ext_theme] || :default\n raw([netzke_css_include(theme), netzke_css, netzke_js_include, netzke_js].join(\"\\n\"))\n end", "def source_files; end", "def webpack_dev_server_tag\n if Rails.configuration.webpack.dev_server.enabled\n javascript_include_tag \"http://#{Rails.configuration.webpack.dev_server.host}:#{Rails.configuration.webpack.dev_server.port}/webpack-dev-server.js\"\n end\n end", "def run\n app, config = @app, @app.config\n return unless app.assets\n\n config.assets.paths.each { |path| app.assets.append_path(path) }\n\n if config.assets.compress\n # temporarily hardcode default JS compressor to uglify. Soon, it will work\n # the same as SCSS, where a default plugin sets the default.\n unless config.assets.js_compressor == false\n app.assets.js_compressor = LazyCompressor.new { expand_js_compressor(config.assets.js_compressor || :uglifier) }\n end\n\n unless config.assets.css_compressor == false\n app.assets.css_compressor = LazyCompressor.new { expand_css_compressor(config.assets.css_compressor) }\n end\n end\n\n if config.assets.compile\n app.routes.prepend do\n mount app.assets => config.assets.prefix\n end\n end\n\n if config.assets.digest\n app.assets = app.assets.index\n end\n end", "def prepare_for_production\n root_glob = combined_app_root_glob(false)\n root_re = combined_app_root_regexp(false)\n\n # Load application modules\n path_re = /#{root_re}(?<path>.*)/\n Dir.glob(File.join(root_glob, '**/*')) do |file|\n if File.directory? file\n file.match(path_re) do |m|\n mod = File.join(file, File.basename(file)) << '.rb'\n if File.file? mod\n require_for_production mod\n else\n Object.const_set_recursive(m[:path].camelize, Module.new)\n end\n end # match\n end # if\n end\n\n # Load templates\n file_re = /#{root_re}(?<path>.*)\\/.*\\.(?<template>.*)\\./\n Dir.glob(File.join(root_glob, \"**/*#{TEMPLATE_EXT}\")) do |file|\n file.match(file_re) do |m|\n ios = StringIO.new\n TemplateCompiler.compile_template(\n ios, File.read(file), m[:path].camelize, m[:template],\n false, @context.timers\n )\n m[:path].camelize.constantize.class_eval(ios.string)\n end # match\n end # glob\n\n # Load CSS\n css = CssCompressor.compress(compile_css(StringIO.new).string)\n Application.use(Rack::FrozenRoute, %r{/bundle.css}, 'text/css', css)\n Application.pull_down(Rack::StaticDir)\n end", "def prepare_for_development\n FileUtils.rm_r(Dir[File.join(@context.gen_root, '*')])\n FileUtils.rm(\n File.join(@context.public_root, 'bundle.css'),\n :force => true\n )\n end", "def set_assets\n\n @custom_csses = []\n @custom_javascripts = []\n\n\n action_hash = {\"create\" => \"new\", \"update\" => \"edit\"}\n file_name = action_hash[action_name] ? action_hash[action_name] : action_name\n root = Rails.root.to_s\n\n @custom_csses << \"compiled/application.css\" # always include the layout css\n @custom_csses << \"compiled/#{controller_name}/#{file_name}.css\" if File.exist?(\"#{root}/public/stylesheets/compiled/#{controller_name}/#{file_name}.css\")\n @custom_csses << \"compiled/#{controller_name}/all.css\" if File.exist?(\"#{root}/public/stylesheets/compiled/#{controller_name}/all.css\")\n\n\n @custom_javascripts << \"#{controller_name}/#{file_name}.js\" if File.exist?(\"#{root}/public/javascripts/#{controller_name}/#{file_name}.js\") # && !(\"#{file_name}.js\" == \"consumer_index.js\")\n @custom_javascripts << \"#{controller_name}/all.js\" if File.exist?(\"#{root}/public/javascripts/#{controller_name}/all.js\")\n\n # a trick to include facebox in the (devise-owned) registrations controller\n include_facebox if controller_name == 'registrations' && action_name == 'edit'\n\n end", "def copy_public_assets \n generate \"blacklight:assets\"\n end", "def assets_path() = self.class.name.demodulize.delete_suffix('Generator').underscore", "def set_static_includes\r\n @javascripts = [JS_SCRIPTACULOUS_SKOBEE_DEFAULT, JS_SKOBEE_COMMENTS]\r\n end", "def init! options = {}\n verify_rails!\n copy_template :rails, :to => :jspec\n vendorize_with_symlink if options.include? :symlink\n vendorize_with_copy if options.include? :freeze\n replace_root\n end", "def js_files\n [\n vue_lib_js, mixins_js, filters_js, components_js,\n pages_js, config_js\n ].flatten!\n end", "def allow_production; end", "def assets_to_compile \n return @assets_to_compile if @assets_to_compile \n files = Dir.glob(prefix + \"**/*\").select {|f| File.file?(f)}\n files.collect! { |f| f.gsub(/^#{prefix}\\//, \"\") }\n end", "def digest\n serve_assets == \"local_dynamic\" ? false : true \n end", "def uglify(file)\n #'hello world'\n template = Tilt.new(File.join('views',file)).render(self)\n Uglifier.compile(template)\n #Uglifier.compile(ERB.new(File.read(File.join('views', file))).result(binding).force_encoding('UTF-8').gsub(/^#.*?\\n/,''))\n end", "def active_scaffold_javascripts(frontend = :default)\r\n ActiveScaffold::Config::Core.javascripts(frontend).collect do |name|\r\n ActiveScaffold::Config::Core.asset_path(name, frontend)\r\n end\r\n end", "def prepare_js\n compile_templates\n compile_controllers\n end", "def comment_for_phantom_script\n \"# Path to magick.js used to render a web page (using PhantomJS, a headless WebKit)\\n\"\n end", "def concat_js_files\n\tjavascript_compile_list.map { |f| File.read(f) }.join\nend", "def source\n source = source_compiler['jison.js'].to_s\n source_compiler.each_logical_path do |logical_path|\n next if logical_path == 'jison.js'\n src = source_compiler[logical_path].to_s\n logical_path.sub! /\\.js$/, ''\n source.concat \"require.def('#{logical_path}',{factory:function(require,exports,module){#{src}}});\"\n end\n source + \"var Dock = require('dock').Dock;\"\n end", "def regenerator; end", "def init_config_folder\n copy_file('config/app.js', src_path('config/app.js'))\n copy_file('config/routes.js', src_path('config/routes.js'))\n copy_file('config/router.js', src_path('config/router.js'))\n end", "def build_combined\n\tself.update_aliases\n\t\n\tcompiler = Closure::Compiler.new\n\t\n\toutput = compiler.compile_files(\n\t\t[\"jquery.syntax.js\", \"jquery.syntax.cache.js\"]\n\t)\n\t\n\tFile.open(MINIFIED_FILE, \"w\") do |file|\n\t\tfile.write(LICENSE)\n\t\tfile.write(output)\n\tend\nend", "def after_release_email(tag, note, type, selector, options) \n command = \"origen web compile --remote --api\" \n Dir.chdir Origen.root do \n system command \n end \n end", "def add_compressed_routes!\n assets.packages.each do |name, package|\n get package.route_regex do\n if defined?(settings.assets.app.clear_tilt_cache) && settings.assets.app.clear_tilt_cache\n AssetPack.clear_tilt_cache!(@template_cache, settings.assets.app)\n end\n\n mtime, contents = @template_cache.fetch(package.path) {\n [ package.mtime, package.minify ]\n }\n\n content_type package.type\n last_modified mtime\n assets_expires\n contents\n end\n end\n end", "def asset_precompiled?(logical_path); end", "def asset_precompiled?(logical_path); end", "def compile_templates\n dir = File.join(Frank.root, Frank.dynamic_folder)\n\n Dir[File.join(dir, '**{,/*/**}/*')].each do |path|\n if File.file?(path) && !File.basename(path).match(/^(\\.|_)/)\n path = path[ (dir.size + 1)..-1 ]\n ext = File.extname(path)\n new_ext = ext_from_handler(ext)\n name = File.basename(path, ext)\n\n # No suitable handler found\n if not new_ext.is_a? String\n next\n end\n\n if Frank.production? && \"#{name}.#{new_ext}\" != 'index.html' && new_ext == 'html'\n new_file = File.join(Frank.export.path, path.sub(/(\\/?[\\w-]+)\\.[\\w-]+$/, \"\\\\1/index.#{new_ext}\"))\n else\n new_file = File.join(Frank.export.path, path.sub(/\\.[\\w-]+$/, \".#{new_ext}\"))\n end\n\n create_dirs(new_file)\n File.open(new_file, 'w') {|f| f.write render(path) }\n puts \" - \\033[32mCreating\\033[0m '#{new_file}'\" unless Frank.silent_export?\n end\n end\n end", "def copy_or_fetch\n filename_pattern = File.join self.class.source_root, \"*\" #/*.html.#{template_engine}\"\n Dir.glob(filename_pattern).map {|f| File.basename f}.each do |f|\n directory f.to_s, \"app/views/#{f}\"\n end\n end", "def production_opening\n $: << File.expand_path(File.dirname(__FILE__) + \"/lib\")\n $USE_SERVER = false\n end", "def copy_assets; end", "def controller_javascript_tags\n \n lo_files = []\n \n required_cc_files.each do |f|\n fn = [f,\"js\"].join(\".\")\n unless Rails.application.assets.find_asset(fn).nil?\n lo_files << javascript_include_tag(fn)\n end\n end\n\n lo_files.join.html_safe\n\n end", "def before_build\n file_patterns = options[:files] || '*.mustache'\n files = Dir[*[file_patterns].flatten]\n vars = {\n :env => pusher.env,\n :config => pusher.config\n }.merge(options[:vars] || {})\n Couchino.logger.debug \"Mustache vars: #{vars.inspect}\"\n files.each do |file|\n Couchino.logger.debug \"Running #{file} through mustache.\"\n basename = File.basename(file)\n dir = File.dirname(file)\n parts = basename.split(/\\./)\n new_file = parts.length > 2 ? parts[0..-2].join('.') : parts[0] + \".html\"\n File.open(File.join(dir, new_file), 'w') do |f|\n f << ::Mustache.render(File.read(file), vars)\n end\n Couchino.logger.debug \"Wrote to #{new_file}\"\n end\n end", "def sg_usemin_js(path, options={})\n usemin = SlimGruntHelpers::Models::UseminJs.new\n options = { alt: nil, absolute: false }.merge!(options)\n\n alt = ''\n alt = \"(#{ options[:alt] })\" unless options[:alt].nil?\n\n text = \"\\n<!-- build:js#{ alt } #{ path } -->\\n\"\n yield(usemin)\n usemin.each(options) do |link|\n text << \"#{ link }\\n\"\n end\n text << \"<!-- endbuild -->\\n\"\n end", "def asset_host; end", "def asset_host; end", "def code(env)\n html_code <<\n css_code <<\n render(js_code,\n :TOKEN => Webconsole::Repl.token,\n :KEY_CODE => Webconsole.key_code,\n :CONTEXT => env['SCRIPT_NAME'] || \"\")\n end", "def precompile_assets\n if rails? && defined?(Rake)\n ::Rake::Task['assets:precompile'].enhance do\n svgs.map(&:build)\n end\n end\n end", "def generate_html_views\n selective_copy 'app/views/kublog/posts/*.html.erb'\n end", "def after_release_email(tag, note, type, selector, options)\n command = \"origen web compile --remote --api\"\n Dir.chdir Origen.root do\n system command\n end\n end", "def compile_js_sources(base_dir, definitions)\n chdir(base_dir) do\n definitions.each do |definition|\n\n jscompressor = :uglifyjs\n\n sources = definition['inputs'].join(' ')\n\n sh %{cat #{sources} > #{definition['output']}.tmp}\n sh %{#{jscompressor} #{definition['output']}.tmp > #{definition['output']}}\n rm definition['output'] + '.tmp'\n end\n end\nend", "def load_js\n AssetManager.include_contrib_library [:core_ui, :jquery_tab]\n AssetManager.include_local_library [ 'ckeditor/init']\n\n AssetManager.include_css [:blog_global]\n end", "def init_build\n if run_build?\n config('build_assets', true, true)\n else\n config('build_assets', false, true)\n end\n end", "def compress_all\n\tself.build_combined\n\t\n\tfiles = Dir[\"jquery.syntax*.js\"]\n\tcompiler = Closure::Compiler.new\n\t\n\tputs \"Minifying JavaScript...\"\n\tfiles.each do |path|\n\t\tputs \"Minifying #{File.basename(path)}...\"\n\t\t\n\t\toutput = compiler.compile_files([path])\n\t\t\n\t\tFile.open(path, \"w\") do |file|\n\t\t\tfile.write(LICENSE)\n\t\t\tfile.write(output)\n\t\tend\n\tend\nend", "def set_generated_assets_dir\n ReactOnRails.configuration.generated_assets_dir = Basch::Application.config.generated_backend_assets_dir\n end" ]
[ "0.66531837", "0.62821525", "0.6220736", "0.6220736", "0.6187166", "0.6154933", "0.6081586", "0.6038984", "0.5971961", "0.59503865", "0.5941376", "0.59234643", "0.5895388", "0.5889352", "0.5878378", "0.58676356", "0.58346045", "0.5809598", "0.5796627", "0.57818174", "0.5780512", "0.57393485", "0.57071054", "0.57071054", "0.57071054", "0.57043964", "0.56481475", "0.5636192", "0.5618491", "0.5616306", "0.5614729", "0.5610362", "0.56018627", "0.55910456", "0.5584935", "0.5584536", "0.5578718", "0.557554", "0.5570561", "0.55660856", "0.55251294", "0.55161", "0.54902345", "0.54902345", "0.54778796", "0.5474626", "0.54740214", "0.54708654", "0.5468399", "0.54675984", "0.5466582", "0.5456426", "0.54404145", "0.5433146", "0.5417519", "0.5406906", "0.54059035", "0.5405467", "0.5388565", "0.5375811", "0.53631485", "0.53599316", "0.53585255", "0.53533876", "0.53425986", "0.53303105", "0.5328648", "0.532419", "0.53130996", "0.5304153", "0.5302492", "0.5300446", "0.5297831", "0.5287178", "0.52863926", "0.52761316", "0.5270652", "0.52670926", "0.52564806", "0.5251551", "0.5251105", "0.5251105", "0.523558", "0.523284", "0.52223074", "0.52183694", "0.5216151", "0.5210456", "0.5206181", "0.5204691", "0.5204691", "0.5204587", "0.52037424", "0.51973355", "0.519102", "0.51842046", "0.5182187", "0.51723784", "0.5166457", "0.5165507" ]
0.65088785
1
Main dispatcher of oldstyle (Sencha Touch) HTTP requests. The URL contains the name of the component, as well as the method of this component to be called, according to the double underscore notation. E.g.: some_grid__post_grid_data.
def endpoint_dispatch(endpoint_path) component_name, *sub_components = endpoint_path.split('__') component_instance = Netzke::Base.instance_by_config(Netzke::Core.session[:netzke_components][component_name.to_sym]) # We render text/plain, so that the browser never modifies our response response.headers["Content-Type"] = "text/plain; charset=utf-8" render :text => component_instance.invoke_endpoint(sub_components.join("__"), params), :layout => false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dispatcher\n endpoint_dispatch(params[:address])\n end", "def method_missing(method_name, params = {})\n component, *action = method_name.to_s.split('__')\n component = component.to_sym\n action = !action.empty? && action.join(\"__\").to_sym\n\n if action\n if components[component]\n # only actions starting with \"endpoint_\" are accessible\n endpoint_action = action.to_s.index('__') ? action : \"_#{action}_ep_wrapper\"\n component_instance(component).send(endpoint_action, params)\n else\n component_missing(component)\n end\n else\n super\n end\n end", "def run url\n # We need to tell Micon about the `:request` scope, so the `:request` component will be\n # destroyed automatically.\n micon.activate :request, {} do\n self.request = Request.new url\n\n # Using router to get controller class and method from the url.\n # Note that You using the `:router` component as if it's just an attribute.\n controller_class, method = router.decode url\n\n # Creating controller and calling it to generate output.\n controller = controller_class.new\n\n # Note we don't need to explicitly pass the `request` to controller, it will be automatically injected.\n controller.send method\n end\n end", "def dispatch(request)\n # {{{\n benchmark_start_time = Time.now \n\n params = Aurita::Attributes.new(request)\n params[:_request] = request\n params[:_session] = Aurita::Session.new(request)\n params[:_logger] = @logger\n params[:_application] = @application\n status = 200\n response_body = ''\n response_header = {}\n\n controller = params[:controller]\n action = params[:action]\n mode = params[:mode]\n controller ||= 'App_Main'\n action ||= 'start'\n mode ||= 'default'\n\n Thread.current['request'] = params\n\n Lore::Connection.reset_query_count()\n Lore::Connection.reset_result_row_count()\n\n begin\n raise ::Exception.new('No controller given') if(controller.nil? || controller == '') \n\n model_klass = @application.get_model_klass(controller)\n controller_klass = @application.get_controller_klass(controller)\n\n raise ::Exception.new('Unknown controller: ' << controller.inspect) unless controller_klass\n \n controller_instance = controller_klass.new(params, model_klass)\n\n response = false\n @logger.debug(\"Calling model interface method #{controller}.#{action}\")\n\n element = controller_instance.call_guarded(action)\n response = controller_instance.response\n if response[:html] == '' then\n if element.is_a?(Aurita::GUI::XML::Document) then\n # Don't use default decorator for XML documents: \n response[:mode] = :none if (!response[:mode] || response[:mode] == :default)\n response[:html] = element.string \n elsif element.respond_to?(:string) then\n # Response is an instance of Aurita::GUI::Element\n response[:html] = element.string \n response[:script] << element.script if element.respond_to?(:script) && element.script\n elsif element.is_a?(Array) then\n element.each { |e|\n response[:html] << e.to_s\n }\n end\n end\n\n response_header.update(response[:http_header]) if response[:http_header]\n if response_header['status_code'] then\n status = response_header['status_code'].to_i \n response_header.delete('status_code')\n end\n\n mode = response[:mode].to_sym if response && response[:mode]\n mode ||= :default \n response[:mode] = mode\n params[:_controller] = controller_instance\n\n response_body = @decorator.render(model_klass, response, params)\n\n @num_dispatches += 1\n\n @benchmark_time = Time.now-benchmark_start_time\n @num_queries = Lore::Connection.query_count\n @num_tuples = Lore::Connection.result_row_count\n Aurita::Plugin_Register.call(Hook.dispatcher.request_finished, \n controller_instance, \n :dispatcher => self, \n :controller => controller_instance, \n :action => action, \n :time => @benchmark_time, \n :num_queries => @num_queries, \n :num_tuples => @num_tuples)\n @logger.debug(\"Num queries: #{@num_queries}\")\n rescue Exception => excep\n @logger.error(excep.message)\n @logger.error(excep.backtrace.join(\"\\n\"))\n response_body = GUI::Error_Page.new(excep).string\n response_body = ''\n end\n\n return [ status, response_header, response_body ]\n end", "def dispatch_request(env)\n @params = Hash.recursively_symbolize_graph!(Rack::Utils::parse_query(env['QUERY_STRING']))\n @json_data = @internal_proxy ? (EventMachineRPC.parse_json_from_file(@params[:json_path]) rescue {}) : {}\n method = strip_base(env)\n self.send(method.to_sym, env)\n end", "def dispatch(name, req, res); end", "def collection_url\n send route_prefix_to_method_name(\"#{class_name.model_name.route_key}_url\")\n end", "def url(name, *args)\n return base_controller.url(name, *args) if base_controller\n super\n end", "def method_missing method, *args, &block\n if main_app_url_helper?(method)\n main_app.send(method, *args)\n else\n super\n end\n end", "def method_missing method, *args, &block\n if main_app_url_helper?(method)\n main_app.send(method, *args)\n else\n super\n end\n end", "def method_missing method, *args, &block\n if main_app_url_helper?(method)\n main_app.send(method, *args)\n else\n super\n end\n end", "def method_missing(method, *args)\n if main_app_url_helper?(method)\n main_app.send(method, *args)\n else\n super\n end\n end", "def dispatch\n body = {\n 'command' => @command,\n 'nodes' => @nodes,\n 'run_timeout' => @timeout\n }\n\n ::Chef_Delivery::ClientHelper.enter_client_mode_as_delivery\n resp = @rest.post_rest('/pushy/jobs', body)\n ::Chef_Delivery::ClientHelper.leave_client_mode_as_delivery\n\n @job_uri = resp['uri']\n refresh\n end", "def dispatch\n Engine.instance.dispatch([self])\n end", "def method_missing(method_name, params = {})\n widget, *action = method_name.to_s.split('__')\n widget = widget.to_sym\n action = !action.empty? && action.join(\"__\").to_sym\n \n if action\n if aggregatees[widget]\n # only actions starting with \"api_\" are accessible\n api_action = action.to_s.index('__') ? action : \"api_#{action}\"\n aggregatee_instance(widget).send(api_action, params)\n else\n aggregatee_missing(widget)\n end\n else\n super\n end\n end", "def dispatch(*args)\n log(:debug) { 'Dispatch message to worker.' }\n\n fetch_idle_worker.future :dispatch, args\n end", "def render(*args)\n path = encode_uri(*args)\n\n debug \"Rendering '#{path}'\" if $DBG\n \n @controller_class, action, query, params, @context.format = @context.dispatcher.dispatch(path)\n# @context.content_type = @context.format.content_type\n\n @context.level += 1\n old_controller_class = Controller.replace_current(@controller_class)\n \n if self.class == @controller_class \n render_action(action, params)\n else\n @controller_class.new(@context).send(:render_action, action, params)\n end\n\n Controller.replace_current(old_controller_class)\n @context.level -= 1\n end", "def method_missing method, *args, &block\n method.to_s.end_with?('_path', '_url') and main_app.respond_to?(method) ? main_app.send(method, *args) : super\n end", "def url_for_main; end", "def url_for_main; end", "def dispatch!\n \n # negotiates initial configuration\n @meta = self.negotiate!\n \n # dispatches hash set to the server\n self.dispatch_hashing!\n self.dispatch_hashset!\n \n # dispatches orders\n self.dispatch_orders!\n \n # dispatches messages\n self.handle_messages!\n \n end", "def method_missing(method, *args, &block)\n if (method.to_s.end_with?('_path') || method.to_s.end_with?('_url')) && main_app.respond_to?(method)\n main_app.send(method, *args, &block)\n else\n super\n end\n end", "def http; end", "def invoke_action(name)\n check_authenticity_token unless req.request_method == 'GET'\n self.send(name)\n self.render(name.to_s) unless already_built_response?\n end", "def test_dispatch_fires_request\n Net::HTTP.class_eval do\n def self.get_response(*_args)\n DummyResponse.new('200')\n end\n end\n\n properties = {\n 'env' => 'dummyKey',\n 'combination' => 1,\n 'url' => 'https://dev.visualwebsiteoptimizer.com/server-side/track-user',\n 'ed' => '{\"p\": \"server\"}',\n 'random' => 0.7382938446947298,\n 'ap' => 'server',\n 'u' => '09CD6107E42B51F9BFC3DD97EA900990',\n 'experiment_id' => 229,\n 'sId' => 1_565_949_670,\n 'sdk-v' => '1.0.2',\n 'sdk' => 'python',\n 'account_id' => 60_781\n }\n\n result = @dispatcher.dispatch(properties, {}, 'end_point')\n assert_equal(result, true)\n\n properties['url']\n properties['url'] = nil\n assert_send([Net::HTTP, :get_response, properties])\n end", "def http_call(payload); 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 url\n @current_controller.url_for :controller => @controller_name, :action => @action_name\n end", "def dispatcher()\n require 'dispatch/dispatch'\n @dispatch = Dispatch.new\n @dispatch.start\n sleep\n end", "def method_missing(m, *args, &block) \n \t\t@proxy_servlet.send(m, *args, &block)\n \t\tend", "def url\n '/' + self.class.name.underscore.gsub('_node', '')\n end", "def method_missing(method_name, *args, &block)\n component.send(method_name,*args,&block)\n end", "def fetch\n url = URI.parse(self.class.url)\n req = Net::HTTP::Post.new(url.path)\n req.body = query_builder\n req.content_type = 'application/x-www-form-urlencoded'\n Net::HTTP.new(url.host, url.port).start {|http| http.request(req) }.body\n end", "def url\n cname = self.class.classname.to_s.downcase\n return \"?show=#{cname}_show&#{cname}_id=#{self.id}\"\n end", "def execute_handler params={},path=nil\n case @type\n when :handlers\n @handlers.each do |handler_ident|\n handler = @context_ref.handlers.fetch(handler_ident) {raise \"handler #{handler_ident} doesn't exist in context #{@context_ref.ref}\"}\n component = handler.(params,path||@url,&:call)\n Context.current_context = @context_ref.ref\n if component.class == Proc\n component.call\n else\n Context.renderer.call(component,handler_ident)\n end\n Context.current_context = :no_context\n end\n when :context\n Context.wipe\n Context.render handlers\n History.push(@context_ref.ref,\"\",[],@context_ref.ref)\n end\n end", "def url\n sprintf(\"%s/%s\",\n ::Configuration.instance.handles[:base_url],\n self.handle)\n end", "def dispatch_action(request)\n method = request_method(request)\n path = request.path.sub(/\\.\\w+$/, '')\n route = @routing.detect { |r| r[0] == method && r[1] == path }\n route[2] if route\n end", "def method_missing(symbol,*args)\n if args.length >= 1\n link_only = false\n if symbol == :link_for\n symbol = args.shift\n link_only = true\n end\n @logger.debug(\"Executing a #{symbol} against gliffy for url #{args[0]}\")\n\n # exposing this for testing\n protocol = determine_protocol(args[1])\n @full_url_no_params = protocol + \"://\" + @api_root + replace_url(args[0])\n url = SignedURL.new(@credentials,@full_url_no_params,symbol == :GET ? 'GET' : 'POST')\n url.logger = @logger\n url.params = args[1] if !args[1].nil?\n url[:protocol_override] = nil\n url[:action] = symbol\n\n # These can be override for testing purposes\n timestamp = args[2] if args[2]\n nonce = args[3] if args[3]\n\n full_url = url.full_url(timestamp,nonce)\n if link_only\n return full_url\n else\n response = @http.post(full_url)\n return response\n end\n else\n super(symbol,args)\n end\n end", "def method_missing(method, *args, &block)\n if method.to_s.end_with?('_path', '_url')\n if main_app.respond_to?(method)\n main_app.send(method, *args)\n else\n super\n end\n else\n super\n end\n end", "def method_missing(meth, *args)\n case meth.to_s\n when /^login/\n _login(meth, *args)\n when /^async/i\n AsyncDispatcher.new(self, :_call)\n else\n Dispatcher.new(self, meth, :_call)\n end\n end", "def call(request); end", "def route\n \"#{@http_verb.to_s.upcase} #{@url}\"\n end", "def dispatch(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"dispatch \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end", "def invoke_direct(method_name, *args)\r\n prepare_request('api', 'api', method_name, *args)\r\n @controller.process(@request, @response)\r\n decode_rpc_response\r\n end", "def perform(arguments = {})\n case type.to_sym\n when :post, :get\n api.public_send(type, path, @arguments.merge(arguments))\n else\n raise ArgumentError, \"Unregistered request type #{request_type}\"\n end\n end", "def dispatch_action(req)\n controller = ROUTE_TO_CONTROLLER[req.path_info]\n raise Heartcheck::Errors::RoutingError if controller.nil?\n\n Logger.info \"Start [#{controller}] from #{req.ip} at #{Time.now}\"\n\n controller.new.index.tap do |_|\n Logger.info \"End [#{controller}]\\n\"\n end\n end", "def _dispatch\n case @options[:action]\n when :init\n _init\n when :add\n fail 'No url given (-u option)' if @options[:url].empty?\n fail 'No name given (-n option)' if @options[:name].empty?\n _add\n when :delete\n fail 'No id given (-i option)' if @options[:id].nil?\n _delete\n when :list\n _list\n else\n fail \"Unknown action #{@options[:action]}\"\n end\n end", "def dispatch(type, data)\n handle_dispatch(type, data)\n end", "def component_update \n if request.xhr?\n # If this is an AJAX request then we just want to delegate to the component to rerender itself\n component\n else\n # If this is from a client without javascript we want to update the session parameters and then delegate\n # back to whatever page is displaying the scaffold, which will then rerender all scaffolds with these update parameters\n update_params :default_scaffold_id => \"webrt\", :default_sort => nil, :default_sort_direction => \"desc\"\n return_to_main\n end\n end", "def get url\n url = URI url\n request = HTTP::Get.new url.path\n\n dispatch request, to: url\n end", "def request(*args); end", "def api_version_dispatch\n # First, version check.\n api_version = params[:api_version]\n if not @@SUPPORTED_VERSIONS.include?(api_version)\n return api_response(:unsupported_api_version)\n end\n\n # Generate method name\n method = params[:method].split('/')\n method = method.join('_')\n\n # Check request method is valid. If we have no definitions of request\n # methods for a call, we assume all methods are permitted.\n # Skip this in development mode, though.\n if ENV['RAILS_ENV'] != 'development'\n if @@SUPPORTED_HTTP_METHODS[api_version.to_sym] and @@SUPPORTED_HTTP_METHODS[api_version.to_sym][method.to_sym]\n supported_methods = @@SUPPORTED_HTTP_METHODS[api_version.to_sym][method.to_sym]\n req_method = request.method.downcase.to_sym\n if not supported_methods.include?(req_method)\n return api_response(:unsupported_request_method)\n end\n end\n end\n\n # Clean up params for send() to work properly\n params.delete(:api_version)\n params.delete(:method)\n params[:action] = method\n\n # Dispatch\n method = \"#{api_version}_#{method}\"\n if not respond_to?(method.to_sym, true)\n return api_response(:unknown_api_method)\n end\n\n begin\n return send(method.to_sym)\n rescue => e\n require 'pp'\n pp e.inspect\n pp e.backtrace\n return api_response(:unknown_error)\n end\n end", "def dispatcher(session,context,dispatch_destination = nil)\n @myclass.Dispatcher.dispatch(session,context,dispatch_destination)\n end", "def dispatch(msg)\n ActiveRecord::Base.establish_connection(Serv::Configuration::database_configuration)\n\n msg = JSON.parse(msg)\n \n controller = msg['controller']\n action = msg['action']\n params = msg['params']\n session_id = msg['session_id']\n \n log \"[REQUEST] - [controller: #{controller},\" + \" action: #{action}, \" + \" params: #{params}]\"\n \n if !params.nil?\n args = \"params\"\n else\n args = nil\n end\n \n # Metaprogramming code that will dyamically call the requested controller\n # and method\n result = nil\n eval %Q(\n session = get_session(session_id)\n \n if !session.nil?\n request = #{controller.camelize}Controller.new\n request.instance_variable_set(:@session, session)\n request.instance_variable_set(:@game_mq, @game_mq)\n request.extend(Broker::Commands)\n \n result = if args.nil?\n request.#{action}\n else\n request.#{action}(#{args})\n end\n else\n raise Interrupt\n end\n )\n respond_success(result)\n rescue ArgumentError\n respond_error(Errors::ERR_ARGUMENT_ERROR, $!)\n rescue Interrupt\n respond_error(Errors::ERR_INVALID_SESSION, $!)\n rescue\n respond_error(Errors::ERR_GENERIC, $!)\n ensure\n ActiveRecord::Base.connection.disconnect!\n #ActiveRecord::Base.verify_active_connections!\n end", "def url(name, *args)\n return web_controller.url(name, *args) if web_controller\n super\n end", "def url\n end", "def url_path\n self.class.url_path_class.new(self).call\n end", "def url_for_index; end", "def url_for_index; end", "def dispatch(name = :default, &block)\n target_queue = @dispatcher[name] ||= Pigeon::Dispatcher.new(name == :default ? nil : 1)\n \n target_queue.perform(&block)\n end", "def invoke_action(name)\n # debugger\n self.send(name)\n render(name.to_s) unless already_built_response?\n end", "def command_uri\n return \"/api_#{@command_name}.php\"\n end", "def request_uri; end", "def install_dispatch(mod)\n # THREAD CRITICAL BEGIN\n unless @dispatch[mod]\n @dispatch[mod] = true\n # $stderr.puts \"install_dispatch(#{name}) into #{mod}\\n\";\n mod.class_eval(body = <<-\"end_eval\", __FILE__, __LINE__)\ndef #{name}(*args)\n ::#{table.class.name}.instance.dispatch(#{name.inspect}, self, args)\nend\nend_eval\n# $stderr.puts \"install_dispatch = #{body}\"\n end\n # THREAD CRITICAL END\n end", "def dispatch(*_arg0); end", "def url=(_arg0); end", "def url=(_arg0); end", "def url=(_arg0); end", "def url=(_arg0); end", "def url=(_arg0); end", "def url=(_arg0); end", "def url=(_arg0); end", "def on_request_uri(cli, request)\r\n print_status(\"Request: #{request.uri}\")\r\n if request.uri =~ /#{Regexp.escape(get_resource)}/\r\n print_status('Sending payload...')\r\n send_response(cli, @pl)\r\n end\r\n end", "def _dispatch(request, *args)\n raise ArgumentError, \"Invalid request #{request.inspect}\" if not request.to_s =~ /\\A(#{Node::NAME_REGEXP})(\\?{,1})\\z/\n node_name = $1.to_sym\n is_question = ($2 != \"\")\n\n node = @instance.find_local_node(node_name, @parent)\n\n # NOTE: Method return result.\n if node\n if is_question\n # Help request.\n out = [\n node.brief_desc || @instance.conf.brief_desc_stub,\n ([\"\", node.full_desc] if node.full_desc),\n ].flatten(1).compact\n\n # `out` are lines of text, eventually.\n ::Kernel.puts out.empty?? \"No description, please provide one\" : out\n\n # For groups list contents after description.\n #if node.is_a? Node::Group\n # ::Kernel.puts [\"\", self.class.new(@instance, node).inspect]\n #end\n else\n # Group/hack request.\n case node\n when Node::Group\n # Create and return a new nested access context.\n self.class.new(@instance, node)\n when Node::Hack\n # Invoke hack in the context of `HackTree` instance.\n @instance.instance_exec(*args, &node.block)\n else\n raise \"Unknown node class #{node.class}, SE\"\n end\n end # if is_question\n else\n ::Kernel.puts \"Node not found: '#{node_name}'\"\n end\n end", "def run_http_client(url, req, process_params)\n\t\t\t\tbegin\n\t\t\t\t\tparsed_url \t= URI.parse(URI.escape(CGI::unescape(url)))\n\t\t\t\t\tclient \t\t= Rex::Proto::Http::Client.new(parsed_url.host, parsed_url.port, {}, false)\n\t\t\t\t\t\n\t\t\t\t\t(req.unparsed_uri =~ /^#{parsed_url.path}/) ? uri = req.unparsed_uri : uri = parsed_url.path + req.unparsed_uri\n\t\t\t\t\t\n\t\t\t\t\tresp = client.send_recv(client.request_raw(\n\t\t\t\t\t\t'method'=> req.request_method, \n\t\t\t\t\t\t'vhost'\t=> parsed_url.host + ':' + parsed_url.port.to_s,\n\t\t\t\t\t\t'agent' => req.header['user-agent'][0],\n\t\t\t\t\t\t'cookie'=> req.cookies[0],\n\t\t\t\t\t\t'uri'\t=> process_params ? Rex::Text.to_hex_ascii(uri).gsub(/\\\\x/, '%') : parsed_url.path,\n\t\t\t\t\t\t'data' => process_params ? req.body : \"\"\n\t\t\t\t\t))\n\t\t\t\t\tclient.close\n\t\t\t\t\treturn resp\n\t\t\t\trescue\n\t\t\t\t\tprint_error(\"Error 1: #{$!}\") if (XSSF_MODE[0] =~ /^Debug$/i)\n\t\t\t\t\treturn nil\n\t\t\t\tend\n\t\t\tend", "def process\n # run preload method (which user can subclass)\n preload\n # early out if render nothing is set or if there is already a redirection\n return if @redirect || @render_nothing\n # decide what method on the controller to call\n meth = nil\n if !@workingpath || !@requestpath ||\n ( @workingpath.length >= @requestpath.length && @workingpath.last == @requestpath.last )\n # i have a subtle disambiguation problem between a request for a method whose name\n # matches the controller name itself and a request for the index page - think more. TODO\n meth = \"index\"\n else\n # normal behavior is to pick a method that matches the leaf of the url passed\n # in ruby on rails this is done at the router level; in appwiki it is at controller scope\n meth = @requestpath.last\n @args = @requestpath.slice(@workingpath.length+1..@requestpath.length+1)\n if !self.respond_to? meth\n @args = [ meth ]\n meth = \"default\"\n end\n end\n # go!\n if self.respond_to? meth\n send meth\n render :action => meth if !@redirect && !@render_nothing && !@rendered_template\n # TODO one design clumsiness here is that the controller method renders\n # directly to the output buffer, and then the layout erases that buffer and\n # then pipes it to itself... it would be better to have a more generalized\n # idea of diffent output buffers that then layout could composit together,\n # this would support the idea of many fragments making up a page and might\n # also help caching. even deferred computation of a fragment would be nice.\n end\n # do post load operations (including skinning)\n postload\n end", "def method_missing(m,params={})\n get url(m.to_s.camelize,params)\n end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def request; end", "def http_send_action\n http = http_inst\n req = http_post\n Response.new http.request req\n end", "def url; end", "def url; end", "def url; end", "def url; end", "def url; end", "def url; end", "def url; end", "def url; end", "def url; end", "def url; end", "def url; end" ]
[ "0.59711206", "0.57147175", "0.5545272", "0.5320577", "0.5257479", "0.5120687", "0.510155", "0.5065449", "0.50552744", "0.50552744", "0.50552744", "0.5034021", "0.50314534", "0.5030001", "0.49982038", "0.49866804", "0.49825743", "0.4977301", "0.49751395", "0.49751395", "0.49741703", "0.4951561", "0.4875104", "0.48642778", "0.48634878", "0.48603487", "0.48549032", "0.4844252", "0.48346785", "0.4828324", "0.4814208", "0.48081928", "0.48080072", "0.4807316", "0.48035493", "0.47930872", "0.47929272", "0.47833398", "0.47763437", "0.47737804", "0.47687453", "0.4766764", "0.47637892", "0.4762663", "0.47550142", "0.4750364", "0.47366774", "0.47182354", "0.47158188", "0.47149172", "0.47146472", "0.47110853", "0.4710056", "0.47040585", "0.47002333", "0.46955556", "0.46924877", "0.46902975", "0.46902975", "0.46890482", "0.46858683", "0.46823663", "0.46809968", "0.4679806", "0.46732965", "0.46654403", "0.46654403", "0.46654403", "0.46654403", "0.46654403", "0.46654403", "0.46654403", "0.4662871", "0.46622336", "0.46621233", "0.46562725", "0.46467358", "0.46358058", "0.46358058", "0.46358058", "0.46358058", "0.46358058", "0.46358058", "0.46358058", "0.46358058", "0.46358058", "0.46358058", "0.46358058", "0.46354684", "0.46287325", "0.46287325", "0.46287325", "0.46287325", "0.46287325", "0.46287325", "0.46287325", "0.46287325", "0.46287325", "0.46287325", "0.46287325" ]
0.58597404
1
=> "I don't care about arguments" Procs and lambdas handle return differently: A lambda will return normally like a method, while A proc will return from the method enclosing the proc.
def proc_return my_proc = Proc.new { return } my_proc.call puts "This will not be printed" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def proc_return_demo\n some_proc = Proc.new { return \"proc returns\"}\n some_proc.call\n \"method returns\"\nend", "def lambda_vs_proc\n my_lam = lambda { return puts \"Hi, I'm your lambda!\" }\n my_lam.call\n puts 'Returned from lambda!'\n my_proc = Proc.new { return puts 'Hello from proc!' }\n my_proc.call\n puts 'The proc will not allow this to be seen!'\nend", "def ret_proc \n proc = Proc.new { return \"a return from inside the proc returns not only from the proc, but the enclosing method itself, unlike a lambda.\"}\n proc.call\n return \"returning from inside the method\"\n end", "def return_from_proc\n a = Proc.new { return 10 }.call\n # 1.times { return 10 }\n puts \"This will never be printed.\"\nend", "def run_couple\n run_a_proc proc { puts 'I am a proc'; return }\n p 'you will not see me'\n run_a_proc lambda { puts 'I am a lambda'; return }\nend", "def proc_in_return\n proc_func = proc {\n return\n }\n proc_func.call\n\n \"mew\"\n end", "def return_test\n\tl = lambda { return }\n\tl.call\n\tputs \"Still here!\"\n\tp = Proc.new { return }\n\tp.call\n\tputs \"You won't see this message!\"\nend", "def proc_method\n\tproc_a = proc { |x| return x }\n\tproc_a.call(@expected_proc_return)\n\t\"unexpected proc return\"\nend", "def create_proc_with_return\n proc = Proc.new { return puts \"I am a proc with return\" }\n #on check on numbers of paramaters\n proc.call()\n # will not be executed!\n puts \"I am behind proc's call that with a return \"\nend", "def proc_return\n Proc.new { return \"Proc.new\"}.call\n return \"proc_return method finished\"\nend", "def proc_return\n my_proc = Proc.new {return}\n my_proc.call\n puts \"Will this be printed (Proc)\"\nend", "def my_method\n puts \"before proc\"\n my_proc = lambda do\n puts \"inside proc\"\n return\n end\n my_proc.call\n puts \"after proc\"\nend", "def b_method()\n Proc.new { return \"we return from proc\" }.call\n return \"return from method\"\nend", "def proc_method\n my_proc = Proc.new { return \"I'm a proc\"}\n my_proc.call\n \"Last line of proc_method\"\nend", "def test1\n p = Proc.new { return }\n p.call\n puts “This line can’t display”\nend", "def my_method\n x = Proc.new{return}\n x.call\n p \"Text from within the method\"\nend", "def proc_method\n p = Proc.new { return \"\\nreturning from proc\\n\"} \n p.call\n print \"\\nStatement after proc\\n\"\nend", "def proc_method\n my_proc = Proc.new { return \"I'm a proc!\"}\n my_proc.call\n \"Last line of proc method\"\nend", "def proc_demo_method\n proc_demo = Proc.new { return \"Only I print!\" }\n proc_demo.call\n \"But what about me?\" # Never reached\nend", "def new_proc\n proc1 = Proc.new{return \"I got it....\"}\n proc1.call\n \n return \".. but not that\"\nend", "def another_proc\n\tp = Proc.new {return}\n\tp.call\n\tputs \"After Proc\"\nend", "def takes_a_proc( p )\n p.call\nend", "def thisIsAMethod myProc\n puts 'SILENCE!!! I have an announcement'\n myProc.call\n puts 'As you were!'\n\nend", "def return_with_Proc\n f = Proc.new { return \"return inside block\" }\n f.call\n v = f.call\n return \"#{v}: return from method_end\" \nend", "def proc_sample\n proc = proc { return 'world' }\n 'hello ' << proc.call\nend", "def call_proc\n puts \"Before proc\"\n my_proc = Proc.new { return 2 }\n my_proc.call\n puts \"After proc\"\n\nend", "def go\n a = Proc.new do \n puts 'Proc'\n\n return\n end\n\n methods(&a)\n\n puts 'end go'\nend", "def call_proc\n puts \"Before proc\"\n my_proc = Proc.new { return 2 }\n my_proc.call\n puts \"After proc\"\nend", "def batman_ironman_proc #will return batman will win\n victor = Proc.new { |n| return \"Batman will win!#{n}\" }\n victor.call(3)\n \"Iron Man will win!\"\nend", "def fred(param)\n proc {}\nend", "def test_proc\n Proc.new { p \"Exit from proc.\" and return }.call\n p \"Exit from proc method\" and return\nend", "def proc_lamda_dif_one\n p = Proc.new { |num1, num2| \n num3= num1+num2 \n puts \"\\nProc executes even if it has less or more number of parameters\\n\"\n } \n p.call 50, 55, 60\n\n print \"\\n\\nFollowing Error with lamda if it has more or less no of arguments\"\n print \" than no of parameters it is catching showing the difference between \"\n print \" proc and lamda: \\n\\n\"\n l = lambda { |num1, num2| puts num1+num2 } \n l.call 50, 55, 60\nend", "def batman_ironman_proc\r\n victor = Proc.new { return \"Batman will win!\" }\r\n puts victor.call\r\n \"Iron Man will win!\"\r\nend", "def proc_math\n Proc.new { return 1 + 1 }.call\n\n return 2 + 2\nend", "def proc_math\n Proc.new { return 1 + 1 }.call\n return 2 + 2\nend", "def my_method\n \n puts \"before proc\"\n\n my_proc = lambda{\n puts \"Inside proc\"\n #return\n #break\n }\n\n my_proc.call\n puts \"after proc\"\n\nend", "def proc\n return $PROC\n end", "def call_proc\n\tputs \"Before proc\"\n\tmy_proc = Proc.new { return 2 } \n\tmy_proc.call\n\tputs \"After proc\"\nend", "def check_return_with_lambda\n my_lambda = lambda { return }\n # lambda return does not cause return of method..\n my_lambda.call\n puts \"This will be output to screen.\"\nend", "def batman_ironman_proc\n victor = Proc.new { return \"Batman will win!\" } # Proc returns immediately, without going back to the batman_ironman_proc method.\n victor.call\n \"Iron Man will win!\"\nend", "def sampleProc\n procOne = Proc.new { return \"Proc block!\" }\n procOne.call\n \"Last Proc statement!\"\nend", "def batman_ironman_proc\r\n victor = Proc.new { return \"Batman will win!\" }\r\n victor.call\r\n \"Iron Man will win!\"\r\nend", "def my_method\n \n puts \"before proc\"\n \n my_proc = lambda{\n \n puts \"Inside proc\"\n break\n }\n \n my_proc.call\n puts \"after proc\"\n \nend", "def lambda_inside\n return_lambda = lambda { return }\n return_lambda.call\n puts \"In Method! (Lambda)\"\nend", "def block_vs_proc_lamda\n #puts $catch_block\n print \"In method: before yield\\n\"\n yield\n print \"In method: after yield\\n\"\n \n p = Proc.new { |my_var| print \"in method in proc and parameter is: #{my_var}\\n\"} \n p.call 10\n l = lambda { |lamda_var| print \"in method in lambda and parameter is: #{lamda_var}\\n\"}\n l.call 11 \n #puts $catch_block\n 10\nend", "def meth5\n p = lambda { return 99 } \n result = p.call \n \"The block returned #{result}\"\nend", "def batman_ironman_proc #calls a proc\n victor = Proc.new { return \"Batman will win!\" }\n victor.call\n \"Iron Man will win!\"\nend", "def batman_ironman_proc\n victor = Proc.new { return \"Batman will win!\" }\n victor.call\n \"Iron Man will win!\"\nend", "def batman_ironman_proc\n victor = Proc.new { return \"Batman will win!\" }\n victor.call\n \"Iron Man will win!\"\nend", "def test_lambda\n lambda { p \"Exit from lambda.\" and return }.call()\n p \"Exit from lambda method\" and return\nend", "def lambda_method\n lambda_a = lambda { |e| return e }\n l = lambda_a.call(\"unexpected lambda return value\")\n raise \"Was expecting unexpected lambda return value but got #{l}\" unless \"unexpected lambda return value\" == l\n @expected_lambda_return\nend", "def lambda; end", "def return_proc\n Proc.new do |name|\n puts \"The length of your name is #{name.length}\"\n end\nend", "def try_ret_lambda\n ret = lambda { return \"Baaam\" }\n ret.call\n \"This is printed\"\nend", "def proc_builder(message)\n\tProc.new { puts message; return }\nend", "def try_ret_lambda\n ret = lambda { return \"Baaam\" }\n ret.call\n \"This is printed\"\nend", "def my_lambda\n\n\tputs \"first lambda\"\n\n\tproc1 = lambda {\n\n\t\tputs \"second lambda\"\n\t\t#breaak or return\n\n\t}\n\n\tproc1.call\n\tputs \"last lambda\"\nend", "def be_proc(&block)\n block.call\n puts block.class\nend", "def check_return_with_lambda\n my_lambda = lambda { return }\n my_lambda.call\n puts \"This will be output to screen.\"\n puts \" \"\n puts \"remaining line.\"\nend", "def call_some_proc(pr)\n a = \"Irrelevant 'a' in method scope\"\n puts a\n pr.call\nend", "def run_proc_closure(p)\n p.call\nend", "def check_return_with_lambda\n my_lambda = lambda { return }\n my_lambda.call\n puts \"This will be output to screen.\"\nend", "def proc_method(&my_proc)\n puts \"method start\"\n my_proc.call\n puts \"method end\"\nend", "def test\r\n puts \"Enter in methods\"\r\n p = Proc.new {p \"Entering block\"; return }\r\n p.call\r\n p \"Existing methods\"\r\nend", "def test\r\n puts \"Enter in methods\"\r\n p = Proc.new { p \"Entering proc\"; break }\r\n p.call\r\n p \"Existing methods\"\r\nend", "def dietproc\n status=Proc.new{return \"You gave in!\"} #explict return skips the part of code so removing return\n status.call\n \"You completed the diet!\"\nend", "def call_a_proc(&block)\n block.call\nend", "def my_method(some_proc)\n puts \"my_method starts\"\n some_proc.call\n puts \"my_method ends\"\nend", "def another_lambda\n\tl = lambda {return}\n\tl.call\n\tputs \"After Lambda\"\nend", "def lamda_method\n l = lambda { return \"\\nreturning from lamda\\n\"}\n l.call\n print \"\\nStatement after lamda\\n\"\nend", "def func_one\n proc_new = Proc.new {return \"123\"}\n proc_new.call(1,2)#proc dont care how many argument added\n return \"456\"\nend", "def to_proc() end", "def to_proc() end", "def return_with_lambda\n f = lambda { return \"return inside block\" }\n f.call\n v = f.call\n return \"#{v}: return from method_end\" \nend", "def check_return_with_lambda\n my_lambda = lambda { return } # merely returns to the execution point where lambda was called\n my_lambda.call\n puts \"This will be output to screen.\"\nend", "def diet_proc\n status = Proc.new { return \"You gave in\"}\n status.call\n \"You completed the diet\"\nend", "def call_a_proc(&my_proc)\n my_proc.call\nend", "def lambda_demo_method\n lambda_demo = lambda { return \"Will I print?\" }\n lambda_demo.call\n \"Sorry - it's me that's printed.\"\nend", "def handle_proc(pr, *a)\n case pr\n when Proc, Method\n pr.call(*a)\n else\n pr\n end\n end", "def bar\n\tf = lambda { return \"return from lambda\"}\n\tf.call # control does not leave bar here\n\treturn \"return from bar\"\nend", "def batman_ironman_proc\n\t victor = Proc.new { return \"Batman will win!\" } # when a proc returns, it does so immediately, without going back to the calling method.\n\t victor.call\n\t \"Iron Man will win!\" \n\tend", "def to_proc() self ; end", "def my_proc\n\n\tputs \"first proc\"\n\n\tproc1 = proc {\n\n\t\tputs \"second proc\"\n\t\t#breaak or return\n\n\t}\n\n\tproc1.call\n\tputs \"last proc\"\nend", "def proc_example\n\tsay_hi = proc {|name| puts \"Hi #{name}\"}\n\tsay_hi.call(\"Ganesh\")\nend", "def batman_ironman_lambda #checks number of arguments\n victor = lambda { return \"Batman will win!\" }\n victor.call\n \"Iron Man will win!\"\nend", "def to_proc()\n #This is a stub, used for indexing\n end", "def procBuilder(message)\r\n Proc.new {p message; return}\r\nend", "def check_return(proc4)\n proc4.call\n puts \"Puts string after return was called\"\nend", "def to_proc\n method(:call).to_proc\n end", "def run_block\n p = Proc.new # <1>\n p.call\nend", "def do_self_importantly(some_proc)\n puts 'Everybody just HOLD ON! I have something to do...'\n some_proc.call\n puts 'Okay everyone, I\\'m done. Go on with what you were doing.'\nend", "def create_proc\n proc = Proc.new { puts \"I am a Proc created by Proc.new\"}\n proc.call\nend", "def procTest\n\t# Create a new Proc\n\tmultiplesOfThree = Proc.new { |n| n % 3 == 0 }\n\n\t# (1..100).to_a gives an array of integers from 1 to 100\n\t# \"Array.select\" selects only the items for which the original block returned true\n\ta = (1..100).to_a\n\ta.select!(&multiplesOfThree)\n\ta.each { |value| puts \"#{value} \" }\n\n\t# Calling a Proc\n\thello = Proc.new { puts \"Hello!\" }\n\thello.call\nend", "def test procArg1, procArg2\n\tProc.new do |arg|\n\t\tprocArg2.call(procArg1.call(arg))\n\tend\nend", "def to_proc\n ->(*args) {call(*args)}\n end", "def lambda_method\n my_lambda = lambda {return \"I'm a lambda\"}\n my_lambda.call\n return \"I'm the last line of the method!\"\nend", "def do_self_importantly(some_proc)\n puts \"Everybody just HOLD ON! I have something to do...\"\n some_proc.call\n puts \"Ok everyone, I'm done. Go on with what you were doing.\"\nend", "def pass_proc1 (proc1, proc2, number, proc3)\n proc1.call\n proc2.call\n proc3.call \n Proc.new { puts \"#{number} procs have been passed as arguments to the currently executing method #{__method__.to_s}\" }.call\n proc5 = Proc.new {puts \"A proc can be output from a method. This is the second property of higher-order functions\"} \nend", "def do_self_importantly(some_proc)\n puts \"Everybody just HOLD ON! I'm doing something...\"\n some_proc.call\n puts \"OK everyone, I am done. As you were.\" \nend", "def do_self_importantly(some_proc)\n puts \"Everybody just HOLD ON! I'm doing something...\"\n some_proc.call\n puts \"OK everyone, I'm done. As you were.\"\nend" ]
[ "0.75660604", "0.75587374", "0.74647546", "0.7360698", "0.7320859", "0.731422", "0.72660494", "0.72437483", "0.7212939", "0.7205226", "0.71961004", "0.7113144", "0.7056424", "0.6909016", "0.6905708", "0.6899517", "0.6844433", "0.684056", "0.68395615", "0.6819871", "0.6753244", "0.67364126", "0.67311597", "0.6715883", "0.6715808", "0.6654838", "0.6633235", "0.6629884", "0.6620465", "0.6612676", "0.6594789", "0.6591331", "0.65491116", "0.6533679", "0.6533547", "0.65170044", "0.647309", "0.64681584", "0.64535993", "0.64485943", "0.63960713", "0.6386374", "0.6370493", "0.63602537", "0.635648", "0.63470995", "0.6304954", "0.6302266", "0.6302266", "0.6220405", "0.6213112", "0.6206408", "0.620634", "0.61855215", "0.61704177", "0.61603904", "0.6148347", "0.614689", "0.61407566", "0.61316127", "0.61274904", "0.6121104", "0.6118477", "0.6106642", "0.6102992", "0.60955346", "0.6095296", "0.60738593", "0.6065906", "0.60602975", "0.6031929", "0.6027962", "0.6027962", "0.6021015", "0.6006993", "0.60036635", "0.5968031", "0.5965607", "0.5963721", "0.5957754", "0.59464407", "0.59363174", "0.5916305", "0.59103465", "0.59045726", "0.5904479", "0.58868927", "0.5883582", "0.58703184", "0.58652216", "0.5865119", "0.58635974", "0.5862755", "0.5836308", "0.58318245", "0.5826726", "0.5816268", "0.5808987", "0.58052963", "0.5801037" ]
0.7487214
2
GET /imagems/1 GET /imagems/1.xml
def show @imagem = @evento.imagems.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml => @imagem } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_image(image_id)\n request(\n :expects => 200,\n :method => 'GET',\n :parser => Fog::Parsers::Compute::Slicehost::GetImage.new,\n :path => \"images/#{image_id}.xml\"\n )\n end", "def show\n @imagem = Imagem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @imagem }\n end\n end", "def images\n IbmCloudRest.get \"#{@uri}/images\"\n end", "def index\n @images = Image.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @images }\n end\n end", "def index\n @imagens = Imagen.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @imagens }\n end\n end", "def show\n @image_set = ImageSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @image_set }\n end\n end", "def index\n @image_sets = ImageSet.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @image_sets }\n end\n end", "def show\n @image = Image.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @image }\n end\n end", "def show\n @image = Image.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @image }\n end\n end", "def show\n @image = Image.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @image }\n end\n end", "def index\n @images = @user.images.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @images }\n end\n end", "def index\n @remote_image_contents = RemoteImageContent.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @remote_image_contents }\n end\n end", "def index\n @images = @owner.images\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @images }\n end\n end", "def images() \n uri = URI.parse(\"http://\" + @location.host + \":9292/v2/images\")\n return get_request(uri, @token)\n end", "def show\n @especie_imagem = EspecieImagem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @especie_imagem }\n end\n end", "def show\n @im = Im.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @im }\n end\n end", "def show\n @image = @user.images.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @image }\n end\n end", "def show\n @image = Image.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.haml\n format.xml { render :xml => @image }\n end\n end", "def show\n @image = @account.images.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @image }\n end\n end", "def index\n if current_user.is_admin\n @images = Image.masters.find(:all)\n else\n @images = Image.this_user(current_user).masters.find(:all)\n end\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @images }\n end\n end", "def show\n @img_info = ImgInfo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @img_info }\n end\n end", "def show\n @images_index = ImagesIndex.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @images_index }\n end\n end", "def show\n @moto_cover_image_uid = MotoCoverImageUid.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @moto_cover_image_uid }\n end\n end", "def show\n @console_image = Image.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @console_image }\n end\n end", "def show\n @map_image = MapImage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @map_image }\n end\n end", "def get_image1(doc, image)\n x = doc.xpath(image).to_s\n end", "def show\n @imagem = Imagem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @imagem }\n end\n end", "def show\n @image = Image.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @image }\n end\n end", "def show\n @imagen = Imagen.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @imagen }\n end\n end", "def index\n @images = Image.where(\"article is not null or thumbnail is not null\").order(\"id desc\").page(params[:page]).per(15)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @console_images }\n end\n end", "def index\n @imagems = Imagem.where(:imovel_id => current_user.imovels {|i| i.id})\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @imagems }\n end\n end", "def show\n @image_store = ImageStore.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @image_store }\n end\n end", "def index\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @welcome_images }\n end\n end", "def index\n @especie = Especie.find(params[:especie_id])\n @especie_imagens = EspecieImagem.find(@especie.especie_imagens)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @especie_imagens }\n end\n end", "def new\n @imagem = @evento.imagems.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @imagem }\n end\n end", "def show\n @image = Image.find(params[:id])\n\n respond_to do |format|\n format.jpg # show.jpg.flexi\n format.html # show.html.erb\n format.png # show.png.flexi\n format.xml { render :xml => @image }\n end\n end", "def get_images\n @command = :get_images\n # set a flag indicating whether or not the user wants to see all images,\n # including the hidden ones\n show_hidden = (@prev_args.peek(0) == \"-i\" || @prev_args.peek(0) == \"--hidden\")\n # get the images from the RESTful API (as an array of objects)\n uri_str = ( show_hidden ? \"#{@uri_string}?hidden=true\" : @uri_string )\n uri = URI.parse uri_str\n result = hnl_http_get(uri)\n unless result.blank?\n # convert it to a sorted array of objects (from an array of hashes)\n sort_fieldname = 'filename'\n result = hash_array_to_obj_array(expand_response_with_uris(result), sort_fieldname)\n end\n # and print the result\n print_object_array(result, \"Images:\", :style => :table)\n end", "def show\n @sys_image = resource_find(params[:id])\n\n respond_to do |format|\n format.ndz {\n send_file get_path(@sys_image, \"ndz\")\n }\n format.html\n end\n\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @welcome_image }\n end\n end", "def show\n @image = Image.find(params[:id])\n\n respond_to do |format|\n format.jpg # show.jpg.flexi\n format.html # show.html.erb\n format.png # show.png.flexi\n format.xml { render :xml => @image }\n end\n end", "def get_storage(request, params)\n # --- Get the Image ---\n image = ImageOCCI.new(\n Image.build_xml(params[:id]),\n @client)\n\n rc = image.info\n if OpenNebula.is_error?(rc)\n return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]\n end\n\n # --- Prepare XML Response ---\n return to_occi_xml(image, :code=>200)\n end", "def show\n @remote_image_content = RemoteImageContent.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @remote_image_content }\n end\n end", "def get_xmlinfo\n def do_xmlget(imagepath)\n xmlinfo = %x{imagex info --xml #{imagepath}}\n @xmlinfo = REXML::Document.new xmlinfo\n return @xmlinfo\n end\n if defined?(@xmlinfo) then return @xmlinfo else @xmlinfo = nil end\n search = File.join(@path, 'sources/install.wim')\n wimage = Dir.glob(search, File::FNM_CASEFOLD)\n if wimage.length > 0\n return do_xmlget(wimage.first)\n end\n search = File.join(@path, 'sources/boot.wim')\n bimage = Dir.glob(search, File::FNM_CASEFOLD)\n if bimage.length > 0\n return do_xmlget(bimage.first)\n end\n @xmlinfo\n end", "def parse_sw_image_ids\n public_xml_doc.xpath('//resource[@type=\"page\" or @type=\"image\" or @type=\"thumb\"]').map do |node|\n node.xpath('./file[@mimetype=\"image/jp2\"]/@id').map do |x|\n \"#{@druid.gsub('druid:', '')}/\" + x\n end << node.xpath('./externalFile[@mimetype=\"image/jp2\"]').map do |y|\n \"#{y.attributes['objectId'].text.split(':').last}\" + '/' + \"#{y.attributes['fileId']}\"\n end\n end.flatten\n end", "def show\n @item_photos = ItemPhoto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @item_photos }\n end\n end", "def getimagesinfo\n trek = Trek.find_by_id(params[:id])\n send_data(trek.get_images_info.to_json,\n {:type => \"application/json\", :disposition => \"inline\"})\n end", "def show\n @user_image = UserImage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @user_image }\n end\n end", "def new\n @image_set = ImageSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @image_set }\n end\n end", "def show\n @image = Image.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.jpg # show.jpg.erb\n format.png # show.png.erb\n format.xml { render :xml => @image }\n end\n end", "def show\n @uploaded_image = UpdatedImage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @uploaded_image }\n end\n end", "def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @photo.to_xml }\n end\n end", "def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @photo.to_xml }\n end\n end", "def index\n @project_images = ProjectImage.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @project_images }\n end\n end", "def index\n @item_photos = ItemPhoto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @item_photos }\n end\n end", "def show\n @photo_set = PhotoSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @photo_set }\n end\n end", "def index\n @pictures = Picture.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @pictures }\n end\n end", "def get_image_by_uuid\n @command = :get_image_by_uuid\n # the UUID was the last \"previous argument\"\n image_uuid = @prev_args.peek(0)\n # setup the proper URI depending on the options passed in\n uri = URI.parse(@uri_string + '/' + image_uuid)\n # and get the results of the appropriate RESTful request using that URI\n result = hnl_http_get(uri)\n # finally, based on the options selected, print the results\n print_object_array(hash_array_to_obj_array([result]), \"Image:\")\n end", "def index\n @images = Image.all\n respond_with @images\n end", "def index\n @photos = @album.photos\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @photos }\n end\n end", "def image(id, nsfw = false)\n img = get url: \"images/#{id}\", nsfw: nsfw\n img['image'] if img\n end", "def show\n @photo_set = PhotoSet.find(params[:id])\n \n respond_to do |format|\n format.html # show.rhtml\n# format.xml { render :xml => @photo_set.to_xml }\n end\n end", "def images\n @picturesandmeta = Pictureandmeta.all\n @kind = Kind.find(params[:kind_id])\n Rails.logger.info(\"Kind: #{@kind.inspect}\")\n end", "def index\n @crops = @image.crops.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @crops }\n end\n end", "def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @photo }\n end\n end", "def list\n @api.get(\"#{@api.path}/Images\")\n end", "def get_image2(doc, image)\n x = doc.xpath(image).first.to_s\n end", "def print_each_photo(api_key, tag)\n # Build the URI\n uri = \"http://www.flickr.com/services/rest?method=flickr.photos.search\" +\n \"&api_key=#{api_key}&tags=#{tag}\"\n\n # Make the HTTP request and get the entity-body.\n response = open(uri).read\n\n # Parse the entity-body as an XML document.\n doc = REXML::Document.new(response)\n\n # For each photo found...\n REXML::XPath.each(doc, '//photo') do |photo| \n # ...generate and print its URI\n puts small_photo_uri(photo) if photo\n end\nend", "def show\n @external_photo = ExternalPhoto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @external_photo }\n end\n end", "def show\n @content_title = 'Tag your friends and beers!'\n @image = Image.find(params[:id], :include => [ :tag_images ])\n @tag_images = @image.tag_images\n respond_to do |format|\n format.html # show.rhtml\n format.xml { render :xml => @tag_images.to_xml }\n end\n end", "def show_images\r\n images = Document.new(self).get_images\r\n puts \"There are #{images.length} images\"\r\n index = 1\r\n images.each do |l|\r\n puts \"image: name: #{l.name}\"\r\n puts \" id: #{l.id}\"\r\n puts \" src: #{l.src}\"\r\n puts \" index: #{index}\"\r\n index += 1\r\n end\r\n end", "def show\n @image_set = ImageSet.find(params[:id])\n\n render json: @image_set\n end", "def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @photo }\n end\n end", "def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @photo }\n end\n end", "def show\n @photo = Photo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @photo }\n end\n end", "def index\n @photos = Photo.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @photos }\n end\n end", "def image_data\n response = nil\n\n Net::HTTP.start(SERVICE_HOST) do |http|\n response = http.get(URI.parse(@url).path + ':medium')\n\n if response.code.to_s =~ /\\A3\\d\\d/\n new_location = URI.parse(response['Location'])\n Net::HTTP.start(new_location.host) do |http|\n response = http.get(new_location.path + '?' + new_location.query)\n end\n end\n end\n\n response.body\n end", "def show\n @picture = Picture.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @picture }\n end\n end", "def show\n @picture = Picture.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @picture }\n end\n end", "def show\n @picture = Picture.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @picture }\n end\n end", "def show\n @album = Album.find(params[:id]) \n @album_images = Image.where(:album_id => @album.id).order(\"mark DESC\").page(params[:page])\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @post.to_xml(:include => :images) }\n format.json { render :json => @post.to_json(:include => :images) }\n end\n end", "def index\n @image_gallery_groups = ImageGalleryGroup.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @image_gallery_groups }\n end\n end", "def new\n @img = Img.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @img }\n end\n end", "def images\n Vultr::Resource::OS.new(@faraday)\n end", "def images()\n @photos = all_photos() \n @headers['Content-Type'] = CONTENT_TYPE\n end", "def new\n @image_gallery_image = @image_gallery_group.images.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @image_gallery_image }\n end\n end", "def images artist\n url = \"http://developer.echonest.com/api/v4/artist/images?api_key=#{ECHONEST_API_KEY}&name=#{artist}&format=json&results=#{RESULTS}&start=0&license=unknown\"\n result = parseURL url\n result[\"response\"][\"images\"]\nend", "def show\n # proxy to GET /roi/id\n @result = ImageServer.get('/roi/'+params[:id]);\n render :json => @result\n end", "def show\n @jpeg_folder = JpegFolder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @jpeg_folder }\n end\n end", "def index\n @images = getmydata(\"Image\")\n pagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @images }\n end\n end", "def new\n @image = Image.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @image }\n end\n end", "def index\n @product_pictures = ProductPicture.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @product_pictures }\n end\n end", "def show\n @project_image = ProjectImage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @project_image }\n end\n end", "def images\n end", "def list_public_virtual_machine_images\n request_path = '/services/images'\n request = ManagementHttpRequest.new(:get, request_path, nil)\n response = request.call\n Serialization.virtual_machine_images_from_xml(response)\n end", "def index\n @images = Image.all\n\n respond_to do |format|\n format.html # index.html.slim\n format.json { render json: @images }\n end\n end", "def new\n @image = Image.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @image }\n end\n end", "def show\n @motivational_image = MotivationalImage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @motivational_image }\n end\n end", "def index\n# @photos = Photo.all\n @photos = Photo.find(:all, :select => 'id, name, thumbnail')\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @photos }\n end\n end", "def show\n @gallery = Gallery.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @gallery }\n end\n end", "def show\n @components_photo = ComponentsPhoto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @components_photo }\n end\n end" ]
[ "0.69916815", "0.69894046", "0.6804412", "0.65871704", "0.6567679", "0.65181506", "0.64555717", "0.64343226", "0.64343226", "0.64343226", "0.64182395", "0.6405345", "0.64015716", "0.63921446", "0.63728523", "0.6349735", "0.63433266", "0.63350546", "0.6333711", "0.6321536", "0.6313131", "0.6280663", "0.6253985", "0.62394375", "0.6228275", "0.622247", "0.62034804", "0.62012273", "0.619516", "0.61941415", "0.6189301", "0.618178", "0.6167424", "0.61387527", "0.6122396", "0.6086955", "0.6059373", "0.60577077", "0.60545653", "0.605167", "0.6049223", "0.60478646", "0.60424894", "0.60048413", "0.598284", "0.5957552", "0.5951158", "0.5946707", "0.59369934", "0.59369135", "0.59054506", "0.59054506", "0.58954257", "0.5891916", "0.58906734", "0.58876115", "0.5870462", "0.5867262", "0.586056", "0.58580476", "0.58493954", "0.58490044", "0.5831153", "0.5825524", "0.58238417", "0.58144915", "0.58030564", "0.57990867", "0.57875305", "0.5786342", "0.5783783", "0.57784915", "0.57784915", "0.57784915", "0.57743824", "0.57707614", "0.5769753", "0.5769753", "0.5769753", "0.57670534", "0.5760879", "0.57579815", "0.5747377", "0.5744235", "0.57350546", "0.5728951", "0.57221526", "0.5716246", "0.57116544", "0.57112694", "0.57095516", "0.570642", "0.5705847", "0.56915945", "0.5688949", "0.56787264", "0.5674643", "0.5670675", "0.56677693", "0.56661266" ]
0.71077454
0
Public interface BlockCommand.new ||Arguments:|| `name` The String name of the command. `args` The NodeList of arguments given to the command. `raw_tokens` A TokenList that represents the entire BlockCommand, generated by the Tokenizer. You must override this method in your subclass of BlockCommand.
def initialize(*args) if self.class == BlockCommand raise TypeError, 'BlockCommand.new should not be called directly' end super end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def command *args, &block\n @commands ||= []\n @args ||= []\n @commands << block\n @args << args\n end", "def new_block_el(*args); end", "def initialize\n @block_args = []\n end", "def command_raw(args)\n\n end", "def initialize( name, *args, &block )\n\t\t\t@name\t\t = name\n\t\t\t@block\t\t = block\n\n\t\t\t@description = args.shift if args.first.is_a?( String )\n\n\t\t\t@required\t = args.include?( :required )\n\t\t\t@multiple\t = args.include?( :multiple )\n\t\tend", "def initialize(args={}, &block)\n @args = args\n @targets = []\n if block\n self.instance_eval(&block)\n end\n end", "def initialize(*args)\n super\n if index = @args.index(\"in\")\n @block_params = @args[0..index-1]\n @value = @args[index+1]\n else\n @block_params = []\n @value = @args.first\n end\n @switched = false\n @commands = NodeList.new(self)\n @else_commands = NodeList.new(self)\n @in_else = false\n end", "def initialize(**args)\n super(command: self.class.command.new(args), executed: [])\n end", "def command(*args,&block)\n return @working_command if @working_command\n name, options = _parse_name_and_options(args,self.name)\n @working_command = cmd = Command.new({:plugin=>self,:name=>name}.merge(options))\n yield(cmd) if block\n bot.add_command(cmd)\n @working_command=nil \n @commands << cmd\n cmd\n end", "def initialize args\n hash_make args, BlockState::ARG_SPECS\n end", "def initialize(name,args)\n @name = name\n @args = args\n end", "def parse_block(*_arg0); end", "def command(*names)\n command_options = {\n :description => @next_desc,\n :arguments_name => @next_arg_name,\n :arguments_options => @next_arg_options,\n :arguments => @next_arguments,\n :long_desc => @next_long_desc,\n :skips_pre => @skips_pre,\n :skips_post => @skips_post,\n :skips_around => @skips_around,\n :hide_commands_without_desc => @hide_commands_without_desc,\n }\n @commands_declaration_order ||= []\n if names.first.kind_of? Hash\n command = GLI::Commands::CompoundCommand.new(self,\n names.first,\n command_options)\n command.parent = self\n commands[command.name] = command\n @commands_declaration_order << command\n else\n new_command = Command.new(command_options.merge(:names => [names].flatten))\n command = commands[new_command.name]\n if command.nil?\n command = new_command\n command.parent = self\n commands[command.name] = command\n @commands_declaration_order << command\n end\n yield command\n end\n clear_nexts\n @next_arguments = []\n command\n end", "def newcommand(options, &block)\n raise \"No name given in command\" unless options.include?(:name)\n\n command = options[:name]\n\n SLAF::Commands.module_eval {\n define_method(\"#{command}_command\", &block)\n }\n\n SLAF::command_options || SLAF.command_options = {}\n\n if options.include?(:allow_arguments)\n SLAF::command_options[command] = options[:allow_arguments]\n else\n SLAF::command_options[command] = false\n end\nend", "def initialize(name, arguments = [])\n @name = name\n @arguments = arguments\n end", "def parsed\n [raw_command] + args\n end", "def initialize tag, cmd, *args\n @tag = tag\n @cmd = cmd\n @args = args\n end", "def command(*names)\n command = Command.new([names].flatten,@@next_desc,@@next_arg_name,@@next_long_desc,@@skips_pre,@@skips_post)\n commands[command.name] = command\n yield command\n clear_nexts\n end", "def define(*args, &block)\n options = args.extract_options!\n\n name = if args.first\n args.shift\n else\n anonymous = true\n self.anonymous_block_number += 1\n \"anonymous_block_#{anonymous_block_number}\"\n end\n\n block_definitions[name].tap do |block_definition|\n block_definition.reverse_merge! options, &block\n block_definition.anonymous = !!anonymous\n end\n end", "def command(name, desc, *args_format, &block)\n if name.is_a? (Array)\n name = name.join(\" \").to_sym\n end\n\n cmd = Hash.new\n cmd[:desc] = desc\n cmd[:arity] = 0\n cmd[:options] = []\n cmd[:args_format] = Array.new\n args_format.each {|args|\n if args.instance_of?(Array)\n cmd[:arity]+=1 unless args.include?(nil)\n cmd[:args_format] << args\n elsif args.instance_of?(Hash) && args[:options]\n if args[:options].is_a? Array\n args[:options].flatten!\n args[:options] = args[:options].sort_by {|o| o[:name] }\n end\n\n cmd[:options] << args[:options]\n else\n cmd[:arity]+=1\n cmd[:args_format] << [args]\n end\n }\n cmd[:proc] = block\n @command_list << name.to_sym\n @commands[name.to_sym] = cmd\n end", "def command(*a)\n command = Command.new(*a)\n command.node = self\n command\n end", "def initialize(argument_types, block)\n @argument_types = argument_types\n @number_of_arguments = argument_types.size\n @block = block\n end", "def initialize(name)\n @block = ->(*args) { new(*args).public_send(name) }\n end", "def initialize(name)\n @block = ->(*args) { new(*args).public_send(name) }\n end", "def initialize(*arguments)\n @arguments = arguments\n @operations = []\n end", "def initialize(*args, &task_block)\n @name = args.shift || :readme\n\n define(args, &task_block)\n end", "def initialize(parsed_arguments)\n @command = parsed_arguments[:command]\n @options = parsed_arguments[:options]\n @arguments = parsed_arguments[:arguments]\n end", "def initialize(tokens, &block)\n super(@tokens = tokens, &block)\n end", "def new(namespace, name, *args, &block); end", "def initialize_cmd_args(args, new_name_args)\n args = args.dup\n args.shift(2 + @name_args.length) \n cmd_args = new_name_args + args\n end", "def initialize(names,description,arguments_name=nil,long_desc=nil,skips_pre=false,skips_post=false) # :nodoc:\n super(names,description,long_desc)\n @arguments_description = arguments_name || ''\n @skips_pre = skips_pre\n @skips_post = skips_post\n clear_nexts\n end", "def initialize(name:, body:, arguments: nil, pairs: nil, location: nil)\n @name = name.is_a?(Yoga::Token) ? name.value : name\n @body = body\n @location = location || derive_location(arguments, name)\n @pairs = pairs.freeze || derive_pairs(arguments).freeze\n end", "def block(name, &block)\n klass = SuperbTextConstructor.block(name, &block)\n @blocks << klass\n klass\n end", "def new args\n\t\t\trequire 'simrb/comd'\n\t\t\tsimrb_app = Simrb::Scommand.new\n\t\t\tsimrb_app.run(args.unshift('new'))\n\t\tend", "def new args\n\t\t\trequire 'simrb/comd'\n\t\t\tsimrb_app = Simrb::Scommand.new\n\t\t\tsimrb_app.run(args.unshift('new'))\n\t\tend", "def raw\n @args\n end", "def build_block_container(*args, &block)\n options = args.extract_options!\n\n anonymous = false\n if args.first\n name = args.shift\n else\n name = self.anonymous_block_name\n anonymous = true\n end\n\n block_container = Blocks::Container.new\n block_container.name = name.to_sym\n block_container.options = options\n block_container.block = block\n block_container.anonymous = anonymous\n block_container\n end", "def initialize text, name\n super()\n\n @text = text\n @name = name\n\n @aliases = []\n @is_alias_for = nil\n @parent_name = nil\n @singleton = nil\n @visibility = :public\n @see = false\n\n @arglists = nil\n @block_params = nil\n @call_seq = nil\n @param_seq = nil\n @params = nil\n end", "def initialize(arg, respect_whitespace = T.unsafe(nil), parent = T.unsafe(nil), raw = T.unsafe(nil), entity_filter = T.unsafe(nil), illegal = T.unsafe(nil)); end", "def initialize(name)\n super \"Unknown command: #{name}\"\n @command = name\n end", "def initialize(name, command)\r\n super(name)\r\n @command = command\r\n end", "def node(type, *args)\n AST.new(type, args)\n end", "def initialize block_parser\n @block_parser = block_parser\nend", "def initialize(raw, prefix, command, params)\n @raw = raw\n @prefix = prefix\n @command = command\n @params = params\n @text = params.last unless params.empty?\n\n @symbol = command.downcase.to_sym\n @data = {}\n @args = {}\n @irc = nil\n end", "def initialize(text, options={})\n @raw = text.to_s.strip\n\n @arguments = []\n @examples = []\n @returns = []\n @raises = []\n @signatures = []\n @signature_fields = []\n\n parse unless @raw.empty?\n end", "def initialize(name, parameters, block)\n @name = name\n @parameters = parameters\n @block = block\n @method = false\n end", "def new(*args)\n obj = allocate()\n\n Rubinius.asm(args, obj) do |args, obj|\n run obj\n run args\n push_block\n send_with_splat :initialize, 0, true\n # no pop here, as .asm blocks imply a pop as they're not\n # allowed to leak a stack value\n end\n\n return obj\n end", "def initialize(args = {})\n @name = args[:name]\n end", "def operation(name, *args, &block)\n branch operations: [[name, args, *block]]\n end", "def new\n\t\t@block = Block.new\n\tend", "def initialize args = {}\n hash_make args, Block::ARG_SPECS\n @initial_params = collect_params\n end", "def new_block_el(*args)\n el = Element.new(*args)\n if @block_ial\n el.options[:ial] = @block_ial\n @block_ial = nil\n end\n el\n end", "def initialize(*args, &task_block)\n @name = args.shift || :changelog\n\n define(args, &task_block)\n end", "def create_commands args\n command = String.new\n args.each do |arg|\n command << arg << \" \" \n end\n command\n end", "def initialize( prev=nil , type=\"\" , *commands )\n @prev , @type , @commands = prev , type , commands\n end", "def method_missing(name, *args, &block)\n command = registry[name]\n\n if args.size > 1\n command.new(*args, &block)\n else\n command.call(*args, &block)\n end\n end", "def new *args\n require 'zsteg/cli/cli'\n Cli.new(*args)\n end", "def initialize(name, *args)\n _initialize(name, args, OPTS)\n end", "def initialize(name, parser, &block)\n @name = name\n @parser = parser\n @modules = []\n @wrapped_functions = []\n @wrapped_classes = []\n @wrapped_structs = []\n\n block.call(self) if block\n end", "def initialize(*args, &task_block)\n @name = args.shift || :lint\n\n define(args, &task_block)\n end", "def args_from_node(args_node); end", "def initialize(raw)\n self.raw = raw\n self.params = []\n end", "def initialize(argv=[])\n super()\n #@text = Text.new(STDOUT, STDERR, STDIN, config)\n @text ||= Megam::Text.new(STDOUT, STDERR, STDIN, config)\n command_name_words = self.class.snake_case_name.split('_')\n\n # Mixlib::CLI ignores the embedded name_args\n\n @name_args = parse_options(argv)\n\n @name_args.delete(command_name_words.join('-'))\n\n @name_args.reject! { |name_arg| command_name_words.delete(name_arg) }\n\n # meg node run_list add requires that we have extra logic to handle\n # the case that command name words could be joined by an underscore :/\n command_name_words = command_name_words.join('_')\n @name_args.reject! { |name_arg| command_name_words == name_arg }\n if config[:help]\n msg opt_parser\n exit 1\n end\n\n # copy Mixlib::CLI over so that it cab be configured in meg.rb\n # config file\n Meggy::Config[:verbosity] = config[:verbosity]\n end", "def method_missing(method_name, *args, &block)\n name = args.shift\n add_to_hash(name, options: [method_name] + args)\n\n new_parser = self.class.new\n add_to_hash(name, content: new_parser.instance_exec(&block)) if block\n add_to_hash(name, content: new_parser.hash)\n new_parser\n end", "def initialize\n super(Network.generate_id(\"block_\"))\n end", "def new(*args,&block)\n Base.new(*args,&block)\n end", "def initialize(name, &block)\n @name = name\n @platos = []\n @precios = []\n @valor_energetico = []\n @valor_ambiental = []\n\n if block_given?\n if block.arity == 1\n yield self\n else\n instance_eval(&block)\n end\n end\n end", "def method_missing(meth, *args, &block)\n if args.length == 0\n code = Block.new(meth.to_s , self )\n if block_given?\n add_block code\n code.instance_eval(&block)\n end\n return code\n else\n super\n end\n end", "def initialize(**args)\n self.args = args\n self.args.freeze\n\n parse_arguments\n validate_arguments!\n\n end", "def initialize( type, parser, state )\n\t\t@args = []\n\t\t@pureargs = []\n\t\tsuper\n\tend", "def initialize(*args, &task_block)\n @name = args.shift || :filter_tasks\n @verbose = true\n @commands = []\n\n desc 'TODO: FILL THIS IN THE BLOCK WHERE YOU CREATE THE TASK'\n\n instance_eval(&task_block)\n run_task(name, *args)\n end", "def node(name, type = Node, &block)\n parent = @nodes_stack.empty? ? Node::ROOT : @nodes_stack.last\n level = [0, @nodes_stack.size - 1].max\n prefix = ':pipe' * level\n if parent.class == LeafNode\n prefix = ':space' * level\n end\n node = type.new(name, parent.full_path, prefix, @nodes_stack.size)\n @nodes << node\n\n return unless block_given?\n\n @nodes_stack << node\n if block.arity.zero?\n instance_eval(&block)\n else\n instance_eval(&(->(*_args) { block[node] }))\n end\n @nodes_stack.pop\n end", "def initialize name, opts={}, **kwargs\n { arguments: []}.merge(opts).merge(kwargs) => { arguments: }\n @name = name\n @arguments = arguments\n end", "def arg_node\n case node.type\n when :command, :aref then node[2][1]\n when :method_add_arg then (node[2][1] ? node[2][1] : nil)\n when :method_add_block then node[1].method_call.arg_node\n when :call, :var_ref, :vcall, :command_call, :zsuper then nil\n when :command_call then node[4][1]\n when :super\n node[1].type == :arg_paren ? node[1][1] : node[1]\n end\n end", "def initialize(name, &block)\n @name = name\n @modules = []\n @writer_mode = :multiple\n @requesting_console = false\n @force_rebuild = false\n\n @options = {\n :include_paths => [],\n :library_paths => [],\n :libraries => [],\n :cxxflags => [],\n :ldflags => [],\n :include_source_files => [],\n :includes => []\n }\n\n @node = nil\n\n parse_command_line\n\n if requesting_console?\n block.call(self) if block\n start_console\n elsif block\n build_working_dir(&block)\n block.call(self)\n build\n write\n compile\n end\n end", "def op(*args, &block)\n Operation.new(*args, &block)\n end", "def raw *args\r\n puts \"not implemented yet\"\r\n end", "def run( args )\n args = args.dup\n\n parse args\n init args\n self.__send__(*@command)\n end", "def syntax\n t = @cmd_args\n t = [[t]] if !t.is_a? Array\n\n args = [] \n count = 0\n t.each do |expected_array|\n count += 1\n if count == 1\n str = \"Syntax: #{@cmd_name}\"\n else\n str = \" #{@cmd_name}\"\n end\n expected_array.each do |expected|\n # each expected arg.\n str += case expected\n when :arg_none then \"\"\n when :arg_dir! then \" <direction>\"\n when :arg_str! then \" <string literal>\"\n when :arg_word!then \" <word>\"\n when :arg_int! then \" <#>\"\n when :arg_obj_inv! then \" <item>\"\n when :arg_obj_room! then \" <item>\"\n when :arg_obj_inv_or_room! then \" <item>\"\n when :arg_class! then \" <Class>\"\n when :arg_player_in_game! then \" <player in game>\"\n when :arg_player_offline! then \" <any player>\"\n when :arg_actor_room! then \" <npc/player>\"\n when String then \" \" + expected \n else \"\"\n \n end\n end \n args << str\n end\n return args\n end", "def command(*args, &_block)\n builder do |xml|\n xml.command do\n if block_given?\n yield xml\n else\n command = args.shift\n command.call(xml)\n args.each do |ext|\n xml.extension do\n ext.call(xml)\n end\n end\n end\n xml.clTRID(clTRID)\n end\n end\n end", "def ident\n \"<Command name=#{name}>\"\n end", "def initialize(*args)\n @args = args\n end", "def name _args\n \"name _args;\" \n end", "def initialize(names,options)\n super(names,options)\n @argument_name = options[:arg_name] || \"arg\"\n @must_match = options[:must_match]\n @type = options[:type]\n @mask = options[:mask]\n @required = options[:required]\n @multiple = options[:multiple]\n end", "def method_missing(name,*args,&block)\n self.class.send :define_method,\"parse_#{name}\" do |node,contents|\n block.call node,contents\n end\n end", "def node(*args)\n Node.new(self, *args)\n end", "def node(*args)\n Node.new(self, *args)\n end", "def command_for(name, *args)\n command_str_for(*(COMMANDS[name] + args))\n end", "def initialize(name, depth = nil, overflow = nil, &ruby_block)\n @name = name.to_sym\n @body = ruby_block\n @depth = depth ? depth.to_i : nil\n @overflow = overflow ? overflow.to_proc : nil\n end", "def evaluate_block_with_arguments(block, args)\n # If block.arity < 0, when a block takes a variable number of args,\n # the one's complement (-n-1) is the number of required arguments\n required_arguments = block.arity < 0 ? ~block.arity : block.arity\n if args.length >= required_arguments\n if block.arity < 0\n instance_exec(*args, &block)\n else\n instance_exec(*args.first(block.arity), &block)\n end\n else\n raise ArgumentError.new(\"wrong number of arguments (#{args.size} for #{required_arguments})\")\n end\n end", "def initialize(args)\n end", "def initialize(argv = [])\n super() # having to call super in initialize is the most annoying anti-pattern :(\n @ui = Chef::Knife::UI.new(STDOUT, STDERR, STDIN, config)\n\n command_name_words = self.class.snake_case_name.split(\"_\")\n\n # Mixlib::CLI ignores the embedded name_args\n @name_args = parse_options(argv)\n @name_args.delete(command_name_words.join(\"-\"))\n @name_args.reject! { |name_arg| command_name_words.delete(name_arg) }\n\n # knife node run_list add requires that we have extra logic to handle\n # the case that command name words could be joined by an underscore :/\n command_name_joined = command_name_words.join(\"_\")\n @name_args.reject! { |name_arg| command_name_joined == name_arg }\n\n # Similar handling for hyphens.\n command_name_joined = command_name_words.join(\"-\")\n @name_args.reject! { |name_arg| command_name_joined == name_arg }\n\n if config[:help]\n msg opt_parser\n exit 1\n end\n\n # Grab a copy before config merge occurs, so that we can later identify\n # where a given config value is sourced from.\n @original_config = config.dup\n\n # copy Mixlib::CLI over so that it can be configured in config.rb/knife.rb\n # config file\n Chef::Config[:verbosity] = config[:verbosity] if config[:verbosity]\n end", "def initialize_argument_list\n args = ArgumentList.new\n args.x = args.y = args.width = args.height = 0\n args.text = ''\n args.options = {}\n\n args\nend", "def initialize(name,&ruby_block)\n # Checks and sets the name.\n @name = name.to_sym\n # Sets the block for instantiating a task.\n @ruby_block = ruby_block\n # Sets the instantiation procedure if named.\n return if @name.empty?\n obj = self\n HDLRuby::High.space_reg(@name) do |*args|\n obj.instantiate(*args)\n end\n end", "def args\n raw_args\n end", "def initialize(args)\n @args = args\n end", "def initialize(name, *instructions)\n @name = name\n @instructions = build_instructions(instructions)\n @tags = []\n end", "def initialize(name, options, block)\n @name = name\n @options = options\n @block = block\n async.run\n end", "def initialize(*args)\n fail ArgumentError, \"no command given\" if args.empty?\n @command = args\n @ran = false\n end", "def initialize(*args)\n raise ArgumentError, \"Must pass arguments to Command.new\" if args.empty?\n @options = default_options.merge(args.extract_options!)\n @command = sanitize_command(args.shift)\n @args = args\n @options.symbolize_keys!\n @stdout, @stderr, @full_stdout, @full_stderr = String.new, String.new, String.new, String.new\n @uuid = Digest::SHA1.hexdigest(SecureRandom.random_bytes(10))[0..7]\n end" ]
[ "0.6585519", "0.6168184", "0.6128972", "0.60842866", "0.6081653", "0.60322154", "0.59502864", "0.5863933", "0.5813367", "0.5808431", "0.5790726", "0.5786573", "0.5776735", "0.57718474", "0.57465255", "0.57334", "0.5682308", "0.5667897", "0.56664985", "0.56640947", "0.56623715", "0.565043", "0.56207985", "0.56207985", "0.5610976", "0.56099886", "0.5580437", "0.5580072", "0.5578355", "0.5566288", "0.5561686", "0.55488366", "0.5535257", "0.55236113", "0.55236113", "0.55207753", "0.5519342", "0.55165267", "0.54917866", "0.5447109", "0.5446622", "0.541544", "0.5410684", "0.54101783", "0.5396015", "0.53917855", "0.5382995", "0.53755206", "0.5373953", "0.5361756", "0.5358355", "0.5357869", "0.5338381", "0.5308995", "0.5306999", "0.530201", "0.5292768", "0.5291616", "0.52887595", "0.5276381", "0.5265662", "0.5262274", "0.5257643", "0.52521116", "0.5241366", "0.5239367", "0.52333176", "0.5232512", "0.5221531", "0.521827", "0.5212466", "0.51979077", "0.5176152", "0.5171837", "0.51698697", "0.5166661", "0.5156497", "0.5155025", "0.51527166", "0.51473236", "0.5145289", "0.5136152", "0.5135585", "0.51329947", "0.513292", "0.5132916", "0.5132916", "0.51316786", "0.5124063", "0.51209253", "0.51169485", "0.51115334", "0.5106283", "0.51048565", "0.51012945", "0.5099544", "0.50971913", "0.5072311", "0.50600076", "0.50586104" ]
0.73147696
0
BlockCommandactive_block Since BlockCommands have the ability to contain multiple blocks, this method returns (at least in theory) the block within this BlockCommand that the Parser is currently looking as it is iterating over it. You must override this method in your subclass of BlockCommand. It must return a NodeList. TODO: At the moment, this method is not used
def active_block raise NotImplementedError, 'BlockCommand#active_block should be overridden by a subclass' end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_blocks\n @blocks\n end", "def block_node; end", "def block_node; end", "def block\n blockable.blocks.detect{|b| b.identifier == self.identifier.to_s} || \n blockable.blocks.build(:identifier => self.identifier.to_s)\n end", "def blocks\n @blocks ||= []\n end", "def block\n (@blocks ||= Array.new) << Block.new\n @in_block = @blocks.last\n yield\n @in_block = nil\n end", "def iter_to_block_commands(iter)\n if iter[3].is_a?(Array) && iter[3].first == :block\n iter[3][1..-1]\n else\n [iter[3]]\n end\n end", "def blocks\n @blocks ||= []\n end", "def blocks\n @block_stacks.map { |candidates| candidates&.first }\n end", "def get_blocks\n if (branches = @cur_state.branches[@tape.val])\n branches.map { |branch| branch.block } \n else\n [@cur_state.default]\n end\n end", "def process_block_token(tk); end", "def block_class() Block; end", "def active_block\n current_case ? blocks[current_case] : default\n end", "def get_current_block(x, y)\n case @block_type\n when :ordinary\n Block.new(adjust_block_coordinates(x,y).to_vec2d)\n when :sliding_horizontally\n SlidingBlock.new(adjust_block_coordinates(x, y).to_vec2d,\n :horizontal) \n when :sliding_vertically\n SlidingBlock.new(adjust_block_coordinates(x, y).to_vec2d,\n :vertical) \n when :moving_enemy\n MovingEnemy.new(adjust_block_coordinates(x, y).to_vec2d)\n when :prize\n PrizeBottom.new(adjust_block_coordinates(x,y).to_vec2d)\n end\n end", "def list_block()\n\nend", "def current_comment_block\n @current_comment_block ||= current_comment ? comment_blocks.find { |block| block.include?(current_comment) } : []\n end", "def current_type\n\t\t@block_type\n\tend", "def process_block_token(tk)\n if balances?(tk)\n @statement << tk\n @state = :first_statement\n process_statement_end(tk)\n elsif @block_num > 1 || (@block.empty? && [TkSPACE, TkNL].include?(tk.class))\n @statement << tk\n else\n if @block.empty?\n @statement << TkBlockContents.new(tk.line_no, tk.char_no)\n end\n @block << tk\n end\n end", "def iterating_block?(node); end", "def block_def_node\n if @ast == nil\n if block == nil\n return nil\n end\n\n # Get array of block parameter names\n block_params = block.parameters.map do |param|\n param[1]\n end\n\n parser_local_vars = command_binding.local_variables + block_params\n source = Parsing.parse_block(block, parser_local_vars)\n @ast = AST::BlockDefNode.new(\n parameters: block_params,\n ruby_block: block, # necessary to get binding\n body: AST::Builder.from_parser_ast(source))\n end\n\n # Ensure `return` is there\n @ast.accept(Translator::LastStatementReturnsVisitor.new)\n\n return @ast\n end", "def is_block?\n get_metadata(:for_block)\n end", "def block_node=(_); end", "def parse_block_extensions; end", "def blocklists; end", "def basic_blocks\n cfg.blocks\n end", "def open_block\n blocks(limit: 1, sort: :desc).first\n end", "def _LineBlock\n\n _save = self.pos\n while true # choice\n _tmp = apply(:_ItemsList)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_LineCommand)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_LineBlock unless _tmp\n return _tmp\n end", "def parse_block_html; end", "def get_blocks\n @blocks ||= Block.find :all, :conditions => { :show_in_all => '' }\n end", "def process_complex_block_opener(tk)\n return unless OPEN_BLOCK_TOKENS.include?(tk.class)\n\n @current_block = tk.class\n @state = :block_statement\n\n true\n end", "def candidate_block(block)\n return unless (my_index = block.parent.blocks.find_index block)\n\n next_block = block.parent.blocks[my_index + 1]\n return unless next_block && next_block.context == :pass\n\n next_block\n end", "def getblocknumber\n coind.getblocknumber\n end", "def get_block name\n name = name.to_sym\n block = @blocks.find {|b| b.name == name}\n raise \"No block found for #{name} (in #{blocks.collect{|b|b.name}.join(':')})\" unless block\n block\n end", "def basic_blocks\n @basic_block_collection ||= BasicBlockCollection.new(self)\n end", "def get_block\n return nil unless @blk_id\n @block ||= @store.get_block_by_id(@blk_id)\n end", "def i_tunes_block_explicit_content\n return @i_tunes_block_explicit_content\n end", "def anonymous_blocklists; end", "def get_parsable\n @block ||= Block.new\n end", "def block_method_name(node)\n case node.type\n when :block\n node.method_name\n when :block_pass\n node.parent.method_name\n end\n end", "def get_blocks(options = {block_range: (0..0)}, &block)\n get_block_objects(options.merge(object: :block), block)\n end", "def children\n block ? [block] : []\n end", "def block_name \n :CodeBlock \n end", "def block_name \n :CodeBlock \n end", "def block\n true\n end", "def get_block id\n block = self.blocks_get_by_id id\n if block[\"success\"]\n return block[\"block\"]\n else\n return nil\n end\n end", "def render\n Debug.debug { \"Now rendering #{@context} block for #{self}\" }\n @document.playback_attributes @attributes\n out = renderer.render(\"block_#{@context}\", self)\n @document.callouts.next_list if @context == :colist\n out\n end", "def retrieve\n if scope == 'preview'\n if alternate_blocks_retriever.blocks_attributes.present?\n alternate_blocks_retriever.block(identifier)\n else\n blocks_retriever.block(identifier)\n end\n else\n blocks_retriever.block(identifier) if blocks_retriever.live?\n end\n end", "def parse_blocks(el, text = nil)\n @stack.push([@tree, @src, @block_ial])\n @tree, @block_ial = el, nil\n @src = (text.nil? ? @src : ::Kramdown::Utils::StringScanner.new(text, el.options[:location]))\n\n status = catch(:stop_block_parsing) do\n until @src.eos?\n @block_parsers.any? do |name|\n if @src.check(@parsers[name].start_re)\n send(@parsers[name].method)\n else\n false\n end\n end || begin\n warning('Warning: this should not occur - no block parser handled the line')\n add_text(@src.scan(/.*\\n/))\n end\n end\n end\n\n @tree, @src, @block_ial = *@stack.pop\n status\n end", "def get_block(blk_hash)\n raise \"Not implemented\"\n end", "def block\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 2 )\n return_value = BlockReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n\n _last = _first_0 = nil\n statement_block2 = nil\n statement3 = nil\n\n\n begin\n # at line 18:3: ( statement_block | statement )\n alt_2 = 2\n look_2_0 = @input.peek( 1 )\n\n if ( look_2_0 == BLOCK )\n alt_2 = 1\n elsif ( look_2_0.between?( AMP, AMP_ASGN ) || look_2_0 == POST_DECR || look_2_0.between?( GEQ, AREF ) || look_2_0.between?( GREATER, HAT ) || look_2_0.between?( ARROW, HAT_ASGN ) || look_2_0.between?( ASGN, REGEX ) || look_2_0.between?( IN, RETURN ) || look_2_0 == INCR || look_2_0.between?( BREAK, RSHIFT3 ) || look_2_0.between?( LABEL, CATCH ) || look_2_0 == RSHIFT_ASGN || look_2_0 == LEQ || look_2_0.between?( LESS, SLASH ) || look_2_0.between?( SLASH_ASGN, CONTINUE ) || look_2_0.between?( STAR, DECR ) || look_2_0 == STAR_ASGN || look_2_0.between?( LSHIFT, THIS ) || look_2_0 == THROW || look_2_0.between?( MINUS, MOD ) || look_2_0.between?( MOD_ASGN, TYPEOF ) || look_2_0.between?( NEQ, UMINUS ) || look_2_0.between?( NEQQ, UNDEFINED ) || look_2_0.between?( NEW, UPLUS ) || look_2_0.between?( OBJECT, FALSE ) || look_2_0.between?( WITH, PLUS ) || look_2_0.between?( ID, DOC ) )\n alt_2 = 2\n else\n raise NoViableAlternative( \"\", 2, 0 )\n end\n case alt_2\n when 1\n root_0 = @adaptor.create_flat_list\n\n\n # at line 18:5: statement_block\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_statement_block_IN_block_59 )\n statement_block2 = statement_block\n @state.following.pop\n\n @adaptor.add_child( root_0, statement_block2.tree )\n\n\n when 2\n root_0 = @adaptor.create_flat_list\n\n\n # at line 19:5: statement\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_statement_IN_block_65 )\n statement3 = statement\n @state.following.pop\n\n @adaptor.add_child( root_0, statement3.tree )\n\n\n end\n return_value.tree = @adaptor.rule_post_processing( root_0 )\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__, 2 )\n\n end\n \n return return_value\n end", "def block_node_followed_by_fluent_method\n each_backward_chained_node(node, :child_as_second_arg) do |chained_node, child_node|\n next unless chained_node.send_type?\n return child_node if child_node.block_type?\n end\n end", "def parse\n _build_document\n _close_open_block_commands\n @document\n end", "def block_selection\n end", "def id\n @block\n end", "def id\n @block\n end", "def blocks\n @blocks ||= ArkEcosystem::Client::API::Blocks.new(@client)\n end", "def get_block_names\n @blocks.keys\n end", "def block delete = nil\n unless delete.nil? # this is from RubyParser\n return find_node :block, delete\n end\n\n expect :iter, :scope, :resbody\n\n case self.node_type\n when :iter\n self[3]\n when :scope\n self[1]\n when :resbody\n # This is for Ruby2Ruby ONLY\n find_node :block\n end\n end", "def block?\n !!block\n end", "def block_type\n @grpc.block_type.to_sym\n end", "def blocks() end", "def content\n @blocks.map {|b| b.render } * EOL\n end", "def select_wrapping_block\n buffer_current.select_wrapping_block\n update_status_line\n end", "def by_basic_block(bb, level)\n assert(\"RelationNodeList#by_basic_block: level != :src,:dst\") { [:src,:dst].include?(level) }\n lookup(@basic_block_index[level], bb, \"#{level}-block\", false) || []\n end", "def blocks\n @num_blocks > 0 ? blocks_for_num_blocks :\n blocks_for_block_size\n end", "def parse_blocks(el, text = T.unsafe(nil)); end", "def block\n options.fetch(:block)\n end", "def last_block?\n return @last_block\n end", "def parse_block(*_arg0); end", "def sexp_provide_block\n program = sexp[1]\n\n program.each do |s|\n if s[0] == :method_add_block and\n s[1][0] == :command_call and\n s[1][1][0] == :method_add_arg and\n s[1][1][1][0] == :call and\n s[1][1][1][1][0] == :const_path_ref and\n s[1][1][1][1][1][0] == :var_ref and\n s[1][1][1][1][1][1][0..1] == [:@const, \"Puppet\"] and\n s[1][1][1][1][2][0..1] == [:@const, \"Type\"] and\n s[1][1][1][3][0..1] == [:@ident, \"type\"] and\n s[2][0] == :do_block\n\n return s[2][2]\n end\n end\n\n []\n end", "def handle_getblocks\n @node.connections.sample.send_getblocks\n {:state => \"Sending getblocks...\"}\n end", "def get_block(level)\n return nil unless data[\"#{level}-block\"]\n rg.get_function(level).blocks.by_name(data[\"#{level}-block\"])\n end", "def statement_block\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 3 )\n return_value = StatementBlockReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n root_0 = nil\n\n _last = _first_0 = nil\n __BLOCK4__ = nil\n statement_list5 = nil\n\n tree_for_BLOCK4 = nil\n\n begin\n root_0 = @adaptor.create_flat_list\n\n\n # at line 23:5: ^( BLOCK ( statement_list )? )\n _save_last_1 = _last = @input.look\n _first_1 = nil\n root_1 = @adaptor.create_flat_list\n _last = @input.look\n __BLOCK4__ = match( BLOCK, TOKENS_FOLLOWING_BLOCK_IN_statement_block_80 )\n\n tree_for_BLOCK4 = @adaptor.copy_node( __BLOCK4__ )\n\n root_1 = @adaptor.become_root( tree_for_BLOCK4, root_1 )\n\n\n\n if @input.peek == DOWN\n match( DOWN, nil )\n # at line 23:14: ( statement_list )?\n alt_3 = 2\n look_3_0 = @input.peek( 1 )\n\n if ( look_3_0.between?( AMP, AMP_ASGN ) || look_3_0 == POST_DECR || look_3_0.between?( GEQ, AREF ) || look_3_0.between?( GREATER, HAT ) || look_3_0.between?( ARROW, HAT_ASGN ) || look_3_0.between?( ASGN, REGEX ) || look_3_0.between?( IN, RETURN ) || look_3_0 == INCR || look_3_0.between?( BREAK, RSHIFT3 ) || look_3_0.between?( LABEL, CATCH ) || look_3_0 == RSHIFT_ASGN || look_3_0 == LEQ || look_3_0.between?( LESS, SLASH ) || look_3_0.between?( SLASH_ASGN, CONTINUE ) || look_3_0.between?( STAR, DECR ) || look_3_0 == STAR_ASGN || look_3_0.between?( LSHIFT, THIS ) || look_3_0 == THROW || look_3_0.between?( MINUS, MOD ) || look_3_0.between?( MOD_ASGN, TYPEOF ) || look_3_0.between?( NEQ, UMINUS ) || look_3_0.between?( NEQQ, UNDEFINED ) || look_3_0.between?( NEW, UPLUS ) || look_3_0.between?( OBJECT, FALSE ) || look_3_0.between?( WITH, PLUS ) || look_3_0.between?( ID, DOC ) )\n alt_3 = 1\n end\n case alt_3\n when 1\n # at line 23:14: statement_list\n _last = @input.look\n @state.following.push( TOKENS_FOLLOWING_statement_list_IN_statement_block_82 )\n statement_list5 = statement_list\n @state.following.pop\n\n @adaptor.add_child( root_1, statement_list5.tree )\n\n\n end\n\n match( UP, nil )\n end\n @adaptor.add_child( root_0, root_1 )\n _last = _save_last_1\n\n\n\n return_value.tree = @adaptor.rule_post_processing( root_0 )\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__, 3 )\n\n end\n \n return return_value\n end", "def block_name \n to_sym\n end", "def iterating_block?(node)\n name = block_method_name(node)\n name && iterating_method?(name)\n end", "def block?\n block_tag? || block_body? || document?\n end", "def xml_blocks\n %w(start_blocks toolbox_blocks required_blocks recommended_blocks)\n end", "def process_blocks(blocks); end", "def block(node, in_sentence=false)\n body = node.array\n body.each_with_index do |node, index|\n if body.length == index + 1 # last element\n if @in_method\n emit \"Finally we return \"\n end\n visit node, true\n emit \".\"\n else\n visit node, in_sentence\n emit '. '\n end\n end\n end", "def return_values(block_body_node); end", "def consume_simple_block(input = @tokens)\n start_token = input.current[:node]\n end_token = BLOCK_END_TOKENS[start_token]\n\n block = {\n :start => start_token.to_s,\n :end => end_token.to_s,\n :value => [],\n :tokens => [input.current]\n }\n\n block[:tokens].concat(input.collect do\n while token = input.consume\n break if token[:node] == end_token\n\n input.reconsume\n block[:value] << consume_component_value(input)\n end\n end)\n\n create_node(:simple_block, block)\n end", "def parse(block)\n ast = block.to_ast\n # produces sth. like:\n # (block\n # (send ..)\n # (args)\n # (begin ..)\n # )\n inner_ast = ast.children[2] # pick up (begin..)\n if inner_ast.type == :send\n lines = [inner_ast]\n else\n lines = inner_ast.children\n end\n\n lines.map do |node|\n if node.type == :send\n buf = []\n extract_value(node, buf)\n buf.reverse\n end\n end\n end", "def blocks\n if num_blocks.positive?\n blocks_for_num_blocks\n else\n blocks_for_block_size\n end\n end", "def new_block_el(*args); end", "def body\n Node::Block.new([return_operation])\n end", "def blocks?\n !@blocks.empty?\n end", "def _BlockDelimiter\n\n _save = self.pos\n while true # choice\n _tmp = apply(:_BlockHead)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_BlockEnd)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_BlockDelimiter unless _tmp\n return _tmp\n end", "def blocks\n @blocks ||= Array(@grpc.blocks).map do |b|\n Block.from_grpc b\n end\n end", "def block_number\n request('getblocknumber')\n end", "def return_block\n return @function.return_block\n end", "def current\n return nil unless @node\n @node.item\n end", "def next\n ptr = C.LLVMGetNextBasicBlock(self)\n BasicBlock.from_ptr(ptr) unless ptr.null?\n end", "def block(name, value = nil, &block)\n value = self._template.context.capture(&block) if value.nil? && block\n self._template.blocks[name] ||= value\n return self._template.blocks[name]\n end", "def block_list(context={})\n \n blocks = []\n blocks.concat(get_menus_as_blocks(context))\n blocks.concat(get_breadcrumb_as_block(context))\n blocks.concat(get_public_breadcrumb_as_block(context))\n blocks.concat(get_views_as_blocks(context))\n blocks.concat(get_contents_as_blocks(context))\n \n return blocks\n \n end", "def blocks_to_embed(block_xml)\n return block_xml\n end", "def cms_block_content(identifier, blockable = @cms_page, use_old_code = false)\n if use_old_code\n tag = blockable && (block = blockable.blocks.find_by_identifier(identifier)) && block.tag\n return '' unless tag\n tag.content\n else\n pluck_page_block_content(identifier, blockable)\n end\n end", "def content\n if @block\n instance_eval(&@block)\n end\n end", "def get_all_blocks\n\n @all_blocks = Block.where(is_published: 't')\n\n end", "def blocks; end", "def blocks; end" ]
[ "0.6610187", "0.64303994", "0.64303994", "0.6326704", "0.6225922", "0.62140965", "0.6201415", "0.61609197", "0.6132075", "0.61044264", "0.6054984", "0.60532784", "0.6030627", "0.6024402", "0.593743", "0.59208715", "0.5899928", "0.5820576", "0.5778507", "0.57395554", "0.57390845", "0.5732719", "0.56913555", "0.5686086", "0.56788164", "0.56343764", "0.5625156", "0.5583954", "0.55756915", "0.55640316", "0.55522436", "0.55287087", "0.5520617", "0.5494527", "0.5491332", "0.5489223", "0.5487442", "0.548285", "0.54811585", "0.54672116", "0.54499954", "0.54451406", "0.54451406", "0.54436815", "0.5419571", "0.54144293", "0.5405918", "0.5385215", "0.53800845", "0.53772503", "0.53596216", "0.5357046", "0.5356196", "0.5352353", "0.5352353", "0.5330085", "0.5304786", "0.529051", "0.5285023", "0.52776045", "0.526802", "0.5265145", "0.5261541", "0.5253165", "0.52529573", "0.525078", "0.5249751", "0.5247999", "0.52464557", "0.52242976", "0.5213675", "0.5213053", "0.5198185", "0.5194937", "0.5185106", "0.5183843", "0.5183001", "0.5175289", "0.5173853", "0.51732606", "0.51695925", "0.5167154", "0.5165153", "0.51623416", "0.51513904", "0.51429486", "0.5138768", "0.5128246", "0.5122951", "0.5121504", "0.5120141", "0.51174796", "0.5115153", "0.51148236", "0.51144797", "0.5113965", "0.5108518", "0.5103011", "0.510295", "0.510295" ]
0.74524754
0
BlockCommandto_s A convenience method. Returns a String.
def to_s "[ #{@name} ]" end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_s\n return command\n end", "def to_s\n #N Without this we won't see the command as a command and a list of arguments\n return command.join(\" \")\n end", "def to_s\n msg = ''\n msg += \"Command: #{name}\\n\"\n options.each { |o| msg += \" \" + o.inspect + \"\\n\"}\n msg += \"\\n\"\n commands.each { |k, v| msg += commands[k].inspect }\n msg\n end", "def to_s(n_cmds); end", "def to_s\n \"executed `#{@command.to_s.ellipsisize}'\"\n end", "def to_s()\r\n\t\ts = \"\"\r\n\t\tif @cuerpo != nil\r\n\t\t\ts << @cuerpo.to_s(0) + \"\\n\"\r\n\r\n\t\telse\r\n\t\t\ts = \"Block\"\r\n\t\tend\r\n\t\treturn s\r\n\tend", "def to_s()\r\n\t\ts = \"\"\r\n\t\tif @cuerpo != nil\r\n\t\t\ts << @cuerpo.to_s(0) + \"\\n\"\r\n\r\n\t\telse\r\n\t\t\ts = \"Block\"\r\n\t\tend\r\n\t\treturn s\r\n\tend", "def to_s\n s = @list.join(command_join_string!)\n s\n end", "def to_s\n \"#{@dir}> #{@cmd}\"\n end", "def to_s\n 'Abstract Command'\n end", "def to_s\n to_buffer.to_s\n end", "def to_s # :nocov:\n s = []\n s << \"CommandSpec:#{self.object_id}\"\n s << \" digest: #{self.digest}\"\n s << \" repo: #{self.repo}\"\n s << \" bundle: #{self.bundle}\"\n s << \" command: #{self.command}\"\n s << \" args: #{self.args}\"\n s << \" user: #{self.user}\"\n s << \" group: #{self.group}\"\n s << \" env: \" + (self.env.nil?() ? \"\" : MultiJson.dump(self.env))\n s << \" stdin: \" + Debug.pretty_str(stdin)\n s.join(\"\\n\")\n end", "def to_s\n pad_field :options\n recalc_block_len\n to_a.map(&:to_s).join + @packets.map(&:to_s).join\n end", "def to_s\n \"[#{command}] => #{exit_code}, #{output.to_s.bytesize} bytes, #{duration} seconds\"\n end", "def to_s\n string\n end", "def to_s\n raw\n end", "def to_s\n to_text\n end", "def to_s\n @stringio.string\n end", "def to_s\n if (@perm.kind_of?(Proc))\n @perm.call(@block).to_s\n else\n @perm.to_s\n end\n end", "def to_s\n @string\n end", "def to_s\n @string\n end", "def to_s\n @string\n end", "def to_s\n @string\n end", "def to_s\n target.to_s\n end", "def to_s\n object.to_s\n end", "def to_s\n text =\"\"\n {'type'=>@type, 'copy'=>(@copy) ? \":copy\" : nil, 'target'=>@target}.each do |name,item|\n if ['target'].index(name)\n text += \"\\\"#{item}\\\" \" unless item.nil?\n else\n text += \"#{item} \" unless item.nil?\n end\n\n end\n text[text.length-1] = \";\" if text.length > 0\n text\n end", "def to_s\n\t\tturntostring\n\tend", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def to_s() end", "def command\n return @raw_command\n end", "def to_s\n to_symbol.to_s\n end", "def to_s; \"<Block #{length}>\"; end", "def to_s\n\t\t\treturn @buffer.to_s\n\t\tend", "def to_s\n str = ''\n str << \"Command: #{@feature} #{@name}\\n\"\n @hash.each { |key, value| str << \" #{key}: #{value}\\n\" }\n str\n end", "def to_s\n @string\n end", "def to_s\n @string\n end", "def to_s\n @string\n end", "def to_s\n @string\n end", "def inspect\n return to_s if success?.nil?\n (success? ? \"success : \" : \"fail : \") + @command\n end", "def to_s\n str\n end", "def to_s\n\t\t\treturn self.each_byte.to_a.pack( 'C*' )\n\t\tend", "def to_s\n return @convert\n end", "def to_s\n return @convert\n end", "def to_s(*) end", "def to_s(*) end", "def to_s(*) end", "def to_s\n\t\t\t@string\n\t\tend", "def to_s\n redacted_string(:to_s)\n end", "def to_s\n redacted_string(:to_s)\n end", "def to_s\n toString()\n end", "def to_s\n toString\n end", "def to_s\n inspect.to_s\n end", "def to_s\n @object.to_s\n end", "def to_s\n l = \" (lambda)\" if lambda?\n \"#<#{self.class}:0x#{self.object_id.to_s(16)}@#{@block.file}:#{@block.line}#{l}>\"\n end", "def to_iscp\n return \"#{@start + @unit_type + @command + @parameter}\"\n end", "def to_s\n text = \"#{keyword} #{base}\"\n text << \"\\n\" + block.to_s.split(\"\\n\").collect { |line| \" #{line}\" }.join(\"\\n\") if block\n\n text\n end", "def to_s\n statements.collect { |s| s.to_s }.join(\";\\n\")\n end", "def to_s\n @str\n end", "def to_s\n @str\n end", "def to_str\n to_s\n end", "def to_s\n @target\n end", "def to_s\n rv = ''\n write rv\n rv\n end", "def to_s() @out.to_s end", "def to_s\n msg_str = \"Command Packet Hex Str: #{@cmd_str.to_s}\\n\"\n msg_str << \"net_id: #{@net_id}\\n\"\n msg_str << \"pkt_no: #{@pkt_no}\\n\"\n msg_str << \"cmd_id: #{@cmd_id.to_s(16)}\\n\"\n msg_str << \"res_req: #{@res_req}\\n\"\n msg_str << \"ack_req: #{@ack_req}\\n\"\n msg_str << \"ack_bit: #{@ack_bit}\\n\"\n msg_str << \"err_bit: #{@err_bit}\\n\"\n if @data != nil\n data_str = \"\"\n if @data == CmdManager::DONT_CARE\n data_str = CmdManager::DONT_CARE\n else \n @data.each{|x| \n if x == CmdManager::DONT_CARE\n data_str << CmdManager::DONT_CARE\n else\n data_str << \"#{x.to_s(16)} \"\n end\n }\n end\n \n msg_str << \"data: [#{data_str.chop}]\\n\"\n end\n if @error_no != 0\n msg_str << \"error_desc: #{@error_desc}\\n\"\n end\n \n msg_str\n end", "def to_s\n source\n end", "def to_s\n source\n end", "def to_s\n @to_s ||= traite_to_text\n end", "def to_s\n @module.to_s\n end", "def to_s\n @message.to_s\n end", "def to_s\n end", "def to_s\n end", "def to_s\n end", "def to_s\n end", "def to_s\n pad_field :data, :options\n recalc_block_len\n to_a.map(&:to_s).join\n end", "def to_s\n @code.to_s\n end", "def to_s\n @string.to_s\n end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end" ]
[ "0.7274692", "0.67441344", "0.66691697", "0.6443314", "0.6411545", "0.6346718", "0.6346718", "0.6260042", "0.624778", "0.618448", "0.60809064", "0.60204303", "0.6009049", "0.5927742", "0.59268844", "0.5913619", "0.58910495", "0.5888042", "0.58464164", "0.5816891", "0.5816891", "0.5816891", "0.5816891", "0.58158535", "0.58013606", "0.58002764", "0.5764216", "0.57613003", "0.57613003", "0.57613003", "0.57613003", "0.57613003", "0.57613003", "0.57613003", "0.57613003", "0.57613003", "0.57613003", "0.57613003", "0.57613003", "0.57613003", "0.57613003", "0.57613003", "0.57613003", "0.57613003", "0.57613003", "0.57605", "0.5757835", "0.5757444", "0.57535", "0.57530195", "0.5746232", "0.5746232", "0.5746232", "0.5746232", "0.57424384", "0.574102", "0.57390875", "0.57365525", "0.57365525", "0.5731142", "0.5731142", "0.5731142", "0.5719129", "0.5717534", "0.5717534", "0.5717235", "0.5685123", "0.56814164", "0.5680271", "0.56699336", "0.565725", "0.5655689", "0.5647199", "0.5639919", "0.5639919", "0.563517", "0.56222004", "0.5614833", "0.56052226", "0.56044084", "0.55976367", "0.55976367", "0.55843586", "0.5569109", "0.5568945", "0.5567664", "0.5567664", "0.5567664", "0.5567664", "0.5559203", "0.5553348", "0.55468434", "0.55460113", "0.55460113", "0.55460113", "0.55460113", "0.55460113", "0.55460113", "0.55460113", "0.55460113", "0.55460113" ]
0.0
-1
Writes an object to the stream. Calls the object's write() method, if available. Uses to_s otherwise.
def write( object ) if object.responds_to?(:write_to) then object.write_to(@stream) else @stream << object.to_s end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def puts( obj )\n return unless writeable?\n\n data = Marshal.dump(obj)\n @socket.write([data.size].pack('I')) + @socket.write(data)\n rescue SystemCallError\n return nil\n end", "def write_object(object)\n object\n end", "def write_object(object)\n @encoder.encode(object, @sock)\n end", "def write object\n if open?\n @reader.close\n @writer.write Marshal.dump(object)\n @writer.close\n end\n end", "def write_object object\n\t\t\t\t@output.puts object.to_json\n\t\t\t\t@output.flush\n\t\t\tend", "def io(data, io)\n io.write(obj)\n end", "def write(io)\n if io.is_a?(String)\n io = File.open(io, 'w')\n self.write(io)\n io.close\n return\n end\n\n Marshal.dump(self, io)\n end", "def write_to(stream)\n end", "def echo obj\n str = obj.to_s\n write str\n end", "def write_raw(obj,encoding = 3)\n\t @stream = \"\" #new output stream\n\t RequestStore.amf_encoding = (encoding == 3) ? 'amf3' : 'amf0'\n\t reset_referencables\n\t write(obj)\n\t @stream\n\tend", "def send_object obj\n data = serializer.dump(obj)\n send_data [data.respond_to?(:bytesize) ? data.bytesize : data.size, data].pack('Na*')\n end", "def dump(obj, io)\n io.puts obj.send(inspect_method)\n end", "def serialize(_object, data); end", "def serialize(_object, data); end", "def output object\n STDOUT.puts \"#{object}\"\n end", "def store(object)\n @collector.sending_stream.puts pack(:store, object)\n end", "def serialize(object) end", "def write!( string )\n @stream << string\n end", "def serialize(object, data); end", "def write_object(object)\n extend_for(super)\n end", "def write(io)\n io = BinData::IO.new(io) unless BinData::IO === io\n\n do_write(io)\n io.flush\n self\n end", "def write\n raise \"Writers must implement #write\"\n end", "def write(msg)\n\t\t\t\t# object should implement send_data\n\t\t\t\traise \"Abstract method called\"\n\t\t\tend", "def puts( *objects )\n\t\t\tself.payload.puts( *objects )\n\t\tend", "def write(s)\n do_write(s)\n s.bytesize\n end", "def write_to(io, *options); end", "def serialize(object)\n object.to_s\n end", "def write\n end", "def to_s_safe(obj)\n if obj.respond_to?(:to_s)\n obj.to_s\n else\n 'to_s error'\n end\n end", "def serialize(obj, state = nil)\n state = SerializerState.from_state(state)\n obj.to_amf(state)\n end", "def write; end", "def write; end", "def to_s\n io = StringIO.new\n write(io)\n io.rewind\n io.read\n end", "def write(io)\n io.write [@value].pack(format)\n end", "def write_to(io)\n end", "def write_to(io)\n end", "def dump(object)\n raise NotImplementedError, \"#{self.class}#dump is not implemented\"\n end", "def serialize(object)\n raise_or_return(object)\n end", "def marshal(_object, _options = {})\n raise NotImplementedError\n end", "def to_s\n io = StringIO.new\n write io\n io.string\n end", "def string_stream\n s = @object.to_s\n s = s.dup if s.frozen?\n marker_string(0x80, 0xD0, @object.to_s.bytesize) + s.force_encoding(Encoding::BINARY)\n end", "def write s\n raise RuntimeError, \"No socket\" unless @socket\n @socket.puts s += \"\\r\\n\"\n puts \"WROTE: #{s.inspect}\" if config[:debug]\n end", "def p(obj)\n @response.write(obj.inspect)\n end", "def save(file)\n case file\n when String\n io = File.open(file, 'wb')\n when IO , StringIO\n io = file\n else\n raise \"must pass io or filename, not #{file}\"\n end\n @object.write io\n io.close\n end", "def write(data); end", "def write(data); end", "def write(data); end", "def write(data); end", "def sendline(obj)\n s = obj.to_s + context.newline\n write(s)\n end", "def write(string)\n self << string\n end", "def putc(obj)\n if obj.is_a?(Numeric)\n write((obj.to_i & 0xff).chr)\n else\n write(obj.to_s.byteslice(0))\n end\n end", "def serialize(io)\n Encoder.encode(io, self)\n io\n end", "def << (s)\n do_write(s)\n self\n end", "def write_to(stream)\n stream.write_int(@my_index)\n stream.write_int(@current_tick)\n stream.write_int(@max_tick_count)\n stream.write_int(@players.length())\n @players.each do |players_element|\n players_element.write_to(stream)\n end\n stream.write_int(@planets.length())\n @planets.each do |planets_element|\n planets_element.write_to(stream)\n end\n stream.write_int(@flying_worker_groups.length())\n @flying_worker_groups.each do |flying_worker_groups_element|\n flying_worker_groups_element.write_to(stream)\n end\n stream.write_int(@max_flying_worker_groups)\n stream.write_int(@max_travel_distance)\n stream.write_int(@logistics_upgrade)\n stream.write_int(@production_upgrade)\n stream.write_int(@combat_upgrade)\n stream.write_int(@max_builders)\n stream.write_int(@building_properties.length())\n @building_properties.each do |building_properties_key, building_properties_value|\n stream.write_int(building_properties_key)\n building_properties_value.write_to(stream)\n end\n stream.write_bool(@specialties_allowed)\n if @view_distance.nil?\n stream.write_bool(false)\n else\n stream.write_bool(true)\n stream.write_int(@view_distance)\n end\n end", "def to_s\n # Update length of the stream.\n @content[pn(:Length)] = @stream.length\n # Convert to String.\n out = []\n out << \"#{@element_id} #{@revision} obj\"\n out << @content.to_s\n out << @stream.to_s\n out << \"endobj\"\n return out.join(LF)\n end", "def serialize(_object, data)\n IO.popen(@cmd, 'w') {|io| io.write(data) }\n end", "def write_to io\n io.write(self.to_2da)\n end", "def write(*args)\n @writer.<<(*args) if @writer\n end", "def write(io, constraints = {})\n to_datastream(constraints).write(io)\n end", "def write(io, constraints = {})\n to_datastream(constraints).write(io)\n end", "def write(string)\n @handle.write(string)\n end", "def dump(object)\n raise NotImplementedError, \"#{self.class} must implement #dump\"\n end", "def write(value)\n\t if value.is_a?(ASRecordset) && (RequestStore.recordset_format == 'fl9' || RequestStore.recordset_format == 'fl.data.DataProvider')\n\t write_data_provider(value)\n\t \n\t elsif RequestStore.amf_encoding == 'amf3'\n\t\t write_byte(AMF3_TYPE)\n\t\t write_amf3(value)\n\t\t\n\t\telsif value.is_a?(ASRecordset)\n\t\t write_recordset(value)\n\t\t \n\t\telsif value.nil?\n\t\t\twrite_null\n\n elsif (value.is_a?(Float))\n\t\t\twrite_number(value)\n\n elsif (value.is_a?(Bignum))\n\t\t\twrite_number(value)\n\t\t\n\t\telsif (value.is_a?(Integer))\n\t\t\twrite_number(value)\n\t\t\n\t\telsif (value.is_a?(Fixnum))\n\t\t\twrite_number(value)\n\t\t\n\t\telsif (value.is_a?(Numeric))\n\t\t\twrite_number(value)\n\n\t\telsif (value.is_a?(String))\n\t\t\twrite_string(value)\n\n\t\telsif (value.is_a?(TrueClass) || value.is_a?(FalseClass))\n\t\t\twrite_booleanr(value)\n\t\t\n elsif(value.is_a?(OpenStruct))\n write_object(value)\n \n\t\telsif (value.is_a?(Array))\n\t\t\twrite_array(value)\n\n\t\telsif (value.is_a?(Hash))\n\t\t\twrite_hash(value)\n\n\t\telsif (value.is_a?(Date))\n\t\t\twrite_date(Time.local(value.year, value.month, value.day, 12, 00, 00, 00)) # Convert a Date into a time object\n \n\t\telsif (value.is_a?(Time))\n\t\t\twrite_date(value)\n\n\t\telsif (value.instance_of?(REXML::Document))\n\t\t\twrite_xml(value.write.to_s)\n \n\t\telsif (value.respond_to?(:to_xml))\n\t\t\twrite_xml(value.to_xml)\n \n\t\telse\n\t\t\twrite_object(value)\n\t\tend\n\tend", "def serialize(object)\n return Rubyprot::Serializer.serialize(object)\n end", "def print(*args)\n args.each do |obj|\n self.write obj.to_s\n end\n\n write $OUTPUT_RECORD_SEPARATOR\n flush\n end", "def encode_to(stream)\n ::Protobuf::Encoder.encode(self, stream)\n end", "def write\n\n # output to disk\n File.open(@outfile, 'w:UTF-8') { |file|\n file.write(@buffer)\n }\n end", "def write_(s)\n s = s.encode(@conf['encoding'], s.encoding)\n @sock.puts s\n log.info \"W > #{s}\"\n end", "def write_berp(obj)\n socket.write(Client.create_berp(obj))\n end", "def write(s)\n @file.write(s)\n end", "def write(record)\n @fh.puts(encode(record))\n self\n end", "def write(data)\n end", "def dump(object, options={})\n ::Oj.dump(object, options)\n end", "def dump(object, options={})\n ::Oj.dump(object, options)\n end", "def to_s(obj = T.unsafe(nil)); end", "def dump( obj, &block )\n f = File.open( get_unique_filename, 'w' )\n\n serialized = serialize( obj )\n f.write( serialized )\n\n block.call( serialized ) if block_given?\n\n f.path\n ensure\n f.close\n end", "def write(str)\n writing { write0 str }\n end", "def write(value)\n # pass\n end", "def encode(obj); end", "def write(s)\n binary_to_store = Marshal.dump(s)\n bytes = @ioctx.write(@oid, binary_to_store, binary_to_store.size, @offset)\n # add an xattr :\n set_attribut(@@size_xattr, binary_to_store.size)\n \n @offset += bytes\n bytes\n end", "def save_to_file(obj)\n File.open(@filename, @mode) do |aFile|\n aFile.puts \"#{obj}\"\n end\n end", "def write string\n end", "def write object, index\n raise NotImplementedError\n end", "def serialize(object, user_options)\n object = prepare(object)\n\n return object unless @binding.representable?\n\n @binding.evaluate_option(:serialize, object) do\n marshal(object, user_options)\n end\n end", "def serialize(writer)\n raise StandardError, 'writer cannot be null' if writer.nil?\n super\n writer.write_object_value(\"content\", @content)\n writer.write_object_value(\"size\", @size)\n end", "def write(str)\n puts self.writings(str)\n end", "def write(str)\n puts self.writings(str)\n end", "def output(obj)\n io.puts Yajl::Encoder.encode(obj.merge('job_data' => job_for_output))\n io.flush\n end", "def to_io\n __advance!\n @_st_stream.to_io\n end", "def write\n command :write\n self\n end", "def write(data)\n # black hole, because we don't actually care about what gets written\n end", "def write data\n _data[:out].write data\n _data[:out].flush\n end", "def write_to(stream)\n stream.write_int(TAG)\n @player_view.write_to(stream)\n stream.write_bool(@debug_available)\n end", "def write(buf); end", "def puts(*args)\n args.each do |obj|\n self.write \"#{obj.to_s.sub(/\\n$/, '')}\\n\"\n flush\n end\n end", "def dump(object)\n internal = ::Riak::Serializers.serialize(content_type, object)\n encrypt(internal)\n end", "def _do_write(io)\n raise NotImplementedError\n end", "def out(*args); to_s(*args); end", "def to_io\n @stream.to_io\n end", "def write_to(stream)\n stream.write_int(TAG)\n @player_view.write_to(stream)\n end" ]
[ "0.71540254", "0.6904508", "0.6904365", "0.67931956", "0.67856747", "0.62626743", "0.6194346", "0.6134303", "0.61313057", "0.60799366", "0.59159815", "0.59101236", "0.58574235", "0.58574235", "0.58492833", "0.5848072", "0.58037907", "0.5790163", "0.5717786", "0.5700183", "0.5672945", "0.56723356", "0.56679416", "0.5661896", "0.56305426", "0.5627602", "0.5621343", "0.56077135", "0.55796194", "0.5540874", "0.5532075", "0.5532075", "0.55255", "0.55190516", "0.5498795", "0.5498795", "0.5494014", "0.54918236", "0.5482784", "0.54639417", "0.546252", "0.5454668", "0.545289", "0.54310733", "0.5430133", "0.5430133", "0.5430133", "0.5430133", "0.54281735", "0.54253036", "0.542001", "0.5413598", "0.54125243", "0.54048854", "0.53990304", "0.53879946", "0.53856015", "0.53824884", "0.53723794", "0.53723794", "0.5360135", "0.53581357", "0.5353104", "0.5351735", "0.53508043", "0.53394395", "0.5331586", "0.5314464", "0.53108054", "0.53025144", "0.52951694", "0.5293038", "0.5279355", "0.5279355", "0.52770233", "0.5276575", "0.5272731", "0.526846", "0.5262918", "0.52610314", "0.52579343", "0.52506596", "0.52480483", "0.5237615", "0.52357626", "0.52240247", "0.52240247", "0.52188194", "0.52074385", "0.52068764", "0.5206584", "0.5196482", "0.5184913", "0.51826525", "0.518201", "0.51815575", "0.51782286", "0.5177922", "0.51751536", "0.51747614" ]
0.8353593
0
Runs your block as a DSL against this renderer.
def capture(&block) instance_eval(&block) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dsl_eval(block)\n @dsl ||= DSL.new(self)\n @dsl.instance_eval(&block)\n self\n end", "def render\n if @block\n instance_eval(&@block)\n end\n end", "def execute(&block)\n DSLHelper.new(Class => [:&, :|, :not]) do\n Kernel.load(File.join(File.dirname(__FILE__), 'dsl_ruby_extensions.rb'))\n self.instance_eval(&block)\n end\n end", "def run\n if @block.arity >= 1\n @block.call self\n else\n @block.call\n end\n end", "def render\n Debug.debug { \"Now rendering #{@context} block for #{self}\" }\n @document.playback_attributes @attributes\n out = renderer.render(\"block_#{@context}\", self)\n @document.callouts.next_list if @context == :colist\n out\n end", "def run(&blk)\n raise(\"A block is needed to run\") unless block_given?\n @run_logic = blk\n end", "def run(&block)\n @running_template = block\n end", "def build(&block)\n Util.instance_eval_or_call(dsl, &block)\n self\n end", "def build(&block)\n Util.instance_eval_or_call(dsl, &block)\n self\n end", "def render(&block)\n self.renderer = block\n end", "def run\n block.call\n end", "def run(&block)\n end", "def __dsl_execute(file = nil, &block)\n DSL.new(self, file, &block)\n end", "def run_block\n @_block_content = nil\n unless block.blank?\n @_block_content = if view.parent.present?\n capture(view, &block)\n else\n ## We've been called directly from a controller.\n yield(view)\n end\n end\n end", "def runner(&ruby_block)\n @runner_proc = ruby_block\n end", "def run_block\n yield\nend", "def eval\n @block.eval\n end", "def ruby(&block)\n @ruby_block = block\n end", "def call\n if @block\n @block.arity < 1 ? self.instance_eval(&@block) : @block.call(self)\n end\n self\n end", "def content\n call_block\n end", "def run\n @ctx.call(self,&@blk) if @blk\n end", "def block_node; end", "def block_node; end", "def run\n yield\n end", "def run(&block); end", "def body_content\n call_block\n end", "def call\n @block.arity < 1 ? self.instance_eval(&@block) : @block.call(self) if @block\n self\n end", "def execute\n src = read_dsl\n dsl = Markun::Dsl.new\n dsl.instance_eval src\n convert_markdown_to_html dsl.markun.have_menu\n end", "def dsl_eval(dsl, *args, **_arg2, &block); end", "def client(&block)\n eval('self', block.binding)\n end", "def call(&block)\n instance_eval(&block)\n end", "def call(&block)\n instance_eval(&block)\n end", "def call(&block)\n instance_eval(&block)\n end", "def yield_inside(&block)\n module_eval &block\n end", "def draw(&block)\n instance_eval(&block)\n end", "def give(&my_block)\n my_block.call(\"2 turtle doves\", \"1 partridge\")\nend", "def dsl_eval_with_block_return(dsl, *args, **_arg2, &block); end", "def dsl_eval_with_block_return(dsl, *args, **_arg2, &block); end", "def give(&my_block)\n my_block.call(\"2 turtle doves\", \"1 partridge\")\nend", "def highlight_codeblock(el)\r\n #puts highlight_code(el.value, el.attr['class'], :span)\r\n #h = ::Kramdown::Converter.syntax_highlighter(@options[:syntax_highlighter])\r\n #puts h.call(self, el.value, el.attr['class'], :span)\r\n #puts syntax_highlighter(self, el.value, el.attr['class'], :span)\r\n puts \"SB #{el.inspect}\"\r\n nil # until it's ready for Shoes to eval it. \r\n end", "def start_block_to_dsl(block)\n return \"\" unless block\n\n block_dsls = block.each_block(false).map do |block|\n dsl_content = block.to_dsl\n\n if block.has_comment?\n dsl_content = method_call_with_possible_block(\n \"with_comment\",\n [block.comment, block.comment_pinned].compact.map(&:inspect).join(\", \"),\n dsl_content\n )\n end\n\n if block.is_shadow?\n dsl_content = method_call_with_possible_block(\"shadow\", \"\", dsl_content)\n end\n\n if block.has_position?\n dsl_content = method_call_with_possible_block(\"with_position\", [block.x, block.y].map(&:inspect).join(\", \"), dsl_content)\n end\n\n dsl_content\n end\n block_dsls.join(\"\\n\")\n end", "def client(&block)\n eval('self', block.binding) if block_given?\n end", "def run_block\n if @block\n _block = @block\n @block = nil\n instance_eval &_block\n true\n end\n end", "def initialize(&block)\n unload\n @environment = 'development'\n @load_directories = []\n @dsl = Moonrope::DSL::BaseDSL.new(self)\n @dsl.instance_eval(&block) if block_given?\n end", "def runblock\r\n\t\t\t@b.call\r\n\t\tend", "def runblock\r\n\t\t\t@b.call\r\n\t\tend", "def parse(data, &block)\n parse_dsl(data, false, &block)\n end", "def run(*args,&ruby_block)\n # Gain access to the runner as local variable.\n runner_proc = @runner_proc\n # # The context is the one of the reader.\n # Execute the code generating the reader in context.\n HDLRuby::High.space_push(@namespace)\n HDLRuby::High.cur_block.open do\n instance_exec(ruby_block,*args,&runner_proc)\n end\n HDLRuby::High.space_pop\n end", "def block\n options.fetch(:block)\n end", "def body(&block)\n call_once\n if block_given?\n yield body\n else\n @body\n end\n end", "def call_block\n @_block.call(self) if @_block\n end", "def build(&block)\n instance_eval(&block)\n end", "def post_block\n end", "def post_block\n end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def block; end", "def run\n\t\t\t@walker.run do\n\t\t\t\tself.update\n\t\t\t\t\n\t\t\t\tyield @walker if block_given?\n\t\t\tend\n\t\tend", "def code(lang, &block)\n source_code = capture(&block).strip\n eval('_erbout', block.binding).concat %Q(<pre class=\"CodeRay\"><code class=\"language-#{lang}\">#{html_escape source_code}</code></pre>)\nend", "def rblock\n if block_given?\n # yield execute the block\n yield\n else\n puts \"No block\"\n end\n end", "def script(&block)\n\t\t\t@script = block\n\t\tend", "def initialize(dsl, parent, blk)\n @dsl = dsl\n @parent = parent\n @blk = blk\n @real = st = ::Swt::Custom::StyledText.new(@parent.real,\n ::Swt::SWT::WRAP)\n st.editable = false\n st.caret = nil\n self.set_font\n self.update_text\n @real.pack\n end", "def rucas &block\n self.instance_eval(&block)\n end", "def content\n if @block\n instance_eval(&@block)\n end\n end", "def execute(block)\n model = @wrapper.object\n block.call model\n end", "def html_block!\n @page << @html_block\n end", "def block(name, &block)\n klass = SuperbTextConstructor.block(name, &block)\n @blocks << klass\n klass\n end", "def run(*args,&ruby_block)\n # Gain access to the runner as local variable.\n runner_proc = @runner_proc\n # Execute the code generating the accesser in context.\n HDLRuby::High.space_push(@namespace)\n HDLRuby::High.cur_block.open do\n instance_exec(ruby_block,*args,&runner_proc)\n end\n HDLRuby::High.space_pop\n end", "def main_content\n yield if block_given?\n end", "def dsl(options = {}, &block)\n dsl = DSL::GroupDSL.new(self, options)\n dsl.instance_eval(&block)\n dsl\n end", "def run(&block)\n task('run').tap do |t|\n t.enhance &block if block\n end\n end", "def mapper(&block)\n @mapper = DSL::Mapper.new\n @mapper.instance_exec(&block)\n end", "def runner(&blk); end", "def runner(&blk); end", "def builder &block\n if block_given?\n @builder = Proc.new do\n say_name\n block.call\n shell.padding += 1\n save_instructions if instructions.present?\n shell.padding -= 1\n end\n else\n @builder\n end\n end", "def build_and_run_block(env)\n builder = Vagrant::Action::Builder.new\n @block.call(builder)\n @child_app = builder.to_app(env)\n Vagrant::Action::Runner.new.run(@child_app, env)\n end", "def run_block_proc\n yield\nend", "def execute_block(&block)\n @currently_executing_block = true\n output \"tell session id #{name}_tty\"\n self.instance_eval(&block)\n output \"end tell\"\n @currently_executing_block = false\n end", "def render(&block) #:nodoc:\r\n instance_eval(&block)\r\n @output_buffer\r\n end", "def blocks; end", "def blocks; end", "def blocks; end", "def record_block\n @block = true\n end", "def run(*args,&ruby_block)\n # Gain access to the accesser as local variable.\n runner_proc = @runner_proc\n # Execute the code generating the accesser in context.\n HDLRuby::High.space_push(@namespace)\n HDLRuby::High.cur_block.open do\n instance_exec(ruby_block,*args,&runner_proc)\n end\n HDLRuby::High.space_pop\n end" ]
[ "0.7001058", "0.6772839", "0.6755337", "0.66568166", "0.65246576", "0.64727616", "0.64645255", "0.6356884", "0.6356884", "0.6287815", "0.62836623", "0.627724", "0.62623775", "0.6246424", "0.62230605", "0.6209218", "0.62003386", "0.61987364", "0.61869085", "0.6159928", "0.61046904", "0.60995597", "0.60995597", "0.60995525", "0.60966426", "0.6079463", "0.6078212", "0.6072318", "0.60365117", "0.60289127", "0.60286355", "0.60286355", "0.60286355", "0.6024898", "0.60199445", "0.60083914", "0.6002714", "0.6002714", "0.59964746", "0.5994963", "0.59859836", "0.5984335", "0.5983706", "0.5979193", "0.5960942", "0.5960942", "0.59524864", "0.5949696", "0.5949202", "0.594752", "0.59449", "0.59409827", "0.5935654", "0.5935654", "0.59336907", "0.59336907", "0.59336907", "0.59336907", "0.59336907", "0.59336907", "0.59336907", "0.59336907", "0.59336907", "0.59336907", "0.59336907", "0.59336907", "0.59336907", "0.59336907", "0.59336907", "0.59336907", "0.59336907", "0.59336907", "0.59336907", "0.59336907", "0.5932214", "0.5929355", "0.59272045", "0.5926557", "0.59094423", "0.5904228", "0.59025604", "0.5894127", "0.58810323", "0.58570915", "0.58445835", "0.58355844", "0.58224607", "0.58159393", "0.5815014", "0.58051634", "0.58051634", "0.57837164", "0.5782249", "0.57732874", "0.57710844", "0.5760648", "0.5747087", "0.5747087", "0.5747087", "0.57455224", "0.5731885" ]
0.0
-1
Writes a string directly to the stream, without any filtering.
def write!( string ) @stream << string end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(str)\n writing { write0 str }\n end", "def write(string)\n @handle.write(string)\n end", "def write(string)\n @buffer << string\n self\n end", "def write string\n end", "def write_(s)\n s = s.encode(@conf['encoding'], s.encoding)\n @sock.puts s\n log.info \"W > #{s}\"\n end", "def write(string)\n self << string\n end", "def write(string)\n log :write, string\n @socket << string\n end", "def write_string(string)\n\t\twrite_byte(2)\n\t\twrite_utf(string.to_s)\n\tend", "def write_string(string, data: nil, stream: nil)\n raise ArgumentError, \"String must be present\" if !string\n\n intbuf = write_varint(string.bytesize, data: data, stream: stream)\n\n stringbuf = BTC::Data.ensure_binary_encoding(string)\n\n data << stringbuf if data\n stream.write(stringbuf) if stream\n\n intbuf + stringbuf\n end", "def write_nonblock(string, _options = {})\n write(string)\n end", "def write(str)\n STDOUT.write str\n end", "def write(str)\n puts self.writings(str)\n end", "def write(str)\n puts self.writings(str)\n end", "def write(string)\n length = string.length\n while 0 < length\n IO::select(nil, [@sock])\n @dumplog.log_dump('>', string[-length..-1]) if @options.has_key?(\"Dump_log\")\n length -= @sock.syswrite(string[-length..-1])\n end\n end", "def write(string)\n sanitized_string = string.to_s.chomp(\"\\n\")\n @logger.send(@method, sanitized_string) if sanitized_string.size > 0\n end", "def syswrite(string)\n raise NotImplementedError\n end", "def write(str, len=nil)\n raise ArgumentError, \"str must respond to :to_s\" unless str.respond_to? :to_s\n @mem.write_string(str.to_s, len)\n end", "def write(s)\n @data += s\n end", "def write_nonblock(string)\n nonblock_writable do\n syswrite(string)\n end\n end", "def do_write(s)\n @wbuffer << s\n @wbuffer.force_encoding(Encoding::BINARY)\n @sync ||= false\n\n if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex($/)\n remain = idx ? idx + $/.size : @wbuffer.length\n nwritten = 0\n\n while remain > 0\n str = @wbuffer[nwritten,remain]\n begin\n nwrote = syswrite(str)\n rescue Errno::EAGAIN\n retry\n end\n remain -= nwrote\n nwritten += nwrote\n end\n\n @wbuffer[0,nwritten] = \"\"\n end\n end", "def unbuffered_write(string)\n bytes_written = @io.write(string)\n @total_bytes_in += bytes_written\n bytes_written\n end", "def write(str)\n s = str.to_s\n # TODO: implement String#bytesize\n @length += s.size\n @writer.call s\n\n set_header(Rack::CONTENT_LENGTH, @length)\n str\n end", "def write_string(string)\n if string.nil?\n write_int16(-1)\n else\n write_int16(string.bytesize)\n write(string)\n end\n end", "def write(string)\n written = 0\n length = string.bytesize\n while written < length\n begin\n written += write_nonblock(string.byteslice(written, length - written))\n rescue IO::WaitWritable, Errno::EINTR\n block_until_writable\n retry\n end\n end\n written\n end", "def send(str)\n write(str + 0.chr)\n end", "def write s\n raise RuntimeError, \"No socket\" unless @socket\n @socket.puts s += \"\\r\\n\"\n puts \"WROTE: #{s.inspect}\" if config[:debug]\n end", "def write(string, *smth)\n #This is a stub, used for indexing\n end", "def __emit(str)\n __writer.flush\n end", "def write(string)\n unless(string.empty?)\n output = deflator.deflate(string)\n output << deflator.flush\n io.write(output)\n else\n 0\n end\n end", "def write(s)\n do_write(s)\n s.bytesize\n end", "def write(s)\n @file.write(s)\n end", "def write(string)\n @dumplog.log_dump('>', string) if @options.has_key?(\"Dump_log\")\n @channel.send_data string\n end", "def write(str)\n\t return if str.nil? || str.empty?\n\t finishStartTag() if @inStartTag\n\t @io << NQXML.encode(str)\n\tend", "def write(string)\n send(string)\n string.length\n end", "def <<(str)\n (@stored_body ||= '') << str\n old_write_to(str)\n end", "def write(string)\n\t\t\t\t@write_buffer << string\n\t\t\t\t\n\t\t\t\tif @write_buffer.size > @block_size\n\t\t\t\t\tflush\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn string.bytesize\n\t\t\tend", "def write(string)\n string.to_s.bytesize\n end", "def unbuffered_write(string)\n # First try to write out the contents of the encrypt buffer because if\n # that raises a failure we can let that pass up the call stack without\n # having polluted the encryption state.\n until @encrypt_buffer.empty? do\n @encrypt_buffer.slice!(0, io.write(@encrypt_buffer))\n end\n # At this point we can encrypt the given string into a new buffer and\n # behave as if it was written.\n string.each_byte do |byte|\n temp = decrypt_byte\n @encrypt_buffer << (byte ^ temp).chr\n update_keys(byte.chr)\n end\n @total_bytes_in += string.length\n string.length\n end", "def <<(string)\n\t\t\t\twrite(string)\n\t\t\t\t\n\t\t\t\treturn self\n\t\t\tend", "def write str = \"\"\n @socket.write str + \"\\r\\n\"\n end", "def text(str)\n @serial.write(\"#{str}\\r\")\n end", "def <<(string = nil)\n message = \"\"\n message << delimiter\n message << string if string\n message << \"\\n\" unless message[-1] == ?\\n\n @buffer << message\n flush if @auto_flush\n\n message\n end", "def <<( str )\n if @closed\n raise RuntimeError,\n \"appender '<#{self.class.name}: #{@name}>' is closed\"\n end\n\n unless off?\n begin\n write(str)\n rescue StandardError => err\n ::Logging.log_internal_error(err)\n end\n end\n self\n end", "def write(text = '')\n puts(sanitize(text))\n end", "def write(*s)\r\n if redirected?\r\n s.each{ |x| @Out.WriteFile(x.dup.to_s) }\r\n else\r\n s.each{ |x| _PrintString(x) }\r\n end\r\n end", "def write(string)\n each_ios_and_stdout(string).map(&:write)\n end", "def write(string, filename)\n Util::FileMutation.write(string, filename)\n end", "def write(s)\n @port.write(s)\n sleep(@wait_after_send / 1000.0) if @wait_after_send\n end", "def put(text)\n ostream << text\n ostream.flush\n end", "def write_string(*text); end", "def puts(str)\n @response.write(str)\n end", "def writeline(str)\n\t\t\tputs(\"writing #{(str+\"\\r\\n\").inspect}\") if $DEBUG\n\t\t\t@connection.write(str + \"\\r\\n\")\n\t\tend", "def text(str)\n @headers[Rack::CONTENT_TYPE] = ContentType::TEXT\n write(str)\n end", "def writeline(str)\n writing { write0 str + \"\\r\\n\" }\n end", "def string_stream\n s = @object.to_s\n s = s.dup if s.frozen?\n marker_string(0x80, 0xD0, @object.to_s.bytesize) + s.force_encoding(Encoding::BINARY)\n end", "def write_output(string)\n @output << string\n end", "def puts(string)\n self.buffer += (string + \"\\n\")\n Kernel.puts string\n end", "def << (s)\n do_write(s)\n self\n end", "def print(str)\n @io << str\n end", "def print(str)\n @io << str\n end", "def write(str)\n\t\tlog \"Write: #{str.inspect}\", :traffic\n\t\t\n\t\tbegin\n\t\t\tstr.each_byte do |b|\n\t\t\t\t@device.putc(b.chr)\n\t\t\tend\n\t\t\n\t\t# the device couldn't be written to,\n\t\t# which probably means that it has\n\t\t# crashed or been unplugged\n\t\trescue Errno::EIO\n\t\t\traise Gsm::WriteError\n\t\tend\n\tend", "def write_str(str, enc = \"UTF-8\")\n @j_del.write(str, enc)\n self\n end", "def write_str(str, enc = \"UTF-8\")\n @j_del.write(str, enc)\n self\n end", "def write_str(str, enc = \"UTF-8\")\n @j_del.write(str, enc)\n self\n end", "def sputs(str)\n puts str unless @simple_output\n end", "def canonical_write( str )\n return self if @io.nil?\n\n str = str.force_encoding(encoding) if encoding and str.encoding != encoding\n @io.flock_sh { @io.syswrite str }\n\n if roll_required?\n @io.flock? {\n @age_fn_mtime = nil\n copy_truncate if roll_required?\n }\n @roller.roll_files\n end\n self\n rescue StandardError => err\n self.level = :off\n ::Logging.log_internal {\"appender #{name.inspect} has been disabled\"}\n ::Logging.log_internal(-2) {err}\n end", "def write_text(text)\n if (@text_filter)\n text = @text_filter.call(text)\n end\n @out << text\n end", "def concat(str)\n output.write(str) if str\n end", "def socket_put(str)\n\t\t\t\tdebug(\">>> \" + str)\n\t\t\t\t@socket.puts str\n\t\t\tend", "def write_string_to(key, string, mtime: nil)\n mtime ||= Time.now\n copy_io_to(key, StringIO.new(string), Digest::MD5.base64digest(string), string.length, mtime: mtime)\n end", "def append_without_prefix(string)\n write(string)\n end", "def write(str)\n s = str.to_s\n\n @length += s.bytesize\n @headers[Rack::CONTENT_LENGTH] = @length.to_s\n @body << s\n end", "def outo( str )\n outi nil, str\n end", "def puts(str = '')\n @io << str << \"\\n\"\n end", "def print(string)\n terminator = @options[\"Terminator\"]\n\n if @options[\"Binmode\"]\n self.write(string)\n else\n self.write(string.gsub(/\\n/n, terminator))\n end\n end", "def send(str)\r\n @socket.write(str + 0.chr)\r\n end", "def <<(str)\n @string << str.to_s\n remove_null_character\n self\n end", "def text!(str)\n @buffer << str\n\n return self\n end", "def write(*strings)\n strings.each do |string|\n buffer.append(string)\n end\n end", "def addOutput( string )\n\t\t@obuffer << string.chomp << EOL\n\t\t@server.reactor.enableEvents( @socket, :write )\n\tend", "def send_string(string)\n Babylon.logger.debug(\"SENDING : #{string}\")\n send_data(\"#{string}\") \n end", "def stdout_puts(string, verbosity=Verbosity::NORMAL)\n if (@verbosinator.should_output?(verbosity))\n @stream_wrapper.stdout_puts(string)\n @stream_wrapper.stdout_flush\n end\n\n # write to log as though Verbosity::OBNOXIOUS\n @loginator.log( string, @streaminator_helper.extract_name($stdout) )\n end", "def puts(string)\n send(string)\n nil\n end", "def string\n self.io unless @written\n return @io.string\n end", "def write(text)\n shell.write(text)\n end", "def write(text); @connection.puts(text) end", "def string=(string)\n set_string(string)\n generate_buffers\n end", "def sendString(str)\r\n\t$oculussock.puts str\r\n\tputs \"> \"+str \r\nend", "def <<(buf)\n return write(buf.to_s)\n end", "def add_output( string )\n\t\tself.obuffer << string.chomp << EOL\n\t\tself.server.reactor.enable_events( self.socket, :write )\n\tend", "def clean(string)\n ::ActiveSupport::SafeBuffer.new string.to_s.dup.tap { |s| clean!(s) }\n end", "def <<(string)\n @string << string\n self\n end", "def output(string, opts = {})\n opts[:method] ||= 'puts'\n opts[:stream] ||= $stdout\n opts[:stream].send(opts[:method], string)\n end", "def putz(s)\n s.each_byte do |ch|\n @serial_port.putc(ch)\n @serial_port.flush\n #$log.debug(\"Wrote: \" + ch.chr)\n end\n end", "def write( object )\n if object.responds_to?(:write_to) then\n object.write_to(@stream)\n else\n @stream << object.to_s\n end\n end", "def <<(string)\n\t\t\t@zstring << string\n\t\t\tinflate\n\t\tend", "def push str\n # See: RFC 2045 for this list of characters\n @buffer << str.gsub(%r@[^A-Za-z0-9+/=]@, '')\n pump\n self\n end", "def write_moved(string); end", "def write(str)\n return if noop?\n FileUtils.mkdir_p(File.dirname(file)) #unless File.file?(file)\n File.open(file, 'w'){ |f| f << str }\n end", "def print(string)\n self.buffer += string\n Kernel.print string\n end" ]
[ "0.75466233", "0.73717535", "0.7187002", "0.71484816", "0.6922733", "0.688927", "0.68741834", "0.67630714", "0.67505395", "0.6742431", "0.67225593", "0.65913945", "0.65913945", "0.65718716", "0.655634", "0.6544536", "0.6539199", "0.6489562", "0.64566904", "0.6446546", "0.6432094", "0.642285", "0.6419727", "0.64170325", "0.6293116", "0.6291653", "0.62871903", "0.6284098", "0.6252738", "0.62412804", "0.62363565", "0.622086", "0.62197894", "0.6218565", "0.6205908", "0.61660343", "0.61537343", "0.6132842", "0.6112537", "0.60813236", "0.60624605", "0.6060279", "0.6059897", "0.6043624", "0.603678", "0.6021835", "0.6014472", "0.60098904", "0.6009766", "0.59966797", "0.59790623", "0.59545946", "0.59440124", "0.5931786", "0.59304196", "0.59253395", "0.5923339", "0.5920937", "0.5904223", "0.5904223", "0.58723426", "0.5864107", "0.5864107", "0.5864107", "0.5863853", "0.5860371", "0.5842328", "0.5834475", "0.5834056", "0.58218044", "0.5812201", "0.5794457", "0.57694775", "0.5767397", "0.57611156", "0.5757339", "0.573431", "0.5733747", "0.5729566", "0.5689645", "0.5661712", "0.562913", "0.5621155", "0.5616259", "0.561117", "0.56024677", "0.56006324", "0.5595911", "0.5585957", "0.5578206", "0.5577405", "0.55721426", "0.55645436", "0.5550075", "0.55442953", "0.55420667", "0.5535994", "0.55342346", "0.55339676", "0.5533822" ]
0.82116294
0
USE ONLY if &f is assocoative, AT YOUR OWN RISK. s is used only for the last reduce.
def reduce (s, &f) self.parallelize{|slice| slice.reduce(&f)}.reduce(s, &f) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reduce\n _reduce = ->(acc, f, xs){\n xs == [] ? acc : _reduce.(f.(acc, xs[0]), f, xs[1..-1])\n }\n\n curry.(->(f, xs) {\n _reduce.(xs[0], f, xs[1..-1])\n })\n end", "def _reduce_1(val, _values, result)\n return \"\" \n result\nend", "def _reduce_667(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def _reduce_72(val, _values, result); end", "def reduce_function\n 'function (key, values) { return reduce(key, values);};'\n end", "def _reduce_239(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_595(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_1(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_23(val, _values, result); end", "def _reduce_612(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_387(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_17(val, _values, result); end", "def _reduce_391(val, _values, result)\n result = new_str val[0]\n \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_591(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_234(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_1(val, _values, result); end", "def _reduce_21(val, _values, result); end", "def _reduce_387(val, _values, result); end", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_247(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_548(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_553(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_556(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_608(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_375(val, _values, result)\n result = val[0].concat(val[2]).concat(val[3])\n \n result\nend", "def _reduce_372(val, _values, result); end", "def _reduce_37(val, _values, result); end", "def _reduce_37(val, _values, result); end", "def _reduce_527(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_1(val, _values, result)\n result = val[0]\n\n result\nend", "def _reduce_69(val, _values, result); end", "def _reduce_555(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_391(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_391(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_430(val, _values, result)\n result = new_dsym val[1]\n \n result\nend", "def _reduce_280(val, _values, result); end", "def _reduce_280(val, _values, result); end", "def _reduce_248(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_248(val, _values, result)\n result = val[0]\n \n result\nend", "def _reduce_367(val, _values, result); end", "def _reduce_545(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_740(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_333(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_33(val, _values, result)\n result = new_assign val[0], val[1], s(:svalue, val[2])\n \n result\nend", "def _reduce_33(val, _values, result)\n result = new_assign val[0], val[1], s(:svalue, val[2])\n \n result\nend", "def _reduce_603(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_723(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_561(val, _values, result); end", "def _reduce_561(val, _values, result); end", "def _reduce_707(val, _values, result); end", "def _reduce_669(val, _values, result); end", "def _reduce_727(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_712(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_557(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_377(val, _values, result); end", "def _reduce_424(val, _values, result)\n result = new_str val[0]\n \n result\nend", "def _reduce_591(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_606(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_339(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_455(val, _values, result); end", "def _reduce_718(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_551(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_427(val, _values, result)\n result = new_dsym val[1]\n \n result\nend", "def _reduce_340(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_417(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_375(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_556(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_369(val, _values, result); end", "def _reduce_369(val, _values, result); end", "def _reduce_724(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_430(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_595(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_1(val, _values, result)\n result = val[0] \n result\nend", "def _reduce_715(val, _values, result)\n result = nil\n\n result\nend", "def _reduce_708(val, _values, result)\n yyerrok\n \n result\nend", "def _reduce_581(val, _values, result)\n result = val[1]\n\n result\nend", "def _reduce_120(val, _values, result)\n result = s(:lit, val[0].to_sym) \n result\nend", "def _reduce_120(val, _values, result)\n result = s(:lit, val[0].to_sym) \n result\nend", "def _reduce_439(val, _values, result)\n result = new_dsym val[1]\n \n result\nend", "def _reduce_120(val, _values, result)\n result = s(:lit, val[0].to_sym)\n \n result\nend", "def _reduce_120(val, _values, result)\n result = s(:lit, val[0].to_sym)\n \n result\nend", "def _reduce_120(val, _values, result)\n result = s(:lit, val[0].to_sym)\n \n result\nend", "def _reduce_120(val, _values, result)\n result = s(:lit, val[0].to_sym)\n \n result\nend", "def _reduce_76(val, _values, result); end", "def _reduce_76(val, _values, result); end", "def _reduce_344(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_728(val, _values, result)\n result = nil\n \n result\nend", "def _reduce_390(val, _values, result)\n result = val[1]\n \n result\nend", "def _reduce_473(val, _values, result)\n result = s(:lasgn, val[0])\n \n result\nend", "def _reduce_637(val, _values, result); end", "def _reduce_600(val, _values, result)\n result = nil\n \n result\nend" ]
[ "0.6401935", "0.6053761", "0.59972626", "0.5986387", "0.5986387", "0.59557736", "0.5932066", "0.5931145", "0.59285116", "0.5910238", "0.5904617", "0.5901731", "0.5901554", "0.58995897", "0.5892134", "0.5891917", "0.5890365", "0.5881632", "0.58763105", "0.5861768", "0.58616257", "0.58616257", "0.58616257", "0.58616257", "0.58616257", "0.58616257", "0.58616257", "0.58616257", "0.58616257", "0.5853206", "0.58502275", "0.5847865", "0.5844025", "0.5839067", "0.5828376", "0.5818521", "0.5818521", "0.5816169", "0.5815788", "0.5812625", "0.58116686", "0.5810635", "0.5810635", "0.58099246", "0.5806937", "0.5806937", "0.58059734", "0.58059734", "0.5804793", "0.58013123", "0.580118", "0.57999533", "0.5795612", "0.5795612", "0.5794851", "0.5792758", "0.5791773", "0.5791773", "0.5790691", "0.5789095", "0.5787581", "0.57837707", "0.57825303", "0.5779178", "0.57726675", "0.5771912", "0.57675004", "0.57651037", "0.5764742", "0.5755892", "0.5755114", "0.575398", "0.5751216", "0.57479954", "0.5745204", "0.5744553", "0.5743589", "0.5743589", "0.57428396", "0.5742541", "0.57423097", "0.57401013", "0.573967", "0.57369906", "0.5736402", "0.5735139", "0.5735139", "0.57346016", "0.5733319", "0.5733319", "0.5733319", "0.5733319", "0.5729914", "0.5729914", "0.5726345", "0.57262826", "0.57235473", "0.5722763", "0.57222", "0.5721263" ]
0.721914
0
quantity quantity of the food unit gram/unit/kilo
def food Food.find(self.food_id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def quantity\n quantity_initial - quantity_consumed\n end", "def total_sugars\n food.sugars * quantity\n end", "def quantity\n 1\n end", "def total_cholesterol\n food.cholesterol * quantity\n end", "def qty()\n 1\n end", "def quantity\n read_integer('quantity')\n end", "def quantity\n 1\n end", "def flour_quantity\n weight / (1 + percentages_except_flour) * pizzas\n end", "def quantity\n @quantity ||= DEFAULT_QUANTITY\n end", "def purchase_unit_factor\n return 1 if unit_id == inventory_unit_id\n return 1 / (pack_size || 1) if inventory_unit_id == pack_unit_id\n return 1 / (pack_size || 1) / (subpack_size || 1) if inventory_unit_id == subpack_unit_id\n 1\n end", "def sell_quantity\r\n 100000000000\r\n end", "def quantity\n return @ucItemNumber.value\n end", "def counting_quantity\n product.allow_fractional_quantity? ? 1 : quantity.to_i\n end", "def qty_to_add\n 0\n end", "def qty_to_add\n 0\n end", "def total_magnesium\n food.magnesium * quantity\n end", "def total_potassium\n food.potassium * quantity\n end", "def total_dietaryFiber\n food.dietaryFiber * quantity\n end", "def total_vitaminD\n food.vitaminD * quantity\n end", "def total_quantity\n total = 0.0\n self.quantities.each do |quantity|\n total = total + quantity.number\n end\n total\n end", "def total_trans\n food.trans * quantity\n end", "def quantity\n hash[\"Quantity\"]\n end", "def total_totalFat\n food.totalFat * quantity\n end", "def total_protein\n food.protein * quantity\n end", "def total\n quantity * unit_price\n end", "def total_amount\n unit_amount * quantity\n end", "def total_sodium\n food.sodium * quantity\n end", "def total_amount\r\n quantity * unit_price\r\n end", "def quantity\n map(&:quantity).sum\n end", "def quantity(type=NonEmpty)\n grep(type).inject(0){ |sum, spot| sum + spot.item.count }\n end", "def total_quantity\n line_items.sum(:quantity)\n end", "def get_total_qnty(line_items)\n line_items.map(&:quantity).sum\n end", "def get_total_qnty(line_items)\n line_items.map(&:quantity).sum\n end", "def total_item_number\n @quantity * product.result_n\n end", "def price (quantity)\n if quantity >= 100\n price_per_unit = 8\n elsif quantity >= 50\n price_per_unit = 9\n else\n price_per_unit = 10\n end\n quantity * price_per_unit\n end", "def total_servingSize\n food.servingSize * quantity\n end", "def quantity\n @quantity ||= 1\n end", "def price_unit_factor\n return 1 if unit_id == price_unit_id\n return pack_size || 1 if price_unit_id == pack_unit_id\n return (pack_size || 1) * (subpack_size || 1) if price_unit_id == subpack_unit_id\n return 1\n end", "def display_quantity\n product.allow_fractional_quantity? ? quantity : quantity.to_i\n end", "def unit_price_x_quantity\n price = unit_price\n price = product.price if price.nil?\n \"$#{(price * quantity)} #{I18n.t('order_products.plus_tax')}\" # \"+ tax\"\n end", "def get_total_qty\n return self.items.sum(:qty)\n end", "def total_calcium\n food.calcium * quantity\n end", "def total_items\r\n\t\t@items.inject(0) { |sum, i| sum + i.quantity }\r\n\tend", "def total_calories\n food.calories * quantity\n end", "def quantity\n @quantity ||= sold_out ? 0 : rand(100)\n end", "def weight\n product_weight * quantity\n end", "def weight\n product_weight * quantity\n end", "def supp_quantity \n\n supp_quantity = 0.0\n \n self.receptions.each do |mr|\n supp_quantity += mr.quantity ? mr.quantity : 0.0 # en caso de que no se haya definido el quantity\n end\n\n return supp_quantity\n\n end", "def item_count\n\t\tquery(\"* marked:'quantityText'\", :text)[0]\n\tend", "def total_items\n order_items.inject(0) { |t,i| t + i.quantity }\n end", "def total_items\n order_items.inject(0) { |t, i| t + i.quantity }\n end", "def total_items\n order_items.inject(0) { |t, i| t + i.quantity }\n end", "def weight\n self.ingredients.map{|i| i.quantity}.reduce(:+)\n end", "def total_quantity\n category_quantity = 0 \n self.products.each do |product|\n category_quantity += product.quantity\n end\n category_quantity\n end", "def total_weight\r\n\t\t@items.inject(0.0) { |sum, i| sum + i.total_unit_weight * i.quantity }\r\n\tend", "def total_price\n self.unit_price * (self.quantity || 1)\n end", "def test_adds_up_in_quanttity\n\t\tcart = Cart.new\n\t\t3.times { cart.add_item 1 }\n\n\t\tassert_equal cart.items.length, 1 #solo un item\n\t\tassert_equal cart.items.first.quantity, 3 #varias unidades del mismo item\n\tend", "def deposit_quantity\n money.to_d.divmod(market.settle_price(currency)).first\n end", "def total_quantity\n cached_qty_bank.to_f + cached_qty_consigned.to_f\n end", "def total_iron\n food.iron * quantity\n end", "def quantity_and_measurement\n result = \"#{self.quantity_in_stock} #{self.unit_of_measurement}\"\n if self.quantity_in_stock > 1\n result += \"s\"\n end\n result\n end", "def total_saturated\n food.saturated * quantity\n end", "def total_quantity\n breastfeedings.sum(:quantity)\n end", "def quantity_of(product_or_supply_item)\n quantity = 0\n lines.each do |l|\n if l.product.componentized?\n l.product.product_sets.each do |ps|\n quantity = ps.quantity if ps.component == product_or_supply_item\n end\n else\n quantity = l.quantity if l.product == product_or_supply_item\n end\n end\n\n return quantity\n end", "def subamount unit_price , quantity\n unit_price.to_f * quantity.to_i\n end", "def quantity_based_on_stock\n if self.quantity > self.item.stock\n errors.add(:quantity, \"should not exceed what's available in stock\")\n end\n end", "def total\n price * quantity\n\n end", "def total_weight\n\t\tif catogery_id == 1\n\t\t\tfomular_1 * amount_qty\n\t\telsif category_id == 2\n\t\t\tfomular_2 * amount_qty\n\t\telsif category_id == 3\n\t\t\tfomular_3 * amount_qty\n\t\telse\n\t\t\t0\n\t\tend\n\tend", "def inventory_quantity\n return @cItemPossess.text.to_i\n end", "def amount\n quantity * price\n end", "def test_should_show_different_quantity_if_have_variations\n # Test a product without variations.\n a_grenade = items(:holy_grenade)\n assert_equal a_grenade.variations.count, 0\n assert_equal a_grenade.quantity, a_grenade.attributes['quantity']\n # Test a product with variations.\n a_lightsaber = items(:lightsaber)\n assert_equal a_lightsaber.variations.count, 3\n assert_equal a_lightsaber.quantity, a_lightsaber.variations.sum(:quantity)\n end", "def total_items\n line_items.sum(:quantity)\n end", "def total_items\n line_items.sum(:quantity)\n end", "def quantity_sold\n purchases.inject(0) { |sum, purchase| sum + purchase.quantity }\n # purchases.sum(:quantity)\n end", "def number_of_calories\n self.ingredients.sum(\"calories\")\n end", "def price(quantity)\n\tif quantity >= 100 \n\t\tprice_per_item = 8\n\t\n\telsif quantity >= 50\n\t\tprice_per_item = 9\n\t\n\telse quantity < 50\n\t\tprice_per_item = 10\n\tend\n\tquantity * price_per_item\nend", "def quantity\n @options['quantity'] || 1\n end", "def quantity_with_recursion(depth=0)\n depth += 1\n raise \"Item.quantity_with_recursion: Cap of 5 reached.\" if depth > 5\n if self.parent\n return self.quantity_with_stock + self.parent.packaging_unit * self.parent.quantity_with_recursion(depth)\n else\n return self.quantity_with_stock\n end\n end", "def infer_amount!\n self.amount = nil\n\n if quantity.present? && quantity.downcase.include?('grams')\n self.amount = quantity.gsub('grams', '').to_i\n return\n end\n\n full_description = \"#{quantity.try(:singularize)} #{description.try(:singularize)}\".downcase\n\n CONTAINER_SIZE_MAPPING.each do |container, grams|\n if full_description.match(container)\n # Call ''.to_r on each segment, utilising the fact that 'and'.to_r.to_f => 0.0\n proportion = full_description.split(' ').map(&:to_r).sum\n\n if proportion\n self.amount = proportion * grams\n # puts \"Translated #{full_description} => #{proportion.to_f} * #{container} => #{amount.to_f}g\"\n break\n end\n\n end\n end\n\n if self.amount == nil\n Rails.logger.warn \"Couldn't infer amount from [#{full_description}]\"\n end\n end", "def quantity=(q)\n delta = quantity - q\n self.quantity_consumed += delta\n save\n end", "def quantity_with_stock\n item_stocks = self.item_stocks.visible\n if item_stocks.any?\n return item_stocks.sum(:quantity)\n else\n return read_attribute :quantity\n end\n end", "def quantity_of(item_id)\n if @item_quantity_map.blank?\n @item_quantity_map = {}\n self.trade_items.each do |ob_item|\n @item_quantity_map[ob_item.item_id] = ob_item.quantity\n end\n end\n @item_quantity_map[item_id] || 0\n end", "def total\n self.amount * self.quantity\n end", "def item_quantity(item_id)\n details.select {|v| v.item_id === item_id}.inject(0) {|s, v| s += v.quantity }\n end", "def total_tax\n unit_tax * quantity\n end", "def total_num_items\n line_items.reduce(0) { |sum, item| sum + item.quantity }\n end", "def sub_total\n # quantity * unit_price\n unit_price\n end", "def total_volume(with_unit)\n if with_unit\n (quantity * volume.to_d).to_s + unit\n else\n quantity * volume.to_d\n end\n end", "def total\n self.quantity * self.amount\n end", "def product_count\n self.items.inject(0) {|sum, item| sum + item.quantity}\n end", "def number_of_kcal_per_meal\n kcal_per_recipe = recipe_ingredients.each.sum do |recipe_ingredient|\n calories_per_gram = recipe_ingredient.ingredient.calories / 100 \n kilograms_of_ingredient = recipe_ingredient.calculated_weight_in_grams / 1000\n (calories_per_gram * kilograms_of_ingredient) #kcal\n end\n kcal_per_recipe / num_people\n end", "def total_carbohydrates\n food.carbohydrates * quantity\n end", "def calculate_quantity(quantity)\r\n if (quantity.nil? or quantity == 0) then\r\n quantity = -1\r\n else\r\n quantity -= 1\r\n end\r\n end", "def total_items\n\t\tline_items.sum(:quantity)\n\tend", "def quantity_of(purchase)\n item = find_item(purchase)\n if item.nil?\n 0\n else\n item.quantity\n end\n end", "def item_count\n order_items.map(&:quantity).sum\n end", "def total_cost\n # quantity * unit_cost_price\n unit_cost_price\n end", "def total\n conv_price_single * conv_quantity\n end", "def add_quantity(number)\n @quantity += number\n end", "def count_items\n order.items.sum(:quantity)\n end", "def preco_total\n produto.preco * quantidade\n end" ]
[ "0.7335919", "0.73286116", "0.7263488", "0.72568536", "0.7207919", "0.7204568", "0.7200629", "0.7200623", "0.71804833", "0.716172", "0.712698", "0.7123181", "0.7068726", "0.7064936", "0.7064936", "0.7049627", "0.7028739", "0.6983993", "0.69572914", "0.69571143", "0.69462746", "0.6942308", "0.69315964", "0.69290996", "0.69252723", "0.6911065", "0.6892179", "0.68782324", "0.6872792", "0.6858967", "0.68372834", "0.6803705", "0.6803705", "0.6803141", "0.67688406", "0.6754323", "0.67510897", "0.6739458", "0.67299753", "0.6695225", "0.6691589", "0.66886884", "0.6653225", "0.66401637", "0.66351146", "0.6614015", "0.6614015", "0.6609705", "0.6601914", "0.6600098", "0.6590335", "0.6590335", "0.6587711", "0.6584231", "0.6580822", "0.6580492", "0.65791124", "0.6567731", "0.6562838", "0.6549346", "0.6544399", "0.65317595", "0.6522158", "0.6491995", "0.6480275", "0.6464878", "0.6463784", "0.6450086", "0.64430344", "0.642766", "0.642296", "0.64166933", "0.64166933", "0.6415216", "0.64069086", "0.64064497", "0.64058024", "0.63883626", "0.6364738", "0.6343168", "0.6342931", "0.63392377", "0.6334762", "0.6333036", "0.6329526", "0.632952", "0.6323118", "0.6320089", "0.63157433", "0.63019353", "0.6300021", "0.6295428", "0.6294167", "0.62911236", "0.62851524", "0.62847227", "0.6265877", "0.6254437", "0.6248403", "0.6247741", "0.6240146" ]
0.0
-1
i^n mod p, where p is prime and i is a primitive root of p With this formula, generate a series through progressive squaring, from zero to (p1). Collect the residue, mod p and perform an xswap with each object's index number. The result will be the corresponding MOF series.
def mof(i, p) arr = [] x_swap = [] (0..(p-2)).each do |x| arr.push((i**x) % p) end (1..(p-1)).each do |n| x_swap.push((arr.index {|item| n == item }) % 12 ) end return x_swap end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mod_mult (p, n)\n q = p\n r = Point.new Float::INFINITY, Float::INFINITY\n\n while n > 0\n if n % 2 == 1\n r = self.mod_add r, q\n end\n\n q = self.mod_add q, q\n n = (n / 2).floor\n end\n r\n end", "def squared_primes(array)\n\n a=[]\n array.each do |x| \n for i in (2..x-1)\n a << x if x % i == 0 \n end\n end\n array -= a\n array.map{ |p| p*p } \n\nend", "def factorize_modp\n me = self\n g = sqfree\n fs = Factors.new\n g.factors_of_sqfree.each do |f|\n\ti, r = 0, 0\n\twhile me.deg > 0\n\t q, r = me.divmod f\n\t if r.zero?\n\t me = q\n\t i += 1\n\t else\n\t break\n\t end\n\tend\n\tfs.push [f, i]\n end\n\n # for 'over Zp'\n if ch = ground.char\n\tif me.deg > 0\n\t me.verschiebung.factorize_modp.each do |f_i|\n\t f0, i0 = f_i\n\t fs.push [f0, i0*ch]\n\t end\n\tend\n end\n fs\n end", "def sieve(n) # quickly makes array of all primes from 2 to n\n s = 3.step(n, 2).to_a # make array of odd integers from 3 to n. Skip evens. \n s.each do |p|\n next if p.nil? # go to next element if p has been marked empty\n break if p * p > n # p only needs to go up to sqrt(n)\n\n k, pval = 0, 0\n\n while pval < n\n pval = p * (p + k) # jump forward 2p at a time: p*p, p*p + 2p, p*p + 4p, etc.\n\n # Set all those multiples to nil. i = (pval - 3)/2 translates pvals to index i\n\n s[(pval - 3) / 2] = nil \n k += 2 \n end\n\n end\n s.compact! # removes all nil elements from array\n s.unshift(2).sort # adds 2 as 1st element\nend", "def modulo(p0) end", "def mod_sqrt(n, p, exp = 1, return_list = false)\r\n\t\tif 1 < exp or return_list\r\n\t\t\tx = mod_sqrt(n, p)\r\n\t\t\treturn x unless x\r\n\t\t\treturn [x] if 1 == exp\r\n\t\t\traise ArgumentError, \"if 1 < exp then n must be relatively prime with p\" if 0 == x\r\n\r\n\t\t\trslt = [x] if return_list\r\n\t\t\tp_power = p\r\n\t\t\tz = extended_lehmer_gcd(x << 1, p)[0]\r\n\t\t\t(exp - 1).times do\r\n\t\t\t\tx += (n - x ** 2) / p_power * z % p * p_power\r\n\t\t\t\tp_power *= p\r\n\t\t\t\trslt.push(x) if return_list\r\n\t\t\tend\r\n\r\n\t\t\treturn return_list ? rslt : x\r\n\t\tend\r\n\r\n\t\tunless (k = kronecker_symbol(n, p)) == 1\r\n\t\t\treturn nil if -1 == k\r\n\t\t\treturn 0\r\n\t\tend\r\n\r\n\t\tif 0 < p & 6\r\n\t\t\treturn power(n, (p >> 2) + 1, p) if p[1] == 1\r\n\t\t\tn %= p\r\n\t\t\tx = power(n, (p >> 3) + 1, p)\r\n\t\t\treturn x if x ** 2 % p == n\r\n\t\t\treturn x * power(2, p >> 2, p) % p\r\n\t\tend\r\n\r\n\t\t# get q and e s.t. p - 1 == 2**e * q with q odd\r\n\t\te = 0\r\n\t\tq = p - 1\r\n\t\te += 1 while 0 == q[e]\r\n\t\tq >>= e\r\n\r\n\t\t# Find generator\r\n\t\tg = 2\r\n\t\tg += 1 until -1 == kronecker_symbol(g, p)\r\n\t\tz = power(g, q, p)\t# |<z>| == 2 ** e\r\n\r\n\t\t# Initialize\r\n\t\ttemp = power(n, q >> 1, p)\r\n\t\tx = n * temp % p\t# n ** ((q + 1) / 2) mod p\r\n\t\tb = x * temp % p\t# n ** q mod p\r\n\r\n\t\t# always\r\n\t\t# n * b == x ** 2\r\n\t\tuntil 1 == b\r\n\t\t\t# Find exponent f s.t. b ** (2 ** f) == 1 (mod p)\r\n\t\t\tf = 0\r\n\t\t\tb_ = b\r\n\t\t\tuntil 1 == b_\r\n\t\t\t\tb_ = b_ ** 2 % p\r\n\t\t\t\tf += 1\r\n\t\t\tend\r\n\r\n\t\t\t# Reduce exponent\r\n\t\t\t(e - f - 1).times { z = z ** 2 % p }\r\n\t\t\te = f\r\n\t\t\tx = x * z % p\r\n\t\t\tz = z ** 2 % p\r\n\t\t\tb = b * z % p\r\n\t\tend\r\n\r\n\t\treturn x\r\n\tend", "def p(n)\r\n (return @ps[n]) if @ps[n]\r\n\r\n sum = 0\r\n @pk.each_with_index do |k, i|\r\n if k > n\r\n break\r\n end\r\n sign = ( i % 4 <= 1 ? 1 : -1)\r\n sum += sign * p( n - k )\r\n sum %= 1_000_000 #keep it under control\r\n end\r\n @ps[n] = sum\r\n return sum\r\n end", "def swapper_map(index)\n array = (0..9).to_a\n 10.times.collect.with_index do |i|\n array.rotate!(index + i ^ spin).pop\n end\n end", "def swapper_map(index)\n array = (0..9).to_a\n 10.times.collect.with_index do |i|\n array.rotate!(index + i ^ spin).pop\n end\n end", "def sieve\n @ws.fill(0)\n @ps.zip(@log_ps, @roots) do |p, lp, (s1, s2)|\n ((@m + s1) % p).step(2 * @m, p) {|i| @ws[i] += lp }\n ((@m + s2) % p).step(2 * @m, p) {|j| @ws[j] += lp }\n end\n end", "def permutationEquation(p)\n n = p.size\n (1..n).map do |x|\n res = 0\n p.each do |y|\n res = y if p[p[y - 1] - 1] == x\n end\n res\n end\nend", "def sptriplet(n)\n divisors_of_500 = []\n1.upto(500) {|n| divisors_of_500 << n if 500 % n == 0}\ndivisors_of_500.inspect\n\n solutions = []\n for x in divisors_of_500\n for z in divisors_of_500\n if (x < z && z < 2*x) && n%(x*z) == 0\n y = z - x\n k = ((n/2) / x) / z\n\n a = k*(x*x-y*y)\n b = 2*k*x*y\n c = k*(x*x+y*y)\n\n solutions << [a,b,c]\n end\n end\n end\n\n product = 1\n solutions.map! {|arr| arr.sort}\n solutions.uniq!\n solutions[0].each {|num|product *= num}\n product\n\nend", "def problem_78\n n = 1\n p_cache = [1]\n\n generate = lambda do |k|\n ret = 0\n sign = 0\n Integer.generalized_pentagonals do |gp|\n if k < gp\n false # Need to exit ruby1.8, can't break...\n else\n if sign >= 0\n ret += p_cache[k-gp]\n else\n ret -= p_cache[k-gp]\n end\n sign += (sign == 1) ? -3 : 1 # 4 states + + - -\n end\n end\n p_cache[k] = ret % 100_000_000\n ret\n end\n\n p = 1\n loop do\n r = generate.call(p)\n# puts \"#{p} #{generate.call(p)}\"\n break if r % 1_000_000 == 0\n p += 1\n end\n p\nend", "def modpow(a, b, n, m)\n if n == 0\n [1, 0]\n elsif n % 2 == 0\n modpow((a * a) % m, (a * b + b) % m, n / 2, m)\n else\n c, d = modpow(a, b, n - 1, m)\n [(a * c) % m, (a * d + b) % m]\n end\nend", "def clumsy(n)\n a = (1..n).to_a.reverse\n \n result = [a[0]]\n \n a[1..a.size - 1].each_with_index do |num, index|\n if index % 4 == 0\n result << '*'\n elsif index % 4 == 1 \n result << '/'\n elsif index % 4 == 2\n result << '+'\n else\n result << '-'\n end\n \n result << num\n end\n \n result = multiply_and_divide_all_results(result)\n \n add_and_subtract_all_results(result)\nend", "def pow(n,p)\n ans = 1\n while p!=0 do\n ans = ans*n%BASE if p&1==1\n n=n*n%BASE\n p=p>>1\n end\n ans\n end", "def candidates(p)\n 1.upto(p-1) do |x|\n yield x if (x*x % p) == (x+1)\n end\nend", "def divmod(p0) end", "def divisors(n)\n arr = Prime.prime_division(n).map { |v,exp| (0..exp).map { |i| v**i } }\n arr.first.product(*arr[1..-1]).map { |a| a.reduce(:*) }.map { |m| [m,n/m] }\nend", "def quadratic_residues(modulus)\n (1..(modulus - 1)).map { |n| n**2 % modulus }.uniq.sort\n end", "def prmutation(num)\n factrl(num)\nend", "def removNb(n)\n results = []\n (2..n).each do |a|\n b = (n*(n+1)/2.0-a)/(a + 1)\n results << [a, b.to_i] if b % 1 == 0 && b < n && b > 2\n end\n results\nend", "def r(p,n,a,s)\n j = p[a-1] - s - 1\n v = 0\n i = 0\n for i in 0..(j-1) do\n v += b(i) * b(n-i-1)\n end\n v +\n (j <= 1 ? 0 : b(n-j-1) * (r(p,j,a+1,s) - 1)) +\n (n-j-1 <= 1 ? 1 : r(p,n-j-1,a+j+1,s+j+1))\n end", "def res(n)\r\n p ~(4 >> 1)\r\nend", "def potenz(x, n)\n check_pre((n.nat?))\n if (n == 1) then\n x\n elsif (n == 0) then\n 1\n else \n x*=potenz((x), n-1)\n end\n end", "def ri(p,i,n,a,s)\n j = 0\n v = nil\n h = nil\n k = nil\n while i > 0\n k = n-j-1\n h = b(k)\n v = b(j) * h\n i -= v\n j += 1\n end\n i += v\n j -= 1\n p[a-1] = j + 1 + s\n y = (i-1-((i-1)/h)*h) + 1\n w = (i-y) / h + 1\n\n if j > 1\n ri(p,w,j,a+1,s) \n elsif j == 1\n p[a] = s+1\n end\n\n if k > 1\n ri(p,y,k,a+j+1,s+j+1)\n elsif k==1\n p[a+j] = s+j+2\n end\n end", "def saveThePrisoner(n, m, s)\n res = ((m - 1) + s) % n\n res == 0 ? n : res \nend", "def saveThePrisoner(n, m, s)\n mod = (m % n == 0) ? n : (m % n)\n return ((mod + s -1) % n == 0) ? n : (mod + s -1) % n\n\nend", "def pmt(i, n, pv)\n return pv / ((1 - (1 / (1 + i) ** n )) / i)\n end", "def solution_slow_2(n, p, q)\n sieve = sieve_of_erathosteneses(n)\n # puts \"sieve:#{sieve}\"\n semi = semiprimes(n, sieve)\n # puts \"sp:#{semi}\"\n prefix = [0,0,0,0,1]\n 5.upto(n) do |x|\n if semi.include? x \n prefix << prefix.last + 1\n else\n prefix << prefix.last\n end\n end\n # puts \"prefix:#{prefix}\"\n\n queries = [p,q].transpose\n\n\n res = queries.map do |query|\n prefix[query.last] - prefix[query.first - 1]\n end\n\n # puts \"res:#{res}\"\n\n res\n end", "def replace_probs(mps, probs)\n mps.each_with_index do |mp,i|\n mp[1].each_with_index do |e,j|\n e[1] = probs[i+j]\n end\n end\n mps#[mps]\n end", "def theoretical_pI\n charges = []\n residue_count().each do |residue|\n charges << charge_proc(residue[:positive],\n residue[:pK],\n residue[:num])\n end\n round(solve_pI(charges), 2)\n end", "def prime_numbers\n s = (0..self).to_a\n s[0] = s[1] = nil\n s.each do |p|\n next unless p\n break if p * p > self\n (p*p).step(self, p) { |m| s[m] = nil }\n end\n s.compact\n end", "def problem3 n\n 2.step(n,1).each do |x|\n return x-1 if n == 1\n n /= x if x.prime? && (n % x == 0)\n end\nend", "def modX(poly, mod)\n coefs = poly.coefs.dup\n coefs = coefs.map! {|x| x % mod}\n Polynomial[coefs]\n end", "def p_triangle(n)\n (0..n).each{|i|\n list = [1]\n element = 1\n k = 1\n (0..i-1).step(1){|index|\n element = element * (i-k+1)/k\n list.push element \n k += 1\n }\n yield(list)\n }\nend", "def primeSieve(n)\n s = (0..n).to_a\n s[0] = s[1] = nil\n s.each do |p|\n next unless p\n break if p * p > n\n (p*p).step(n, p) { |m| s[m] = nil }\n end\n s.compact\n end", "def modpow(a, x, mod)\n return 1 if x == 0\n return a if x == 1\n half = modpow(a, x/2, mod)\n val = half*half\n val *= a if x.odd?\n val % mod\nend", "def ^(n)\n base = n>0 ? self : !self\n res = Permutation::IDENTITY\n (n.abs).times {res*=base}\n res\n end", "def merge_primes(pd)\n if pd[0] && pd[0][0] == 2 \n if pd[0][1] > 1\n pd << [4, (pd[0][1] / 2).to_i] # for some bizarre reason i have to call to_i here to avoid a fraction\n pd[0][1] = pd[0][1] % 2\n end\n if pd[1] && pd[1][0] == 3 && pd[0][1] == 1\n pd << [6, 1]\n pd[1][1] -= 1\n pd[0][1] -= 1\n end\n end\n pd.reject{|e| e[1] == 0}\nend", "def rankinverse(p,i,n)\n ri(p,i,n,1,0)\n return p\n end", "def recurringCycleLengthOfPrime(n)\n return 0 if n == 2 || n == 5\n\n # Solve multiplicative order of 10 (mod n)\n i = 1\n until (10 ** i - 1) % n == 0\n i = i.next\n end\n\n i\nend", "def sieve(n)\r\n # Create two arrays (l and empty store)\r\n l = Array.new(n, 1)\r\n store = Array.new\r\n for i in 2 .. n\r\n next unless l[i]\r\n # num.step(limit, step ) {|i| block } => num\r\n # Start at num to limit of step:\r\n # E.g. 4.step(100, 2) = 4, 6, 8\r\n (i**2).step(n, i) {|x| \r\n l[x] = nil \r\n }\r\n store << i \r\n end\r\n store\r\nend", "def squared_primes(array)\n array.find_all{|x| (2..x-1).select(){|i| x % i == 0}.count == 0 && x > 1}.map{|p| p*p}\nend", "def rearrange_array(array)\n # size of an array\n n = array.size\n # iterate \n (0...n).each do |iter|\n array[iter] = array[iter]+(array[array[iter]]%n)*n\n end\n p array, n\n (0...n).each do |iter|\n p array[iter]\n array[iter] = (array[iter]/n)\n end\n array\nend", "def prime_decomposition(n)\n if n <= 1\n return []\n end\n $primes.each do |p|\n if n % p == 0\n return ( prime_decomposition(n/p) << p ).uniq\n end\n end\nend", "def factorize\n x = self\n o = []\n loop do\n break unless (c = (2..x).find { |i| x % i == 0 })\n x /= c\n o << c\n end\n o\n end", "def getSwifts epsPF, epsPN, sigF, sigN\n\t rtn = Array.new\n\t #first get eps_o using the solver\n\t eps_o = solve(epsPF, epsPN, sigF, sigN)\n\t rtn << eps_o\n\t #back solve for n\n\t n = eps_o + epsPN\n\t rtn << n\n\t #back solve for k\n\t k = sigF / ((eps_o + epsPF)**n)\n\t rtn << k\n\t rtn\n\tend", "def rpower(n) end", "def recessive k, m, n\n all = k + m + n\n mix = m + n\n total = 4.0 * triangle(all) # 2 * squareish all = 2 * 2 * triangle all\n\n lhs = triangle n\n mid = n * mix - n\n rhs = triangle mix\n\n 1 - (lhs+mid+rhs) / total\n end", "def primitive_root(p)\r\n\t\tp_m1 = p - 1\r\n\t\tcheck_order = factorize(p_m1)\r\n\t\tcheck_order.shift\r\n\t\thalf_p_m1 = p_m1 >> 1\r\n\t\tcheck_order.map!{|f| half_p_m1 / f.first}\r\n\r\n\t\ta = 1\r\n\t\tloop do\r\n\t\t\ta += 1\r\n\r\n\t\t\tnext unless -1 == kronecker_symbol(a, p)\r\n\t\t\tcheck = true\r\n\t\t\tcheck_order.each do |e|\r\n\t\t\t\tif p_m1 == power(a, e, p)\r\n\t\t\t\t\tcheck = false\r\n\t\t\t\t\tbreak\r\n\t\t\t\tend\r\n\t\t\tend\r\n\r\n\t\t\treturn a if check\r\n\t\tend\r\n\tend", "def squares (x, n)\n starting_number = x\n repeate = n\n array = []\n\n\n if n == 0 || n == nil\n return array\n end\n\n array.push(starting_number)\n\n\n i = 1\n until i == repeate\n root_index = starting_number * starting_number\n starting_number = root_index\n array.push(starting_number)\n i += 1\n end\n\n\n return array\nend", "def inv_mod x,n\n d,r,s = gcd2 x,n\n if d==1\n r % n\n else\n 0\n end\nend", "def sundaram\n limit = @limit/2 - 2\n j_limit = (limit-1)/3\n\n # only odd are needed.\n ary = (2..@limit/2).map{|t| 2*t - 1}\n\n (1..j_limit).each do |j|\n (1..j).each do |i|\n num = i + j + 2*i*j - 1\n break if num > limit\n ary[num] = nil\n end\n end\n ary.compact.unshift 2\n end", "def solve_roots\n @roots = []\n @ps.zip(@sqrts) do |p, s|\n a_inv = Utils.mod_inv(2 * @a, p)\n x1 = (-@b + s) * a_inv % p\n x2 = (-@b - s) * a_inv % p\n @roots << [x1, x2]\n end\n end", "def solve( n = 100_000_000 )\n # Observe that:\n # 1. n must be 1 or even\n # 2. n + 1 must be prime\n # 3. n/2 + 2 must be prime\n # 4. (n - 2) % 4 = 0 for n > 1, so (n + 1) % 4 = 3 for n > 1\n p = {}\n n.prime_sieve.each {|i| p[i] = 1}\n\n # From observation 2, we can work backward to compute candidate values of\n # n from known primes.\n primes = p.keys.select do |i|\n # Skip primes that don't satisfy observation 4. \n next if 3 != i % 4\n\n # Test every divisor up to the square root of each candidate.\n cand, d = i - 1, 1 \n begin\n d += 1\n q, r = cand / d, cand % d\n\n match = p.has_key?( d+q ) if 0 == r\n end while match && d < q\n\n match\n end\n\n # Add one since it isn't included in the primes array. Adjust down to\n # account for each n = p-1.\n 1 + primes.reduce( :+ ) - primes.length\n end", "def prime_factorization(min_div)\r\n\tlist = []\r\n\tmin_div.prime_division.each{|arr| arr[1].times {list << arr[0]}}\r\n\tpowers = list.reverse.map{|i| i - 1}\r\n\tlist = Prime.take(list.size)\r\n\tlist.map.with_index{|_, idx| list[idx] ** powers[idx]}.inject(:*)\r\nend", "def prime_factorisation(n)\n Prime.prime_division(n).flat_map { |factor, power| [factor] * power }\n end", "def solve2( n = 150_000_000 )\n # Brute force.\n sum = 10\n i = 20\n\n while i < n\n if 0 != i % 3\n i2 = i*i\n\n # Must verify that the primes are consecutive (i.e. there aren't any\n # primes hiding between entries).\n if (i2 + 1).miller_rabin? &&\n (i2 + 3).miller_rabin? &&\n (i2 + 7).miller_rabin? &&\n (i2 + 9).miller_rabin? &&\n !(i2 + 11).miller_rabin? &&\n (i2 + 13).miller_rabin? &&\n !(i2 + 17).miller_rabin? &&\n !(i2 + 19).miller_rabin? &&\n !(i2 + 21).miller_rabin? &&\n !(i2 + 23).miller_rabin? &&\n (i2 + 27).miller_rabin?\n \n sum += i\n i += 315410\n end\n end\n\n # From observation that 10 | a_n in similar sequences.\n i += 10\n end\n\n sum\n end", "def sieve_upto(n)\n s = (0..n).to_a\n s[0] = s[1] = nil\n s.each do |p|\n next unless p\n break if p * p > n\n (p*p).step(n, p) { |m| s[m] = nil }\n end\n s.compact\nend", "def sieve(x)\n s = (0..x.to_i).to_a\n\n s[0] = s[1] = nil\n\n s.each{ |p| # Perform the block for each entry in the array.\n next unless p # Iterate on next array value if entry is nil\n break if p * p > x # Cease iteration if p*p > max_value\n (p*p).step(x, p) { |m| s[m] = nil } # Starting at p*p, set every p-th value to \"nil\" until max_value\n }\n s = s.compact\nend", "def sieve(x)\n s = (0..x.to_i).to_a\n\n s[0] = s[1] = nil\n\n s.each{ |p| # Perform the block for each entry in the array.\n next unless p # Iterate on next array value if entry is nil\n break if p * p > x # Cease iteration if p*p > max_value\n (p*p).step(x, p) { |m| s[m] = nil } # Starting at p*p, set every p-th value to \"nil\" until max_value\n }\n s = s.compact\nend", "def sieve(x)\n s = (0..x.to_i).to_a\n\n s[0] = s[1] = nil\n\n s.each{ |p| # Perform the block for each entry in the array.\n next unless p # Iterate on next array value if entry is nil\n break if p * p > x # Cease iteration if p*p > max_value\n (p*p).step(x, p) { |m| s[m] = nil } # Starting at p*p, set every p-th value to \"nil\" until max_value\n }\n s = s.compact\nend", "def isPP(n)\n i, j = 2, 2\n while i**j <= n do\n while i**j <= n do\n return [i, j] if i**j == n\n j+=1\n end\n i+=1\n j=2\n end\n nil\nend", "def print_cut_rod_solution(p,n)\n\nend", "def Si2(i)\n raise unless 1 <= i\n raise unless i <= n\n # @reps is indexed from the left to right\n index = n - i\n factor = 1.0\n\n # We compute this iteratively leveraging the fact that\n # 1 / (a * b) = (1 / a) / b\n for rep in @reps[0, index]\n factor /= rep\n end\n # Then at this point we have:\n # factor * (1 / (r_i - 1)) = factor / (r_i - 1)\n factor /= @reps[index] - 1\n\n # Second line of the above definition, the lines are multiplied.\n indicies = index_iterator(0, index+1)\n sum = 0.0\n for index in indicies\n a = mean(index)\n b = mean(index[0,index.size-1])\n sum += (a - b) ** 2\n end\n factor * sum\n end", "def squared_primes(array)\n array.find_all{|x| (2..x-1).select(){|i| x % i == 0}.count == 0 && x > 1}.map{|p| p*p}\n\n\n # primes = []\n # array.each do |x|\n # 2.upto(x-1) do |i|\n # if x % i == 0 && x > 2\n # primes << x*x\n # end\n # end\n # end\n # primes\n\n # primes= []\n # array.find_all do |x|\n # if x == 2\n # primes << 2*2\n # end\n\n # if x > 2 && (x % 2 != 0)\n # #(2..x-1).select()\n # # if x % 2 != 0 && x > 1\n # #{|i| x % i == 0}\n # #x.count == 0 && x > 1\n # primes << x * x\n # #end\n # end\n # end\n # # new_array.map{|p| p*p}\n # primes\nend", "def shift n\n Polynomial.new @coeffs.unshift(*([0]*n))\n end", "def p7\n\tprimes = [2]\n\t(1...10001).each do\n\t\tprime = next_prime(primes[-1])\n\t\tprimes << prime\n\tend\n\tprimes[-1]\nend", "def pentagon_sequence(nth)\n sequence = []\n (1..nth).each do |n|\n sequence.push( n * (3 * n - 1) / 2 )\n end\n return sequence\nend", "def index_multiplier_method\n #@multiplied_integer_array = []\n @reversed_array.each_with_index do |value, index|\n if index.odd? == true\n value = value * 2\n @multiplied_integer_array << value\n else\n value = value\n @multiplied_integer_array << value\n end\n end\n return @multiplied_integer_array\n end", "def pythagoreans (n)\n return (1..n).to_a.permutation(3).to_a.select { |a,b,c| a**2 + b**2 == c**2 }.each(&:sort!).uniq\nend", "def squared_primes(array)\n metodo1(array).map{|p| p*p}\nend", "def circular_primes_of (n)\n res = [n]\n tmp = origin = n.to_s\n (origin.length-1).times do |i|\n tmp.concat(tmp[0]); tmp[0] = ''\n if prime? tmp.to_i then res << tmp.to_i else return nil end\n end\n res\nend", "def solve( n = 100 )\n n.partition_sieve[-1] - 1\n end", "def twin_prdx(mass)\n top=1\n for i in 366..366-mass\n top *= i\n end\n return top/ui_pow(366, mass)\nend", "def solution(n)\n lowest_p = nil\n a = 1\n\n while a * a <= n\n if n % a == 0\n b = n / a\n current_p = 2 * (a + b)\n\n if !lowest_p || current_p < lowest_p\n lowest_p = current_p\n end\n end\n\n a += 1\n end\n\n lowest_p\nend", "def make_picky_generator(start, factor, multiples_of)\n Enumerator.new do |y|\n start = start\n loop do\n result = (start * factor) % 2_147_483_647\n y << result if (result % multiples_of).zero?\n start = result\n end\n end\nend", "def modpow(a, n, m)\n r = 1\n while true\n r = r * a % m if n[0] == 1\n n >>= 1\n return r if n == 0\n a = a * a % m\n end\n end", "def perfect_power(n)\n\nend", "def permutations(n, r)\n result = factorial(n) / factorial(n - r)\n puts \"\\nP(#{n},#{r}) = #{result}\"\n end", "def sieve_of_e(n)\n a = (0...n).to_a\n a[0] = nil\n a[1] = nil\n (2..Math.sqrt(n)).each do |i|\n if a[i]\n it = 0\n j = i * i\n while j <= n\n a[j] = nil\n it += 1\n j = i * i + i * it\n end\n end\n end\n a.select{|i| i}\nend", "def prime_products(n)\n i = 2\n product = 1\n while i < n\n product *= i if i.prime?\n i += 1\n end\n product\nend", "def josephus_survivor(n,k)\n result = 1\n for i in 1...n + 1\n result = (result + k - 1) % i + 1\n end\n \n result\nend", "def cp2\n\trot1= []\n\trot2 = []\n\tpermPrime = true\n\ttotal = 0;\n\t1.upto(1000000) do |x|\n\t\t#if (x % 1000 == 0) then p x end\n\t\tif(isPrime(x) == false) then next end\n\t\trot1 = splitNumber(x)\n\t\trot1.rotate!\n\t\tprintf \"\\nChecking %d, rot1 = %s\", x, rot1\n\t\trot2 = rot1.rotate(-2).dup\n\t\t#numRot = numRot.map {|y| y.join.to_i}\n\t\tprintf \" - rot2 = %s\", rot2\n\t\tpermPrime = true\n\t\t#numRot.each do |perm|\n\t\t\t#printf \"checking %s \\n\", perm\n\t\tif(isPrime(rot1.join.to_i) == false) then permPrime = false; next end\n\t\tif(isPrime(rot2.join.to_i) == false) then permPrime = false; next end\n\t\t#end\n\t\t#p permPrime\n\t\ttotal = total + 1\n\t\tprintf \" -- x = %d\\n\", x\n\tend\n\ttotal\nend", "def isPP(n)\n\t (2..n).each do |i|\n\t \t(2..n).each do |j|\n\t \t\treturn [i,j] if i**j==n\n\t \t\tbreak if i**j > n\n\t \tend\n\t \treturn nil if i**2 > n\n\t end\nend", "def self_powers_2\n (1..1000).map {|i| i**i}.reduce(:+) % (10**10)\nend", "def pythagoreans (n)\r\n pythagoreans = Array.new\r\n for i in 1..n\r\n for h in 1..i\r\n sum = Math.sqrt(i**2+h**2)\r\n if sum%1 == 0 && sum <= n\r\n temp = [i,h,sum.round]\r\n temp.sort!\r\n pythagoreans.push(temp)\r\n end\r\n end\r\n end\r\n pythagoreans.sort!\r\n return pythagoreans\r\nend", "def removNb(n)\n res = []\n total = (n*n + n) / 2\n range = (1..n)\n \n (1..n).each do |a|\n b = ((total - a) / (a * 1.0 + 1.0))\n if b == b.to_i && b <= n\n res.push([a,b.to_i])\n end\n end\n\n return res\nend", "def dig_pow(n, p)\n sum = n.digits.reverse.map.with_index { |digit, i| digit ** (p + i) }.sum\n sum % n == 0 ? sum / n : -1\nend", "def prime_factorization(n)\n new_arr = []\n (2...n).each do |i|\n if n % i == 0\n dividend = n / i\n return [*prime_factorization(i), *prime_factorization(dividend)]\n end\n end\n new_arr << n\nend", "def pow base, p\n base ** p\n end", "def prim value\n for i in 2..(value - 1)\n if value % i == 0 \n return 0\n end\n end\n \n return 1\nend", "def permute_segment_up_to n\n segment = (0..n).to_a # segment is an array of numbers in the range 0 to n\n index = 0\n permuted_segment = [] # here we will store our permutation of the numbers in segment\n while segment != []\n random_index = rand(0..segment.length - 1)\n permuted_segment[index] = segment[random_index]\n segment.delete_at(random_index) # TODO: method hunting! this should be unfolded in a loop\n index += 1\n end\n return permuted_segment\nend", "def nth_powers(n)\n (1..9).to_a.map {|num| num**n}\nend", "def prime_series\n t = self\n limit = Math.sqrt(t)\n a = (2..t).to_a\n n = 2\n while (n < limit) do\n x = n*2\n begin\n a[x-2]=2\n x+=n\n end until (x > t )\n begin\n n+=1\n end until ( a[n-2] != 2 )\n end\n a.uniq!\n end", "def dig_pow(n, p)\n power_arr = []\n\n digit_arr = n.to_s.chars.map(&:to_i)\n\n digit_arr.each do |digit|\n power_arr << (digit ** p)\n p += 1\n end\n\n\n if power_arr.sum % n == 0\n k = power_arr.sum / n\n else\n -1\n end\nend", "def circular_primes(n)\n circular_primes = Set.new\n Prime.each(n) do |prime|\n circular = true\n rotations = prime.to_s.length - 1\n digits = prime.to_s.chars.map(&:to_i)\n rotations.times do # For an n-digit number, there are n-1 rotations.\n digits << digits.shift # 'Rotate' the digits. Ex: 197 -> 971\n circular = false unless digits.reduce { |ac, i| ac*10 + i }.prime?\n end\n circular_primes << prime if circular\n end\n return circular_primes\nend", "def primordial; end", "def solution(n, p, q)\n primes = []\n sieve(n).each_with_index { |v, i| \n primes << i if v\n }\n #puts primes\n \n semiprimes = [false] * (n + 1)\n primes.each { |x|\n primes.each { |y|\n sp = x * y\n break if sp > n\n semiprimes[sp] = true\n }\n }\n #puts semiprimes.inspect\n \n counts = [0]\n (1..n).each { |i|\n counts[i] = counts[i - 1]\n counts[i] += 1 if semiprimes[i]\n }\n #puts counts.inspect\n \n result = []\n p.each_with_index { |a, i| \n b = q[i]\n result << counts[b] - counts[a - 1]\n }\n result\nend" ]
[ "0.61392176", "0.588643", "0.57472026", "0.57002056", "0.5683183", "0.5673275", "0.5672151", "0.56346744", "0.56346744", "0.55487424", "0.5485087", "0.5465638", "0.5440824", "0.5367206", "0.53502285", "0.53487235", "0.5338467", "0.5331518", "0.5331102", "0.5328647", "0.5282746", "0.5276469", "0.5256604", "0.52523404", "0.5240939", "0.52323985", "0.5215066", "0.51999086", "0.51951694", "0.5190017", "0.5186656", "0.518376", "0.5182175", "0.51723796", "0.51647943", "0.51551574", "0.5137221", "0.51228315", "0.5119889", "0.5112645", "0.51081145", "0.5095763", "0.50947535", "0.5091078", "0.5090482", "0.5090113", "0.5088599", "0.5088079", "0.5081782", "0.5081257", "0.50743884", "0.50719357", "0.507142", "0.50710934", "0.5050826", "0.5001164", "0.49969962", "0.49959677", "0.4984341", "0.49835312", "0.49834418", "0.49834418", "0.49834418", "0.4973475", "0.49712884", "0.49702385", "0.4969688", "0.49641666", "0.49637768", "0.4959553", "0.49591836", "0.49580386", "0.4956859", "0.49559352", "0.49547863", "0.49546665", "0.49545336", "0.49520642", "0.49507928", "0.49504024", "0.49453738", "0.49430597", "0.49427715", "0.4922708", "0.49210137", "0.49204788", "0.49115294", "0.4899885", "0.489885", "0.48919564", "0.4891819", "0.489171", "0.4889935", "0.48864263", "0.48862037", "0.48860142", "0.48831528", "0.48806977", "0.48781738", "0.487671" ]
0.7118193
0
create a random order of N (nonunique) items handy for testing and monte carlo method
def random_item items.to_a.sample end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_multiset_simple n\n @set.permutation(n).to_a.sort_by { rand }\n end", "def randn(n)\n (1..MAX_PK).to_a.shuffle!.take(n)\n end", "def pick!(n = nil)\n if n\n if n > self.size\n r = self.dup\n self.replace([])\n r\n else\n r = []\n n.times { r << delete_at(SecureRandom.random_number(size)) }\n r\n end\n else\n delete_at(SecureRandom.random_number(size))\n end\n end", "def generate_collection(array)\n array =[]\n 50.times do |n|\n array << n + 1\n end\n return array.shuffle\nend", "def randomly_select(n)\n list = []\n n.times do\n list << self[rand * size]\n end\n list\n end", "def random_list(sz, k)\n sz.times.map { Random.rand(k) + 1 }\nend", "def randomly_select_different(n)\n old_self = self\n list = []\n n.times do\n list << old_self.delete_at(rand * size)\n end\n list\n end", "def random_select(array, n)\n=begin\n rand_elements = []\n n.times do\n rand_elements << array[rand(array.length-1)]\n end\n rand_elements\n=end\n array.shuffle.sample(n)\nend", "def rnd_select(list, n)\n if n > 0\n selected, rest = remove_at(list, rand(n))\n [selected] + rnd_select(rest, n - 1)\n else\n []\n end\nend", "def populate_items\n return if @items.size >= 15\n\n type = rand\n if type < 0.010\n @items.push(Goody.new(:apple))\n elsif type < 0.040\n @items.push(Goody.new(:merde))\n end\n end", "def ary(n); Array.new(n){rand}; end", "def build\n Constant::RANKS.product(Constant::SUITS).shuffle\n end", "def generateCart\n cart = []\n rand(20).times do\n cart.push(ITEMS.sample) \n end\n cart\nend", "def random_select(array, n)\n array.shuffle.take(n)\nend", "def rand_recs(n) \n \tub = Event.maximum(\"id\")\n \tr = ApplicationHelper::rand_indexes(n, ub) \n \treturn [] if r == [] || n > 2 # only valid for a = 2\n \t(0..1).each do |i|\n\t \twhile (Event.exists?(r[i])==nil) || (r[0] == r[1]) do\n\t \t r[i]+=(rand * ub).round \n\t \t r[i] %= ub\n\t \tend\n\tend\n \treturn r # exit with array of n unique record ids for db permitting deletions...\n end", "def delete(n, i=0)\n i = rand(n) while @list[i].nil?\n @hash.delete(@list[i])\n @list[i] = nil\n end", "def random_select(array, n)\nrandom = []\n n.times do\n random << array.sample\n array.shuffle\nend\nrandom \nend", "def aleatorios(n)\n list = []\n (1..n).each do\n num = (rand*100000+1).to_i\n list.push(num)\n end\n list\nend", "def order_item\n @items.sample\n end", "def random_products_by_product_type(n=8)\n skope = presentable.randomize.limit(n)\n \n (ActiveSupport::OrderedHash.new).tap do |hasz|\n taxon_names.each do |taxon_name|\n taxon = Spree::Taxon.find_by_name(taxon_name)\n hasz[taxon] = skope.in_taxon(taxon) unless taxon.nil?\n end\n end\n end", "def generate_list(scale:, length: 16, seed: rrand_i(1, 1000000))\n use_random_seed seed\n unsorted_list = []\n while unsorted_list.length < length\n n = scale.choose\n unsorted_list.push(n) unless unsorted_list.include?(n)\n end\n unsorted_list\nend", "def generateCart\n cart = []\n rand(20).times do\n cart.push(ITEMS.sample)\n end\n ap cart \nend", "def random_attribute_indexes number\n (0...@data.first.size).sort_by { rand }[0..number]\n end", "def random_keys(sample_size)\n CanonicalItem.all.pluck(:partner_key).sample(sample_size).uniq.map(&:to_sym)\nend", "def insert(i, n)\n begin\n string = rand(n).to_s(36)\n end while @hash.has_key? string\n @hash[string] = i\n @list[i] = string\n end", "def rand_population(n)\r\n\t\treturn Array.new(n) { Snek.new(@start_x,@start_y, Array.new(@nb_heuristic) { @random.rand(-5.0..5.0) }) }\r\n\tend", "def randomPop(n)\n pop = []\n for i in 0..Popsize-1\n bits = \"\"\n for i in 0..n-1\n bits += rand(2).to_s\n end\n pop = pop << bits\n end\n return pop\nend", "def randomize\n randomly_select_different(self.size)\n end", "def suggested(n = 4)\n # TODO : Commented out because this request is extremely slow and makes page render twice.\n # return(Spree::Product.random_marketplace(n)) if self.get_type.nil?\n # \n # kolors = self.colors_hash\n # color1, color2 = kolors[:primary], kolors[:secondary]\n # \n # ret = []\n # ret.concat(color1.products.presentable.randomize.limit(n * 5)) unless color1.nil?\n # ret.concat(color2.products.presentable.randomize.limit(n * 5)) unless color2.nil?\n # ret = ret.sort_by { rand }\n # ret.concat(Spree::Product.random_marketplace(n))\n # ret.reject! {|product| product.get_type == self.get_type }\n # ret.delete(self)\n # ret.uniq!\n # ret.first(n)\n \n Spree::Product.active.with_image.randomize.limit(n)\n end", "def gen_uniq_rand(limit, unuseable)\n random = rand(limit)\n !(unuseable.include?(random)) ? random : gen_uniq_rand(limit, unuseable)\nend", "def create_random_list(limit)\n limit.times do\n add(rand(10))\n end\n end", "def generate_combos(n, item1, item2, item3, u1, u2, u3)\n used = []\n success = 0\n while (success < n)\n new_triplet = make_triplet(item1, item2, item3)\n if (triplet_included(new_triplet, used))\n # do nothing\n else\n success += 1\n used.push(new_triplet)\n end\n end\n end", "def randomly(n = 8)\n Enumerator.new do |out|\n s = self.ensure_enum\n pool = s.grab(n)\n while s.has_next?\n index = rand(n)\n out.yield pool[index]\n pool[index] = s.next\n end\n pool.sort_by{rand}.each{|x| out.yield x}\n end\n end", "def rand_indexes(n, lim)\n \t# lim = Event.count\n \treturn [] if (n < 1 || n > lim)\n \tray = []\n \twhile ray.count != n do\n \t\tray << (rand * lim).round\n \t\tray.delete(0)\n \t\tray.uniq! \t\t\n \tend\n \treturn ray\n end", "def random_select(array, n)\n [].tap do |result|\n n.times { result << array[rand(array.size)] }\n end\nend", "def typical_users(n=1,randomize=true)\n ids = items.flat_map {|item|\n item.subscriber_ids\n }.reduce(Hash.new(0)) { |h,id|\n h[id] += 1\n h\n }\n .sort_by{|k,v| v}.reverse\n .take(2*n)\n .sample(n)\n .map(&:first)\n\n User.any_in(id: ids)\n end", "def random_pick(number)\n sort_by{ rand }.slice(0...number)\n end", "def shuffle!\n size.downto(1) { |n| push delete_at(rand(n)) }\n self\nend", "def populate_random(n)\n n.times do\n set(rand(0...@x_size), rand(0...@y_size), :alive)\n end\n end", "def generate(n, words)\n lexicon = @mc.nodes()\n words = random_word(lexicon) if words.nil?\n elems = []\n 1.upto(n) do |i|\n next_word = @mc.rand(words)\n # if no word is word, take a random one from the lexicon\n if next_word.nil?\n words = random_word(lexicon)\n else\n if 1 == @order \n words = next_word\n elems << words\n else\n elems << words.shift()\n words.push(next_word)\n end\n end\n if ( i % LOG_WORDS_NUM == 0 && $VERBOSE )\n puts \"Generated #{i} words.\" \n STDOUT.flush()\n end\n end\n elems\n end", "def random_hugs\n huglist_sample = []\n 5.times { huglist_sample.push(Huglist.all.sample[:id]) }\n return huglist_sample.uniq\nend", "def random_items(items)\r\n\t\trandom_items = Document.has_photos.find(:all, :limit => items, :order => \"RAND()\")\r\n\tend", "def random_select(array, n)\n random_arr = Array.new\n n.times do\n random_array << array[rand(array.length)]\n end\nend", "def test_generate_unique_ids\n\n n = 10_000\n\n wfids = (1..n).collect { @dashboard.context.wfidgen.generate }\n\n assert_equal n, wfids.uniq.size\n end", "def shuffle(nums, n)\n current_index = 1\n (0..n - 1).each do |i|\n nums.insert(current_index, nums.delete_at(i + n))\n current_index += 2\n end\n nums\nend", "def initialize(n)\n\t\t@nums=(1..n).to_a.sort{ rand() - 0.5 }\n\t\tindex_pairs_sum\n\tend", "def index\n @items1 = Item.find(Item.pluck(:id).shuffle[0..2])\n @items2 = Item.find(Item.pluck(:id).shuffle[0..2])\n @items3 = Item.find(Item.pluck(:id).shuffle[0..2])\n @items4 = Item.find(Item.pluck(:id).shuffle[0..2])\n end", "def pick(n = nil)\n if n\n a = self.dup\n a.pick!(n)\n else\n at(SecureRandom.random_number(size))\n end\n end", "def random_select(array, n)\n\tresult = [] # Solution array\n\tn.times do # n times repeat\n\t\tresult << array[rand(array.length)] # Random position & save number\n\tend\n\tresult\nend", "def rnd_permu(list)\n rnd_select(list, list.length)\nend", "def random_select(array, n)\n randnumber = Random.new\n randvalues = Array.new\n randomizedarray = Array.new\n n.times do\n randomizedarray << array[randnumber.rand(array.count)]\n end\n return randomizedarray\nend", "def randomize\n original_list = tracks\n song_count = original_list.size\n attempt_threshold = (song_count * 0.33).floor # so we don't spin forever\n new_list = [original_list.shift]\n idx = 0\n until original_list.empty? do\n attempts = 0\n until attempts >= attempt_threshold || (original_list[idx] && new_list.last.artist != original_list[idx].artist)\n idx = rand(song_count) \n attempts +=1\n end\n new_list << original_list[idx]\n original_list.delete_at(idx) \n end\n# clear\n new_list\n end", "def random_item\n return @items[rand(@items.length)]\n end", "def generate\n (0..30).sort{ rand() } .take(@conf)\n end", "def group\n students = (1...59).to_a\n students.shuffle.each_slice(5).to_a\nend", "def random_select(array, n)\n result = []\n n.times do\n result << array[rand(array.size)]\n end\n return result\nend", "def sample(n=nil)\n if n\n choice = []\n _n = n.to_f\n each_with_index do |x,i|\n if rand < (_n/(i+1))\n if choice.size < n\n choice << x\n else\n choice[rand(n)] = x\n end\n end\n end\n choice\n else\n choice = nil\n each_with_index do |x,i|\n choice = x if rand(i+1) == 0\n end\n choice\n end\n end", "def generate_random_attribute_rule( size )\n r = []\n size.times { r << rand.round }\n r\nend", "def generate_random_attribute_rule( size )\n r = []\n size.times { r << rand.round }\n r\nend", "def random_batch_quantity\n Factory::Randomiser.number(10..1000)\n end", "def random_cards_without_duplicates(count)\n result = Set[]\n count.times do\n card = random_card\n redo if result.include?(card)\n result << card\n end\n result.to_a\n end", "def random_select(array, n)\n result = Array.new\n n.times do \n result << array[rand(array.length)]\n end\n return result\nend", "def generateCart\n\tcart = []\n\trand(20).times do\n\t\tcart.push(ITEMS.sample) \n\tend\n\tcart\nend", "def generateCart\n\tcart = []\n\trand(20).times do\n\t\tcart.push(ITEMS.sample) \n\tend\n\tcart\nend", "def generateCoups\n coups = []\n rand(2).times do\n coups.push(COUPS.sample)\n end\n coups\nend", "def nostalgia; return rand end", "def roll_misc\n [rand(2..12) * 10, rand(2..12) * 10, rand(3)]\n end", "def l(x); rand(x*@n); end", "def random_pairs()\r\n\r\n\tpair_ups = []\r\n\r\n\tnamelist = [\"Allen\", \"Brian\", \"Cummie\", \"Dover\", \"Edwin\", \"FrankM\",\r\n\r\n\t\t\"FrankC\", \"George\", \"Jayvon\", \"John\", \"Khalifa\", \"Lee\", \"Lisa\",\r\n\r\n\t\t\"Matt\", \"Max\", \"Mike\", \"Pat\", \"Patrick\", \"Sheri\", \"Takhir\", \"Teela\"]\r\n\r\n\trandom_num = rand(0..9)\r\n\r\n\tshuffled_list = namelist.shuffle.each_slice(2)\r\n\r\n\tshuffled_list.each do |pairs|\r\n\r\n\t\tif pairs.length == 2\r\n\r\n\t\t\tpair_ups.push(pairs)\r\n\r\n\t\telse\r\n\r\n\t\t\tpair_ups[random_num].push(pairs[0])\r\n\r\n\t\tend\r\n\r\n\tend\r\n\r\n\treturn pair_ups\r\n\r\n# puts pair_ups.inspect\r\n\r\nend", "def create_random_array(size=5)\n Array.new(size) { Array.new(size) { [\"Yes\", \"No\", \"Maybe\"].sample } }\n end", "def shuffle(nums, n)\n merged = []\n n.times { |i| merged.push(nums[i], nums[n + i]) }\n return merged\nend", "def generate_random_trade_items(bonus_rate = 0, categories = [])\n rate = ShopsSettings::TRADE_REFLOW_RATE + bonus_rate\n items = []\n trade_flow.each { |ary|\n next if ary[1] == 1 and !categories.include?(:items)\n next if ary[1] == 2 and !categories.include?(:weapons)\n next if ary[1] == 3 and !categories.include?(:armors)\n if rand(100) <= rate\n arx = [ary[0], ary[1], 1]\n items.push(arx)\n ary[2] -= 1\n trade_flow.delete(ary) if ary[2] <= 0\n end\n }\n items\n end", "def create_group(list) \n if list.length > 5 \n group = []\n group = list.shuffle.each_slice(5).to_a\n p group\n else\t\n p list\n end\nend", "def replicate(number, item)\n repeat(item).take(number)\n end", "def random_index\n return (rand * size).to_i\n end", "def generate_random_hypothesis( size )\n hypothesis = Hypothesis.new\n size.times do\n hypothesis << generate_random_rule\n end\n hypothesis\nend", "def generate_random_hypothesis( size )\n hypothesis = Hypothesis.new\n size.times do\n hypothesis << generate_random_rule\n end\n hypothesis\nend", "def sample_nodes(n)\n if n >= @nodes.length\n @nodes.dup\n else\n result = []\n while result.length < n\n node = sample_node\n result << node unless result.include? node\n end\n result\n end\n end", "def build_shuffler(deck_count = 1)\n arr = []\n\n for i in 1..deck_count\n for j in 1..52\n arr << rand(MAX_INT)\n end\n end\n arr\n end", "def random_distinct_bytes(length)\n if (length.kind_of?(Array) || length.kind_of?(Range))\n #return Array.new(length.sort_by { rand }.first) { random_byte }\n self.entries.sort_by { rand }.slice(0...(length.sort_by { rand }.first))\n else\n self.entries.sort_by { rand }.slice(0...length) \n end\n end", "def stack\n LETTERS.map{|x| [x]*QUANTITY_OF_LETTERS[LETTERS.index(x)]}.flatten.shuffle\nend", "def init length\n gen = []\n length.times { gen << @codon.rand_gen }\n gen\n end", "def random_objects_with_max(max, model_type)\n number_of_objects = Random.rand(1..max)\n objects = []\n number_of_objects.times do |index|\n objects[index] = create(model_type)\n end\n objects\nend", "def create_random_permutation(length, offset=0, pad=offset)\n a = Array.new(length) {|i| i + offset}\n b = Array.new(pad, nil)\n (length - 1).downto(0) {|i| b.push(a.delete_at(rand(i + 1)))}\n b\nend", "def random_select(n = 100)\n new_sh = ViralSeq::SeqHash.new\n dna_hash = self.dna_hash\n aa_hash = self.aa_hash\n qc_hash = self.qc_hash\n\n keys = dna_hash.keys.sample(n)\n\n keys.each do |k|\n new_sh.dna_hash[k] = dna_hash[k]\n new_sh.aa_hash[k] = aa_hash[k]\n new_sh.qc_hash[k] = qc_hash[k]\n end\n new_sh.file = self.file\n new_sh.title = self.title + \"_\" + n.to_s\n return new_sh\n end", "def n_generator\n number = rand(10..30)\n end", "def pronouncable_random(size=4)\n c = %w(b c d f g h j k l m n p qu r s t v w x z ch cr fr nd ng nk nt ph pr rd sh sl sp st th tr)\n v = %w(a e i o u y)\n f, r = true, ''\n (size * 2).times do\n r << (f ? c[rand * c.size] : v[rand * v.size])\n f = !f\n end\n return r\nend", "def randomize\n self.sort_by { rand }\n end", "def generate_order_number\n record = true\n while record\n random = \"R#{Array.new(9){rand(9)}.join}\"\n record = self.class.where(:number => random).first\n end\n self.number = random if self.number.blank?\n self.number\n end", "def random_item(electives)\n electives[rand(electives.length)]\nend", "def mp(a)\n n = []\n b = a.flatten.shuffle\n a.length.times do\n n << [b.pop, b.pop]\n end\n puts \"#{n}\"\nend", "def gen_arr(n, min = 0, max = 999999999)\n n.times.map do |x|\n rand(min..max)\n end\nend", "def make_answer\n\tlist = (0..9).to_a\n\t(0..2).map{ list.delete_at( rand(list.size-1)) }\nend", "def sample(cnt, lim)\n x = {}\n tmp = nil\n\n for i in 0...cnt\n while x.has_key?(tmp = rand(lim))\n end\n x[tmp] = true\n end\n ptime \"rand\"\n\n x = x.keys.sort\n ptime \"sort\"\n x\nend", "def select_customes\n customes = []\n 2.times { customes << CUSTOMES[rand(CUSTOMES.length)] }\n customes\nend", "def generate_n_sets(array, number_of_sets)\n\nend", "def initialize_deck\n VALUES.product(SUITS).shuffle\nend", "def new_groups(array)\n new_group = []\n array.shuffle.each_slice(4){|acc| new_group << acc}\n if new_group.length > 1 && new_group.last.length <= 2\n (new_group.last.length).times do |i|\n new_group[i].push(new_group.last.pop)\n new_group.pop\n end\n end\n new_group\nend", "def secure_sample(n=:single, o={})\n o, n = n, :single if n.is_a?(Hash)\n raise ArgumentError, 'wrong number of arguments (2 for 1)' unless o.is_a?(Hash)\n if random = o[:random]\n args = [{random: random}]\n args.unshift(n) unless n == :single\n sample(*args)\n else\n if n == :single\n self[SecureRandom.random_number(size)]\n else\n raise ArgumentError, 'negative sample number' if n < 0\n res = []\n old = dup\n n = size if n > size\n [*(size-n+1)..size].reverse_each.with_object([]){ |i, res|\n res << old.delete_at(SecureRandom.random_number(i))\n }\n end\n end\n end", "def create_rand_num (random_num_array, num_of_itens)\n num_of_itens.times do |i|\n random_num = rand(0..num_of_itens - 1 )\n while random_num_array.include?(random_num)\n random_num = rand(0..num_of_itens - 1 )\n end\n random_num_array << random_num\n end\nend" ]
[ "0.6721891", "0.6655618", "0.6648356", "0.6602962", "0.6413543", "0.6404212", "0.63592046", "0.6325159", "0.63228416", "0.63053834", "0.62699354", "0.62311935", "0.62185025", "0.62082523", "0.6189463", "0.6155809", "0.61550593", "0.61501", "0.61398077", "0.6123339", "0.61191905", "0.61127114", "0.61103654", "0.6086874", "0.60844696", "0.606745", "0.606357", "0.6055815", "0.60419905", "0.6029256", "0.60251296", "0.600575", "0.5998452", "0.59964436", "0.5950816", "0.5946893", "0.5922413", "0.5901323", "0.5895016", "0.58898014", "0.5883966", "0.5876103", "0.5866834", "0.5866202", "0.5864847", "0.5856391", "0.58397615", "0.58312804", "0.58222693", "0.58198607", "0.5810888", "0.5795899", "0.57948023", "0.5789646", "0.57879233", "0.5771918", "0.5755114", "0.5754934", "0.5754934", "0.5754924", "0.57534677", "0.5733281", "0.57219875", "0.57219875", "0.5717406", "0.57159126", "0.5706942", "0.57037175", "0.56996477", "0.5680245", "0.5676107", "0.5674707", "0.5657926", "0.56441766", "0.5625777", "0.56220347", "0.56220347", "0.5616165", "0.5611827", "0.5611678", "0.560754", "0.5605923", "0.5603132", "0.5599598", "0.5596178", "0.559591", "0.5595356", "0.55866134", "0.55842483", "0.5582669", "0.55709535", "0.55685055", "0.55669737", "0.55608135", "0.5559874", "0.5557105", "0.5556839", "0.55552536", "0.55539966", "0.5552244" ]
0.6156917
15
A callback initiated after successfully authenticating. This can be used to insert your own logic that is only run after the user successfully authenticates. Example: def after_ip_authentication(remote_ip) self.update_attribute(:invite_code, nil) end
def after_ip_authentication(_remote_ip); end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def after_custom_authentication; end", "def after_ip_authentication\n end", "def after_custom_authentication\n\n end", "def callback\n rpx_auth\n after_auth(params[:on_complete_url])\n end", "def after_hash_token_authentication\n end", "def after_crowd_authentication\n end", "def after_token_authentication\n end", "def after_token_authentication\n end", "def after_login(&block)\n add_callback(:login, block)\n end", "def after_password_reset; end", "def successful_authentication!(ip_address = nil)\n self.last_session_at = Time.now\n self.last_session_ip = ip_address\n self.save\n self.increment!(:session_count, 1)\n end", "def after_database_authentication; end", "def after_password_reset\n accept_invitation! if invitation_token.present?\n end", "def callback\n # This stores all the user information that came from Auth0\n # and the IdP\n userinfo = request.env['omniauth.auth']\n\n begin\n result = SessionService.process!(userinfo, session)\n\n if result.new_user?\n redirect_to welcome_path\n else\n # Redirect to the URL you want after successful auth\n redirect_to services_path,\n flash: {\n success: I18n.t(:welcome_html, scope: [:auth, :existing_user])\n }\n end\n rescue SignupNotAllowedError\n # no new user or existing user, so they weren't allowed to sign up\n redirect_to signup_not_allowed_path\n end\n end", "def handle_unverified_request\n sorcery_config.before_unverified_request.each do |callback|\n send(callback)\n end\n @current_user = nil\n super # call the default behaviour which resets the session\n end", "def authentication_succeed(oidresp)\n end", "def after_authentication\n @initiating_url = session[:initiating_url]\n session[:initiating_url] = nil\n render :'authentication/after_authentication'\n end", "def after_password_reset;\n end", "def user_verification?; end", "def after_successful_token_authentication\n @user = current_user\n end", "def handle_mobile_verification\n if valid_otp?\n current_user.update(mobile_verified: true)\n Redis.current.del(current_user.id)\n # I18n.t 'devise.sessions.signed_in'\n flash[:success] = I18n.t 'after_signup.verification_success'\n render_wizard current_user\n else\n flash[:error] = I18n.t 'after_signup.verification_failure'\n render after_signup_path(:verify_mobile)\n end\n # current_user.update(mobile_verified: true) if valid_otp?\n end", "def user_verification; end", "def process_authentication\n\n omniauth = request.env[\"omniauth.auth\"]\n Rails.logger.info(\"[CNTRL][Authentications] Auth process callback #{params} omniauth #{omniauth}\")\n\n if omniauth.nil?\n #TODO: Send back to sign in\n Rails.logger.info(\"[CNTRL][Authentications] Omni auth is nil, back to home\")\n redirect_to \"/\"\n end\n\n provider = params['provider']\n uid = omniauth['uid']\n\n already_existing_auth = Authentication.find_by_provider_and_uid(provider, uid)\n\n if already_existing_auth.nil?\n Rails.logger.info(\"[CNTRL][Authentications] A new foreign auth\")\n if user_signed_in?\n\n Rails.logger.info(\"[CNTRL][Authentications] User is already signed in #{current_user.full_name}\")\n\n query_hash = {}\n query_hash[provider] = uid \n invite_status = Invite.check_if_invite_exists(query_hash)\n\n \n\n any_existing_auth_for_same_provider = current_user.authentications.find_by_provider(provider)\n if any_existing_auth_for_same_provider.nil?\n Rails.logger.info(\"[CNTRL][Authentications] No existing auth for #{provider} for user\")\n authentication=Authentication.create(:provider=>provider,\n :uid=>uid,\n :token=> omniauth['credentials']['token'],\n :secret=> omniauth['credentials']['secret'],\n :user_id=>current_user.id)\n\n Rails.logger.info(\"[CNTRL][Authentications] Cache the new foreign profile\")\n authentication.foreign_profile = ForeignProfile.new\n authentication.foreign_profile.send(\"import_#{provider}\",omniauth)\n \n #redirect back to where you came from\n #\n \n\n if current_user.get_invited_status() == true\n enable_hash = {\n :user_id => current_user.id,\n :provider => provider,\n :uid => uid\n } \n current_user.enable_service(enable_hash)\n end\n redirect_to session[:return_to] || '/'\n \n else\n Rails.logger.info(\"[CNTRL][Authentications] #{current_user.full_name} already has auth for #{provider}\")\n if current_user.get_invited_status() == true\n enable_hash = {\n :user_id => current_user.id,\n :provider => provider,\n :uid => uid\n }\n current_user.enable_service(enable_hash)\n end\n redirect_to session[:return_to] || '/'\n end\n else\n # New authentication for no signed in user\n Rails.logger.info(\"[CNTRL][Authentications] User is not signed in but auth is new.\")\n\n authentication = Authentication.create( :provider => provider,\n :uid => uid,\n :token=> omniauth['credentials']['token'],\n :secret=> omniauth['credentials']['secret'])\n\n\n Rails.logger.info(\"[CNTRL][Authentications] New foreign profile to cache for new auth no signin.\")\n authentication.foreign_profile = ForeignProfile.new\n authentication.foreign_profile.send(\"import_#{provider}\",omniauth)\n\n\n query_hash = {}\n query_hash[provider] = uid\n \n invite_status = Invite.check_if_invite_exists(query_hash)\n if invite_status \n Invite.mark_invite_accepted(provider, uid)\n end\n\n Rails.logger.info(\"[CNTRL][Authentications] Redirecting to auth signup page.\")\n #if validation does not exist and user is not signed in do not allow access\n\n redirect_to :controller => 'authentications',\n :action => 'auth_signup_provider',\n :provider => provider,\n :uid => uid,\n :key => authentication.salt\n\n end\n else\n #save latest auth token\n Rails.logger.info(\"[CNTRL][Authentications] Renew credentials for an existing auth\")\n already_existing_auth.token = omniauth['credentials']['token']\n already_existing_auth.secret = omniauth['credentials']['secret']\n\n if user_signed_in?\n Rails.logger.info(\"[CNTRL][Authentications] User already signed in for a new auth.\")\n if already_existing_auth.user_id.nil?\n Rails.logger.info(\"[CNTRL][Authentications] User is being connected to auth\")\n already_existing_auth.user_id = current_user.id\n already_existing_auth.save!\n \n if current_user.get_invited_status() == true\n enable_hash = {\n :user_id => current_user.id,\n :provider => provider,\n :uid => uid\n }\n current_user.enable_service(enable_hash) \n end\n\n redirect_to session[:return_to] || '/'\n else\n\n if already_existing_auth.user_id == current_user.id\n Rails.logger.info(\"[CNTRL][Authentications] Auth token being updated for user\")\n already_existing_auth.save!\n end\n Rails.logger.info(\"[CNTRL][Authentications] Going back to where we came from\")\n enable_hash = {\n :user_id => current_user.id,\n :provider => provider,\n :uid => uid\n }\n current_user.enable_service(enable_hash) \n redirect_to session[:return_to] || '/'\n end\n else\n Rails.logger.info(\"[CNTRL][Authentications] A new auth and user is not signed in.\")\n if already_existing_auth.user_id.nil?\n Rails.logger.info(\"[CNTRL][Authentications] Auth is not associated to any user.\")\n already_existing_auth.save!\n\n Rails.logger.info(\"[CNTRL][Authentications] Foreign profile being saved for auth.\")\n already_existing_auth.foreign_profile = ForeignProfile.new\n Rails.logger.info(\"[CNTRL][Authentications] Foreign profile import method call.\")\n already_existing_auth.foreign_profile.send(\"import_#{provider}\",omniauth)\n \n\n Rails.logger.info(\"[CNTRL][Authentications] Redirecting to auth sign in\")\n redirect_to :controller => 'authentications',\n :action => 'auth_signup_provider',\n :provider => provider,\n :uid => uid,\n :key => already_existing_auth.salt\n\n else\n # I know the user, allow him to get in\n Rails.logger.info(\"[CNTRL][Authentications] Known auth, user sign in [user id : #{already_existing_auth.user_id}]\")\n \n if already_existing_auth.user.user_type == AppConstants.user_type_crawled \n Rails.logger.info(\"[CNTRL][Authentications] Cache the new foreign profile\")\n already_existing_auth.foreign_profile = ForeignProfile.new\n already_existing_auth.foreign_profile.send(\"import_#{provider}\",omniauth)\n already_existing_auth.save!\n\n redirect_to :controller => 'authentications',\n :action => 'auth_signup_provider',\n :provider => provider,\n :uid => uid,\n :key => already_existing_auth.salt\n return\n end\n\n\n already_existing_auth.save!\n \n invite_status = already_existing_auth.user.get_invited_status \n if invite_status \n enable_hash = {\n :user_id => already_existing_auth.user.id,\n :provider => provider,\n :uid => uid\n }\n already_existing_auth.user.enable_service(enable_hash) \n end\n sign_in_and_redirect(:user, already_existing_auth.user)\n end\n end\n end\n rescue => e\n Rails.logger.error(\"[CNTRL][Authentications] Save raised exception : #{e}\")\n redirect_to \"/\"\n end", "def user_verified?; end", "def callback\n @user = User.find_by_hash(auth_hash)\n if @user\n login(@user)\n redirect_to \"/\" and return\n else\n # We store the authorization so that the user cannot modify\n # the provider/uid details in the form\n @authorization = Authorization.create_from_hash(auth_hash)\n session[:auth_id] = @authorization.id\n @user = User.new_from_hash(auth_hash)\n end\n end", "def user_verified; end", "def successful_authentication(user)\n set_brute_force_counter(user, 0)\n super\n end", "def pre_authorize_cb; end", "def user_verified=(_arg0); end", "def on_success!(response, sreg_response)\n if user = find_user_by_identity_url(response.identity_url)\n user\n else\n request.session[:'openid.url'] = response.identity_url\n required_reg_fields.each do |f|\n session[:\"openid.#{f}\"] = sreg_response.data[f] if sreg_response.data[f]\n end if sreg_response\n redirect!(Merb::Router.url(:signup))\n end\n end", "def on_failure!(response)\n session.authentication.errors.clear!\n session.authentication.errors.add(:openid, 'OpenID verification failed, maybe the provider is down? Or the session timed out')\n nil\n end", "def pre_authorize_cb=(_arg0); end", "def callback_phase\n @user_info = get_user(@auth_token = fetch_auth_token(session['omniauth.ebay.session_id']))\n super\n end", "def handle_inverified_request\n \tsignout\n \tsuper\n end", "def callback_phase\n @auth_token = get_auth_token(request.params[\"username\"], request.params[\"sid\"])\n @user_info = get_user_info(request.params[\"username\"], @auth_token)\n ap @user_info\n super\n rescue => ex\n fail!(\"Failed to retrieve user info from ebay\", ex)\n end", "def callback_call\n setup_phase\n log :debug, 'Callback phase initiated.'\n @env['omniauth.origin'] = session.delete('omniauth.origin')\n @env['omniauth.origin'] = nil if env['omniauth.origin'] == ''\n @env['omniauth.params'] = session.delete('omniauth.params') || {}\n OmniAuth.config.before_callback_phase.call(@env) if OmniAuth.config.before_callback_phase\n callback_phase\n end", "def before_method(request, response)\n if @current_principal\n # We already have authentication information. This means that the\n # event has already fired earlier, and is now likely fired for a\n # sub-request.\n #\n # We don't want to authenticate users twice, so we simply don't do\n # anything here. See Issue #700 for additional reasoning.\n #\n # This is not a perfect solution, but will be fixed once the\n # \"currently authenticated principal\" is information that's not\n # not associated with the plugin, but rather per-request.\n #\n # See issue #580 for more information about that.\n return nil\n end\n\n if @backends.empty?\n fail Dav::Exception, 'No authentication backends were configured on this server.'\n end\n\n reasons = []\n @backends.each do |backend|\n result = backend.check(request, response)\n\n if !result.is_a?(Array) ||\n result.size != 2 ||\n !(result[0].is_a?(TrueClass) || result[0].is_a?(FalseClass)) ||\n !result[1].is_a?(String)\n fail Dav::Exception, 'The authentication backend did not return a correct value from the check method.'\n end\n\n if result[0]\n @current_principal = result[1]\n # Exit early\n return nil\n end\n reasons << result[1]\n end\n\n # If we got here, it means that no authentication backend was\n # successful in authenticating the user.\n @current_principal = nil\n\n @backends.each do |backend|\n backend.challenge(request, response)\n end\n fail Exception::NotAuthenticated, reasons.join(', ')\n end", "def callback_phase\n ym_session_id = env['rack.session'][RACK_SESSION_KEY]\n fail!(E_YM_SESSION_ID_BLANK) if ym_session_id.blank?\n ym_session = YourMembership::Session.new(ym_session_id, 100)\n\n begin\n fail! 'Failed To Log In' unless ym_session.authenticated?\n rescue YourMembership::Error => e\n fail! e.error_description\n end\n\n @user_id = ym_session.user_id\n @access_token = ym_session.to_s\n\n super\n end", "def register_verify_callback(connection)\n connection.verify_callback = self\n end", "def after_auth(user)\n # Push the avatar (Just in case any clients support it)\n # AvatarUpdaterService.new(user).update\n\n # Set rooms, groups, etc.\n UserService.update(user).save\n\n # We're done here\n sign_in_and_redirect user\n end", "def on_after_oauth2_connect(oauth2_user_attributes)\n if self.respond_to?(:after_oauth2_connect)\n self.send(:after_oauth2_connect, oauth2_user_attributes)\n end\n end", "def callback\n auth = build_auth\n respond_to do |format|\n if logged_in?\n add_identity_to_current_user(auth)\n welcome_user(current_user)\n format.html { redirect_logged_in_user }\n format.json { render_jsend_success(:logged_in) }\n else\n user = find_or_create_user_from_auth(auth)\n if user\n user.remember_me! if session.delete(:remember_me)\n if user.connected?\n setup_new_user(user, auth)\n format.html { redirect_to_signup_flow_entry_point }\n format.json { render_jsend_success(:connected, new_profile_data(user, auth)) }\n elsif user.registered?\n setup_existing_user(user)\n format.html { redirect_after_onboarding_check(user, request.env['omniauth.origin']) }\n format.json { render_jsend_success(:registered) }\n else\n notify_visitor_user_creation_failed(user)\n format.html { redirect_after_auth(request.env['omniauth.origin'] || login_path) }\n format.json { render_jsend(error: :user_creation) }\n end\n else\n format.html { redirect_to(login_path) }\n format.json { render_jsend(error: :no_user) }\n end\n end\n end\n end", "def after_successful_token_authentication\n # binding.pry\n # Make the authentication token to be disposable - for example\n # renew_authentication_token!\n end", "def after_confirmation; end", "def handle_unverified_request\n\t\t\tsign_out\n\t\t\tsuper\n\t\tend", "def verify_callback=(verify_callback); end", "def verify_callback=(verify_callback); end", "def on_success(&block)\n apply_hook(:success, &block)\n end", "def callback\n return unless passes_whitelist?\n session[:user_id] = User.from_omniauth(@auth_hash, current_tenant.tenant_id, unmangle_orcid).id\n redirect_to dashboard_path\n end", "def after_request(response)\n unless @authenticating\n if captcha_required(response)\n raise Jiralicious::CaptchaRequired.\n new(\"Captacha is required. Try logging into Jira via the web interface\")\n elsif cookie_invalid(response)\n # Can usually be fixed by logging in again\n clear_session\n raise Jiralicious::CookieExpired\n end\n end\n @authenticating = false\n end", "def after_login!(user, username = '', password = '', options = {})\n sorcery_config.after_login.each do |callback|\n send(callback, user, username, password, options)\n end\n end", "def after_invite_new_user(invite)\n end", "def callback\n\n\n # Access the authentication hash for omniauth\n data = request.env['omniauth.auth']\n\n # Temporary for testing!\n render json: data.to_json\n\n\n # Access the authentication hash for omniauth\n # data = request.env['omniauth.auth']\n\n # microsoft_email_address = data.dig(:extra, :raw_info, :mail) || data.dig(:extra, :raw_info, :userPrincipalName)\n\n # if user_account = UserAccount.find_by(email: microsoft_email_address)\n # session[:user_account_id] = user_account.id\n # if session[:previously_requested_page]\n # last_page = session[:previously_requested_page]\n # session.delete(:previously_requested_page)\n # redirect_to last_page\n # else\n # redirect_to root_path\n # end\n # else\n # redirect_to new_session_path, notice: \"An account could not be found for #{microsoft_email_address}.\"\n # end\n end", "def handle_unverified_request\n\t\tsign_out\n\t\tsuper\n\tend", "def handle_unverified_request\n\t\tsign_out\n\t\tsuper\n\tend", "def handle_unverified_request\n\t\tsign_out\n\t\tsuper\n\tend", "def after_successful_sign_in\n invite = current_account.claim_invitation\n if invite\n invitable = invite.invitable\n invitable_name = invitable.class.name.downcase\n anchor = '/%s/%d' % [invitable_name.pluralize, invitable.id]\n\n flash[:success] = _('%s invited you to collaborate on %s %s.') % [\n invite.user.nicename, invitable.title, invitable_name ]\n\n redirect_to root_path(:anchor => anchor)\n else\n super\n end\n end", "def on_connection_success &block\n @connection_success_callback = block\n end", "def verify_callback; end", "def verify_callback; end", "def handle_unverified_request\n\tsign_out\n\tsuper\nend", "def handle_unverified_request\n employee_sign_out\n company_sign_out\n super\n end", "def successful_login!\n unthrottle_user\n clear_bad_login_counter\n end", "def azure_auth\n if (email = authenticated?)\n email_pat = /\\A([^@\\s]+)@((?:[-a-z0-9]+\\.)+[a-z]{2,})\\z/i\n unless email =~ email_pat\n flash[:alert] = \"Unknown email: #{email}\"\n redirect_to root_path\n return\n end\n user = User.where(:email => email).first\n unless user\n password = Devise.friendly_token[0,8]\n user = User.create(\n email:email,\n password:password,\n password_confirmation:password\n )\n end\n \n if user.email_confirmed?\n sign_in_and_redirect user, :event => :authentication\n else\n redirect_to root_path, :notice => I18n.t(:conf_msg, :scope => [:messages, :controllers, :invitations])\n end\n else\n flash[:alert] = \"No email found.\"\n redirect_to root_path\n end\n end", "def handle_unverified_request\n \tsign_out\n \tsuper\n end", "def handle_unverified_request\n \tsign_out\n \tsuper\n end", "def handle_unverified_request\n \tsign_out\n \tsuper\n end", "def handle_unverified_request\n \tsign_out\n \tsuper\n end", "def handle_unverified_request\n \tsign_out\n \tsuper\n end", "def handle_unverified_request\n \tsign_out\n \tsuper\n end", "def after_logout(&block)\n add_callback(:logout, block)\n end", "def after_create\n @password = nil\n @confirm_password = nil\n end", "def controller_account_success_authentication_after(context={})\n context[:controller].flash[:kittens] = \"Yay! Welcome #{context[:user].firstname}!\"\n end", "def after_create\n @password = nil\n end", "def after_create\n @password = nil\n end", "def handle_response!\n logger.debug \"Attempting OpenID auth: #{provider_response.inspect}\"\n\n case provider_response.status\n when :success\n resource = find_resource || build_resource || create_resource\n\n if resource && validate(resource)\n begin\n update_resource!(resource)\n rescue\n fail! $!\n else\n success!(resource)\n end\n else\n fail! \"This OpenID URL is not associated with any registered user\"\n end\n\n when :cancel\n fail! \"OpenID authentication cancelled\"\n when :failure\n fail! \"OpenID authentication failed\"\n end\n end", "def on_success( &block )\n @on_success = block\n end", "def handle_unverified_request\n sign_out\n super\n #When you invoke super with no arguments Ruby sends a message to the parent of the current object, asking it to invoke a method of the same name as the method invoking super. It automatically forwards the arguments that were passed to the method from which it's called.\n end", "def authenticate_once_state\n super\n end", "def after_magic_link_authentication\n end", "def user_authentication\n end", "def after_token_authentication\n if params[:authentication_key].present?\n @user = User.find_by_authentication_token(params[:authentication_key]) # we are finding \n sign_in @user if @user # we are siging in user if it exist. sign_in is devise method \n if @user == nil\n\trender :status=>400, :json=>{:message=>\"Invalid token.\"}\n end\n end\n end", "def on_success(&block)\n @handlers[:success] = block\n self\n end", "def clean_up_passwords; end", "def handle_unverified_request\n logout()\n flash_message(:alert, \"An unverified request was received! For security reasons you have been signed out. ApplicationController#handle_unverified_request\")\n super\n end", "def after_remembered\n end", "def verify_signed_out_user; end", "def verify_signed_out_user; end", "def verify_signed_out_user; end", "def authCallback\n begin\n auth_code = params.fetch(\"code\")\n rescue KeyError\n raise \"error: no code param provided\"\n end\n\n from_sso = params.fetch(\"from_sso\", \"0\") == \"1\" \n origin = params[\"origin\"] if params.key?(\"origin\")\n\n redirect_uri_sso = URI(api_args[\"redirect_uri\"])\n redirect_uri_sso.query = URI.encode_www_form(params.select{|k, v| [\"from_sso\", \"origin\"].include? k})\n\n redirect_uri = from_sso ? redirect_uri_sso.to_s : api_args[\"redirect_uri\"]\n\n password_reset = sign_in(auth_code, redirect_uri)\n\n if from_sso\n # we got here from sso, redirect to origin(the page where user entered \n # the site)\n redirect_to origin\n elsif password_reset\n # we got here from email password reset, redirect to change password\n redirect_to \"/#{app.name}/profile_change_password\"\n else\n # since we are in an iframe, reload the parent, not the current window,\n # otherwise we will get nesting.\n render :text => \"<script>window.parent.location.reload()</script>\"\n end \n end", "def user_verification=(_arg0); end", "def on_after_oauth2_connect(oauth2_user_attributes)\n \n if self.respond_to?(:after_oauth2_auto_create)\n self.send(:after_oauth2_auto_create, oauth2_user_attributes) \n end\n on_after_oauth2_connect\n end", "def after_confirmation\n end", "def finish_signed_up_but_email_not_confirmed?\n @identity.update(identity_params) && !@identity.confirmed?\n end", "def acknowledge(authcode = nil)\n verified?\n end", "def redirect_after_signup &blk\n self.lwt_authentication_system_options[:redirect_after_signup] = blk\n end", "def handle_unverified_request\n sign_out_user\n super\n end", "def after_remembered; end", "def after_initialize \n @unencrypted = self.password.nil?\n end", "def callback_phase\n error = request.params['error_reason'] || request.params['error']\n fail(OAuthError, error) if error\n @session_state = request.params['session_state']\n @id_token = request.params['id_token']\n @code = request.params['code']\n @claims, @header = validate_and_parse_id_token(@id_token)\n # validate_chash(@code, @claims, @header)\n super\n end" ]
[ "0.6595618", "0.65379465", "0.6419615", "0.60326874", "0.59665775", "0.5953205", "0.5950166", "0.5950166", "0.59467286", "0.5876996", "0.5848361", "0.58358914", "0.5788606", "0.5708852", "0.5708394", "0.5685545", "0.56622446", "0.56618494", "0.56517303", "0.56498915", "0.5636803", "0.5597152", "0.5512405", "0.5491136", "0.54854256", "0.5481654", "0.5475308", "0.5470581", "0.54570705", "0.543368", "0.5417341", "0.5367448", "0.5355947", "0.5344029", "0.53323287", "0.53186023", "0.5318032", "0.5312891", "0.53127337", "0.5303359", "0.5297818", "0.52928346", "0.52764904", "0.5259458", "0.52499634", "0.52211595", "0.52211595", "0.5213915", "0.52043015", "0.51950073", "0.5187822", "0.51877916", "0.51860255", "0.5171466", "0.5171466", "0.5171466", "0.5164603", "0.51420826", "0.5138668", "0.5138668", "0.5123579", "0.5119361", "0.51187277", "0.5118139", "0.5104726", "0.5104726", "0.5104726", "0.5104726", "0.5104726", "0.5104726", "0.50954974", "0.50924003", "0.5091952", "0.5085178", "0.5085178", "0.50792986", "0.50708115", "0.50681525", "0.50653553", "0.5059835", "0.5057225", "0.5044689", "0.5044526", "0.5042466", "0.5042141", "0.5028221", "0.5021198", "0.5021198", "0.5021198", "0.50188226", "0.5017281", "0.5016424", "0.5011069", "0.5009628", "0.5005962", "0.49915573", "0.49805868", "0.4978073", "0.4968807", "0.49687952" ]
0.5928965
9
Card Test cards belonging in the card class
def test_card_members card = Card.new("A", "Hearts") assert_equal(card.value, 1) assert_equal(card.face, "A") assert_equal(card.is_ace, true) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cards\n @cards\n end", "def initialize(cards)\n @cards = cards\n end", "def initialize(cards)\n @cards = cards\n end", "def initialize(cards)\n @cards = cards\n end", "def cards\n\t\t@cards.each do |card|\n\t\t\tputs card.card\n\t\tend\n\tend", "def initialize\n @cards = []\n suits = [:hearts, :diamonds, :spades, :clubs]\n suits.each do |suit|\n (2..10).each do |value|\n @cards << Card.new(suit, value)\n end\n [\"J\", \"Q\", \"K\", \"A\"].each do |facecard|\n @cards << Card.new(suit, facecard)\n end\n end\n\n def shuffle!\n cards.shuffle!\n end\n\n def empty?\n self.cards.empty?\n end\n\n\nend", "def initialize(cards)\n @cards = cards\n end", "def test_deck_has_cards\n assert_equal [@card_1, @card_2, @card_3], @deck.cards\n end", "def cards\n @cards ||= EbanqApi::Cards.new(self)\n end", "def test_it_has_cards\n assert_equal [@card_generator.cards[0], @card_generator.cards[1], @card_generator.cards[2], @card_generator.cards[3]], @card_generator.cards\n end", "def initialize\n @cards = []\n end", "def get_card\n end", "def initialize(cards = Deck.all_cards)\n @cards = cards\n end", "def initialize()\n @cards = []\n end", "def get_cards(deck)\n\n end", "def initialize(cards) #argument\n @cards = cards\n end", "def initialize(cards = Deck.all_cards)\n end", "def display_deck\n @deck_array.each do |x|\n x.display_card\n end\n end", "def initialize\n @cards = ((1..6).to_a * 3 + (7..10).to_a * 4 + (11..17).to_a * 2 + (18..25).to_a).shuffle\n end", "def has_card? test_card\r\n @card_list.has_card? test_card\r\n end", "def cards\n @cards ||= Hand.new\n end", "def card_deck\n CardDeck.new(card: @subject)\n end", "def get_rounds_cards\n # get all the cards from this round's deck\n @cards = self.deck.cards\n end", "def initialize\r\n\t\t@cards =[]\r\n\t\t%w[Spades Hearts Diamonds Clubs].each do |suit|\r\n\t\t\t%w[2 3 4 5 6 7 8 9 10 J Q K A].each do |face_value|\r\n\t\t\t\t@cards << Card.new(suit, face_value)\r\n\t\t\tend\r\n\t\tend\r\n\t\tshuffle!\r\n\tend", "def has_card? test_card \n @card_list.has_card? test_card\n end", "def initialize(card_array) # creates an array of cards\n @cards = card_array\n end", "def initialize\n @card_classes = ['Hearts','Spades','Diamonds','Clubs']\n @card_types = ['Two of','Three of','Four of','Five of','Six of','Seven of','Eight of','Nine of','Ten of','Jack of','Queen of' ,'King of','Ace of']\n @deck = []\n @card_types.each do |c_types|\n @card_classes.each do |c_class|\n @deck.push(c_types + \" \" + c_class)\n end\n end\n end", "def initialize\n self.cards = []\n (0..51).each { |i| cards << Card.new(i) }\n self.cards.shuffle! \n end", "def draw_card\n #suit = Card::SUITS.sample\n #rank = Card::RANKS.sample\n #Card.new(suit: suit, rank: rank)\n @cards.pop\n end", "def fetch_cards\n log 'fetch_cards'\n data = get(PRODUCTS_ENDPOINT, fields: { carteras: false,listaSolicitada: 'TODOS',indicadorSaldoPreTarj: false })\n data['datosSalidaTarjetas']['tarjetas'].map{ |data| build_card(data) }\n end", "def getCardArray()\n\t\treturn @cards\n\tend", "def initialize \r\n @cards = []\r\n\r\n\r\n\r\n # Idiomatic ruby loop\r\n SUITS.each do |suit|\r\n RANKS.each do |rank|\r\n @cards.push(Card.new(rank,suit))\r\n end\r\n end\r\n end", "def populate_deck\n # self.initial_size.times do\n # new_card_class = Card.library.values.sample\n # new_card = new_card_class.new\n # self.cards << new_card\n # end\n 40.times do\n new_card_type = Card.library.values.sample\n new_card = new_card_type.create\n self.cards << new_card\n end\n end", "def create_cards\r\n @cards.each{|e| e.create}\r\n @symbols_card.each{|e| e.create}\r\n @cards_rotated.each{|e| e.create}\r\n end", "def initialize\n @cards = Card::RANKS.product(Card::SUITS).collect { |rank, suit| Card.new(suit, rank) }\n end", "def initialize\n @cards = []\n\n RANKS.product(SUITS).each do |rank, suit|\n @cards << Card.new(rank, suit)\n end\n end", "def cards_attributes=(cards)\n @cards = []\n cards.each do |card|\n @cards << PlainCard.new(card)\n end\n check_warnings\n end", "def my_cards\n index = 0\n @my_cards = []\n @suits.each do |suit|\n (1..13).each do |value|\n card = Card.new(value, suit)\n @my_cards.push(card)\n end\n end\n return @my_cards\n end", "def parse_cards\n cards = []\n card_nodes = search('tr.cardItem')\n card_nodes.each do |card_node|\n card = {}\n card[:name] = name(card_node)\n card[:mana_cost] = mana_cost(card_node)\n card[:cmc] = cmc(card_node)\n card[:rules] = rules(card_node)\n card[:power] = power(card_node)\n card[:toughness] = toughness(card_node)\n card[:set_versions] = set_versions(card_node)\n\n # Supertype, Subtype, P/T, Loyalty, Hand/Life Modifiers, etc are all stored in the same node\n type_data = type_data(card_node)\n card.merge! type_data\n\n cards << card\n p card if DEBUG\n end\n cards\n end", "def generate_deck # ANTHONY\n @suits.each do |suit|\n @rank.each do |rank|\n color = (suit == 'Spades' || suit == 'Clubs') ? 'Black' : 'Red'\n @cards << Card.new(rank, suit, color)\n end\n end\n end", "def desk_cards\n desk = []\n self.public_deal.each do |i|\n desk.push(i)\n end\n self.hand_deal.each do |i|\n desk.push(i)\n end\n desk\n end", "def initialize\n @deck = Array.new\n suits = ['Club', 'Diamond', 'Heart','Spades']\n cards = ['2', '3', '4', '5', '6', '7', '8', '9', '10', 'J', 'Q', 'K', 'A']\n suits.each do |suit|\n cards.each do |card|\n @deck << Card.new(suit,card)\n end\n end\n @deck.shuffle!\n end", "def create_deck\r\n all_cards = []\r\n # Hearts ♥\r\n all_cards << ace_of_hearts = Ace.new('A', 'hearts', \"♥\")\r\n all_cards << king_of_hearts = Card.new('K', 'hearts', 10, \"♥\")\r\n all_cards << queen_of_hearts = Card.new('Q', 'hearts', 10, \"♥\")\r\n all_cards << jack_of_hearts = Card.new('J', 'hearts', 10, \"♥\")\r\n all_cards << ten_of_hearts = Card.new('10', 'hearts', 10, \"♥\")\r\n all_cards << nine_of_hearts = Card.new('9', 'hearts', 9, \"♥\")\r\n all_cards << eight_of_hearts = Card.new('8', 'hearts', 8, \"♥\")\r\n all_cards << seven_of_hearts = Card.new('7', 'hearts', 7, \"♥\")\r\n all_cards << six_of_hearts = Card.new('6', 'hearts', 6, \"♥\")\r\n all_cards << five_of_hearts = Card.new('5', 'hearts', 5, \"♥\")\r\n all_cards << four_of_hearts = Card.new('4', 'hearts', 4, \"♥\")\r\n all_cards << three_of_hearts = Card.new('3', 'hearts', 3, \"♥\")\r\n all_cards << two_of_hearts = Card.new('2', 'hearts', 2, \"♥\")\r\n # Spades ♠\r\n all_cards << ace_of_spades = Ace.new('A', 'spades', \"♠\")\r\n all_cards << king_of_spades = Card.new('K', 'spades', 10, \"♠\")\r\n all_cards << queen_of_spades = Card.new('Q', 'spades', 10, \"♠\")\r\n all_cards << jack_of_spades = Card.new('J', 'spades', 10, \"♠\")\r\n all_cards << ten_of_spades = Card.new('10', 'spades', 10, \"♠\")\r\n all_cards << nine_of_spades = Card.new('9', 'spades', 9, \"♠\")\r\n all_cards << eight_of_spades = Card.new('8', 'spades', 8, \"♠\")\r\n all_cards << seven_of_spades = Card.new('7', 'spades', 7, \"♠\")\r\n all_cards << six_of_spades = Card.new('6', 'spades', 6, \"♠\")\r\n all_cards << five_of_spades = Card.new('5', 'spades', 5, \"♠\")\r\n all_cards << four_of_spades = Card.new('4', 'spades', 4, \"♠\")\r\n all_cards << three_of_spades = Card.new('3', 'spades', 3, \"♠\")\r\n all_cards << two_of_spades = Card.new('2', 'spades', 2, \"♠\")\r\n # Diamonds ♦\r\n all_cards << ace_of_diamonds = Ace.new('A', 'diamonds', \"♦\")\r\n all_cards << king_of_diamonds = Card.new('K', 'diamonds', 10, \"♦\")\r\n all_cards << queen_of_diamonds = Card.new('Q', 'diamonds', 10, \"♦\")\r\n all_cards << jack_of_diamonds = Card.new('J', 'diamonds', 10, \"♦\")\r\n all_cards << ten_of_diamonds = Card.new('10', 'diamonds', 10, \"♦\")\r\n all_cards << nine_of_diamonds = Card.new('9', 'diamonds', 9, \"♦\")\r\n all_cards << eight_of_diamonds = Card.new('8', 'diamonds', 8, \"♦\")\r\n all_cards << seven_of_diamonds = Card.new('7', 'diamonds', 7, \"♦\")\r\n all_cards << six_of_diamonds = Card.new('6', 'diamonds', 6, \"♦\")\r\n all_cards << five_of_diamonds = Card.new('5', 'diamonds', 5, \"♦\")\r\n all_cards << four_of_diamonds = Card.new('4', 'diamonds', 4, \"♦\")\r\n all_cards << three_of_diamonds = Card.new('3', 'diamonds', 3, \"♦\")\r\n all_cards << two_of_diamonds = Card.new('2', 'diamonds', 2, \"♦\")\r\n # Clubs ♣\r\n all_cards << ace_of_clubs = Ace.new('A', 'clubs', \"♣\")\r\n all_cards << king_of_clubs = Card.new('K', 'clubs', 10, \"♣\")\r\n all_cards << queen_of_clubs = Card.new('Q', 'clubs', 10, \"♣\")\r\n all_cards << jack_of_clubs = Card.new('J', 'clubs', 10, \"♣\")\r\n all_cards << ten_of_clubs = Card.new('10', 'clubs', 10, \"♣\")\r\n all_cards << nine_of_clubs = Card.new('9', 'clubs', 9, \"♣\")\r\n all_cards << eight_of_clubs = Card.new('8', 'clubs', 8, \"♣\")\r\n all_cards << seven_of_clubs = Card.new('7', 'clubs', 7, \"♣\")\r\n all_cards << six_of_clubs = Card.new('6', 'clubs', 6, \"♣\")\r\n all_cards << five_of_clubs = Card.new('5', 'clubs', 5, \"♣\")\r\n all_cards << four_of_clubs = Card.new('4', 'clubs', 4, \"♣\")\r\n all_cards << three_of_clubs = Card.new('3', 'clubs', 3, \"♣\")\r\n all_cards << two_of_clubs = Card.new('2', 'clubs', 2, \"♣\")\r\n all_cards\r\nend", "def initialize(card)\n @card = card #TODO: change this to @rank\n end", "def cards\n RecipeCard.all.select do |recipe_card|\n recipe_card.user == self\n end\n end", "def cards\n @cards ||= @client.resource['creditCards']\n end", "def test_add_card\n @LiarHand.remove_card(Card.new(:Ace))\n\n assert_equal(1, @LiarHand.cards_in_hand, 'remove_card method not working for <LiarHand>')\n assert_equal(false, @LiarHand.contains?(Card.new(:Ace)), 'Ace card deleted from <LiarHand>, is it still there')\n @LiarHand.add_card(:Ace)\n assert_equal(2, @LiarHand.cards_in_hand, 'add_card method not working for <LiarHand>')\n\n @IdiotHand.remove_card(Card.new(:Two))\n\n assert_equal(1, @IdiotHand.cards_in_hand, 'remove_card method not working for <LiarHand>')\n assert_equal(false, @IdiotHand.contains?(Card.new(:Two)), 'Ace card deleted from <LiarHand>, is it still there')\n @IdiotHand.add_card(:Two)\n assert_equal(2, @IdiotHand.cards_in_hand, 'add_card method not working for <LiarHand>')\n\n @LightHand.remove_card(Card.new(:Queen))\n\n assert_equal(4, @LightHand.cards_in_hand, 'remove_card method not working for <LiarHand>')\n assert_equal(false, @LightHand.contains?(Card.new(:Queen)), 'Ace card deleted from <LiarHand>, is it still there')\n @LightHand.add_card(:Queen)\n assert_equal(5, @LightHand.cards_in_hand, 'add_card method not working for <LiarHand>')\n\n @SpiderHand.remove_card(Card.new(:King))\n\n assert_equal(4, @SpiderHand.cards_in_hand, 'remove_card method not working for <LiarHand>')\n assert_equal(false, @SpiderHand.contains?(Card.new(:King)), 'Ace card deleted from <LiarHand>, is it still there')\n @SpiderHand.add_card(:King)\n assert_equal(5, @SpiderHand.cards_in_hand, 'add_card method not working for <LiarHand>')\n\n\n end", "def newCard\n\t@card = Cards.new\n \t@card.random\n end", "def gen_cards\n # done in a verbose manner so that code is easy to understand\n %w[H D S C].each do |suit|\n @cards.push(Card.new('Ace', suit, 1))\n @cards.push(Card.new('Two', suit, 2))\n @cards.push(Card.new('Three', suit, 3))\n @cards.push(Card.new('Four', suit, 4))\n @cards.push(Card.new('Five', suit, 5))\n @cards.push(Card.new('Six', suit, 6))\n @cards.push(Card.new('Seven', suit, 7))\n @cards.push(Card.new('Eight', suit, 8))\n @cards.push(Card.new('Nine', suit, 9))\n @cards.push(Card.new('Ten', suit, 10))\n @cards.push(Card.new('Jack', suit, 10))\n @cards.push(Card.new('Queen', suit, 10))\n @cards.push(Card.new('King', suit, 10))\n end\n end", "def shuffle\r\n @playable_cards = []\r\n SUITES.each do |suite|\r\n NAME_VALUES.each do |name, value|\r\n @playable_cards << Card.new(suite, name, value)\r\n end \r\n end\r\n puts \"PLAYABLE CARDS\"\r\n end", "def create_deck\n all_cards = []\n # Hearts ♥\n all_cards << ace_of_hearts = Ace.new('A', 'hearts', \"♥\")\n all_cards << king_of_hearts = Card.new('K', 'hearts', 10, \"♥\")\n all_cards << queen_of_hearts = Card.new('Q', 'hearts', 10, \"♥\")\n all_cards << jack_of_hearts = Card.new('J', 'hearts', 10, \"♥\")\n all_cards << ten_of_hearts = Card.new('10', 'hearts', 10, \"♥\")\n all_cards << nine_of_hearts = Card.new('9', 'hearts', 9, \"♥\")\n all_cards << eight_of_hearts = Card.new('8', 'hearts', 8, \"♥\")\n all_cards << seven_of_hearts = Card.new('7', 'hearts', 7, \"♥\")\n all_cards << six_of_hearts = Card.new('6', 'hearts', 6, \"♥\")\n all_cards << five_of_hearts = Card.new('5', 'hearts', 5, \"♥\")\n all_cards << four_of_hearts = Card.new('4', 'hearts', 4, \"♥\")\n all_cards << three_of_hearts = Card.new('3', 'hearts', 3, \"♥\")\n all_cards << two_of_hearts = Card.new('2', 'hearts', 2, \"♥\")\n # Spades ♠\n all_cards << ace_of_spades = Ace.new('A', 'spades', \"♠\")\n all_cards << king_of_spades = Card.new('K', 'spades', 10, \"♠\")\n all_cards << queen_of_spades = Card.new('Q', 'spades', 10, \"♠\")\n all_cards << jack_of_spades = Card.new('J', 'spades', 10, \"♠\")\n all_cards << ten_of_spades = Card.new('10', 'spades', 10, \"♠\")\n all_cards << nine_of_spades = Card.new('9', 'spades', 9, \"♠\")\n all_cards << eight_of_spades = Card.new('8', 'spades', 8, \"♠\")\n all_cards << seven_of_spades = Card.new('7', 'spades', 7, \"♠\")\n all_cards << six_of_spades = Card.new('6', 'spades', 6, \"♠\")\n all_cards << five_of_spades = Card.new('5', 'spades', 5, \"♠\")\n all_cards << four_of_spades = Card.new('4', 'spades', 4, \"♠\")\n all_cards << three_of_spades = Card.new('3', 'spades', 3, \"♠\")\n all_cards << two_of_spades = Card.new('2', 'spades', 2, \"♠\")\n # Diamonds ♦\n all_cards << ace_of_diamonds = Ace.new('A', 'diamonds', \"♦\")\n all_cards << king_of_diamonds = Card.new('K', 'diamonds', 10, \"♦\")\n all_cards << queen_of_diamonds = Card.new('Q', 'diamonds', 10, \"♦\")\n all_cards << jack_of_diamonds = Card.new('J', 'diamonds', 10, \"♦\")\n all_cards << ten_of_diamonds = Card.new('10', 'diamonds', 10, \"♦\")\n all_cards << nine_of_diamonds = Card.new('9', 'diamonds', 9, \"♦\")\n all_cards << eight_of_diamonds = Card.new('8', 'diamonds', 8, \"♦\")\n all_cards << seven_of_diamonds = Card.new('7', 'diamonds', 7, \"♦\")\n all_cards << six_of_diamonds = Card.new('6', 'diamonds', 6, \"♦\")\n all_cards << five_of_diamonds = Card.new('5', 'diamonds', 5, \"♦\")\n all_cards << four_of_diamonds = Card.new('4', 'diamonds', 4, \"♦\")\n all_cards << three_of_diamonds = Card.new('3', 'diamonds', 3, \"♦\")\n all_cards << two_of_diamonds = Card.new('2', 'diamonds', 2, \"♦\")\n # Clubs ♣\n all_cards << ace_of_clubs = Ace.new('A', 'clubs', \"♣\")\n all_cards << king_of_clubs = Card.new('K', 'clubs', 10, \"♣\")\n all_cards << queen_of_clubs = Card.new('Q', 'clubs', 10, \"♣\")\n all_cards << jack_of_clubs = Card.new('J', 'clubs', 10, \"♣\")\n all_cards << ten_of_clubs = Card.new('10', 'clubs', 10, \"♣\")\n all_cards << nine_of_clubs = Card.new('9', 'clubs', 9, \"♣\")\n all_cards << eight_of_clubs = Card.new('8', 'clubs', 8, \"♣\")\n all_cards << seven_of_clubs = Card.new('7', 'clubs', 7, \"♣\")\n all_cards << six_of_clubs = Card.new('6', 'clubs', 6, \"♣\")\n all_cards << five_of_clubs = Card.new('5', 'clubs', 5, \"♣\")\n all_cards << four_of_clubs = Card.new('4', 'clubs', 4, \"♣\")\n all_cards << three_of_clubs = Card.new('3', 'clubs', 3, \"♣\")\n all_cards << two_of_clubs = Card.new('2', 'clubs', 2, \"♣\")\n all_cards\nend", "def initialize()\n # Cards table, containing cards hashes\n setAllCards()\n end", "def test_card_exists\n card = Card.new(\"What is the capital of Alaska?\", \"Juneau\", :Geography)\n turn = Turn.new(\"Juneau\", card)\n\n assert_equal card, turn.card\n end", "def card_detection\n end", "def test_suit()\n expected = \"spades\"\n actual = @card1.suit()\n assert_equal(expected,actual)\n end", "def initialize\n @cards = Card::VALID_RANKS.flat_map do |rank|\n Suit::VALID_SUITS.each.flat_map do |suit|\n Card.new(rank, Suit.new(suit))\n end\n end.shuffle\n end", "def initialize\n suits = [\"Heart\", \"Diamond\", \"Spade\", \"Club\"]\n values = [:Two, :Three, :Four, :Five, :Six, :Seven,\n :Eight, :Nine, :Ten, :Jack, :Queen, :King, :Ace]\n\n @cards = []\n suits.each do |suit|\n values.each do |value|\n @cards << Card.new(suit, value)\n end\n end\n shuffle!\n end", "def initialize(cards)\n # If more than one card exists in the deck (i.e. cards are an array)\n if cards.class == Array\n @cards = cards\n # If only one card exists in the deck (cards.class == Card)\n else\n @cards = Array.new([cards])\n end\n end", "def test_sorting_the_deck\n card_1 = Card.new(\"4\",\"Hearts\")\n card_2 = Card.new(\"3\", \"Clubs\")\n card_3 = Card.new(\"5\", \"Diamonds\")\n deck = Deck.new([card_1, card_2, card_3])\n assert_equal [card_2, card_1, card_3], deck.sorting_the_deck\n end", "def initialize\n @cards = SEEDS.map do |seed|\n VALUES.map do |value|\n Card.new(value, seed)\n end\n end\n @cards.flatten!\n @cards.shuffle!\n end", "def build_card\n @items = game.reset_items\n @card = BingoBuilder::Card.new(@game.title, @game.size)\n add_mandatory_items\n add_discretionary_items\n @card\n end", "def initialize\n\t\t@cards = (1..52).to_a\n\tend", "def initialize\n @cards = []\n @players = []\n @cards_thrown = []\n cards_json = File.read('cards.json')\n cards_data = JSON.load cards_json\n cards_data.each do |data|\n title = false\n type = ''\n data.each do |card|\n if title\n save_card(card, type)\n title = false\n else\n type = card\n title = true\n end\n end\n end\n end", "def test_draw_several_cards\n cards = @deck.draw(4)\n assert_equal(48, @deck.count)\n assert_equal(4, cards.length)\n end", "def initialize(card, board_name, actions)\n @card_id = card.id\n @card_name = card.name\n @board_id = card.board_id\n @board_name = board_name\n @actions = actions\n @labels = card.card_labels\n end", "def has_card? test_card\n @cards.each do |card|\n if card.to_string==test_card.to_string\n return true\n end\n end\n false\n end", "def cards_attributes=(cards)\n @cards = []\n cards.each do |card|\n @cards << Card.new(card)\n end\n end", "def shuffle\n @playable_cards = []\n SUITS.each do |suite|\n NAME_VALUES.each do |name, value|\n @playable_cards << Card.new(suite, name, value)\n end\n end\n end", "def each\n @card_list.each\n end", "def create_52_card_deck\n\n end", "def test_initial_card_count \n assert_equal(52, @deck.count)\n assert_equal(52, @deck.cards.length)\n end", "def test_it_has_a_suit\n card = Card.new(\"Ace\", \"Spades\")\n assert_equal \"Ace\", card.suit\n end", "def test_round_has_guesses\n card_1 = Card.new(\"3\", \"Hearts\")\n card_2 = Card.new(\"4\", \"Clubs\")\n deck = Deck.new([card_1, card_2])\n round = Round.new(deck)\n assert_equal [], round.guesses\n end", "def each\r\n @card_list.each\r\n end", "def initialize_cards\n cards = []\n 4.times { cards += (2..14).to_a }\n cards.sample(52)\n end", "def card_factory(unformatted_cards)\n unformatted_cards.each do |hash|\n add_cards_to_deck(Card.new(hash))\n end \n end", "def test_guess_card_return\n card = Card.new(\"10\", \"Hearts\")\n guess = Guess.new(\"10 of Hearts\", card)\n\n assert_equal guess.card, card\n end", "def test_cards_have_a_suit\n card = Card.new\n #we haven't defined suit in Card class\n assert [\"Hearts\",\"Clubs\", \"Diamonds\",\"Spades\"] \"Suit should be one of hearts, clubs, diamonds, or spades.\"\n end", "def cards\n object.game_cards.map do |gc|\n { id: gc.card.id, word: gc.card.word, identity: gc.identity }\n end\n end", "def cards(options = { :filter => :open })\n return @cards if @cards\n @cards = Client.get(\"/boards/#{id}/cards\").json_into(Card)\n end", "def initialize\n @ranks = %w(1 2 3 4 5 6 7 8 9 10 11 12)\n @suits = %w(Spades Diamonds Clubs Hearts)\n @cards = []\n generate_deck\n \n\n end", "def place(card)\n end", "def generate_a_deck\n Card::SUITS.map do |suit|\n Card::RANKS.map do |rank|\n Card.new(suit: suit, rank: rank)\n end\n end.flatten\n end", "def initialize(properties)\n @card = properties\n end", "def card\n false\n end", "def build_card(data)\n Card.new(\n bank: self,\n id: data['contrato']['numerodecontrato'],\n name: data['panmdp'],\n avaliable: money(data['saldoDisponible']),\n amount: money(data['saldoDispuesto']),\n pan: data['panmdp'],\n description: data['descripcion'],\n contract_id: data['contrato']['producto'],\n is_credit: data['tipoTarjeta'].to_s == \"credit\"\n )\n end", "def initialize\r\n @pack = []\r\n possible = Card.ranks ** Card.suits\r\n possible.each { |combo| @pack.push(Card.new(combo[0], combo[1])) }\r\n end", "def initialize\n # Could add options so that game can be created with different amounts of cards depending upon the game being created\n\n deck = Array.new\n\n Card::VALID_SUITS.each do |vs|\n Card::VALID_NUMBERS.each do |vn|\n deck.push Blackjack::Card.new(vs, vn)\n end\n end\n @deck = deck.shuffle\n end", "def test_the_round_exists\n card_1 = Card.new(\"3\", \"Hearts\")\n card_2 = Card.new(\"4\", \"Clubs\")\n deck = Deck.new([card_1, card_2])\n round = Round.new(deck)\n assert_instance_of Round, round\n end", "def test_draw_one_card\n cards = @deck.draw\n assert_equal(51, @deck.count)\n assert_equal(1, cards.length)\n end", "def deal_cards\n\t\t\tend", "def card_on_file(card)\n all_cards = cards.map(&:card)\n end", "def take_card(card)\n @cards << card\n end", "def test_sorting_the_deck_large\n card_1 = Card.new(\"4\",\"Hearts\")\n card_2 = Card.new(\"3\", \"Clubs\")\n card_3 = Card.new(\"5\", \"Diamonds\")\n card_4 = Card.new(\"1\",\"Hearts\")\n card_5 = Card.new(\"Jack\", \"Clubs\")\n card_6 = Card.new(\"Ace\", \"Diamonds\")\n card_7 = Card.new(\"7\", \"Diamonds\")\n deck = Deck.new([card_1, card_2, card_3, card_4, card_5, card_6, card_7])\n assert_equal [card_4, card_2, card_1, card_3, card_7, card_5, card_6], deck.sorting_the_deck\n end", "def start\n card_1 = Card.new(\"What is 5 + 5?\", \"10\", :STEM)\n card_2 = Card.new(\"What is Rachel's favorite animal?\", \"not panda\", \"Turing Staff\".to_sym)\n card_3 = Card.new(\"What is Mike's middle name?\", \"nobody knows\", \"Turing Staff\".to_sym)\n card_4 = Card.new(\"What cardboard cutout lives at Turing?\", \"Justin Bieber\", \"Pop Culture\".to_sym)\n deck = Deck.new([card_1, card_2, card_3, card_4])\n Round.new(deck)\n end", "def initialize(name)\n @name = name\n @cards = []\n end", "def initialize(card_values)\n @cards = CARD_SUITS.flat_map do |suit|\n CARD_NAMES.map(&:to_s).map do |name|\n Card.new(name: name, suit: suit)\n end\n end\n end", "def createDeck\n\t\t10.times do |f|\n\t\t\t@deck.push(Card.new(5, 5, 5, '5 cost minion'))\n\t\tend\n\t\t10.times do |f|\n\t\t\t@deck.push(Card.new(2, 2, 2, '2 cost minion'))\n\t\tend\n\t\t10.times do |f|\n\t\t\t@deck.push(Card.new(1, 1, 1, '1 cost minion'))\n\t\tend\t\t\n\t\t@deck.shuffle!\t\n\tend", "def my_recipe_cards\n RecipeCard.all.select do |recipecard|\n recipecard.recipe == self\n end\n end", "def get_card\n all_cards = self.deck.cards\n correct_cards = self.guesses.where(correct: true).map { |guess| guess.card }\n (all_cards - correct_cards).shuffle.sample\n end" ]
[ "0.707315", "0.70665234", "0.70665234", "0.70665234", "0.7052203", "0.7004935", "0.69747305", "0.69489425", "0.69261783", "0.6864857", "0.684946", "0.68325603", "0.68214726", "0.6771567", "0.6768702", "0.6721055", "0.66996026", "0.6685493", "0.66793084", "0.6665216", "0.6661636", "0.6660493", "0.6657418", "0.66557777", "0.66540956", "0.6648414", "0.6637274", "0.65927976", "0.65722466", "0.6558337", "0.65388787", "0.6536952", "0.6521759", "0.64838046", "0.64626414", "0.6436307", "0.6423097", "0.64228255", "0.6421436", "0.6416549", "0.64125127", "0.63954526", "0.63929266", "0.6391593", "0.6388842", "0.63876873", "0.638448", "0.6368868", "0.63679457", "0.63674384", "0.6367187", "0.6356355", "0.63250387", "0.63223654", "0.6321481", "0.6312698", "0.63099843", "0.6307328", "0.6299815", "0.6292221", "0.62921154", "0.6274614", "0.6271038", "0.62698996", "0.6264363", "0.62543553", "0.6253551", "0.62508005", "0.6250693", "0.62430966", "0.6234347", "0.62317425", "0.62315005", "0.6227767", "0.62097424", "0.6202632", "0.6201702", "0.61976486", "0.6195461", "0.61770314", "0.61701596", "0.6167907", "0.6155097", "0.6153953", "0.61533034", "0.6150821", "0.614485", "0.61399436", "0.6138578", "0.613077", "0.61295265", "0.6122049", "0.6118769", "0.6116657", "0.61100465", "0.6106904", "0.61042047", "0.6102344", "0.6102011", "0.6100622" ]
0.7157642
0
Generates a new persistence identifier, ensuring that no object exists for the new URI.
def generate_new_location_uri candidate = nil loop do candidate = uri_prefix + pid_generator.next_pid break unless exists?(candidate) end candidate end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _new_id\n @lock.synchronize do\n begin\n # Generate a random number. It's recommended to not store more than\n # 2**62 objects in the same store.\n id = rand(2**64)\n # Ensure that we don't have already another object with this ID.\n end while @in_memory_objects.include?(id) || @db.include?(id)\n\n id\n end\n end", "def new_id\n dbm = self.class.dbm\n\n max = dbm.keys.map { |k| k.to_i }.max || 0\n id = max + 1\n\n dbm[id.to_s] ||= \"\"\n\n id.to_s\n end", "def assign_identifier\n self.id ||= SecureRandom.uuid\n end", "def generate_id()\n return nil unless @name and @represents\n @id ||= Digest::SHA1.hexdigest(@name + @represents)[0..5].force_encoding('utf-8').to_s\n end", "def rebuild_id_uri\n self.id_uri = build_id_uri\n end", "def generate_new_id\n Util::UUID.generate\n end", "def newId\r\n @seed = @seed + 1\r\n \"X#{@seed}\"\r\n end", "def set_identifier\n self.identifier ||= SecureRandom.uuid\n end", "def generate_identifier\n self.identifier = Digest::MD5.hexdigest(\"NoteRecordIdentifier#{commit_token}#{Rails.application.config.try(:hash_salt)}\")[0..254]\n end", "def create_guid\n self.id ||= UUIDTools::UUID.random_create.to_s\n end", "def new_resource_id!\n uuid = Viziwiki::new_uuid\n # TODO write lock with create only\n #do\n # uuid = Viziwiki::new_uuid\n #unless lock_resource (uuid)\n uuid\n end", "def create_new_id\n @new_session = true\n self.class.generate_unique_id\n end", "def assign_new_id\n self.oid ||= (self.class.unscoped.maximum(:oid) || 0 ) + 1\n end", "def generate_new_id()\n\t\tbegin\n\t\t\t(id = rand(9000)+1000)\n\t\tend while @objects[id]\n\t\treturn id\n\tend", "def make_foreign_ID\r\n loop do\r\n ret = rand(2 ** 16) | rand(2 ** 16) << 16\r\n return ret if ret != @id\r\n end\r\n return 0\r\n end", "def basic_generate_id(str); end", "def assign_id\n self.uid = service.mint unless new_record? && uid.present?\n self.id = service.hash(uid)\n end", "def assign_id\n self.uid = service.mint unless new_record? && uid.present?\n self.id = service.hash(uid)\n end", "def create_id(parent)\n \"#{parent}/#{noid_service.mint}\"\n end", "def make_store_unknown\n self.store_id = nil\n save!\n end", "def new_id\n id = (@xid_next ||= 0)\n @xid_next += 1\n\n (id & @internal.resource_id_mask) | @internal.resource_id_base\n end", "def generate_id(str); end", "def id_generator; end", "def generate_identifier\n self.identifier ||= self.name.parameterize.underscore\n end", "def new_id\n @last_id ||= 0\n @last_id += 1\n end", "def new_id\n @last_id ||= 0\n @last_id += 1\n end", "def ensure_identifier\n # ensure an existing identifier is reserved (if needed for EZID)\n return resource.identifier.to_s if resource&.identifier&.identifier.present?\n\n resource.ensure_identifier(mint_id)\n end", "def assign_id\n Sufia::IdService.mint if Sufia.config.enable_noids\n end", "def make_id\n new_id = @id\n @id += 1\n new_id\n end", "def identify!\n self.id ||= SecureRandom.uuid\n end", "def new_id\n SecureRandom.uuid\n end", "def uri\n \"#{database.uri}/#{ensure_id}\"\n end", "def new_id\n @last_id ||= 0\n @last_id += 1\n end", "def generate_unique_id\n \"1.3.6.1.4.1.21367.2009.5.14.#{id}.#{Time.now.to_i}\"\n end", "def generate_new_id\n UUIDTools::UUID.random_create.to_s\n end", "def generate_uid\n begin\n # .uuid or .hex? both seem to do the same job\n self.uid = SecureRandom.uuid.gsub(/[-]/, '')\n end while self.class.exists?(uid: self.uid)\n end", "def generate_identifier\n self.identifier = Digest::MD5.hexdigest(\"PersonRecordIdentifier#{email}#{Rails.application.config.try(:hash_salt)}\")[0..254]\n end", "def generate_guid\n begin\n guid = SecureRandom.urlsafe_base64\n end while Person.where(:guid => guid).exists?\n self.guid = guid\n end", "def generate_guid\n begin\n guid = SecureRandom.urlsafe_base64\n end while Person.where(:guid => guid).exists?\n self.guid = guid\n end", "def set_identifier\n time_tag = \"#{Time.now.to_s}\".gsub(/[^0-9]/,'')[0,14]\n fingerprint_tag = \"#{fingerprint}\".gsub(/[^0-9a-zA-Z]/,'')[-6,6]\n self.identifier ||=\n begin\n case key_type\n when KEY_TYPE_USER\n user.gitolite_identifier\n #\"#{user.gitolite_identifier}_#{fingerprint_tag}_#{time_tag}\"\n when KEY_TYPE_DEPLOY\n \"#{user.gitolite_identifier}_#{fingerprint_tag}_#{time_tag}_#{DEPLOY_PSEUDO_USER}\"\n end\n end\n end", "def reserve_id(doi:)\n if id_exists?\n @resource.identifier.to_s\n else\n ezid_client.create_identifier(doi, status: 'reserved', profile: 'datacite')\n doi\n end\n end", "def create_guid\n self.guid = SecureRandom.uuid\n end", "def unique_identifier\n @u_id ||= \"T1\"\n @u_id = @u_id.succ\n end", "def generate_id \n end", "def ensure_id\n self[:_id] = ( id ? escape_doc_id : database.server.next_uuid )\n end", "def probably_unique_id\n @probably_unique_id||=complete_path.base26_hash\n end", "def create_new_id\n require 'securerandom'\n begin\n # by OpenSSL, or system provided entropy pool\n session_id = SecureRandom.hex(16)\n rescue NotImplementedError\n # never happens on modern systems\n require 'digest'\n d = Digest('SHA512').new\n now = Time::now\n d.update(now.to_s)\n d.update(String(now.usec))\n d.update(String(rand(0)))\n d.update(String($$))\n d.update('foobar')\n session_id = d.hexdigest[0, 32]\n end\n session_id\n end", "def assign_uuid\n self.uuid = UUIDTools::UUID.random_create.to_s\n self.document_number ||= Numerator.get_number\n end", "def set_id\n self.id = SecureRandom.random_number(9223372036854775807)\n end", "def generate_identity\n handle_name ||= username if respond_to?(:username)\n handle_name ||= short_name if respond_to?(:short_name)\n handle_name ||= name.parameterize(\"_\").gsub(\"-\",\"_\") if respond_to?(:name)\n\n self.handle = Handle.build_unique(self, handle_name)\n self.handle.identifiable = self\n\n self[identity_field] = handle.name\n instance_variable_set(:\"@#{identity_field}\", handle.name)\n end", "def ensure_id\n self[:_id] = ( id ? escape_doc_id : database.server.next_uuid )\n end", "def generate_id\n @mutex.synchronize { @current_id += 1 }\n end", "def assign_uuid\n self.id = UUIDTools::UUID.timestamp_create().to_s\n end", "def generate_id\n id = @id\n @id += 1\n id\n end", "def pstore_idpath_to_id\n @pstore_idpath_to_id ||= File.join('.', 'data', 'pstore', 'articles_idpath_to_id.pstore')\n end", "def persistent_id(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"id \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end", "def newrandombuildingid()\n while(true)\n if(@filename_pur.match(/^_/))\n id = \"\"\n else\n id = \"_\"\n end\n id += \"#{@filename_pur}_BD.#{@buildinggennr}\"\n if(@exportedid[id] == nil)\n break;\n end\n @buildinggennr += 1\n end\n return id\n end", "def get_new_uuid\n uuid = UUID.new\n return uuid.generate\n end", "def populate_id\n @id = Digest::SHA256.hexdigest(@source_url).slice(0, ID_LENGTH)\n end", "def new_id(id=nil)\n # self.class.new_id\n @new_id ||= -1\n if id\n @new_id = id if @new_id < id\n id\n else\n @new_id += 1\n end\n end", "def persistence_key #:nodoc:\n # initial_config[:persistence_key] ? parent.try(:persistence_key) ? \"#{parent.persistence_key}__#{initial_config[:persistence_key]}\".to_sym : initial_config[:persistence_key] : global_id.to_sym\n initial_config[:persistence_key] ? initial_config[:persistence_key] : global_id.to_sym\n end", "def create_unique_key\n begin\n self.unique_key = UrlShort.generate_key\n rescue ActiveRecord::RecordNotUnique\n if (count +=1) < 5\n retry\n else\n raise\n end\n end\n end", "def create_id_from_path(path)\n return nil if path.nil?\n\n path.gsub('/', '.').gsub(/^[0-9]*/, '')\n end", "def generate_guid\n loop do\n @guid = SecureRandom.urlsafe_base64\n break if !Venue.where(guid: guid).any?\n end\n self.guid = @guid\n end", "def id\n @id ||= \"%x-%s\" % [ Time.now.to_i, SecureRandom::hex(2) ]\n end", "def generate_temporary_id\n (Time.now.to_f*1000).to_i.to_s\n end", "def unique_id\n id || @generated_dom_id || (@generated_dom_id = Time.now.to_f.to_s.gsub('.', '_'))\n end", "def make_not_avid!\n namespace.__avid_instances__.delete_if { |i| i.object_id == object_id }\n end", "def make_id\n \"#{self.class.name.downcase}#{id}\"\n end", "def sneaky_create\n if self.id.nil? && sneaky_connection.prefetch_primary_key?(self.class.table_name)\n self.id = sneaky_connection.next_sequence_value(self.class.sequence_name)\n end\n\n attributes_values = skeaky_attributes_values\n\n # Remove the id field for databases like Postgres which will raise an error on id being NULL\n if self.id.nil? && !sneaky_connection.prefetch_primary_key?(self.class.table_name)\n attributes_values.reject! { |key,_| key.name == 'id' }\n end\n\n new_id = if attributes_values.empty?\n self.class.unscoped.insert sneaky_connection.empty_insert_statement_value\n else\n self.class.unscoped.insert attributes_values\n end\n\n @new_record = false\n !!(self.id ||= new_id)\n end", "def globally_unique_identifier\n super\n end", "def create_unique_id\n\t\tself.unique_id = loop do\n\t\t\trandom_token = SecureRandom.urlsafe_base64\n\t\t\tbreak random_token unless User.exists?(unique_id: random_token)\n\t\tend\n\tend", "def identifier\n @identifier ||= \"#{self.type_prefix}.#{Model::to_id(name)}\"\n end", "def generate_primary_key\n self[self.class.primary_key] ||= self.class.new_primary_key(10_000)\n end", "def identifier\n @identifier ||= \"#{self.type_prefix}.#{Model::to_id @schema.title}.#{Model::to_id name}\"\n end", "def __object_unique_id__\n name\n end", "def __object_unique_id__\n name\n end", "def create_sha1_id\n self.sha1_id = Digest::SHA1.hexdigest(\"#{self.id}-#{self.contactable_type}-#{self.contactable_id}\")\n end", "def unique_identifier\n Digest::MD5.hexdigest(@name.to_s)[0..9]\n end", "def get_new_id\n\t\t\n\t\tcount = 0 \t\t# Start at 0\n\n\t\twhile true\n\t\t\tcount += 1 # Increment\n\t\t\t# Break out of loop when ID found\n\t\t\tbreak if @templates[ count.to_s ].is_a? NilClass\n\t\tend\n\n\t\t# Raise error if out of range\n\t\traise RangeError, \"#{count} exceeds the planned range, may cause problems\" if count.to_s.length > 9\n\n\t\t# Return id in String form\n\t\tcount.to_s\n\n\tend", "def mint_uuid\n self.url_uuid ||= Time.now.to_i\n end", "def fire_duplicate_id(old_entity, new_entity); end", "def identifier\n @identifier ||= \"#{ATTRIBUTE_PREFIX}.#{Model::to_id @schema_ref}.#{Model::to_id @reference}\"\n end", "def generate_number(store)\n store.number = loop do\n random_number = Digest::SHA1.hexdigest([Time.now, rand].join)[0..5].upcase\n break random_number unless Store.exists?(number: random_number)\n end\n end", "def identify\n document.id = compose.join(\" \").identify if document.primary_key\n document.id = generate_id if document.id.blank?\n document.id\n end", "def create_record(init)\n subject.transaction(requires_new: true) do\n InternalId.create!(\n **scope,\n usage: usage_value,\n last_value: init.call(subject) || 0\n )\n end\n rescue ActiveRecord::RecordNotUnique\n lookup\n end", "def generate_uid\n if self.id && !self.uid\n self.uid = \"app-#{self.id}\"\n App.update_all({uid:self.uid}, {id: self.id})\n end\n return true\n end", "def save_identifier(record)\n raise \"This method must be implemented by subclass!\"\n end", "def unique_object_name_for(name)\n \"#{name}_#{SecureRandom.hex(5)}\"\n end", "def generate_slug!\n\t\tself.slug = self.id.to_s(36)\n\t\tsave\n\tend", "def identify\n Identity.new(self).create\n nil\n end", "def identify\n Identity.new(self).create\n nil\n end", "def dedupe_id\n raise NotImplementedError\n end", "def assign_id\n self.id = self.class.identifier(self.module, resource, action)\n end", "def generate_web_id\n proposed_id = nil\n while true\n proposed_id = (36 ** (WEB_ID_LENGTH - 1) +\n rand(36 ** WEB_ID_LENGTH - 36 ** (WEB_ID_LENGTH - 1))).to_s(36)\n break unless ::Item.find_by_web_id(proposed_id)\n end\n proposed_id\n end", "def generate_id\n Util::UUID.generate\n end", "def _next_id\n @@id -= 1\n @@id\n end", "def create_new_version!\n if self.new?\n raise DataCatalog::Error, \"document must be saved before versioning\"\n end\n unless self.id\n raise DataCatalog::Error, \"expected document to have an id\"\n end\n copy = self.dup\n copy.id = BSON::ObjectID.new.to_s\n copy.next_id = self.id\n copy.save!\n self.previous_id = copy.id\n copy\n end", "def generate_secure_id(overwrite = false)\n token = nil\n loop do\n token = SecureRandom.urlsafe_base64\n break unless Algorithm.exists?(secure_id: token)\n end\n self.secure_id = token if (self.secure_id == nil || overwrite)\n end", "def generate_generation_id_(seckey)\n # NOTE: Do hsetnx with '-1' to detect weather the seckey is already set\n if @redis.hsetnx @url, seckey, '-1'\n max_genid = @redis.hincrby @url, 'max-genid', 1\n @redis.hset @url, seckey, max_genid.to_s\n return max_genid.to_s\n else\n return @redis.hget @url, seckey\n end\n end" ]
[ "0.6663946", "0.65618205", "0.64491725", "0.6353967", "0.6203314", "0.62010306", "0.6195559", "0.6176102", "0.615472", "0.61157405", "0.61072636", "0.60505223", "0.6030096", "0.60107934", "0.5985302", "0.5984192", "0.597313", "0.597313", "0.5971608", "0.5967458", "0.5962256", "0.5959053", "0.59435993", "0.59418386", "0.59402883", "0.59402883", "0.59252995", "0.5899797", "0.58971757", "0.58817196", "0.5863335", "0.58543265", "0.58503574", "0.58490044", "0.58476335", "0.5846403", "0.5839352", "0.5833179", "0.5833179", "0.5794882", "0.5779074", "0.5772277", "0.5755356", "0.57254326", "0.5719782", "0.57111025", "0.5704649", "0.57030785", "0.5699513", "0.5679185", "0.5669382", "0.5656791", "0.5650146", "0.56496376", "0.5642575", "0.56003195", "0.5599661", "0.5576043", "0.55610347", "0.5551321", "0.5543637", "0.5538115", "0.553346", "0.54863787", "0.54828393", "0.54781246", "0.5471567", "0.54559183", "0.5449914", "0.54450387", "0.54430234", "0.5442358", "0.5435266", "0.54326993", "0.54297495", "0.5419671", "0.5419671", "0.54009557", "0.53971773", "0.5394118", "0.53907335", "0.538912", "0.5388245", "0.5381267", "0.5374155", "0.53735185", "0.5372499", "0.5363009", "0.5360815", "0.53589547", "0.5356692", "0.5356692", "0.5354379", "0.53538126", "0.5352624", "0.53517956", "0.5351654", "0.53493726", "0.5343965", "0.5335117" ]
0.6074885
11
Checks to see whether anything currently exists at the given location.
def exists?(location_uri) r = client[connection.api.object_url(location_uri_to_fedora3_pid(location_uri), format: 'xml')].head # without disabling redirection, we should not get 3xx here (200..299).cover? r.code rescue RestClient::ExceptionWithResponse => e return false if e.response.code.eql? 404 raise e end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def exists?(location_uri)\n raise NotImplementedError\n end", "def is_here?(element)\n element.exists?\n rescue\n false\n end", "def exists?\n !@not_found\n end", "def here?\n @locations.any?(&:here)\n end", "def exists?\n folder_location.present?\n end", "def exist?\n nil\n end", "def exist?\n true\n end", "def empty_location?(location)\n return @state[location[0]][location[1]] == nil\n end", "def exist?\n workspace_info.exist?\n end", "def exist?\n @lock.synchronize { valid? }\n end", "def exists?()\n #This is a stub, used for indexing\n end", "def exist?\n @local_path and @local_path.exist?\n end", "def exists?\n !@exists.nil? && @exists\n end", "def exists?\n !@exists.nil? && @exists\n end", "def exists?\n !@exists.nil? && @exists\n end", "def exists?\n # TODO: Expose window querying from driver\n url != ''\n end", "def exists?\n !@exists.nil? && @exists\n end", "def exists?\n !@exists.nil? && @exists\n end", "def exists?\n assert_exists\n true\n rescue NoMatchingWindowFoundException\n false\n end", "def check_location\n\t\tif locations.empty? or locations.all? {|location| location.marked_for_destruction? }\n\t errors.add(:base, 'Business must have at least one location')\n\t end\n\tend", "def exist?\n !find_exists.nil?\n end", "def location?\n !!self.location\n end", "def exist?(*args)\n find(*args) && true\n rescue NotFoundError\n false\n end", "def exists?\n zk.exists?(path)\n end", "def exists?()\n end", "def branch_exists?(location, branch_name)\n return false unless [:remote, :local].include? location\n prefix = location == :remote ? 'remotes/origin/' : ''\n all_branches.include?(prefix + branch_name)\n end", "def exist?\n\t\t\tClient.head @root\n\t\tend", "def exist?\n # shouldn't force network connections just to check if content exists\n # only check that the path is not empty\n !path.to_s.empty?\n end", "def exist?\n # shouldn't force network connections just to check if content exists\n # only check that the path is not empty\n !path.to_s.empty?\n end", "def exist?\n !entries.empty?\n end", "def exists?\n begin \n CouchSpring.get uri\n true\n rescue\n false\n end \n end", "def existent; end", "def exists?\n error_code.success?\n end", "def exists?\n @exists\n end", "def exists?\n validate_directory_structure\n end", "def exists?\n @exists == true\n end", "def exists?\n\t\treturn false\n\tend", "def exists?(location_ext_key)\n locations.any?{ |location| location[:external_key] == location_ext_key }\n end", "def exists?(path)\n !!scope.get(path)\n end", "def exist?\n stat ? true : false\n end", "def exist?(*args)\n alloc(*args).exist?\n end", "def exists?\n !count.zero?\n end", "def exist?\n !count.zero?\n end", "def exist?\n @exists\n end", "def validate_location(location)\n if @board.keys.to_a.include?(location)\n mark_board(location)\n else\n puts \"#{location} is not a valid location.\"\n # Increment to let the same player try again.\n increment_player_idx\n false\n end\n end", "def object_exists?(uri)\n url = uri\n request = Request.new(\"Get\", url)\n response = request.perform\n exists = (response and response.code.to_i == 200) ? true : false\n exists\n end", "def exist?\n request(:get)\n true\n rescue Stretcher::RequestError::NotFound\n false\n end", "def exists?\n false\n end", "def exists?\n false\n end", "def exists?\n assert_exists\n true\n rescue UnknownObjectException\n false\n end", "def exists?; end", "def resource_exists?\n reload!\n @exists = true\n rescue Google::Cloud::NotFoundError\n @exists = false\n end", "def exist\n\treturn true\n end", "def exist?\n !!@exist\n end", "def exist?\n !!@exist\n end", "def exists?\n File.exists?(File.join(@root))\n end", "def exists?\n !!@exists\n end", "def exists?\n factory.system.dir_exists?(@path)\n end", "def always_locate?\n always_locate_message\n true\n end", "def exist?\n raise NotImplementedError\n end", "def exists?\n true\n end", "def potentially_within_lookup?(full_dir_path)\n @lookup_paths.any? { |p| p.start_with? full_dir_path }\n end", "def exists?\n File.exist? absolute_path\n end", "def exist?\n File.exist?(index_file)\n end", "def location_information?\n [ :site, :building, :room, :freezer, :shelf, :box, :box_position ].detect { |l| self.send(l).present? }\n end", "def exist?\n ruby_gems_fetcher.started?\n end", "def any_locations?\r\n contacts.detect { |x| x && !x.address.nil? }\r\n end", "def exists?(path)\n eval(EXISTS_CHECK, binding, __FILE__, EXISTS_CHECK_LINE)\n nil\nend", "def exist?\n !closed? && window.present?\n end", "def exists?(path)\n @exists[path]\n end", "def contains?(loc)\n return loc.city == self.name\n end", "def exists!\n @exists = true\n end", "def exists?(object); end", "def exists?(object); end", "def has_location?(type, value)\n @locations.select { |loc| loc[:type] == type && loc[:value] == value }.any?\n end", "def exists? path\n end", "def exists?\n fail NotImplementedError\n end", "def folder_reachable?\n Dir.exists? folder_path\n end", "def caught_up?(location)\n string = connection.quote(location)\n\n # In case the host is a primary pg_last_wal_replay_lsn/pg_last_xlog_replay_location() returns\n # NULL. The recovery check ensures we treat the host as up-to-date in\n # such a case.\n query = <<-SQL.squish\n SELECT NOT pg_is_in_recovery()\n OR pg_wal_lsn_diff(pg_last_wal_replay_lsn(), #{string}) >= 0\n AS result\n SQL\n\n row = query_and_release(query)\n\n ::Gitlab::Utils.to_boolean(row['result'])\n rescue *CONNECTION_ERRORS\n false\n end", "def location?\n false\n end", "def exists?\n !@trace.nil?\n end", "def exists?\n status.exists? name\n end", "def exist?\n File.exist? fullpath\n end", "def file_location_exists\n if self.file_location.nil? || !File.exists?(self.file_location)\n errors.add(:file_location, \"doesn't exist on the server\")\n end\n end", "def exists?\n !data.empty?\n end", "def exists?\n ! Tainers::API.get_by_name(name).nil?\n end", "def contain?(location)\n @map.map.with_index { |v, i| i }.include? location.x and\n @map[location.x].map.with_index { |v, i| i }.include? location.y\n end", "def has_location?\n # Since we require presence of both lat&lon, checking for one\n # property is good enough.\n lat.present?\n end", "def exists?\n context.count > 0\n end", "def exists?\n this.count > 0\n end", "def exists?\n if performed?\n total != 0\n else\n limit(0).terminate_after(1).total != 0\n end\n end", "def exists?(path)\n head(path).empty? ? false : true\n end", "def marked?\n @location != nil\n end", "def check_if_business_location_is_set\n lookup_business_location unless business_location\n end", "def exists?(name)\r\n \t!template_paths(name).empty?\r\n end", "def exist?\n jobinfo.exist?\n end", "def exists?\n return @checked_paths[absolute_path] if @checked_paths.has_key? absolute_path\n @checked_paths[absolute_path] = File.exist? absolute_path\n end", "def storable_location?\n [\n request.get?,\n !request.xhr?,\n !unstorable?\n ].all?\n end", "def exists?\n @lxc.exists?(self.name)\n end", "def empty?(location) \n\t\trow=(location-1)/4 #takes the value of location (1-9) and converts it into a row coordinate 0, 1, or 2\n\t\tcolumn=(location+3)%4 #takes the value of location (1-9) and converts it into a column coordinate 0, 1, or 2\n\t\treturn true if @board[row][column]==0 #if the location that the player just entered is equal to 0, which means \n\t\t#it has not been played yet, then return true, otherwise, return false.\n\t\treturn false\n\tend" ]
[ "0.7274327", "0.6738706", "0.6724346", "0.6704184", "0.6701831", "0.63999087", "0.63611555", "0.63513106", "0.63443905", "0.63250864", "0.6246865", "0.6222583", "0.6213896", "0.6213896", "0.6213896", "0.62010026", "0.61985993", "0.61985993", "0.6178999", "0.6174857", "0.61539906", "0.61503553", "0.61200994", "0.61061716", "0.6094058", "0.60782385", "0.60662895", "0.6062745", "0.6062745", "0.60620713", "0.6059777", "0.6045321", "0.60390455", "0.60356116", "0.60304636", "0.602597", "0.6024237", "0.60225385", "0.60209626", "0.6000569", "0.5993222", "0.5992978", "0.59917694", "0.59866166", "0.59721184", "0.5965504", "0.5965323", "0.59578735", "0.59578735", "0.59575844", "0.59469956", "0.5945101", "0.59388334", "0.592165", "0.592165", "0.5920125", "0.59155804", "0.59143466", "0.5913801", "0.59068954", "0.5899909", "0.5897479", "0.5895853", "0.58914083", "0.5888271", "0.58829445", "0.58766454", "0.5875006", "0.58690244", "0.58664435", "0.58584636", "0.58543706", "0.58523905", "0.58523905", "0.5851485", "0.5842332", "0.5837156", "0.5835637", "0.5834191", "0.5832482", "0.5827795", "0.5826309", "0.5823322", "0.5795495", "0.57954234", "0.578557", "0.57785225", "0.57766396", "0.57746786", "0.57693094", "0.57670164", "0.5766646", "0.5755231", "0.57520807", "0.57473993", "0.5738331", "0.5735421", "0.5729135", "0.572819", "0.57257366" ]
0.6895828
1
GET /organizations GET /organizations.json
def index return unless params[:type] == 'building' @organizations = @organizations.only_categories(%w[Fraternity Sorority Independent Blitz Concessions]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_organizations\n params = {\n 'method' => :get,\n 'command' => '/org'\n }\n\n response, headers = send_request(params)\n orgs = response.css('OrgList Org')\n\n results = {}\n orgs.each do |org|\n results[org['name']] = org['href'].gsub(\"#{@api_url}/org/\", \"\")\n end\n results\n end", "def get_organizations\n begin\n github_api_setup.organizations.list\n rescue Exception => e\n logger.error \"Github #get_organizations error #{e}\"\n end\n end", "def GetOrgs params = {}\n\n params = params.merge(path: 'organizations.json')\n APICall(params)\n\n end", "def find_all_organizations\n get_url(\"https://api.github.com/users/#{current_user.username}/orgs\")\n end", "def organization\n _get(\"/account/organization\") { |json| json }\n end", "def GetOrg id\n\n APICall(path: \"organizations/#{id}.json\")\n\n end", "def orgs\n client.organizations\n end", "def index\n @organizations = Organization.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organizations }\n end\n end", "def index\n @organizations = Organization.where(:id => current_user.organization_id)\n \n respond_with(@organizations)\n end", "def show\n organization = current_user.organizations.find(params[:id])\n if organization\n render json: organization, status: 200\n else\n head 404\n end\n end", "def index\n @organizations = Organization.all\n respond_with(@organizations)\n end", "def index\n @organizations = Organization.all\n respond_with @organizations\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def organizations\n\t@organizations = Organization.all\n\t@organization_names = []\n\t@organizations.each do |o|\n\t\t@organization_names << o.name\n\tend\n\t\n\trespond_to do |format|\n\t\tformat.html { render :json => @organization_names }\n\tend\n end", "def index\r\n @orgs = Org.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @orgs }\r\n end\r\n end", "def query_organizations(options = nil)\n require_relative 'telerivet/organization'\n self.cursor(Organization, get_base_api_path() + \"/organizations\", options)\n end", "def list \n @organizations = Organization.all\n \n render \"list\"\n end", "def organization(name, params = {})\n http.get \"/organization/#{name}\", params\n end", "def organization(name, params = {})\n http.get \"/organization/#{name}\", params\n end", "def list_organizations\r\n Organization.organizations_by_user(self)\r\n end", "def find_organizations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: OrganizationsApi#find_organizations ...\"\n end\n \n # resource path\n path = \"/organizations\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'attribute'] = opts[:'attribute'] if opts[:'attribute']\n query_params[:'value'] = opts[:'value'] if opts[:'value']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<OrganizationComposite>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: OrganizationsApi#find_organizations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n render json: Organization.all\n end", "def account_organization\n get('account/organization')\n end", "def index\n @organizations = Organization.page(params[:page]).per_page(9).order(\"name DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organizations }\n end\n end", "def find_organizations\n Organization.all\n end", "def current_user_oganizations\n endpoint = '/api/user/orgs'\n @logger.debug(\"Getting current user organizations (GET #{endpoint})\") if @debug\n get(endpoint)\n end", "def index\n @orgs = Org.all\n end", "def index\n\t\t@organizations = Organization.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @organizations }\n\t\tend\n\tend", "def organizations\r\n OrganizationsController.instance\r\n end", "def index\n @organizations = Spree::Organization.all\n end", "def get_organisations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BlueOceanApi.get_organisations ...'\n end\n # resource path\n local_var_path = '/blue/rest/organizations/'\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 = nil\n auth_names = ['jenkins_auth']\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 => 'Organisations')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BlueOceanApi#get_organisations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @user_organizations = UserOrganization.all\n end", "def index\n redirect_to :root unless current_user.is_admin?\n @organizations = Organization.all\n end", "def orgs\n @orgs = Organization.find(:all, :order => 'name ASC')\n\n respond_to do |format|\n format.html # orgs.html.erb\n format.xml { render :xml => @orgs }\n end\n end", "def index\n @organizations = Organization.by_query(params[:q])\n end", "def get_organization_info\n path = \"/d2l/api/lp/#{$lp_ver}/organization/info\"\n _get(path)\n # return: Organization JSON block\nend", "def orgs(params = {})\n params.merge!(key: 'orgs')\n objects_from_response(Code42::Org, :get, 'org', params)\n end", "def organizations\n if Interface.first.nil?\n redirect_to root_url and return\n end\n\n respond_to do |format|\n format.html {\n render partial: 'organization'\n }\n end\n end", "def own_organizations\n api.org_memberships.select { |org| org[:role] == \"admin\"}\n end", "def show\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organization }\n end\n end", "def show\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organization }\n end\n end", "def show\n cf_get(path: \"/organizations/#{org_id}\")\n end", "def index\n if current_user.super_admin?\n @organisations = Organisation.all.order(:id)\n render json: @organisations.to_json\n else\n head :no_content\n end\n end", "def index\n @organization_accounts = OrganizationAccount.all.sort_by(&:organization_name).reverse\n \n if user_signed_in? && current_user.admin?\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organization_accounts }\n end\n else\n redirect_to root_path\n end\n end", "def orgs\n @orgs ||= begin\n client.organizations.map(&:login)\n rescue Octokit::Unauthorized, Faraday::ConnectionFailed\n []\n end\n end", "def index\n @clients_organizations = ClientsOrganization.all\n end", "def list\n @connection.get('/user/orgs').map do |org_data|\n GitHubApi::Org.new(self, org_data)\n end\n end", "def index\n @admins_organizations = Organization.all\n end", "def get(*args)\n arguments(args, required: [:org_name])\n\n get_request(\"/orgs/#{arguments.org_name}\", arguments.params)\n end", "def org_dashboard\n respond_to do |format|\n format.html { @organization = Organization.first }\n format.json { render json: Organization.first }\n end\n end", "def get_organizations\n org_references =\n locations.each_with_object({}) do |loc, acc|\n reference = loc.resource.managingOrganization.reference\n org_id = reference.match(ID_MATCHER)[1]\n\n acc[org_id] ||= []\n acc[org_id] << loc\n end\n\n facility_identifiers = org_references&.keys&.join(',')\n org_response = organization_service.search(_id: facility_identifiers, _count: '100')\n\n org_response&.resource&.entry\n end", "def index\n @organization = Organization.find_by_id(params[:organization_id])\n if @organization\n @users = @organization.users\n else\n @status = :fail\n @data = {organization: \"Organization #{params[:organization_id]} not found.\"}\n render status: :not_found, json: json_response(:fail, data: @data)\n end\n end", "def index\n @organizations = Organization.find(:all, :order => 'name ASC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @organizations }\n end\n end", "def index\n organizations = if params[:q]\n CclaSignature.search(params[:q])\n else\n Organization.includes(:ccla_signatures)\n end\n\n respond_to do |format|\n format.json do\n render json: organizations.to_json(only: [:id], methods: [:company])\n end\n end\n end", "def get_user_organizations(user_id)\n raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?\n\n get \"#{users_path}/#{user_id}/organizations\"\n end", "def organization_teams\n get(\"/organizations/#{@default_org_slug}/teams/\")\n end", "def get(incoming={})\n opts = HttpClient::Helper.symbolize_keys(incoming)\n query = {\n :guid => HttpClient::Preconditions.assert_class_or_nil('guid', HttpClient::Helper.to_uuid(opts.delete(:guid)), String),\n :user_guid => HttpClient::Preconditions.assert_class_or_nil('user_guid', HttpClient::Helper.to_uuid(opts.delete(:user_guid)), String),\n :key => HttpClient::Preconditions.assert_class_or_nil('key', opts.delete(:key), String),\n :name => HttpClient::Preconditions.assert_class_or_nil('name', opts.delete(:name), String),\n :limit => HttpClient::Preconditions.assert_class_or_nil('limit', opts.delete(:limit), Integer),\n :offset => HttpClient::Preconditions.assert_class_or_nil('offset', opts.delete(:offset), Integer)\n }.delete_if { |k, v| v.nil? }\n @client.request(\"/organizations\").with_query(query).get.map { |hash| Apidoc::Models::Organization.new(hash) }\n end", "def index\n @orgs ||= Github::Org.orgs(\n current_user_github_access_token,\n current_github_username\n )\n end", "def find_organizations(opts = {})\n data, status_code, headers = find_organizations_with_http_info(opts)\n return data\n end", "def get_user_github_organizations(github_orgs_url)\n uri = URI.parse(github_orgs_url)\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = uri.scheme == 'https'\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n response = http.request(Net::HTTP::Get.new(uri.request_uri))\n\n user_organizations = JSON.parse(response.body)\n user_organizations.map { |o| o['login'] }\n end", "def index\n authorize @organization\n render :json => @organization.tags\n end", "def orgs(enterprise = 'default')\n @api.orgs enterprise\n end", "def org_show_data\n org = Organization.find(params[:org])\n\n @data = {\n name: org.name,\n website: org.website,\n logo_link: org.logo_link,\n users: user_names_and_emails_from_org(org)\n }\n\n render json: @data\n end", "def index\n @people = current_organization.people.all\n end", "def list_org\n @users = User.where(organization: true)\n\n render \"list_org\"\n end", "def index\n @organizations = Organization.order(sort_column + \" \" + sort_direction).page(params[:page])\n\n respond_to do |format|\n format.html\n format.json { render json: @organizations }\n end\n end", "def show\n authorize @organization_membership\n render json: @organization_membership\n end", "def index\n # Get page number\n page = params[:page].nil? ? 1 : params[:page]\n\n if current_user.admin?\n @organizations = Organization.all.paginate(page: page, per_page: PAGE_COUNT)\n else\n if current_user.organization\n redirect_to current_user.organization\n else\n redirect_to new_organization_path\n end\n end\n end", "def get_orgs_list(grafana_options)\n grafana_options[:method] = 'Get'\n grafana_options[:success_msg] = 'The list of organizations has been successfully retrieved.'\n grafana_options[:unknown_code_msg] = 'OrganizationApi::get_orgs_list unchecked response code: %{code}'\n grafana_options[:endpoint] = '/api/orgs/'\n\n _do_request(grafana_options)\n rescue BackendError\n nil\n end", "def show\n @organization_profile = OrganizationProfile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organization_profile }\n end\n end", "def show\n @organization = Organization.find(params[:id])\n end", "def index\n @search = params[:search] || Hash.new\n @search[:name_contains] = params[:term] if params[:term]\n @search.each do |k,v|\n if !v.blank? && Organization::SEARCHABLE.include?( k.to_sym )\n @organizations = @organizations.send k, v\n end\n end\n @organizations = @organizations.page(params[:page])\n\n\n respond_to do |format|\n format.html { render action: 'index' } # index.html.erb\n format.json { render json: @organizations.map { |o| { id: o.id, label: o.name, value: o.name(:last_first) } } }\n format.xml { render :xml => @organizations }\n end\n end", "def show\n @organization = Organization.find(params[:id])\n respond_with @organization\n end", "def index\n @group_organizations = GroupOrganization.all\n end", "def retrieve_organization(name = nil)\n name ||= organization_name\n org = Organization.find_by(name: name)\n halt_with_json_response(404, INVALID_ORG, 'organization does not exist') \\\n if org.nil?\n return org\n end", "def get_by_key(key)\n HttpClient::Preconditions.assert_class('key', key, String)\n @client.request(\"/organizations/#{CGI.escape(key)}\").get { |hash| Apidoc::Models::Organization.new(hash) }\n end", "def all_organizations\n admin? ? Organization.all : organizations.map(&organization_mapper(false)).flatten\n end", "def org_members\n @members = @github.orgs.members.list APP_CONF['org']\n render json: @members\n end", "def index\n @organization_memberships = OrganizationMembership.where(user_id: params['user_id'])\n authorize @organization_memberships\n\n render json: @organization_memberships\n end", "def index\n render json: current_org.users\n end", "def active_organizations\n admin? ? Organization.all : organizations.map(&organization_mapper).flatten\n end", "def org\n client.org(org_id)\n end", "def org\n client.org(org_id)\n end", "def index\n if search_params \n logger.debug \"Got params: #{search_params}\"\n @organization = Organization.find(search_params)\n else\n logger.debug \"No params!\"\n end\n # @organizations = Organization.all\n end", "def org(id = \"my\", params = {})\n object_from_response(Code42::Org, :get, \"org/#{id}\", params)\n end", "def show\n case current_user.role.name\n when \"Viewer\", \"User\"\n head :no_content\n return\n when \"Manager\", \"Admin\", \"SuperAdmin\"\n else\n raise \"User with email = \\\"#{current_user.email}\\\" has an invalid role!\"\n end\n render json: @organisation.as_json(\n only: [:id, :name],\n include: {\n organisation_units: {\n only: [:id, :name],\n include: {\n users: {\n only: [:id, :name],\n include: {\n role: { only: [:name] }\n }\n }\n }\n },\n }\n )\n end", "def get_organization_by_id(id)\n require_relative 'telerivet/organization'\n Organization.new(self, self.do_request(\"GET\", get_base_api_path() + \"/organizations/#{id}\"))\n end", "def index\n @sourcing_orgs = SourcingOrg.all\n end", "def organizations \n puts \"List of organizations:\"\nend", "def get_information_all_companies()\n\t\tpage = 275\n\t\tbegin\n\t\t\turl = create_url(\"organizations\",\"\",page)\n\t\t\tputs \"Reading #{url}\"\n\t\t\tresult = read_url(url)\n\t\t\t#save_json(result, [\"organizations\"])\n\n\t\t\tadd_organization_info(result,\"name\")\n\t\t\tadd_organization_info(result,\"path\")\n\t\t\t\n\t\t\tnext_url = result['data']['paging']['next_page_url']\n\t\t\tpage = page + 1\n\t\tend while next_url != nil\n\t\tcreate_permalink(@paths)\n\t\tsave_json(\"\", [\"names\", \"paths\", \"permalinks\"])\n\tend", "def show\n @external_organization = ExternalOrganization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @external_organization }\n end\n end", "def index\n @organization = current_user.organization\n @merits = @organization.merits\n end" ]
[ "0.80765116", "0.80071", "0.78597564", "0.78338337", "0.78312206", "0.7745588", "0.7691283", "0.7672265", "0.76290935", "0.7590858", "0.7536119", "0.7533662", "0.7521284", "0.75053763", "0.75053763", "0.75053763", "0.75053763", "0.75053763", "0.75053763", "0.75053763", "0.75053763", "0.75053763", "0.75003576", "0.7459552", "0.74238825", "0.7423191", "0.74064505", "0.74064505", "0.7357264", "0.7353553", "0.7341248", "0.73080254", "0.73058045", "0.72576714", "0.72547036", "0.7234301", "0.7142644", "0.71310985", "0.71163946", "0.7108704", "0.7107696", "0.70913565", "0.70783454", "0.707133", "0.7065519", "0.70442355", "0.7034759", "0.7028269", "0.70132995", "0.70132995", "0.7013245", "0.6974229", "0.69214576", "0.68938667", "0.6885557", "0.68472105", "0.68455255", "0.68368435", "0.6836245", "0.6833144", "0.68022317", "0.6798124", "0.6792869", "0.6792308", "0.6789671", "0.6787703", "0.6787543", "0.6781702", "0.67770505", "0.6767805", "0.6752179", "0.67115045", "0.6705219", "0.6704132", "0.66987795", "0.66933274", "0.6674487", "0.6657487", "0.66493815", "0.66468114", "0.6620185", "0.661743", "0.6609138", "0.65819615", "0.65304035", "0.6525404", "0.6518936", "0.6513303", "0.65101445", "0.6500153", "0.64931446", "0.64931446", "0.6490563", "0.64766717", "0.64659196", "0.6454719", "0.64336836", "0.6418678", "0.6411601", "0.6403693", "0.6392693" ]
0.0
-1
GET /organizations/1 GET /organizations/1.json
def show @booth_chairs = @organization.booth_chairs @tools = Tool.checked_out_by_organization(@organization).just_tools @shifts = @organization.shifts @participants = @organization.participants @charges = @organization.charges end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetOrg id\n\n APICall(path: \"organizations/#{id}.json\")\n\n end", "def show\n organization = current_user.organizations.find(params[:id])\n if organization\n render json: organization, status: 200\n else\n head 404\n end\n end", "def index\n @organizations = Organization.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organizations }\n end\n end", "def get_organizations\n begin\n github_api_setup.organizations.list\n rescue Exception => e\n logger.error \"Github #get_organizations error #{e}\"\n end\n end", "def organization(name, params = {})\n http.get \"/organization/#{name}\", params\n end", "def organization(name, params = {})\n http.get \"/organization/#{name}\", params\n end", "def get_organizations\n params = {\n 'method' => :get,\n 'command' => '/org'\n }\n\n response, headers = send_request(params)\n orgs = response.css('OrgList Org')\n\n results = {}\n orgs.each do |org|\n results[org['name']] = org['href'].gsub(\"#{@api_url}/org/\", \"\")\n end\n results\n end", "def organization\n _get(\"/account/organization\") { |json| json }\n end", "def index\n @organizations = Organization.where(:id => current_user.organization_id)\n \n respond_with(@organizations)\n end", "def index\r\n @orgs = Org.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @orgs }\r\n end\r\n end", "def GetOrgs params = {}\n\n params = params.merge(path: 'organizations.json')\n APICall(params)\n\n end", "def index\n @organizations = Organization.all\n respond_with(@organizations)\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n respond_with @organizations\n end", "def find_all_organizations\n get_url(\"https://api.github.com/users/#{current_user.username}/orgs\")\n end", "def index\n @organizations = Organization.all\n end", "def show\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organization }\n end\n end", "def show\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organization }\n end\n end", "def index\n render json: Organization.all\n end", "def index\n @organizations = Organization.page(params[:page]).per_page(9).order(\"name DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organizations }\n end\n end", "def get_organization_info\n path = \"/d2l/api/lp/#{$lp_ver}/organization/info\"\n _get(path)\n # return: Organization JSON block\nend", "def list \n @organizations = Organization.all\n \n render \"list\"\n end", "def find_organizations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: OrganizationsApi#find_organizations ...\"\n end\n \n # resource path\n path = \"/organizations\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'attribute'] = opts[:'attribute'] if opts[:'attribute']\n query_params[:'value'] = opts[:'value'] if opts[:'value']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n _header_accept = ['application/json']\n _header_accept_result = @api_client.select_header_accept(_header_accept) and header_params['Accept'] = _header_accept_result\n\n # HTTP header 'Content-Type'\n _header_content_type = []\n header_params['Content-Type'] = @api_client.select_header_content_type(_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<OrganizationComposite>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: OrganizationsApi#find_organizations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n cf_get(path: \"/organizations/#{org_id}\")\n end", "def orgs\n client.organizations\n end", "def index\n @orgs = Org.all\n end", "def organizations\n\t@organizations = Organization.all\n\t@organization_names = []\n\t@organizations.each do |o|\n\t\t@organization_names << o.name\n\tend\n\t\n\trespond_to do |format|\n\t\tformat.html { render :json => @organization_names }\n\tend\n end", "def org_dashboard\n respond_to do |format|\n format.html { @organization = Organization.first }\n format.json { render json: Organization.first }\n end\n end", "def account_organization\n get('account/organization')\n end", "def show\n @organization = Organization.find(params[:id])\n end", "def organizations\r\n OrganizationsController.instance\r\n end", "def index\n\t\t@organizations = Organization.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @organizations }\n\t\tend\n\tend", "def index\n @organizations = Organization.by_query(params[:q])\n end", "def query_organizations(options = nil)\n require_relative 'telerivet/organization'\n self.cursor(Organization, get_base_api_path() + \"/organizations\", options)\n end", "def show\n @organization_profile = OrganizationProfile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organization_profile }\n end\n end", "def show\n @organization = Organization.find(params[:id])\n respond_with @organization\n end", "def retrieve_organization(name = nil)\n name ||= organization_name\n org = Organization.find_by(name: name)\n halt_with_json_response(404, INVALID_ORG, 'organization does not exist') \\\n if org.nil?\n return org\n end", "def index\n @organizations = Spree::Organization.all\n end", "def index\n redirect_to :root unless current_user.is_admin?\n @organizations = Organization.all\n end", "def find_organizations\n Organization.all\n end", "def index\n @user_organizations = UserOrganization.all\n end", "def index\n @organization = Organization.find_by_id(params[:organization_id])\n if @organization\n @users = @organization.users\n else\n @status = :fail\n @data = {organization: \"Organization #{params[:organization_id]} not found.\"}\n render status: :not_found, json: json_response(:fail, data: @data)\n end\n end", "def index\n @organizations = Organization.find(:all, :order => 'name ASC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @organizations }\n end\n end", "def orgs\n @orgs = Organization.find(:all, :order => 'name ASC')\n\n respond_to do |format|\n format.html # orgs.html.erb\n format.xml { render :xml => @orgs }\n end\n end", "def organizations\n if Interface.first.nil?\n redirect_to root_url and return\n end\n\n respond_to do |format|\n format.html {\n render partial: 'organization'\n }\n end\n end", "def get(*args)\n arguments(args, required: [:org_name])\n\n get_request(\"/orgs/#{arguments.org_name}\", arguments.params)\n end", "def org(id = \"my\", params = {})\n object_from_response(Code42::Org, :get, \"org/#{id}\", params)\n end", "def get(incoming={})\n opts = HttpClient::Helper.symbolize_keys(incoming)\n query = {\n :guid => HttpClient::Preconditions.assert_class_or_nil('guid', HttpClient::Helper.to_uuid(opts.delete(:guid)), String),\n :user_guid => HttpClient::Preconditions.assert_class_or_nil('user_guid', HttpClient::Helper.to_uuid(opts.delete(:user_guid)), String),\n :key => HttpClient::Preconditions.assert_class_or_nil('key', opts.delete(:key), String),\n :name => HttpClient::Preconditions.assert_class_or_nil('name', opts.delete(:name), String),\n :limit => HttpClient::Preconditions.assert_class_or_nil('limit', opts.delete(:limit), Integer),\n :offset => HttpClient::Preconditions.assert_class_or_nil('offset', opts.delete(:offset), Integer)\n }.delete_if { |k, v| v.nil? }\n @client.request(\"/organizations\").with_query(query).get.map { |hash| Apidoc::Models::Organization.new(hash) }\n end", "def current_user_oganizations\n endpoint = '/api/user/orgs'\n @logger.debug(\"Getting current user organizations (GET #{endpoint})\") if @debug\n get(endpoint)\n end", "def index\n if current_user.super_admin?\n @organisations = Organisation.all.order(:id)\n render json: @organisations.to_json\n else\n head :no_content\n end\n end", "def get_organization_by_id(id)\n require_relative 'telerivet/organization'\n Organization.new(self, self.do_request(\"GET\", get_base_api_path() + \"/organizations/#{id}\"))\n end", "def show\n @external_organization = ExternalOrganization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @external_organization }\n end\n end", "def list_organizations\r\n Organization.organizations_by_user(self)\r\n end", "def get_by_key(key)\n HttpClient::Preconditions.assert_class('key', key, String)\n @client.request(\"/organizations/#{CGI.escape(key)}\").get { |hash| Apidoc::Models::Organization.new(hash) }\n end", "def get_organisations_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BlueOceanApi.get_organisations ...'\n end\n # resource path\n local_var_path = '/blue/rest/organizations/'\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 = nil\n auth_names = ['jenkins_auth']\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 => 'Organisations')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BlueOceanApi#get_organisations\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @clients_organizations = ClientsOrganization.all\n end", "def show\n @environment = current_user.organization.environments.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @environment }\n end\n end", "def index\n @organization_accounts = OrganizationAccount.all.sort_by(&:organization_name).reverse\n \n if user_signed_in? && current_user.admin?\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organization_accounts }\n end\n else\n redirect_to root_path\n end\n end", "def show\n authorize @organization_membership\n render json: @organization_membership\n end", "def index\n @admins_organizations = Organization.all\n end", "def own_organizations\n api.org_memberships.select { |org| org[:role] == \"admin\"}\n end", "def index\n organizations = if params[:q]\n CclaSignature.search(params[:q])\n else\n Organization.includes(:ccla_signatures)\n end\n\n respond_to do |format|\n format.json do\n render json: organizations.to_json(only: [:id], methods: [:company])\n end\n end\n end", "def org_show_data\n org = Organization.find(params[:org])\n\n @data = {\n name: org.name,\n website: org.website,\n logo_link: org.logo_link,\n users: user_names_and_emails_from_org(org)\n }\n\n render json: @data\n end", "def index\n @organizations = Organization.order(sort_column + \" \" + sort_direction).page(params[:page])\n\n respond_to do |format|\n format.html\n format.json { render json: @organizations }\n end\n end", "def index\n @orgs ||= Github::Org.orgs(\n current_user_github_access_token,\n current_github_username\n )\n end", "def index\n @people = current_organization.people.all\n end", "def orgs(params = {})\n params.merge!(key: 'orgs')\n objects_from_response(Code42::Org, :get, 'org', params)\n end", "def organization organization_id, cached_token=token\n uri = URI.parse(\"https://anypoint.mulesoft.com/accounts/api/organizations/#{organization_id}\")\n client = Net::HTTP.new(uri.host, uri.port)\n client.use_ssl = true\n\n request = Net::HTTP::Get.new(uri.request_uri)\n request.add_field(\"Authorization\", \"Bearer #{cached_token}\")\n\n response = client.request(request)\n\n return JSON.parse(response.body)\n end", "def org\n client.org(org_id)\n end", "def org\n client.org(org_id)\n end", "def show\r\n @org = Org.from_param(params[:abbr])\r\n # @jobs = Job.find(Curation.where(:org_id => @org.id).pluck(:job_id))\r\n @jobs = @org.jobs\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @org }\r\n end\r\n end", "def index\n # Get page number\n page = params[:page].nil? ? 1 : params[:page]\n\n if current_user.admin?\n @organizations = Organization.all.paginate(page: page, per_page: PAGE_COUNT)\n else\n if current_user.organization\n redirect_to current_user.organization\n else\n redirect_to new_organization_path\n end\n end\n end", "def get_user_github_organizations(github_orgs_url)\n uri = URI.parse(github_orgs_url)\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = uri.scheme == 'https'\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n response = http.request(Net::HTTP::Get.new(uri.request_uri))\n\n user_organizations = JSON.parse(response.body)\n user_organizations.map { |o| o['login'] }\n end", "def get_user_organizations(user_id)\n raise Auth0::MissingUserId, 'Must supply a valid user_id' if user_id.to_s.empty?\n\n get \"#{users_path}/#{user_id}/organizations\"\n end", "def get_organizations\n org_references =\n locations.each_with_object({}) do |loc, acc|\n reference = loc.resource.managingOrganization.reference\n org_id = reference.match(ID_MATCHER)[1]\n\n acc[org_id] ||= []\n acc[org_id] << loc\n end\n\n facility_identifiers = org_references&.keys&.join(',')\n org_response = organization_service.search(_id: facility_identifiers, _count: '100')\n\n org_response&.resource&.entry\n end", "def show\n @organ = Organ.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organ }\n end\n end", "def index\n authorize @organization\n render :json => @organization.tags\n end", "def index\n render json: current_org.users\n end", "def show\n case current_user.role.name\n when \"Viewer\", \"User\"\n head :no_content\n return\n when \"Manager\", \"Admin\", \"SuperAdmin\"\n else\n raise \"User with email = \\\"#{current_user.email}\\\" has an invalid role!\"\n end\n render json: @organisation.as_json(\n only: [:id, :name],\n include: {\n organisation_units: {\n only: [:id, :name],\n include: {\n users: {\n only: [:id, :name],\n include: {\n role: { only: [:name] }\n }\n }\n }\n },\n }\n )\n end", "def index\n @group_organizations = GroupOrganization.all\n end", "def find_organization\n @organization = Organization.find(params[:organization_id])\n end", "def index\n @search = params[:search] || Hash.new\n @search[:name_contains] = params[:term] if params[:term]\n @search.each do |k,v|\n if !v.blank? && Organization::SEARCHABLE.include?( k.to_sym )\n @organizations = @organizations.send k, v\n end\n end\n @organizations = @organizations.page(params[:page])\n\n\n respond_to do |format|\n format.html { render action: 'index' } # index.html.erb\n format.json { render json: @organizations.map { |o| { id: o.id, label: o.name, value: o.name(:last_first) } } }\n format.xml { render :xml => @organizations }\n end\n end", "def show\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def index\n @organization_memberships = OrganizationMembership.where(user_id: params['user_id'])\n authorize @organization_memberships\n\n render json: @organization_memberships\n end", "def index\n if search_params \n logger.debug \"Got params: #{search_params}\"\n @organization = Organization.find(search_params)\n else\n logger.debug \"No params!\"\n end\n # @organizations = Organization.all\n end", "def list_org\n @users = User.where(organization: true)\n\n render \"list_org\"\n end", "def show\n @organization = Organization.find(params[:id])\n @address = @organization.address\n @member = Member.new\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def organization_teams\n get(\"/organizations/#{@default_org_slug}/teams/\")\n end", "def org_members\n @members = @github.orgs.members.list APP_CONF['org']\n render json: @members\n end", "def list\n @connection.get('/user/orgs').map do |org_data|\n GitHubApi::Org.new(self, org_data)\n end\n end", "def show\n @organization = current_user.organization\n end" ]
[ "0.7965355", "0.7789723", "0.7624976", "0.76014984", "0.75791377", "0.75791377", "0.75518954", "0.7519814", "0.74602246", "0.74229765", "0.7412952", "0.7383728", "0.7383559", "0.7383559", "0.7383559", "0.7383559", "0.7383559", "0.7383559", "0.7383559", "0.7383559", "0.7383559", "0.73825437", "0.73576486", "0.73490685", "0.7316738", "0.7316738", "0.72754604", "0.72455674", "0.7211236", "0.7186702", "0.7161037", "0.7154822", "0.7125796", "0.7124134", "0.70706636", "0.70245826", "0.7014641", "0.7011128", "0.69999534", "0.69630075", "0.6957113", "0.69350725", "0.69199747", "0.68781155", "0.68747586", "0.68743825", "0.6853471", "0.6851181", "0.68506324", "0.68443793", "0.68412125", "0.6808725", "0.67993337", "0.67981666", "0.6772103", "0.67623574", "0.6758727", "0.67547286", "0.67540437", "0.6732849", "0.6729809", "0.67246115", "0.6689021", "0.66730356", "0.6672913", "0.6647419", "0.66281456", "0.66230065", "0.6617488", "0.6606483", "0.6603194", "0.65953904", "0.6561981", "0.65604", "0.6555643", "0.65367585", "0.65364915", "0.65364915", "0.65260214", "0.6500989", "0.64982224", "0.649001", "0.64874667", "0.6487327", "0.6475932", "0.6464521", "0.6452377", "0.64430994", "0.6432239", "0.64304185", "0.6414206", "0.63979995", "0.6393904", "0.6387008", "0.6369483", "0.6352581", "0.6352581", "0.6348649", "0.6348477", "0.6331517", "0.6318389" ]
0.0
-1
GET /organizations/new GET /organizations/new.json
def new; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def new\r\n @org = Org.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @org }\r\n end\r\n end", "def new\n @organization = Organization.new\n @organization.name = params[:name]\n @organization.url = params[:url]\n @organization.homepage_url = params[:homepage_url]\n @organization.address = params[:address]\n\n authorize! :new, @organization\n\n @title = new_action_title\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def new\n @organizations = Organization.find(:all)\n @organization_user = OrganizationUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization_user }\n end\n end", "def new\n @organization = Organization.new\n end", "def new\n @organization = Organization.new\n end", "def new\n @organization = Organization.new\n end", "def new\n @organization = Organization.new\n end", "def new\n @organization = Organization.new\n end", "def new\n @user = User.new(:organization_id => current_org.id)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user }\n end\n end", "def new\n @organ = Organ.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organ }\n end\n end", "def new\n @organization = Organization.new\n respond_with(@organization)\n end", "def new\n @organization_profile = OrganizationProfile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization_profile }\n end\n end", "def new\n @organism = Organism.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organism }\n end\n end", "def new\n @organization_account = OrganizationAccount.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization_account }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def new\n @external_organization = ExternalOrganization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @external_organization }\n end\n end", "def new\n\t@user = User.new\n\t@organizations = Organization.all\n end", "def create\r\n @org = Org.new(params[:org])\r\n\r\n respond_to do |format|\r\n if @org.save\r\n format.html { redirect_to @org, notice: 'Org was successfully created.' }\r\n format.json { render json: @org, status: :created, location: @org }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @org.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @organization = Organization.new(params[:organization])\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to admin_organizations_path, notice: \"Organization #{@organization.name} was successfully created.\" }\n format.json { render json: @organization, status: :created, location: @organization }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @organisation = Organisation.new\n end", "def new\n @organisation = Organisation.new\n end", "def new\n @organization = Organization.new\n session[:breadcrumbs].add \"New\"\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def new\n\t\t@organization = Organization.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @organization }\n\t\tend\n\tend", "def create\n @organization = Organization.new(organization_params)\n\n if @organization.save\n render :show, status: :created, location: @organization\n else\n render json: @organization.errors, status: :unprocessable_entity\n end\n end", "def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization }\n end\n end", "def new\n @organization = Organization.new\n respond_with @organization\n end", "def new\n @location = @organization.locations.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @location }\n end\n end", "def new\n @organization = Organization.new\n @organization.user_id = session[:user_id]\n\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n respond_to do |format|\n if @organization.save\n format.html { redirect_to organization_path(@organization), notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @org = authed_user.orgs.build(org_params)\n\n respond_to do |format|\n if @org.save\n format.html { redirect_to @org, notice: 'Org was successfully created.' }\n format.json { render :show, status: :created, location: @org }\n else\n format.html { render :new }\n format.json { render json: @org.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @owner = Owner.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @owner }\n end\n end", "def new\n @serviceorg = Serviceorg.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serviceorg }\n end\n end", "def create\n authorize! :create, Organization\n @organization = Organization.new(organization_params)\n respond_to do |format|\n if @organization.save\n format.js\n format.json { render :show, status: :created, location: @organization }\n else\n format.js { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @person = Person.new\n @companies = Company.pluck(:name)\n\n authorize! :create, Person\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @participating_organization = ParticipatingOrganization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @participating_organization }\n end\n end", "def new\n @orgao = Orgao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @orgao }\n end\n end", "def create\n @organization = Organization.new(params[:organization])\n if @organization.save\n flash[:notice] = VALIDATION_MESSAGE[\"ORGANIZATION\"][\"CREATE\"]\n redirect_to admin_organization_path(@organization.id)\n else\n flash[:error] = @organization.errors.full_messages.join(\", \")\n render('new')\n end\n end", "def new\n @person = people_type.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n authorize! :create, Project\n \n @project = Project.new\n puts @project\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @organism = Organism.new\n end", "def new\n @company = Company.new(:name => 'default')\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @company }\n end\n end", "def new\n @projects_person = ProjectsPerson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @projects_person }\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n # create an associated Org_user\n @org_user = OrgUser.new\n @org_user.organization_id = @organization.id\n @org_user.user_id = current_user.id\n @org_user.save\n\n # On default create a membership to the OrgUser/Admin/person_that_created_the_org\n @membership = Membership.new\n @membership.individual_id = current_user.individual.id\n @membership.organization_id = @organization.id\n @membership.save\n\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render action: 'show', status: :created, location: @organization }\n else\n format.html { render action: 'new' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @people_organization = PeopleOrganization.new(people_organization_params)\n\n respond_to do |format|\n if @people_organization.save\n format.html { redirect_to @people_organization, notice: 'People organization was successfully created.' }\n format.json { render :show, status: :created, location: @people_organization }\n else\n format.html { render :new }\n format.json { render json: @people_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repository }\n end\n end", "def new\n @repository = Repository.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @repository }\n end\n end", "def new\n @environment = @project.environments.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @environment }\n end\n end", "def new\n @organization_detail = OrganizationDetail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization_detail }\n end\n end", "def new\n @project = Project.new :company_id => params[:company_id]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def create\n @organization = Organization.new(permitted_params)\n\n authorize! :create, @organization\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render json: @organization, status: :created, location: @organization }\n else\n format.html {\n existing_organization = Organization.with_url(@organization.url)\n if existing_organization.nil?\n @title = new_action_title; render action: \"new\"\n else\n redirect_to existing_organization, :notice => \"Organization has already been submitted.\"\n end\n }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @panel_organization_invitation = Panel::OrganizationInvitation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @panel_organization_invitation }\n end\n end", "def new\n @organ = Organ.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organ }\n end\n end", "def new\n @breadcrumb = 'create'\n @entity = Entity.new\n @towns = towns_dropdown\n @provinces = provinces_dropdown\n @zipcodes = zipcodes_dropdown\n @regions = Region.order(:name)\n @countries = Country.order(:name)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entity }\n end\n end", "def create\n @orgn = Orgn.new(orgn_params)\n\n respond_to do |format|\n if @orgn.save\n format.html { redirect_to @orgn, notice: 'Orgn was successfully created.' }\n format.json { render :show, status: :created, location: @orgn }\n else\n format.html { render :new }\n format.json { render json: @orgn.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @person = Person.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @territory = Territory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @territory }\n end\n end", "def new\n @person = Person.new\n @person.org = Org.find(params[:org]) if params[:org]\n @person.needs_office_space = true\n @person.from_date = Date.today\n @person.to_date = nil\n authorize! :create, @person\n\n respond_to do |format|\n format.html # new.html.erb\n format.js\n format.json { render json: @person }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @company = Company.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @company }\n end\n end", "def new\n @organization_status = OrganizationStatus.new(organization: @organization)\n respond_with @organization_status\n end", "def create\n @organization = current_user.build_organization(organization_params)\n respond_to do |format|\n if @organization.save\n format.html { redirect_to root_path, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organisation = Organisation.new(organisation_params)\n\n respond_to do |format|\n if @organisation.save\n format.html { redirect_to @organisation, notice: 'Organisation was successfully created.' }\n format.json { render :show, status: :created, location: @organisation }\n else\n format.html { render :new }\n format.json { render json: @organisation.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @person = @organisation.people.build\n authorize! :create, @person\n respond_to do |format|\n format.html\n format.js\n end\n end", "def new\n @gitto = Gitto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gitto }\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Place was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(params[:organization])\n\n respond_to do |format|\n if @organization.save\n flash[:notice] = 'Organization was successfully created.'\n format.html { redirect_to(@organization) }\n format.xml { render :xml => @organization, :status => :created, :location => @organization }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\r\n @company = Company.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @company }\r\n end\r\n end", "def new\n @client_org_orderable = ClientOrgOrderable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client_org_orderable }\n end\n end", "def new\n @entity = Entity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entity }\n end\n end", "def new\n @organization_member = OrganizationMember.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @organization_member }\n end\n end", "def new\n @project = current_user.projects.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @project }\n end\n end", "def new\n @organization_user = @organization.organization_users.new\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def new\n @person = Person.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @person }\n end\n end", "def create\n @organization_membership = OrganizationMembership.new(organization_membership_create_params)\n # authorize @organization_membership\n\n if @organization_membership.save\n render json: @organization_membership, status: :created, location: nil\n else\n render json: @organization_membership.errors, status: :unprocessable_entity\n end\n end", "def new\n @distro = Distro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @distro }\n end\n end", "def new\n @distro = Distro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @distro }\n end\n end", "def new\n @environment = Environment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @environment }\n end\n end", "def create\n @organization_profile = OrganizationProfile.new(params[:organization_profile])\n\n respond_to do |format|\n if @organization_profile.save\n format.html { redirect_to @organization_profile, notice: 'Organization profile was successfully created.' }\n format.json { render json: @organization_profile, status: :created, location: @organization_profile }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organization_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @corp_location = CorpLocation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @corp_location }\n end\n end" ]
[ "0.80002916", "0.80002916", "0.79110706", "0.7769764", "0.74969125", "0.7459801", "0.7459801", "0.7459801", "0.7459801", "0.7459801", "0.74499846", "0.7448206", "0.7431489", "0.7401061", "0.7384301", "0.73354286", "0.73137957", "0.7312422", "0.7312422", "0.7299635", "0.7295927", "0.72741574", "0.7259706", "0.7255205", "0.7255205", "0.72195643", "0.7211597", "0.7079275", "0.70639724", "0.70164716", "0.6991808", "0.6977392", "0.6920034", "0.6920034", "0.6920034", "0.6920034", "0.6911976", "0.68763185", "0.68471557", "0.68430716", "0.68269634", "0.6821844", "0.6800542", "0.67991483", "0.67890555", "0.67750335", "0.677212", "0.6766512", "0.6766152", "0.6766145", "0.6748429", "0.6748051", "0.6745811", "0.6745811", "0.67414737", "0.6739125", "0.6738126", "0.6734612", "0.6724808", "0.6715736", "0.6714379", "0.6706905", "0.6700001", "0.66959167", "0.6693069", "0.668828", "0.668828", "0.668828", "0.668828", "0.668828", "0.668828", "0.668828", "0.668828", "0.668828", "0.668828", "0.6685327", "0.66850114", "0.6684378", "0.6677995", "0.66554344", "0.6650883", "0.66308016", "0.66260415", "0.6612926", "0.6610075", "0.6605693", "0.66055274", "0.660184", "0.659424", "0.659424", "0.659424", "0.659424", "0.659424", "0.659424", "0.659424", "0.659124", "0.65894455", "0.65894455", "0.65692085", "0.6569121", "0.65686065" ]
0.0
-1
POST /organizations POST /organizations.json
def create @organization.save respond_with(@organization) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def CreateOrganization params = {}\n \n APICall(path: 'organizations.json',method: 'POST',payload: params.to_json)\n \n end", "def create\n @organization = Organization.new(params[:organization])\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to admin_organizations_path, notice: \"Organization #{@organization.name} was successfully created.\" }\n format.json { render json: @organization, status: :created, location: @organization }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n if @organization.save\n render :show, status: :created, location: @organization\n else\n render json: @organization.errors, status: :unprocessable_entity\n end\n end", "def create\n @org = authed_user.orgs.build(org_params)\n\n respond_to do |format|\n if @org.save\n format.html { redirect_to @org, notice: 'Org was successfully created.' }\n format.json { render :show, status: :created, location: @org }\n else\n format.html { render :new }\n format.json { render json: @org.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n @organization.access_token = ('a'..'z').to_a.shuffle[0,32].join\n\n respond_to do |format|\n if @organization.save\n OrganizationMembership.create(user_id: current_user.id, organization_id: @organization.id, admin: true)\n params[:departments].each do |d_id|\n DepartmentEntry.create(context: @organization, department_id: d_id)\n end\n format.html { redirect_to :dashboard, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = current_user.build_organization(organization_params)\n respond_to do |format|\n if @organization.save\n format.html { redirect_to root_path, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n respond_to do |format|\n if @organization.save\n format.html { redirect_to organization_path(@organization), notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @admins_organization = Organization.new(admins_organization_params)\n\n respond_to do |format|\n if @admins_organization.save\n format.html { redirect_to @admins_organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @admins_organization }\n else\n format.html { render :new }\n format.json { render json: @admins_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n # create an associated Org_user\n @org_user = OrgUser.new\n @org_user.organization_id = @organization.id\n @org_user.user_id = current_user.id\n @org_user.save\n\n # On default create a membership to the OrgUser/Admin/person_that_created_the_org\n @membership = Membership.new\n @membership.individual_id = current_user.individual.id\n @membership.organization_id = @organization.id\n @membership.save\n\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render action: 'show', status: :created, location: @organization }\n else\n format.html { render action: 'new' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @people_organization = PeopleOrganization.new(people_organization_params)\n\n respond_to do |format|\n if @people_organization.save\n format.html { redirect_to @people_organization, notice: 'People organization was successfully created.' }\n format.json { render :show, status: :created, location: @people_organization }\n else\n format.html { render :new }\n format.json { render json: @people_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n @organization.assignments << Assignment.new({user: current_user, organization: @organization, is_admin: true, is_active: true})\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_organization = UserOrganization.new(user_organization_params)\n\n respond_to do |format|\n if @user_organization.save\n format.html { redirect_to @user_organization, notice: 'User organization was successfully created.' }\n format.json { render :show, status: :created, location: @user_organization }\n else\n format.html { render :new }\n format.json { render json: @user_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(name: params[:name], owner: params[:username]) #owner: params[:username]\n if @organization.save\n #binding.pry\n @owner = @organization.employees.new(username: params[:username], \n password: params[:password], \n organization_id: @organization.id,\n email: params[:email],\n admin: true)\n if @owner.save\n render \"create.json.jbuilder\", status: :created\n else\n render json: { errors: @owner.errors.full_messages }, status: :unprocessable_entity\n end\n\n else\n render json: { errors: @organization.errors.full_messages }, status: :unprocessable_entity\n end\n end", "def create\n @organization = current_user.organizations.build(params[:organization])\n if @organization.save\n redirect_to @organization, :flash => { :success => \"Profile created!\" }\n else\n render 'pages/home'\n end\n end", "def create\r\n @org = Org.new(params[:org])\r\n\r\n respond_to do |format|\r\n if @org.save\r\n format.html { redirect_to @org, notice: 'Org was successfully created.' }\r\n format.json { render json: @org, status: :created, location: @org }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @org.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def post(organization_form)\n HttpClient::Preconditions.assert_class('organization_form', organization_form, Apidoc::Models::OrganizationForm)\n @client.request(\"/organizations\").with_json(organization_form.to_json).post { |hash| Apidoc::Models::Organization.new(hash) }\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Place was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization_membership = OrganizationMembership.new(organization_membership_create_params)\n # authorize @organization_membership\n\n if @organization_membership.save\n render json: @organization_membership, status: :created, location: nil\n else\n render json: @organization_membership.errors, status: :unprocessable_entity\n end\n end", "def create\n current_user.organization_users.build(organization_user_params)\n @organization = Organization.find(organization_user_params[:organization_id])\n respond_to do |format|\n if current_user.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render json: @organization, status: :created, location: @organization }\n else\n format.html { redirect_to @organization, error: 'Organization creation failed.' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n respond_to do |format|\n if @organization.save\n current_user.add_role :editor, @organization\n format.html { redirect_to organizations_path, notice: 'Thank you for your submission. It will be published once it is reviewed by the staff.' }\n format.json { render action: 'show', status: :created, location: @organization }\n else\n format.html { render action: 'new' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Spree::Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Spree::Organization was successfully created.' }\n format.json { render action: 'show', status: :created, location: @organization }\n else\n format.html { render action: 'new' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize! :create, Organization\n @organization = Organization.new(organization_params)\n respond_to do |format|\n if @organization.save\n format.js\n format.json { render :show, status: :created, location: @organization }\n else\n format.js { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organisation = Organisation.new(organisation_params)\n\n respond_to do |format|\n if @organisation.save\n format.html { redirect_to @organisation, notice: 'Organisation was successfully created.' }\n format.json { render :show, status: :created, location: @organisation }\n else\n format.html { render :new }\n format.json { render json: @organisation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n if params[\"organization\"][\"org_type\"] == \"Other\"\n params[\"organization\"][\"org_type\"] = params[\"org_type_text\"]\n end\n @organization = Organization.new(organization_params)\n\n if params[\"organization\"][\"org_type\"] == \"Shelter\" && params[:availability_status] == \"Available\"\n @organization.availability = true\n else\n @organization.availability = false\n end \n\n respond_to do |format|\n if @organization.save\n session[:organization_id] = @organization.id\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n else\n format.html { redirect_to new_organization_path, flash: {errors: @organization.errors} }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to new_project_path, notice: 'Organization was successfully created.' }\n format.json { render :show, status: :created, location: @organization }\n @organization.memberships.create(user_id: current_user.id)\n organization_info = {\n pretext: \"A new organization has been created.\",\n fallback: \"#{@organization.name}: #{@organization.description}\",\n title: \"#{@organization.name}\",\n title_link: \"#{organization_url(@organization)}\",\n text: \"#{@organization.description}\",\n color: \"#BDD6DD\",\n }\n PROJECT501_NOTIFIER.ping(attachments: [organization_info])\n else\n format.html { render :new }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n respond_to do |format|\n if @organization.save && @organization.associate_user(current_user, ['admin'])\n User.add_user_to_group(@organization, ['admin'], params[:admin1_email], params[:admin1_first_name], params[:admin1_last_name], params[:admin1_phone] ) if (params[:admin1_email].present?)\n User.add_user_to_group(@organization, ['admin'], params[:admin2_email], params[:admin2_first_name], params[:admin2_last_name], params[:admin2_phone] ) if (params[:admin2_email].present?)\n \n format.html { redirect_to organization_path(@organization), notice: 'Organization was successfully created.' }\n format.json { render action: 'show', status: :created, location: @organization }\n else\n format.html { render action: 'new' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize @organization\n if @organization.update_attributes(tag_list: @tags)\n render :json => @organization.reload.tags, :status => :created\n else\n error!(:invalid_resource, @organization.errors, \"Tags have not been saved\")\n end\n end", "def create\n @organ = Organ.new(params[:organ])\n\n respond_to do |format|\n if @organ.save\n format.html { redirect_to @organ, notice: 'Organ was successfully created.' }\n format.json { render json: @organ, status: :created, location: @organ }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organ.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @address = Address.create!(params[:address])\n @organization = Organization.new(params[:organization])\n @organization.address = @address\n \n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render json: @organization, status: :created, location: @organization }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(params[:organization])\n if @organization.save\n flash[:notice] = VALIDATION_MESSAGE[\"ORGANIZATION\"][\"CREATE\"]\n redirect_to admin_organization_path(@organization.id)\n else\n flash[:error] = @organization.errors.full_messages.join(\", \")\n render('new')\n end\n end", "def create\n\t\t@organization = Organization.new(params[:organization])\n\n\t\trespond_to do |format|\n\t\t\tif @organization.save\n\t\t\t\tformat.html { redirect_to(@organization, :notice => 'Organization was successfully created.') }\n\t\t\t\tformat.xml { render :xml => @organization, :status => :created, :location => @organization }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def index\n @organizations = Organization.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organizations }\n end\n end", "def create\n @organization = Organization.new(params[:organization])\n \n \n respond_to do |format|\n if @organization.save\n User.updateOrg(current_user.id,@organization.id)\n \n @album = Album.new\n @album.name = @organization.name\n @album.save\n @organization.album_id = @album.id\n Organization.updateAlbum(@organization.id,@album.id)\n \n current_user.has_role!('owner', @organization)\n flash[:notice] = 'Organization was successfully created.'\n format.html { redirect_to(@organization) }\n format.xml { render :xml => @organization, :status => :created, :location => @organization }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @clients_organization = ClientsOrganization.new(clients_organization_params)\n\n respond_to do |format|\n if @clients_organization.save\n format.json { render :show, status: :created, location: @clients_organization }\n else\n format.json { render json: @clients_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @group_organization = GroupOrganization.new(group_organization_params)\n\n respond_to do |format|\n if @group_organization.save\n format.html { redirect_to @group_organization, notice: 'Group organization was successfully created.' }\n format.json { render :show, status: :created, location: @group_organization }\n else\n format.html { render :new }\n format.json { render json: @group_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organizer = Organizer.new(organizer_params)\n\n respond_to do |format|\n if @organizer.save\n format.html { redirect_to @organizer, notice: 'Organizer was successfully created.' }\n format.json { render :show, status: :created, location: @organizer }\n else\n format.html { render :new }\n format.json { render json: @organizer.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization_profile = OrganizationProfile.new(params[:organization_profile])\n\n respond_to do |format|\n if @organization_profile.save\n format.html { redirect_to @organization_profile, notice: 'Organization profile was successfully created.' }\n format.json { render json: @organization_profile, status: :created, location: @organization_profile }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organization_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n params[:organization][:tag_ids] ||= []\n @organization = Organization.new(params[:organization])\n\n respond_to do |format|\n if @organization.save\n flash[:notice] = t(\"organization.success_created\")\n format.html { redirect_to(@organization) }\n else\n @tag = Tag.new\n format.html { render :action => \"new\" }\n end\n end\n end", "def create\n @organization = Organization.new(params[:organization])\n\n respond_to do |format|\n if @organization.save\n flash[:notice] = 'Organization was successfully created.'\n format.html { redirect_to(@organization) }\n format.xml { render :xml => @organization, :status => :created, :location => @organization }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create(organization_name)\n organization = client.organization\n organization.name = organization_name\n organization.create!\n\n organization\n end", "def create_organisation_items\n create_organisation\n end", "def create\n @organization_profile = OrganizationProfile.new(organization_profile_params)\n current_user.organization_account.organization_profiles << @organization_profile \n authorize @organization_profile\n respond_to do |format|\n if @organization_profile.save\n format.html { redirect_to @organization_profile, notice: 'Organization profile was successfully created.' }\n format.json { render :show, status: :created, location: @organization_profile }\n else\n format.html { render :new }\n format.json { render json: @organization_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def index\n @organizations = Organization.all\n end", "def org_params\n params.require(:organization).permit(:name, :variety, {:user_ids =>[]})\n end", "def create\n @organization = Organization.new(permitted_params)\n\n authorize! :create, @organization\n\n respond_to do |format|\n if @organization.save\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render json: @organization, status: :created, location: @organization }\n else\n format.html {\n existing_organization = Organization.with_url(@organization.url)\n if existing_organization.nil?\n @title = new_action_title; render action: \"new\"\n else\n redirect_to existing_organization, :notice => \"Organization has already been submitted.\"\n end\n }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @external_organization = ExternalOrganization.new(params[:external_organization])\n\n respond_to do |format|\n if @external_organization.save\n format.html { redirect_to @external_organization, notice: 'External organization was successfully created.' }\n format.json { render json: @external_organization, status: :created, location: @external_organization }\n else\n format.html { render action: \"new\" }\n format.json { render json: @external_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def organizations\r\n OrganizationsController.instance\r\n end", "def organizations\n\t@organizations = Organization.all\n\t@organization_names = []\n\t@organizations.each do |o|\n\t\t@organization_names << o.name\n\tend\n\t\n\trespond_to do |format|\n\t\tformat.html { render :json => @organization_names }\n\tend\n end", "def create\n @organism = Organism.new(organism_params)\n\n respond_to do |format|\n if @organism.save\n format.html { redirect_to @organism, notice: 'Organism was successfully created.' }\n format.json { render json: @organism, status: :created, location: @organism }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organism.errors, status: :unprocessable_entity }\n end\n end\n end", "def organization_params\n params.require(:organization).permit(:name, :abbreviation, :term_id)\n end", "def create\n authorize Org\n\n # Let the OrgSelectable concern determine which org was selected\n org = process_org_params\n\n if org.present?\n if org.new_record?\n org.language = Language.default\n org.managed = org_params[:managed] == '1'\n org.logo = params[:logo] if params[:logo]\n org.links = if org_params[:org_links].present?\n ActiveSupport::JSON.decode(org_params[:org_links])\n else\n { org: [] }\n end\n end\n\n begin\n # TODO: The org_types here are working but would be better served as\n # strong params. Consider converting over to follow the pattern\n # for handling Roles in the ContributorsController. This will allow\n # the use of all org_types instead of just these 3 hard-coded ones\n org.funder = org_params[:funder] == 'true'\n org.institution = org_params[:institution] == 'true'\n org.organisation = org_params[:organisation] == 'true'\n\n if org.save\n msg = success_message(org, _('created'))\n redirect_to admin_edit_org_path(org.id), notice: msg\n else\n flash.now[:alert] = failure_message(org, _('create'))\n @org = org\n @org.links = { org: [] } if org.links.blank?\n render 'super_admin/orgs/new'\n end\n rescue Dragonfly::Job::Fetch::NotFound\n failure = _('There seems to be a problem with your logo. Please upload it again.')\n redirect_to admin_edit_org_path(org), alert: failure\n render 'orgs/admin_edit', locals: {\n org: org,\n languages: Language.all.order('name'),\n method: 'POST',\n url: super_admin_orgs_path\n }\n end\n else\n flash.now[:alert] = _('Unable to create the organisation. Name can\\'t be blank')\n render 'super_admin/orgs/new'\n end\n end", "def create\n @organization = Organization.new(org_params)\n if @organization.save\n redirect_to :root, notice: 'You have signed up successfully but your account has not been approved.'\n else\n render action: 'new'\n end\n end", "def organization_invite\n params['host'] = Ind.http_api\n params['api_key'] = Accounts.new.find_by_email(params['email']).api_key\n\n org_res = Organizations.new.list(params).orgs\n\n org_res[0][:related_orgs] << params['org_id']\n org_res[0][:api_key] = params['api_key']\n org_res[0][:email] = params['email']\n org_res[0][:host] = Ind.http_api\n\n res = Organizations.new.update(org_res[0])\n redirect_to root_url\n end", "def create\n @organism = Organism.new(params[:organism])\n\n respond_to do |format|\n if @organism.save\n format.html { redirect_to @organism, notice: 'Organism was successfully created.' }\n format.json { render json: @organism, status: :created, location: @organism }\n else\n format.html { render action: \"new\" }\n format.json { render json: @organism.errors, status: :unprocessable_entity }\n end\n end\n end", "def UpdateOrganization params = {}\n \n APICall(path: 'organizations.json',method: 'PUT',payload: params.to_json)\n \n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def new\n @organization = Organization.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @organization }\n end\n end", "def index\n @organizations = Organization.all\n end", "def create_member\n # Member.create!..\n\n respond_to do |format|\n format.html { redirect_to organization_path(params[:orgaid])}\n format.json { head :no_content }\n end\n end", "def create_organizations_api\n InfluxDB2::API::OrganizationsApi.new(@api_client)\n end", "def create\n @organization_catagory = OrganizationCatagory.new(organization_catagory_params)\n\n respond_to do |format|\n if @organization_catagory.save\n format.html { redirect_to @organization_catagory, notice: 'Organization catagory was successfully created.' }\n format.json { render :show, status: :created, location: @organization_catagory }\n else\n format.html { render :new }\n format.json { render json: @organization_catagory.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization_status = OrganizationStatus.new(create_organization_status_params)\n @organization_status.participant = Current.user\n @organization_status.save\n respond_with @organization_status, location: -> { @organization_status.organization }\n end", "def create\n @person = Person.new(params[:person])\n current_organization.people << @person\n if @person.save\n redirect_to people_path, notice: @person.name.to_s + ' was successfully created.'\n else\n render action: \"new\"\n end\n end", "def create\n @ngo = current_user.ngos.build(ngo_params)\n \n respond_to do |format|\n if @ngo.save\n @ngo.reindex\n format.html { redirect_to @ngo, notice: 'The organization was successfully created.' }\n format.json { render :show, status: :created, location: @ngo }\n else\n format.html { render :new }\n format.json { render json: @ngo.errors, status: :unprocessable_entity }\n end\n end\n end", "def organization_params\n params.permit(:id, :organization_id, :name)\n end", "def organization\n _get(\"/account/organization\") { |json| json }\n end", "def create\n @o_rganization = ORganization.new(o_rganization_params)\n\n respond_to do |format|\n if @o_rganization.save\n format.html { redirect_to @o_rganization, notice: 'O rganization was successfully created.' }\n format.json { render :show, status: :created, location: @o_rganization }\n else\n format.html { render :new }\n format.json { render json: @o_rganization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @sourcing_org = SourcingOrg.new(sourcing_org_params)\n\n respond_to do |format|\n if @sourcing_org.save\n format.html { redirect_to @sourcing_org, notice: 'Sourcing org was successfully created.' }\n format.json { render :show, status: :created, location: @sourcing_org }\n else\n format.html { render :new }\n format.json { render json: @sourcing_org.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @partnering_organization = PartneringOrganization.new(partnering_organization_params)\n\n respond_to do |format|\n if @partnering_organization.save\n format.html { redirect_to @partnering_organization, notice: 'Partnering organization was successfully created.' }\n format.json { render :show, status: :created, location: @partnering_organization }\n else\n format.html { render :new }\n format.json { render json: @partnering_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @organization = Organization.new(organization_params)\n if @organization.save\n session[:organization_id] = @organization.id\n if params[:organization][:dialog] == \"true\"\n if !params[:organization][:alias].blank?\n render json: {id: @organization.id, name: @organization.name, alias: params[:organization][:alias]}\n else\n @workday = session[:workday_id]\n render partial: \"dialog_add_workday_organization_fields\"\n end\n else\n flash[:success] = \"Organization created\"\n if !params[:to_donations].blank?\n redirect_to donations_organization_path(@organization)\n else\n if params[:stay].blank?\n redirect_to search_organizations_path\n else\n redirect_to edit_organization_path(@organization)\n end\n end\n end\n else # Save not successful\n if params[:organization][:dialog] == \"true\"\n @alias = params[:alias].blank? ? \"\" : params[:alias]\n render partial: \"dialog_form\"\n else\n @num_workdays = []\n @allow_stay = true\n render :new\n end\n end\n end", "def create\n @partnering_organization = PartneringOrganization.new(partnering_organization_params)\n respond_to do |format|\n if @partnering_organization.save\n format.html { redirect_to @partnering_organization, notice: 'Partnering organization was successfully created.' }\n format.json { render :show, status: :created, location: @partnering_organization }\n else\n format.html { render :new }\n format.json { render json: @partnering_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def organisation_params\n params[:organisation].permit(:name, :contact_information, org_user_ids: [])\n end", "def create_organisation(user)\n\n user.organisations.create\n\n logger.info \"Successfully created organisation ID: #{user.organisations.first.id}\"\n\n end", "def create\n @orging = Orging.new(orging_params)\n\n respond_to do |format|\n if @orging.save\n format.html { redirect_to @orging, notice: 'Orging was successfully created.' }\n format.json { render :show, status: :created, location: @orging }\n else\n format.html { render :new }\n format.json { render json: @orging.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @participating_organization = ParticipatingOrganization.new(params[:participating_organization])\n\n respond_to do |format|\n if @participating_organization.save\n format.html { redirect_to(participating_organizations_path, :notice => 'Participating Organization was successfully created.') }\n format.xml { render :xml => @participating_organization, :status => :created, :location => @participating_organization }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @participating_organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @organizations = Organization.all\n respond_with @organizations\n end", "def new\n @organization = Organization.new\n respond_with(@organization)\n end", "def index\n @organizations = Organization.all\n respond_with(@organizations)\n end", "def people_organization_params\n params.require(:people_organization).permit(:PersonalID, :OrganizationName)\n end", "def create\n respond_to do |format|\n if @organization.save\n @organization.registrations << @registration if @registration\n flash[:notice] = 'Organization was successfully created.'\n format.html { redirect_to(@organization) }\n format.xml { render :xml => @organization, :status => :created, :location => @organization }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n contestorganization = Contestorganization.create(params.require(:contestorganization).permit(:contest_id, :user_id))\n redirect_to contest_path(contestorganization.contest)\n end", "def create\n @organization = Organization.new(organization_params)\n if organization_params[:manual_fee_entry] == \"0\" || organization_params[:manual_fee_entry].nil?\n @organization.amount_owe = @organization.tournament.price*@organization.clubs.size\n end\n respond_to do |format|\n if @organization.save\n EventMailer.tournament_registration(@organization).deliver\n format.html { redirect_to @organization, notice: 'Organization was successfully created.' }\n format.json { render action: 'show', status: :created, location: @organization }\n else\n @tournaments = Tournament.active_tournaments\n @organization.clubs.build if @organization.clubs.empty?\n format.html { render action: 'new' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n\t@user = User.new\n\t@organizations = Organization.all\n end", "def orgs\n client.organizations\n end", "def create\n @organization = Organization.new(params[:organization])\n\n respond_to do |format|\n if @organization.save\n OrganizationQuarter.create :organization_id => @organization.id, :quarter_id => @quarter.id, :unit_id => @unit.id\n flash[:notice] = 'Organization was successfully created.'\n format.html { redirect_to(service_learning_organization_path(@unit, @quarter, @organization)) }\n format.xml { render :xml => @organization, :status => :created, :location => @organization }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def index\n @organizations = Organization.where(:id => current_user.organization_id)\n \n respond_with(@organizations)\n end", "def index\n @organizations = Organization.page(params[:page]).per_page(9).order(\"name DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @organizations }\n end\n end", "def organisation_params\n params.require(:organisation).permit(:name, :abbreviation, :people_count, :other, :order)\n end" ]
[ "0.7546241", "0.71868527", "0.703545", "0.70268863", "0.7016771", "0.6988308", "0.6930564", "0.69226116", "0.69226116", "0.69226116", "0.69226116", "0.6916983", "0.6892586", "0.68546283", "0.67094165", "0.670208", "0.6676121", "0.6673902", "0.6667356", "0.661678", "0.6606358", "0.65989137", "0.65920204", "0.6576153", "0.6521847", "0.6511296", "0.6482782", "0.640478", "0.63843775", "0.6384338", "0.63596475", "0.6326186", "0.63151497", "0.63103044", "0.6306872", "0.62964654", "0.6295117", "0.628761", "0.6258914", "0.62503666", "0.62382954", "0.6235161", "0.62307596", "0.6229324", "0.6229037", "0.6227364", "0.6224935", "0.6224935", "0.6224935", "0.6224935", "0.6224935", "0.6224935", "0.6224935", "0.6224935", "0.6224935", "0.62167937", "0.6210213", "0.62032807", "0.6191011", "0.61832935", "0.61745024", "0.6167605", "0.6155596", "0.61482435", "0.6146451", "0.6145141", "0.61335015", "0.61284405", "0.61284405", "0.61250895", "0.61244977", "0.6122394", "0.612111", "0.6113998", "0.60993814", "0.6095899", "0.6077696", "0.6071919", "0.6071832", "0.60713065", "0.6065354", "0.60527307", "0.60492986", "0.6044099", "0.6038256", "0.60272247", "0.6013011", "0.6011849", "0.60022265", "0.60020775", "0.6001953", "0.59976673", "0.59904414", "0.5988663", "0.59828705", "0.5968018", "0.5965894", "0.5964181", "0.5963653", "0.5950892" ]
0.685141
14
PUT /organizations/1 PUT /organizations/1.json
def update @organization.update(organization_params) respond_with(@organization) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def UpdateOrganization params = {}\n \n APICall(path: 'organizations.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n @organization = Organization.find(params[:id])\n @organization.update_attributes(organization_params)\n \n respond_with(@organization, :location => admin_organizations_path)\n end", "def update\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n format.html { redirect_to admin_organizations_path, notice: \"Organization #{@organization.name} was successfully updated.\" }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @organization = Organization.find(params[:id])\n @organization.update_attributes(params[:organization])\n respond_with @organization\n end", "def update\n @organization.update(organization_params)\n if @organization.save\n render json: { success: \"organization updated successfully\"}, status: :ok\n else\n render json: { errors: @orgnanization.errors.full_messages }, status: :unprocessable_entity\n end\n end", "def update\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @organization.update(organization_params)\n render :show, status: :ok, location: @organization\n else\n render json: @organization.errors, status: :unprocessable_entity\n end\n end", "def update\n @organization_person = OrganizationPerson.find(params[:id])\n\n if @organization_person.update(organization_person_params)\n render json: @organization_person\n else\n render json: @organization_person.errors, status: :unprocessable_entity\n end\n end", "def update(name: nil)\n data = name.nil? ? {} : {name: name}\n cf_patch(path: \"/organizations/#{org_id}\", data: data)\n end", "def update\n if @organization.update(organization_params)\n render :show, status: :ok, location: @organization\n else\n render json: @organization.errors, status: :unprocessable_entity\n end\n end", "def update\r\n @org = Org.from_param(params[:abbr])\r\n\r\n respond_to do |format|\r\n if @org.update_attributes(params[:org])\r\n format.html { redirect_to @org, notice: 'Org was successfully updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @org.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @org.update(org_params)\n format.html do\n redirect_to @org, notice: 'Org was successfully updated.'\n end\n format.json { render :show, status: :ok, location: @org }\n else\n format.html { render :edit }\n format.json { render json: @org.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit_organization(org, options={})\n patch \"/orgs/#{org}\", :body => options\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @organization = Organization.find(params[:id])\n\n if @organization.update_attributes(params[:organization])\n redirect_to admin_organizations_url, :notice => t('organization.messages.update.success')\n else\n render action: \"edit\"\n end\n end", "def update_organization( params )\n\n raise ArgumentError.new(format('wrong type. \\'params\\' must be an Hash, given \\'%s\\'', params.class.to_s)) unless( params.is_a?(Hash) )\n raise ArgumentError.new('missing \\'params\\'') if( params.size.zero? )\n\n organization = validate( params, required: true, var: 'organization', type: String )\n name = validate( params, required: true, var: 'name', type: String )\n org = organization( organization )\n\n return { 'status' => 404, 'message' => format('Organization \\'%s\\' not found', organization) } if( org.nil? || org.dig('status').to_i != 200 )\n\n organization_id = org.dig('id')\n\n endpoint = format( '/api/orgs/%s', organization_id )\n payload = { name: name }\n\n @logger.debug(\"Update Organisation id #{organization_id} (PUT #{endpoint})\") if @debug\n\n put( endpoint, payload.to_json )\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to edit_admin_organization_path(@organization), notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n flash[:error] = \"#{@organization.errors.full_messages.first}\"\n format.html { redirect_to edit_admin_organization_path(@organization) }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @people_organization.update(people_organization_params)\n format.html { redirect_to @people_organization, notice: 'People organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @people_organization }\n else\n format.html { render :edit }\n format.json { render json: @people_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to edit_organization_path(@organization), notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n format.html { redirect_to admin_organization_path, notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { redirect_to admin_organization_path, notice: 'Organization could not be updated.' }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Place was successfully updated.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @organization = Organization.find(params[:id])\n\n authorize! :update, @organization\n\n respond_to do |format|\n if @organization.update_attributes(permitted_params)\n format.html { redirect_to @organization, notice: 'Organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { @title = edit_action_title; render action: \"edit\" }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if !current_user.admin?\n head :forbidden\n else\n if @organisation.update(organisation_params)\n render json: @organisation.to_json, status: :ok\n else\n render json: @organisation.errors, status: :unprocessable_entity\n end\n end\n end", "def update\n\t\trespond_to do |format|\n\t\t\tif @organization.update_attributes(params[:organization])\n\t\t\t\tformat.html { redirect_to(@organization, :notice => 'Organization was successfully updated.') }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @clients_organization.update(clients_organization_params)\n format.json { render :show, status: :ok, location: @clients_organization }\n else\n format.json { render json: @clients_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, Organization\n respond_to do |format|\n if @organization.update(organization_params)\n format.js\n else\n format.js { render :edit }\n end\n end\n end", "def update\n respond_to do |format|\n if @user_organization.update(user_organization_params)\n format.html { redirect_to @user_organization, notice: 'User organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_organization }\n else\n format.html { render :edit }\n format.json { render json: @user_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @org.update(org_params)\n redirect_to @org, notice: \"#{@org.name} was successfully updated.\"\n else\n render :edit\n end\n end", "def update\n standard_update(OrganizationType, params[:id], organization_type_params)\n end", "def update\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n flash[:notice] = 'Organization was successfully updated.'\n format.html { redirect_to @organization }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update_attributes( params[:organization],\n :as => ( permitted_to?( :admin, @organization ) ? :admin : :default ) )\n flash[:notice] = 'Organization was successfully updated.'\n format.html { redirect_to(@organization) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @organization = Organization.find(params[:id])\n\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n flash[:notice] = 'Organization was successfully updated.'\n #format.html { redirect_to(@organization) }\n format.html { redirect_to :controller => 'organizations', :action => 'show' , :organization=> @organization.site_name }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_org\n @org = Organization.find(params[:id])\n end", "def update\n respond_to do |format|\n if @casa_org.update(casa_org_params)\n format.html { redirect_to @casa_org, notice: 'CASA org was successfully updated.' }\n format.json { render :show, status: :ok, location: @casa_org }\n else\n format.html { render :edit }\n format.json { render json: @casa_org.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to organization_path(@organization), notice: 'Организация успешно обновлена.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @admins_organization.update(admins_organization_params)\n format.html { redirect_to @admins_organization, notice: 'Organization was successfully updated.' }\n format.json { render :show, status: :ok, location: @admins_organization }\n else\n format.html { render :edit }\n format.json { render json: @admins_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @external_organization = ExternalOrganization.find(params[:id])\n\n respond_to do |format|\n if @external_organization.update_attributes(params[:external_organization])\n format.html { redirect_to @external_organization, notice: 'External organization was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @external_organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @organ = Organ.find(params[:id])\n\n respond_to do |format|\n if @organ.update_attributes(params[:organ])\n format.html { redirect_to @organ, notice: 'Organ was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @organ.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sourcing_org.update(sourcing_org_params)\n format.html { redirect_to @sourcing_org, notice: 'Sourcing org was successfully updated.' }\n format.json { render :show, status: :ok, location: @sourcing_org }\n else\n format.html { render :edit }\n format.json { render json: @sourcing_org.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit\n @organization = Organization.find(params[:id])\n end", "def update(name, org_guid)\n org = @client.organization(org_guid)\n org.name = name\n org.update!\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def it_update_from_organization\n organization = params[:org]\n if organization != '0'\n @organization = Organization.find(organization)\n @stores = @organization.blank? ? stores_dropdown : @organization.stores.order(:name)\n @products = @organization.blank? ? products_dropdown : @organization.products.order(:product_code)\n else\n @stores = stores_dropdown\n @products = products_dropdown\n end\n # Products array\n @products_dropdown = products_array(@products)\n # Setup JSON\n @json_data = { \"store\" => @stores, \"product\" => @products_dropdown }\n render json: @json_data\n end", "def update\n respond_to do |format|\n if update_organisation\n format.html { redirect_to @organisation, notice: 'Organisation was successfully updated.' }\n format.json { render :show, status: :ok, location: @organisation }\n else\n format.html { render :edit }\n format.json { render json: @organisation.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_organization\n begin\n @organization = Organization.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n render json: { status: 'error', errors: [\"Organization not found\"] },\n status: :not_found\n end\n end", "def update\n authorize @organization_membership\n\n if @organization_membership.update(organization_membership_update_params)\n head :no_content\n else\n render json: @organization_membership.errors, status: :unprocessable_entity\n end\n end", "def set_organization\n # @org = Organization.find(params[:id])\n end", "def update\n @organization_profile = OrganizationProfile.find(params[:id])\n\n respond_to do |format|\n if @organization_profile.update_attributes(params[:organization_profile])\n format.html { redirect_to @organization_profile, notice: 'Organization profile was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @organization_profile.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_organization\n @organization = Organization.find(params[:name])\n end", "def update\n @organization = Organization.find(params[:id])\n\n if current_user.has_role?('admin')\n @organization.is_pending = false\n end\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n flash[:notice] = 'Organization was successfully updated.'\n format.html { redirect_to(@organization) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @organization_detail = OrganizationDetail.find(params[:id])\n\n respond_to do |format|\n if @organization_detail.update_attributes(params[:organization_detail])\n format.html { redirect_to(@organization_detail, :notice => 'OrganizationDetail was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organization_detail.errors, :status => :unprocessable_entity }\n end\n end\n end", "def co_update_from_organization\n organization = params[:company]\n if organization != '0'\n @organization = Organization.find(organization)\n @users = @organization.blank? ? users_dropdown : users_dropdown\n #@users = @organization.blank? ? users_dropdown : @organization.users.order(:email)\n else\n @users = users_dropdown\n end\n @json_data = { \"users\" => @users }\n render json: @json_data\n end", "def update\n @participating_organization = ParticipatingOrganization.find(params[:id])\n\n respond_to do |format|\n if @participating_organization.update_attributes(params[:participating_organization])\n format.html { redirect_to(participating_organizations_path, :notice => 'Participating Organization was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @participating_organization.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if @organization.update(organization_params)\n redirect_to [:settings, @organization], notice: \"Organization was successfully updated.\"\n else\n render :edit\n end\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def set_organization\n @organization = Organization.find(params[:id])\n end", "def update\n result = Organization::Editor.perform(organization: current_organization, options: update_organization_params.to_h)\n\n respond_to do |format|\n format.html do\n if result.success?\n flash[:success] = \"Successfully updated \\\"#{current_organization.title}\\\"!\"\n redirect_to current_organization\n else\n current_organization.reload\n render :edit\n end\n end\n format.js do\n set_filter_options\n set_filtered_organizations\n render \"organizations/archive.js.erb\", format: :js\n end\n end\n end", "def set_organization\n @organization = current_user.organizations.where(id: params[:id]).first\n end", "def update!(**args)\n @organization_id = args[:organization_id] if args.key?(:organization_id)\n @organization_name = args[:organization_name] if args.key?(:organization_name)\n end", "def set_organization\n\t @organization = Organization.find(params[:id])\n\tend", "def update\n @organization_status.update(update_organization_status_params)\n respond_with @organization_status, location: lambda {\n organization_organization_statuses_path(@organization_status.organization)\n }\n end", "def update\n @organisation = Organisation.find(params[:id])\n\n respond_to do |format|\n if @organisation.update_attributes(params[:organisation])\n format.html { redirect_to(locations_url, :notice => \"#{@organisation.to_s} was successfully updated.\") }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organisation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def edit(org_name, params={})\n _validate_presence_of org_name\n normalize! params\n filter! VALID_ORG_PARAM_NAMES, params\n\n patch_request(\"/orgs/#{org_name}\", params)\n end", "def update\n @organ = Organ.find(params[:id])\n\n respond_to do |format|\n if @organ.update_attributes(params[:organ])\n format.html { redirect_to(@organ, :notice => 'Organ was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @organ.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @organization_account = OrganizationAccount.find(params[:id])\n\n respond_to do |format|\n if @organization_account.update_attributes(params[:organization_account])\n format.html { redirect_to @organization_account, notice: 'Organization account was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @organization_account.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @organization.update_attributes(params[:organization])\n flash[:notice] = VALIDATION_MESSAGE[\"ORGANIZATION\"][\"UPDATE\"] rescue nil\n format.html { redirect_to admin_organization_path(@organization.id) }\n else\n flash[:error] = @organization.errors.full_messages.join(\", \")\n format.html { render :action => \"edit\",:id => @organization.id }\n end\n end\n end", "def update\n @organization.user_updated_id = current_user.id\n respond_to do |format|\n if @organization.update(organization_params)\n format.html { redirect_to @organization, notice: 'Información actualizada satisfactoriamente.' }\n format.json { render :show, status: :ok, location: @organization }\n else\n format.html { render :edit }\n format.json { render json: @organization.errors, status: :unprocessable_entity }\n end\n end\n end", "def GetOrg id\n\n APICall(path: \"organizations/#{id}.json\")\n\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def set_organization\n @organization = Organization.friendly.find(params[:id])\n end", "def set_organization\n @organization = Organization.friendly.find(params[:id])\n end" ]
[ "0.78295016", "0.7434708", "0.7253623", "0.7247928", "0.7240768", "0.7187564", "0.7173343", "0.71054447", "0.70963454", "0.70263505", "0.6951313", "0.6945305", "0.6945305", "0.6945305", "0.6945305", "0.6945305", "0.6945305", "0.6945305", "0.69379544", "0.6911741", "0.6906686", "0.6906686", "0.6874064", "0.6866124", "0.6851786", "0.68257964", "0.6825172", "0.6817825", "0.68084365", "0.6807733", "0.68032545", "0.67244667", "0.6711768", "0.668489", "0.66743207", "0.66698605", "0.6653635", "0.66099143", "0.660866", "0.65779406", "0.6577848", "0.657128", "0.65699774", "0.65657026", "0.6536534", "0.65126604", "0.6494768", "0.648594", "0.64733297", "0.6468194", "0.6468194", "0.6468194", "0.6468194", "0.6428561", "0.64274645", "0.64257985", "0.6422472", "0.6415664", "0.6392162", "0.63602877", "0.63543195", "0.6343582", "0.6326525", "0.6320336", "0.63197505", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.63137686", "0.62912583", "0.62722176", "0.62656796", "0.62626505", "0.62559086", "0.6238496", "0.6238106", "0.6235311", "0.62265193", "0.6220996", "0.62146163", "0.62117165", "0.62000173", "0.6172005", "0.6172005" ]
0.71293944
7
DELETE /organizations/1 DELETE /organizations/1.json
def destroy @organization.destroy respond_with(@organization) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def DeleteOrganization id\n \n APICall(path: \"organizations/#{id}.json\",method: 'DELETE')\n \n end", "def destroy\n @organization = Organization.find(params[:id])\n @organization.destroy\n\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization = Organization.find(params[:id])\n @organization.destroy\n\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @org = Org.from_param(params[:abbr])\r\n @org.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to orgs_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end", "def delete(id:)\n id_check(:id, id)\n\n cf_delete(path: \"/organizations/#{org_id}/railguns/#{id}\")\n end", "def destroy\n @organization = Organization.find(params[:id])\n @organization.delete\n end", "def destroy\n @org = Organisation.find_by( id: params[\"id\"]).delete\n redirect_to root_url\n end", "def destroy\n @people_organization.destroy\n respond_to do |format|\n format.html { redirect_to people_organizations_url, notice: 'People organization was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization = Organization.find(params[:id])\n\n authorize! :destroy, @organization\n\n @organization.destroy\n\n respond_to do |format|\n format.html { redirect_to organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n the_org = @person.org_id\n the_name = @person.name\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to org_path(the_org), status: 303, notice: t('.delete_ok', item: the_name) }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n\n respond_to do |format|\n format.html { redirect_to(organizations_url) }\n end\n end", "def destroy\n @organization.destroy\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 @organization.destroy\n render json: { success: \"Organization deleted successfully\" }, status: :ok\n end", "def destroy\n @organization = Organization.find(params[:id])\n begin\n @organization.destroy\n rescue Exception => e\n flash[:alert] = e.message\n end\n\n respond_to do |format|\n format.html { redirect_to admin_organizations_path }\n format.json { head :no_content }\n end\n end", "def destroy\n # @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @external_organization = ExternalOrganization.find(params[:id])\n @external_organization.destroy\n\n respond_to do |format|\n format.html { redirect_to external_organizations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization = Organization.find(params[:id])\n @organization.destroy\n\n respond_to do |format|\n format.html { redirect_to(organizations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @organization.destroy\n\n respond_to do |format|\n format.html { redirect_to(organizations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Организация успешно удалена.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @sourcing_org.destroy\n respond_to do |format|\n format.html { redirect_to sourcing_orgs_url, notice: 'Sourcing org was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organizations_url, notice: \"Organization was destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @organisation.destroy\n respond_to do |format|\n format.html { redirect_to organisations_url, notice: 'Organisation was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to current_org }\n format.json { render json: @organization }\n end\n end", "def destroy\n @organization.destroy\n respond_with(:organizations)\n # respond_to do |format|\n # format.html { redirect_to organizations_url }\n # format.json { head :no_content }\n # end\n end", "def destroy\n standard_destroy(OrganizationType, params[:id])\n end", "def destroy\n Organization.find(params[:id]).destroy\n flash[:success] = \"Organization deleted\"\n redirect_to search_organizations_path\n end", "def destroy\n @clients_organization.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @organization = Organization.find(params[:id])\n @organization.destroy\n respond_with(@organization)\n end", "def destroy\n @admins_organization.destroy\n respond_to do |format|\n format.html { redirect_to admins_organizations_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization = Organization.find(params[:id])\n @organization.destroy\n respond_with @organization\n end", "def destroy\n \n @organization.destroy\n \n respond_to do |format|\n format.html { redirect_to organizations_url, notice: 'Place was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @serviceorg = Serviceorg.find(params[:id])\n @serviceorg.destroy\n\n respond_to do |format|\n format.html { redirect_to serviceorgs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organism = Organism.find(params[:id])\n @organism.destroy\n\n respond_to do |format|\n format.html { redirect_to organisms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n respond_to do |format|\n format.html { redirect_to organization_url, notice: 'Organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! @organization\n @organization.destroy\n\n redirect_to root_path\n end", "def destroy\n @organ = Organ.find(params[:id])\n @organ.destroy\n\n respond_to do |format|\n format.html { redirect_to organs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization = Organization.find(params[:id])\n @organization.destroy\n \n redirect_to admin_organizations_url, notice: t('organization.messages.delete.success')\n end", "def destroy\n \n @organism.destroy\n\n respond_to do |format|\n format.html { redirect_to organisms_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @casa_org.destroy\n respond_to do |format|\n format.html { redirect_to casa_orgs_url, notice: 'CASA org was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @user_organization.destroy\n respond_to do |format|\n format.html { redirect_to user_organizations_url, notice: 'User organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_org_orderable = ClientOrgOrderable.find(params[:id])\n @client_org_orderable.destroy\n\n respond_to do |format|\n format.html { redirect_to client_org_orderables_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization_account = OrganizationAccount.find(params[:id])\n @organization_account.destroy\n\n respond_to do |format|\n format.html { redirect_to organization_accounts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @host_org.destroy\n respond_to do |format|\n format.html { redirect_to host_orgs_url, notice: 'Host org was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @org.destroy\n redirect_to orgs_url, notice: \"#{@org.name} was successfully deleted.\"\n end", "def destroy\n @environment = current_user.organization.environments.find(params[:id])\n @environment.destroy\n\n respond_to do |format|\n format.html { redirect_to environments_url }\n format.json { head :no_content }\n end\n end", "def delete_by_key(key)\n HttpClient::Preconditions.assert_class('key', key, String)\n @client.request(\"/organizations/#{CGI.escape(key)}\").delete\n nil\n end", "def delete\n render json: Company.delete(params[\"id\"])\n end", "def destroy\n @organization.destroy\n end", "def destroy\n @orging.destroy\n respond_to do |format|\n format.html { redirect_to orgings_url, notice: 'Orging was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization_detail = OrganizationDetail.find(params[:id])\n @organization_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to(organization_details_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @organization_profile = OrganizationProfile.find(params[:id])\n @organization_profile.destroy\n\n respond_to do |format|\n format.html { redirect_to organization_profiles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organization.destroy\n flash[:notice] = 'Organization was successfully removed.'\n\n respond_to do |format|\n format.html { redirect_to(organizations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @o_rganization.destroy\n respond_to do |format|\n format.html { redirect_to o_rganizations_url, notice: 'O rganization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n\t\t@organization = Organization.find(params[:id])\n\t\t@organization.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to(organizations_url) }\n\t\t\tformat.xml { head :ok }\n\t\tend\n\tend", "def destroy\n @organization_catagory.destroy\n respond_to do |format|\n format.html { redirect_to organization_catagories_url, notice: 'Organization catagory was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @employe.destroy\n respond_to do |format|\n format.html { redirect_to employes_path(api_id: @employe.organisme_id), notice: 'Employe was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @participating_organization = ParticipatingOrganization.find(params[:id])\n @participating_organization.destroy\n\n respond_to do |format|\n format.html { redirect_to(participating_organizations_url) }\n format.xml { head :ok }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n respond_to do |format|\n format.json { render json: {}, status: :ok }\n end\n end", "def destroy\n official = Official.find(params[:id])\n official.destroy\n head 204\n end", "def destroy\n @alumno.destroy\n respond_to do |format|\n format.html { redirect_to grupos_path }\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.json { head :ok }\n end\n \n end", "def destroy\n check_privileges(:superadmin?, organisation_path(params[:id])); return if performed?\n @organisation = Organisation.friendly.find(params[:id])\n @organisation.destroy\n flash[:success] = \"Deleted #{@organisation.name}\"\n redirect_to organisations_path\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @orgn.destroy\n track_activity @orgn\n respond_to do |format|\n format.html { redirect_to orgns_url, notice: 'Orgn was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @person.destroy\n respond_to do |format|\n format.html { redirect_to admin_people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_agency = Admin::Agency.find(params[:id])\n @admin_agency.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_agencies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @org_unit.destroy\n respond_to do |format|\n format.html { redirect_to org_units_url, notice: 'Org unit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @group_organization.destroy\n respond_to do |format|\n format.html { redirect_to group_organizations_url, notice: 'Group organization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organisme.destroy\n respond_to do |format|\n format.html { redirect_to organismes_url, notice: 'Organisme was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organizer.destroy\n respond_to do |format|\n format.html { redirect_to organizers_url, notice: 'Organizer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @organizer.destroy\n respond_to do |format|\n format.html { redirect_to organizers_url, notice: 'Organizer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @personal.destroy\n respond_to do |format|\n format.html { redirect_to personals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n \n keystone.delete_tenant(keystone.get_tenant(params[:id])[:id])\n\n respond_to do |format|\n format.html { redirect_to tenants_url }\n format.json { head :ok }\n end\n end", "def destroy\n # @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @orphan.destroy\n respond_to do |format|\n format.html { redirect_to orphans_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @organ = Organ.find(params[:id])\n @organ.destroy\n\n respond_to do |format|\n format.html { redirect_to(organs_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n authorize! :destroy, @individual\n @individual.destroy\n respond_to do |format|\n format.html { redirect_to individuals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n unless current_user.try(:superadmin?)\n flash[:notice] = PERMISSION_DENIED\n redirect_to organisation_path(params[:id]) and return false\n end\n @organisation = Organisation.friendly.find(params[:id])\n @organisation.destroy\n flash[:success] = \"Deleted #{@organisation.name}\"\n\n redirect_to organisations_path\n end", "def destroy\n @enrollment.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :ok }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :ok }\n end\n end", "def destroy\n @person = Person.find(params[:id])\n @person.destroy\n\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :ok }\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_by_body\n @person = Person.find(person_delete_param[:id])\n id = @person.id\n\n if @person.destroy\n render json: { status: 'DELETE Success' }, status: :ok\n else\n render json: { status: 'Error', message:'Error deleting person', person: @person.errors }, status: :unprocessable_entity\n end\n end", "def destroy\n ## note use of method chaining to combine find & destroy into one line\n Person.find(params[:id]).destroy\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person.destroy\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @person.destroy\n respond_to do |format|\n format.html { redirect_to people_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.7767288", "0.75106853", "0.75106853", "0.7457346", "0.7439525", "0.7439525", "0.7439525", "0.7331174", "0.73253006", "0.73227197", "0.7295465", "0.7285924", "0.7278945", "0.7270234", "0.726735", "0.72643864", "0.72632885", "0.723405", "0.7200872", "0.7193817", "0.71657467", "0.71488714", "0.71204734", "0.71204734", "0.71204734", "0.71204734", "0.71204734", "0.71204734", "0.71204734", "0.7115395", "0.7101233", "0.7098312", "0.708705", "0.7085407", "0.7084386", "0.7071004", "0.706313", "0.7062378", "0.7061485", "0.7059044", "0.704055", "0.7036474", "0.70297706", "0.702916", "0.70251834", "0.70162535", "0.70135725", "0.7001765", "0.6998686", "0.6978198", "0.696906", "0.6968368", "0.6925744", "0.69044435", "0.6895838", "0.68868506", "0.68823034", "0.6874819", "0.68583053", "0.68555754", "0.6850577", "0.6850006", "0.6835527", "0.6809422", "0.6804169", "0.67862296", "0.6782862", "0.6779343", "0.67624056", "0.6749459", "0.67456675", "0.67302835", "0.6723526", "0.67176485", "0.670722", "0.6705247", "0.6701616", "0.66924155", "0.6691064", "0.66808456", "0.668001", "0.6679329", "0.666764", "0.666764", "0.66624546", "0.6654458", "0.6648173", "0.6645709", "0.66453046", "0.664137", "0.66357213", "0.66341585", "0.6625787", "0.6625787", "0.6625787", "0.6622431", "0.66215783", "0.66163236", "0.6612257", "0.6612257" ]
0.69501054
52
Note: Midnight is 12:00:00AM on a 12hour clock, and 00:00:00 on a 24hour clock. Noon is 12:00:00PM on a 12hour clock, and 12:00:00 on a 24hour clock. Input Format A single string containing a time in hour clock format (i.e.: or ), where and . Output Format Convert and print the given time in hour format, where . Sample Input 07:05:45PM Sample Output 19:05:45
def timeConversion(s) time = s.split(':') if time.first == "12" && time.last[-2..-1] == 'AM' time[0] = time.first.to_i - 12 elsif time.first != "12" && time.last[-2..-1] == 'PM' time[0] = time.first.to_i + 12 end time.last.gsub!(/[PM AM pm am]/, '') # required to add leading zero to pass all hackerrank tests time[0] = '0' + time[0].to_s if time[0].to_s.size <= 1 time.join(":") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def timeConversion(s)\n # Write your code here\n b = s[-2..-1] == 'PM' ? 12 : 0\n p b\n h = s.split(':')[0]\n h = h.to_i%12 + b\n p h\n p h.to_s + s[2..-3]\nend", "def convert_to_usable_time(xanga_time)\n arr = xanga_time.split(\" \")\n ret = arr[0]\n ret.insert(0,\"0\") if arr[0].length == 4 #pad left-most zero\n \n if arr[1] == \"PM\" #add 12 to it\n str = ret.slice(0,2)\n 0.upto(11){ str.succ! } \n ret[0,2] = str\n end\n \n ret.concat(\":00 +0000\")\n end", "def formatTime( time )\n hours = 0\n minutes = 0\n time[/(\\d+):(\\d+)/]\n hours = $1.to_i\n minutes = $2.to_i\n if time.include? \"PM\"\n if( hours!=12 )\n hours += 12\n end \n end \n if time.include? \"AM\"\n if (hours == 12)\n hours = 0\n end\n end\n # The year, month and day are irrelevant. \n return Time.local( 1, 1, 1, hours, minutes, 0)\n end", "def timeConversion(s)\n #\n # Write your code here.\n #\n split = s.split(\":\")\n pm = split[2][-2,2]\n split[2] = split[2][0,2]\n if pm == \"AM\" && split[0] == \"12\"\n split[0] = 00\n end\n if pm == \"PM\"\n split[0] = split[0].to_i + 12\n if split[0] == 24\n split[0] = 12\n end\n end\n\n split[0] = split[0].to_s.rjust(2,\"0\")\n split[1] = split[1].to_s.rjust(2,\"0\")\n split[2] = split[2].to_s.rjust(2,\"0\")\n\n p split.join(\":\")\nend", "def timeConversion(s)\n timeArr = s.split(\":\");\n hours = timeArr[0];\n minutes = timeArr[1];\n seconds = timeArr[2][0...-2]\n am_or_pm = timeArr[2][-2..-1]\n\n if am_or_pm == \"PM\" && hours != \"12\"\n hours = (hours.to_i + 12).to_s\n elsif am_or_pm == \"AM\" && hours == \"12\"\n hours = \"00\"\n end\n\n hours + \":\" + minutes + \":\" + seconds\nend", "def timeConversion(s)\n am_pm = s[(s.length - 2)..(s.length - 1)]\n s.gsub!(am_pm, '')\n hour = s[0..1]\n if hour == '12'\n if am_pm == 'AM'\n s[0..1] = '00'\n end\n elsif am_pm == 'PM'\n new_hour = (hour.to_i + 12).to_s\n s[0..1] = new_hour\n end\n result = s\nend", "def format_time_from_hour hour\n hrs = hour.to_i\n min = ((hour - hrs) * 60.0 + 0.5).to_i\n \"%2d:%02d\" % [hrs, min]\n end", "def change_time(hour,min)\n Time.strptime(\"#{hour}:#{min}\", \"%H:%M\")\n end", "def timeConversion(s)\n meridiem = s.scan(/[A-Z]+/).first\n s.gsub!(/[A-Z]+/, '')\n hour_str = s.scan(/\\d\\d/).first\n return s if hour_str == '12' && meridiem == 'PM'\n hour_int = hour_str.to_i\n new_hour =\n if meridiem == 'PM'\n (hour_int + 12) % 24\n else\n (hour_int - 12) % 12\n end\n s.gsub(/^\\d\\d/, new_hour.to_s.rjust(2, '0'))\nend", "def timeConversion(s)\n if s =~ /[pP]/\n r = s.chomp(\"PM\")\n r = r.split(\":\")\n if r[0] == \"12\"\n r[0] = \"12\"\n else\n r[0] = (r[0].to_i + 12).to_s\n end \n \n r = r[0] + \":\" + r[1] + \":\" + r[2]\n elsif\n if s =~ /[aA]/\n r = s.chomp(\"AM\")\n r = r.split(\":\")\n if r[0] == \"12\"\n r[0] = \"00\"\n end\n r = r[0] + \":\" + r[1] + \":\" + r[2]\n end\n end\n p r\nend", "def time_conversion s\n converted_time = \"#{(s[0,2].to_i + 12) % 12}#{s[2,6]}\".rjust(8, \"0\")\n converted_time = \"#{converted_time[0,2].to_i + 12}#{s[2,6]}\" if s[8,9] == \"PM\"\n converted_time\n end", "def time_convert(string)\n new_str = string.split(':')\n\n if string.start_with?('12') && string.end_with?('AM')\n new_str[0] = '00'\n new_str.join(':').slice(0, 8)\n elsif string.start_with?('12') || string.end_with?('AM')\n new_str.join(':').slice(0, 8)\n elsif string.end_with?('PM')\n new_str[0] = new_str[0].to_i\n new_str[0] += 12\n new_str[0].to_s\n new_str.join(':').slice(0, 8)\n end\nend", "def parse_hour_12h(time)\n sounds_for_number(time.strftime(\"%l\"))\n end", "def timeConversion(s)\n if s[-2..-1] == \"PM\"\n return s[0..-3] if s[0..1] == \"12\"\n converted_time = (s[0..1].to_i + 12).to_s\n converted_time + s[2..-3]\n else\n return \"00\" + s[2..-3] if s[0..1] == \"12\"\n s[0..-3]\n end\nend", "def generic_forecast_hour_str(forecast_hour_str)\n # \"11-12\" => \"one hour long\"\n forecast_hour_str.gsub(/^\\d+-\\d+\\s+hour/) do |range_str|\n start, stop = range_str.split(/[\\- ]/)[0..1].map(&:to_i)\n int_to_english(stop - start) + \" hour long\"\n end.gsub(/\\s*\\d+\\s*/, \"\") # \"7 hour fcst\" => \"hour fcst\"\nend", "def convert_time_of_day(val)\n return val unless parse_integer(val).nil?\n\n if val == \"noon\"\n val = \"12pm\"\n elsif val == \"midnight\"\n val = \"12am\"\n elsif !(/a$/ =~ val).nil?\n val = val.gsub(/a$/, \"am\")\n elsif !(/p$/ =~ val).nil?\n val = val.gsub(/p$/, \"pm\")\n end\n hours = parse_integer(Time.zone.parse(val).strftime(\"%H\"))\n minutes = parse_integer(Time.zone.parse(val).strftime(\"%M\"))\n seconds = parse_integer(Time.zone.parse(val).strftime(\"%S\"))\n (hours * 3600 + minutes * 60 + seconds).to_s\n rescue\n val\n end", "def format_time\n hours = format_hour @hour\n minutes = format_minute @minutes\n ampm = @hour < 12 ? @@ampm_hash['a'] : @@ampm_hash['p']\n time = ''\n time += hours[0] + minutes[0] + ' ' + ampm[0] + \"\\n\"\n time += hours[1] + minutes[1] + ' ' + ampm[1] + \"\\n\"\n time += hours[2] + minutes[2] + ' ' + ampm[2] + \"\\n\"\n time\n end", "def parse_hour_24h(time)\n sounds_for_number(time.strftime(\"%k\"))\n end", "def formattime2(unformattedtime)\n unformattedtime.strftime('%H:%M:%S')\n end", "def tt(time, format=:short); '13:37'; end", "def format_time(time)\n first_colon = time.index(':')\n if first_colon.nil? \n #if it's not a time\n return time\n end\n second_colon = time.index(':', first_colon + 1)\n result = time[0, first_colon]\n if result.length < 2\n result = \"0#{result}\"\n end\n if second_colon.nil?\n second_colon = time.length\n end\n result += time[first_colon, second_colon - first_colon]\n return result\nend", "def get_formatted_hours(stdTime)\n time = stdTime.split('-')\n hours = time[0].to_i\n if hours > 12\n hours = hours - 12\n hours = hours.to_s + \":\" + time[1].to_s + \"pm\"\n else\n hours = hours.to_s + \":\" + time[1].to_s + \"am\"\n end\n end", "def fmt_time(dt) _format_dt dt, H12_M_PM end", "def time_conversion(minutes)\n if minutes / 60 == 0\n if minutes < 10 \n return \"00:0#{minutes}\"\n \n else\n return \"00:#{minutes}\"\n end\n else\n hours = minutes / 60\n minutes2 = minutes % 60\n if minutes2 == 0\n return \"0#{hours}:00\"\n else\n return \"0#{hours}:#{minutes2}\"\n end\n end\nend", "def correct_format(string)\n parts = string.split(\"-\")\n if parts[0].include?(\"AM\") then parts[0] = \"#{set_24hour(parts[0].split(\":\").first, false)}:30\" else parts[0] = \"#{set_24hour(parts[0].split(\":\").first)}:30\" end \n if parts[1].include?(\"AM\") then parts[1] = \"#{set_24hour(parts[1].split(\":\").first, false)}:30\" else parts[1] = \"#{set_24hour(parts[1].split(\":\").first)}:30\" end\n parts[2] = what_day(parts[2])\n return \"#{parts[0]}-#{parts[1]}-#{parts[2]}\"\n end", "def format_time(time)\n hour = time.hour\n min = time.min\n if min >= 30\n hour += 1\n min = 0\n else\n min = 30\n end\n\n d = Time.now\n Time.new(d.year,d.month,d.day,hour,min,0)\n\n end", "def formattimeanddate(unformattedtime)\n unformattedtime.strftime('%I:%M:%S %p - %d %m %Y')\n end", "def format_time_h_mm(time_string)\n\t\tresult = ''\n\t\ttime_duration = Time.at(time_string).utc\n\n\t\t#format hours\n\t\tif time_duration.hour > 0\n \t\t\tresult << time_duration.strftime('%k hour')\n \t\t\tif time_duration.hour > 1\n\t\t\t\tresult << 's'\n\t\t\tend\n\t\t\tresult << ', '\n \t\tend\n\n \t\t#format minutes\n \t\tif time_duration.min > 0\n \t\t\tresult << time_duration.strftime('%M minute')\n\t \t\tif time_duration.min > 1\n\t\t\t\tresult << 's'\n\t \t\tend\n \t\tend\n\tend", "def time_conversion(minutes)\n hours = 0\n if minutes < 10\n minutes = \"0\" + minutes.to_s\n elsif minutes % 60 == 0 \n hours = minutes / 60\n minutes = \"00\"\n else\n hours = minutes / 60\n minutes = minutes % 60\n end\n return hours.to_s + \":\" + minutes.to_s\nend", "def time_convert (num)\n hour = (num/60).to_s\n min = (num % 60).to_s\n puts hour + \":\"+ min\nend", "def format_hour(hour)\n first, second = hour.divmod(10)\n first_digit_arr = @@number_strs[first]\n second_digit_arr = @@number_strs[second]\n [\n first_digit_arr[0] + second_digit_arr[0] + ' ',\n first_digit_arr[1] + second_digit_arr[1] + '.',\n first_digit_arr[2] + second_digit_arr[2] + '.'\n ]\n end", "def after_midnight(str)\n if str[0..1] == '24'\n hour = 0\n else\n hour = str[0..1].to_i\n end\n (hour * 60) + str[3..4].to_i\nend", "def time_for_string(time)\n time = time.scan(/\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}/)[0].sub(' ','T')\n Time.xmlschema(time)\n end", "def time_convert(twelve)\n\tif twelve[8..9] == \"PM\" then\n \tif twelve[0..1] == \"12\" then \n \ttwentyfour = twelve[0..7]\n \telse\n \ttwentyfour = (twelve[0..1].to_i + 12).to_s + twelve[2..7]\n \tend\n\telse\n \tif twelve[0..1] == \"12\" then \n \ttwentyfour = \"00\" + twelve[2..7]\n \telse\n \ttwentyfour = twelve[0..7]\n \tend\n\tend\n\ttwentyfour\nend", "def TimeConvert(str)\r\n\r\n inTime = str.to_i\r\n hrs = inTime / 60\r\n mins = inTime - (hrs * 60)\r\n \r\n return hrs.to_s + \":\" + mins.to_s\r\n \r\nend", "def after_midnight(str)\n str = str.split(\":\")\n h = str[0].to_i % 24\n m = str[1].to_i\n minutes = (h * 60) + m \nend", "def hour_time(unix_time)\n time = Time.at(unix_time)\n hour_string = time.strftime(\"%l %p\")\n hour_string[0] = '' if hour_string[0] == ' '\n hour_string\n end", "def time_of_day(time)\n hour = (time % (24 * 60)) / 60\n minute = time % 60\n \n format('%02d:%02d',hour,minute)\nend", "def format_hours\n\n self.breakHours = self.breakHours[1,self.breakHours.length] if !self.breakHours.blank? && self.breakHours =~ /0[0-9]:/\n\t\tself.hours = self.hours[1,hours.length] if !self.hours.blank? && self.hours =~ /0[0-9]:/\n \n\tend", "def after_midnight(str)\n hours, minutes = str.split(\":\").map(&:to_i)\n \n hours < 24 ? (hours * 60) + minutes : 0\nend", "def format_time(time)\n part = time.strftime(@time_pattern)\n\n if(!GRUtil.is_empty?(part))\n part\n else\n \"\"\n end\n end", "def format_time(time)\n return time.strftime(\"%l:%M%p\")\n end", "def format_hour_minute(hour_minute)\n hour_minute.lstrip.rstrip.rjust(2,'0') \n end", "def time_conversion(minutes)\n\t # hours = 0\n\n # while minutes >= 60 do\n # if minutes >=60\n # hours += 1\n # minutes -=60\n # end\n # end\n\n\n # new_hour = hours.to_s\n # new_minutes = minutes.to_s\n\n \tmin = minutes % 60\n hours = minutes / 60\n\n if min < 10\n \tmin = '0'+min.to_s\n end\n\n \treturn hours.to_s + ':' + min.to_s\n\nend", "def TimeConvert(num)\n\nhour= num.div(60)\n min=num.remainder(60)\n \n return \"#{hour}\" + \":\" + \"#{min}\"\n \nend", "def formattime()\n\t\tamOrpm = 0\t# this will decide P or A\n\t\ttopResult = ''\t# save top string from the digital clock\n\t\tmiddleResult = ''\t# save middle string from the digital clock\n\t\tbotResult = ''\t\t# save bot string from the digital clock\n\t\t\n\t\thour = gethour().to_i\t# change to integer for hour\n\t\tmin = getminute().to_i\t# change to integer for minute\n\t\t@amOrpm = @t.strftime(\"%p\")\t# this get PM or AM, I used strftime method which provided from the Time class\n\t\tif @amOrpm == \"PM\"\t# if PM\t\n\t\t\tamOrpm = 1\t# save 1\n\t\telse\t\t\t# if AM\n\t\t\tamOrpm = 0\t# save 0\n\t\tend\n\n\t\ttopResult = top(hour,min)\t# Save top string from the digital clock with top method\n\t\tmiddleResult = middle(hour,min)\t# Save middle string from the digital clock with middle method\n\t\tbotResult = bot(hour,min, amOrpm)\t# Save bot string from the digital clock with bot method\n\t\ttotal = topResult + middleResult + botResult\t# save all the string in the total\n\t\treturn total\t\t\t# return total represent perfect digital time\n\tend", "def format_date(date)\n am_or_pm = date.slice -2..-1\n less_stamp = date.slice(0..7)\n hour = date.slice 0..1\n hour = hour.to_i\n if am_or_pm == \"AM\"\n if hour == 12 # subtract 12\n hour = \"00\"\n puts hour << date.slice(2..7)\n else\n puts date.slice(0..7)\n end\n else\n if hour != 12\n hour = hour + 12\n hour = hour.to_s\n puts hour << date.slice(2..7)\n else\n hour = hour + 1\n hour = hour.to_s\n puts hour << date.slice(2..7)\n end\n end\nend", "def time( time = birth )\n # Check to be sure time is a valid Time object\n raise RuntimeError, 'Invalid Time' unless time.instance_of? Time\n\n show_day = time.strftime( '%a' )\n show_time = '2000' # Defaults to 8PM\n\n # Friday is a 9:00 PM show\n show_time = '2100' if time.wday == 5\n\n # Saturday after 10 PM file creation is 10:30 PM show\n if ( time.wday == 6 && time.hour >= 22 ) || ( time.wday == 0 && time.hour <= 2 )\n show_day = 'Sat'\n show_time = '2230'\n end\n\n # Return the day-time string\n show_day + '-' + show_time\n end", "def get_time(integer_time_slot)\n\t\tif integer_time_slot > 60 * 12\n\t\t\tinteger_time_slot = integer_time_slot - 60 * 12\n\t\t\tminutes = integer_time_slot % 60\n\t\t\tminutes = if minutes < 10 then \"0#{minutes}\" else \"#{minutes}\" end\n\t\t\t(integer_time_slot / 60).to_s + \":\" + minutes + \" PM\"\n\t\telse\n\t\t\tminutes = integer_time_slot % 60\n\t\t\tminutes = if minutes < 10 then \"0#{minutes}\" else \"#{minutes}\" end\n\t\t\t(integer_time_slot / 60).to_s + \":\" + minutes + \" AM\"\n\t\tend\n\tend", "def transformTime(time)\n temp1 = time[0..1]\n temp2 = time[2..3]\n temp3 = time[4..5]\n time = temp1+\":\"+temp2+\":\"+temp3\n \n end", "def after_midnight(time_str)\n hours, minutes = time_str.split(':').map(&:to_i)\n (hours * MINUTES_PER_HOUR + minutes) % MINUTES_PER_DAY\nend", "def parse_times( times )\n case times\n when /^\\s*any\\b/i\n Hour.new(\"12 AM\")..Hour.new(\"11 PM\")\n when /^\\s*before (\\d+ [AP]M)\\b/i\n Hour.new(\"12 AM\")..Hour.new($1)\n when /^\\s*after (\\d+ [AP]M)\\b/i\n Hour.new($1)..Hour.new(\"11 PM\")\n when /^\\s*(\\d+ [AP]M) to (\\d+ [AP]M)\\b/i\n Hour.new($1)..Hour.new($2)\n when /^\\s*not available\\b/i\n nil\n else\n raise \"Unexpected availability format.\"\n end\n end", "def day_at(day, time_str)\n hour, minute = time_str.split('H')\n day.dup.getlocal.change(hour: hour, min: minute)\n end", "def after_midnight(time)\n hour,minute = time.split(':').map(&:to_i)\n \n return hour == 24 ?\n 0\n : ((hour * 60) + minute)\nend", "def time_conversion( minutes )\n\n# https://ruby-doc.org/stdlib-2.1.1/libdoc/time/rdoc/Time.html\n#\n# must require 'time' to work\n#\n# t = Time.now\n# puts(t.iso8601)\n# puts(t.rfc2822)\n# puts(t.httpdate)\n#\n# output:\n#\n# 2018-01-18T17:36:58-08:00\n# Thu, 18 Jan 2018 17:36:58 -0800\n# Fri, 19 Jan 2018 01:36:58 GMT\n\n if( minutes < 60 )\n time = minutes.to_s()\n time = \"0:\" + time\n #puts(time)\n return time\n else\n\n hours = minutes / 60\n minutes = minutes % 60 # to get remainning minutes\n\n # puts ( hours )\n # puts( minutes )\n\n time = hours.to_s()\n minutes = minutes.to_s()\n\n if( minutes.length() == 1 )\n minutes += \"0\"\n end\n\n time = time + \":\" + minutes\n\n return time\n end\n\nend", "def TimeConvert(num)\n hour = num/60\n minute = num % 60\n puts (\"#{hour}:#{minute}\")\n\nend", "def findTime(t, k)\n \n # convert the given time in minutes\n minutes = ((((t[0]).ord() - ('0').ord())* 10 + \n (t[1]).ord() - ('0').ord())* 60 + \n (((t[3]).ord() - ('0').ord()) * 10 + \n (t[4]).ord() - ('0').ord()));\n \n # Add K to current minutes\n minutes += k\n \n # Obtain the new hour\n # and new minutes from minutes\n hour = (minutes / 60).to_i % 24\n \n min = minutes % 60\n \n output = \"\"\n \n # Print the hour in appropriate format\n if (hour < 10)\n output = output + 0 + hour.to_s + \":\") \n else\n output = output + hour.to_s + \":\")\n end \n \n # Print the minute in appropriate format\n if (min < 10)\n puts (0 + min.to_s) \n else\n puts (min.to_s)\n end \n\n\n end", "def after_midnight(time)\n time_arr = time.split(':')\n hour = time_arr[0].to_i\n minutes = time_arr[1].to_i\n if hour == 24 && minutes == 0\n 0\n else\n minutes = minutes + ( hour * MINUTES_PER_HOUR )\n end\nend", "def TimeConvert(num)\n\thour = num / 60\n\tmin = num % 60\n\treturn \"#{hour}:#{min}\"\nend", "def strptime_to_hour(time)\n Time.strptime(time, '%m/%d/%Y %k').hour\nend", "def time_conversion(minutes)\n hours = minutes/60\n min = minutes - (hours * 60)\n if min == 0\n min = '00'\n end\n if min > 0 && min < 10\n min = \"0\" + min.to_s\n end\n puts \" #{hours}:#{min}\"\nend", "def nice_time(time)\n time = time.to_i\n return \"\" if time == 0\n t = \"\"\n h = time / 3600\n m = (time - (3600 * h)) / 60\n s = time - (3600 * h) - (60 * m)\n t = good_date(h) + \":\" + good_date(m) + \":\" + good_date(s)\n end", "def time_format\n return :time12 if new_us_user?\n\n clock_type == '12h' ? :time12 : :time24\n end", "def nytimes_time(time, opts={})\n raise ArgumentError.new \"Time or DateTime required\" unless time.is_a?(DateTime) || time.is_a?(Time)\n str = \"\"\n str << time.strftime(\"%l:%M\").strip\n str << time.strftime(\" %p\").sub('PM','p.m.').sub('AM','a.m.') unless opts[:hide_abbreviation]\n str\n end", "def parseTime(time)\n\t\tstr = time.to_s.rjust(4, \"0\")\n\t\t@hour = str[0..1].to_i\n\t\t@minute = str[2..3].to_i\n\tend", "def nice_time(time)\n time = time.to_i\n return \"\" if time == 0\n h = time / 3600\n m = (time - (3600 * h)) / 60\n s = time - (3600 * h) - (60 * m)\n good_date(h) + \":\" + good_date(m) + \":\" + good_date(s)\n end", "def initialTimeDecimal(inputStartTime)\n split = inputStartTime.split(':')\n hours = split[0].to_i\n split = split[1].split(' ')\n #mins = split[0].to_i\n if (split[1] == \"PM\")\n hours += 12\n end\n return hours\nend", "def before_midnight(str)\nhours, minutes = str.split(':').map{|char| char.to_i}\ntime = hours * MINUTES_PER_HOUR + minutes\ntime % MINUTES_PER_DAY\nend", "def appt_date_time_formatter(time, date)\n apptHour = (time[0] + time[1]).to_i\n apptMin = (time[3] + time[4]).to_i\n if time.match(\"PM\")\n apptHour += 12\n end\n appt_date = date.split(\"-\")\n appt_date_year = appt_date[2].to_i\n appt_date_month = appt_date[0].to_i\n appt_date_day = appt_date[1].to_i\n appt_date_time = DateTime.new(appt_date_year, appt_date_month, appt_date_day, \n apptHour, apptMin)\n return appt_date_time\n end", "def pt_et_convert(hour=0,minutes=0)\n\t\tpt = Time.parse(\"#{hour}:#{minutes}\")\n\t\tet = Time.parse(\"#{hour + 3}:#{minutes}\")\n\t\treturn \"#{et.strftime(\"%I%p\").gsub(/^0/, '').downcase} ET (#{pt.strftime(\"%I%p\").gsub(/^0/, '').downcase} PT)\"\t \n\tend", "def hour_12\n self.strftime(\"%I:%M %p\")\n end", "def hour_12\n self.strftime(\"%I:%M %p\")\n end", "def timeformat_change(time)\n from_format = time.to_s.split(\" \")\n from_format = \"#{from_format[0]} #{from_format[1]}\"\n return from_format\n end", "def after_midnight(string)\n hours, minutes = string.split(':').map(&:to_i)\n hours.remainder(24) * 60 + minutes\nend", "def time_conversion(minutes)\n hours = 0\n\n while minutes >= 60\n hours = hours + 1\n minutes = minutes - 60\n end \n \n if minutes < 10\n minutes_string = \"0\" + minutes.to_s \n else \n minutes_string = minutes.to_s\n end\n \n return hours.to_s + \":\" + minutes_string\n \nend", "def time_conversion2(minutes)\n hours = 0\n\n while minutes >= 60 # keep substracting 60 untill leaving just minutes less than 60\n hours += 1\n minutes -= 60\n end\n\n if minutes < 10 # less than two digit minutes\n minutes_s = \"0\" + minutes.to_s\n else # more than 10\n minutes_s = minutes.to_s\n end\n\n return hours.to_s + \":\" + minutes_s\nend", "def time_string(time)\n h = time/3600.to_i # heure\n m = time/60.to_i-h*60 # minute\n s = time - h * 3600 - m * 60 # seconde\n h=pres(h)\n m=pres(m)\n s=pres(s)\n return [h,m,s].join(\":\")\n end", "def display_time(time_type, time)\n message = Time.new.strftime('%H:%M:%S') + \" #{time_type} \"\n message += time.days.positive? ? \"#{time.days} day, \" : ''\n message.insert(message.length - 2, 's') if time.days > 1\n message += time.hours.positive? ? \"#{time.hours}:#{time.minutes}\" : \"#{time.minutes} min\"\n puts message\nend", "def bot(h, m, amOrpm)\n\t\tlastString = ''\t# this will save last string of digital clock\n\n\t\th = h.to_s\t# convert hour from integer to string\n\t\tif m < 10\t# if minute is less than 10\n\t\t\tm = m.to_s\t\n\t\t\tm = '0' + m.to_s\t# then put the 0 in front of minute (ex 09, 02, 03)\n\t\telse\n\t\t\tm = m.to_s\t\t# if not just convert from integer to string\n\t\tend\n\t\ttotal = h + m\t\t\t# I combined the hour and minute in one string\n\n\t\tfor i in 0..total.length-1 do\t# loop until total length\n\t\t\tif total[i] == '1'\t\t\t\t# if character is 1\n\t\t\t\tlastString = lastString + \" | \"\t\t# save proper bar\n\t\t\telsif total[i] == '4' || total[i] == '7'\t# if character is 4 or 7\n\t\t\t\tlastString = lastString + \" |\"\t\t# save proper bar\n\t\t\telsif total[i] == '2'\t\t\t\t# if character is 2\n\t\t\t\tlastString = lastString + \"|_ \"\t\t# save proper bar\n\t\t\telsif total[i] == '3' || total[i] == '5' || total[i] == '9'\t# if character is 3 or 5 or 9\n\t\t\t\tlastString = lastString + \" _|\"\t\t# save proper bar\n\t\t\telsif total[i] == '6' || total[i] == '8'\t# if character is 6 or 8\n\t\t\t\tlastString = lastString + \"|_|\"\t\t# save proper bar\n\t\t\telsif total[i] == '0'\t\t\t\t# if character is 0\n\t\t\t\tlastString = lastString + \"|_|\"\t\t# save proper bar\n\t\t\tend\n\n\t\t\tif h.length == i+1\t\t\t\t# if hour length is matched with i\n\t\t\t\tlastString = lastString + \".\"\t\t# then save dot which represent colon in the future\n\t\t\tend\n\t\tend\n\t\t\n\t\t# AM and PM is consist of same string in middle and top, except bot. So in the bot method we will decide A or P (AM or PM)\n\t\tif amOrpm == 1\t\t\t\t\t\t# This decide last bar of PM or Am\n\t\t\tlastString = lastString + \" | \"\t\t# it is P\n\t\telse\n\t\t\tlastString = lastString + \" | |\"\t\t# It is A\n\t\tend\n\tend", "def after_midnight(time_str)\n count = 0\n hour, min = time_str.split ':'\n hour.to_i.times { count += 60 }\n count += min.to_i\n count % 1440\nend", "def after_midnight(time_str)\n time = Time.parse(time_str)\n (time.hour * 60) + time.min\nend", "def convert_minutes_into_hours(minutes)\n hour = minutes / 60\n min = minutes % 60\nputs \" #{hour}:#{min}\"\nend", "def time_convert(num)\n hr, min = num.divmod(60)\n \"#{hr}:#{min}\"\nend", "def valid_time2(time)\n time = time.split(\":\")\n puts \"0\" <= time[0] && time[0] <= \"23\" && \"0\" <= time[1] && time[1] <= \"59\"\nend", "def fix_time(time=nil)\n if time == nil\n # no full time, use current\n hh, mn, ss = Time.now.strftime(\"%H:%M:%S\").split(':')\n elsif time.size == 3\n # we got full time\n hh = time[0].rjust(2,'0')\n mn = time[1].rjust(2,'0')\n ss = time[2].rjust(2,'0')\n elsif time.size == 2\n # we got full time minus seconds\n hh = time[0].rjust(2,'0')\n mn = time[1].rjust(2,'0')\n ss = Time.now.strftime(\"%S\")\n end\n return hh, mn, ss\n end", "def makeDate date, time\n arrDate = date.split(\"-\")\n arrTime = time.tr('A-Za-z ', '').split(\":\")\n\n #checks if the time is in PM. If yes add 12 hours to it. Special case is when its 12 AM. Need to minus 12 hours.\n if (params[:time].include? \"A\") && arrTime[0] == \"12\"\n arrTime[0] = 0\n elsif (params[:time].include? \"P\") && arrTime[0] != \"12\"\n arrTime[0] = arrTime[0].to_i + 12\n end\n\n return Time.new(arrDate[2], arrDate[1], arrDate[0], arrTime[0], arrTime[1])\n end", "def convert_time(time_string)\n parts = time_string.to_s.split('/')\n return parts.length == 3 ? Time.new(parts[2].to_i, parts[0].to_i, parts[1].to_i) : nil\n end", "def format_time(time, opts = {})\n format = opts[:include_timezone] ? \"%H:%M%:z\" : \"%H:%M\"\n if time.is_a? String\n case time\n when 'now'\n return DateTime.now.strftime format\n else\n unless time =~ /^\\d{2}\\:\\d{2}$/\n raise Fitgem::InvalidTimeArgument, \"Invalid time (#{time}), must be in HH:mm format\"\n end\n timezone = DateTime.now.strftime(\"%:z\")\n return opts[:include_timezone] ? [ time, timezone ].join : time\n end\n elsif DateTime === time || Time === time\n return time.strftime format\n else\n raise Fitgem::InvalidTimeArgument, \"Date used must be a valid time object or a string in the format HH:mm; supplied argument is a #{time.class}\"\n end\n end", "def time_conversion(minutes)\n hr = 0\n min = 0\n \n while minutes >= 0\n if minutes >= 60\n minutes = minutes - 60\n hr = hr + 1\n elsif minutes < 10\n min = 0.to_s + minutes.to_s\n return hr.to_s + ':' + min.to_s\n else\n min = minutes\n return hr.to_s + ':' + min.to_s\n end\n end\nend", "def midnight(time)\n hours, minutes = time.split(':').map!(&:to_i)\n mins_difference = (hours * 60) + minutes\n if mins_difference == 0 || mins_difference == (60 * 24)\n puts \"This time is #{mins_difference} minutes after midnight or #{mins_difference} minutes before midnight too!\"\n else\n puts \"This time is #{mins_difference} minutes after midnight\"\n puts \"This time is #{(60 * 24) - mins_difference} minutes before midnight\"\n end\n mins_difference\nend", "def parse_time(time)\n time = \"0#{time}\" if time.match(/^\\d:\\d\\d/)\n time = time.gsub(/u/, '') if utime?\n time = time.gsub(/s/, '') if stime?\n\n time\n end", "def time_conversion(minutes)\n hours = minutes / 60\n remaining_minutes = minutes % 60\n \"%s:%02d\" % [hours, remaining_minutes]\nend", "def timeofday(input)\n input = input % 1440\n hour, min = input.divmod(60)\n format('%02d:%02d', hour, min)\nend", "def to_s\n if @am_pm\n display = @current.strftime(\"%I:%M\")\n else\n display = @current.strftime(\"%H:%M\")\n end\n @fuzz.times { display.sub!(/\\d(\\D*)$/, '~\\1') } if @fuzz > 0\n display\n end", "def time_conversion(minutes)\n hours, minutes = minutes.divmod(60)\n minutes = ('0' + minutes.to_s)[-2, 2]\n \"#{hours}:#{minutes}\"\nend", "def time_conversion(mins)\n hour = mins/60\n min = mins.modulo(60)\n return '%02d:%02d' %[hour,min]\nend", "def from_to_time_format(from,to)\n @to_format = to\n @from_format = from\n if from == nil && to == nil\n from = (Time.new-24*60*60).to_s.split(\" \")[0]\n to = from + \" 24:00:00\"\n from = from + \" 00:00:00\"\n @from_format = from\n @to_format = to\n return from,to\n end\n if to == nil || to == \"\"\n to = timeformat_change(Time.new)\n @to_format = to\n end\n if from.to_s.size < 5\n from_format = (Time.new + from.to_i*60*60)\n @from_format = timeformat_change(from_format)\n else\n if from.size < 12\n from = from.split(\"-\")\n from = Time.new(from[0].to_i,from[1].to_i,from[2].to_i) \n @from_format = timeformat_change(from)\n end\n end\n if to.size < 12\n @to_format = to+\" 24:00:00\"\n end\n show_info(\"from_time: #{@from_format}\\t to_time #{@to_format}\")\n return @from_format,@to_format\n end", "def after_midnight(time_str)\n time = DateTime.parse(time_str)\n minutes, hours = time.minute, time.hour\n minutes + hours * MINUTES_PER_HOUR \nend", "def before_midnight(str)\n hour, minute = str.split(':').map(&:to_i)\n ( (23-hour) * 60 + (60-minute) ) % 1440\nend", "def time_format(time)\n\t if time\n\t time.strftime(\"%d/%m/%Y %H:%M\")\n\t end\n\tend" ]
[ "0.74392605", "0.7401905", "0.7399482", "0.7308697", "0.72945887", "0.72411305", "0.72367275", "0.72241366", "0.7184251", "0.7158791", "0.7097165", "0.7096342", "0.69559735", "0.6792906", "0.67880046", "0.6787258", "0.6785053", "0.67141044", "0.66891676", "0.66418207", "0.6612558", "0.6610305", "0.66098744", "0.6570784", "0.6568206", "0.6557452", "0.65541965", "0.6541096", "0.6521441", "0.6519657", "0.6503737", "0.65003806", "0.64790124", "0.64747465", "0.64677525", "0.6466189", "0.64658713", "0.6425083", "0.64209765", "0.641323", "0.640636", "0.64015067", "0.64008105", "0.6391632", "0.63781977", "0.63704264", "0.63616574", "0.63555485", "0.6322873", "0.63125217", "0.6307036", "0.62970483", "0.6276813", "0.62750334", "0.6273944", "0.6273308", "0.62573516", "0.6255435", "0.6246858", "0.6246374", "0.62441254", "0.62161666", "0.6207377", "0.62042594", "0.62039185", "0.6202098", "0.620099", "0.6200117", "0.61986136", "0.61877453", "0.618633", "0.618633", "0.6184003", "0.61722684", "0.6170902", "0.61616766", "0.61255425", "0.6114354", "0.6111441", "0.6109024", "0.61079353", "0.6101721", "0.60949516", "0.6093574", "0.60904837", "0.60882294", "0.60783434", "0.6072657", "0.60710365", "0.6052946", "0.6052659", "0.6050236", "0.6037763", "0.60190827", "0.6017319", "0.6009632", "0.6008245", "0.6004284", "0.59983534", "0.5994533" ]
0.7371044
3
Initializer. It prepares all the dirty stuff needed to have a
def initialize(args={}) @cfg = { :path => "/Users/cremes/dev/mygit/proto-rina/README.md", :id => 25, :len => 1024, :mode => Shared::IPC_CREAT, :access => Shared::IPC_W | Shared::IPC_R } @cfg.merge! args @key = Shared::try("ftok") {Shared::ftok(@cfg[:path], @cfg[:id])} @id = Shared::try("shmget") {Shared::shmget(@key, @cfg[:len], 0666 | @cfg[:mode])} p @id, @key, @cfg[:len], (0666 | @cfg[:mode]) @mem = Shared::shmat(@id, 0, @cfg[:access]) p @mem, @id end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def post_init\n end", "def pre_initialize; end", "def init; end", "def init; end", "def init; end", "def init; end", "def pre_initialize\n end", "def init\n end", "def init\n end", "def init\n end", "def post_init\n end", "def at_init\n\n\t\tend", "def init\n\n end", "def post_initialize\n end", "def initialize() end", "def initialize\n initialize!\n end", "def initialize\n initialize!\n end", "def post_init\n\tend", "def initialize\n init\n end", "def initialize\n clean\n end", "def init\n\nend", "def initialize\n \n end", "def after_initialize\n end", "def initialize\n super()\n init_data()\n end", "def init; end", "def initialize()\n end", "def initialize\n reset!\n end", "def initialize\n reset!\n end", "def initialize()\n\t\tend", "def initialize\n\t\t\n\tend", "def initialize \n # Keep track of hooks and what object owns what\n @hooks = {}\n @cmds = {}\n @modules = {}\n\n # Prevent access to hooks when other things are\n # editing or using them.\n @hooks_mutex = Mutex.new\n end", "def post_setup\n end", "def initialize\n\n\n\n end", "def user_init; end", "def standard_setup\n @body = Body.new(@client)\n @entity_tracker = EntityTracker.new(@client, @body)\n @chunk_tracker = ChunkTracker.new(@client)\n @inventory = Inventory.new(@client)\n end", "def initialize\n # complete\n end", "def after_initialize; end", "def after_initialize; end", "def after_initialize; end", "def after_initialize; end", "def post_initialize\n # raise NotImplementedError\n end", "def before_initialize(&block); end", "def initialize\r\n\r\n end", "def initialize\n @preloader = Rendering::NoopPreloader\n @pretty = true\n @cache_templates = false\n @lookup_context = nil\n @using = []\n end", "def initialize()\r\n\r\n end", "def initialize\n reset!\n end", "def initialize\n reset!\n end", "def initialize\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 Init()\n end", "def initialize\n reset!\n end", "def initialize\n\n\tend", "def initialize\n\n\tend", "def auto_initialize!\n # noop by default\n end", "def initialize\n # Create temporary data directory\n create_data_dir\n\n # Init connection to ADS\n init_ads\n\n # Initialize Data science toolkit\n init_dstk\n\n # Init connection to SQLite\n # init_sqlite3\n end", "def initialize\n reset\n \tend", "def prepare\n FileUtils.rm_rf(@tempdirs, secure: true) if @tempdirs\n @tempdirs = []\n @base_options = nil\n @mode_options = nil\n @user_recipients = nil\n @user_keys = nil\n @system_identifiers = nil\n end", "def initialize_environment\n end", "def initialize_environment\n end", "def after_initialize\n # noop\n end", "def initialize\n preprocess false\n debug false\n end", "def initialize(*args)\n\t\t\t\t\tself.track_changed_attributes = true\n\t\t\t\t\tself.changed_attributes_aado = []\n\n\t\t\t\t\tsuper(*args)\n\t\t\t\t\t\n\t\t\t\t\trequire \"obdb/AR_DatabaseObject\"\t# its here because of a circular reference problem\n\t\t\t\t\tself.database_object = DatabaseObject.create_do(self.class, self.id, self)\n\t\t\t\tend", "def pre_initialize_fields\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end", "def initialize()\n super\n end" ]
[ "0.7586399", "0.7392385", "0.7365339", "0.7365339", "0.7365339", "0.7365339", "0.7297682", "0.7227676", "0.7227676", "0.7227676", "0.72090983", "0.71922284", "0.7171496", "0.7045878", "0.7009534", "0.70022476", "0.70022476", "0.6986332", "0.69289833", "0.6917057", "0.68771005", "0.68463033", "0.68345547", "0.6819389", "0.68164665", "0.68011427", "0.679051", "0.679051", "0.6771724", "0.67540705", "0.6753683", "0.6729971", "0.67215157", "0.6720851", "0.6708964", "0.6699187", "0.6698846", "0.6698846", "0.6698846", "0.6698846", "0.6692456", "0.66924524", "0.66632164", "0.66555643", "0.663416", "0.6633979", "0.6633979", "0.662959", "0.6608542", "0.6608542", "0.660844", "0.66054493", "0.6596238", "0.6596238", "0.6573495", "0.6553107", "0.65515167", "0.6533023", "0.65310127", "0.65310127", "0.65278345", "0.6521035", "0.6519459", "0.65140647", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338", "0.6511338" ]
0.0
-1
Closes the shared memory area end frees its content.
def close Shared::try("dhmdt") {Shared::shmdt(@mem)} Shared::try("shmctl") {Shared::shmctl(@id, Shared::IPC_RMID, nil)} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def close\n @sp.close if @sp != nil\n @sp = nil\n end", "def close\n @io.close if @io\n @m.munmap if @m\n @m = nil\n @io = nil\n end", "def dispose\n call Memory.deAlloc(self)\n end", "def dispose\n call Memory.deAlloc(self)\n end", "def close() end", "def close() end", "def close() end", "def close() end", "def close() end", "def dispose; end", "def close\n @s.close\n end", "def close\n\t\t@sp.close\n\tend", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close; end", "def close\n return unless @_context\n XDo::FFILib.xdo_free @_pointer\n @_pointer = nil\n @_context = nil\n end", "def close\n\t\t@manager.close\n\tend", "def close\n Common.uncontain\n self\n end", "def close\n\n # nothing to do here.\n end", "def close\n Wrapper.Quit(@native_manager) if @native_manager\n ensure\n @native_manager = nil\n end", "def close\n if @src.data.respond_to? :unmap\n @src.data.unmap\n end\n end", "def close()\n @closed = true\n end", "def close\n @closed = true\n end", "def finalize\n close\n end", "def close()\n #This is a stub, used for indexing\n end", "def close\n @mutex.synchronize do\n @thread.kill\n @store.each_value do |value|\n sess, _ = value\n sess.close(@context)\n end\n end\n end", "def close\n @h.close\n end", "def close\n @closed = true\n end", "def _close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n @data.close\n @index.close\n end", "def close\n sync\n\n @data_file.close\n\n write_hint_files\n\n File.delete @lockfile\n end", "def do_close; end", "def close() \n @my.close()\n @my = nil\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n close!\n end", "def close\n # Force full flush call to ensure that all accumulated messages are flushed.\n buffer_flush(:final => true)\n end", "def close!\n _close\n @clean_proc.call\n ObjectSpace.undefine_finalizer(self)\n end", "def dispose\n nil\n end", "def close\n end", "def close\n end", "def close\n close_data_file\n end", "def close\n @ram_list = nil\n end", "def close\n self.disconnect\n end", "def close\n end", "def close\n end", "def close\n end", "def close\n @output.write('', :reloaded)\n @output.close\n end", "def close!\n storages.each_value(&:close) and @storages = {}\n nil\n end", "def close\n SAP_LOGGER.debug(\"In #{self.class} close ...\")\n\t \t return nil unless self.handle\n SAP_LOGGER.debug(\"In #{self.class} handle: #{self.handle} ...\")\n res = self.handle.close()\n\t\t \tself.handle = nil\n\t\t\t\t# XXX Should destroy all cached functions and structures and types tied to handle ?\n\t\t \treturn true\n\t\t end", "def close\n SAP_LOGGER.debug(\"In #{self.class} close ...\")\n\t \t return nil unless self.handle\n SAP_LOGGER.debug(\"In #{self.class} handle: #{self.handle} ...\")\n res = self.handle.close()\n\t\t \tself.handle = nil\n\t\t\t\t# XXX Should destroy all cached functions and structures and types tied to handle ?\n\t\t \treturn true\n\t\t end", "def closing; end", "def closing; end", "def close\n asl_free(@aslmsg) if @aslmsg\n asl_close(@aslclient) if @aslclient\n @aslmsg = nil\n @aslclient = nil\n end", "def close\n # ..\n end", "def dispose\n\n end", "def close\n nil\n end", "def close\n update\n end", "def close #:nodoc:#\n update\n end", "def close!\n safe_close\n end", "def close\n # NOOP\n end" ]
[ "0.6465218", "0.63502145", "0.63124734", "0.63124734", "0.62463796", "0.62463796", "0.62463796", "0.62463796", "0.6243381", "0.6235345", "0.6208395", "0.61819994", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.616931", "0.6168863", "0.61472887", "0.61410564", "0.6138848", "0.6121636", "0.6116288", "0.61152035", "0.61000836", "0.60938853", "0.6078307", "0.6078011", "0.6077218", "0.6067439", "0.6065541", "0.606549", "0.606549", "0.606549", "0.606549", "0.606549", "0.606549", "0.606549", "0.606549", "0.606549", "0.60466796", "0.6037477", "0.6021425", "0.6020136", "0.60172224", "0.60172224", "0.60172224", "0.60172224", "0.60172224", "0.60172224", "0.60172224", "0.60172224", "0.60172224", "0.60137147", "0.6005552", "0.60039896", "0.5991613", "0.59906864", "0.59906864", "0.5989907", "0.59887654", "0.59775", "0.5974763", "0.5974763", "0.5974763", "0.5973515", "0.5969663", "0.59548944", "0.59548944", "0.5951553", "0.5951553", "0.5950724", "0.59438074", "0.593933", "0.59198475", "0.5905905", "0.5902395", "0.590069", "0.58944213" ]
0.68270093
0
Writes a string len bytes.
def write(str, len=nil) raise ArgumentError, "str must respond to :to_s" unless str.respond_to? :to_s @mem.write_string(str.to_s, len) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(string)\n send(string)\n string.length\n end", "def write(str)\n s = str.to_s\n # TODO: implement String#bytesize\n @length += s.size\n @writer.call s\n\n set_header(Rack::CONTENT_LENGTH, @length)\n str\n end", "def write(string)\n string.to_s.bytesize\n end", "def write(str)\n s = str.to_s\n\n @length += s.bytesize\n @headers[Rack::CONTENT_LENGTH] = @length.to_s\n @body << s\n end", "def write(s)\n do_write(s)\n s.bytesize\n end", "def write(str)\n writing { write0 str }\n end", "def send(str)\n # $stderr.puts str.size\n (p str.size;fail) if str.size > 0x20\n print str.ljust(0x20, 'A')\nend", "def write(string)\n\t\t\t\t@write_buffer << string\n\t\t\t\t\n\t\t\t\tif @write_buffer.size > @block_size\n\t\t\t\t\tflush\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn string.bytesize\n\t\t\tend", "def write string\n end", "def write_string(string)\n\t\twrite_byte(2)\n\t\twrite_utf(string.to_s)\n\tend", "def read_string(length)\n BinData::Stringz.read(read_and_advance(length))\n end", "def write(string)\n written = 0\n length = string.bytesize\n while written < length\n begin\n written += write_nonblock(string.byteslice(written, length - written))\n rescue IO::WaitWritable, Errno::EINTR\n block_until_writable\n retry\n end\n end\n written\n end", "def lzpad(str, length)\n until str.length == length\n str = '0' + str\n end\n str\n end", "def length\n string.length\n end", "def set_length(len , fill_char)\n return if len <= 0\n counter = self.length()\n return if counter >= len\n internal_object_grow( len + 1)\n fill_from_with( counter + 1 , fill_char )\n end", "def bytesize(string)\n string.respond_to?(:bytesize) ? string.bytesize : string.length\n end", "def stringio_length(io)\n io.string.length\n end", "def _w(str)\n _t(str).length.to_s\n end", "def write(string)\n length = string.length\n while 0 < length\n IO::select(nil, [@sock])\n @dumplog.log_dump('>', string[-length..-1]) if @options.has_key?(\"Dump_log\")\n length -= @sock.syswrite(string[-length..-1])\n end\n end", "def _v(str)\n _f(str).length.to_s\n end", "def length\n @string.length\n end", "def pad!(str_length=nil)\n @value = pad(str_length)\n end", "def length_prefixed_string(data)\n msg = data.encode(Encoding::UTF_8)\n # https://ruby-doc.org/core-1.9.3/Array.html#method-i-pack\n [msg.bytes.length].pack('V') + msg.force_encoding(Encoding::BINARY)\n end", "def make(byte, length)\n while byte.length < length\n byte = \"0\" + byte\n end\n return byte\nend", "def RandomString(len)\n rand_max = RAND_CHARS.size\n ret = \"\" \n len.times{ ret << RAND_CHARS[rand(rand_max)] }\n ret \n end", "def write_string(string)\n if string.nil?\n write_int16(-1)\n else\n write_int16(string.bytesize)\n write(string)\n end\n end", "def random_string(len)\n rand_max = RAND_CHARS.size\n ret = \"\" \n len.times{ ret << RAND_CHARS[rand(rand_max)] }\n ret \n end", "def random_string(len)\n rand_max = RAND_CHARS.size\n ret = \"\"\n len.times{ ret << RAND_CHARS[rand(rand_max)] }\n ret\n end", "def write(string)\n @handle.write(string)\n end", "def write str = \"\"\n @socket.write str + \"\\r\\n\"\n end", "def length(str)\n g_unpack(str).length\n end", "def write_varint_string(string)\n if string.nil?\n write_varint(-1)\n else\n write_varint(string.bytesize)\n write(string)\n end\n end", "def width(str)\n str.length\n end", "def width(str)\n str.length\n end", "def string()\n len = self.uint32()\n self.bytes(len)\n end", "def write(string)\n @buffer << string\n self\n end", "def send(str)\n write(str + 0.chr)\n end", "def random_string(len)\n chars = (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (\"0\"..\"9\").to_a\n str = \"\"\n 1.upto(len) { |i| str << chars[rand(chars.size-1)] }\n str\n end", "def fixed_length_string(name, bytes, options = {})\n impl = Tem::Builders::Abi::Impl\n signed = options.fetch :signed, true\n big_endian = options.fetch :big_endian, true \n \n defines = Proc.new do \n define_method :\"read_#{name}\" do |array, offset| \n impl.string_from_array array, offset, bytes\n end\n define_method :\"to_#{name}\" do |n|\n impl.string_to_array n, bytes\n end\n define_method(:\"#{name}_length\") { bytes }\n end\n \n @target.class_eval(&defines)\n (class << @target; self; end).module_eval(&defines)\n end", "def put_string(*strings)\n strings.each { |s| @request << [s.length].pack('N') + s }\n self\n end", "def random_string_of_length(length)\r\n str = ''\r\n 1.upto(length) do\r\n str << CHARS[rand(CHARS.size)]\r\n end\r\n str\r\n end", "def bytes(length)\n length = Rubinius::Type.coerce_to length, Integer, :to_int\n s = ''\n i = 0\n while i < length\n s << @randomizer.random_integer(255).chr\n i += 1\n end\n\n s\n end", "def write_byte(*n); end", "def write_(s)\n s = s.encode(@conf['encoding'], s.encoding)\n @sock.puts s\n log.info \"W > #{s}\"\n end", "def write(string, *smth)\n #This is a stub, used for indexing\n end", "def write(bytes)\r\n end", "def write_string(string, data: nil, stream: nil)\n raise ArgumentError, \"String must be present\" if !string\n\n intbuf = write_varint(string.bytesize, data: data, stream: stream)\n\n stringbuf = BTC::Data.ensure_binary_encoding(string)\n\n data << stringbuf if data\n stream.write(stringbuf) if stream\n\n intbuf + stringbuf\n end", "def length_of_string(the_string)\n puts 'your string is this many characters ' + the_string.length.to_s\nend", "def random_string(len)\n # first, we make a bunch of random characters in an array\n chars = (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (\"0\"..\"9\").to_a\n newpass = \"\"\n # then we grab a random element of that array, and add it onto our newpass\n 1.upto(len) { |i| newpass << chars[rand(chars.size-1)] }\n return newpass\n end", "def write_utf(file, string, md)\n write_short(file, string.length, md)\n write(file, string, md)\n end", "def length\n length = 0\n each{|s| length += s.bytesize}\n length\n end", "def string(val)\n val = val.to_s\n\n raise ArgumentError, \"string() cannot encode a string longer \" +\n \"than 2**32-1 bytes\" \\\n unless val.length <= 2**32-1\n\n self.uint32(val.length).bytes(val)\n end", "def add_to_length_written(size)\n @length_written += size\n raise \"Content-Length overwritten: #{@length_written}, #{@content_length}\" if @content_length != nil && @length_written > @content_length\n end", "def syswrite(string)\n raise NotImplementedError\n end", "def size=(size)\n throw ArgumentError.new('new size is negative') if size.negative?\n size -= data.size\n if size.positive?\n @data += '\\0' * size\n elsif size.negative?\n @data = @data[0...size]\n end\n @data.size\n end", "def write(s)\n @data += s\n end", "def length=(length)\n end", "def write(str)\n puts self.writings(str)\n end", "def write(str)\n puts self.writings(str)\n end", "def bytes(val)\n val = val.to_s\n\n # Pad with zeros until length is a multiple of 4\n while val.length % 4 != 0 do\n val += \"\\0\"\n end\n\n @io.write(val)\n end", "def length (string)\n string.length\nend", "def send(str)\r\n @socket.write(str + 0.chr)\r\n end", "def strlen(key)\n send_command([:strlen, key])\n end", "def make_truncatable_string str, truncated_byte_count = 0\n TraceProtos::TruncatableString.new \\\n value: str,\n truncated_byte_count: truncated_byte_count\n end", "def write!( string )\n @stream << string\n end", "def write_string(*text); end", "def string_inspect(str, len)\n str = \"#{str[0, len]}...\" if str.length > len\n str.inspect\n end", "def do_write(s)\n @wbuffer << s\n @wbuffer.force_encoding(Encoding::BINARY)\n @sync ||= false\n\n if @sync or @wbuffer.size > BLOCK_SIZE or idx = @wbuffer.rindex($/)\n remain = idx ? idx + $/.size : @wbuffer.length\n nwritten = 0\n\n while remain > 0\n str = @wbuffer[nwritten,remain]\n begin\n nwrote = syswrite(str)\n rescue Errno::EAGAIN\n retry\n end\n remain -= nwrote\n nwritten += nwrote\n end\n\n @wbuffer[0,nwritten] = \"\"\n end\n end", "def pad_string(s)\n # s = s[0..80]\n b = s.bytes\n b << 0\n b << 0 while b.size % 4 > 0\n b.pack(\"c*\")\n end", "def write(string)\n log :write, string\n @socket << string\n end", "def length_of_string(string)\n string = \"A string of length 21\".length\nend", "def random_string(len=8)\n (0...len).map{65.+(rand(25)).chr}.join\n end", "def recording_length_string(len)\n if len > 60\n \"#{(len / 60).to_i} h #{len % 60} min\"\n else\n \"#{len} min\"\n end\n end", "def get_str(offset, len)\n @buf[offset..offset+len-1]\n end", "def write_string_to(key, string, mtime: nil)\n mtime ||= Time.now\n copy_io_to(key, StringIO.new(string), Digest::MD5.base64digest(string), string.length, mtime: mtime)\n end", "def pad(key, len)\n key ? key.to_s.rjust(len, '0') : nil\n end", "def peek(len)\n return \"\" if eos?\n\n @string[@current, len]\n end", "def generate(len = 5)\n @str = ''\n \n len.times do\n i = rand(@@CHARS.size)\n @str += @@CHARS[i]\n end\n \n @str\n end", "def string(str)\n raise(TypeError, \"wrong argument type #{str.class} (expected String)\") unless str.is_a?(String)\n p = FFI::MemoryPointer.new(str.size)\n p.write_string_length(str, str.size)\n FFI::Libmagic.magic_buffer(_cookie, p, str.size)\n end", "def gen_string(str_type, length = 10)\n raise ArgumentError, \"str_type: #{str_type} not supported\" unless RFauxFactory::STRING_TYPES.key?(str_type)\n send(RFauxFactory::STRING_TYPES[str_type], length)\n end", "def write(string)\n self << string\n end", "def string_length(password)\n if password.size >= 10 && password.size < 17\n return 0\n else\n return password.size > 16 ? (16 - password.size) : 10 - password.size\n end\n end", "def <<(str)\n raise RecordTooLarge.new(str) if str.bytesize >= MAX_BYTES_PER_RECORD\n @buffer << str\n end", "def length_of_string(str)\n return str.length\n end", "def length\n to_s.length\n end", "def rand_string(len)\n o = [('a'..'z'),('A'..'Z')].map{|i| i.to_a}.flatten\n string = (0..len).map{ o[rand(o.length)] }.join\n\n return string\n end", "def ios_password(length = 1)\n 8226.chr('UTF-8') * length\n end", "def pascal_string_len_field(name)\n \"_#{name.to_s}_len\".to_sym\n end", "def write(s)\n binary_to_store = Marshal.dump(s)\n bytes = @ioctx.write(@oid, binary_to_store, binary_to_store.size, @offset)\n # add an xattr :\n set_attribut(@@size_xattr, binary_to_store.size)\n \n @offset += bytes\n bytes\n end", "def send(message)\n length = sprintf(\"%-8d\", message.length)\n @socket.write(\"#{length}#{message}\")\n end", "def length()\n return to_s.size\n end", "def set_string string, pos\n @string = string\n @string_size = string ? string.size : 0\n @pos = pos\n end", "def set_string string, pos\n @string = string\n @string_size = string ? string.size : 0\n @pos = pos\n end", "def set_string string, pos\n @string = string\n @string_size = string ? string.size : 0\n @pos = pos\n end", "def write s\n raise RuntimeError, \"No socket\" unless @socket\n @socket.puts s += \"\\r\\n\"\n puts \"WROTE: #{s.inspect}\" if config[:debug]\n end", "def string(str)\n TYPE_STRING +\n word(str.length) +\n str.encode!(\"ASCII\")\n end", "def wrap(msg,len)\n finalmsg = [msg].pack(\"v\")\n finalLen = [len].pack(\"V\")\n return finalmsg+finalLen\nend", "def max=(length)\n @string_rule.max = length\n end", "def string\n io.pos = start_index unless io.pos == start_index\n io.read(num_bytes)\n end", "def store_text_length locator, variable_name\n command 'storeTextLength', locator, variable_name\n end" ]
[ "0.7160371", "0.6932254", "0.67634094", "0.65381235", "0.64792395", "0.62913436", "0.61667496", "0.6080244", "0.60673696", "0.6021334", "0.6009206", "0.596005", "0.5925651", "0.59051514", "0.5896064", "0.58767563", "0.5869751", "0.5854464", "0.58264357", "0.58109885", "0.5783207", "0.57444584", "0.57131004", "0.5667552", "0.5657813", "0.56477046", "0.5642698", "0.563911", "0.5635703", "0.5632489", "0.56320846", "0.5597271", "0.55936956", "0.55936956", "0.55588245", "0.5536103", "0.55259204", "0.55098706", "0.5496647", "0.5490691", "0.5489752", "0.54858065", "0.54743445", "0.5466066", "0.5459513", "0.5443749", "0.54408514", "0.5417256", "0.5413097", "0.54054815", "0.5402062", "0.53926915", "0.5391341", "0.53840077", "0.5362197", "0.5350816", "0.5331987", "0.5327261", "0.5327261", "0.53254396", "0.5322616", "0.5316188", "0.53073883", "0.5305454", "0.5295909", "0.52951175", "0.5294358", "0.5278825", "0.5276197", "0.527144", "0.52671343", "0.52533925", "0.524737", "0.5242962", "0.5238792", "0.52337545", "0.52337533", "0.5232746", "0.52266467", "0.5219513", "0.521276", "0.52101713", "0.5208514", "0.5198224", "0.5189996", "0.51890635", "0.518616", "0.5180542", "0.5177089", "0.51678264", "0.51651716", "0.51547503", "0.51547503", "0.51547503", "0.5136388", "0.5135691", "0.51260775", "0.51248807", "0.51025474", "0.5094611" ]
0.8049257
0
without refilling it. And you need to get from point A to point B, and the distance between them is 950 kilometers. Of course, you need to refuel on your way, and luckily, there are a few gas stations on your way from A to B. These are denoted by blue circles, and the numbers above them mean the distance from A to the corresponding gas station along the way from A to B. And you need to find the minimum number of refuels to get from A to B. input: we have a car which can travel at most L kilometers, where L is a parameter if it's filled up to full tank. We have a source and destination, A and B, and we have n gas station at distances from x1 to xn in kilometers, from A along the path from A to B. And we need to output the minimum number of refills to get from A to B, not counting the initial refill at A. We want to solve this problem using a greedy strategy, and greedy strategy in general is very easy. You first make some greedy choice, then you reduce your problem to a smaller subproblem, and then you iterate until there are no problems left. D = total distance between A and B
def min_refuel array_of_gas_station, total_distance, l_km t1 = Time.now total_refuel = 0 refueld_at = [] can_travel = l_km flag = "yes" array_of_gas_station.each_with_index do |arr,index| if arr > can_travel can_travel += l_km total_refuel += 1 refueld_at << (index-1) elsif arr == can_travel can_travel += l_km total_refuel += 1 refueld_at << index end end refueld_at.each_with_index do |arr, i| if refueld_at[i] == refueld_at[i+1] || refueld_at[i] < 0 flag = "no" end end if flag.eql? "yes" t2 = Time.now p "total refuel : #{total_refuel}" p "refueled at : #{refueld_at}" p "Time taken : #{t2 - t1}" else t2 = Time.now p "can't travel" p "Time taken : #{t2 - t1}" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def min_refills(x,n,L)\n\t# total number of refills done so far\n\tnum_refills = 0\n\t# the stop from where we are evaluating whether or not to refill \n\tcurrent_stop = 0\n\n\t# while there are still stops on the road\n\twhile current_stop <= n\n\t\t# last stop where added gas\n\t\tlast_stop_refill = current_stop\n\n\t\t# we check is there are still stops to make\n\t\t# we check if the difference between the next stop and the last stop where \n\t\twhile (current_stop <= n && x[current_stop + 1] - x[last_stop_refill] < L)\n\t\t\tcurrent_stop += 1\n\t\tend\n\n\t\t# if the curren stop did not change meaning that we never entered the previous loop\n\t\t# means that the next stop was too far away and we could no reach it so the trip is imposible\n\t\tif current_stop == last_stop_refill\n\t\t\treturn \"impossible trip\"\n\t\tend\n\n\t\t# if we get here means that there is a new stop where we refilled and we can up the \n\t\t# count if there are still stops to go\n\t\tif current_stop <= n\n\t\t\t# We could also keep track of the path in here\n\t\t\tnum_refills += 1\n\t\tend\n\tend\n\n\tnum_refills\nend", "def solve(distance, other_car, as)\n other_car_vs = [] \n other_car.each_cons(2) do |from, to|\n other_car_vs << (to[1] - from[1]) / (to[0] - from[0])\n end\n return as.collect { |a| Math.sqrt(2*distance/a) } if (other_car_vs == [])\n return as.collect { |a| [Math.sqrt(2*distance/a), (distance - other_car[0][1]) /other_car_vs[0]].max }\nend", "def find_solution\n open = [{:cell => @start_cell, :parent => nil, :distance => 0}]\n closed = []\n\n while !open.empty?\n # Find the lowest movement cost\n current_node = open.min{ |a,b| a[:distance] <=> b[:distance]}\n\n # Check if we reached the end cell\n if is_end?(current_node[:cell])\n return current_node[:distance]\n end\n\n # Find immediate neighbors\n current_neighbors = find_neighbors(current_node[:cell])\n current_neighbors.each { | neighbor |\n if closed.find { | node | node[:cell].eql?(neighbor[:cell])}.nil?\n # Find if the cell is already in the open list\n existing_open = open.find { |node | node[:cell].eql?(neighbor[:cell])}\n if existing_open\n # Find the shorter distance to the cell\n current_distance = existing_open[:distance]\n new_distance = current_node[:distance] + neighbor[:distance]\n existing_opened[:distance] = new_distance if current_distance > new_distance\n else\n # Add the new visited cell to the open list\n neighbor[:distance] = neighbor[:distance] + current_node[:distance]\n open << neighbor\n end\n end\n }\n closed << current_node\n open.delete(current_node)\n end\n 0\n end", "def dijkstra(city1, city2)\n #if city's distance is the same\n if city1==city2\n return 0\n end\n #set up dijkstra\n\n active = []\n distance = Hash.new\n previous = Hash.new\n\n @metros.each do |city_code, metro|\n distance[city_code] = Float::INFINITY\n previous[city_code] = nil\n active.push(city_code)\n end\n\n distance[city1] = 0\n until active.empty?\n #remove the min from dis\n min_city = active[0]\n min_dist = distance[min_city]\n active.each do |city|\n if distance[city]<min_dist\n min_dist = distance[min_city]\n min_city = city\n end\n end\n active.delete(min_city)\n this_city = min_city\n\n #for all the neighbor\n dest = @metros[this_city].destination\n dest.each do |next_city, dist|\n current_distance = get_distance(this_city, next_city)\n total_distance = distance[this_city]+current_distance\n if total_distance < distance[next_city]\n distance[next_city] = total_distance\n previous[next_city] = this_city\n end\n end\n end\n #return a list of prebious cities\n return previous, distance\n\n end", "def solve(input_a, input_b)\n least_distance_from_start(\n cross_points(\n covered_cells(split_parse(input_a)),\n covered_cells(split_parse(input_b))\n )\n )\nend", "def guide(from, to, unit_type=nil, max_depth=400)\n return nil if @map.blocked?(from, unit_type) || @map.blocked?(to, unit_type)\n from_element = PathElement.new(from)\n from_element.dist_from = @map.distance(from,to)\n open = PriorityQueue.new { |x, y| (x <=> y) == -1 }\n open.push from_element, from_element.rating\n closed = SplayTreeMap.new\n step = 0\n \n until open.empty? || step > max_depth\n step += 1\n \n current_element = open.pop\n @nodes_considered += 1\n \n loc = current_element.location\n if @map.cost(loc,to) == 0\n path = []\n until current_element.parent.nil?\n path.unshift current_element\n current_element = current_element.parent\n end\n\n return path\n else\n closed.push loc, current_element\n @map.neighbors(loc).each do |next_door|\n next if closed.has_key? next_door\n\n el = PathElement.new(next_door,current_element)\n\n if @map.blocked? next_door, unit_type\n closed.push el.location, el\n else\n current_rating = current_element.cost_to + @map.cost(loc, next_door)\n\n # add to open\n el.cost_to = current_rating\n el.dist_from = @map.distance(next_door,to)\n \n open.push el, el.rating\n end\n end\n end\n end\n nil\n end", "def find_shortest_distance(from_city,to_city)\n\n # store the intermediate cities in Queue\n intermedite_cities = Queue.new\n\n # Store the start city\n intermedite_cities.push [from_city,0]\n \n minimum_distance =0\n\n #Find distance till target city reached\n until intermedite_cities.empty?\n #pop up the first element\n city = intermedite_cities.pop\n\n if city.first == to_city\n minimum_distance = city.last.to_i if (minimum_distance > city.last.to_i)|| minimum_distance==0\n next\n end\n\n #store adjucent cities in queue\n old_distance = city.last.to_i\n for adjust_city in adjucent_cities(city.first)\n if (minimum_distance > old_distance+adjust_city.last.to_i) || minimum_distance==0\n intermedite_cities.push [adjust_city.first,old_distance+adjust_city.last.to_i]\n end\n end\n end\n minimum_distance\n end", "def guide(from, to, unit_type=nil, max_depth=400)\n return nil if @map.blocked?(from, unit_type) || @map.blocked?(to, unit_type)\n from_element = PathElement.new(from)\n from_element.dist_from = @map.distance(from,to)\n open = PrioritySet.new\n open.push from_element, from_element.rating\n closed = SplayTreeMap.new\n step = 0\n\n until open.empty? || step > max_depth\n step += 1\n\n current_element = open.pop\n @nodes_considered += 1\n\n loc = current_element.location\n if @map.cost(loc,to) == 0\n path = []\n until current_element.parent.nil?\n path.unshift current_element\n current_element = current_element.parent\n end\n\n return path\n else\n closed.push loc, current_element\n @map.neighbors(loc).each do |next_door|\n if closed.has_key? next_door\n next\n end\n \n el = PathElement.new(next_door,current_element)\n\n if @map.blocked? next_door, unit_type\n closed.push el.location, el\n else\n current_rating = current_element.cost_to + @map.cost(loc, next_door)\n\n # add to open\n el.cost_to = current_rating\n el.dist_from = @map.distance(next_door,to)\n el.reset_rating\n\n open.push el, el.rating\n end\n end\n end\n end\n nil\n end", "def solution (x, y, d)\n distance = y - x\n no_of_jumps = distance.to_f / d\n puts no_of_jumps.ceil\nend", "def dijkstra(source, destination, calcweight)\n\tvisited = Hash.new\t\t\t\t#hash of airports and booleans\n\tshortest_distances = Hash.new\t#hash of airports and the cost of reaching that airport from source\n\tprevious = Hash.new\t\t\t\t#hash of airports and their predecessor in the dijkstra algorithm -- the values are tuples of airports and flights\n\t@airports.each do |a|\n\t\tvisited[a] = false\t\t\t#initially no airports are visited\n\t\tshortest_distances[a]=@INFINITY\t\t#the cost to reach every airport is infinite\n\t\tprevious[a]= [nil,nil]\t\t\t#no airport has been reached yet\n\tend\n\n\t#info about priority queue: http://www.math.kobe-u.ac.jp/~kodama/tips-ruby-pqueue.html\n\tpq = PQueue.new(proc {|x,y| shortest_distances[x[0]] < shortest_distances[y[0]]})\n\n\tpq.push([source,@date]) \t\t#the priority queue contains a tuple of airports and the arrival time in that airport\n\tvisited[source] = true\n\tshortest_distances[source] = 0\n\n\n\n\twhile pq.size!=0\t\t\t#If the priority queue is empty, the algorithm is finished\n\t\tnode = pq.pop\n\t\tvisited[node[0]] = true\t\t#(node[0] contains the airport code)\n\n\t\t#if edges[v]\n\t\t\tnode[0].connections.each do |w|\t\n\n\t\t\t\tif visited[w]==false\n\t\t\t\t\tf = getFlights(node[0],w,node[1])\t#for each connection from that airport\n\t\t\t\t\tif(not f.nil? and f.length!=0)\t\t#get the suitable flights\n\t\t\t\t\t\tweight = @INFINITY\t\t#and find the most optimal of this array of flights\n\t\t\t\t\t\tflight = nil\n\n\t\t\t\t\t\tf.each do |fl|\t\t\t\n\t\t\t\t\t\t\tt = calcweight.call(fl,shortest_distances[node[0]])\n\t\t\t\t\t\t\tif t<weight then \n\t\t\t\t\t\t\t\tweight = t \n\t\t\t\t\t\t\t\tflight = fl\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\t#continue regular dijkstra algorithm\n\t\t\t\t\t\tif shortest_distances[w] > weight\n\t\t\t\t\t\t\tshortest_distances[w] = weight\n\t\t\t\t\t\t\tprevious[w] = [node[0],flight]\n\t\t\t\t\t\t\tarrdate = Date.new(flight.date.to_s,flight.departureTime.to_s) #calculate the arrival time/date \n\t\t\t\t\t\t\tarrdate.addTimeToDate(flight.flightDuration)\t\t\t#of this flight\n\t\t\t\t\t\t\tpq.push([w,arrdate])\t\t\t\t#and put it with the airport in the priority queue\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\tend\n\n\tret = []\n\t#get the list of flights form the 'previous' hash\n\twhile destination != source\n\t\tif destination.nil? then \n\t\tp \"No flights available, try an other day...\"\n\t\treturn nil\n\t\tend\n\t\tf = previous[destination][1]\n\n\t\tret.push(f)\n\t\tdestination = previous[destination][0]\n\n\n\tend\n\t#ret now holds the flights in reversed order, so we need to reverse the array before returning it.\n\treturn ret.reverse\nend", "def distance(graph, source, target)\n queue = Queue.new\n queue.enq(source)\n distances = { source => 0 }\n\n while !queue.empty?\n vtx = queue.deq\n return distances[vtx] if vtx == target # processing step\n graph[vtx].each do |neighbor|\n queue.enq(neighbor) unless distances[neighbor]\n distances[neighbor] = distances[vtx] + 1\n end\n end\n\n return nil\nend", "def min_cost_connect_points(points)\n total = 0\n visited = [true] + [false] * (points.length - 1)\n min_costs = {}\n current_id = 0\n\n (points.length - 1).times do\n min = nil\n next_id = nil\n points.each_with_index do |point, index|\n next if visited[index]\n\n new_min = manhattan_distance(points[current_id], points[index])\n\n if !min_costs[index] || min_costs[index] > new_min\n min_costs[index] = new_min\n else\n new_min = min_costs[index]\n end\n\n if !min || new_min < min\n min = min_costs[index] < new_min ? min_costs[index] : new_min\n next_id = index\n end\n end\n\n total += min\n visited[next_id] = true\n current_id = next_id\n end\n\n total\nend", "def if_goal_reachable(num_gas_stand, course_distance, init_gas_amount, gas_stand_spot, gas_amounts)\n track = Track.new(init_gas_amount)\n gas_stand_spot.each_with_index do |dist, index|\n print \"index: #{index}, dist: #{dist}\\n\"\n track.run(dist - track.location)\n while track.check_gasoline_necessary\n if_successful = track.consume_gasoline\n print \"gasoline_necessary. consume gasoline_successful? #{if_successful}\\n\"\n return -1 unless if_successful\n end\n track.gasoline_right_provided(gas_amounts[index])\n end\n\n # From last gas stop to the goal\n track.run(course_distance - track.location)\n if track.check_gasoline_necessary\n if_successful = track.consume_gasoline\n return -1 unless if_successful\n end\n print \"gas_station_used: #{track.show_gas_station_used}\\n\"\n return track.count_gas_stand_used\nend", "def calculate(route)\n dist = 0\n route.each_cons(2) { |points| dist = dist + points[0].distance(points[1])}\n dist\nend", "def find_shortest_path(initial_node, final_node)\n\t\tunless @nodes.include?(initial_node) && @nodes.include?(final_node)\n\t\t raise(\"Either of the nodes not found in the Graph\") \n\t\tend\n\t\tdistance = {}\n\t previous = {}\n\t\tdistance[initial_node] = 0 # Distance from initial_node to initial_node\n\t previous[initial_node] = nil\n\t\tnodes_counted = @nodes\n\t\t\t\n\t\tnodes_counted.each do |n|\n\t\t if n != initial_node \n\t\t\t distance[n] = Float::INFINITY # Unknown distance function from initial_node to final_node\n\t\t\t previous[n] = nil \t # Previous node in optimal path from initial_node\n\t\t\tend\n\t\tend\n\n\t\tuntil nodes_counted.empty? \n\t\t\n\t\t\tu = distance.select{|k,v| nodes_counted.include?(k)}.min_by{|k,v| v}.first # Source node in first case\n\t\t\tbreak if (distance[u] == Float::INFINITY)\n\t\t\tnodes_counted.delete(u)\n\t\t\t\n\t\t\t@paths[u].keys.each do |v|\n\t\t\t\talt = distance[u] + @paths[u][v]\n\t\t\t\tif alt < distance[v] # A shorter path to v has been found\n\t\t\t\t\tdistance[v] = alt\n\t\t\t\t\tprevious[v] = u\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t \n\t\tpath = []\n\t\tcurrent = final_node\n\t\twhile current\n\t\t\tpath.unshift(current)\n\t\t\tcurrent = previous[current]\n\t\tend\n \n\t\treturn distance[final_node], path\n\n\tend", "def min_cost(cost, inf)\n # dist[i] stores minimum cost to reach station i from station 0.\n dist = {};\n\n i = 0\n n = cost.length\n while i < n do\n dist[i] = inf\n i += 1\n end\n dist[0] = 0\n\n # Go through every station and check if using it as an intermediate station gives better path\n i = 0\n while i < n do\n j = i + 1\n while j < n do\n c = dist[i] + cost[i][j]\n dist[j] = c if dist[j] > c\n j += 1\n end\n i += 1\n end\n return dist[n-1];\nend", "def find_path(source, target, map)\n @main_loop_count = 0\n\n max_y = map.size - 1\n max_x = map[0].size - 1\n target_x = target[0]\n target_y = target[1]\n # target heuristic is 0\n target = [target_x, target_y, 0]\n\n # Sets up the search to begin from the source\n source = source.dup.push((target_x - source[0]).abs + (target_y - source[1]).abs)\n came_from = {}\n came_from[source] = nil\n frontier = [source]\n\n # Until the target is found or there are no more cells to explore from\n until came_from.has_key?(target) || frontier.empty?\n @main_loop_count += 1\n\n # Take the next frontier cell\n new_frontier = frontier.shift\n\n # Find the adjacent neighbors\n adjacent_neighbors = []\n\n # Gets all the valid adjacent_neighbors into the array\n # From southern neighbor, clockwise\n nfx = new_frontier[0]\n nfy = new_frontier[1]\n adjacent_neighbors << [nfx , nfy - 1, (target_x - nfx).abs + (target_y - nfy + 1).abs] unless nfy == 0\n adjacent_neighbors << [nfx - 1, nfy - 1, (target_x - nfx + 1).abs + (target_y - nfy + 1).abs] unless nfx == 0 || nfy == 0\n adjacent_neighbors << [nfx - 1, nfy , (target_x - nfx + 1).abs + (target_y - nfy).abs] unless nfx == 0\n adjacent_neighbors << [nfx - 1, nfy + 1, (target_x - nfx + 1).abs + (target_y - nfy - 1).abs] unless nfx == 0 || nfy == max_y\n adjacent_neighbors << [nfx , nfy + 1, (target_x - nfx).abs + (target_y - nfy - 1).abs] unless nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy + 1, (target_x - nfx - 1).abs + (target_y - nfy - 1).abs] unless nfx == max_x || nfy == max_y\n adjacent_neighbors << [nfx + 1, nfy , (target_x - nfx - 1).abs + (target_y - nfy).abs] unless nfx == max_x\n adjacent_neighbors << [nfx + 1, nfy - 1, (target_x - nfx - 1).abs + (target_y - nfy + 1).abs] unless nfx == max_x || nfy == 0\n\n new_neighbors = adjacent_neighbors.select do |neighbor|\n # That have not been visited and are not walls\n unless came_from.has_key?(neighbor) || map[neighbor[1]][neighbor[0]] != '.'\n # Add them to the frontier and mark them as visited\n # frontier << neighbor\n came_from[neighbor] = new_frontier\n end\n end\n\n # Sort the frontier so cells that are close to the target are then prioritized\n if new_neighbors.length > 0\n new_neighbors = merge_sort(new_neighbors)\n if frontier.length > 0 && new_neighbors[0][2] >= frontier[0][2]\n frontier = merge_sort(new_neighbors.concat(frontier))\n else\n frontier = new_neighbors.concat(frontier)\n end\n end\n end\n\n # If the search found the target\n if came_from.has_key?(target)\n # Calculates the path between the target and star for the greedy search\n # Only called when the greedy search finds the target\n path = []\n next_endpoint = came_from[target]\n while next_endpoint\n path << [next_endpoint[0], next_endpoint[1]]\n next_endpoint = came_from[next_endpoint]\n end\n path\n else\n return nil\n end\n end", "def trip_with_maximum_stops(from_city,to_city,max_stops,has_exact=false,max_distance=0)\n max_stops = max_stops.to_i + 1\n max_distance = max_distance.to_i\n # store the intermediate cities in Queue\n intermedite_cities = Queue.new\n\n # Store the start city\n intermedite_cities.push [from_city,from_city]\n\n all_possible_routes = []\n\n #Find routes\n until intermedite_cities.empty?\n #pop up the first element in queue\n city = intermedite_cities.pop\n if max_distance> 0\n has_maximum_or_equal_stops = parse_and_find_distance(city.last).to_i < max_distance\n else\n has_maximum_or_equal_stops = has_exact ? (city.last.split('-').size ==max_stops) : (city.last.split('-').size <=max_stops)\n end\n\n # Add the reached route in array\n if city.first == to_city && has_maximum_or_equal_stops && city.last.split('-').size > 1\n all_possible_routes << city.last\n next\n end\n\n #store adjucent cities in queue\n old_distance = city.last\n\n if max_distance > 0\n condition = \"parse_and_find_distance(old_distance+'-'+adjust_city.first).to_i < max_distance\"\n else\n condition = \"(max_stops >= (old_distance+'-'+adjust_city.first).split('-').size)\"\n end\n\n for adjust_city in adjucent_cities(city.first)\n if eval(condition)\n intermedite_cities.push [adjust_city.first,old_distance+'-'+adjust_city.first]\n end\n end\n \n end\n all_possible_routes\n\n end", "def search_jps\n open_list = [@nodes[@route.start_id]]\n close_list = []\n goal = @nodes[@route.goal_id]\n\n until open_list.empty?\n n = open_list.min_by { |node| @route.estimated_cost(node) }\n if n == goal\n @route.found = true\n break\n end\n\n close_list.push( open_list.delete(n) )\n\n adjacents_of_n = n.pruned_neighbors(@route.parent(n))\n adjacents_of_n.keys.each do |m|\n j = jump(n, clamp(m.x - n.x, -1, 1), clamp(m.y - n.y, -1, 1))\n next if j == nil or close_list.include?(j)\n h = @heuristic.call(j, goal)\n new_real_cost_j = @route.real_cost(n) + Math.sqrt((n.x-j.x)**2 + (n.y-j.y)**2) # g\n new_estimated_cost_j = new_real_cost_j + h # f = g + h\n if open_list.include?(j)\n # If estimated costs are equal then use real costs for more precise comparison (or we may get less optimal path).\n next if new_estimated_cost_j > @route.estimated_cost(j)\n next if new_estimated_cost_j == @route.estimated_cost(j) && new_real_cost_j >= @route.real_cost(j)\n @route.record(j, n, new_real_cost_j, h)\n else\n open_list.push(j)\n @route.record(j, n, new_real_cost_j, h)\n end\n @visited << j.id unless @visited.include? j.id # stats\n end\n @search_iter += 1 # stats\n end\n end", "def trucking(trucks, distance)\n running_sum = 0\n\n current_sum = 0\n\n while (trucks > 0)\n #strictly greater than is 432. Greater than or equal to is 482.\n #actual answer is around 450. Could add with smaller increments and not\n #use integers\n until (current_sum > distance/trucks)\n current_sum += 1\n running_sum += 1\n end\n\n current_sum = 0\n trucks -= 1\n end\n\n return running_sum\nend", "def solver(flights)\n (p all_paths(flights)).min_by { |path| cost_of_path(path) }\nend", "def a_star pitch, start, goal\n\t\t# The set of nodes already evaluated.\n\t\tclosedset = []\n\t\t# The set of tentative nodes to be evaluated.\n\t\topenset = []\n\t\t# Visited nodes\n\t\tfrontier = []\n\t\topenset << start\n\t\t# The map of navigated nodes.\n\t\tcame_from = { }\n\t\t# Distance from start along optimal path.\n\t\tg_score, h_score, f_score = { }, { }, { }\n\t\tg_score[start] = 0\n\t\th_score[start] = dist start, goal, :manhattan\n\t\t# Estimated total distance from start to goal through y.\n\t\tf_score[start] = h_score[start]\n\n\t\t# Main loop\n\t\twhile not openset.empty?\n\t\t\t# Fetching the node among openset with the least f_score\n\t\t\tx, _value = [], 1_000_000\n\t\t\topenset.each do |key|\n\t\t\t\tx, _value = key, f_score[key] if f_score[key] < _value\n\t\t\tend\n\n\t\t\tbreak if x == goal # We reached target point and thus finished looking for it !!\n\n\t\t\t# Moving x from openset to closedset\n\t\t\topenset.delete x\n\t\t\tclosedset << x\n\n\t\t\t(-1..1).each do |i|\n\t\t\t\t(-1..1).each do |j|\n\t\t\t\t\ty = [x[0] + i, x[1] + j]\n\t\t\t\t\tunless i == 0 and y == 0\n\t\t\t\t\t\tif pitch[y].nil? # We only want to explore neighbours\n\t\t\t\t\t\t\tnext if closedset.include? y # If already in closedset, we skip it\n\n\t\t\t\t\t\t\tbetter = false\n\t\t\t\t\t\t\th = dist x, y, :manhattan\n\t\t\t\t\t\t\tg = g_score[x] + h\n\n\t\t\t\t\t\t\tif not openset.include? y then\n\t\t\t\t\t\t\t\treturn [] if frontier.include? y\n\t\t\t\t\t\t\t\tfrontier << y\n\t\t\t\t\t\t\t\topenset << y # Adding current neighbours to openset\n\t\t\t\t\t\t\t\tbetter = true\n\t\t\t\t\t\t\telsif g < g_score[y]\n\t\t\t\t\t\t\t\tbetter = true\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tbetter = false\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t# Updating what needs to be\n\t\t\t\t\t\t\tif better then\n\t\t\t\t\t\t\t\tcame_from[y] = x\n\t\t\t\t\t\t\t\tg_score[y] = g\n\t\t\t\t\t\t\t\th_score[y] = dist y, goal, :manhattan # heuristic estimate of distance (y, coords)\n\t\t\t\t\t\t\t\tf_score[y] = g_score[y] + h_score[y]\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\tend\n\t\tend\n\n\t\t# Finally assembling path and returning it\n\t\tpath = []\n\t\t_cur = goal\n\t\twhile _cur != start do\n\t\t\tpath << _cur\n\t\t\t_cur = came_from[_cur]\n\t\tend\n\n\t\treturn path.reverse\n\tend", "def compute_shortest_path\n update_distance_of_all_edges_to(Float::INFINITY)\n @distance_to[@source_node] = 0\n\n # The prioriy queue holds a node and its distance from the source node.\n @pq.insert(@source_node, 0)\n while @pq.any?\n node = @pq.remove_min\n node.adjacent_edges.each do |adj_edge|\n relax(adj_edge)\n end\n end\n end", "def traverse (from, to, points_visited_so_far = [])\n \n return points_visited_so_far if from.eql?(to)\n\n # Select those adjacent points that that has not been already traversed\n # and that do not represent walls\n possible_steps = adjacent_traversible_points(from).select { |point| \n (not points_visited_so_far.include?(point))\n }\n\n # For each possible step, take that step, and find out the list of points\n # that need to be traversed to reach \"to\" point. In case there were more\n # than one possible steps, pick the one that has smaller number of steps\n # to destination\n points_to_destination_from_here = []\n possible_steps.each do |point|\n traversal_result = traverse(point, to, points_visited_so_far + [point])\n if not traversal_result.empty?\n points_to_destination_from_here = traversal_result if \n (points_to_destination_from_here.empty? or\n traversal_result.size < points_to_destination_from_here.size)\n end\n end\n \n return points_to_destination_from_here\n\n end", "def find_journey(city1, city2, graph_instance)\n distance, previous = find_shortest_journey(city1, city2, graph_instance)\n puts \"Shortest distance is #{distance} with stopovers at\"\n c = city2\n while(true)\n if(c == city1)\n break\n end\n puts \"#{previous[c]}\"\n c = previous[c]\n end\nend", "def compute(source, num_nodes)\n x = [source]\n source.length = 0\n until x.length == num_nodes\n min_edge = nil\n min_distance = Float::INFINITY\n x.each do |xnode|\n xnode.outgoing_edges.each do |xedge|\n next if xedge.visited?\n curr_distance = xnode.length + xedge.distance\n if curr_distance <= min_distance\n min_distance = curr_distance\n min_edge = xedge\n end\n end\n end\n min_edge.head.length = min_distance\n x << min_edge.head\n end\n x\nend", "def find_path_brute_force( board, start_point )\n options = get_options( start_point, board )\n\n # Bottom right corner\n if options.length == 0\n return { points: [start_point], best_value: get_value( start_point, board ) }\n end\n\n # If there's only one option, this works fine still.\n first_result = find_path_brute_force( board, options.first )\n second_result = find_path_brute_force( board, options.last )\n if first_result[:best_value] > second_result[:best_value]\n return {\n points: [start_point] + first_result[:points],\n best_value: first_result[:best_value] + get_value( start_point, board )\n }\n else\n return {\n points: [start_point] + second_result[:points],\n best_value: second_result[:best_value] + get_value( start_point, board )\n }\n end\nend", "def computeSP\n @graph.nodes.each do |node|\n @dist_to[node]=Float::INFINITY\n end\n @dist_to[@source] = 0\n \n #node and it's distance to source (source -> source = 0)\n @queue.insert(@source, 0)\n \n #while elements exist in the queue\n while @queue.any?\n #check the lowest distance (closest)\n close = @queue.remove_min\n #check each adjacent edge\n close.adjacent_edges.each do |adjacent|\n relax(adjacent)\n end\n end\n end", "def distance(graph, source, target)\n queue = Queue.new\n queue.enq(source)\n visited = { source => true}\n distances = { source => 0 }\n\n while !queue.empty?\n vtx = queue.deq\n return distances[vtx] if vtx == target\n graph[vtx].each do |neighbor|\n queue.enq(neighbor) unless visited[neighbor]\n distances[neighbor] = distances[vtx] + 1\n visited[neighbor] = true\n end\n end\n\n return nil\nend", "def getShortFlight(csa)\n number2 = 10000000\n @parse.map{ |airport| \n if( airport[\"name\"] == csa) \n airport[\"destinations\"].map do |element|\n number1 = element[\"distance\"]\n if(number1<number2)\n number2 = number1\n end\n end\n airport[\"destinations\"].map{ |dest| \n if(number2==dest[\"distance\"])\n puts \"The min distance is \" + number2.to_s + \" in the fligth between \"+ dest[\"ports\"].to_s\n end\n }\n end\n }\n end", "def shortest_length(start, finish)\n infinity = (2**(0.size * 8 - 2) - 1) # max Fixnum integer value\n distances = {} # smallest distance from starting vertex to this one\n previous = {}\n cyclic = start == finish # true if starting vertex = ending vertex\n loops = 0 # useful for cyclic path\n vertex_pq = PriorityQueue.new\n\n adj_lists.each do |vertex|\n vname = vertex.name\n if vname == start\n distances[vname] = 0\n vertex_pq.enq(vname, 0)\n else\n distances[vname] = infinity\n vertex_pq.enq(vname, infinity)\n end\n previous[vname] = nil\n end\n\n while vertex_pq\n loops += 1\n # if cyclic, pretend starting vertex is unvisited. put it back in queue.\n if cyclic && loops == 2\n vertex_pq.enq(start, infinity)\n distances[start] = infinity\n end\n # vertex currently being checked. picks closest one first.\n current = vertex_pq.deq\n vname = current.keys.first\n\n # if we've arrived at final vertex, return shortest distance\n # if cyclic, skip this code during first loop\n if vname == finish && loops > 1\n shortest_path = []\n vname2 = vname\n while previous[vname2]\n shortest_path << vname2\n vname2 = previous[vname2]\n previous[start] = nil if cyclic # pretend starting vertex is unvisited\n end\n shortest_path = [start] + shortest_path.reverse\n print \"Shortest path: #{shortest_path}, Length = #{path_length(shortest_path)}\\n\"\n return distances[finish]\n end\n\n # leave if we never get to final vertex\n break if vname == nil || distances[vname] == infinity\n\n adj_vertices(vname, adj_lists).each do |vertex|\n alt_distance = distances[vname] + dist(vname, vertex)\n # if total distance to neighbor < last minimum total distance\n # to neighbor, replace it with this new distance\n if alt_distance < distances[vertex]\n distances[vertex] = alt_distance\n previous[vertex] = vname\n vertex_pq.enq(vertex, alt_distance)\n end\n end\n end\n\n end", "def shortest_path_between_nodes(initial, destination)\n initial.distance = 0\n\n current = initial\n loop do\n # at the destination node, stop calculating\n break if current == destination\n\n unvisited.delete(current)\n\n calculate_neighbor_shortest_distances(current)\n\n return nil if no_reachable_nodes\n\n current = unvisited.min_by(&:distance)\n end\n\n destination.path\n end", "def distance\n distance = 0\n @solution.each { |route| distance += route.distance }\n return distance\n end", "def shortest_distance_from(latitude, longitude)\n\t\tmin_dist = BigDecimal.new(\"10.0\")\n\t\tinput_lat = BigDecimal.new(latitude)\n\t\tinput_lng = BigDecimal.new(longitude)\n\n\t\t#Find waypoint with shortest distance from input\n\t\tfor location in self.locations\n\t\t\tpoint_lat = BigDecimal(location.coord.latitude.to_s)\n\t\t\tpoint_lng = BigDecimal(location.coord.longitude.to_s)\n\n\t\t\t#Get distance between two points\n\t\t\tdist = ((input_lat - point_lat)**2 + (input_lng - point_lng)**2).sqrt(10)\n\n\t\t\t#Update the minimum\n\t\t\tif min_dist > dist\n\t\t\t\tmin_dist = dist\n\t\t\tend\n\t\tend\n\n\t\treturn min_dist\n\tend", "def waypoints_must_be_at_most_n_km_apart\n self.waypoints_minus_removed.each do |waypoint|\n next if waypoint.parent_index.nil? || waypoint.parent_index < 0 || waypoint.parent_index == waypoint.local_index\n parent = waypoints_minus_removed[waypoint.parent_index]\n if !parent.nil? && type == 'Road' && waypoint.dist(parent.latitude, parent.longitude) > 50\n\tputs \"cannot be more than 50km apart.\"\n errors.add(:waypoints, \"cannot be more than 50km apart.\")\n elsif !parent.nil? && type != 'Road' && waypoint.dist(parent.latitude, parent.longitude) > 20\n\tputs \"cannot be more than 20km apart.\"\n errors.add(:waypoints, \"cannot be more than 20km apart.\")\n end\n end\n end", "def greedy_salesman (cities)\n path = []\n not_visited = cities\n path.push(not_visited.shift)\n loop do\n current = path.last\n # for testing, only prints if PRINT_STEPS is set to true at the top of the file\n puts \"current: \" + current.name + \" (\" + current.x.round(2).to_s + \",\" + current.y.round(2).to_s + \")\" if PRINT_STEPS\n next_city = nearest_possible_neighbor(current,not_visited)\n path.push(not_visited.delete(next_city))\n break if not_visited.empty?\n end\n path\nend", "def solve_dijkstra\n\n unvisited_set = @unvisited_set.dup\n\n # create a queue for nodes to check\n @queue = []\n current_node = @start_node\n @queue << current_node\n\n # Stop If there are no unvisited nodes or the queue is empty\n while unvisited_set.size > 0 && @queue.size > 0 do\n\n # set the current node as visited and remove it from the unvisited set\n current_node = @queue.shift\n\n # remove visited node from the list of unvisited nodes\n unvisited_set.delete(current_node)\n\n # find the current node's neighbours and add them to the queue\n rolling_node = @node_list.find { |hash| hash[:id] == current_node }\n rolling_node[:neighs].each do |p|\n # only add them if they are unvisited and they are not in the queue\n if unvisited_set.index(p) && !@queue.include?(p)\n @queue << p\n # set the previous node as the current for its neighbours\n change_node = @node_list.find { |hash| hash[:id] == p }\n change_node[:prev] = current_node\n # increase the distance of each node visited\n change_node[:dist] = rolling_node[:dist] + @step\n end\n end\n\n if current_node == @goal_node\n find_shortest_path(rolling_node)\n break\n end\n end\n return @shortest_path_coords\n end", "def find_path(start, goal)\n raise \"loc1 must not be the same as loc2\" if start == goal\n\n # Using A* path-finding algorithm\n # See pseudocode here: https://en.wikipedia.org/wiki/A*_search_algorithm\n # https://www.redblobgames.com/pathfinding/a-star/introduction.html\n # NOTE that this is overkill for this problem...\n open_set = Set.new([start])\n came_from = {}\n\n # Default value of \"Infinity\", but we can just use nil\n g_score = {}\n g_score[start] = 0\n\n # f_score = g_score[node] + h_score[node]\n # This uses both current best path (g score) aka similar to Djikstra's algorithm,\n # plus the heuristic score.\n f_score = {}\n # g_score[start] is 0, so not included here\n f_score[start] = h_score(start, goal)\n\n # Note that we add d_score as the weight of the edge, but in our\n # case, we consider all edges equally, so hardcode 1\n d_score = 1\n\n until open_set.empty? do\n # Node in open set with lowest f score (would ideally use PriorityQueue)\n current = open_set.min_by { |node| f_score[node] }\n\n if current == goal\n return reconstruct_path(came_from, current)\n end\n\n open_set.delete(current)\n\n valid_neighbours(current).each do |neighbour_loc|\n tentative_g_score = g_score[current] + d_score\n if g_score[neighbour_loc].nil? || tentative_g_score < g_score[neighbour_loc]\n # This path to neighbor is better than any previous one. Record it!\n came_from[neighbour_loc] = current\n g_score[neighbour_loc] = tentative_g_score\n f_score[neighbour_loc] = g_score[neighbour_loc] + h_score(neighbour_loc, goal)\n if !open_set.include?(neighbour_loc)\n open_set << neighbour_loc\n end\n end\n end\n end\n\n raise \"error, no path found!\"\n end", "def calc_dijkstra\n # The initial values for the Dijkstra search\n dijkstra_search.frontier << [state.star, 0]\n dijkstra_search.came_from[state.star] = nil\n dijkstra_search.cost_so_far[state.star] = 0\n\n # Until their are no more cells to be explored\n until dijkstra_search.frontier.empty?\n # Get the next cell to be explored from\n # We get the first element of the array which is the cell. The second element is the priority.\n current = dijkstra_search.frontier.shift[0]\n\n # Stop the search if we found the target\n return if current == state.target\n\n # For each of the neighbors\n adjacent_neighbors(current).each do | neighbor |\n # Unless this cell is a wall or has already been explored.\n unless dijkstra_search.came_from.key?(neighbor) or state.walls.key?(neighbor)\n # Calculate the movement cost of getting to this cell and memo\n new_cost = dijkstra_search.cost_so_far[current] + cost(neighbor)\n dijkstra_search.cost_so_far[neighbor] = new_cost\n\n # Add this neighbor to the cells too be explored\n dijkstra_search.frontier << [neighbor, new_cost]\n dijkstra_search.came_from[neighbor] = current\n end\n end\n\n # Sort the frontier so exploration occurs that have a low cost so far.\n # My implementation of a priority queue\n dijkstra_search.frontier = dijkstra_search.frontier.sort_by {|cell, priority| priority}\n end\n end", "def astar_search(origin:, target:)\n costs = {}\n seen = {}\n path = {}\n initial_estimate = heuristic(current: origin, target: target)\n costs[origin] = 0\n\n pq = PriorityQueue.new\n\n pq.push(origin, initial_estimate)\n\n loop do\n current = pq.delete_min_return_key\n\n # made it\n return path if current == target\n\n seen[current] = true\n\n # get moves and estimate costs\n moves(current).each do |move|\n move_pair = move[0]\n cost = move[1]\n\n next if seen[move_pair]\n\n new_cost = costs[current] + cost\n\n # skip if more costly\n next if pq.has_key?(move_pair) && !costs[move_pair].nil? && new_cost >= costs[move_pair]\n\n path[move_pair] = current\n costs[move_pair] = new_cost\n estimate = new_cost + heuristic(current: move_pair, target: target)\n\n if pq.has_key?(move_pair)\n pq.change_priority(move_pair, estimate)\n else\n pq.push(move_pair, estimate)\n end\n end\n end\nend", "def min_cost(costs)\n prev_color_path1 = 0\n prev_color_path2 = 1\n path1 = costs[0][prev_color_path1]\n path2 = costs[0][prev_color_path2]\n \n if costs[0][2] < path1\n if path1 < path2\n path2 = path1\n prev_color_path2 = prev_color_path1\n path1 = costs[0][2]\n prev_color_path1 = 2\n end\n elsif costs[0][2] < path2\n if path2 < path1\n path1 = path2\n prev_color_path1 = prev_color_path2\n path2 = costs[0][2]\n prev_color_path2 = 2\n end\n end\n\n costs[1..-1].each do |cost|\n min1 = nil\n min1idx = nil\n # for first path\n cost.each_with_index do |amt, idx|\n next if idx == prev_color_path1\n if min1\n if amt < min1\n min1 = amt\n prev_color_path1 = idx\n else\n next\n end\n else\n min1 = amt\n min1idx = idx\n end\n end\n path1 += min1\n\n \n min2 = nil\n min2idx = nil\n # for second path\n cost.each_with_index do |amt, idx|\n next if idx == prev_color_path2\n if min2\n if amt < min2\n min2 = amt\n prev_color_path2 = idx\n else\n next\n end\n else\n min2 = amt\n min2idx = idx\n end\n end\n \n path2 += min2\n end\n\n path1 < path2 ? path1 : path2\nend", "def shortest_distance_between_nodes(initial, destination)\n shortest_path_between_nodes(initial, destination).last.distance\n end", "def solve_bfs(initial, final)\n\tunvisited = [initial]\n\tvisited = Set.new unvisited\n\n\twhile not unvisited.empty?\n\t\tc = unvisited[0]\n\t\tunvisited.delete_at 0\n\n\t\treturn c.n_moves if c.eql? final\n\t\tneighbours = c.moves.select { |x| not visited.include? x }\n\t\tunvisited.concat(neighbours)\n\t\tvisited.merge neighbours\n\tend\n\tNO_SOLUTION\nend", "def two_break_distance(p, q)\n p_nodes = colored_edges(p)\n q_nodes = colored_edges(q)\n\n all_nodes = p_nodes + q_nodes\n\n puts all_nodes.length\n # puts all_nodes.sort.join(\" \")\n\n cycle_count = 0\n\n loop do \n\n break if all_nodes.empty?\n cycle = {}\n # cycle = all_nodes[0]\n cycle[all_nodes[0][0]] = 1\n cycle[all_nodes[0][1]] = 1\n\n found_a_node = 1\n\n loop do\n\n break if found_a_node == 0\n\n found_a_node = 0\n # all_nodes.dup.each do |node|\n index = 0\n loop do\n break if all_nodes.length == index\n node = all_nodes[index]\n # if (cycle.include?(node[0]) || cycle.include?(node[1]))\n if (cycle.has_key?(node[0]) || cycle.has_key?(node[1]))\n # puts all_nodes.length\n # print node.join(\" \") + \" \"\n # cycle += node\n cycle[node[0]] = 1\n cycle[node[1]] = 1\n # cycle.uniq!\n all_nodes.delete(node)\n found_a_node = 1\n else\n index += 1\n end\n end\n\n end\n \n # puts cycle.join(\" \")\n # puts cycle.keys.length\n cycle_count += 1 unless cycle.empty?\n # puts all_nodes.join(\" \")\n # break\n end\n\n # puts cycle_count\n no_of_blocks = p_nodes.length\n\n return (no_of_blocks - cycle_count)\n\n end", "def choose_next_waypoint(current_waypoint, destination, min_search_radius, max_search_radius)\n current_waypoint.find_potential_next_waypoints(destination, min_search_radius, max_search_radius).sample\n end", "def social_distance_to user_id\n\n fake_test_data = {\n 1 => [5,6],\n 5 => [1],\n 6 => [1,7,8],\n 7 => [6],\n 8 => [6, 9, 12],\n 9 => [8],\n 12 => [13, 8],\n 13 => [12,14],\n 14 => [13]\n }\n\n start_id = 1\n end_id = user_id\n\n get_vertices = lambda { |x|\n fake_test_data[x] || []\n }\n\n a = start_id\n b = end_id\n marked = Set.new # keep track of checked vertices\n depth_a = get_vertices.call a\n depth_b = get_vertices.call b\n # check for distance=1 here, next checks will be for a common vertex in-between\n return 1 if b.in? depth_a\n distance = 2\n next_depth_a = []\n next_depth_b = []\n while depth_a.size > 0 && depth_b.size > 0\n # first check for even distances\n return distance if (depth_a & depth_b).size > 0\n distance += 1\n # get full front on next depth (all connected vertices of all vertices on this depth)\n depth_a.each do |aa|\n unless aa.in? marked\n next_depth_a += get_vertices.call aa\n marked.add(aa)\n end\n end\n # ... same for the other end\n depth_b.each do |bb|\n unless bb.in? marked\n next_depth_b += get_vertices.call bb\n marked.add(bb)\n end\n end\n depth_a = next_depth_a\n # second check with only one front moved forward (otherwise we might \"jump over\" the common vertex)\n return distance if (depth_a & depth_b).size > 0\n distance += 1\n depth_b = next_depth_b\n next_depth_a = next_depth_b = []\n end\nend", "def solution(a)\n cars_going_east = [0]\n\n a.each do |direction|\n next_counter = direction.zero? ? cars_going_east.last + 1 : cars_going_east.last\n cars_going_east << next_counter\n end\n\n passings = 0\n a.each_with_index do |direction, index|\n passings += cars_going_east[index] if direction == 1\n end\n\n return -1 if passings > 1000000000\n passings\nend", "def heuristic(current:, target:)\n d = (current[0].real - target[0].real).abs + (current[0].imag - target[0].imag).abs\n d += 7 if d <= 8 && current[1] != target[1]\n\n d\nend", "def plan(s1, s2)\r\n if s1 == s2\r\n return []\r\n end\r\n\r\n condensed_path = Array.new\r\n full_path = Array.new\r\n temp = BFS.new(graph, find_node(s1)).shortest_path_to(find_node(s2))\r\n\r\n temp.each {|x| full_path.push(x.to_s)}\r\n condensed_path.push(full_path.first)\r\n condensed_path = condensed_path + transfer_stations(full_path)\r\n \r\n if condensed_path.last != full_path.last #need to test this more\r\n condensed_path << full_path.last\r\n end\r\n\r\n return condensed_path\r\n end", "def getShortestPath(max_jumps, random=true)\n checkValidSetup\n \n sequenceOfDives = DiveSequence.new\n \n move_pairs =\n @movePool.values.map { |a| @movePool.values.map { |b| [a, b] } }. # make some arrays of move pairs\n inject([]) { |result, move_pairs| result.concat(move_pairs) }. # concatenate those into a single array of move pairs\n reject { |a, b| a == b } # throw away pairs of the same move\n \n move_pairs.sort! { |x,y| x[0].symbol.rjust(3) << x[1].symbol.rjust(3) <=> y[0].symbol.rjust(3) << y[1].symbol.rjust(3) } unless random\n\n lastMove = random ? move_pairs[rand(move_pairs.length)].first : move_pairs.first.first\n currentDive = Dive.new(lastMove)\n \n while !move_pairs.empty? && ((max_jumps <= 0) || (sequenceOfDives.length < max_jumps)) # if max_jumps > 0 them limit jumps to max_jumps\n currentDivePoints = lastMove.points unless currentDive.length > 1\n\n nextMove =\n if !(next_moves = move_pairs.select { |a, b| a == lastMove }.map { |a, b| b } - currentDive).empty?\n # standard random call for next move when there are loads of moves available\n random ? next_moves[rand(next_moves.length)] : next_moves.first\n elsif !(next_moves = move_pairs.map { |a, b| a } - currentDive).empty?\n # nothing left in last permutation, just get a new starting position\n random ? next_moves[rand(next_moves.length)] : next_moves.first\n else\n # just pull anything from the move pool that has not been used, nothing left at all to use!\n anymovepool = @movePool.values.reject { |move| currentDive.include?(move) }\n random ? anymovepool[rand(anymovepool.length)] : anymovepool.first\n end\n\n currentDivePoints += nextMove.points\n currentDive << nextMove\n \n # clean up, remove the pair lastMove-nextMove\n move_pairs.delete([lastMove, nextMove])\n\n # puts (lastMove.points.to_s + \"_\" + nextMove.points.to_s + \" \" + currentDivePoints.to_s + \":\" + (currentDive.collect {|a| a.symbol + \"-\"}).to_s)\n\n if (currentDivePoints < @minPointsPerRound)\n lastMove = nextMove\n else\n # remember that a sequence such as ABC also has the pair CA in it because ABC is ABCABCABC... delete movePermutation CA\n move_pairs.delete([currentDive.first, currentDive.last])\n\n sequenceOfDives << currentDive\n\n lastMove = (random ? move_pairs[rand(move_pairs.length)].first : move_pairs.first.first) unless move_pairs.empty?\n currentDive = Dive.new(lastMove)\n end\n end\n \n sequenceOfDives\n end", "def solution(a)\n # write your code in Ruby 2.2\n binding.pry\n trips = Hash.new {|h,k| h[k]=0}\n start = 0\n ending = 0\n min = nil\n a.each_with_index do |trip,i|\n ending = i\n\n if trips[trip] == 0\n min = ending - start\n end\n trips[trip] += 1\n\n while start < ending\n break if trips[a[start]] - 1 == 0\n trips[start] -= 1\n start += 1\n min = ending - start if ending-start < min\n end\n end\n min\nend", "def best_path(start, target)\n queue = []\n path = []\n targetX = target[0]\n targetY = target[1] \n update_possible_moves(start)\n path << [@x, @y]\n until @x == targetX && @y == targetY\n @moves.each do |valid_move|\n queue << valid_move unless out_of_bounds?(valid_move) \n end\n #shift because we want bread-first search\n next_move = queue.shift\n update_possible_moves(next_move)\n path << [@x, @y] \n end\n # Filter out the best path and present it\n best_possible_path = filter_path(path)\n puts \"You made it in #{best_possible_path.length} moves! The path is:\\n#{best_possible_path}\"\n end", "def calc\n # If the searches have not started\n if breadth_first_search.visited.empty?\n # Calculate the two searches\n calc_breadth_first\n calc_dijkstra\n end\n end", "def lesstrips(start, finish, max_distance)\n total_paths, distance = 0, 0\n path, paths = [], []\n visited = [start]\n cycles = all_cycles # all cycles in graph\n puts \"MAX DISTANCE = #{max_distance}\\n\"\n total_paths += lesstrips_dfs(start, finish, max_distance, distance, visited, path, paths, cycles)\n puts \"\\n==> Total paths from #{start} to #{finish}, with distance < #{max_distance}: #{total_paths}\\n\"\n total_paths\n end", "def relative(reference_point, distance)\n return if reference_point.nil? # there is no cell\n return if (reference_point + distance) >= board_size # out of bound +\n return if (reference_point + distance).negative? # out of bound -\n\n # calculate possible move\n reference_point/columns == (reference_point + distance)/columns ? (reference_point + distance) : nil\n end", "def shortest_route_by_distance_to!(place_or_object_place_was_built_from)\n routes_for!(place_or_object_place_was_built_from).min_by(&:distance_in_meters)\n end", "def dijkstra(root)\n distance, predecessor = initialize_single_source(root)\n @graph[root].each do |k, v|\n distance[k] = v\n predecessor[k] = root\n end\n queue = distance.dup\n queue.delete(root)\n\n while queue.size != 0\n min = queue.min {|a, b| a[1] <=> b[1]}\n u = min[0]\t\t# extranct a node having minimal distance\n @graph[u].each do |k, v|\n # relaxing procedure of root -> 'u' -> 'k'\n if distance[k] > distance[u] + v\n distance[k] = distance[u] + v\n predecessor[k] = u\n end\n end\n queue.delete(u)\n end\n return distance, predecessor\n end", "def can_complete_circuit(gas, cost)\n return -1 if gas.size != cost.size\n local_trip = 0\n total_trip = 0\n idx = 0\n (0...gas.size).each { |i|\n local_trip += gas[i] - cost[i]\n total_trip += local_trip\n if local_trip < 0\n local_trip = 0\n idx = (i + 1) % gas.size\n end\n }\n \n return total_trip < 0 ? -1 : idx\nend", "def djikstra(world, from_x, from_y, to_x, to_y)\n key = [world.join, from_x, from_y].join(',')\n cached_prev = DJ_GRAPH_MEMO[key]\n\n prev = cached_prev\n\n unless cached_prev\n nodes = map_each_cell(world) {|cell, x, y| cell == '.' ? [x, y] : nil }.\n flatten(1).\n reject(&:nil?)\n\n source = [from_x, from_y]\n dist = Hash[nodes.zip([INFINITY].cycle)]\n queue = nodes.dup\n queue.push(source) unless queue.include?(source)\n dist[source] = 0\n prev = {}\n\n while !queue.empty?\n queue.sort_by! {|node| dist[node]}\n u = queue.shift\n\n neighbors = DIRECTIONS.values.map {|d| [u[0] + d[:x], u[1] + d[:y]] }\n neighbors = neighbors & nodes\n\n neighbors.each do |v|\n alt = dist[u] + 1\n\n if alt < dist[v]\n dist[v] = alt\n prev[v] = u\n end\n end\n end\n\n DJ_GRAPH_MEMO[key] ||= prev\n end\n\n path = []\n target = [to_x, to_y]\n\n return [source] if target == source\n\n # cannot reach target:\n return nil if prev[target].nil?\n\n while target\n path.push(target)\n target = prev[target]\n end\n\n path = path.reverse\n path\nend", "def solve(points)\r\n min_dis = BigDecimal(\"-1\")\r\n p min_dis.class\r\n \r\n min_route = []\r\n (1..points.length-1).to_a.permutation(points.length-1).to_a.each do |route|\r\n route.unshift(0)\r\n #p route\r\n dis = BigDecimal(\"0\")\r\n (0...route.length-1).each do |i|\r\n dis += Math.sqrt((BigDecimal(points[route[i]][0].to_s) - BigDecimal(points[route[i+1]][0]))**2 + (BigDecimal(points[route[i]][1]) - BigDecimal(points[route[i+1]][1]))**2)\r\n end\r\n dis += Math.sqrt((BigDecimal(points[route[route.length-1]][0]) - BigDecimal(points[route[0]][0]))**2 + (BigDecimal(points[route[route.length-1]][1]) - BigDecimal(points[route[0]][1]))**2)\r\n #p dis\r\n if min_dis == -1 || min_dis > dis\r\n #p dis.class\r\n min_dis = dis\r\n min_route = route\r\n end\r\n end\r\n\r\n p min_dis.class\r\n print \"{{\"\r\n (0...min_route.length).each do |i|\r\n print \"#{min_route[i]+1},\"\r\n end\r\n print \"1},#{min_dis}}\\n\"\r\n #p min_dis\r\n #p min_route\r\n\r\nend", "def solve\n @destinations = create_locations_from_file(file)\n @destinations.build_distance_table\n @bus.set_start(@destinations.get_start)\n while @bus.has_next_destination do\n @bus.drive_to_next_closet_destination\n end\n @bus.route\n end", "def dijkstra(root)\n distance, predecessor = initialize_single_source(root)\n @graph[root].each do |k, v|\n distance[k] = v\n predecessor[k] = root\n end\n queue = distance.dup\n queue.delete(root)\n\n while queue.size != 0\n\tmin = queue.min {|a, b| a[1] <=> b[1]}\n\tu = min[0]\t\t# extranct a node having minimal distance\n @graph[u].each do |k, v|\n\t # relaxing procedure of root -> 'u' -> 'k'\n if distance[k] > distance[u] + v\n distance[k] = distance[u] + v\n predecessor[k] = u\n end\n end\n\tqueue.delete(u)\n end\n return distance, predecessor\n end", "def minimumBribes(q)\n q.each_with_index.inject(0) do |bribes, (actual, index)|\n return bribes if q[index + 1].nil?\n\n index_diff = actual - index - 1\n maximun_distance = actual - 2\n distance = if index_diff <= 0 && maximun_distance >= 0 then\n q[maximun_distance...index].all? { |x| x > actual } ? 1 : 0\n else\n [index_diff, 0].max\n end\n\n debug(actual, distance, index_diff, bribes)\n\n if distance > 2\n return \"Too chaotic\"\n break\n end\n bribes + distance\n end\nend", "def solve\n dp = H.times.map { [nil] * W }\n dp[0][0] = 1 << 60\n dp[1][0] = A[0][0] + A[1][0] + C\n dp[0][1] = A[0][0] + A[0][1] + C\n\n (1...W).each do |x|\n dp[0][x] = [A[0][x - 1] + C + A[0][x],\n dp[0][x - 1] + C + A[0][x] - A[0][x - 1]].min\n end\n (1...H).each do |y|\n dp[y][0] = [A[y - 1][0] + C + A[y][0],\n dp[y - 1][0] + C + A[y][0] - A[y - 1][0]].min\n end\n (1...H).each do |y|\n (1...W).each do |x|\n now = A[y][x]\n dp[y][x] = [\n A[y - 1][x] + C + now,\n A[y][x - 1] + C + now,\n dp[y - 1][x] + C + now - A[y - 1][x],\n dp[y][x - 1] + C + now - A[y][x - 1]\n ].min\n end\n end\n\n dp.flatten.min\nend", "def getLongFlight(csa)\n number2 = 0\n @parse.map{ |airport| \n if( airport[\"name\"] == csa) \n airport[\"destinations\"].map do |element|\n number1 = element[\"distance\"]\n if(number1>number2)\n number2 = number1\n end\n end\n airport[\"destinations\"].map{ |dest| \n if(number2 == dest[\"distance\"])\n puts \"The max distance is \" + number2.to_s + \" in the fligth between \"+ dest[\"ports\"].to_s\n end\n }\n end\n }\n end", "def lesstrips_dfs(start, finish, max_distance, distance, visited, path, paths, cycles)\n adj_vertices(visited.last, adj_lists).each do |vertex|\n print \"Visited stack: #{visited}, Next vertex: #{vertex}\\n\"\n totald = distance + dist(visited.last, vertex)\n\n if visited.last == finish && cycles != \"NO CYCLES EXIST\"\n\n # try adding cycles\n\n visited_before_cycles = visited\n # picks expanded cycles that begin with finish vertex\n ec = expanded_cycles(cycles).select{|c| c.first == finish}\n\n # keep adding cycles till we reach max distance\n ec.each do |cycle1|\n visited, paths, break_loop = try_cycles(visited, cycle1, paths, 0, max_distance)\n visited1 = visited\n\n ec.each do |cycle2|\n begin\n visited, paths, break_loop = try_cycles(visited, cycle2, paths, 0, max_distance)\n end until break_loop\n visited = visited1\n end\n\n visited = visited_before_cycles\n end\n\n elsif !visited.include?(vertex) && totald != \"NO SUCH ROUTE\" && totald < max_distance\n visited << vertex\n path = visited\n distance = totald\n\n if vertex == finish\n paths << path\n print \"\\n*** Path: #{path}, Length: #{path_length(path)}\\n\\n\"\n visited.pop\n break\n end\n\n lesstrips_dfs(start, finish, max_distance, distance, visited, path, paths, cycles)\n visited.pop\n visited.pop if visited.size.between?(2, 3)\n visited = [start] if visited == []\n end\n end\n paths.size\n end", "def astar pos, phi, current_road, goal\n fringe = PriorityQueue.new\n # figure out which node of our road we're facing\n facing, other = [current_road.n0, current_road.n1].sort_by{|n|\n ((n.pos - pos).dir - phi).abs\n }\n fringe.add(AStarNode.new(facing, AStarNode.new(other, nil)))\n closed_states = Set.new [other]\n nodes_expanded = 0\n until fringe.isEmpty\n current = fringe.remove\n next if closed_states.include? current.state\n return current if current.state == goal\n\n expanded = current.expand\n \n closed_states << current.state\n # since we have a bunch of nodes that only go to a single\n # node, it seems kind of silly to count those as expansions\n nodes_expanded += 1 if expanded.size > 1\n \n if nodes_expanded > MAX_NODES_EXPANDED\n puts \"Reached max expansion depth\"\n return nil\n end\n expanded.each{|successor|\n successor.g = current.g + current.state.pos.dist(successor.state.pos)\n successor.h = successor.state.pos.dist goal.pos\n fringe.add(successor)\n }\n end\n puts \"Failed to find solution after #{nodes_expanded} expansions\"\n return nil\n end", "def transfers_to_reach_santa\n santa_ancestors = @node_hash['SAN'].ancestors\n you_ancestors = @node_hash['YOU'].ancestors\n closest_common_ancestor = self.class.closest_common_ancestor(santa_ancestors, you_ancestors)\n distance_from_common_to_santa = santa_ancestors.length - santa_ancestors.index(closest_common_ancestor) - 1\n distance_from_common_to_you = you_ancestors.length - you_ancestors.index(closest_common_ancestor) - 1\n distance_from_common_to_santa + distance_from_common_to_you\n end", "def minimumBribes(q)\r\n moves = 0\r\n r = (0..q.size-1).to_a\r\n\r\n until q == (1..q.size).to_a do\r\n q.map { |a| a - 1 }\r\n .reverse_each.with_index do |person, i|\r\n i = q.size - i - 1\r\n if person - i > 2\r\n puts \"Too chaotic\"\r\n return\r\n end\r\n\r\n if person > r[i] && person > q[person] -1\r\n moves += person - r[i]\r\n q = q - [person + 1]\r\n q.insert(person, person + 1)\r\n end\r\n end\r\n end\r\n\r\n puts moves\r\nend", "def can_complete_circuit(gas, cost)\n total = 0\n trip = 0\n start = 0\n (0...gas.size).each { |i|\n trip += gas[i] - cost[i]\n total += trip\n if trip < 0\n trip = 0\n start = i + 1\n end\n }\n \n total < 0 ? - 1 : start\nend", "def find_optimal(rootCode,goalCode)\n\tfindHops(rootCode, goalCode, \n\t\tlambda{|flight,oldweight| \n\t\t\toldweight + (flight.date.date.to_i + (flight.flightDuration).seconds - @date.date.to_i)/1200 + 100 + flight.seatprice/5 \n\t\t\t# oldweight + (number of hours between arrival and departure + 100 (per hop))*3 + seatprice/5 (~25-250)\n\t\t\t})\nend", "def problem_107\n if false\n net = [ \"-,16,12,21,-,-,-\", \"16,-,-,17,20,-,-\", \"12,-,-,28,-,31,-\",\n \"21,17,28,-,18,19,23\", \"-,20,-,18,-,-,11\", \"-,-,31,19,-,-,27\",\n \"-,-,-,23,11,27,-\" ]\n net.map! {|line| line.split(/,/).map {|i| i == '-' ? nil : i.to_i}}\n else\n net = []\n open(\"network.txt\").each do |line|\n net << line.chomp.split(/,/).map {|i| i == '-' ? nil : i.to_i}\n end\n end\n\n # Reformat into an array of nodes, with the their connections\n nodes = Hash.new {|h,k| h[k] = Hash.new }\n net.each_with_index do |row,i| # Each nodes is connected to...\n row.each_index do |col| # For each possible connection....\n # Add the node we are connected to and the cost\n nodes[i][col] = row[col] if row[col]\n end\n end\n\n initial = nodes.reduce(0) do |a,row|\n row[1].reduce(a) {|aa,p| aa + p[1] }\n end / 2\n # add to the 'borg' that is node0\n node0,node0_links = nodes.shift\n ans = []\n node0_contains = Hash.new\n node0_contains[node0] = true\n\n # What we do select the lowest link, the 'merge' it into node0, repeat\n while nodes.length > 0\n n,v = node0_links.min {|a,b| a[1] <=> b[1]}\n ans << [n,v] # Save the link for the answer\n node0_contains[n] = true # add to the 'borg' that is node0\n nodes[n].each_pair do |k,a| # Now merge in new poin, update vertexs\n next if node0_contains[k]\n node0_links[k] = [a, node0_links[k] || 1_000_000].min\n end\n nodes.delete(n) # Remove from free nodes\n node0_links.delete(n) # Remove from vertexes to resolve\n end\n\n now = ans.reduce(0) {|a,v| a + v[1]}\n puts \"initial = #{initial}\"\n puts \"now = #{now}\"\n initial - now\nend", "def greedy strategy\n closed = []\n fringe = initialize_fringe\n\n loop do\n return nil if fringe.empty? # No solution\n current = fringe.delete(strategy.next(fringe)) # Pick next using heuristic\n city = current[:city]\n return current if done? city # Found solution?\n unless closed.include? city # Only expand new cities\n closed.push city\n fringe = fringe + expand(current)\n end\n end\n end", "def truckin(trucks, mileage)\n distance = 0\n while trucks >= 1\n distance += (mileage.to_f / trucks)\n trucks -= 1\n end\n distance\nend", "def path_finder(start_node=START_NODE, goal_node=GOAL_NODE)\n\t\n\t# INITIALIZE\n\tvalid = valid_nodes # largest set\n\treachable = [start_node] # nodes we can reach from current node\n\texplored = [] # nodes we've already considered\n\t# nodes reachable, valid, and not explored\n\topen_nodes = valid.select{|node| reachable.include?(node)}.select{|node| !explored.include?(node)} \n\t# record node path {node => previous_node}\n\tnodes_path = {start_node => nil} \n\t\n\twhile !open_nodes.empty?\n # node = choose_node(reachable)\n\t\tnode = open_nodes.sample # random node in open_nodes\n\t\t\n\t\treturn build_path(goal_node, nodes_path) if node==goal_node # STOP if reached goal! \n \n # Don't repeat ourselves.\n reachable.delete(node) # remove current node from reachable\n explored.push(node) # add node to explored\n \n # What nodes are now open from this node?\n # Adjacent, not in explored, and valid (not an obstacle and in maze)\n new_reachable = (get_adjacent_nodes(node) - explored) & valid\n\t\t# ADD new nodes to reachable\n new_reachable.each do |adj_node|\n if !reachable.include?(adj_node)\n # adjacent.previous = node # Remember how we got there.\n nodes_path[adj_node] = node # {[0,3] => [0,2]}\n reachable << adj_node\n end\n end\n \n\t\t# REFRESH OPEN NODES\n open_nodes = valid.select{|node| reachable.include?(node)}.select{|node| !explored.include?(node)} \n \n end\n \n\treturn nil # open_nodes empty - no path found\nend", "def shortest_way(source, dest)\n\t\t@source = source\n dijkstra source\n \n if @distances[dest] != @infinity\n return @distances[dest]\n end\n\tend", "def find_path(start_node, end_node, grid)\n start_node = sanitize(start_node)\n end_node = sanitize(end_node)\n if grid.nil?\n [start_node]\n else\n _max_x = grid.max_x\n _max_y = grid.max_y\n\n @current_grid = grid.inner_grid.clone\n\n raise 'max_x & max_y required' unless _max_x && _max_y\n\n _start_node = start_node.clone\n _end_node = end_node.clone\n\n heuristic = @heuristic.new(_end_node, @weight)\n\n _start_node[:f] = 0 # sum of g and h\n _start_node[:g] = 0 # steps to start node\n _start_node[:h] = nil # steps to end node\n _start_node[:opened] = true\n\n # use heap or tree for better perf\n open = []\n open.push _start_node\n\n while !open.empty? do\n _current_node = open.pop\n\n _current_node[:closed] = true\n @current_grid[node_to_a(_current_node)] = _current_node\n\n if node_to_a(_current_node) == node_to_a(_end_node)\n return final_path(_current_node)\n end\n\n new_g = _current_node[:g] + 1\n\n x = _current_node[:x]\n y = _current_node[:y]\n\n neighbors = []\n\n neighbors << [x-1, y] if x > 0\n neighbors << [x, y-1] if y > 0\n neighbors << [x+1, y] if x < _max_x-1\n neighbors << [x, y+1] if y < _max_y-1\n\n _neighbors = neighbors.map do |position|\n node = @current_grid[position]\n if node.nil? || node[:walkable]\n node ||= {}\n @current_grid[position] = node.merge({\n x: position.first,\n y: position[1],\n closed: false,\n opened: false\n })\n end\n end.compact\n\n _neighbors.each do |neighbor|\n if (!neighbor[:opened] || new_g < neighbor[:g])\n neighbor[:g] = new_g\n neighbor[:h] ||= heuristic.h(neighbor)\n neighbor[:f] = neighbor[:g] + neighbor[:h]\n neighbor[:parent] = node_to_a(_current_node)\n\n if (!neighbor[:opened])\n open.push neighbor\n neighbor[:opened] = true\n else\n # ???\n puts \"got here some how!!!\"\n end\n end\n end\n\n open.sort_by! {|i| [-i[:f], -i[:h]]}\n # grid_p\n end\n end\n end", "def dijkstra(src, target = nil)\n frontier = PriorityQueue.new\n shortest_paths = {src => 0}\n frontier[src] = 0\n\n until frontier.empty?\n v, c = frontier.pop_min # much faster\n\n return c if target == v\n shortest_paths[v] = c\n\n v.outer_edges.each do |e|\n v2, c2 = e.to, e.cost\n next if shortest_paths[v2]\n\n frontier.insert([v2, c + c2]) # faster\n end\n end\n\n shortest_paths\nend", "def brute_force_optimal(tg,faulty,replacements,n)\n if tg[1].size == 0 # special case if there are no edges(all replacements are equal)\n return get_mappings(faulty,replacements)[0] # return the first mapping\n end\n get_mappings(faulty,replacements).min_by do |a|\n euclidean_distance(tg,a,n) \n end\nend", "def solution(a, b)\n return 0 if a == 0 && b == 0 # why do anything?\n\n nummoves = 0 # track moves\n board = Board.new(a, b) # handle visited squares\n\n queue = [ {x: 0, y: 0} ] \n while queue.size > 0 && nummoves < MAX_MOVES do \n nummoves = nummoves + 1 \n\n # \"drain queue\" to check and mark as checked\n queue.each do |square|\n board.push square\n square[:moves] = []\n\n MOVES.each do |move|\n nextmove = { x: move[:x] + square[:x], y: move[:y] + square[:y] }\n return nummoves if nextmove[:x] == a && nextmove[:y] == b\n if board.in_bounds?(nextmove[:x], nextmove[:y]) && !board.visited?(nextmove[:x], nextmove[:y]) \n square[:moves].push nextmove \n end\n end\n end \n \n # enqueue children since we haven't hit our mark\n newq = []\n queue.each do |square|\n newq.concat square[:moves]\n end\n queue = newq.uniq\n end\n \n -1\nend", "def cohesion(boids)\n neighbordist = 50\n sum = PVector.new(0, 0) # Start with empty vector to accumulate all locations\n count = 0\n boids.each do |other|\n d = PVector.dist(@location, other.location)\n if d > 0 && d < neighbordist\n sum.add(other.location) # Add location\n count += 1\n end\n end\n if count > 0\n sum.div(count)\n return seek(sum) # Steer towards the location\n else\n return PVector.new(0, 0)\n end\n end", "def allocate_distance(total)\n\t\t# TODO - should be a range from .5 - .2 incr of .05 - 6 possibilites\n\t\tincr = rand(0..5)\n\t\t@up.target_distance = total * (0.2 + (0.05 * incr))\n\n\t\ttotal -= @up.target_distance\n\n\t\t@down.target_distance = 200\n\t\ttotal -= @down.target_distance\n\n\t\t@main.target_distance = total\n\tend", "def shortest_path\n initial_position_obj = { position: start_position, source: {} }\n\n knights_path = [initial_position_obj]\n\n while knights_path.present?\n current_position = knights_path.shift\n\n position = current_position[:position]\n\n if position == end_position\n return path_to_destination(current_position, initial_position_obj)\n end\n\n add_possible_destination(position, current_position, knights_path)\n end\n end", "def findnearest( coords, targetx, targety )\n # find nearest coordinate\n nearest = 0\n targetcounter = 0\n target = -1\n coords.each do |neighborx,neighbory|\n d = Math::sqrt( ( neighborx - targetx ) ** 2 + ( neighbory - targety ) ** 2 )\n if d < 0.2\n target = targetcounter\n end\n targetcounter += 1\n end\n return target\nend", "def greedy(tg,faulty,replacements,n)\n result = Hash.new\n repl = Array.new(replacements.size) {|i| replacements[i]}\n # sort tg by # successors\n sort_by_subtree_size!(tg)\n\n # sort faulty by # successors\n faulty.sort_by!{|a| tg[0].index(lookup_task(tg,a))}\n \n faulty.each do |fault|\n # pick the replacement which minimizes starting time of fault\n choice = repl.min_by{|a| euclidean_distance(tg,result.merge({fault=>a}),n)}\n # add the mapping to the solution\n result[fault] = choice\n # remove the replacement from the set\n repl.delete(choice)\n end\n return result\nend", "def solve\n queue = [self]\n seen = {}\n loop do\n return nil unless p = queue.shift\n return p if p.solved?\n unless seen[p.to_s]\n p.available_moves.each do |move|\n p2 = p.clone.move(*move)\n queue << p2\n queue = queue.sort_by {|a| a.moves.size + a.solved_distance} \n seen[p.to_s] = true\n end\n end\n end\n end", "def solution_proximity_heuristic(amount,comb,coins)\n (amount-comb.sum)*min_size_heuristic(amount,comb,coins)\nend", "def dijkstra(source)\n\t\t@distances = {}\n\t\t@predecessor_node = {}\n\t\t@nodes.each do |node|\n\t\t\t@distances[node] = @infinity\n\t\t\t@predecessor_node[node] = -1\n\t\tend\t\n\t\t@distances[source] = 0\n\t\tnodes_compressed = @nodes.compact\n\t\twhile (nodes_compressed.size > 0)\n\t\t\tnode_near = nil;\n\t\t\tnodes_compressed.each do |node_compressed|\n\t\t\t\tif (not node_near) or (@distances[node_compressed] and @distances[node_compressed] < @distances[node_near])\n\t\t\t\t\tnode_near = node_compressed\n\t\t\t\tend\n\t\t\tend\n\t\t\tif (@distances[node_near] == @infinity)\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tnodes_compressed = nodes_compressed - [node_near]\n\t\t\t@graph[node_near].keys.each do |neighbor_node|\n\t\t\t\ttotal_distance = @distances[node_near] + @graph[node_near][neighbor_node]\n\t\t\t\tif (total_distance < @distances[neighbor_node])\n\t\t\t\t\t@distances[neighbor_node] = total_distance\n\t\t\t\t\t@predecessor_node[neighbor_node] = node_near\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend", "def min_distance_away(truth_points, up)\n truth_points.inject([]){|arr, p| arr << [up.sqd_distance(p), p]; arr}.min{|a, b| a.first <=> b.first}\n end", "def minimum_jumps(arr)\n # two arrays. One to keep track of minimum number of jumps needed to reach\n # the position. The other to keep track of which index was needed to reach\n # a given index position.\n num_jumps = [0]\n jump_idx = [nil]\n # use two pointers, one being the destination index and the other\n # being which index to jump from to reach it.\n destination_idx = 1\n while destination_idx < arr.length\n current_idx = find_starting_idx(destination_idx, jump_idx)\n p [current_idx, destination_idx]\n # break the inner while loop once we find an answer\n while current_idx < destination_idx && num_jumps[destination_idx].nil?\n if can_jump?(arr, current_idx, destination_idx)\n num_jumps[destination_idx] = num_jumps[current_idx] + 1\n jump_idx[destination_idx] = current_idx\n end\n current_idx += 1\n end\n destination_idx += 1\n end\n p jump_idx\n num_jumps.last\nend", "def find_shortest(rootCode,goalCode)\n\tself.findHops(rootCode, goalCode, lambda{|flight,oldweight| oldweight+1})\nend", "def calculate_path_size\n t0 = Time.now\n path_sizes = {0 => 0.0, 1 => 0.0, 2 => 0.0, 4 => 0.0, 10 => 0.0, Float::INFINITY => 0.0}\n\n # Retrieves all routes provenient from the same trip\n sibling_routes = AlternateRoute.where(:trip_id => @route.trip_id)#.where(\"state != 'discarded'\")\n\n # Get segment-based mileage for all sibling routes\n sibling_routes_mileage = calculate_routes_mileage(sibling_routes)\n\n # Remove the main route from sibling routes group\n sibling_routes = (sibling_routes.map{|r| r.id} - [@route.id])\n\n # Generate frequencies of each route segment over alternate routes\n frequencies = {}\n appearances = Segment.where(:osm_way_id => @segment_ids).group_by {|s| s.osm_way_id}\n appearances.each do |k, v|\n frequencies[k] = v.map{|e| e.alternate_route_id}.uniq - [nil]\n end\n\n @route.segments.each do |segment|\n segment_length = segment.length\n\n impedance = segment_length/sibling_routes_mileage[@route.id]\n\n # Get all sibling routes where the current segment is used\n ocurrences = frequencies[segment.osm_way_id] & sibling_routes\n #ocurrences = AlternateRoute.joins(:segments).where(:id => sibling_routes).where(\"segments.osm_way_id = ?\", segment.osm_way_id).references(:segments).pluck(:id).uniq\n\n path_sizes.keys.each do |gamma|\n sums = {0 => 1.0, 1 => 1.0, 2 => 1.0, 4 => 1.0, 10 => 1.0, Float::INFINITY => 1.0}\n\n ocurrences.each do |route|\n if gamma == Float::INFINITY\n # if (sibling_routes_mileage[@route.id]/sibling_routes_mileage[route]) > 1.0\n if (sibling_routes_mileage.values.min/sibling_routes_mileage[route]) > 1.0\n sums[gamma] = 0.0\n end\n else\n # sums[gamma] += (sibling_routes_mileage[@route.id]/sibling_routes_mileage[route])**gamma\n # sums[gamma] += (sibling_routes_mileage.values.min/sibling_routes_mileage[route])**gamma\n sums[gamma] += (sibling_routes_mileage.values.min/sibling_routes_mileage[route])**gamma**@route.systems_suggested\n end\n end\n\n if gamma == Float::INFINITY\n path_sizes[gamma] += (impedance * sums[gamma])\n else\n path_sizes[gamma] += (impedance * (1.0/sums[gamma]))\n end\n end\n end\n puts \"[#{@route.id}] Completed in #{(Time.now - t0)* 1000.0} ms\"\n puts \"[#{@route.id}] Path Size: #{path_sizes}\"\n path_sizes\n end", "def shortest_distance_to_all_nodes(initial)\n Hash[shortest_path_to_all_nodes(initial).map {|n| [n, n.distance]}]\n end", "def main(points) # array with all the points\n #copy of the array by an especific cordinate\n #nlogn\n # This is a primitive, aka operations that are costless compared to the\n # total complexity we are aming for\n px = sort_by_cordinate(points, 0)\n py = sort_by_cordinate(points, 1)\n\n result = closest_pair(px, py)\nend", "def dijkstra\n # Intialise the algorithom if first run\n init_dijkstra if empty_path?\n\n # Stop the execution if all the nides have been reached\n return path if completed_path?\n\n # Make sure that all the weights are updated\n current_node[:node].adjacent_nodes.values.each do |node|\n @pool << node.merge(\n from: current_node[:node],\n weight: node[:weight] + current_node[:weight]\n )\n end\n\n # Sort the pool of nodes/edges by weight so to be able to grab the smallest\n # weight.\n pool.sort_by! { |edge| edge[:weight] }\n\n # Pick the next untouched node by shifting the nodes in the pool starting\n # from the smallest to the greatest.\n next_node = nil\n loop do\n next_node = pool.shift\n break unless values_in_path.include?(next_node[:node].value)\n end\n\n # Push the next step (from -> to) in the path\n @path << \"#{next_node[:from].value} ==> #{next_node[:node].value}\"\n\n # Track the node as seen\n @values_in_path += [next_node[:node].value, current_node[:node].value]\n\n # Update the current node\n @current_node = next_node\n\n # Keep the execution going\n dijkstra\n end", "def bike_on_road(road)\n \n @destinations_left_behind += missed_destinations(road)\n puts \"missed destinations:\", @destinations_left_behind\n destination_city = road.the_city_opposite(@current_city)\n\n # we have arrived at the city now\n @current_city = destination_city\n\n @visited_cities << @current_city\n\n end", "def calculate_g(neighbor)\n total_g = 0\n branching_dup = dup_hash(@branching_paths)\n loop do\n parent = branching_dup[neighbor]\n if diagonal_move?(parent, neighbor)\n total_g += 14\n else\n total_g += 10\n end\n break if neighbor == @maze.find_start\n neighbor = parent\n end\n total_g\n end", "def road_trip_game(route, neighbours)\n seen_plate_scores = {}\n route.each do |state, plates|\n plates.each do |plate|\n points = state_distance(state, neighbours, plate)\n seen_plate_scores[plate] = seen_plate_scores[plate].nil? ? [points] : seen_plate_scores[plate].push(points)\n end\n end\n \n result = {}\n seen_plate_scores.each do |plate, scores|\n result[plate] = scores.max\n end\n result\nend", "def print_shortest_flight(graph_instance)\n min_distance = 100000\n city1 =''\n city2 =''\n graph_instance.node_hash.each_key { |key|\n linked = graph_instance.node_hash[key].linked_cities\n linked.each{ |tuple|\n if(tuple.distance < min_distance)\n min_distance = tuple.distance\n city1 = key\n city2 = tuple.city\n end\n }\n }\n puts \"Shortest flight is #{min_distance} between #{city1} and #{city2}\"\nend", "def run\n closed_squares = []\n opened_squares = [@start]\n\n @start.current_path_cost = 0\n\n while opened_squares.any?\n current_square = opened_squares.sort do |a, b|\n a.estimated_total_cost(@finish) <=> b.estimated_total_cost(@finish)\n end.first\n\n if current_square == @finish\n return find_path(current_square)\n end\n\n closed_squares.push(current_square)\n opened_squares.delete(current_square)\n\n @board.neighbours(current_square).each do |neighbour|\n if closed_squares.include?(neighbour)\n next\n end\n\n if !opened_squares.include?(neighbour)\n opened_squares.push(neighbour)\n end\n\n if current_square.current_path_cost + neighbour.move_cost >= neighbour.current_path_cost\n next\n end\n\n neighbour.path_via = current_square\n neighbour.current_path_cost = current_square.current_path_cost + neighbour.move_cost \n end\n end\n end" ]
[ "0.71177846", "0.62346464", "0.61523235", "0.6033831", "0.6024065", "0.60100675", "0.5988783", "0.5965839", "0.595736", "0.5826507", "0.5799008", "0.5764749", "0.5764295", "0.57489306", "0.5745554", "0.5735429", "0.5727455", "0.5722662", "0.5702264", "0.5689565", "0.56660587", "0.56524795", "0.5650609", "0.56047285", "0.55855143", "0.5571241", "0.5538588", "0.5510234", "0.55088794", "0.5506022", "0.5490212", "0.5478872", "0.5477924", "0.54708207", "0.5467377", "0.546222", "0.54616874", "0.5446603", "0.5438805", "0.542353", "0.53998375", "0.53941435", "0.5390508", "0.53852785", "0.53784657", "0.5353183", "0.534878", "0.5342138", "0.53250325", "0.53232306", "0.53194976", "0.531914", "0.5316171", "0.53055483", "0.53044176", "0.53008413", "0.5288798", "0.5284314", "0.52834827", "0.52834123", "0.52732253", "0.5271473", "0.5267016", "0.5259946", "0.5254859", "0.5254342", "0.52508336", "0.5243792", "0.5241386", "0.52407914", "0.5234112", "0.5227385", "0.52245265", "0.5205422", "0.520074", "0.5199327", "0.51971024", "0.5197009", "0.51931703", "0.51927185", "0.5188708", "0.5179163", "0.51739305", "0.5166843", "0.5148812", "0.5147786", "0.5147255", "0.5144951", "0.51404345", "0.5122673", "0.51154596", "0.5114756", "0.5109735", "0.5109136", "0.51074576", "0.5106513", "0.5103299", "0.5098787", "0.5082193", "0.50809395" ]
0.59606487
8
As a user, if 'modify' is selected, I am prompted to enter an id for the contact to be modified. As a user, when an id is entered, I am prompted to type 'yes' or 'no' to confirm my selection. As a user, if 'yes' is typed, I am prompted to change 'firstname', 'lastname', 'email' or 'notes' by number. You shouldn't be able to change the 'id'.
def modify_contact puts "Please enter the id of the contact to modify: " id = gets.chomp.to_i puts "Please confirm 'yes' or 'no' to modify this contact: " puts @rolodex.display_contact(id) answer = gets.chomp.downcase if answer == 'yes' puts "Please enter the number of the attribute you would like to edit: \n 1. First Name \n 2. Last Namme \n 3. Email \n 4. Note" option = gets.chomp.to_i puts "Please provide the edit:" new_attribute = gets.chomp @rolodex.modify_contact(id, option, new_attribute) puts "Edit complete: " puts @rolodex.display_contact(id) elsif answer == 'no' return else puts "That is not a valid answer, please try again." end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def modify_contact\n puts \"Enter the id of the contact you would like to modify\"\n id_to_modify = gets.chomp \n\n contact = Contact.find(id_to_modify)\n \n puts \"Are you sure? (y/n)\"\n \tuser_input = gets.chomp\n\n if user_input == \"y\"\n puts \"Enter the id of the contact that you would like to change? 1. First Name, 2. Last Name, 3. Email, 4. Notes\"\n user_input = gets.chomp\n puts \"What is the new value?\"\n new_value = gets.chomp \n case field \n \t when 1 \n \t contact.first_name = new_value\n \t when 2\n \t\tcontact.last_name = new_value\n \t when 3 \n \t\tcontact.email = new_value\n \t when 4\n contact.notes = new_value \n else \n \t puts \"No changes were made\"\n end \n end\n end", "def modify_option\n\t\t\n\t\tputs \"What is the ID of the user you seek?\"\n\t\t\n\t\tselected_id = gets.to_i\n\t\t\n\t\tputs @rolodex.find_contact(selected_id)\n\n\t\tputs \"What is the new first name?\"\n\t\tfirst_name = gets.chomp\n\t\t\n\t\tputs \"What's the new last name?\"\n\t\tlast_name = gets.chomp\n\t\t\n\t\tputs \"What's the new email?\"\n\t\temail = gets.chomp\n\t\t\n\t\tputs \"What's the new note?\"\n\t\tnote = gets.chomp\n\n\t\tmodified_contact = Contact.new(first_name,last_name,email,note)\n\n\t\t@rolodex.edit_contact(selected_id,modified_contact)\n\n\n#Similarly making life easier by removing this for now. \n\t\t# case user_selected\n\t\t# \twhen 1\n\t\t# \t\t#modify ID\n\t\t# \twhen 2\n\t\t# \t\t#modify First Name\n\t\t# \twhen 3\n\t\t# \t\t#modify Last Name\n\t\t# \twhen 4\n\t\t# \t\t#modify email address\n\t\t# \twhen 5\n\t\t# \t\t#modify note\n\t\t# \twhen 6\n\t\t# \t\tputs \"goodbye\"\n\t\t# \t\treturn\n\t\t# \telse\n\t\t# \t\tputs \"Invalid option. Try again.\"\n\t\t# \t\tprint_modify_menu\n\t\t# end\n\n\tend", "def edit\n puts \"\\nSelect field to edit in Personal Details\"\n ch = \"1\"\n until ch == \"6\" do\n puts \" 1 => Name\\n 2 => Date Of Birth\\n 3 => Marital Status\\n 4 => Mobile Number\\n 5 => Email\\n 6 => Exit\"\n ch = gets.chomp\n case ch\n when \"1\"\n print \" Name : \"\n name = gets.chomp\n update({:name => name}) unless name == \"\"\n when \"2\"\n print \" Date Of Birth : \"\n dob = gets.chomp\n update({:dob => dob}) unless dob == \"\"\n when \"3\"\n print \" Marital Status : \"\n marital_status = gets.chomp\n update({:marital_status => marital_status}) unless marital_status == \"\"\n when \"4\"\n print \" Mobile Number : \"\n mobile_number = gets.chomp\n update({:mobile_number => mobile_number}) unless mobile_number == \"\"\n when \"5\"\n print \" Email : \"\n email = gets.chomp\n update({:email => email}) unless email == \"\"\n when \"6\"\n \n else\n puts \"Wrong Choice\"\n end\n end\n end", "def modify_existing_contact\n display_all_contacts\n puts \"Choose the ID you would like to modify\"\n id = gets.chomp.to_i\n modify_contact = Contact.find(id)\n unless modify_contact\n puts \"ID not found\"\n return\n end\n\n attribute_list\n\n while user_selected =gets.to_i\n\n case user_selected\n when 1 then puts \"Enter New First Name\"\n new = modify_contact.update(:first_name, value = gets.chomp)\n puts\n modify_contact.display_contact\n puts\n break\n\n when 2 then puts \"Enter New Last Name\"\n new = modify_contact.update(:last_name, value = gets.chomp)\n puts\n modify_contact.display_contact\n puts\n break\n\n when 3 then puts \"Enter New Email Address\"\n new = modify_contact.update(:email, value = gets.chomp)\n puts\n modify_contact.display_contact\n puts\n break\n\n when 4 then puts \"Enter New Note\"\n new =modify_contact.update(:note, value = gets.chomp)\n puts\n modify_contact.display_contact\n puts\n break\n\n else\n puts \"=======================================\"\n puts \"please enter a number between 1 and 4\"\n puts \"=======================================\"\n attribute_list\n end\n end\n end", "def modify_existing_contact\n display_all_contacts\n puts \"What ID would you like to modify?\"\n id = gets.to_i\n modify_existing_contact = Contact.find(id)\n\n attribute_list\n\n case user_selected\n when 1 then puts \"Edit First Name\"\n edit = modify_existing_contact.update(:first_name, value =gets.chomp)\n puts\n modify_existing_contact.display_contact\n\n\n\n when 2 then puts \"Edit Last Name\"\n edit = modify_existing_contact.update(:last_name, value =gets.chomp)\n puts\n modify_existing_contact.display_contact\n\n\n\n when 3 then puts \"Edit Email\"\n edit = modify_existing_contact.update(:email, value =gets.chomp)\n puts\n modify_existing_contact.display_contact\n\n\n\n when 4 then puts \"Edit Note\"\n edit = modify_existing_contact.update(:note, value =gets.chomp)\n puts\n modify_existing_contact.display_contact\n\nelse\n puts \"Please select an attribute from 1 to 4\"\n attribute_list\n end\n end", "def modify_contact\n\t\tprint_modify_contact\n \tmodify_attribute = gets.chomp.to_i\n\n \tif modify_attribute == 5 \t\n \t\tmain_menu \n \telse \n\t \tputs \"Are you sure you want to change this attribute [Y/N]\"\n\t \tconfirm = gets.chomp\n\t \tif confirm.downcase == \"y\"\n\t \t\tmodify_contact_option(modify_attribute)\n\t \telse\n\t \t\tmodify_contact\n\t \tend\n\t end\n\tend", "def editContacts(db)\r\n\tputs \"::::::::::::::::::::::::::::Edit Contacts:::::::::::::::::::::::::::::::::::\"\r\n\tputs \"Enter the ID of the contact to edit:\"\r\n\tid = gets.chomp.to_i\r\n\t\r\n\tputs\"1 --To Edit Name\"\r\n\tputs\"2 --To Edit Phone #\"\r\n\tputs\"3 --To Edit Address\"\r\n\tx = gets.chomp.to_i\r\n\tcase x\r\n\twhen 1\r\n\t\tputs \"Enter new name:\"\r\n\t\tn = gets.chomp\r\n\t\tdb.execute(\"UPDATE contacts SET name = ? WHERE id = ?\", [n, id])\r\n\twhen 2\r\n\t\tputs \"Enter new phone number (No dashes/parens):\"\r\n\t\tp = gets.chomp.to_i\r\n\t\tdb.execute(\"UPDATE contacts SET phone = ? WHERE id = ?\", [p, id])\r\n\twhen 3\r\n\t\tputs \"Enter new address:\"\r\n\t\ta = gets.chomp\r\n\t\tdb.execute(\"UPDATE contacts SET address = ? WHERE id = ?\", [a,id])\r\n\telse\r\n\t\tputs \"Invalid Selecting...\"\r\n\tend\r\n\r\nend", "def modify_contact\n contact = retrieve_contact_by_email\n if contact\n attr_code = attr_menu\n if attr_code\n print \"You have chosen to change the contact's #{@@attr_ops[attr_code]}. Is that correct? \"\n confirm = gets.chomp.downcase\n if confirm == 'yes'\n print \"Please provide the new value for #{@@attr_ops[attr_code]}: \"\n new_value = gets.chomp\n contact = @rolodex.modify(contact, attr_code, new_value)\n if contact\n puts \"Contact successfully updated:\\n#{contact}\\n\"\n end\n elsif confirm == 'no'\n print \"Update canceled. \"\n else\n puts \"Error: only 'yes' and 'no' are valid responses.\"\n end\n end\n end \n return contact\n end", "def modify_contact\n # prompt user for id\n puts \"What id to modify?\"\n id = gets.chomp.to_i\n # get contact from rolodex\n contact = @rolodex.get_contact_by_id(id)\n # call modify\n modify(contact)\n end", "def edit_patron(selected)\n\tedit_patron_name(selected)\n\tedit_patron_email_address(selected)\nend", "def modify_existing_contact \n\t\t contact = display_one_contact\t\n\t\t print \"Change First Name: \"\n\t\t first_name = gets.chomp\n\t\t print \"Change Last Name: \"\n\t\t last_name = gets.chomp\n\t\t print \"Change Email Address: \"\n\t\t email = gets.chomp\n\t\t print \"Change your Note: \"\n\t\t note = gets.chomp\n\t\t contact = Contact.new(first_name, last_name, email, note)\n\tend", "def edit_contact(db, contact_id)\n # Get the right record, stuff the data into the \"contact\" variable\n edit_contact_query = \"SELECT \n ids\n ,firstname\n ,lastname\n ,phone\n ,address\n ,email\n ,occupation\n ,company\n ,tags\n \n FROM contacts WHERE ids = #{contact_id};\"\n \n contact = db.execute(edit_contact_query)\n\n # edit the data\n puts \"The contact record you've chosen is:\\n\\n#{contact}\\n\\n\"\n what_to_change = input(\"What would you like to change? You can change\n \n firstname\n lastname\n phone\n address\n email\n occupation\n company\n \n or you can type 'edit tags' to edit associated tags.\")\n \n if what_to_change == \"edit tags\"\n #WARNING -- passes the whole contact array into the edit-tags function\n edit_tags(contact)\n \n #if it's an allowed choice \n elsif [ \"firstname\", \"lastname\", \"phone\", \"address\", \"email\", \"occupation\", \"company\",].include?(what_to_change)\n newinfo = input(\"What would you like to change the #{what_to_change} to?\")\n \n #make the change\n query = \"UPDATE contacts\n SET #{what_to_change}='#{newinfo}'\n WHERE ids='#{contact_id}'\"\n \n db.execute(query)\n \n end\n \n changedcontact = db.execute(edit_contact_query)\n puts \"The contact record is now\\n\\n#{changedcontact}\\n\\n\"\n \nend", "def pet_sitter_edit(pet_sitter)\n if @prompt.select(\"Edit name? \", @yes_or_no)\n pet_sitter[\"name\"] = @prompt.ask(\"Name: \") do |q|\n # error handling requiring input\n q.required true\n q.validate /[a-z]+/\n # error handling message\n q.messages[:valid?] = \"Name need to start with a letter.\"\n q.messages[:required?] = \"Required name\"\n q.modify :capitalize\n end\n end\n\n if @prompt.select(\"Edit Email? \", @yes_or_no)\n pet_sitter[\"contact\"] = @prompt.ask(\"Email: \") do |q|\n # error handling requiring input\n q.required true\n q.messages[:required?] = \"Required email address\"\n # error handling message\n q.validate(/\\A\\w+@\\w+\\.\\w+\\Z/, \"Invalid email address\")\n end\n end\n\n if @prompt.select(\"Edit Post Code? \", @yes_or_no)\n pet_sitter[\"post_code\"] = @prompt.ask(\"Post code: \", convert: :integer) do |q|\n q.messages[:valid?] = \"Post code has to be a number\"\n end\n end\n\n if @prompt.select(\"Edit ABN? \", @yes_or_no)\n pet_sitter[\"abn\"] = @prompt.ask(\"ABN: \", convert: :integer) do |q|\n q.messages[:convert?] = \"ABN has to be a number (no spaces)\"\n end\n end\n \n @db.edit(\"pet_sitters\", pet_sitter)\n return pet_sitter\n end", "def show_edit_menu\n puts \" You are now in edit mode\"\n puts \" edit name - edit the name of this contact\"\n puts \" edit email - edit the email of this contact\"\n puts \" add phone - add a phone number to this contact\"\n puts \" edit importance - edit the importance of this contact\"\n print \"> \"\n end", "def edit_data\n puts \"1-add student\"\n puts \"2-delete student\"\n puts \"3-edit student data\"\n user_selection = gets.chomp\n case user_selection\n when \"1\"\n add_student\n when \"2\"\n delete_student\n when \"3\"\n edit_student_data\n else\n puts @dash+\"error-invalid-selection\"+@dash\n user_menu\n end\n end", "def edit_patron_email_address(selected)\n\tp = Patron.find(selected)\n\tprint \"To edit the patron email address please enter here: \"\n\temail_address = gets.chomp\n\tp.update_attributes(email_address: email_address)\nend", "def edit_contact(first_name,last_name,email,note)\n @selected_contact.first_name = first_name\n @selected_contact.last_name = last_name\n @selected_contact.email = email\n @selected_contact.note = note\n end", "def update(update_contact)\n found_contact = false\n @@contact_list.each do |info|\n if info == update_contact\n found_contact = true\n puts \"Would you like to change the \\'first name\\', \\'last name\\', \\'email\\', or \\'note\\'?\n Please type it in below as one of the four choices. Please mind your spelling.\"\n answer = gets.chomp.downcase.to_s\n if answer == \"first name\"\n puts \"What would you like to change the first name to?\"\n @first_name = gets.chomp.to_s\n elsif answer == \"last name\"\n puts \"What would you like to change the last name to?\"\n @last_name = gets.chomp.to_s\n elsif answer == \"email\"\n puts \"What would you like to change the email to?\"\n @email = gets.chomp.to_s\n elsif answer == \"note\"\n puts \"What would you like to change the note to?\"\n @note = gets.chomp.to_s\n else\n puts \"Your answer is invalid. Start over\"\n break\n end\n end\n if found_contact == false\n puts \"Your contact doesn't exist in your list.\"\n end\n end\n end", "def pet_edit(pet)\n if @prompt.select(\"Edit pet name? \", @yes_or_no)\n pet[\"name\"] = @prompt.ask(\"Name: \")do |q|\n # error handling requiring input\n q.required true\n q.validate /[a-z]+/\n # error handling message\n q.messages[:valid?] = \"Name need to start with a letter.\"\n q.messages[:required?] = \"Required pet name\"\n q.modify :capitalize\n end\n end\n\n if @prompt.select(\"Edit pet age? \", @yes_or_no)\n pet[\"age\"] = @prompt.ask(\"Age: \", convert: :integer) do |q|\n # error handling requiring input\n q.required true\n # error handling message\n q.messages[:required?] = \"Required pet age\"\n q.messages[:convert?] = \"Age has to be a number\"\n end\n end\n\n if @prompt.select(\"Edit Observations? \", @yes_or_no)\n pet[\"observations\"] = @prompt.ask(\"Observations: \") do |q|\n q.modify :capitalize\n end\n end\n \n @db.edit(\"pets\", pet)\n return pet\n end", "def update_owner_info\n puts \"\\nPlease enter your first name and then press the RETURN key\"\n first_name = gets.chomp\n owner = Owner.all.find_by(name: first_name)\n if owner.nil?\n puts \"\\nThat user doesn't yet exist. You'll now be transferred to the ADD USER menu.\"\n add_owner\n end\n\n prompt = TTY::Prompt.new\n choices = {\n \" 1 - Your address\" => 1,\n \" 2 - The type of food you leave on the porch (please enter 'wet' or 'dry')\" => 2,\n \" 3 - Your cat ownership status\" => 3,\n \" 4 - Your dog ownership status\" => 4,\n \" 5 - Your current neighborhood\" => 5,\n \" 6 - Return to the Main Menu\" => 6 }\n choice = prompt.select(\"\\nHowdy, #{first_name}! What information would you like to update?\\n\", choices, per_page: 6)\n\n case (choice.to_i)\n when 1 #address\n puts \"\\nWhat is your new address? format: 221-B Baker Street\"\n new_address = gets.chomp\n owner.address = new_address\n when 2 #food\n puts \"\\nWhat type of food are you leaving out on your porch? Please enter 'wet' or 'dry'.\"\n new_food = gets.chomp\n owner.food_provided = new_food\n when 3 #cat?\n cat_status_loop = true\n while cat_status_loop do\n puts \"\\nDo you currently own a cat? Please enter 'y' or 'n'.\"\n cat_status = gets.chomp\n if cat_status == \"y\"\n cat_status = true\n cat_status_loop = false\n elsif cat_status == \"n\"\n cat_status = false\n cat_status_loop = false\n else\n puts \"\\nPlease enter 'y' or 'n'.\"\n end\n end\n owner.cat_already = cat_status\n when 4 #dog?\n dog_status_loop = true\n while dog_status_loop do\n puts \"\\nDo you currently own a dog? Please enter 'y' or 'n'.\"\n dog_status = gets.chomp\n if dog_status == \"y\"\n dog_status = true\n dog_status_loop = false\n elsif dog_status == \"n\"\n dog_status = false\n dog_status_loop = false\n else\n puts \"\\nPlease enter 'y' or 'n'.\"\n end\n end\n owner.dog = dog_status\n when 5 #neighborhood\n puts \"\\nIn which neighborhood are you currently living?\"\n new_hood = gets.chomp\n puts \"\\nCity and state?\"\n city_state = gets.chomp\n hood = Neighborhood.find_by(name: new_hood, location: city_state)\n owner.neighborhood = hood\n if hood.nil?\n new_hood_instance = Neighborhood.create(name: new_hood, location: city_state)\n owner.neighborhood_id = new_hood_instance.id\n end\n when 6\n main_menu\n end\n owner.save\n end", "def edit_book_author(selected)\n\tb = Book.find(selected)\n\tprint \"To edit the book author please enter here: \"\n\tauthor = gets.chomp\n\tb.update_attributes(author: author)\nend", "def choose_option(input)\n \t# input = user_input\n case input\n when 1 then add_contact\n when 2 then modify_contact\n when 3 then display_all_contacts\n when 4 then display_contact\n when 5 then display_contact_attributes\n when 6 then delete_contact\n when 7 then exit \t\n else puts \"I'm sorry Dave, but you cant do that.\"\n end\n end", "def edit_ingredients\n @prompt.select(\"Do you want to add or delete ingredients?\") do |menu|\n menu.choice \"Add ingredient(s)\", -> {add_ingredients}\n menu.choice \"Delete ingredient(s)\", -> {delete_ingredients}\n menu.choice \"Back to menu\", -> {nav_menu}\n end\n end", "def edit_user(shelter)\n\n #Show the user the list of all animals\n list_all_clients(shelter)\n \n #Ask user for the name of the animal and validate that animal exists\n value = validate_input(shelter.clients) {prompt {\"Enter the ID of the client you want to edit: \"}}\n puts\n\n #Unless user wants to exit\n if value != 'q'\n\n #Store animal to a new variable\n client = shelter.clients[value]\n\n #Ask user for the value they want to edit\n puts \"Name: #{client.name}, ID: #{client.id}, Gender: #{client.gender}, Age: #{client.age}, Pets: #{client.pets.join(', ')}, Kids: #{client.kids}\"\n puts\n puts \"What to you want to edit?\"\n\n #Get user input and validate\n choice = validate_simple_input(%w(n i g a p k)) {prompt {\"(n)ame, (i)d, (g)ender, (a)ge, (p)ets, (k)ids: \"}}\n if choice != 'q'\n case choice\n\n #Edit name\n when 'n'\n shelter.clients[value].name = prompt {\"Enter new name: \"}\n \n when 'i'\n #Get user input and assign changed value to hash\n res = prompt {\"Enter new id: \"} #Get new name\n client.id = res #Store the name into new animal variable\n shelter.clients.store(res, client) #Insert new animal into animals hash\n shelter.clients.delete(value) #Remove animal with old name\n client = shelter.clients[res] #Assign the animal variable for all animal properties\n when 'g'\n #Get user input, validate, and assign changed value to hash\n res = validate_simple_input(%w(m f)) {prompt {\"Enter new gender (m , f): \"}}\n if res != 'q'\n shelter.clients[value].gender = res\n end\n when 'a'\n #Get user input and assign changed value to hash\n shelter.clients[value].age = prompt {\"Enter new age: \"}\n when 'p'\n #Get user input and assign changed value to hash\n shelter.clients[value].pets << prompt {\"Enter new pet: \"}\n when 'k'\n #Get user input, validate, and assign changed value to hash\n shelter.clients[value].kids = prompt {\"Enter new num of kids: \"}\n end\n end\n puts \"Edit completed\"\n # Output new animal\n puts \"Name: #{client.name}, Breed: #{client.id}, Gender: #{client.gender}, Age: #{client.age}, Pets: #{client.pets.join(', ')}, Kids: #{client.kids}\"\n else\n puts \"Aborted\"\n end\n\nend", "def edit_patron_name(selected)\n\tp = Patron.find(selected)\n\tprint \"\\nTo edit the patron name please enter here: \"\n\tname = gets.chomp\n\tp.update_attributes(name: name)\nend", "def edit_staff_member(selected)\n\tedit_staff_member_name(selected)\n\tedit_staff_member_email_address(selected)\nend", "def edit_staff_member_email_address(selected)\n\ts = StaffMember.find(selected)\n\tprint \"To edit the staff member email address please enter here: \"\n\temail_address = gets.chomp\n\ts.update_attributes(email_address: email_address)\nend", "def update(attribute, value)\n if attribute == \"first name\"\n @first_name = value\n #puts \"The first name was changed to: #{@first_name}\"\n elsif attribute == \"last name\"\n @last_name = value\n #puts \"The last name was changed to: #{@last_name}\"\n elsif attribute == \"email\"\n @email = value\n #puts \"The new email is: #{@email}\"\n elsif attribute == \"note\"\n @note = value\n #puts \"The new note is: #{@note}\"\n # puts \"No match was found. Please try again\"\n end\n end", "def edit_library_phone(selected)\n\tl = Library.find(selected)\n\tprint \"To edit the library phone number please enter here: \"\n\tphone = gets.chomp\n\tl.update_attributes(phone: phone)\t\nend", "def alter_account\n action = Dialog::how_can_we_help_you_man\n case action\n when \"new account\"\n show_man_balance\n choice = Dialog::which_customer\n if bank.find_customer_by_customer_id(choice).length > 0\n @customer_id = choice\n do_new_account\n else\n Dialog::wrong_entry\n end\n alter_account\n when \"balance\"\n show_man_balance\n alter_account\n when \"deposit\"\n do_deposit \n alter_account\n when \"withdraw\"\n do_withdraw\n alter_account\n when \"transfer\"\n transfer_funds\n alter_account\n when \"end\"\n return\n else\n Dialog::wrong_entry\n alter_account\n end\n end", "def print_update\n puts \"Attribute to Change\"\n puts \"[1] First Name\"\n puts \"[2] Last Name\"\n puts \"[3] E-mail\"\n puts \"[4] Note\"\n puts \"Enter a number\"\n end", "def update\n\nputs \"------------------------------------------------\nWho do you want to update: (Politician or Person)\"\nupdate_input= gets.chomp.downcase\n\n if update_input == \"politician\"\n Politician.update_politician\n elsif update_input == \"person\"\n Person.update_person\n else\n update\n end #end of if\nmain_menu\nend", "def modify_contact(attribute_to_modify,contact_to_modify,new_value)\n\t\tif attribute_to_modify == \"id\" \n\t\t\t@database_array[@database_array.index {|x| \n\t\t\t\tcontact_to_modify==x.id||contact_to_modify==x.first_name||contact_to_modify==x.last_name||\n\t\t\t\tcontact_to_modify==x.email}].id = new_value\n\t\telsif attribute_to_modify == \"first name\" \n\t\t \t@database_array[@database_array.index {|x| \n\t\t \t\tcontact_to_modify==x.id||contact_to_modify==x.first_name||contact_to_modify==x.last_name||\n\t\t \t\tcontact_to_modify==x.email}].first_name = new_value\n\t\telsif attribute_to_modify == \"last name\" \n\t\t\t@database_array[@database_array.index {|x| \n\t\t\t\tcontact_to_modify==x.id||contact_to_modify==x.first_name||contact_to_modify==x.last_name||\n\t\t\t\tcontact_to_modify==x.email}].last_name = new_value\t\t\t\t\n\t\telsif attribute_to_modify == \"email\" \n\t\t\t@database_array[@database_array.index {|x| \n\t\t\t\tcontact_to_modify==x.id||contact_to_modify==x.first_name||contact_to_modify==x.last_name||\n\t\t\t\tcontact_to_modify==x.email}].email = new_value\n\t\telse\n\t\t\tputs \"Wrong input. Please try again!\\n\" rescue nil\n\t\tend\n\t\n\tend", "def ask_name\n PROMPT.ask(\"Choose your name: \") do |q|\n q.required true\n q.modify :capitalize\n end\nend", "def modify_contact(selection)#, attribute, modification)\n puts \"wat\"\n end", "def ask_for_update(client)\r\n\tputs \"Select a field to update (or none).\"\r\n\tputs client.keys\r\n\tchoice = gets.chomp.to_sym\r\n\tif client.keys.include?(choice)\r\n\t\tif client[choice].is_a? Integer\r\n\t\t\tclient[choice] = gets.chomp.to_i\r\n\t\telse\r\n\t\t\tclient[choice] = gets.chomp\r\n\t\tend\r\n\tend\r\n\treturn client\r\nend", "def edit_contact\nputs \"Which Contact Would You Like to Edit?\"\n @contacts.delete(gets)\n puts \"What are the new details?\"\n @contacts << gets\n puts \"Your contact has been Edited\"\n #edited_contacts = @contacts.map {|contact| }\nend", "def update_email\n puts \"-------------------------------------------------------------------------------------------\"\n puts \"You have chose to update your email! Please follow the prompts! Again, we love prompts here :)\"\n puts \"\\nRemember you can go back to the menu or exit at any time by typing 'menu' or 'exit'\"\n puts \"-------------------------------------------------------------------------------------------\"\n \n puts \"\\n\\nPlease enter the current email you used to setup with your account.\"\n \n old_email = gets.strip.downcase\n return_to_menu(old_email)\n exit_anything(old_email)\n \n if User.exists?(email:old_email)\n email_to_change = old_email\n puts \"Great! Thank you #{User.find_by(email:old_email).first_name}, looks like we have you in our system.\".colorize(:green)\n else\n puts \"\\nWhoops, looks like we didn't recognize that email. Let's try again.\"\n update_email\n end\n \n puts \"\\nPlease enter the new email address you'd like us to update your account to\"\n new_email = gets.strip.downcase\n return_to_menu(new_email)\n exit_anything(new_email)\n if User.exists?(email:new_email)\n email_to_change = old_email\n puts \"\\nOOhhhh Noooo, looks like we may have an account that already has that email.\".colorize(:red)\n else\n user = User.find_by(email:old_email)\n user.email = new_email\n user.save\n puts\"\\n-------------------------------------------------------------------------------------------\".colorize(:green)\n puts \"Nice! Looks like we were able to update your account from #{old_email} to #{User.find_by(email:new_email).email}.\".colorize(:green)\n puts\"-------------------------------------------------------------------------------------------\".colorize(:green)\n end\n menu_exit\n end", "def input_students(current_students) # Ex 7 - Requests name, cohort, hobbies, deals with empty value, allows user to edit.\n# Ex 10 - Replace chomp with .gsub(\"\\n\", \"\")\n finished = false\n until finished\n puts \"add - adds student, edit - edits student, exit - exits program\"\n choice = gets.gsub(\"\\n\", \"\")\n if choice == \"add\"\n puts \"name?\"\n name = gets.gsub(\"\\n\", \"\")\n if name == \"\"\n name = \"no name entered\"\n end\n puts \"cohort?\"\n cohort = gets.gsub(\"\\n\", \"\")\n if cohort == \"\"\n cohort = \"no cohort entered\"\n end\n puts \"hobbies?\"\n hobbies = gets.gsub(\"\\n\", \"\")\n if hobbies == \"\"\n hobbies = \"no hobbies entered\"\n end\n current_students << {name: name.to_sym, cohort: cohort.to_sym, hobbies: hobbies.to_sym}\n elsif choice == \"edit\"\n puts \"enter name of student\"\n edit_student = gets.gsub(\"\\n\", \"\")\n current_students.each do |h|\n if h[:name] == edit_student\n puts \"what would you like to edit?\"\n puts \"name, cohort or hobbies\"\n edit_variable = gets.gsub(\"\\n\", \"\")\n if edit_variable == \"name\"\n puts \"enter what you wish the name to be\"\n name = gets.gsub(\"\\n\", \"\")\n h[:name] = name\n elsif edit_variable == \"cohort\"\n puts \"enter desired cohort\"\n cohort = gets.gsub(\"\\n\", \"\")\n h[:cohort] = cohort\n elsif edit_variable == \"hobbies\"\n puts \"enter desired hobby\"\n hobby = gets.gsub(\"\\n\", \"\")\n h[:hobbies] = hobby\n end\n end\n end\n elsif choice == \"exit\"\n finished = true\n end\n end\n current_students\nend", "def edit\n @title = \"Edit basic info\"\n @user=User.find(session[:user_id])\n if param_posted?(:user)\n attribute = params[:attribute]\n case attribute\n when \"email\"\n try_to_update @user, attribute\n when \"password\"\n if @user.correct_password?(params)\n try_to_update @user, attribute\n else\n @user.password_errors(params)\n end\n when \"team_id\"\n try_to_update @user, attribute\n end\n end \n #For security purpose, never fill in password fields automatically.\n @user.clear_password!\n end", "def edit_entry(db, id, edit_choice)\r\n\tcase edit_choice\r\n\twhen 1\r\n\t\tprint \"Enter the new title: \"\r\n\t\tnew_title = gets.chomp\r\n\t\tdb.execute(\"UPDATE games SET title=? WHERE id=?\", [new_title, id])\r\n\twhen 2\r\n\t\tprint \"Enter the new release year: \"\r\n\t\tnew_year = gets.to_i\r\n\t\tdb.execute(\"UPDATE games SET release_year=? WHERE id=?\", [new_year, id])\r\n\twhen 3\r\n\t\tstatus = db.execute(\"SELECT unopened FROM games WHERE id=?\", [id])\r\n\t\tif status[0][0] == 1\r\n\t\t\tdb.execute(\"UPDATE games SET unopened=0 WHERE id=?\", [id])\r\n\t\telsif status[0][0] == 0\r\n\t\t\tdb.execute(\"UPDATE games SET unopened=1 WHERE id=?\", [id])\r\n\t\tend\t\r\n\t\tputs (\"Status changed.\")\r\n\twhen 4\r\n\t\tprint \"Enter the new market value: \"\r\n\t\tnew_value = gets.to_f\r\n\t\tdb.execute(\"UPDATE games SET market_value=? WHERE id=?\", [market_value, id])\t\t\t\t\r\n\twhen 5\r\n\t\tprint \"Enter the new system: \"\r\n\t\tnew_system = gets.chomp.upcase\r\n\t\tdb.execute(\"INSERT OR IGNORE INTO systems (name) VALUES (?)\", new_system)\r\n\t\tsys_id = db.execute(\"SELECT id FROM systems WHERE name=?\", new_system)\r\n\t\tdb.execute(\"UPDATE games SET system_id=? WHERE id=?\", [sys_id, id])\r\n\tend\t\r\nend", "def update_option\n puts \"Would you like to Update a (V)oter or (P)olitician record?\".center(80)\n update_type = verified_answer(gets.chomp.downcase, [\"p\", \"v\"])\n if update_type == \"p\"\n update_politician\n list_politicians\n else\n update_voter\n list_voters\n end\n puts \"Record successfully updated.\".center(80).green\n puts\nend", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit; end", "def edit_book(selected)\n\tedit_book_title(selected)\n\tedit_book_author(selected)\n\tedit_book_isbn(selected)\nend", "def edit\n puts \"\\n******* edit *******\"\n end", "def edit_cat_info\n puts \"\\nPlease enter your cat's name and then press the RETURN key.\"\n kitty_name = gets.chomp\n kitty = Cat.all.find_by(name: kitty_name)\n if kitty.nil?\n puts \"\\nThat meowzer doesn't yet exist. You'll now be transferred to the ADD CAT menu.\"\n add_cat\n end\n\n prompt = TTY::Prompt.new\n choices = {\n \" 1 - #{kitty_name}'s current owner\" => 1,\n \" 2 - #{kitty_name}'s favorite food\" => 2,\n \" 3 - #{kitty_name}'s temperament with other cats\" => 3,\n \" 4 - Return to the Main Menu\" => 4 }\n choice = prompt.select(\"\\nHowdy, #{kitty_name}'s owner! What information would you like to update?\\n\", choices, per_page: 4)\n\n case (choice.to_i)\n\n when 1 #current owner?\n current_owner_loop = true\n \n puts \"\\nWhat is the first name of #{kitty_name}'s current owner?\"\n new_owner = gets.chomp\n new_owner_id = Owner.all.find_by(name: new_owner)\n if new_owner_id.nil?\n puts \"\\nThat user doesn't yet exist. You'll now be transferred to the ADD USER menu.\"\n add_owner\n else\n kitty.owner_id = new_owner_id.id\n puts \"\\nYay! #{new_owner} is now #{kitty_name}'s owner!\\n\"\n current_owner_loop = false\n end\n \n when 2 #food\n puts \"\\nWhich type of cat food does #{kitty_name} prefer, wet or dry?\"\n new_fav_food = gets.chomp\n kitty.favorite_food = new_fav_food\n when 3 #temperament\n new_temp_loop = true\n while new_temp_loop do\n puts \"\\nDoes #{kitty_name} get along with other cats? Please enter 'y' or 'n'.\"\n new_temperament = gets.chomp\n if new_temperament == \"y\"\n new_temperament = true\n new_temp_loop = false\n elsif new_temperament == \"n\"\n new_temperament = false\n new_temp_loop = false\n else\n puts \"\\nPlease enter 'y' or 'n'.\"\n end\n end\n kitty.temperament = new_temperament\n when 4\n main_menu\n end\n kitty.save\n end", "def edit_staff_member_name(selected)\n\ts = StaffMember.find(selected)\n\tprint \"\\nTo edit the staff member name please enter here: \"\n\tname = gets.chomp\n\ts.update_attributes(name: name)\nend", "def modify_contact\n\n end", "def update\n if @user.phone != params[:user][:phone]\n @user.phone = params[:user][:phone]\n @user.po_email = params[:user][:po_email]\n @user.save\n flash[:success] = \"Info changed successfully!\"\n send_text_greeting\n end\n if @user.po_email != params[:user][:po_email]\n @user.phone = params[:user][:phone]\n @user.po_email = params[:user][:po_email]\n @user.save\n flash[:success] = \"Info changed successfully!\"\n UserMailer.email_notify_po(@user).deliver_now\n end\n\n redirect_to edit_user_path(@user)\n end", "def edit\n puts \"******* edit *******\"\n end", "def update(target, value)\n case target\n when 'first_name'\n return @first_name = value\n when 'last_name'\n return @last_name = value\n when 'email'\n return @email = value\n when 'note'\n return @note = value\n else puts \"INPUT ERROR, INVALID TARGET\"\n end\n # if target==\"first_name\"\n # @first_name = value\n # return @first_name\n # elsif target == \"last_name\"\n # @last_name = value\n # return @last_name\n # elsif target == \"email\" <<<< MAKE SURE TO CHANGE M's back to N's if you ever decide to uncomment this.\n # @email = value\n # return @email\n # elsif target == \"note\"\n # @mote = value\n # return @mote\n # else puts \"INPUT ERROR, INVALID TARGET\"\n # end\n end", "def edit_review\n # client should be able to edit a review.\n puts \"Which review would you like to edit?\"\n pp Client.find_by(name: @@client_name).reviews\n puts \"Please enter the ID\"\n input = gets.strip\n selected_review = Review.find_by(id: input)\n puts \"What would you like for the new review to say?\"\n input = gets.strip\n selected_review.update(text_body: input)\n puts \"Your review has been updated, here's the new review:\"\n pp selected_review\n client_continue\n end", "def update_info_input(db)\n\tputs \"-\" * 50\n\tputs \"Update Information: \"\n\tprint \"Enter the horse record you would like to update: \"\n\thorse_selection = gets.split.map(&:capitalize).join(' ')\n\n\twhile true do\n\t\tputs \"-\" * 50\n\t\tputs \"Enter the category that you would like to update: \"\n\t\tputs \" 1. Name\"\n\t\tputs \" 2. Breed\"\n\t\tputs \" 3. Color\"\n\t\tputs \" 4. Age\"\n\t\tputs \" 5. Rideable\"\n\t\tprint \"Please select: \"\n\t\tupdate_selection = gets.to_i\n\n\t\tif update_selection == 1\n\t\t\tprint \"New name: \"\n\t\t\tnew_name = gets.chomp.split.map(&:capitalize).join(' ')\n\t\t\tupdate_info(db, horse_selection, \"name\", new_name)\n\t\t\tbreak\n\t\telsif update_selection == 2\n\t\t\tprint \"New breed: \"\n\t\t\tnew_breed = gets.chomp.split.map(&:capitalize).join(' ')\n\t\t\tupdate_info(db, horse_selection, \"breed\", new_breed)\n\t\t\tbreak\n\t\telsif update_selection == 3\n\t\t\tprint \"New horse_color: \"\n\t\t\tnew_color = gets.chomp.split.map(&:capitalize).join(' ')\n\t\t\tupdate_info(db, horse_selection, \"color\", new_color)\n\t\t\tbreak\n\t\telsif update_selection == 4\n\t\t\tprint \" New age: \"\n\t\t\tnew_age = gets.to_i\n\t\t\tupdate_info(db, horse_selection, \"age\", new_age)\n\t\t\tbreak\n\t\telsif update_selection == 5\n\t\t\tprint \"Rideable (y/n): \"\n\t\t\trideable = gets.chomp.downcase\n\t\t\tif rideable == \"y\"\n\t\t\t\tnew_rideable = \"true\"\n\t\t\telse\n\t\t\t\tnew_rideable = \"false\"\n\t\t\tend\n\t\t\tupdate_info(db, horse_selection, \"rideable\", new_rideable)\n\t\t\tbreak\n\t\telse\n\t\t\tputs \"Not a valid choice. Try again.\"\n\t\tend\n\tend\nend", "def displayUpdateInstr\n puts \"Type a letter to execute the corresponding command:\"\n puts \"a - update name\"\n puts \"b - update number\"\n puts \"c - update e-mail address\"\n puts \"d - update relation to you\"\n puts \"e - update city\"\nend", "def edit\n @time_zone = @note.receiver.time_zone\n note_receiver = @note.receiver\n @time_zone = note_receiver.time_zone\n @contacts = Contact.find_all_by_company_id(note_receiver.company_id,:order=>\"coalesce(last_name,'')||''||first_name||''||coalesce(middle_name,'') asc\").collect{|contact|[ contact.full_name, contact.id ]}\n matter_peoples = MatterPeople.find_matter_people(note_receiver.id)\n @matters = Matter.find_matter_peoples_matters(matter_peoples).collect{|matter|[matter.clipped_name, matter.id]}\n set_lawfirm_and_lawyers_val\n end", "def edit_recipe_options(r,i)\n edit_options = [\n {name: \"Add a new ingredient to the recipe\", value: 1},\n {name: \"select an ingredient to re-enter\", value: 2},\n {name: \"select an ingredient to Delete\", value: 3},\n {name: \"Delete Recipe\", value: 4},\n {name: \"back to recipe select\", value: 5}\n ] \n recipe_edit_options = $prompt.select(\"What would you like to do with this recipe\", edit_options)\n case recipe_edit_options\n when 1\n # clear and ascii heading format and cleanup window.\n clear\n ascii_heading(\"Edit Recipe\")\n add_ingredient(r,i)\n when 2\n clear\n ascii_heading(\"Edit Recipe\")\n edit_ingredient(r,i)\n when 3 \n clear\n ascii_heading(\"Edit Recipe\")\n delete_ingredient(r,i)\n when 4\n clear\n ascii_heading(\"Edit Recipe\")\n delete_recipe(r,i)\n system \"clear\"\n main_menu(3) # returns to edit recipe options selection screen.\n when 5\n clear\n main_menu(3)\n end\nend", "def display_info_by_attribute(contact)\n puts \"Enter attribute you want to display\"\n puts \"(1) First name\"\n puts \"(2) Last name\"\n puts \"(3) Email\"\n puts \"(4) Note\"\n att = gets.chomp.to_i\n print \"Is this the correct contact y/n?: \"\n user_choice = gets.chomp\n if user_choice.upcase() == 'Y'\n if att == 1\n puts \"#{contact.id}: #{contact.first_name}\"\n elsif att == 2\n puts \"#{contact.id}: #{contact.last_name}\"\n elsif att == 3\n puts \"#{contact.id}: #{contact.email}\"\n elsif att == 4\n puts \"#{contact.id}: #{contact.note}\"\n else\n puts \"I'm sorry but there is no such attribute\"\n end\n elsif user_choice.upcase() == 'N'\n main_menu\n end\n puts \"Press ENTER to continue....\"\n end", "def user_selection\n menu\n choice = gets.to_i\n case choice\n when 1\n create_contact\n when 2\n view_contacts\n when 3\n delete_contact\n when 4\n edit_contact\n when 5\n puts \"Adios Amigo!\"\n exit\n else\n puts \"Invalid Choice Try Again\"\n end\nend", "def edit_book_title(selected)\n\tb = Book.find(selected)\n\tprint \"\\nTo edit the book title please enter here: \"\n\ttitle = gets.chomp\n\tb.update_attributes(title: title)\nend", "def edit_player_info(db)\r\n puts \"\\nEnter the number of the player you would like to edit.\"\r\n view_players(db)\r\n id = gets.chomp\r\n puts \"\\nWould you like to update name or location?\"\r\n field = gets.chomp.downcase\r\n puts \"\\nWhat is the updated #{field}?\"\r\n correction = gets.chomp\r\n db.execute(\"UPDATE players SET #{field} = \\\"#{correction}\\\" WHERE id = #{id}\")\r\nend", "def edit(*)\n super.tap do\n __debug_sim('USER initiates modification of existing entries.')\n end\n end", "def edit_more\n\n\t\tprint \"\\n\\n\\t\\tDo you want to edit more(y/n)?: \" \n\t\toption=gets.chomp\n\n\t\tif option==\"y\" or option==\"Y\"\n\t\t#call edit method\n\t\t\t\tedit\n\t\telsif option==\"n\" or option==\"N\"\n\t\t#call dispaly_card method\n\t\t\t\tdisplay_card\n\t\telse\n\t\t\tputs \"\\n\\n\\t\\tInvalid Choice!!!...Try again\"\n\t\t\tedit_more\n\t\tend\n\tend", "def edit_library(selected)\n\tedit_library_name(selected)\n\tedit_library_address(selected)\n\tedit_library_phone(selected)\nend", "def manage_account_menu\n choice = @prompt.select(\"Please choose from the following options:\") do |menu|\n menu.choice 'Change my name'\n menu.choice 'Change my password'\n menu.choice 'Delete my account'.blue\n menu.choice \"Back to Main Menu\"\n end\n\n if choice == \"Change my name\"\n change_name\n elsif choice == \"Change my password\"\n change_password\n elsif choice == \"Delete my account\".blue\n delete_account\n elsif choice == \"Back to Main Menu\"\n start_menu\n end\nend", "def edit_content(collection_id, question, question_key)\r\n new_value = @prompt.ask(\"What is your new value for #{question_key}?\") do |q|\r\n q.required true\r\n q.modify :capitalize\r\n end\r\n question[question_key] = new_value\r\n edit_single_question(collection_id, question)\r\n end", "def update_student\n name = ask_for(\"name of the student you want to change\")\n selected_student = find_student(name)\n print_names(selected_student)\n confirmation = ask_for(\" Y/N to modify\")\n if confirmation.downcase == \"y\"\n selected_student.first[:name] = ask_for(\"New name\")\n selected_student.first[:cohort] = ask_for(\"New cohort\")\n selected_student.first[:hobbies] = ask_for(\"New hobbies\")\n @students.map! {|student| (student[:name] == selected_student.first[:name]) ? selected_student.first : student }\n end\nend", "def edit_single_question(collection_id, question)\r\n clear\r\n begin\r\n puts \"#{question['Id']}. #{question['Question']}\\n\"\r\n puts \"A: #{question['A']}\\n\"\r\n puts \"B: #{question['B']}\\n\"\r\n puts \"C: #{question['C']}\\n\"\r\n puts \"D: #{question['D']}\\n\"\r\n puts \"Correct option: #{question['Right_answer']}\\n\"\r\n puts \"-------------------------\\n\".colorize(:light_cyan)\r\n rescue JSON::ParserError, NoMethodError, NoMemoryError, StandardError\r\n puts \"It seems the custom content is empty. Please move to custom menu to add a new custom collection.\\n\\n\\n\"\r\n end\r\n # Passing the inheritance arguments plus corresponding keys to edit the content\r\n options = [\r\n { name: 'Question Content', value: -> { edit_content(collection_id, question, 'Question') } },\r\n { name: 'Option A', value: -> { edit_content(collection_id, question, 'A') } },\r\n { name: 'Option B', value: -> { edit_content(collection_id, question, 'B') } },\r\n { name: 'Option C', value: -> { edit_content(collection_id, question, 'C') } },\r\n { name: 'Option D', value: -> { edit_content(collection_id, question, 'D') } },\r\n { name: 'Correct option', value: -> { edit_correct_option(collection_id, question, 'Right_answer') } },\r\n { name: 'Comfirm the change', value: lambda {\r\n @prompt.yes?(\"\\nDo you want to comfirm the change or continue editing?\") ? comfirm_edit(collection_id, question['Id'], question) : return\r\n } },\r\n { name: 'Ignore the changes and go back to upper menu', value: lambda {\r\n @prompt.yes?(\"\\nDo you really want to go back to upper menu without saving?\") ? edit_quiz(collection_id) : return\r\n } }\r\n ]\r\n option = @prompt.select('Please select from the following options.', options,\r\n help: \"(Select with pressing ↑/↓ arrow keys, and then pressing Enter)\\n\\n\\n\", show_help: :always, per_page: 8)\r\n end", "def change_franchise_owner\n company = get_company\n no_franchises(company)\n display_franchises(company)\n puts \"Please enter the id number for the franchise whose ownership has changed.\"\n id = gets.strip\n \n if valid_franchise_choice(company, id) \n puts \"Please enter the name of the new owner.\"\n new_owner = gets.strip\n if !Owner.exists?(name: new_owner)\n Owner.create(name: new_owner)\n end\n\n franchise = Franchise.where(id: id).update(owner_id: Owner.find_by(name: new_owner).id)\n franchise.select { |franchise| puts \"Franchise #{franchise.id} has new owner #{franchise.owner.name}.\" }\n else\n puts \"Please select an id from the list above next time or find an owner to purchase a franchise!\" \n menu\n end\n menu\n end", "def case_account_details(selection)\n case selection\n when 'Change Password'\n password = @prompt.ask('Please enter your new password >')\n @user.change_password(password)\n when 'Delete Account'\n @user.delete_account\n when 'Back'\n menu_router\n end\n end", "def user_choice_of_field(object)\n fields = object.database_field_names\n \n create_menu = Menu.new(\"Which field do you want to update?\")\n fields.each_with_index do |field, x|\n create_menu.add_menu_item({key_user_returns: x + 1, user_message: field, do_if_chosen: \n [field]})\n end\n run_menu(create_menu)[0]\n end", "def edit_field(field)\n result = true\n while(result)\n field_header(field)\n\n choose do |menu|\n menu.prompt = \"Please select: \"\n menu.index = :number\n menu.index_suffix = ') '\n menu.choice(:quit, 'Quit') {result = false}\n case AppConfig.data_type[field]\n when :BOOLEAN\n menu.choice(:true, 'True') {AppConfig.config[field] = true}\n menu.choice(:false, 'False') {AppConfig.config[field] = false}\n else\n menu.choice(:default, 'Default') {AppConfig.config[field] = AppConfig.initial[field]}\n if AppConfig.data_type[field].to_s =~ /^ARRAY/\n menu.choice(:add, 'Add') {array_add(field)}\n menu.choice(:delete, 'Delete') {array_delete(field)}\n elsif AppConfig.data_type[field].to_s =~ /^HASH/\n menu.choice(:add, 'Add') {hash_add(field)}\n menu.choice(:delete, 'Delete') {hash_delete(field)}\n else\n menu.choice(:edit, 'Edit') {object_edit(field)}\n end\n end\n end\n end\n result\n end", "def update_primary_contact(matter, params)\n new_contact_id = (params[:matter][:contact_id] ||matter.contact_id).to_i\n # Check if the primary matter contact was changed during matter edit.\n if new_contact_id != matter.contact_id.to_i\n old_primary_matter_contact = matter.primary_matter_contact\n new_primary_matter_contact = matter.matter_peoples.find(:first, :conditions => [\"people_type = 'client_contact' AND contact_id = ?\", new_contact_id])\n # To avoid invalid data - Milind/Pratik\n # Used obj.save to avoid the callback relatd to phone and email\n # because here we are only updating the people_type and member_role_id\n # Update their respective roles.\n new_primary_matter_contact.people_type = \"matter_client\"\n new_primary_matter_contact.can_access_matter =params[:matter][:client_access] unless params[:matter][:client_access].nil?\n unless old_primary_matter_contact.blank?\n new_primary_matter_contact.matter_team_role_id = old_primary_matter_contact.matter_team_role_id.nil? ? @matter.company.client_roles.find_by_lvalue('Matter Client').id : old_primary_matter_contact.matter_team_role_id\n else\n new_primary_matter_contact.matter_team_role_id = @matter.company.client_roles.find_by_lvalue('Matter Client').id\n end\n new_primary_matter_contact.save(false)\n old_primary_matter_contact.people_type = \"client_contact\"\n old_primary_matter_contact.matter_team_role_id = nil\n old_primary_matter_contact.save(false)\n else\n unless matter.primary_matter_contact.blank?\n old_primary_matter_contact = matter.primary_matter_contact\n old_primary_matter_contact.can_access_matter = params[:matter][:client_access] unless params[:matter][:client_access].nil?\n old_primary_matter_contact.save(false)\n end\n end\n end", "def client_program\n puts \"Hello and welcome to my store. What is your name?\"\n $user_information[:client_name] = gets.chomp\n # p $user_information\n\n puts \"Nice to meet you, #{$user_information[:client_name]}\"\n\n puts \"And how old are you?\"\n $user_information[:age] = gets.to_i\n # p $user_information\n\n puts \"How many children do you have?\"\n $user_information[:num_children] = gets.to_i\n # p $user_information\n\n puts \"What kind of theme do you like for decor?\"\n $user_information[:decor_theme] = gets.chomp\n # p $user_information\n\n puts \"Thank you for answering these questions, below you can find a list of the information you provided us. If you would like to change any of this, enter which you would like to change. If not, type none!\"\n p $user_information\n update = gets.chomp\n\n if update.include?(\"client_name\") == true\n puts \"Re-enter your name.\"\n $user_information[:client_name] = gets.chomp\n p $user_information\n\n elsif update.include?(\"decor_theme\") == true\n puts \"Re-enter your theme.\"\n $user_information[:decor_theme] = gets.chomp\n p $user_information\n\n elsif update.include?(\"age\") == true\n puts \"Re-enter your age.\"\n $user_information[:age] = gets.chomp \n p $user_information \n\n elsif update.include?(\"num_children\") == true\n puts \"Re-enter your theme.\"\n $user_information[:num_children] = gets.chomp\n p $user_information\n\n else \n puts \"Thank you for using this program.\"\n p $user_information\n \n end\n\nend", "def edit_book_isbn(selected)\n\tb = Book.find(selected)\n\tprint \"To edit the book isbn please enter here: \"\n\tisbn = gets.chomp\n\tb.update_attributes(isbn: isbn)\t\nend", "def display_one_contact\n\t\tputs \"Enter Contact ID:\"\n \t\tinput = gets.chomp.to_i\t\n \t\t@rolodex.contacts.each do |contact|\n \t\t\tif contact.id == input\n \t\t\t\tputs \"Contact ID: #{contact.id}\"\n \t\tputs \"Name: #{contact.first_name} #{contact.last_name}\"\n \t\tputs \"Email: #{contact.email}\"\n \t\tputs \"Notes: #{contact.note}\"\n \t\telse\n \t\t\tputs \"Contact not found in system, please try again.\"\n \t\tend\n \tend\n \tend", "def update\n\n puts \"\n Who do you want to update: (Politician or Person)\"\n update_input= gets.chomp.downcase\n\n if update_input == \"politician\"\n Politician.update_politician\n elsif update_input == \"person\"\n Person.update_person\n else\n update\n\n end #end of if\nend", "def name_confirmation\n puts \"Been here before? (y/n)\"\n user_response = gets.chomp.downcase\n system \"clear\" \n if user_response == \"y\"\n find_user\n elsif user_response == \"n\"\n create_user\n else\n name_confirmation\n end\n end", "def user_settings\n\n prompt.select (\"Choose an option\") do |menu|\n menu.choice \"Delete account\", -> {\n answer = prompt.yes? (\"Are you sure?\")\n if answer \n User.find(user_id).delete_account \n user_id = nil \n welcome\n else\n puts \"Glad you're staying\" \n user_settings\n end\n }\n\n menu.choice \"Change Password\\n\", -> {\n\n password = prompt.mask(\"Enter your current password:\")\n while User.find(user_id).password != password\n puts \"Invalid password - please try again.\"\n password = prompt.mask(\"Enter your current password:\")\n end\n\n password = prompt.mask(\"Choose a new password over 5 characters.\")\n while password.length < 5\n puts \"Password too short - must be over 5 characters long\"\n password = prompt.mask(\"Choose a new password over 5 characters.\")\n end\n\n User.find(user_id).change_password(password)\n user_settings\n }\n\n menu.choice \"Return to threads\", -> {show_threads}\n end \n\n end", "def edit\n \n end", "def run_command(command)\n rerun = true\n while rerun == true\n case command.downcase\n\n when 'new'\n new_contact\n return true\n\n when 'list'\n list_contact\n return true\n\n when 'show'\n show_contact\n return true\n\n when 'find'\n puts \"by: first name, last name, or email\"\n choice = gets.chomp\n puts \"Enter #{choice}: \"\n input = gets.chomp\n case choice\n when 'first name'\n choice = :firstname\n when 'last name'\n choice = :lastname\n when 'email'\n choice = :email\n else\n puts \"Do not compute!\"\n end\n find_contact(choice, input)\n return true\n\n when 'update'\n puts \"Enter contact ID to update: \"\n id = gets.chomp.to_i\n\n if id_error_rescue(id) == false\n puts Contact.find(id).inspect\n end\n \n t = Contact.find(id)\n puts \"You will edit the following contact:\"\n puts t.firstname + \" \" + t.lastname\n \n puts \"What would you like to update (first name, last name, email): \"\n choice = gets.chomp\n\n puts \"Enter new #{choice}: \"\n input = gets.chomp\n case choice\n when 'first name'\n Contact.find(id).update(firstname: input)\n when 'last name'\n Contact.find(id).update(lastname: input)\n when 'email'\n Contact.find(id).update(email: input)\n else\n puts \"do not compute!\"\n end\n\n return true\n\n when 'save'\n save_contact\n return true\n\n when 'quit'\n return false\n\n else \n puts \"unknown command\"\n return true\n end\n end\n end" ]
[ "0.7670978", "0.767083", "0.7332969", "0.7313281", "0.7264931", "0.7229206", "0.7188044", "0.7134588", "0.6988199", "0.6899287", "0.6848723", "0.6702242", "0.66444314", "0.6616212", "0.6594362", "0.6581", "0.65768516", "0.651908", "0.6315838", "0.6197697", "0.61948967", "0.61785007", "0.61561316", "0.61322486", "0.61310065", "0.6114242", "0.6103916", "0.6086656", "0.6075686", "0.605385", "0.60267526", "0.59947425", "0.59919316", "0.59760445", "0.5973817", "0.5968008", "0.5962652", "0.59227073", "0.591357", "0.5911522", "0.5894705", "0.589449", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.58884764", "0.5881494", "0.58727014", "0.58695555", "0.5867253", "0.58614725", "0.58547974", "0.58518064", "0.58118916", "0.57633793", "0.5755749", "0.5746386", "0.5741656", "0.57352555", "0.5731441", "0.57231", "0.5719731", "0.57167184", "0.57121515", "0.57016057", "0.5696332", "0.5678893", "0.56741655", "0.5671485", "0.5666519", "0.5666004", "0.565558", "0.5653732", "0.5649227", "0.56389624", "0.5634588", "0.56232715", "0.56205827", "0.56138074", "0.56111133", "0.5610968", "0.5605608", "0.5602906" ]
0.7869783
0
As a user, if 'display attribute' is selected, I am prompted to enter an attribute ('firstname', 'lastname', 'email', or 'notes') so that I can see all of the contacts according to that attribute.
def display_attribute puts "Please enter an attribute: " attribute = gets.chomp @rolodex.display_attribute(attribute) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def display_info_by_attribute(contact)\n puts \"Enter attribute you want to display\"\n puts \"(1) First name\"\n puts \"(2) Last name\"\n puts \"(3) Email\"\n puts \"(4) Note\"\n att = gets.chomp.to_i\n print \"Is this the correct contact y/n?: \"\n user_choice = gets.chomp\n if user_choice.upcase() == 'Y'\n if att == 1\n puts \"#{contact.id}: #{contact.first_name}\"\n elsif att == 2\n puts \"#{contact.id}: #{contact.last_name}\"\n elsif att == 3\n puts \"#{contact.id}: #{contact.email}\"\n elsif att == 4\n puts \"#{contact.id}: #{contact.note}\"\n else\n puts \"I'm sorry but there is no such attribute\"\n end\n elsif user_choice.upcase() == 'N'\n main_menu\n end\n puts \"Press ENTER to continue....\"\n end", "def display_by_attribute\n\t\tputs \"Please enter desired attribute to be displayed: \"\n\t\tputs \"[1] First name\"\n\t\tputs \"[2] Last name\"\n\t\tputs \"[3] Email\"\n\t\tputs \"[4] Note\"\n\t\tputs \"[5] ID\" \n\t\tattribute = gets.chomp.to_i\n\t\tcase attribute\n\t\twhen 1\n\t\t\t@rolodex.contacts.each do |contact|\n\t\t\t\tputs \"#{contact.first_name}\"\n\t\t\tend\n\t\twhen 2\n\t\t\t@rolodex.contacts.each do |contact|\n\t\t\t\tputs \"#{contact.last_name}\"\n\t\t\tend\n\t\twhen 3\n\t\t\t@rolodex.contacts.each do |contact|\n\t\t\t\tputs \"#{contact.email}\"\n\t\t\tend\n\t\twhen 4\n\t\t\t@rolodex.contacts.each do |contact|\n\t\t\t\tputs \"#{contact.note}\"\n\t\t\tend\n\t\twhen 5\n\t\t\t@rolodex.contacts.each do |contact|\n\t\t\t\tputs \"#{contact.id}\"\n\t\t\tend\n\t\tend\n\tend", "def display_by_attribute\n\t\tputs \"\\nEnter attribute to display (ID, first name, last name, email):\"\n\t\tattribute = gets.chomp.downcase\n\t\tif attribute == \"id\"\n\t\t\t@database_array.each {|x| puts x.id}\n\t\telsif attribute == \"first name\"\n\t\t\t@database_array.each {|x| puts x.first_name}\n\t\telsif attribute == \"last name\"\n\t\t\t@database_array.each {|x| puts x.last_name}\n\t\telsif attribute == \"email\"\n\t\t\t@database_array.each {|x| puts x.email}\n\t\telse\n\t\t\tputs \"Please try again!\" rescue nil\n\t\tend\t\t\n\tend", "def search_by_attribute\n puts \"\\nPlease select a contact attribute to search by.\"\n print_search_by_attribute_options\n user_attribute = gets.chomp.downcase\n #Attepted to loop back through function after contacts displayed\n # if user_attribute == 5\n # display_all_contacts\n # search_by_attribute\n if user_attribute == \"cancel\"\n puts \"\\e[H\\e[2J\"\n return\n end\n\n puts \"Please enter the contact's info: \"\n user_value = gets.chomp\n contact = Contact.find_by(user_attribute => user_value)\n # Attempting safeguard\n # if contact == \"invalid\"\n # return \"INVALID OPTION\"\n # end\n puts \"\\e[H\\e[2J\"\n puts \"\\n------------------------------\"\n puts \"Name: #{contact.first_name} #{contact.last_name}\\nEmail: #{contact.email}\\nNote: #{contact.note}\"\n puts \"------------------------------\\n\\n\"\n return contact\n end", "def search_by_attribute\n attribute_list\n puts \" Choose number for Search attribute\"\n while user_selected =gets.to_i\n\n case user_selected\n when 1 then puts \"Enter First Name\"\n search_result = Contact.find_by(:first_name, value = gets.chomp.to_s)\n unless search_result\n puts\"========================\"\n puts \"first name not found\"\n puts\"=======================\"\n return\n end\n puts\n search_result.display_contact\n puts\n break\n\n when 2 then puts \"Enter Last Name\"\n search_result = Contact.find_by(:last_name, value = gets.chomp.to_s)\n puts\n search_result.display_contact\n unless search_result\n puts\"========================\"\n puts \"last name not found\"\n puts\"=======================\"\n return\n end\n puts\n break\n\n when 3 then puts \"Enter Email Address\"\n search_result = Contact.find_by(:email, value = gets.chomp)\n unless search_result\n puts\"========================\"\n puts \"email not found\"\n puts\"=======================\"\n return\n end\n puts\n search_result.display_contact\n puts\n break\n\n when 4 then puts \"Enter Note\"\n search_result = Contact.find_by(:note, value = gets.chomp)\n unless search_result\n puts\"========================\"\n puts \"note not found\"\n puts\"=======================\"\n return\n end\n puts\n search_result.display_contact\n puts\n break\n\n else\n puts \"---------------------------------------\"\n puts \"please enter a number between 1 and 4\"\n puts \"=======================================\"\n attribute_list\n\n end\n end\n end", "def search_by_attribute #search by first name \n p \"enter first name\"\n enter_name = gets.chomp\n contact = Contact.find_by_first_name(enter_name)\n puts \"name: #{contact.full_name}\"\n puts \"----------------------------------\"\n puts \"email: #{contact.email}\"\n puts \"----------------------------------\"\n puts \"notes: #{contact.notes}\"\n puts \"----------------------------------\"\n puts \"unique ID: #{contact.id_reader}\"\n \n return \n end", "def display_contacts\n\n # HINT: Make use of this method in the display_all_contacts and search_by_attribute methods to keep your code DRY\n end", "def display_contacts\n\n # HINT: Make use of this method in the display_all_contacts and search_by_attribute methods to keep your code DRY\n end", "def display_info_by_attribute(type, attribute_val)\n if type == 1\n result = Contact.where(first_name: attribute_val)\n if result.empty?\n {status: false, error: \"\\nContact with first name #{attribute_val} not found.\"}\n else\n # see private method section for load_people\n {status: true, contact: load_people(result)}\n end\n\n elsif type == 2\n result = Contact.where(last_name: attribute_val)\n if result.empty?\n {status: false, error: \"\\nContact with last name #{attribute_val} not found.\"}\n else\n {status: true, contact: load_people(result)}\n end\n\n elsif type == 3\n result = Contact.where(email: attribute_val)\n if result.empty?\n {status: false, error: \"\\nContact with email #{attribute_val} not found.\"}\n else\n {status: true, contact: load_people(result)}\n end\n\n elsif type == 4\n result = Contact.where(notes: attribute_val)\n if result.empty?\n {status: false, error: \"\\nContact with notes: #{attribute_val} not found.\"}\n else\n {status: true, contact: load_people(result)}\n end\n\n end\n end", "def display_contacts\n Contact.each do |contacts|\n print \"First name: #{contacts.first_name}, Last name: #{contacts.last_name}, Email address: #{contacts.email}, Notes: #{contacts.note}\"\n end\n\n # HINT: Make use of this method in the display_all_contacts and search_by_attribute methods to keep your code DRY\n end", "def display_contacts\n # Fill this in\n # HINT: Make use of this method in the display_all_contacts and search_by_attribute methods\n Contact.all.each do |contacts|\n puts \":#{contacts.full_name}, #{contacts.email}, #{contacts.id}, #{contacts.note}\"\n end\n end", "def modify_existing_contact\n display_all_contacts\n puts \"What ID would you like to modify?\"\n id = gets.to_i\n modify_existing_contact = Contact.find(id)\n\n attribute_list\n\n case user_selected\n when 1 then puts \"Edit First Name\"\n edit = modify_existing_contact.update(:first_name, value =gets.chomp)\n puts\n modify_existing_contact.display_contact\n\n\n\n when 2 then puts \"Edit Last Name\"\n edit = modify_existing_contact.update(:last_name, value =gets.chomp)\n puts\n modify_existing_contact.display_contact\n\n\n\n when 3 then puts \"Edit Email\"\n edit = modify_existing_contact.update(:email, value =gets.chomp)\n puts\n modify_existing_contact.display_contact\n\n\n\n when 4 then puts \"Edit Note\"\n edit = modify_existing_contact.update(:note, value =gets.chomp)\n puts\n modify_existing_contact.display_contact\n\nelse\n puts \"Please select an attribute from 1 to 4\"\n attribute_list\n end\n end", "def display_attribute_across\n unless @rolodex.is_empty?\n attr_code = attr_menu\n if attr_code\n @rolodex.display_info_by_attribute(attr_code)\n end\n end\n puts \"Number of contacts: #{@rolodex.length}\"\n end", "def show ( contact )\n puts \"#{contact[:name]}\"\n puts \"phone: #{contact[:phone]}\"\n puts \"email: #{contact[:email]}\"\n puts\nend", "def display_contacts(contacts)\n\n contacts.each do |display|\n puts \"First name: #{display.first_name} Last name: #{display.last_name} Email: #{display.email} Note: #{display.note}\"\n end\n end", "def modify_existing_contact\n display_all_contacts\n puts \"Choose the ID you would like to modify\"\n id = gets.chomp.to_i\n modify_contact = Contact.find(id)\n unless modify_contact\n puts \"ID not found\"\n return\n end\n\n attribute_list\n\n while user_selected =gets.to_i\n\n case user_selected\n when 1 then puts \"Enter New First Name\"\n new = modify_contact.update(:first_name, value = gets.chomp)\n puts\n modify_contact.display_contact\n puts\n break\n\n when 2 then puts \"Enter New Last Name\"\n new = modify_contact.update(:last_name, value = gets.chomp)\n puts\n modify_contact.display_contact\n puts\n break\n\n when 3 then puts \"Enter New Email Address\"\n new = modify_contact.update(:email, value = gets.chomp)\n puts\n modify_contact.display_contact\n puts\n break\n\n when 4 then puts \"Enter New Note\"\n new =modify_contact.update(:note, value = gets.chomp)\n puts\n modify_contact.display_contact\n puts\n break\n\n else\n puts \"=======================================\"\n puts \"please enter a number between 1 and 4\"\n puts \"=======================================\"\n attribute_list\n end\n end\n end", "def display_attribute\n\t\tprint_display_attribute\n\t\tshow_attribute = gets.chomp.to_i\n\n\t\tif show_attribute == 5 \t\n \t\tmain_menu \n \telse \n \t\tprint_attribute(show_attribute)\n \tend\n\tend", "def modify_contact\n\t\tprint_modify_contact\n \tmodify_attribute = gets.chomp.to_i\n\n \tif modify_attribute == 5 \t\n \t\tmain_menu \n \telse \n\t \tputs \"Are you sure you want to change this attribute [Y/N]\"\n\t \tconfirm = gets.chomp\n\t \tif confirm.downcase == \"y\"\n\t \t\tmodify_contact_option(modify_attribute)\n\t \telse\n\t \t\tmodify_contact\n\t \tend\n\t end\n\tend", "def modify_contact\n\t\tputs \"Please enter the id of the contact to modify: \"\n\t\tid = gets.chomp.to_i\n puts \"Please confirm 'yes' or 'no' to modify this contact: \"\n puts @rolodex.display_contact(id)\n answer = gets.chomp.downcase\n if answer == 'yes'\n puts \"Please enter the number of the attribute you would like to edit: \\n\n 1. First Name \\n\n 2. Last Namme \\n\n 3. Email \\n\n 4. Note\"\n option = gets.chomp.to_i\n puts \"Please provide the edit:\"\n new_attribute = gets.chomp\n @rolodex.modify_contact(id, option, new_attribute)\n puts \"Edit complete: \"\n puts @rolodex.display_contact(id)\n elsif answer == 'no'\n return\n else\n puts \"That is not a valid answer, please try again.\"\n end\n\tend", "def display_name\n return attributes['display_name'] unless attributes['display_name'].blank?\n return \"#{attributes['first_name']} #{attributes['last_name']}\" unless attributes['first_name'].blank? && attributes['last_name'].blank?\n return '(unknown)'\n end", "def atv2_details(firstname, lastname, email)\n firstname_field_v2.send_keys firstname\n lastname_field_v2.send_keys lastname\n email_field_v2.send_keys email\n dropdown_select\n end", "def formal_firstname\n read_attribute :firstname\n end", "def display_resource(person)\n if person.first_name.blank? || person.last_name.blank?\n \"#{person.email}\"\n else\n \"#{person.first_name} #{person.last_name}\".strip\n end\n end", "def display_one_contact\n contact = retrieve_contact_by_email\n end", "def display_one_contact\n\t\tputs \"Enter Contact ID:\"\n \t\tinput = gets.chomp.to_i\t\n \t\t@rolodex.contacts.each do |contact|\n \t\t\tif contact.id == input\n \t\t\t\tputs \"Contact ID: #{contact.id}\"\n \t\tputs \"Name: #{contact.first_name} #{contact.last_name}\"\n \t\tputs \"Email: #{contact.email}\"\n \t\tputs \"Notes: #{contact.note}\"\n \t\telse\n \t\t\tputs \"Contact not found in system, please try again.\"\n \t\tend\n \tend\n \tend", "def display_contact\r\n\t\tputs \"ID: #{@id}\"\r\n\t\tputs \"First Name: #{@firstname}\" \r\n\t\tputs \"Last Name: #{@lastname}\"\r\n\t\tputs \"Email Address: #{@email}\"\r\n\t\tputs \"Notes on User: #{@notes}\" \r\n\tend", "def show_person( title, person )\n\n #puts \"#{title} #{person}\"\n puts \"#{title}\"\n show_field( 'ix', person.index, ' ' )\n show_field( 'cid', person.computing_id, ' ' )\n show_field( 'first_name', person.first_name, ' ' )\n show_field( 'last_name', person.last_name, ' ' )\n show_field( 'department', person.department, ' ' )\n show_field( 'institution', person.institution, ' ' )\n end", "def display_one_contact(contact)\n if contact\n puts \"Name: #{contact.name}\"\n puts \"E-mail: #{contact.email}\"\n puts \"Phone Number: #{contact.phone_number}\"\n else\n puts \"Not found!\"\n end\n end", "def attribute(show_attribute)\n case show_attribute\n when 'deadline'\n return self.deadline\n when 'renter_id'\n return self.renter.surname if self.renter_id > 0\n when 'property_id'\n return self.property.name if self.property_id > 0\n when 'object'\n return self.object.downcase\n when 'price'\n return self.price\n when 'category'\n return self.category\n when 'groupp'\n return self.groupp\n when 'paid'\n return self.paid\n else \n return ''\n end\n end", "def search_attributes\n\t\t['dn', self.attr_firstname, self.attr_lastname, self.attr_mail, self.attr_member]\n\tend", "def edit_staff_member_email_address(selected)\n\ts = StaffMember.find(selected)\n\tprint \"To edit the staff member email address please enter here: \"\n\temail_address = gets.chomp\n\ts.update_attributes(email_address: email_address)\nend", "def display_particular_contact(option, keyword)\n @contacts.each do |contact|\n if option == 1\n contact.contact_display if keyword == contact.id\n elsif option == 2\n contact.contact_display if keyword == contact.firstname\n elsif option == 3\n contact.contact_display if keyword == contact.lastname\n elsif option == 4\n contact.contact_display if keyword == contact.email\n elsif option == 5\n contact.contact_display if keyword == contact.notes\n end\n end\n end", "def edit_patron_email_address(selected)\n\tp = Patron.find(selected)\n\tprint \"To edit the patron email address please enter here: \"\n\temail_address = gets.chomp\n\tp.update_attributes(email_address: email_address)\nend", "def contact_info\n puts 'Enter first name: '\n fname = gets.strip.capitalize\n puts 'Enter last name: '\n lname = gets.strip.capitalize\n puts 'Enter email: '\n email = gets.strip\n puts 'Enter city: '\n city = gets.strip.capitalize\n puts 'Enter state: '\n state = gets.strip.upcase\n\n h = Hash.new { |h, k| h[k] = '' }\n #figure out how to catch blank entry?\n h[:firstname] << fname\n\n h[:lastname] << lname\n\n h[:email] << email\n\n h[:city] << city\n\n h[:state] << state\n\n @contacts << h\nend", "def update(attribute, value)\n if attribute == \"first name\"\n @first_name = value\n #puts \"The first name was changed to: #{@first_name}\"\n elsif attribute == \"last name\"\n @last_name = value\n #puts \"The last name was changed to: #{@last_name}\"\n elsif attribute == \"email\"\n @email = value\n #puts \"The new email is: #{@email}\"\n elsif attribute == \"note\"\n @note = value\n #puts \"The new note is: #{@note}\"\n # puts \"No match was found. Please try again\"\n end\n end", "def edit_contact(first_name,last_name,email,note)\n @selected_contact.first_name = first_name\n @selected_contact.last_name = last_name\n @selected_contact.email = email\n @selected_contact.note = note\n end", "def modify_existing_contact \n\t\t contact = display_one_contact\t\n\t\t print \"Change First Name: \"\n\t\t first_name = gets.chomp\n\t\t print \"Change Last Name: \"\n\t\t last_name = gets.chomp\n\t\t print \"Change Email Address: \"\n\t\t email = gets.chomp\n\t\t print \"Change your Note: \"\n\t\t note = gets.chomp\n\t\t contact = Contact.new(first_name, last_name, email, note)\n\tend", "def display\n puts \"Personal Details\"\n puts \" Name : #{self.name}\"\n puts \" Date of Birth : #{self.dob}\"\n puts \" Marital Status : #{self.marital_status}\"\n puts \" Mobile Number : #{self.mobile_number}\"\n puts \" Email : #{self.email}\"\n end", "def display_particular_contact(contact_display)\n\t\t\t@database_array.each do |x|\n\t\t\t\tif contact_display == x.id || contact_display == x.first_name ||\n\t\t\t\t\tcontact_display == x.last_name || contact_display == x.email\n\t\t\t\t\t\tx.display_contacts\n\t\t\t\telse\n\t\t\t\t\treturn nil\n\t\t\t\tend\n\t\t\tend\n\tend", "def get_contact_name\n puts \"Please enter the contact first name:\"\n gets.chomp\n end", "def display_all_contacts\n all_contact = Contact.all\n all_contact.each do |list|\n puts:\"===============================\"\n puts \"first name: #{list.first_name}\"\n puts \"last name: #{list.last_name}\"\n puts \"email: #{list.email}\"\n puts \"note: #{list.note}\"\n puts \"id: #{list.id}\"\n puts\n\n end\n end", "def display_name\n @attributes[:display_name]\n end", "def show\n puts \"need an index?\".green\n index = gets.chomp.to_i\n show_contact(@@contacts.at(index))\n end", "def display_name\n if !self.first_name.blank?\n self.first_name\n elsif !self.name.blank?\n self.name\n elsif !self.provider_username.blank?\n self.provider_username\n else\n self.email\n end\n end", "def display_name\n first_name.blank? || last_name.blank? ? email : first_name + \" \" + last_name\n end", "def action_search( contacts )\n puts\n pattern = ask \"Search for? \"\n puts\n contacts.each do |contact|\n\n #Patttern works on the first letter of first/sur name\n if contact[:name] =~ /\\b#{pattern}/i\n show ( contact )\n puts\n end\n end\nend", "def enter_contact_names(test_data)\n test_names = test_data[Org::CONTACT_NAMES.name]\n test_names = [{ Org::CONTACT_NAME.name => ''}] unless test_names\n prep_fieldsets_for_test_data([fieldset(Org::CONTACT_NAMES.name)], test_names)\n\n test_names.each_with_index do |test_name, index|\n enter_auto_complete(contact_name_input(index), contact_name_options(index), test_name[Org::CONTACT_NAME.name], 'Local Persons')\n end\n end", "def display_name\n name || email\n end", "def display_name\n name || email\n end", "def display_name\n self.email\nend", "def display_name\n display = [first_name, last_name].join(' ').strip\n display.blank? ? email : display\n end", "def display_name\n self.email\n end", "def show\n puts \"number 1 org\"\n @organization = Organization.find(params[:id])\n #what is saved in @organization?\n # @organization.name = 'KCW'\n # @organization.address.....\n @contacts = Contact.all.select { |contact| contact.organization == @organization.name }\n @contacts.each do |contact|\n puts contact.name\n end\n end", "def enter_personal_info_plus_email(first_name, last_name, email_address, phone_number)\n $tracer.trace(\"GameStopMobileDSL : #{__method__}, Line : #{__LINE__}\")\n # enter_personal_info_plus_email(first_name, last_name, phone_number)\n first_name_hops_field.value = first_name\n last_name_hops_field.value = last_name\n email_address_hops_field.value = email_address\n # confirm_email_address_hops_field.value = email_address\n phone_number_hops_field.value = phone_number\n\n end", "def edit\n puts \"\\nSelect field to edit in Personal Details\"\n ch = \"1\"\n until ch == \"6\" do\n puts \" 1 => Name\\n 2 => Date Of Birth\\n 3 => Marital Status\\n 4 => Mobile Number\\n 5 => Email\\n 6 => Exit\"\n ch = gets.chomp\n case ch\n when \"1\"\n print \" Name : \"\n name = gets.chomp\n update({:name => name}) unless name == \"\"\n when \"2\"\n print \" Date Of Birth : \"\n dob = gets.chomp\n update({:dob => dob}) unless dob == \"\"\n when \"3\"\n print \" Marital Status : \"\n marital_status = gets.chomp\n update({:marital_status => marital_status}) unless marital_status == \"\"\n when \"4\"\n print \" Mobile Number : \"\n mobile_number = gets.chomp\n update({:mobile_number => mobile_number}) unless mobile_number == \"\"\n when \"5\"\n print \" Email : \"\n email = gets.chomp\n update({:email => email}) unless email == \"\"\n when \"6\"\n \n else\n puts \"Wrong Choice\"\n end\n end\n end", "def get_user_input(input) \n # case statement\n # puts Contact.all\n choice = input[0]\n case choice\n when 'new'\n puts \"you choose new\"\n puts Contact.create(input[1], input[2])\n when 'list'\n puts \"you choose list\"\n puts contact_array = Contact.all\n puts \"Total contacts: #{contact_array.length}\"\n when 'show'\n puts \"you choose show by ID\"\n # Contact.all\n puts Contact.find(input[1].to_i)\n when 'search'\n puts \"you choose search\"\n # Contact.all\n p Contact.search(input[1].downcase)\n else \n display_menu\n # choice = gets.chomp\n # get_user_input(choice)\n end\n end", "def display_all_contacts\n\t\t@rolodex.contacts.each do |user|\n\t\t\tputs \"First Name:#{user.first_name}\" \n\t\t\tputs \"Last Name: #{user.last_name}\"\n\t\t\tputs \"Email Address:#{user.email}\" \n\t\t\tputs \"Note: #{user.note}\"\n\t\tend\n\tend", "def get_contact_info\n puts 'Enter email address:'\n email = $stdin.readline().chomp\n if Contact.contact_exists?(email)\n puts 'You\\'ve already added this contact!'\n return nil\n else\n puts 'Enter contact name:'\n name = $stdin.readline().chomp\n puts 'Enter phone numbers: (e.g. mobile 604-678-3456, home 345-234-3456'\n phone_numbers = $stdin.readline().chomp.split(\", \")\n id = ContactDatabase.read.length + 1\n return [id, name, email, phone_numbers]\n end\n end", "def record_edit_display\n \"1. Name: #{name}\\n\"\\\n \"2. Email: #{email}\\n\"\\\n \"3. Library: #{libraries_edit_display}\"\n end", "def name_display\n if first_name || last_name\n \"#{first_name} #{last_name}\".strip\n else\n email\n end\n end", "def form_select\n if Contact.order(\"last_name ASC, first_name ASC\").collect.present?\n Contact.order(\"last_name ASC, first_name ASC\").collect {|p| [ p.last_name + ', ' + p.first_name, p.id ] }\n end\n end", "def view_record\n\tfound = false\n\tputs \"\\n\"\n\tprint \"First Name: \"\n\tfname = gets.chomp.upcase\n\tprint \"Last Name: \"\n\tlname = gets.chomp.upcase\n\t\n\t@personnel.each do |a|\n\t\tif a.fname == fname && a.lname == lname\n\t\t\tfound = true\n\t\tend\n\tend\n\n\tif found == true\n\t\taccount_view(fname,lname)\n\telsif @count < 3 \n\t\t@count += 1\n\t\tputs \"Account not found. Please try again.\"\n\t\taccount_menu\n\telse\n\t\tputs \"Too many login attempts. Please contact customer service.\"\n\t\tmain_menu\n\tend\nend", "def display_name\n self.name.blank? ? self.email : self.name\n end", "def contact_info(object, attr)\n if %w(phone fax).include?(attr)\n content_tag :span, phone_number(object.__send__(attr))\n elsif %w(email website).include?(attr)\n auto_link(object.__send__(attr).to_s).html_safe\n else\n object.__send__(attr).to_s\n end\n end", "def print_update\n puts \"Attribute to Change\"\n puts \"[1] First Name\"\n puts \"[2] Last Name\"\n puts \"[3] E-mail\"\n puts \"[4] Note\"\n puts \"Enter a number\"\n end", "def list_options\n puts \"Here is a list of available commands:\"\n puts \"new - Create a new contact\"\n puts \"list - List all contacts\"\n puts \"show - Show a contact\"\n puts \"search - Search contacts\"\n\n choice = gets.chomp\n\n case choice\n when \"list\"\n puts Contact.all\n when \"new\"\n puts \"Enter Name:\"\n new_name = gets.chomp\n puts \"Enter Email\"\n new_email = gets.chomp\n puts Contact.create(new_name, new_email)\n when \"show\"\n puts \"Enter ID:\"\n id = gets.chomp.to_i\n puts Contact.find(id)\n when \"search\"\n puts \"Enter a keyword\"\n term = gets.chomp\n puts Contact.search(term)\n end\n end", "def contact_name\n attributes[:contact] && attributes[:contact][:name]\n end", "def modify_contact\n contact = retrieve_contact_by_email\n if contact\n attr_code = attr_menu\n if attr_code\n print \"You have chosen to change the contact's #{@@attr_ops[attr_code]}. Is that correct? \"\n confirm = gets.chomp.downcase\n if confirm == 'yes'\n print \"Please provide the new value for #{@@attr_ops[attr_code]}: \"\n new_value = gets.chomp\n contact = @rolodex.modify(contact, attr_code, new_value)\n if contact\n puts \"Contact successfully updated:\\n#{contact}\\n\"\n end\n elsif confirm == 'no'\n print \"Update canceled. \"\n else\n puts \"Error: only 'yes' and 'no' are valid responses.\"\n end\n end\n end \n return contact\n end", "def find_by_name(name)\n # name = gets.chomp\n Contact.all.each do |contact|\n if contact.first_name == name || contact.last_name == name || \"#{contact.first_name} #{contact.last_name}\" == name\n puts \"ID:#{contact.id} Name: #{contact.first_name} #{contact.last_name}, Email: #{contact.email}\".colorize(:light_blue)\n end\n end\n end", "def print (input)\n\tinput.each do |contact|\n\t\tputs \"\t\t#{contact['id']}. #{contact['firstname']} #{contact['lastname']}\"\n\t \tputs \"\t\tEMAIL: #{contact['email']}\"\n\t \tputs \"\t\tPHONE: #{contact['phone']}\"\n\t \tputs \"\t\tADDRESS: #{contact['address']}\"\n\t \tputs \"\"\n\tend\nend", "def display_name\n if cas_surname and cas_givenname\n cas_givenname + ' ' + cas_surname\n else\n username\n end\n end", "def update(attribute, new_value)\n\t\t\tcase attribute\n\t\t\twhen \"first_name\"\n\t\t\t\t@first_name = new_value\n\t\t\twhen \"last_name\"\n\t\t\t\t@last_name = new_value\n\t\t\twhen \"email\"\n\t\t\t\t@email = new_value\n\t\t\twhen \"note\"\n\t\t\t\t@note = new_value\n\t\t\tend\n\tend", "def attribute_display_params\n# params.require(:model).permit(:model:classname, :schema, :tablename, :name)\n params.permit(:attributeid, :format, :action, :header)\n\n end", "def display_name\n return \"#{first_name} #{last_name}\".strip if first_name\n return email\n end", "def get_customer_first_name\n puts \"What's your first name?\"\n print \"> \"\n set_customer_first_name(gets.chomp)\n end", "def personal_information\n # separando a data xx/xx/xx\n dia, mes, ano = @data_nasc\n find(@@gender, visible: false).click\n fist_name_elem.set @fist_name\n last_name_elem.set @last_name\n pass_elem.set @pass\n # converte pra inteiro pra remover o zero da frente do numero.\n select_custom(locator: @@select_dia, option_value: dia.to_i)\n select_value(locator: @@select_mes, option_value: mes.to_i)\n select_custom(locator: @@select_ano, option_value: ano)\n end", "def display_patron(selected)\n\tp = Patron.find(selected)\n\tputs \"\\n#{p.name} #{p.email_address}\"\nend", "def display_fields\n [\"user_name\", \"assignment_name\"]\n end", "def fill_in_contact_info options = DEFAULT_CONTACT_INFO\n options.each do |option, value|\n begin\n fills_in option, :with => value\n rescue RuntimeError # different method needed for picking from select box (i.e. the State box)\n selects value, :from => option\n end\n end\n clicks_button \"Continue\"\n end", "def modify_contact\n puts \"Enter the id of the contact you would like to modify\"\n id_to_modify = gets.chomp \n\n contact = Contact.find(id_to_modify)\n \n puts \"Are you sure? (y/n)\"\n \tuser_input = gets.chomp\n\n if user_input == \"y\"\n puts \"Enter the id of the contact that you would like to change? 1. First Name, 2. Last Name, 3. Email, 4. Notes\"\n user_input = gets.chomp\n puts \"What is the new value?\"\n new_value = gets.chomp \n case field \n \t when 1 \n \t contact.first_name = new_value\n \t when 2\n \t\tcontact.last_name = new_value\n \t when 3 \n \t\tcontact.email = new_value\n \t when 4\n contact.notes = new_value \n else \n \t puts \"No changes were made\"\n end \n end\n end", "def contact_details\n puts \"Contact name: #{self.contact_name}\"\n puts \"Phone number: #{self.phone}\"\n puts \"Email: #{self.email}\"\n end", "def show_name\n \tif first_name\n \t\t\"#{first_name}\".strip.squeeze(\" \")\n \telse\n \t\temail\n \tend\n end", "def modify_contact(attribute_to_modify,contact_to_modify,new_value)\n\t\tif attribute_to_modify == \"id\" \n\t\t\t@database_array[@database_array.index {|x| \n\t\t\t\tcontact_to_modify==x.id||contact_to_modify==x.first_name||contact_to_modify==x.last_name||\n\t\t\t\tcontact_to_modify==x.email}].id = new_value\n\t\telsif attribute_to_modify == \"first name\" \n\t\t \t@database_array[@database_array.index {|x| \n\t\t \t\tcontact_to_modify==x.id||contact_to_modify==x.first_name||contact_to_modify==x.last_name||\n\t\t \t\tcontact_to_modify==x.email}].first_name = new_value\n\t\telsif attribute_to_modify == \"last name\" \n\t\t\t@database_array[@database_array.index {|x| \n\t\t\t\tcontact_to_modify==x.id||contact_to_modify==x.first_name||contact_to_modify==x.last_name||\n\t\t\t\tcontact_to_modify==x.email}].last_name = new_value\t\t\t\t\n\t\telsif attribute_to_modify == \"email\" \n\t\t\t@database_array[@database_array.index {|x| \n\t\t\t\tcontact_to_modify==x.id||contact_to_modify==x.first_name||contact_to_modify==x.last_name||\n\t\t\t\tcontact_to_modify==x.email}].email = new_value\n\t\telse\n\t\t\tputs \"Wrong input. Please try again!\\n\" rescue nil\n\t\tend\n\t\n\tend", "def get_org_attr orgs, attr\n print 'SCRAPING: ['\n orgs.each do |org|\n agent = Mechanize.new\n page = agent.get \"https://activities.osu.edu/involvement/student_organizations/find_a_student_org?i=#{org['id']}\"\n\n # get values from form via XPath\n name = page.search('//div/h4')\n table = page.search('//form/div/table/tr')\n\n # store into name object\n org['Name'] = name.text.strip\n (0...table.length).each do |i|\n combo = table[i].text.split ':'\n if (combo[0].include? 'Primary Type') || (combo[0].include? 'Secondary Types')\n combo[1].insert(combo[1].index(/[a-z]{1}[A-Z]{1}/) + 1, '*') while combo[1].match?(/[a-z]{1}[A-Z]{1}/)\n combo[1].split('*').each do |type|\n (org['Types'].push type.strip).uniq!\n end\n else\n org[combo[0].strip] = attr_parse combo, attr\n end\n end\n print '█'\n end\n print ']'\n puts\nend", "def format_attributes\n self.email = self.email.downcase\n self.first_name = self.first_name.titleize\n self.last_name = self.last_name.titleize\n self.full_name = \"#{self.first_name} #{self.last_name}\"\n end", "def contact_info\n puts \" Address: #{@address}\"\n puts \" Phone No: #{@phone}\"\n puts \" Email: #{@email}\"\n end", "def by_name first_name, last_name\n query = { \"and\" => [{ \"first name\" => { \"is\"=> first_name } }, { \"last name\" => { \"is\"=> last_name } }, { \"record type\"=> { \"is\"=> \"person\" }} ] }\n resp = @nimble.get 'contacts', { :query => query.to_json }\n self.contact = resp['resources'].first\n return nil unless self.contact\n self\n end", "def display_resource(contact_information)\n primary_phone = \"<b>Primary Phone:</b> #{contact_information.primary_phone}\".html_safe\n mobile_phone = \"<b>Mobile Phone:</b> #{contact_information.primary_mobile}\".html_safe\n\n if contact_information.primary_phone.present? && contact_information.primary_mobile.present?\n primary_phone + ' | ' + mobile_phone\n elsif contact_information.primary_phone.present?\n primary_phone\n else\n 'N/A'\n end\n end", "def show_name\n return_string = \"\"\n if first_name.present? || last_name.present?\n return_string = \"#{first_name} #{last_name}\".strip\n end\n if login.present?\n return_string = return_string.blank? ? login : \"#{return_string} (#{login})\".strip\n end\n if return_string.blank?\n return_string = email\n end\n return_string\n end", "def start\n case ARGV[0]\n when \"new\"\n puts \"Please enter the name\"\n name = $stdin.gets.strip\n puts \"Please enter the email address\"\n email = $stdin.gets.strip\n raise ArgumentError, \"Name and Email must have value\" if name.empty? or email.empty?\n phones = []\n while true\n puts \"Optional phone number ('yes' to continue)\"\n opt = $stdin.gets.strip\n break if opt != 'yes'\n puts \"home/work/mobile\"\n opt2 = $stdin.gets.strip\n raise ArgumentError, \"invalid input\" if opt2 != 'home' and opt2 != 'work' and opt2 != 'mobile'\n puts \"enter phone number\"\n phone = $stdin.gets.strip\n phones << opt2 + ':' + phone\n end\n p phones\n Contact.create(name, email, phones)\n \n when \"list\"\n all_contact = Contact.all\n display_contact\n\n when \"show\"\n puts \"show\"\n\n puts \"#{@contact_list.name} and #{contact_list.email}\"\n \n\n when \"search\"\n raise ArgumentError, \"Must have exactly 2 argument\" if ARGV.size != 2\n display_contact\n # @contact_list.each_with_index { |contact, i| puts \"#{contact.name} (#{contact.email})\" }\n # puts \"---\\n#{@contact_list.size} record total\"\n else\n puts \"no command\"\n\n end\n end", "def print_header\n puts \"\\nTo display the students in the database, select a filter setting \"\n puts \"to apply:\"\n puts \"'NONE' or just press Enter -> display all students.\"\n puts \"'LETTER' -> display only students whose first name begins with a specific letter\"\n puts \"'LENGTH' -> display only students whose names are less than a set length\"\n puts \"'COHORT' -> display only students of the selected cohort\"\n puts \"'ALL BY COHORT' -> display all students ordered by cohort\"\n print \">>\"\n\n # Return the user filter setting via the print_options variable\n print_options = gets.chomp\nend", "def set_attribute_display\n @attribute_display = AttributeDisplay.find(params[:id])\n end", "def display_attrtype_details( attrtype )\n\t\tocs = self.directory.schema.object_classes.values.find_all do |oc|\n\t\t\t( oc.must_oids | oc.may_oids ).include?( attrtype.name.to_sym )\n\t\tend\n\n\t\tif ocs.empty?\n\t\t\tself.prompt.say \"No objectClasses with the '%s' attribute are in the current schema.\" %\n\t\t\t\t[ attrtype.name ]\n\t\telse\n\t\t\tocnames = ocs.uniq.map( &:name ).map( &:to_s ).sort\n\n\t\t\tself.prompt.say \"objectClasses with the '%s' attribute in the current schema:\" %\n\t\t\t\t[ attrtype.name ]\n\t\t\tself.prompt.say( self.prompt.list(ocnames, :columns_across) )\n\t\tend\n\tend", "def show_attribute(form, resource, attribute)\n if is_date?(resource, attribute)\n form.input(attribute, :as => :string, :wrapper_html => {:class => 'datepick'}, :input_html => {:disabled => true})\n elsif is_document?(resource, attribute)\n content_tag(:fieldset) do\n content_tag(:legend) do\n content_tag(:label, I18n.t(\"formtastic.labels.#{resource.class.name.underscore}.#{attribute}\"))\n end +\n if is_document_empty?(resource, attribute)\n t(:no_document)\n else\n if is_image?(resource, attribute)\n image_tag(resource.send(attribute).url(:thumb))\n else\n link_to(resource.send(\"#{attribute}_file_name\"), resource.send(attribute).url)\n end\n end\n end\n else\n form.input(attribute, :input_html => {:disabled => true})\n end\n end", "def display_all_contacts(contacts)\n count = 0\n contacts.each do |contact|\n if count < 5\n count += 1\n puts \"#{contact.id}: #{contact.name} (#{contact.email}) (#{contact.phone_number})\"\n else\n puts \"Press Enter to continue.\"\n STDIN.gets\n # if user_input == \"\\n\"\n count = 1\n system \"clear\"\n puts \"#{contact.id}: #{contact.name} (#{contact.email}) (#{contact.phone_number})\"\n # end\n end\n end\n puts \"\"\n puts \"---------\"\n puts \"#{contacts.count} records total\"\n end", "def show\n @contact = Contact.find(params[:id])\n @company = @contact.company\n @company = Company.new if !@company\n @company_path_ = @company.id ? company_path(@company) : \" \"\n restrict_access(\"contacts\") if @contact.firm_id != @firm.id\n end", "def display_details()\n\t\tputs \"------------------------------\"\n\t\tputs \"User Details\"\n\t\tputs \"#{@first_name} #{@surname} aged '#{@age}'\"\n\t\tputs \"------------------------------\"\n\tend", "def display_resource(expert)\n \"#{expert.first_name} #{expert.last_name}\"\n end", "def edit_library_address(selected)\n\tl = Library.find(selected)\n\tprint \"To edit the library address please enter here: \"\n\taddress = gets.chomp\n\tl.update_attributes(address: address)\nend", "def autoname\n# auto completed to get list of users. Nee to expand it to seach name field and names in the user table\n# puts \"----------->>>>>>>>>>>>>>>>> in Auto Name\"\n \n if (params[:term] && !current_account.user.mycontacts.nil?)\n like= \"%\".concat(params[:term].concat(\"%\"))\n clone_emails = current_account.user.mycontacts.where(\"clone_email LIKE ? OR name LIKE ? \", like, like)\n # puts \"clone emails = \"+clone_emails.inspect\n else\n clone_emails = []\n end\n\n #list = clone_emails.map {|u| Hash[ :id => u.id, :label => (u.clone_email), :name => u.clone_email]}\n list = clone_emails.map {|u| Hash[ :id => u.id, :label => concat_email_name(u), :name => u.clone_email]}\n render :json => list\nend" ]
[ "0.7907715", "0.7787269", "0.7581397", "0.73593324", "0.7228612", "0.70733535", "0.6630586", "0.6630586", "0.6598577", "0.6567943", "0.6505169", "0.6167311", "0.6132295", "0.610253", "0.6082505", "0.6054668", "0.60449684", "0.60171616", "0.6008596", "0.59610456", "0.5958544", "0.58844227", "0.5844422", "0.58312446", "0.5758306", "0.57452744", "0.57161903", "0.5700664", "0.56947017", "0.56766194", "0.5665907", "0.5652885", "0.5647936", "0.561913", "0.5618029", "0.56088454", "0.556298", "0.5560896", "0.55531496", "0.55126375", "0.55099267", "0.55041766", "0.54895806", "0.54838467", "0.54776984", "0.5471452", "0.54704523", "0.5462483", "0.5462483", "0.54502946", "0.5449673", "0.5435365", "0.54279304", "0.5421498", "0.5421404", "0.5418292", "0.54067385", "0.537656", "0.53666663", "0.53648645", "0.5362303", "0.53579485", "0.5356214", "0.5314889", "0.53093344", "0.53068566", "0.53011686", "0.5296837", "0.5289785", "0.5289544", "0.5288382", "0.52759767", "0.52706325", "0.52686656", "0.5268116", "0.52626127", "0.5257497", "0.52449524", "0.52407926", "0.5236616", "0.5235723", "0.5230146", "0.52237076", "0.52229244", "0.5214892", "0.5208659", "0.52076614", "0.5202394", "0.5202367", "0.51983917", "0.51831234", "0.5178306", "0.5173995", "0.51540333", "0.51524734", "0.51502573", "0.51442087", "0.5141211", "0.5141093", "0.51348937" ]
0.6810416
6
Returns the type of this comment. Inline comments correspond to `:inline`: whatever Block comments correspond to `:document`: =begin hi i am a document =end
def type case text when /^#/ :inline when /^=begin/ :document end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def comment?\n [\"text\", \"text_wholepage\"].include?(@type)\n end", "def commentable_type\n read_attribute(:commentable_type) == 'Topic' ? Topic.find(commentable_id).class.to_s : read_attribute(:commentable_type)\n end", "def type comment\n comment.nil? ? 'Solution' : 'Comment'\n end", "def get_type\n \"line\"\n end", "def type\n CMark.node_get_type(@pointer)\n end", "def is_comment?\n self.object_type.downcase.to_s == \"comment\" || self.object_type.blank?\n end", "def determine_paragraph_type\n @paragraph_type = \\\n case\n when blank?\n :blank\n when definition_list? # order is important! A definition_list is also an unordered_list!\n :definition_term\n when (ordered_list? or unordered_list?)\n :list_item\n when property_drawer_begin_block?\n :property_drawer_begin_block\n when property_drawer_end_block?\n :property_drawer_end_block\n when property_drawer_item?\n :property_drawer_item\n when metadata?\n :metadata\n when block_type\n if block_should_be_exported?\n case block_type.downcase.to_sym\n when :center, :comment, :example, :html, :quote, :src\n block_type.downcase.to_sym\n else\n :comment\n end\n else\n :comment\n end\n when title?\n :title\n when raw_text? # order is important! Raw text can be also a comment\n :raw_text\n when comment?\n :comment\n when table_separator?\n :table_separator\n when table_row?\n :table_row\n when table_header?\n :table_header\n when inline_example?\n :inline_example\n when horizontal_rule?\n :horizontal_rule\n else :paragraph\n end\n end", "def type\n @type || @document.root.attributes[\"type\"] || @document.root.name\n end", "def document_type\n FileUtility.get_file_type(@file_name)\n end", "def type\n @node[\"type\"] || \"text\"\n end", "def type\n declaration.type if declaration.respond_to? :type\n end", "def comment?\n @kind == :line_comment || @kind == :block_comment\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n return @type\n end", "def type\n @type\n end", "def type\n @type\n end", "def type\n @type\n end", "def type\n @type\n end", "def type\n content.split(' ', 2).first\n end", "def current_type\n @token_type[@current_tok]\n end", "def type \n\t\n\t$cst.add_branch(\"type\")\n\t\n\tmatch_token(\"T_TYPE\", $tokens[$index])\n\t\n\t$cst.ascend\nend", "def type\n Type.new(type_param).yard_type_string\n end", "def type\n @type\n end", "def type\n document._type = document.class.name if typed?\n end", "def current_type\n @type\n end", "def type\n @type.name\n end", "def type\n @type.to_s\n end", "def type\n @type\n end", "def document_type\n instance.class.tire.document_type\n end", "def type\n stype = \"file\"\n stype = \"atom\" if @filepath.nil? and !@metadata.empty?\n stype = \"multipart\" if !@filepath.nil? and !@metadata.empty?\n stype\n end", "def get_comment_type(filename)\n\n # Identify method entry\n debug_print \"#{ self } : #{ __method__ }\\n\"\n\n # Merge config file type list with defaults\n _comments = COMMENT_DEFINITIONS.merge(@config.type_list)\n\n # Grab all possible extensions, check for comment match in reverse order\n # Return comment type if found in comment definitions, else false\n filename.split('.')[1..-1].each { |_ext| return _comments['.' << _ext] if _comments.has_key?('.' << _ext) }\n\n debug_print \"Couldn't find any recognized extension type\\n\"\n false\n\n end", "def content_type\n reader.format.content_type if valid?\n end", "def type\n @node[\"type\"]\n end", "def get_type\n\n end", "def comment?\n type == COMMENT_NODE\n end", "def type\n 'it'\n end", "def name_of_content_type\n if self.content_type == 'application/vnd.ms-word'\n return \"Word document\"\n elsif self.content_type == 'application/pdf'\n return \"PDF file\"\n end\n end", "def type\n DocInfoClasses.key(self.class)\n end", "def typename\n end", "def typename\n end", "def type\n end", "def _type\n self.class.to_s\n end", "def current_type\n\t\t@block_type\n\tend", "def parent_type\n type_tag.to_s.sub(\"_description\", \"\")\n end", "def content_type\n @record.send( :\"#{@column}_content_type\" ) rescue ''\n end", "def type\n @type ||= case\n when is_many?, is_many_ints?\n :multi\n when @associations.values.flatten.length > 1\n :string\n else\n translated_type_from_database\n end\n end", "def type\n _type\n end", "def type\n @type ||= begin\n base_type = case\n when is_many?, is_many_ints?\n :multi\n when @associations.values.flatten.length > 1\n :string\n else\n translated_type_from_database\n end\n \n if base_type == :string && @crc\n base_type = :integer\n else\n @crc = false unless base_type == :multi && is_many_strings? && @crc\n end\n \n base_type\n end\n end", "def type() end", "def comment?\n return @assigned_paragraph_type == :comment if @assigned_paragraph_type\n return block_type.casecmp(\"COMMENT\") if begin_block? or end_block?\n return @line =~ /^[ \\t]*?#[ \\t]/\n end", "def type\n self.class.type\n end", "def type\n self.class.type\n end", "def type\n self.class.type\n end", "def type\n self.class.type\n end", "def type\n self.class.type\n end", "def type\n self.class.type\n end", "def type\n\t\tself.class.type\n\tend", "def type\n\t\tself.class.type\n\tend", "def type_id\n @type_id ||= extract_int(@content[0...TYPE_SIZE])\n end", "def type\n @type ||= IDS_TYPES[type_id]\n end", "def content_type\n @io.content_type\n end", "def type\n\t\t@type\n\tend", "def content_type\n return @content_type\n end", "def code_type()\n path = @opts[:file]\n if path.end_with? '.rb'\n :ruby\n elsif path.end_with? '.xml'\n :xml\n else\n :text\n end\n end", "def type\n self.class.type(self)\n end", "def getContenttype\r\n\t\t\t\t\treturn @contenttype\r\n\t\t\t\tend", "def doc_type\n DOC_TYPES[self.TipoDoc.to_sym]\n end", "def yard_type_string\n if association?(ast)\n yard_type_from_association(ast)\n elsif collection?(ast)\n yard_type_from_collection(ast)\n elsif ast.ref?\n yard_type_from_reference(ast)\n elsif !ast[0].nil?\n Type.new(ast[0]).yard_type_string\n else\n nil\n end\n end", "def type\n @@type\n end", "def type\n @@type\n end", "def type; self._type; end", "def type\n if object.spot?\n \"spot\"\n else\n \"submission\"\n end\n end", "def type\n return :opening_tag if element_is_opening_tag?\n return :text if element_is_text?\n return :closing_tag if element_is_closing_tag?\n end", "def type\n return :opening_tag if element_is_opening_tag?\n return :text if element_is_text?\n return :closing_tag if element_is_closing_tag?\n end", "def type\n self[:type]\n end", "def type\n end", "def type\n @type ||= calculate_type\n end", "def type\n TYPES[@type_id]\n end", "def get_type()\n # Check if a type has been specified and if not set it to :round.\n if @metadata[:type] == nil\n @metadata[:type] = :round\n end\n return @metadata[:type]\n end", "def type\n self.class.type\n end", "def type\n self.class.type\n end", "def type\n self.class.type\n end", "def nodeType\n DOCUMENT_TYPE_NODE\n end", "def _type\n @link['type']\n end", "def media_type\n hyper_schema_link.media_type\n end", "def type_name\n \"_doc\"\n end", "def type\n self[:type]\n end", "def type\n return @type if defined? @type\n @type = self.to_s.gsub(/.*::/, '')\n end", "def type\n @type ||= \"#{as}_type\" if polymorphic?\n end", "def type\n return @type if defined? @type\n\n @type = self.to_s.gsub(/.*::/, '')\n end", "def type\n ''\n end", "def type\n\tend", "def type\n\tend", "def type(node, type); end" ]
[ "0.6380302", "0.6371671", "0.6371038", "0.6366362", "0.6309205", "0.6304772", "0.60622334", "0.604331", "0.59842545", "0.5919068", "0.5901766", "0.5866075", "0.58624786", "0.5850932", "0.5850932", "0.5850932", "0.5850932", "0.5850932", "0.5850932", "0.5850932", "0.5847068", "0.5847068", "0.5847068", "0.5846324", "0.5841538", "0.582126", "0.58208644", "0.5818188", "0.57833266", "0.5750294", "0.57380664", "0.5730888", "0.5729741", "0.57213336", "0.57173306", "0.57070225", "0.56962544", "0.5695003", "0.5689288", "0.56798166", "0.56549627", "0.56483924", "0.5639666", "0.56357574", "0.5611209", "0.5611209", "0.5606987", "0.56029576", "0.5602638", "0.5600147", "0.55902624", "0.5587777", "0.5586253", "0.5585695", "0.5584075", "0.5576637", "0.55658746", "0.55658746", "0.55658746", "0.55641574", "0.55641574", "0.55641574", "0.5546045", "0.5546045", "0.55324095", "0.5527382", "0.5519779", "0.5517592", "0.55170166", "0.55105436", "0.5508247", "0.5507934", "0.5505184", "0.55034524", "0.54814965", "0.54814965", "0.54786116", "0.54764676", "0.5476003", "0.5476003", "0.54756635", "0.5472351", "0.54690063", "0.5463098", "0.54630166", "0.5451753", "0.5451753", "0.5451753", "0.54436624", "0.5434402", "0.54315925", "0.54303575", "0.5425671", "0.54172635", "0.54120934", "0.5411373", "0.5401484", "0.53958684", "0.53958684", "0.53924924" ]
0.7114647
0
Compares comments. Two comments are identical if they correspond to the same source range.
def ==(other) other.is_a?(Source::Comment) && @location == other.location end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def assert_parses_with_comments(ast_pattern, source, comments_pattern)\n with_versions(ALL_VERSIONS) do |_ver, parser|\n source_file = Parser::Source::Buffer.new('(comments)', source: source)\n\n comments_pattern_here = comments_pattern.map do |(from, to)|\n range = Parser::Source::Range.new(source_file, from, to)\n Parser::Source::Comment.new(range)\n end\n\n ast, comments = parser.parse_with_comments(source_file)\n\n assert_equal ast_pattern, ast\n\n assert_equal comments_pattern_here, comments\n end\n end", "def get_same_comment(nodes, metadata)\n record_call(:get_same_comment, nodes, metadata)\n nodes.map { |node| [node, \"Comment for #{node}\"] }.to_h\n end", "def adjacent_comments(comments, buffer)\n comments = comments.sort_by { |comment| comment.location.begin_pos }\n current_chunk = 0\n last_line_seen = -100\n chunks_to_comment = comments.chunk do |comment|\n line = comment.location.begin_pos.line\n if last_line_seen.next == line\n last_line_seen = line\n current_chunk\n else\n last_line_seen = line\n current_chunk += 1\n end\n end\n chunks_to_comment.map &:last\n end", "def get_different_comment(nodes, metadata)\n record_call(:get_different_comment, nodes, metadata)\n nodes.map { |node| [node, 'Comment from test_cmdb_2'] }.to_h\n end", "def check_conflict_and_comment()\n results = check_conflict()\n\n results.each do |result|\n next if result[:mergeable]\n message = \"<p>This PR conflicts with <a href=\\\"#{result[:pull_request][:html_url]}\\\">##{result[:pull_request][:number]}</a>.</p>\"\n table = '<table><thead><tr><th width=\"100%\">File</th><th>Line</th></tr></thead><tbody>' + result[:conflicts].map do |conflict|\n file = conflict[:file]\n line = conflict[:line]\n line_link = \"#{result[:pull_request][:head][:repo][:html_url]}/blob/#{result[:pull_request][:head][:ref]}/#{file}#L#{line}\"\n \"<tr><td>#{file}</td><td><a href=\\\"#{line_link}\\\">#L#{line}</a></td></tr>\"\n end.join('') + '</tbody></table>'\n puts (message + table)\n warn(\"<div>\" + message + table + \"</div>\")\n end\n\n results\n end", "def get_different_comment_2(nodes, metadata)\n record_call(:get_different_comment_2, nodes, metadata)\n nodes.map { |node| [node, 'Comment2 from test_cmdb_2'] }.to_h\n end", "def test_ut_diff_source_code_02\n assert_equal(1,@diff_source_code_1.diff_result_id)\n assert_equal(1,@diff_source_code_1.original_file_id)\n assert_equal(1,@diff_source_code_1.diff_file_id)\n assert_equal(nil,@diff_source_code_1.added_lines)\n assert_equal(\"7;8;9;25;390;396;397;400;404\",@diff_source_code_1.deleted_lines)\n assert_equal(\"1,1;2,2;3,3;4,4;6,6;10,10;11,11;12,12;13,13;14,14;15,15;\",@diff_source_code_1.common_lines)\n end", "def comments_range; end", "def comments_range; end", "def parse_with_comments(source_buffer); end", "def parse_with_comments(source_buffer); end", "def parse_with_comments(source_buffer); end", "def pair_comments(post)\n replacements = post.replacements.order(id: :asc).to_a\n comments = post.comments.where(creator: User.system).where_regex(:body, \"replaced this post\").order(id: :asc).to_a\n pairs = []\n\n while replacements.present? && comments.present?\n # Take the Cartesian product of all possible replacement-comment pairs, filter for matching pairs, and take the pair\n # with the closest matching created_at times.\n replacement, comment = replacements.product(comments).select do |replacement, comment|\n data = parse_comment(comment)\n\n if replacement.old_md5.present? && replacement.md5.present?\n data.old_source == replacement.original_url && data.replacer == replacement.creator && data.old_md5 == replacement.old_md5 && data.new_md5 == replacement.md5\n elsif replacement.old_md5.present?\n data.old_source == replacement.original_url && data.replacer == replacement.creator && data.old_md5 == replacement.old_md5\n else\n data.old_source == replacement.original_url && data.replacer == replacement.creator\n end\n end.min_by do |replacement, comment|\n [(replacement.updated_at - comment.created_at).abs, replacement.id, comment.id]\n end\n\n pairs << [replacement, comment]\n replacements -= [replacement]\n comments -= [comment]\n end\n\n [pairs, replacements]\nend", "def parse_with_comments(source); end", "def canonicalize_comments!\n @comment = nil if @comment && @comment.match(/^Track \\d+$/)\n end", "def test_html_check_comment_text\n ct = CodeTerminator::Html.new\n p \"3 test if text in comment is the same as the text of comment in code\"\n p errors = ct.match(\"exercises/html/check_comment_text.html\",\"<html><head></head><body><!-- This is a comment --></body></html>\")\n assert_equal errors.empty? , true\n end", "def comment_line?(line_source); end", "def comment_line?(line_source); end", "def autocorrect_preceding_comments(corrector, comment); end", "def formatComments(theLines)\n\n\ttheLines.each_with_index do |theLine, theIndex|\n\n\t\tif (theIndex >= 2)\n\t\t\n\t\t\tline0 = theLines[theIndex - 2];\n\t\t\tline1 = theLines[theIndex - 1];\n\t\t\tline2 = theLines[theIndex - 0];\n\t\t\t\n\t\t\tif (line0[:text].empty? &&\n\t\t\t\tline1[:text].empty? &&\n\t\t\t\tline2[:text].empty? &&\n\n\t\t\t\tline0[:comment] =~ /^\\/\\/==========+/ &&\n\t\t\t\tline2[:comment] =~ /^\\/\\/----------+/ &&\n\t\t\t\tline1[:comment] =~ /^\\/\\/\\s*(.*)/ )\n\n\n\t\t\t\t# Fix up standard blocks\n\t\t\t\ttheComment = $1;\n\t\t\t\tcommentKey = $1.chomp('.').downcase;\n\n\t\t\t\tif (COMMENT_STANDARD.has_value?(theComment))\n\t\t\t\t\t# Accept as-is\n\n\t\t\t\telsif (COMMENT_STANDARD.has_key?(commentKey))\n\t\t\t\t\ttheComment = COMMENT_STANDARD[commentKey];\n\n\n\n\t\t\t\t# Fix up function blocks\n\t\t\t\telsif (theComment =~ /^(.*)\\s:\\s(.*)$/)\n\t\t\t\t\ttheName = $1.strip;\n\t\t\t\t\ttheDesc = $2.strip.chomp(\".\");\n\n\n\t\t\t\t\t# Normalise the description\n\t\t\t\t\tif (theName =~ /^(\\w+)::\\1$/)\n\t\t\t\t\t\ttheDesc = \"Constructor.\";\n\t\t\t\t\t\n\t\t\t\t\telsif (theName =~ /^(\\w+)::~\\1$/)\n\t\t\t\t\t\ttheDesc = \"Destructor.\";\n\t\t\t\t\t\n\t\t\t\t\telsif (theDesc.empty?)\n\t\t\t\t\t\ttheDesc = \"MISSING DESCRIPTION.\";\n\t\t\t\t\tend\n\t\t\t\t\n\t\t\t\t\tif (!theDesc.end_with?(\".\", \"?\", \"!\"))\n\t\t\t\t\t\ttheDesc += \".\";\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\ttheComment = theName + \" : \" + theDesc;\n\t\t\t\tend\n\n\n\n\t\t\t\t# Rewrite the the comment\n\t\t\t\ttheLines[theIndex - 2][:comment] = COMMENT_BAR_TOP;\n\t\t\t\ttheLines[theIndex - 1][:comment] = COMMENT_BAR_CONTENT + theComment;\n\t\t\t\ttheLines[theIndex - 0][:comment] = COMMENT_BAR_BOTTOM;\n\t\t\tend\n\t\t\n\t\tend\n\tend\n\n\treturn theLines;\n\nend", "def adjust_comments\n scan_tokens do |prev, token, post, i|\n next 1 unless token[0] == :COMMENT\n before, after = @tokens[i - 2], @tokens[i + 2]\n if before && after &&\n ((before[0] == :INDENT && after[0] == :OUTDENT) ||\n (before[0] == :OUTDENT && after[0] == :INDENT)) &&\n before[1] == after[1]\n @tokens.delete_at(i + 2)\n @tokens.delete_at(i - 2)\n next 0\n elsif prev[0] == \"\\n\" && [:INDENT].include?(after[0])\n @tokens.delete_at(i + 2)\n @tokens[i - 1] = after\n next 1\n elsif ![\"\\n\", :INDENT, :OUTDENT].include?(prev[0])\n @tokens.insert(i, [\"\\n\", Value.new(\"\\n\", token[1].line)])\n next 2\n else\n next 1\n end\n end\n end", "def foldable_comment_block_ranges; end", "def compare_docstring_tags(d1, d2); end", "def preceding_comment?(node1, node2); end", "def process_comments\n source_path = configuration['comments']['source_path']\n ignored_paths = configuration['comments']['ignored_paths']\n ignored_methods = configuration['comments']['ignored_methods']\n\n find_files_without(source_path, ignored_paths).each do |path|\n comments = []\n temp_file = Tempfile.new(SecureRandom.hex)\n\n begin\n File.open(path).each_with_index do |line, index|\n if line.strip.start_with?('#')\n comments.push(line)\n else\n if line.strip.start_with?('def ')\n method_name = extract_method_name_without_arguments(line)\n\n condition_0 = comments.none?\n condition_1 = !ignored_methods.include?(method_name)\n\n data = (condition_0 && condition_1) ? process_line(line, index) : comments.join\n temp_file.print(data)\n else\n temp_file.print(comments.join)\n end\n\n comments = []\n temp_file.write line\n end\n end\n\n temp_file.print(comments.join)\n temp_file.close\n FileUtils.mv(temp_file.path, path)\n ensure\n temp_file.close\n temp_file.unlink\n end\n end\n end", "def detect_comments\n if @input =~ %r{^\\s*[/]{2}}\n @mode = :comment\n @expression = ''\n end\n end", "def parse_comments(comments); end", "def mark_commented_lines\n [].tap do |reg|\n in_block_comment = false\n line_no = 0\n start_block = 0\n end_block = 0\n @source.each_line do |line|\n line_no = line_no+1\n\n start_block = line_no if !in_block_comment and line =~ @start_block_comment_regex\n end_block = line_no if start_block < line_no and line =~ @end_block_comment_regex\n end_block = line_no if line =~ @oneline_block_comment_regex\n\n in_block_comment = end_block < start_block\n\n reg << line_no if in_block_comment or end_block == line_no or line =~ @comment_regex\n end\n end\n end", "def ensure_comments_section\n if self.body.match(/^\\* COMMENT Comments$/)\n self.body[$~.end(0)..-1] = self.body[$~.end(0)..-1].gsub(/^\\* COMMENT Comments/, '')\n else\n self.body << \"\\n* COMMENT Comments\\n\"\n end\n end", "def parse_comment\n s0 = @scanner.pos\n if match_str('*') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n s2 = parse_nonls\n if parse_nl == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = s2.join\n end\n end\n if s0 == :failed\n s0 = @scanner.pos\n s1 = match_str('&')\n if s1 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n s2 = parse_nonls\n if parse_nl == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = '&' + s2.join\n end\n end\n end\n s0\n end", "def comments_range=(_arg0); end", "def comments_have_alignment?\n true\n end", "def comment_lines\n repository.files.map do |file|\n content = repository.read(file)\n content.to_s.lines.map do |line|\n first = line.strip[0]\n first = first.chr if first\n first == '#' ? 1 : 0\n end.sum\n end.sum\n end", "def comment_del(name)\n bc = Array.new(@comment) # We need a copy\n if name.include? \"=\"\n nc = @comment.delete_if { |x| x == name }\n else\n nc = @comment.delete_if { |x| x.split(\"=\")[0] == name }\n end\n\n if nc == bc\n return false\n else\n @comments_changed = 1\n return true\n end\n end", "def parse_with_comments(source_buffer)\n @lexer.comments = []\n\n [ parse(source_buffer), @lexer.comments ]\n ensure\n @lexer.comments = nil\n end", "def check_duplicate_comments\n return unless event_type == 'comment' and event_action == 'created'\n if Activity.where(event_type: 'comment', event_action: 'created', user_id: user_id, repo: repo, :commented_on.lte => commented_on, :commented_on.gte => commented_on - 1.hour, description: description).count > 0\n errors.add(:description, 'Duplicate comment for the same repository by the same user')\n end\n end", "def comment_line?(line_source)\n /^\\s*#/.match?(line_source)\n end", "def compare(src, dest) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity\n if !src.is_a?(dest.class) && !(dest.is_a?(Array) || src.is_a?(Array)) && !(dest['content'] || dest['type'])\n return [\"- #{src.to_s[0..70]}#{src.to_s.size > 70 ? '...' : ''}\",\n \"+ #{dest.to_s[0..70]}#{dest.to_s.size > 70 ? '...' : ''}\"]\n elsif dest.is_a?(Array)\n return compare src, dest.first\n elsif src.is_a?(Array)\n return compare src.first, dest\n end\n case src\n when Array\n result = src.map.with_index { |s, i| compare s, array(dest)[i] }\n compact result\n when String\n dest_str = case dest\n when Hash then dest['content'] || dest['type']\n when Array then dest[0]['content'] || dest[0]['type']\n else dest\n end\n src != dest_str && [\"- #{src}\", \"+ #{dest_str}\"]\n when Hash\n result = src.map do |k, v|\n dest[k]['begins'].sub!(/\\s00:00$/, '') if k == 'validity'\n res = compare v, dest[k]\n { k => res } if res && !res.empty?\n end\n compact result\n end\nend", "def strip_comments\n in_str = false\n @src_lines.each do |line|\n pos = line.each_char.with_index do |ch,i|\n if ch == '\"'\n if in_str\n in_str = false\n else\n in_str = true\n end\n end\n \n if ch == \";\" && !in_str\n break i\n end\n \n end\n \n if pos.class == Fixnum\n #strip them to the end of the file\n line.slice!(pos..-1)\n end\n \n end\n end", "def set_encoder_from_comments!\n start_comment = @discs.compact.first.tracks.first.comment\n if start_comment.is_a? Array\n start_comment = start_comment.uniq.join(' / ')\n end\n\n if start_comment != nil && start_comment != ''\n consistent = true\n \n @discs.compact.each do |disc|\n disc.tracks.each do |track|\n if track.comment != start_comment\n consistent = false\n break\n end\n end\n end\n \n encoder_list = start_comment.split(' / ').compact.select {|encoder| !(encoder =~ /^\\s*$/)}\n if consistent && encoder_list && encoder_list.size > 0\n @discs.compact.each do |disc|\n disc.tracks.each do |track|\n track.comment = nil\n if track.encoder.nil?\n track.encoder = []\n end\n track.encoder << encoder_list\n end\n end\n end\n end\n end", "def uses_legacy_comments?\n end", "def filter_comment_format(comment, struct_comment)\n sc, cc = struct_comment, comment\n comment = nil unless cc && cc.match(/./)\n sc = nil unless sc && sc.match(/./)\n if cc || sc\n [cc, sc].uniq.compact.join(' / ').gsub(/\"/, '')\n else\n ''\n end\n end", "def comments\n results = []\n return results unless @comments\n\n comment = ''\n @comments.split(\"\\n\").each do |line|\n if line =~ /^\\S/\n results << comment unless comment.empty?\n comment = line\n else\n comment += \"\\n\" + line\n end\n end\n\n results << comment unless comment.empty?\n return results\n end", "def n_way_diff *data\n comments = []\n codes = []\n\n split_and_group(data).each do |subdata|\n n = subdata.find_index { |s| s !~ /^#/ }\n\n comment, code = subdata[0..n-1], subdata[n..-1]\n comment = [] if n == 0\n\n comments << comment\n codes << code\n end\n\n comments = collapse_and_label pad_with_empty_strings comments\n codes = collapse_and_label pad_with_empty_strings codes\n\n (comments + codes).flatten.join(\"\\n\")\n end", "def verify_comment(line) \n end", "def _comment\n\n _save = self.pos\n while true # choice\n _tmp = scan(/\\A(?-mix:--.*?$)/)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_multi_comment)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_comment unless _tmp\n return _tmp\n end", "def test_html_check_comment_exist\n ct = CodeTerminator::Html.new\n p \"1 test if comment exist in code with comment\"\n p errors = ct.match(\"exercises/html/check_comment_exist.html\",\"<html><head></head><body><!-- This is a comment --></body></html>\")\n assert_equal errors.empty? , true\n end", "def extract_magic_comments(processed_source); end", "def table_comment_changes\n comment = table_or_view_comment\n new_comment = table_comments[:table]\n return unless comment != new_comment\n\n new_comment\n end", "def test_html_check_comment_empty\n ct = CodeTerminator::Html.new\n p \"5 test if text in comment of the code can be different in empty comments\"\n p errors = ct.match(\"exercises/html/check_comment_empty.html\",\"<html><head></head><body><!-- This is MY comment --></body></html>\")\n assert_equal errors.empty? , true\n end", "def hash_tag_comments(pr)\n ccs = commit_comments(pr)\n prcs = pr_comments(pr)\n ics = issue_comments(pr)\n (ccs + prcs + ics).reduce(0) do |acc, ic|\n unless ic[:body].nil?\n acc + ic[:body].gsub(/`.*?`/, '').\\\n scan(/#([0-9]+)/).size\n else\n acc\n end\n end\n end", "def set_encoder_from_comments!\n if @discs.compact.size > 1 || @discs.compact.first.tracks.size > 1\n start_comment = @discs.compact.first.tracks.first.comment\n if start_comment.is_a? Array\n start_comment = start_comment.uniq.join(' / ')\n end\n\n if start_comment != nil && start_comment != ''\n consistent = true\n \n @discs.compact.each do |disc|\n disc.tracks.each do |track|\n if track.comment != start_comment\n consistent = false\n break\n end\n end\n end\n \n encoder_list = start_comment.split(' / ').compact.select {|encoder| !(encoder =~ /^\\s*$/)}\n if consistent && encoder_list && encoder_list.size > 0\n @discs.compact.each do |disc|\n disc.tracks.each do |track|\n track.comment = nil\n if track.encoder.nil?\n track.encoder = []\n end\n encoder_list.each do |element|\n next if element =~ /engiTunNORM/\n track.encoder << element\n end\n end\n end\n end\n end\n end\n end", "def add_sql_diff_comment(comment = nil)\n sql_diff_text_log << '--'\n sql_diff_text_log << \" #{comment}\" if comment\n sql_diff_text_log << \"\\r\\n\"\n end", "def test_ut_diff_result_02\n original_source_code = OriginalSourceCode.new(\n :original_file_id => 10,\n :line_number => 349898,\n :error_line => 4564,\n :line_content => \"123456\"\n )\n assert_equal(10,original_source_code.original_file_id)\n assert_equal(349898,original_source_code.line_number)\n assert_equal(4564,original_source_code.error_line)\n assert_equal(\"123456\",original_source_code.line_content)\n end", "def comment?\n return @assigned_paragraph_type == :comment if @assigned_paragraph_type\n return block_type.casecmp(\"COMMENT\") if begin_block? or end_block?\n return @line =~ /^[ \\t]*?#[ \\t]/\n end", "def ==(other)\n if other.is_a?(Code)\n @other_lines = other.instance_variable_get(:@lines)\n @lines.each_with_index.all? do |(l, ln), i|\n l == @other_lines[i].first && ln == @other_lines[i].last\n end\n else\n to_s.chomp == other.to_s.chomp\n end\n end", "def process_initial_comment(tk)\n if @statement.empty? && (@comments_last_line || 0) < tk.line_no - 2\n @comments = nil\n end\n\n return unless tk.class == TkCOMMENT\n\n case tk.text\n when Parser::SourceParser::SHEBANG_LINE\n if !@last_ns_tk && !@encoding_line\n @shebang_line = tk.text\n return\n end\n when Parser::SourceParser::ENCODING_LINE\n if (@last_ns_tk.class == TkCOMMENT && @last_ns_tk.text == @shebang_line) ||\n !@last_ns_tk\n @encoding_line = tk.text\n return\n end\n end\n\n return if !@statement.empty? && @comments\n return if @first_line && tk.line_no > @first_line\n\n if @comments_last_line && @comments_last_line < tk.line_no - 1\n if @comments && @statement.empty?\n @tokens.unshift(tk)\n return @done = true\n end\n @comments = nil\n end\n @comments_line = tk.line_no unless @comments\n\n # Remove the \"#\" and up to 1 space before the text\n # Since, of course, the convention is to have \"# text\"\n # and not \"#text\", which I deem ugly (you heard it here first)\n @comments ||= []\n if tk.text.start_with?('=begin')\n lines = tk.text.count(\"\\n\")\n @comments += tk.text.gsub(/\\A=begin.*\\r?\\n|\\r?\\n=end.*\\r?\\n?\\Z/, '').split(/\\r?\\n/)\n @comments_last_line = tk.line_no + lines\n else\n @comments << tk.text.gsub(/^(#+)\\s{0,1}/, '')\n @comments_hash_flag = $1 == '##' if @comments_hash_flag.nil?\n @comments_last_line = tk.line_no\n end\n @comments.pop if @comments.size == 1 && @comments.first =~ /^\\s*$/\n true\n end", "def sync(source_comment)\n [ :comment_ip, :comment_author, :comment_email, :comment_url, :comment_text, \n :comment_created_on, :comment_modified_on, :comment_created_by, :comment_modified_by, \n :comment_commenter_id, :comment_visible, :comment_junk_score, :comment_junk_status, \n :comment_last_moved_on, :comment_junk_log ].each do |attribute|\n self[attribute] = source_comment[attribute]\n end\n end", "def ==(other)\n return false if other.class != self.class\n # checking for lines.size is an optimisation\n @lines.size == other.lines.size and @lines.sort == other.lines.sort\n end", "def test_comment_sanitization\n\n full_tests = {\n \"hey `there`\" => \"<p>hey <code>there</code></p>\",\n\n \"hey `<b>`\" => \"<p>hey <code>&lt;b&gt;</code></p>\",\n\n # this one is not desired, but it's safe and acceptable\n \"hey `<script>`\" => \"<p>hey <code>&lt;script&gt;</code></p>\",\n\n \"hey `<link href=\\\"what\\\">`\" => \"<p>hey <code>&lt;link href=\\\"what\\\"&gt;</code></p>\",\n\n \"hey <script>\" => \"<p>hey &lt;script&gt;&lt;/script&gt;</p>\",\n \"hey <script>yes</script>\" => \"<p>hey &lt;script&gt;yes&lt;/script&gt;</p>\",\n \"hey <b>yes</b>\" => \"<p>hey <b>yes</b></p>\",\n }\n\n full_tests.each do |input, output|\n assert_equal output, routing.render_comment_body(input).strip\n end\n\n\n end", "def comments=(_arg0); end", "def comments=(_arg0); end", "def comments=(_arg0); end", "def comments=(_arg0); end", "def comments=(_arg0); end", "def diff_conflicts(diff1, diff2)\n da1 = diff1.path.split(\"/\")\n da2 = diff2.path.split(\"/\")\n\n cmp_size = [da1, da2].map(&:size).min - 1\n return false if da2.size == cmp_size + 1\n da1[0..cmp_size] == da2[0..cmp_size]\n end", "def process_block_comment!(index, tokens, ranges)\n start_index = index\n line_num = line_for_offset(tokens[index][1])\n while index < tokens.length - 2\n break unless tokens[index + 1][0] == :TOKEN_COMMENT\n next_line = line_for_offset(tokens[index + 1][1])\n # Tokens must be on contiguous lines\n break unless next_line == line_num + 1\n # Must not be a region comment\n comment = extract_text(tokens[index + 1][1])\n break if start_region?(comment) || end_region?(comment)\n # It's a block comment\n line_num = next_line\n index += 1\n end\n\n return index if start_index == index\n\n add_range!(create_range_span_tokens(tokens[start_index][1], tokens[index][1], REGION_COMMENT), ranges)\n index\n end", "def comment\n comment = buffer.options.comment_line.to_s\n indent = nil\n lines = []\n\n each_line do |line, fc, tc|\n line_fc = \"#{line}.#{fc}\"\n line_tc = \"#{line}.#{tc}\"\n\n next if buffer.at_end == line_tc\n\n lines << line\n\n next if indent == 0 # can't get lower\n\n line = buffer.get(\"#{line}.#{fc}\", \"#{line}.#{tc}\")\n\n next unless start = line =~ /\\S/\n\n indent ||= start\n indent = start if start < indent\n end\n\n indent ||= 0\n\n buffer.undo_record do |record|\n lines.each do |line|\n record.insert(\"#{line}.#{indent}\", comment)\n end\n end\n end", "def _comment\n\n _save = self.pos\n while true # sequence\n _tmp = match_string(\"#\")\n unless _tmp\n self.pos = _save\n break\n end\n while true\n\n _save2 = self.pos\n while true # sequence\n _save3 = self.pos\n _tmp = apply(:_eol)\n _tmp = _tmp ? nil : true\n self.pos = _save3\n unless _tmp\n self.pos = _save2\n break\n end\n _tmp = get_byte\n unless _tmp\n self.pos = _save2\n end\n break\n end # end sequence\n\n break unless _tmp\n end\n _tmp = true\n unless _tmp\n self.pos = _save\n break\n end\n _tmp = apply(:_eol)\n unless _tmp\n self.pos = _save\n end\n break\n end # end sequence\n\n set_failed_rule :_comment unless _tmp\n return _tmp\n end", "def remove_comments(source)\n for_outstrings_of(source) do |str|\n str.gsub! /\\/\\*.*?\\*\\//im, ''\n str.gsub! /\\/\\/.*?$/, ''\n str\n end\n end", "def multi_line_comment\n # /*\n if @codes[@pos] == 0x2f and @codes[@pos + 1] == 0x2a\n @pos += 2\n pos0 = @pos\n # */\n while (code = @codes[@pos] != 0x2a) or @codes[@pos + 1] != 0x2f\n raise ParseError.new(\"no `*/' at end of comment\", self) if code.nil?\n @pos += 1\n end\n @pos +=2\n return ECMA262::MultiLineComment.new(@codes[pos0...(@pos-2)].pack(\"U*\"))\n else\n nil\n end\n end", "def prepare_comments #:nodoc:\n count = 0\n comments = []\n\n # We sort the comments by row and column but that isn't strictly required.\n #\n rows = @comments.keys.sort\n rows.each do |row|\n cols = @comments[row].keys.sort\n cols.each do |col|\n comments.push(@comments[row][col])\n count += 1\n end\n end\n\n @comments = {}\n @comments_array = comments\n\n return count\n end", "def comments(file, revision, opts = {})\n method = opts[:draft] ? :draft_comments : :comments\n reference = revision > 0 ? revision : 1\n cs = @gerrit.send(method, @id, reference)[file] || []\n side = revision > 0 ? 'REVISION' : 'PARENT'\n cs.select { |c| (c['side'] || 'REVISION') == side }\n end", "def comment\n multi_line_comment || single_line_comment\n end", "def emit_comments_before(source_part = :expression)\n comments_before = comments.take_before(node, source_part)\n return if comments_before.empty?\n\n emit_comments(comments_before)\n buffer.nl\n end", "def ==(other)\n (@message == other.message) &&\n (@source_location == other.source_location) &&\n (@source_method == other.source_method)\n end", "def prepare_comment_text(comment)\n simple_format comment.body\n # raw comment.body.split(\"\\n\").map(&:squish).reject(&:blank?).map { |s| parse_common_string s }.join\n end", "def comments_hash_flag; end", "def comments_hash_flag; end", "def comments_hash_flag; end", "def <=>(other)\n return nil unless other.is_a?(::Parser::Source::Range) &&\n @source_buffer == other.source_buffer\n (@begin_pos <=> other.begin_pos).nonzero? ||\n (@end_pos <=> other.end_pos)\n end", "def parse_comment\n return false unless @lexer.get and @lexer.get.type == :comment_start\n @lexer.next!\n\n buf = ''\n while token = @lexer.get\n break if token.type == :comment_end\n buf << token.value\n @lexer.next!\n end\n\n found :comment, buf\n @lexer.next!\n true\n end", "def remove_comments(code_array)\n code_array.select { |line| !(line.match(Parser::COMMENT_REGEXP)) }\n end", "def show_something?(comment_set)\n\t\tcomment_count = comment_set.count do |line| \n\t\t Regexp.new(\"^[\\s\\t]*#{@options[:literal]}+.*$\") =~ line\n\t\tend\n\t\tputs \"#{comment_count} comment#{comment_count>1 ? 's' : ''} found.\"\n\t\tputs \"#{comment_count.zero?? \"Nothing to change.\" : \"Processing ...\"}\"\n\t end", "def comments; end", "def comments; end", "def comments; end", "def comments; end", "def comments; end", "def comments; end", "def _comment\n\n _save = self.pos\n while true # sequence\n _tmp = match_string(\"#\")\n unless _tmp\n self.pos = _save\n break\n end\n while true\n\n _save2 = self.pos\n while true # sequence\n _save3 = self.pos\n _tmp = apply(:_end_hyphen_of_hyphen_line)\n _tmp = _tmp ? nil : true\n self.pos = _save3\n unless _tmp\n self.pos = _save2\n break\n end\n _tmp = apply(:_utf8)\n unless _tmp\n self.pos = _save2\n end\n break\n end # end sequence\n\n break unless _tmp\n end\n _tmp = true\n unless _tmp\n self.pos = _save\n end\n break\n end # end sequence\n\n set_failed_rule :_comment unless _tmp\n return _tmp\n end", "def comments_from path\n path = File.expand_path(\"../lib/friendly_id/#{path}\", __FILE__)\n match = File.read(path).match(/\\n=begin(.*)\\n=end/m)[1].to_s\n match.split(\"\\n\").reject {|x| x =~ /^@/}.join(\"\\n\").strip\nend", "def _comment\n\n _save = self.pos\n begin # sequence\n _tmp = match_string(\"#\")\n break unless _tmp\n while true # kleene\n\n _save1 = self.pos\n begin # sequence\n _save2 = self.pos\n _tmp = apply(:_eol)\n _tmp = !_tmp\n self.pos = _save2\n break unless _tmp\n _tmp = match_dot\n end while false\n unless _tmp\n self.pos = _save1\n end # end sequence\n\n break unless _tmp\n end\n _tmp = true # end kleene\n break unless _tmp\n _tmp = apply(:_eol)\n end while false\n unless _tmp\n self.pos = _save\n end # end sequence\n\n set_failed_rule :_comment unless _tmp\n return _tmp\n end", "def detect_comments(code,extension)\n flag=false\n case extension\n when \".rb\"\n if code[0] == \"#\"\n code = code[1..-1]\n flag = true\n end\n when \".js\"\n if code[0..1] == \"//\"\n code = code[2..-1]\n flag = true\n end\n when \".py\"\n if code[0] == \"#\"\n code = code[1..-1]\n flag = true\n end\n end\n return code,flag\nend", "def comment_sections\n @comment_sections ||= raw ? raw.split(\"\\n\\n\") : []\n end", "def restore_removed_comments(corrector, offense_range, node, first_child); end", "def associated_comment?(node, ast_with_comments)\n return false if ast_with_comments[node].empty?\n\n preceding_comment = ast_with_comments[node].last\n distance = node.loc.keyword.line - preceding_comment.loc.line\n return false if distance > 1\n\n !annotation?(preceding_comment)\n end", "def postprocess_comments(comment_lines)\n comment_lines.map! {|l| l.sub(/^\\s([^\\s])/, '\\\\1').rstrip }\n comment_lines.delete_at(0) while comment_lines.size > 0 && comment_lines[0].empty?\n comment_lines.delete_at(-1) while comment_lines.size > 0 && comment_lines[-1].empty?\n end", "def diff_to_compare; end", "def comment_threshold\n 40\n end" ]
[ "0.63363314", "0.6174508", "0.5982283", "0.59663063", "0.5859584", "0.5847983", "0.58178973", "0.58064544", "0.58064544", "0.5803391", "0.5803391", "0.5803391", "0.57457685", "0.5739237", "0.57106584", "0.56896263", "0.56792617", "0.56792617", "0.5666213", "0.56462944", "0.56380755", "0.5624397", "0.56164604", "0.56080806", "0.55726683", "0.5537753", "0.5524873", "0.55172163", "0.5499071", "0.54514885", "0.5394247", "0.5379943", "0.5367847", "0.5342573", "0.5318376", "0.53178114", "0.5296988", "0.5295586", "0.5293036", "0.52739054", "0.5273042", "0.5271635", "0.52677834", "0.5253353", "0.52516806", "0.5167924", "0.5131607", "0.5112652", "0.5106814", "0.51012814", "0.5092741", "0.5090437", "0.5085756", "0.5079417", "0.5077893", "0.50644326", "0.5062029", "0.50604737", "0.50594467", "0.50543964", "0.5046731", "0.5046731", "0.5046731", "0.5046731", "0.5046731", "0.504155", "0.50346696", "0.5019286", "0.5016942", "0.5012795", "0.50107574", "0.50095254", "0.5003233", "0.50007826", "0.4993956", "0.49909616", "0.49866855", "0.4977749", "0.4977749", "0.4977749", "0.49754107", "0.497159", "0.49611607", "0.49571595", "0.49497956", "0.49497956", "0.49497956", "0.49497956", "0.49497956", "0.49497956", "0.4946617", "0.4942746", "0.49376038", "0.49318743", "0.49303335", "0.49265534", "0.49223977", "0.49168548", "0.49085826", "0.49075112" ]
0.6715794
0
GET /badges GET /badges.json
def index @games = Game.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def badges\n get(\"user/#{user_id}/badges.json\")\n end", "def badges(id)\n get(\"users/#{id}/badges\")\n end", "def badges(user_id: '-')\n return get(\"#{API_URI}/#{PROFILE_API_VERSION}/user/#{user_id}/badges.json\")\n end", "def badges(options={})\n self.class.parse_badges(request(singular(user_id) + \"/badges\", options))\n end", "def full_badges\n client.user_badges(id)\n end", "def badges(options={})\n get('/user_badge', options)\n end", "def user_badges user_id=\"self\"\n response = get(\"/users/#{user_id}/badges\")[\"response\"]\n if response[\"sets\"] and response[\"sets\"][\"groups\"]\n response[\"sets\"][\"groups\"].map!{|group| Foursquared::Response::BadgeGroup.new(self, group)}\n end\n\n if response[\"badges\"]\n response[\"badges\"].each_key do |badge_id|\n response[\"badges\"][badge_id] = badge(badge_id)\n end\n end\n response\n end", "def badges_for_user(username)\n response = get \"v1/market/user-badges:#{username}.json\"\n response[:'user-badges']\n end", "def show\n @badge = Badge.find(params[:id])\n @users = @badge.users\n respond_with @badge\n end", "def badge\n if badge_id\n Merit::Badge.find(badge_id)\n else\n Merit::Badge.find_by_name_and_level(badge_name, level)\n end\n end", "def badges_url\n view_context.badges_url\n end", "def new\n @badge = Badge.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @badge }\n end\n end", "def new\n @badge = Badge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @badge }\n end\n end", "def parse_badges(result)\n parse_type(result, \"badge\")\n end", "def index\n @user_badges = UserBadge.where(active: true).where(user_id: params[:user_id])\n end", "def show\n @badge = Badge.find_by_key(params[:id])\n respond_to do |format|\n format.html\n end\n end", "def new_badges\n achievements.map(&:new_badges).flatten\n end", "def badges\n end", "def index\n session[:admin] = true\n @badges = Badge.order('approved_at desc,id')\n @fri_count = Badge.select { |b| b.friday? }.size\n @sat_count = Badge.select { |b| b.saturday? }.size\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @badges }\n end\n end", "def index\n @my_badges = current_account.my_badges \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @user_my_badges }\n end\n end", "def badge\n if @badge.nil?\n badges = Badge.by_name(badge_name)\n badges = badges.by_level(level) unless level.nil?\n @badge = badges.first\n end\n @badge\n end", "def index\n check_authorization\n #@badges = Badge.find(:all, :conditions => [\"organization_id = ? and segment_id = ?\", @organization.id, @segment.id ] )\n @badges = Badge.find(:all)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @badges }\n end\n end", "def parse_badges(badges)\n badges.map { |badge| create_new_badge(badge) } if badges\n end", "def index\n if current_user.admin?\n @badges = Badge.all\n else\n @badges = Badge.finished\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @badges }\n end\n end", "def show\n @badge = Badge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @badge }\n end\n \n rescue ActiveRecord::RecordNotFound\n logger.error \"Attempt to access invalid flag #{params[:id]}\"\n redirect_to root_path, notic: 'Invalid page'\n end", "def badges\n achievements.reduce({}) do |badges, achievement|\n badges.merge(achievement.name => achievement.badges)\n end\n end", "def show\n @badge = Badge.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @badge }\n end\n end", "def [](level)\n raise ArgumentError unless valid?(level)\n\n @badges ||= {}\n @badges[level] ||= new(level)\n end", "def showbadge\n authorize! :read, Operator\n @operator = Operator.find_by_badge(params[:badge])\n if @operator\n render json: @operator, except: :badge\n else\n render json: {error: ['Cannot find user']}, status: :unprocessable_entity\n end\n end", "def set_badge\n @badge = Badge.find(params[:id])\n end", "def get_project_vulnerabilities_badge1_with_http_info(uuid, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BadgeApi.get_project_vulnerabilities_badge1 ...'\n end\n # verify the required parameter 'uuid' is set\n if @api_client.config.client_side_validation && uuid.nil?\n fail ArgumentError, \"Missing the required parameter 'uuid' when calling BadgeApi.get_project_vulnerabilities_badge1\"\n end\n # resource path\n local_var_path = '/v1/badge/vulns/project/{uuid}'.sub('{' + 'uuid' + '}', CGI.escape(uuid.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(['image/svg+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] || 'ProjectMetrics' \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: BadgeApi#get_project_vulnerabilities_badge1\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create\n @badge = Badge.new(params[:badge])\n\n respond_to do |format|\n if @badge.save\n format.html { redirect_to @badge, :notice => 'Badge was successfully created.' }\n format.json { render :json => @badge, :status => :created, :location => @badge }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @badge.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_badges(badge)\n @badges = {}\n badge.split(',').each do |_badge|\n type, value = _badge.split '/'\n @badges[type] = value.to_i\n end\n end", "def update\n respond_to do |format|\n if @badge.update(badge_params)\n format.html { redirect_to @badge, notice: 'Badge was successfully updated.' }\n format.json { render :show, status: :ok, location: @badge }\n else\n format.html { render :edit }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end", "def fetch_badge_from_params\n badge = nil\n\n params.permit(:badge_name)\n if params[:badge_name].nil?\n params.require(:badge_id)\n badge = Badge.find_by(id: params[:badge_id], enabled: true)\n else\n badge = Badge.find_by(name: params[:badge_name], enabled: true)\n end\n raise Discourse::NotFound if badge.blank?\n\n badge\n end", "def add_badge(badge_id)\n badges = JSON.parse(self.badges)\n badges[\"#{badge_id}\"][\"earned\"] = true\n badges[\"#{badge_id}\"][\"earn_date\"] = Date.current\n self.update(badges: badges.to_json)\n end", "def set_badge\n @badge = Badge.find(params[:id])\n end", "def set_badge\n @badge = Badge.find(params[:id])\n end", "def set_badge\n @badge = Badge.find(params[:id])\n end", "def badges\n Merit::Badge.find { |b| b.custom_fields[:skill_level] == self.name_key.to_sym }\n end", "def set_badge\n @badge = Badge.find(params[:id])\n end", "def earned(badge_id)\n badges = JSON.parse(self.badges)\n badges[\"#{badge_id}\"][\"earned\"]\n end", "def index\n @pledges = Pledge.where('user_id = ?', current_user.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pledges }\n end\n end", "def update\n @badge = Badge.find(params[:id])\n\n respond_to do |format|\n if @badge.update_attributes(params[:badge])\n format.html { redirect_to @badge, notice: 'Badge was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n respond_to do |format|\n format.html { render_template } # index.html.erb\n format.xml { render xml: @badges }\n end\n end", "def create\n @badge = Badge.new(params[:badge])\n \n\n respond_to do |format|\n if @badge.save\n format.html { redirect_to @badge, notice: 'Badge was successfully created.' }\n format.json { render json: @badge, status: :created, location: @badge }\n else\n format.html { render action: \"new\" }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @honey_badgers = HoneyBadger.all\n respond_to do |format|\n format.html\n format.json { render json: @honey_badgers }\n end\n end", "def badges_count\n badges.count\n end", "def new\n @badge = Badge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @badge }\n end\n end", "def get_project_vulnerabilities_badge_with_http_info(name, version, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BadgeApi.get_project_vulnerabilities_badge ...'\n end\n # verify the required parameter 'name' is set\n if @api_client.config.client_side_validation && name.nil?\n fail ArgumentError, \"Missing the required parameter 'name' when calling BadgeApi.get_project_vulnerabilities_badge\"\n end\n # verify the required parameter 'version' is set\n if @api_client.config.client_side_validation && version.nil?\n fail ArgumentError, \"Missing the required parameter 'version' when calling BadgeApi.get_project_vulnerabilities_badge\"\n end\n # resource path\n local_var_path = '/v1/badge/vulns/project/{name}/{version}'.sub('{' + 'name' + '}', CGI.escape(name.to_s)).sub('{' + 'version' + '}', CGI.escape(version.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(['image/svg+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] || 'ProjectMetrics' \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: BadgeApi#get_project_vulnerabilities_badge\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def badges_version_list_with_http_info(owner, repo, package_format, package_name, package_version, package_identifiers, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: BadgesApi.badges_version_list ...\"\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 BadgesApi.badges_version_list\"\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 BadgesApi.badges_version_list\"\n end\n # verify the required parameter 'package_format' is set\n if @api_client.config.client_side_validation && package_format.nil?\n fail ArgumentError, \"Missing the required parameter 'package_format' when calling BadgesApi.badges_version_list\"\n end\n # verify the required parameter 'package_name' is set\n if @api_client.config.client_side_validation && package_name.nil?\n fail ArgumentError, \"Missing the required parameter 'package_name' when calling BadgesApi.badges_version_list\"\n end\n # verify the required parameter 'package_version' is set\n if @api_client.config.client_side_validation && package_version.nil?\n fail ArgumentError, \"Missing the required parameter 'package_version' when calling BadgesApi.badges_version_list\"\n end\n # verify the required parameter 'package_identifiers' is set\n if @api_client.config.client_side_validation && package_identifiers.nil?\n fail ArgumentError, \"Missing the required parameter 'package_identifiers' when calling BadgesApi.badges_version_list\"\n end\n # resource path\n local_var_path = \"/badges/version/{owner}/{repo}/{package_format}/{package_name}/{package_version}/{package_identifiers}/\".sub('{' + 'owner' + '}', owner.to_s).sub('{' + 'repo' + '}', repo.to_s).sub('{' + 'package_format' + '}', package_format.to_s).sub('{' + 'package_name' + '}', package_name.to_s).sub('{' + 'package_version' + '}', package_version.to_s).sub('{' + 'package_identifiers' + '}', package_identifiers.to_s)\n\n # query parameters\n query_params = {}\n query_params[:'badge_token'] = opts[:'badge_token'] if !opts[:'badge_token'].nil?\n query_params[:'cacheSeconds'] = opts[:'cache_seconds'] if !opts[:'cache_seconds'].nil?\n query_params[:'color'] = opts[:'color'] if !opts[:'color'].nil?\n query_params[:'label'] = opts[:'label'] if !opts[:'label'].nil?\n query_params[:'labelColor'] = opts[:'label_color'] if !opts[:'label_color'].nil?\n query_params[:'logoColor'] = opts[:'logo_color'] if !opts[:'logo_color'].nil?\n query_params[:'logoWidth'] = opts[:'logo_width'] if !opts[:'logo_width'].nil?\n query_params[:'render'] = opts[:'render'] if !opts[:'render'].nil?\n query_params[:'shields'] = opts[:'shields'] if !opts[:'shields'].nil?\n query_params[:'show_latest'] = opts[:'show_latest'] if !opts[:'show_latest'].nil?\n query_params[:'style'] = opts[:'style'] if !opts[:'style'].nil?\n\n # header parameters\n header_params = {}\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['apikey']\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 if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BadgesApi#badges_version_list\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to badges_url }\n format.json { head :no_content }\n end\n end", "def for_badge(badge); end", "def get_project_vulnerabilities_badge1(uuid, opts = {})\n data, _status_code, _headers = get_project_vulnerabilities_badge1_with_http_info(uuid, opts)\n data\n end", "def index\n @badge_projects = BadgeProject.all\n end", "def craft_badge(badge_page_url)\n appid = badge_page_url.split('/').last\n uid = badge_page_url.split('/')[4]\n # TODO, figure out what the series and border_color parameters mean.\n # for now set them to the observed values of 1,0\n sessionid = URI.decode(@c.cookie_manager.cookies.select{|i| i.match?(URI(\"https://steamcommunity.com\")) && i.name == \"sessionid\"}.first.value)\n body = {\n appid: appid,\n series: 1,\n border_color: 0,\n sessionid: sessionid\n }\n res = @c.post(\"http://steamcommunity.com/id/#{uid}/ajaxcraftbadge/\", body, {Referer: badge_page_url, Origin: \"http://steamcommunity.com\"}) rescue nil\n res && res.code == 200\n end", "def add_winner_badges\n\t\trespond_to do |format|\n\t\t\tformat.json{\n\t\t\t\tscrimage = Scrimage.find(params[:scrimage_id])\n\n\t\t\t\tmaxVotes = scrimage.photos.maximum(\"votes\")\n\n\t\t\t\twinningPhotoIDs = scrimage.photos.where(\"votes = ?\", maxVotes)\n\n\t\t\t\tscrimage.winner_id = winningPhotoIDs.first.id\n\t\t\t\t\n\t\t\t\tscrimage.save()\n\n\t\t\t\twinningPhotoIDs.each do |photoID|\n\t\t\t\t\tphoto = Photo.find(photoID)\n\t\t\t\t\tnotification = Notification.new(:user_id => photo.user_id, :message => \"100 Points Awarded - You won the scrimage with your photo, \"+photo.description+\"!\")\n\n\t\t\t\t\t#Ensures that all winners receive points for their winning photos\n\t\t\t\t\tuser = User.find(photo.user_id)\n\t\t\t\t\tuser.update(points: user.points + 100)\n\n\t\t\t\t\tnotification.save()\n\t\t\t\tend\n\n\t\t\t\t#render :json => {:winningPhotoID => winningPhotoIDs} \n\t\t\t\trender :json => {:html => render_to_string({:partial => \"scrimages/displayChildPhotos\", :formats => [:html, :js], :locals => {:scrimage => scrimage, :layout => false}})}\n \t\t\t}\t\t\t\n \t\tend\n\tend", "def show\n @gauge = Gauge.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gauge }\n end\n end", "def show\n @grumble = Grumble.find(params[:id])\n render status: 200, json: @grumble.to_json\n end", "def destroy\n @badge.destroy\n respond_to do |format|\n format.html { redirect_to badges_url, notice: 'Badge was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def get_badge\n swimmer.badges.for_season(@season).first if swimmer.badges.for_season(@season).exists?\n end", "def add_badge!( badge, update_badge = true )\n unless @badges.include?( badge )\n @badges << badge\n badge.add_user!( self, false) if update_badge\n end\n return @badges\n end", "def show\n @account = current_account\n @my_badges = current_account.my_badges\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @account }\n end\n end", "def badge; end", "def get_badge(subject, status, color = 'blue', options = {})\n st = status.gsub(/-/, '--').gsub(/_/, '__')\n res = \"https://img.shields.io/badge/#{subject}-#{st}-#{color}.svg\"\n res += \"?style=#{options[:style]}\" if options[:style]\n res\n end", "def destroy\n @my_badge = User::MyBadge.find(params[:id])\n @my_badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_my_badges_url) }\n format.xml { head :ok }\n end\n end", "def print_user_badges(user_data)\n puts \"-\" * 70\n puts \"Badge Name\".ljust(60) + \"Date\".ljust(10)\n puts \"-\" * 70\n\n # loop through all badges and format the date into something readable\n user_data[\"badges\"].each do |badge|\n puts badge[\"name\"].slice(0, 60).ljust(60) + badge[\"earned_date\"].slice(0, 10).split(\"-\").join(\"/\").ljust(10)\n end\n\n puts \"-\" * 70\nend", "def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(badges_url) }\n format.xml { head :ok }\n end\n end", "def award_badges!(new_badges)\n return true if new_badges.empty?\n if !new_badges.first.is_a?(Badge)\n new_badges = Badge.find(:all, :conditions => [\"ref IN (?)\", new_badges])\n end\n self.badges += (new_badges - self.badges)\n end", "def update\n respond_to do |format|\n if @badge.update(badge_params)\n format.html { redirect_to([:admin, @badge], notice: 'Badge was successfully updated.') }\n format.xml { head :ok }\n website.add_log(user: current_user, action: \"Updated badge: #{@badge.name}\")\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @badge.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_user\n id = params[:slug] || params[:id]\n @user = User.find(id)\n @badges = @user.badges.group_by(&:level)\n end", "def deli_tags(uri, id)\n begin\n md5 = Digest::MD5.hexdigest(uri)\n target = \"http://badges.del.icio.us/feeds/json/url/data?hash=#{md5}\"\n json = open(target).read\n deli = JSON.load(json)[0]\n tags = \"\"\n if deli['top_tags'].class == Hash then\n all_tags = deli['top_tags'].sort_by {|k,v| v}.reverse.map{|i|i[0]}\n if all_tags.size > 8 then\n all_tags = all_tags.first(8) << '...'\n end\n tags = '(' << all_tags.join(', ') << ')'\n end\n if deli['total_posts'].to_i > 0 then\n response = \"#{id}: (deli) #{deli['total_posts']} links, tagged #{tags}\"\n $q_meta.enq response\n end\n rescue\n puts \"problem fetching deli for #{uri}\"\n end\nend", "def show\n authorize @badge\n @staff = User.where(role: 'staff', school: current_user.school)\n @awarded_badge = AwardedBadge.where(user: current_user, badge: @badge).first\n end", "def update\n @badge = Badge.find(params[:id])\n respond_to do |format|\n if @badge.update_attributes(params[:badge])\n flash[:notice] = 'Badge was successfully updated.'\n format.html { redirect_to organization_segment_badge_url(@organization,@segment, @badge) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @badge.errors, :status => :unprocessable_entity }\n end\n end\n end", "def show\n @user = User.find(params[:id])\n unless @user.uuid == current_user.uuid\n unless current_user.rels(dir: :outgoing, type: :visits, between: @user).blank?\n rel = current_user.rels(dir: :outgoing, type: :visits, between: @user)\n rel[0].count = rel[0].count + 1\n rel[0].save!\n else\n rel = Visit.new\n rel.from_node = current_user\n rel.to_node = @user\n rel.count = 1\n rel.save!\n end\n current_user.save!\n end\n #@b = current_user.badges(:u, :r).where( uuid: @user.uuid ).pluck(:r)\n #@badges = @b.map {|b| b.badgeType}.uniq\n @uniq_badges = @user.rels(dir: :incoming, type: :badges).each.map {|r| r.badgeType}.uniq\n @all_badges = {}\n @uniq_badges.each do |badge|\n @all_badges[badge] = @user.rels(dir: :incoming, type: :badges).each.select{|r| r.badgeType == badge }.count\n end\n @my_badges = []\n @badges_count = @user.rels(dir: :incoming, type: \"badges\").count\n if current_user.uuid != @user.uuid\n current_user.rels(dir: :outgoing, type: :badges, between: @user).each do |r|\n #current_user.badges(:u, :r).where( uuid: @user.uuid ).each_with_rel do |u, r| \n @my_badges << r[:badgeType]\n end\n end\n @pictures = @user.pictures\n @testimonials = @user.testimonials\n\n unless @user.uuid == current_user.uuid\n @like = current_user.rels(dir: :outgoing, type: :likes, between: @user).blank? ? true : false\n end\n @likes_count = @user.rels(dir: :incoming, type: \"likes\").count\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user }\n end\n end", "def update\n get_my_badge\n respond_to do |format|\n if @my_badge.update_attributes(params[:my_badge])\n flash[:notice] = 'Your badge was successfully updated.'\n format.html { redirect_to user_my_badge_url(@my_badge) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @my_badge.errors, :status => :unprocessable_entity }\n end\n end\n end", "def set_admin_badge\n @badge = Badge.find(params[:id])\n end", "def set_users_badge\n @users_badge = UsersBadge.find(params[:id])\n end", "def index\n @badge_categories = BadgeCategory.all\n end", "def find_bridges(params={}, headers=default_headers)\n @logger.info(\"Find Bridges.\")\n get(\"#{@api_url}/bridges\", params, headers)\n end", "def badge(*args)\n badge_label(:badge, *args)\n end", "def show\n @badge = Badge.find(params[:id])\n if not @badge.finished? and not current_user.admin?\n redirect_to home_url\n return\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @badge }\n end\n end", "def get_project_vulnerabilities_badge(name, version, opts = {})\n data, _status_code, _headers = get_project_vulnerabilities_badge_with_http_info(name, version, opts)\n data\n end", "def index_by_user\n @gifts = @current_user.gifts\n render json: @gifts, include: :ages, status: :ok\n end", "def has_badge?(badge)\n case badge\n when Badge\n badges.find_by_id(badge.id)\n when Fixnum\n badges.find_by_id(badge)\n when String\n badges.find_by_name(badge)\n end\n end", "def set_badge\n @badge = Badge.friendly.find(params[:id])\n authorize @badge\n end", "def index\n @bulletins = Bulletin.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bulletins }\n end\n end", "def create\n @user_badge = UserBadge.new(user_badge_params)\n @user_badge.active = true\n @user_badge.user_id = @user.id\n\n respond_to do |format|\n if @user_badge.save\n format.html { redirect_to team_user_path(@team, @user), notice: 'User badge was successfully created.' }\n format.json { render :show, status: :created, location: @user_badge }\n else\n format.html { render :new }\n format.json { render json: @user_badge.errors, status: :unprocessable_entity }\n end\n end\n end", "def groups\n response[\"groups\"].map!{|group| Foursquared::Response::BadgeGroup.new(client, group)}\n end", "def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(organization_segment_badges_url) }\n format.xml { head :ok }\n end\n end", "def index\n @bounties = Bounty.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @bounties }\n end\n end", "def show\n @gage = Gage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gage }\n end\n end", "def crear_achievement badge, id_app\n description = badge[\"description\"].encode(\"UTF-8\")\n \n body = {\n name:badge[\"name\"],\n imageUrl:badge[\"imageUrl\"],\n unique: true,\n criteriaUrl: badge[\"criteriaUrl\"],\n earnerDescription: description,\n consumerDescription: description ,\n criteria: badge[\"criteria\"],\n type: 'Badge'\n }\n status 201\n \n response = signed_post_request @@API_ROOT+\"/issuers/#{id_app}/badges\", body\n\n end", "def create\n @badge = Badge.new(params[:badge])\n\n respond_to do |format|\n if @badge.save\n flash[:notice] = 'Badge was successfully created.'\n format.html { redirect_to organization_segment_badge_url(@organization, @segment, @badge) }\n format.xml { render :xml => @badge, :status => :created, :location => @badge }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @badge.errors, :status => :unprocessable_entity }\n end\n end\n end", "def badges(league_id, player_id)\n # get players\n players = player_ids league_id\n badges = Hash.new { |h, k| h[k] = [] }\n all_games = game_ids(league_id)\n\n # tournament hack\n # badges[399] << badge('🏆', 'New Bags Champs') #adam\n # badges[453] << badge('🏆', 'Jan 18th Champs') #james\n # badges[397] << badge('🥈', 'New Bags 2nd Place') #greg\n # badges[319] << badge('🥈', 'Jan 18th - 2nd Place') #mike\n # badges[449] << badge('🥉', 'New Bags 3rd Place') #kirk\n # badges[21] << badge('🥉', 'Jan 18th - 3rd Place') #randall\n\n # plays a lot\n # players.each do |p|\n # badges[p] << badge('⚽', 'Determined') if games_this_week(p, league_id) > 50\n # end\n\n # fire badge\n # best daily change\n best_change = players.group_by { |p| daily_elo_change(p, league_id) }.max\n best_change.last.each { |b| badges[b] << badge('🔥', 'On Fire') } if !best_change.nil? && best_change.first >= 10\n\n # poop badge\n # worst daily change\n worst_change = players.group_by { |p| daily_elo_change(p, league_id) }.min\n worst_change.last.each { |b| badges[b] << badge('💩', 'Rough Day') } if !worst_change.nil? && worst_change.first <= -10\n\n # baby badge\n # 10-15 games played\n babies = players.select do |p|\n games_with_player(p, league_id, 20).length.between?(10, 15)\n end\n babies.each { |b| badges[b] << badge('👶🏼', 'Newly Ranked') } unless all_games.length < 100 || babies.nil?\n\n # monkey badge\n # won last game but elo went down\n # flexing badge\n # won last game and gained 10+ elo\n players.select do |p|\n games = games_with_player(p, league_id, 1)\n next if games.empty?\n last_game = api_game(games.first, league_id)\n winner = last_game[:teams][0][:players].any? { |a| a[:playerID] == p }\n badges[p] << badge('🙈', 'Monkey\\'d') if last_game[:teams][0][:delta] < 0 && winner\n badges[p] << badge('🍌', 'Graceful Loss') if last_game[:teams][0][:delta] < 0 && !winner\n badges[p] << badge('💪🏼', 'Hefty Win') if last_game[:teams][0][:delta] >= 10 && winner\n badges[p] << badge('🤕', 'Hospital Bound') if last_game[:teams][0][:delta] >= 10 && !winner\n end\n\n # toilet badge\n # last skunk (lost w/ 0 points)\n toilet_game = all_games.find do |g|\n (api_game(g, league_id)[:teams][1][:score]).zero?\n end\n toilets = api_game(toilet_game, league_id)[:teams][1][:players] if toilet_game\n toilets.each { |b| badges[b[:playerID]] << badge('🚽', 'Get Rekt') } unless toilets.nil?\n\n # win streak badges\n # 5 and 10 current win streak\n win_streaks = {}\n players.each do |p|\n games = games_with_player(p, league_id, 20)\n last_wins = games.take_while do |g|\n game = api_game(g, league_id)\n game[:teams][0][:players].any? { |a| a[:playerID] == p }\n end\n win_streaks[p] = last_wins.length\n end\n\n win_streaks.each do |p, s|\n badges[p] << badge(\"#{s}⃣\", \"#{s}-Win Streak\") if s.between?(3, 9)\n badges[p] << badge('💰', \"#{s}-Win Streak\") if s.between?(10, 19)\n badges[p] << badge('👑', '20+ Win Streak') if s >= 20\n end\n\n # zzz badge\n # hasn't played a game in 2 weeks\n if league_id == 1\n sleepers = players.select do |p|\n player_snoozin(p, league_id)\n end\n sleepers.each { |b| badges[b] << badge('💤', 'Snoozin\\'') }\n end\n\n # nemesis and ally badges\n if player_id > 0\n nemeses = []\n allies = []\n you = api_player(player_id, true, league_id)\n players.each do |p|\n this_player = api_player(p, false, league_id)\n nemeses << p if this_player[:displayName] == you[:nemesis]\n allies << p if this_player[:displayName] == you[:ally]\n end\n nemeses.each { |b| badges[b] << badge('😈', 'Your Nemesis') }\n allies.each { |b| badges[b] << badge('😇', 'Your Ally') }\n end\n\n # build hash\n badges.collect do |k, v|\n {\n playerID: k,\n badges: v\n }\n end\nend", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @my_badge }\n end\n end", "def index_by_age\n @age = Age.find(params[:age_id])\n @gifts = @age.gifts\n render json: @gifts, include: :ages, status: :ok\n end", "def destroy\n @badge.destroy\n respond_to do |format|\n format.html { redirect_to(admin_badges_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted badge: #{@badge.name}\")\n end", "def badge_status(user)\n if user.badges.select {|b| b.is_a?(self)}.empty?\n 0\n else\n current = user.badges.select {|b| b.is_a?(self)}\n current.map {|b| b.level }.max\n end\n end", "def create\n @badge = Badge.new(badge_params)\n\n respond_to do |format|\n if @badge.save\n format.html { redirect_to camera_badge_url(@badge) }\n format.json { render :show, status: :created, location: @badge }\n else\n format.html { render :new }\n format.json { render json: @badge.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @gig = Gig.find(params[:id])\n\n respond_to do |format|\n format.html {render json: @gig, status: :ok}\n format.json { render json: @gig, status: :ok }\n end\n end" ]
[ "0.87536204", "0.8055727", "0.77719414", "0.7684046", "0.7552645", "0.74981487", "0.72334045", "0.713744", "0.6892226", "0.6846787", "0.68157053", "0.67125493", "0.6708214", "0.66353303", "0.6620842", "0.65226746", "0.65138704", "0.65126044", "0.64497757", "0.64222705", "0.64106536", "0.635823", "0.62924683", "0.6273773", "0.62725466", "0.62656295", "0.6235476", "0.6195654", "0.61740935", "0.6155067", "0.61525774", "0.61186314", "0.6105596", "0.6099875", "0.6096209", "0.6088213", "0.6073157", "0.6073157", "0.6073157", "0.60581434", "0.60561234", "0.6042051", "0.60328007", "0.59734064", "0.59592044", "0.59441566", "0.591913", "0.590683", "0.58962727", "0.5875432", "0.5829649", "0.5795253", "0.57810074", "0.5759281", "0.57560474", "0.5750335", "0.57153004", "0.56846154", "0.5663383", "0.5635906", "0.5634315", "0.5616956", "0.5611611", "0.55962306", "0.55699575", "0.5569489", "0.5563023", "0.5552466", "0.5540932", "0.55363655", "0.5519765", "0.5518963", "0.55136585", "0.55120516", "0.549805", "0.5495785", "0.5493924", "0.5480595", "0.54685146", "0.5468514", "0.5466773", "0.54643273", "0.54636425", "0.54580474", "0.54548484", "0.54493254", "0.5449124", "0.54477215", "0.5445182", "0.5443289", "0.5433538", "0.542523", "0.5417255", "0.54161364", "0.5413117", "0.5408175", "0.5394159", "0.5393672", "0.5384924", "0.53827083", "0.53800684" ]
0.0
-1
DELETE /badges/1 DELETE /badges/1.json
def destroy @game.destroy respond_to do |format| format.html { redirect_to admin_users_path(@admin), notice: 'Game was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to badges_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @badge.destroy\n respond_to do |format|\n format.html { redirect_to badges_url, notice: 'Badge was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(badges_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @badge = Badge.find(params[:id])\n @badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(organization_segment_badges_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @badge.destroy\n respond_to do |format|\n format.html { redirect_to(admin_badges_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted badge: #{@badge.name}\")\n end", "def destroy\n @my_badge = User::MyBadge.find(params[:id])\n @my_badge.destroy\n\n respond_to do |format|\n format.html { redirect_to(user_my_badges_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @gauge = Gauge.find(params[:id])\n @gauge.destroy\n\n respond_to do |format|\n format.html { redirect_to gauges_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @meritbadge = Meritbadge.find(params[:id])\n @meritbadge.destroy\n\n respond_to do |format|\n format.html { redirect_to(meritbadges_url) }\n format.xml { head :ok }\n end\n end", "def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end", "def destroy\n @badge_category.destroy\n respond_to do |format|\n format.html { redirect_to badge_categories_url, notice: 'Badge category was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @green = Green.find(params[:id])\n @green.destroy\n\n respond_to do |format|\n format.html { redirect_to scaffold_greens_url }\n format.json { head :ok }\n end\n end", "def destroy\n @badge_project.destroy\n respond_to do |format|\n format.html { redirect_to badge_projects_url, notice: 'Badge project was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @achievement.destroy\n\n respond_to do |format|\n format.html { redirect_to achievements_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Post.delete(params[\"id\"])\n end", "def destroy\n @bounty.destroy\n respond_to do |format|\n format.html { redirect_to bounties_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @Growth = Growth.find(params[:id])\n begin\n if(@Growth.destroy)\n render :json =>'Successfully'\n end\n rescue => e\n render :json => \"#{e}\", :status => :unprocessable_entity\n end\n end", "def destroy\n @hoge = Hoge.find(params[:id])\n @hoge.destroy\n\n respond_to do |format|\n format.html { redirect_to hoges_url }\n format.json { head :ok }\n end\n end", "def destroy\n @hit = Hit.find(params[:id])\n @hit.reactions.destroy_all\n @hit.destroy\n\n respond_to do |format|\n format.html { redirect_to hits_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @honey_badger.destroy\n respond_to do |format|\n format.html { redirect_to honey_badgers_url, notice: 'Honey badger was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @grumble.destroy\n respond_to do |format|\n format.html { redirect_to grumbles_url, notice: 'Grumble was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @gig = Gig.find(params[:id])\n @gig.destroy\n\n respond_to do |format|\n format.html { redirect_to gigs_url }\n format.json { render json: nil, status: :ok }\n end\n end", "def destroy\n @gig_request = GigRequest.find(params[:id])\n @gig_request.destroy\n\n respond_to do |format|\n format.html { redirect_to gig_requests_url }\n format.json { head :no_content }\n end\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def destroy\n @lounge.destroy\n respond_to do |format|\n format.html { redirect_to lounges_url, notice: 'Lounge was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @achievement.destroy\n respond_to do |format|\n format.html { redirect_to achievements_url, notice: 'Achievement was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @achievement.destroy\n respond_to do |format|\n format.html { redirect_to achievements_url, notice: 'Achievement was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @garply.destroy\n respond_to do |format|\n format.html { redirect_to garplies_url, notice: 'Garply was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @gage = Gage.find(params[:id])\n @gage.destroy\n\n respond_to do |format|\n format.html { redirect_to gages_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Item.delete(params[\"id\"])\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def incident_delete(statuspage_id, incident_id)\n data = {}\n data['statuspage_id'] = statuspage_id\n data['incident_id'] = incident_id\n\n request :method => :post,\n :url => @url + 'incident/delete',\n :payload => data\n end", "def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end", "def destroy\n @health.destroy\n respond_to do |format|\n format.html { redirect_to \"/dashboard\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @manage_glow.destroy\n respond_to do |format|\n format.html { redirect_to manage_glows_url }\n format.json { head :no_content }\n end\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @bgimage = Bgimage.find(params[:id])\n @bgimage.destroy\n\n respond_to do |format|\n format.html { redirect_to bgimages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gastracker = Gastracker.find(params[:id])\n @gastracker.destroy\n\n respond_to do |format|\n format.html { redirect_to gastrackers_url }\n format.json { head :no_content }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def destroy\n @healthpro.destroy\n respond_to do |format|\n format.html { redirect_to root_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @goody = Goody.find(params[:id])\n @goody.destroy\n\n respond_to do |format|\n format.html { redirect_to goodies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @heartbeat = Heartbeat.find(params[:id])\n @heartbeat.destroy\n\n respond_to do |format|\n format.html { redirect_to heartbeats_url }\n format.json { head :no_content }\n end\n end", "def delete\n request(:delete)\n end", "def delete(id:)\n id_check(:id, id)\n\n cf_delete(path: \"/organizations/#{org_id}/railguns/#{id}\")\n end", "def destroy\n @nudge.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @achievement = Achievement.find(params[:id])\n @achievement.destroy\n\n respond_to do |format|\n format.html { redirect_to(achievements_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @house = House.find(params[:id])\n @house.destroy\n\n respond_to do |format|\n format.html { redirect_to gigs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @health.destroy\n respond_to do |format|\n format.html { redirect_to healths_url, notice: 'Health was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @pushbullet.destroy\n respond_to do |format|\n format.html { redirect_to pushbullets_url, notice: 'Pushbullet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @bundle = Bundle.find(params[:id])\n @bundle.destroy\n\n respond_to do |format|\n format.html { redirect_to bundles_url }\n format.json { head :ok }\n end\n end", "def destroy\n @damage = Damage.find(params[:id])\n @damage.destroy\n\n respond_to do |format|\n format.html { redirect_to damages_url }\n format.json { head :ok }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @gist.destroy\n respond_to do |format|\n format.html { redirect_to gists_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @great.destroy\n respond_to do |format|\n format.html { redirect_to greats_url, notice: 'Great was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @banner_img = BannerImg.find(params[:id])\n @banner_img.destroy\n\n respond_to do |format|\n format.html { redirect_to banner_imgs_url }\n format.json { head :no_content }\n end\n end", "def delete\n api_client.delete(url)\n end", "def destroy\n @bulletin = Bulletin.find(params[:id])\n @bulletin.destroy\n\n respond_to do |format|\n format.html { redirect_to bulletins_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @gitem = Gitem.find(params[:id])\n @gitem.destroy\n\n respond_to do |format|\n format.html { redirect_to gitems_url }\n format.json { head :ok }\n end\n end", "def destroy\n @ambush = Ambush.find(params[:id])\n @ambush.destroy\n\n respond_to do |format|\n format.html { redirect_to ambushes_url }\n format.json { head :ok }\n end\n end", "def destroy\n @bird.destroy\n \n begin\n respond_to do |format|\n format.json { render json:({:status => NO_CONTENT}) }\n end\n else\n render json: ({:status => INTERNAL_SERVER_ERROR})\n end\n end", "def destroy\n # sorry but not delete is not allow\n #@bundle = Bundle.find(params[:id])\n #@bundle.destroy\n\n respond_to do |format|\n format.html { redirect_to bundles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @health_level.destroy\n\n respond_to do |format|\n format.html { redirect_to health_levels_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @baggage = Baggage.find(params[:id])\n @baggage.destroy\n\n respond_to do |format|\n format.html { redirect_to baggages_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @goofball.destroy\n respond_to do |format|\n format.html { redirect_to goofballs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @fridge = Fridge.find(params[:id])\n @fridge.destroy\n\n respond_to do |format|\n format.html { redirect_to fridges_url }\n format.json { head :no_content }\n end\n end", "def delete(id)\n Mailgun.submit :delete, webhook_url(id)\n end", "def destroy\n @gpath = Gpath.find(params[:id])\n @gpath.destroy\n\n respond_to do |format|\n format.html { redirect_to gpaths_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lodging.destroy\n respond_to do |format|\n format.html { redirect_to lodgings_url, notice: 'Lodging was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end", "def destroy\n @lodging.destroy\n respond_to do |format|\n format.html { redirect_to lodgings_url, notice: \"Lodging was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @graveyard.destroy\n respond_to do |format|\n format.html { redirect_to graveyards_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @graveyard.destroy\n respond_to do |format|\n format.html { redirect_to graveyards_url }\n format.json { head :no_content }\n end\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def destroy\n @achievementuser = Achievementuser.find(params[:id])\n @achievementuser.destroy\n\n respond_to do |format|\n format.html { redirect_to achievementusers_url }\n format.json { head :no_content }\n end\n end", "def delete!\n request! :delete\n end", "def destroy\n @allergy.destroy\n respond_to do |format|\n format.html { redirect_to allergies_url, notice: t('allergies.destroy_success') }\n format.json { head :no_content }\n end\n end", "def delete\n render json: UserBoards.delete(params[\"id\"])\n end", "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def destroy\n if @hit.destroy\n flash[:notice] = 'Batida apagada com sucesso.'\n else\n flash[:error] = @hit.errors[:base].to_sentence\n end\n respond_to do |format|\n format.html { redirect_to hits_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @svgpost = Svgpost.find(params[:id])\n @svgpost.destroy\n\n respond_to do |format|\n format.html { redirect_to svgposts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @redpack = Redpack.find(params[:id])\n @redpack.destroy\n\n respond_to do |format|\n format.html { redirect_to redpacks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lodge = Lodge.find(params[:id])\n @lodge.destroy\n\n respond_to do |format|\n format.html { redirect_to lodges_url }\n format.json { head :ok }\n end\n end", "def destroy\n @gameroom = Gameroom.find(params[:id])\n if @gameroom.destroy\n render json: @gameroom, status: :accepted\n else\n render json: {errors: @gameroom.errors.full_messages}, status: :unprocessable_entity\n end\n end", "def destroy\n @gig.destroy\n respond_to do |format|\n format.html { redirect_to gigs_url, notice: 'Gig was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @gig.destroy\n respond_to do |format|\n format.html { redirect_to gigs_url, notice: \"Gig was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @gig_request.destroy\n respond_to do |format|\n format.html { redirect_to gig_requests_url, notice: 'Gig request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @bg_check.destroy\n respond_to do |format|\n format.html { redirect_to bg_checks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @refugee.destroy\n respond_to do |format|\n format.html { redirect_to refugees_url, notice: 'Refugee was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @gauge_graph.destroy\n respond_to do |format|\n format.html { redirect_to gauge_graphs_url, notice: 'Gauge graph was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @objective = Objective.find(params[:id])\n @objective.destroy\n render json: @objective \n end", "def delete!( opts = {} )\n http_action :delete, nil, opts\n end", "def delete\n item = FormImage.last\n id = item[:id]\n item.destroy\n render json: {id: id}\n end", "def destroy\n @zombie = Zombie.find(params[:id])\n @zombie.destroy\n\n respond_to do |format|\n format.html { redirect_to zombies_url }\n format.json { head :ok }\n end\n end", "def destroy\n @jam_circle.destroy\n respond_to do |format|\n format.html { redirect_to jam_circles_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.79502434", "0.77699876", "0.77665925", "0.7672124", "0.7605875", "0.7516433", "0.6969911", "0.69289273", "0.672313", "0.6656472", "0.6632456", "0.6632145", "0.6627479", "0.6593265", "0.6510939", "0.6510934", "0.6457726", "0.6455014", "0.64465874", "0.64278996", "0.64102", "0.64083827", "0.6406901", "0.64001524", "0.6389876", "0.63861734", "0.63806427", "0.63806427", "0.6379187", "0.63681567", "0.63677776", "0.6336664", "0.6325039", "0.6321368", "0.6318935", "0.6314145", "0.6304823", "0.6302139", "0.6301903", "0.62800735", "0.62800735", "0.62800735", "0.62800735", "0.62743515", "0.62719846", "0.62667614", "0.62611747", "0.62584746", "0.62424797", "0.6240955", "0.62332505", "0.62306887", "0.6229575", "0.6226957", "0.6223555", "0.6222969", "0.6219217", "0.62168264", "0.62127906", "0.62079555", "0.6205152", "0.61951", "0.6193821", "0.6191628", "0.6190929", "0.6190202", "0.61894494", "0.6185097", "0.6172951", "0.6169974", "0.6163108", "0.61621505", "0.6160528", "0.61600226", "0.61570966", "0.61570966", "0.6154453", "0.6154107", "0.61524326", "0.6151817", "0.61510295", "0.6141516", "0.61372876", "0.6135885", "0.6127459", "0.6126588", "0.6125471", "0.6125106", "0.6123951", "0.61226577", "0.6120961", "0.6118042", "0.6113678", "0.6093759", "0.60884273", "0.60873675", "0.60859466", "0.6085851", "0.60852593", "0.6083005", "0.60815006" ]
0.0
-1
Use callbacks to share common setup or constraints between actions.
def set_game @game = game.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 badge_params params[:user].permit(:name, :badge, :admin_id) 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 valid_params_request?; end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n 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 safe_params\n params.require(:user).permit(:name)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\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 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 url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "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 valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def active_code_params\n params[:active_code].permit\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\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 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 filter_parameters; end", "def filter_parameters; end", "def list_params\n params.permit(:name)\n 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 admin_social_network_params\n params.require(:social_network).permit!\n end", "def url_whitelist; end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def filter_params\n params.require(:filters).permit(:letters)\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 user_params\n params.permit(:name, :age, :username, :display_photo, :password)\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 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.69802505", "0.6781974", "0.67470175", "0.67430073", "0.67350477", "0.6593221", "0.6504263", "0.64988977", "0.6481794", "0.64800006", "0.64568025", "0.64411247", "0.6379476", "0.63765615", "0.6368045", "0.6320141", "0.6300363", "0.6300057", "0.62952244", "0.6294712", "0.6293856", "0.6290323", "0.62816143", "0.6241851", "0.6241208", "0.622036", "0.62128764", "0.62110275", "0.61966056", "0.61776453", "0.617547", "0.6174961", "0.61654735", "0.6153256", "0.61516005", "0.6149498", "0.6123234", "0.6118653", "0.61077267", "0.61061186", "0.6093616", "0.608318", "0.6074428", "0.60650206", "0.60244286", "0.6020295", "0.60155797", "0.6012826", "0.6010141", "0.6010141", "0.60037106", "0.600298", "0.59979576", "0.5994806", "0.5994283", "0.5993927", "0.5980616", "0.59667075", "0.59614897", "0.59610957", "0.596071", "0.5959614", "0.59554", "0.59542966", "0.5946781", "0.5940262", "0.5940262", "0.59401053", "0.5937168", "0.5932135", "0.59293395", "0.592659", "0.59202623", "0.59112674", "0.59088206", "0.590716", "0.59056735", "0.589997", "0.5899655", "0.5898926", "0.5896042", "0.589589", "0.5895867", "0.58894163", "0.5884936", "0.5879227", "0.58740723", "0.5871364", "0.5870148", "0.5869228", "0.5868196", "0.5867967", "0.5865532", "0.58653617", "0.58644646", "0.58631665", "0.5862611", "0.5857609", "0.58558804", "0.5853729", "0.5853025" ]
0.0
-1
HTTParty raises an errors after time limit defined by ::default_timeout if it cannot connect to server, then it raises Net::OpenTimeout if it cannot read response from server, then it raises Net::ReadTimeout
def handle_timeouts yield rescue Net::OpenTimeout, Net::ReadTimeout {} end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def http_get(url)\n response = HTTParty.get(url)\n\n puts url\n\n if response.key?('errorMessage')\n puts 'error, retry...'\n begin\n http_get(url)\n rescue Net::ReadTimeout\n puts 'takes too long to respond, retry...'\n http_get(url)\n end\n else\n puts 'no error, return'\n response\n end\nend", "def http_timeout; end", "def test_connect_timeout_get\n connect_timeout = $config[\"nginx\"][\"proxy_connect_timeout\"]\n read_timeout = $config[\"nginx\"][\"proxy_read_timeout\"]\n delay = connect_timeout + 2\n assert_operator(delay, :<, read_timeout)\n\n response = Typhoeus.get(\"http://127.0.0.1:9080/api/delay-sec/#{delay}\", http_options)\n assert_response_code(200, response)\n assert_operator(response.total_time, :>, connect_timeout - BUFFER_TIME_LOWER)\n end", "def timeout_wrap(&block)\n ::Timeout.timeout(timeout, &block)\n rescue ::Timeout::Error\n failure(:RPC_FAILED, \"The server took longer than #{timeout} seconds to respond\")\n end", "def error_timeout; end", "def request_timeout(type, options); end", "def http_timeout=(_arg0); end", "def connect_to_server(path = '/', timeout = MAX_TIMEOUT)\n begin\n Net::HTTP.start('127.0.0.1', 9201) do |http|\n http.read_timeout = timeout\n return(http.get(path))\n end\n rescue Errno::ECONNREFUSED => error\n return unless ((timeout -= 1) > 0)\n sleep(1)\n retry\n end\n end", "def configure_timeout(options, env)\n req = request_options(env)\n options[:inactivity_timeout] = request_timeout(:read, req)\n options[:connect_timeout] = request_timeout(:open, req)\n end", "def connect_timeout; end", "def connect_timeout; end", "def http_With_Timeout(url)\n begin\n Timeout::timeout(5) do\n return JSON.parse(Net::HTTP.get(URI(url)))\n end\n rescue Timeout::Error\n return false\n end\n end", "def timeout\n time = time_ago_in_words(@timeout.seconds.from_now)\n logger.warn(\"Response: Parse Error. Retry in #{time}\")\n\n sleep(@timeout)\n @timeout *= 2 if @timeout < TIMEOUT_UPPER_CAP\n end", "def apiFetch(url) \n\n retries = 10\n\n begin\n Timeout::timeout(150){\n open(url) do |f|\n \treturn f.read\t\n end\n }\n rescue Timeout::Error\n retries -= 1\n if (retries >= 0) then\n \t puts \"open uri request fail, sleep 4 sec, retry #{10-retries} of 10\"\n sleep 4 and retry\n else\n raise\n end\n\n \t\trescue\n \tputs \"Connection failed: #{$!}\\n\"\n \n \tend\n \nend", "def handle_timeout\n err = \"No response from server: Timed out connecting to server. Server is either down or connection is slow.\"\n redirect_to root_path, flash: { error: err }\n end", "def safe_timeout(conn, meth, name)\n Timeout.timeout(5) { conn.send(meth) }\n true\nrescue Timeout::Error\n $stderr.puts \"Timed out waiting to close #{name} connection\"\n false\nrescue Exception => ex\n $stderr.puts(\"#{ex.class}: #{ex.message}\")\n false\nend", "def request_with_timeout(req)\n params = {\n timeout: opts[:connect_timeout],\n retry_exceptions: [Errno::ECONNREFUSED],\n log: self.log,\n }\n Ncio::Support::RetryAction.retry_action(params) do\n connection.request(req)\n end\n end", "def test_no_request_retry_when_timeout_between_varnish_and_nginx_timeout\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=post-between-varnish-timeout\")\n assert_response_code(200, response)\n assert_equal(\"0\", response.body)\n\n response = Typhoeus.get(\"http://127.0.0.1:9080/api/between-varnish-timeout\", http_options)\n assert_response_code(504, response)\n\n # Ensure that the backend has only been called once.\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=post-between-varnish-timeout\")\n assert_response_code(200, response)\n assert_equal(\"1\", response.body)\n\n # Wait 5 seconds for any possible retry attempts that might be pending, and\n # then ensure the backend has still only been called once.\n sleep 5\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=post-between-varnish-timeout\")\n assert_response_code(200, response)\n assert_equal(\"1\", response.body)\n end", "def read_timeout; end", "def read_timeout; end", "def read_timeout; end", "def read_timeout; end", "def read_timeout; end", "def read_timeout; end", "def read_timeout; end", "def read_timeout; end", "def test_no_request_retry_get\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=get-timeout\")\n assert_response_code(200, response)\n assert_equal(\"0\", response.body)\n\n response = Typhoeus.get(\"http://127.0.0.1:9080/api/timeout\", http_options)\n assert_response_code(504, response)\n\n # Ensure that the backend has only been called once.\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=get-timeout\")\n assert_response_code(200, response)\n assert_equal(\"1\", response.body)\n\n # Wait 5 seconds for any possible retry attempts that might be pending, and\n # then ensure the backend has still only been called once.\n sleep 5\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=get-timeout\")\n assert_response_code(200, response)\n assert_equal(\"1\", response.body)\n end", "def failsafe_timeout\n super\n end", "def def_read_timeout\n 10\n end", "def def_read_timeout\n 10\n end", "def tcp_timeout\n super\n end", "def timeout(seconds, &block)\n Timeout.timeout seconds, Pinglish::TooLong, &block\n end", "def read_timeout=(sec); end", "def timeout(*args, &blk)\n (@client ||= connect).timeout(*args, &blk)\n end", "def test_no_request_retry_when_timeout_between_layer_timeouts\n start_delay = $config[\"nginx\"][\"proxy_connect_timeout\"] - 1\n end_delay = $config[\"nginx\"][\"proxy_read_timeout\"] * 2\n assert_operator(start_delay, :>, 0)\n assert_operator(start_delay, :<, end_delay)\n\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=#{unique_test_id}\")\n assert_response_code(200, response)\n assert_equal(\"0\", response.body)\n\n hydra = Typhoeus::Hydra.new\n requests = []\n delay = start_delay\n while delay <= end_delay\n request = Typhoeus::Request.new(\"http://127.0.0.1:9080/api/delay-sec/#{delay}?backend_counter_id=#{unique_test_id}\", http_options)\n hydra.queue(request)\n\n requests << {\n :request => request,\n :delay => delay,\n }\n\n delay += 0.5\n end\n hydra.run\n\n timeout_count = 0\n ok_count = 0\n either_count = 0\n requests.each do |req|\n if req.fetch(:delay) > $config[\"nginx\"][\"proxy_read_timeout\"] + 1\n timeout_count += 1\n assert_response_code(504, req.fetch(:request).response)\n assert_match(\"Inactivity Timeout\", req.fetch(:request).response.body)\n elsif req.fetch(:delay) < $config[\"nginx\"][\"proxy_read_timeout\"]\n ok_count += 1\n assert_response_code(200, req.fetch(:request).response)\n else\n # For requests in the vicinity of the timeout, either a timeout or an\n # ok response may happen due to various timing edge cases.\n either_count += 1\n end\n end\n\n assert_operator(timeout_count, :>=, 6)\n assert_operator(ok_count, :>=, 6)\n assert_operator(either_count, :>=, 3)\n assert_operator(either_count, :<=, 6)\n\n # Ensure that the backend has only been called once for each test.\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=#{unique_test_id}\")\n assert_response_code(200, response)\n assert_equal(requests.length.to_s, response.body)\n\n # Wait 5 seconds for any possible retry attempts that might be pending, and\n # then ensure the backend has still only been called once.\n sleep 5\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=#{unique_test_id}\")\n assert_response_code(200, response)\n assert_equal(requests.length.to_s, response.body)\n end", "def test_url_timeout(url, timeout)\n uri = URI(url)\n begin\n timeout(timeout) do\n s = TCPSocket.new(uri.host, uri.port)\n s.close\n end\n rescue Timeout::Error, SocketError\n return false\n end\n return true\n end", "def request_timeout()\n @req_timeout\n end", "def test_no_request_retry_get\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=get-timeout\")\n assert_response_code(200, response)\n assert_equal(\"0\", response.body)\n\n response = Typhoeus.get(\"http://127.0.0.1:9080/api/delay-sec/20?backend_counter_id=get-timeout\", http_options)\n assert_response_code(504, response)\n assert_match(\"Inactivity Timeout\", response.body)\n\n # Ensure that the backend has only been called once.\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=get-timeout\")\n assert_response_code(200, response)\n assert_equal(\"1\", response.body)\n\n # Wait 5 seconds for any possible retry attempts that might be pending, and\n # then ensure the backend has still only been called once.\n sleep 5\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=get-timeout\")\n assert_response_code(200, response)\n assert_equal(\"1\", response.body)\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 read_timeout=(read_timeout); end", "def http_timeout\n t = if ENV['EDS_TIMEOUT'].present?\n ENV['EDS_TIMEOUT'].to_f\n else\n 6\n end\n (t / 3)\n end", "def server_timeout\n get_configuration 'server_timeout', @config\n rescue\n 60\n end", "def tcp_socket_request\n Timeout.timeout(request_timeout) do\n s = TCPSocket.new(host, port)\n s.close\n end\n rescue Errno::ECONNREFUSED => e\n addl_message = \"#{host} is not accepting connections on port #{port}: \"\n raise ConnectionFailed, addl_message + e.message\n rescue SocketError => e\n addl_message = \"connection to #{host} on port #{port} failed with '#{e.message}': \"\n raise ConnectionFailed, addl_message + e.message\n rescue Timeout::Error => e\n addl_message = \"#{host} did not respond on port #{port} within #{request_timeout} seconds: \"\n raise ConnectionFailed, addl_message + e.message\n rescue => e\n raise ConnectionFailed, e\n end", "def client_timeout\n # Store the target and error in the blacklist.\n if @conf[:use_blacklist]\n blacklist_entry = @current_target.to_s\n @conf[:blacklist][blacklist_entry] = [408, \"Client Timeout\", nil, :client_timeout]\n ::EM.add_timer(@conf[:blacklist_time]) { @conf[:blacklist].delete blacklist_entry }\n end\n\n try_next_target 408, \"Client Timeout\", nil, :client_timeout\n end", "def connect_timeout=(_arg0); end", "def with_timeout(timeout, &block)\n block.call\n rescue IO::WaitReadable => e\n if IO::select([self], nil, nil, timeout)\n retry\n else\n fail Aerospike::Exceptions::Connection, \"Socket timeout: #{e}\"\n end\n rescue IO::WaitWritable => e\n if IO::select(nil, [self], nil, timeout)\n retry\n else\n fail Aerospike::Exceptions::Connection, \"Socket timeout: #{e}\"\n end\n rescue => e\n raise Aerospike::Exceptions::Connection, \"Socket error: #{e}\"\n end", "def default_timeout\n 3\n end", "def open_timeout; end", "def open_timeout; end", "def open_timeout; end", "def open_timeout; end", "def timeout\n configuration[:timeout] || DEFAULT_TIMEOUT\n end", "def timeout\n configuration[:timeout] || DEFAULT_TIMEOUT\n end", "def timeouts_set; end", "def safe_get(uri, event_host)\n # Handle connection timeouts\n response = nil\n begin\n connection = Faraday.new(uri)\n response = connection.get do |req|\n req.options[:timeout] = options[:read_timeout]\n req.options[:open_timeout] = options[:open_timeout]\n end\n rescue => e\n report(:host => event_host,\n :service => \"resmon\",\n :state => \"critical\",\n :description => \"HTTP connection error: #{e.class} - #{e.message}\"\n )\n end\n response\n end", "def timeout_http_request(params = nil)\n if @name_index\n @conf.insert(@name_index + @conf.length, \" \" + \"timeout http-request \" + params.to_s + \"\\n\")\n else\n puts \"no #{@proxy_type} name assigned\"\n return false\n end\n end", "def test_connect_timeout\n conn = nil\n EM.run do\n conn = EM.connect '192.0.2.0', 80, StubConnection\n conn.pending_connect_timeout = 1\n end\n assert_equal Errno::ETIMEDOUT, conn.error\n end", "def do_alive_check(id, auth, info_url)\n response = HTTParty.get(info_url, timeout: TIMEOUT, basic_auth: auth)\n send_service_response(id, response)\nrescue HTTParty::ResponseError, Errno::ECONNREFUSED => e\n send_text_status(id, 'Dead', moreinfo: e.message, danger: true)\n [false, e]\nrescue StandardError => e\n send_text_status(id, 'Indeterminate', moreinfo: e.message, fatal: true)\n [false, e]\nend", "def default_timeout\n 60\n end", "def http_client\n client = HTTPClient.new\n client.connect_timeout = 20 # 20 seconds\n client.receive_timeout = 20 # 20 seconds\n client\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 server_close_timeout\n super\n end", "def test_idle_timeout_server_no_open\n s = TCPServer.new(0)\n cont = Container.new(__method__)\n cont.connect(\":#{s.addr[1]}\", {:idle_timeout => 0.1, :handler => ExceptionMessagingHandler.new })\n ex = assert_raises(Qpid::Proton::Condition) { cont.run }\n assert_match(/resource-limit-exceeded/, ex.to_s)\n ensure\n s.close if s\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 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 open_timeout=(open_timeout); end", "def error_threshold_timeout; end", "def timed_out\n response['timed_out']\n end", "def http_get(uri_string, headers={}, limit = 10, open_timeout=15, read_timeout=15)\n\n #@task_result.logger.log \"http_get Connecting to #{uri}\" if @task_result\n response = nil\n begin\n\n attempts=0\n max_attempts=10\n user_agent=\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36\"\n found = false\n\n uri = URI.parse uri_string\n\n until( found || attempts >= max_attempts)\n #@task_result.logger.log \"Getting #{uri}, attempt #{attempts}\" if @task_result\n attempts+=1\n\n http = Net::HTTP.new(uri.host,uri.port)\n http.read_timeout = 10\n http.open_timeout = 10\n\n path = uri.path\n path = \"/\" if path==\"\"\n\n #request = Net::HTTP::Get.new(path,{'User-Agent'=>user_agent})\n if uri.instance_of? URI::HTTPS\n http.use_ssl=true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n response = http.get(path)\n\n if response.code==\"200\"\n break\n end\n\n if (response.header['location']!=nil)\n newuri=URI.parse(response.header['location'])\n if(newuri.relative?)\n #@task_result.logger.log \"url was relative\" if @task_result\n newuri=uri+response.header['location']\n end\n uri=newuri\n\n else\n found=true #resp was 404, etc\n end #end if location\n end #until\n\n ### TODO - this code may be be called outside the context of a task,\n ### meaning @task_result is not available to it. Below, we check to\n ### make sure that it exists before attempting to log anything,\n ### but there may be a cleaner way to do this (hopefully?). Maybe a\n ### global logger or logging queue?\n ###\n #rescue TypeError\n # # https://github.com/jaimeiniesta/metainspector/issues/125\n # @task_result.logger.log_error \"TypeError - unknown failure\" if @task_result\n rescue Net::OpenTimeout => e\n @task_result.logger.log_error \"Timeout : #{e}\" if @task_result\n rescue Net::ReadTimeout => e\n @task_result.logger.log_error \"Timeout : #{e}\" if @task_result\n rescue URI::InvalidURIError => e\n #\n # XXX - This is an issue. We should catch this and ensure it's not\n # due to an underscore / other acceptable character in the URI\n # http://stackoverflow.com/questions/5208851/is-there-a-workaround-to-open-urls-containing-underscores-in-ruby\n #\n @task_result.logger.log_error \"Unable to request URI: #{uri} #{e}\" if @task_result\n rescue OpenSSL::SSL::SSLError => e\n @task_result.logger.log_error \"SSL connect error : #{e}\" if @task_result\n rescue Errno::ECONNREFUSED => e\n @task_result.logger.log_error \"Unable to connect: #{e}\" if @task_result\n rescue Errno::ECONNRESET => e\n @task_result.logger.log_error \"Unable to connect: #{e}\" if @task_result\n rescue Net::HTTPBadResponse => e\n @task_result.logger.log_error \"Unable to connect: #{e}\" if @task_result\n rescue Zlib::BufError => e\n @task_result.logger.log_error \"Unable to connect: #{e}\" if @task_result\n rescue Zlib::DataError => e # \"incorrect header check - may be specific to ruby 2.0\"\n @task_result.logger.log_error \"Unable to connect: #{e}\" if @task_result\n rescue EOFError => e\n @task_result.logger.log_error \"Unable to connect: #{e}\" if @task_result\n rescue SocketError => e\n @task_result.logger.log_error \"Unable to connect: #{e}\" if @task_result\n #rescue SystemCallError => e\n # @task_result.logger.log_error \"Unable to connect: #{e}\" if @task_result\n #rescue ArgumentError => e\n # @task_result.logger.log_error \"Argument Error: #{e}\" if @task_result\n rescue Encoding::InvalidByteSequenceError => e\n @task_result.logger.log_error \"Encoding error: #{e}\" if @task_result\n rescue Encoding::UndefinedConversionError => e\n @task_result.logger.log_error \"Encoding error: #{e}\" if @task_result\n end\n\n response\n end", "def negotiate!(socket, timeout); end", "def timeout(*args, &block)\n Timeout::timeout(*args, &block)\n rescue Timeout::Error\n :timeout\n end", "def connect_timeout\n @connect_timeout\n end", "def setconnectiontimeout(timeout)\r\n setvalue(@@CONNECTION_TIMEOUT, timeout)\r\n end", "def initialize\n @timeouts = {\n write: 5,\n connect: 5,\n read: 5\n }\n end", "def test_idle_timeout_client\n server = ServerContainerThread.new(\"#{__method__}.server\", {:idle_timeout => 0.1})\n client_handler = Class.new(ExceptionMessagingHandler) do\n def initialize() @ready, @block = Queue.new, Queue.new; end\n attr_reader :ready, :block\n def on_connection_open(c)\n @ready.push nil # Tell the main thread we are now open\n @block.pop # Block the client so the server will time it out\n end\n end.new\n\n client = Container.new(nil, \"#{__method__}.client\")\n client.connect(server.url, {:handler => client_handler})\n client_thread = Thread.new { client.run }\n client_handler.ready.pop # Wait till the client has connected\n server.join # Exits when the connection closes from idle-timeout\n client_handler.block.push nil # Unblock the client\n ex = assert_raises(Qpid::Proton::Condition) { client_thread.join }\n assert_match(/resource-limit-exceeded/, ex.to_s)\n end", "def api_timeout\n @@api_timeout\n end", "def request_timed_out(exception)\n data = error('request_timedout', 'request uncompleted in time.', format_exception(exception))\n [408, hdrs(content_length: data_size(data)), [data]]\n end", "def response\n payload\n rescue Net::OpenTimeout => e\n Rails.logger.debug(e)\n end", "def default_timeout\n 900\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 timed_out?\n @exception.class == TimeoutError\n end", "def check_connection\n one_wait = 5\n max_wait = 5\n request = Net::HTTP::Get.new('/')\n wait = 0;\n while (wait < max_wait)\n begin\n response = Net::HTTP.start(@url.host, @url.port) {|http|\n http.request(request)\n }\n break if Net::HTTPForbidden === response\n break if Net::HTTPNotFound === response\n break if Net::HTTPSuccess === response\n # When we try to connect to a down server with an Apache proxy, \n # we'll get Net::HTTPBadGateway and get here\n rescue Errno::ECONNREFUSED\n # When we try to connect to a down server without an Apache proxy, \n # such as a dev instance, we'll get here\n end\n sleep one_wait;\n wait += one_wait\n end\n if (wait == max_wait)\n puts(\"-- ERROR: couldn't connect to test host on \" + @url.host.to_s)\n return false\n end\n puts(\"-- SUCCESS: test host is alive !\\n\")\n return true\nend", "def timedout_read(duration)\n begin \n timeout(duration) do\n @sock.wait_readable\n end\n rescue Celluloid::TaskTimeout\n return true\n end\n false\n end", "def timed_out\n response['timed_out']\n end", "def http_request(original_uri, params)\n max_iterations = 60\n iterations = 0\n response = nil\n while iterations < max_iterations do\n begin\n @https_client.with_https_connection(original_uri.host, original_uri.port, original_uri.path, query: original_uri.query) do |conn, uri|\n conn.open_timeout = params[:open_timeout] ? params[:open_timeout] : 4 * 60\n conn.read_timeout = params[:read_timeout] ? params[:read_timeout] : 4 * 60\n if params[:request]\n request = params[:request].new(uri, params[:headers])\n else\n request = Net::HTTP::Get.new uri.request_uri\n end\n if params[:body]\n request.body = params[:body]\n end\n puts \"Request: \" + request.method + \" \" + request.uri.to_s\n response = conn.request(request)\n end\n break\n rescue Errno::ECONNREFUSED, Errno::EADDRNOTAVAIL\n puts \"Error: #{$!}, url=#{original_uri}\"\n if iterations == max_iterations - 1\n puts(\"Request failed after #{max_iterations} attempts: #{$!}, url=#{original_uri}\")\n raise\n else\n sleep 1\n end\n end\n iterations += 1\n end\n #puts \"Response: #{response.inspect}\"\n response\n end", "def backoff response\n # backoff when server isn't persisting connection\n sleep CNXN_SLEEP_TIME if (! @http.started?)\n # Response-based sleep time\n sleep_time = 0\n case response\n when Net::HTTPSuccess then return # 2xx\n when Net::HTTPRedirection then return # 3xx\n when Net::HTTPBadRequest then sleep_time = 10 # 400 (rate limit, probably)\n when Net::HTTPUnauthorized then sleep_time = 0 # 401 (protected user, probably)\n when Net::HTTPForbidden then sleep_time = 10 # 403 update limit\n when Net::HTTPNotFound then sleep_time = 0 # 404 deleted or suspended\n when Net::HTTPServiceUnavailable then sleep_time = 10 # 503 Fail Whale\n when Net::HTTPServerError then sleep_time = 2 # 5xx All other server errors\n else sleep_time = 1\n end\n sleep_time += response['retry-after'].to_i rescue 0\n Log.warn \"Received #{response.code} and retry-after #{response['retry-after']}, sleeping #{sleep_time} ('#{response.message[0..200].gsub(%r{[\\r\\n\\t]}, \" \")}' from #{@host}+#{@connection_opened_at}): '#{response.body[0..200].gsub(%r{[\\r\\n\\t]}, \" \")}'\"\n sleep sleep_time\n end", "def read_timeout=(_arg0); end", "def read_timeout=(_arg0); end", "def read_timeout=(_arg0); end", "def def_write_timeout\n 10\n end", "def timeout!; end", "def timeouts_exceeded\n @reactor.log(:warn, \"#{self.class}, Client exceeded allowable [#{@max_broker_timeouts}] timeout failures; reopening socket to Broker!\")\n\n # active requests that haven't timed out & failed will still have the old\n # client ID; we need to restart those requests with the new ID\n @broker_timeouts = 0\n reopen_broker_connection\n end", "def timeout; end", "def timeout; end", "def timeout; end", "def get_embedded_http_server_timeout\n if timeout = ENV['EMBEDDED_HTTP_SERVER_TIMEOUT']\n puts \"EMBEDDED_HTTP_SERVER_TIMEOUT=#{timeout}\"\n timeout.to_i\n else\n 4\n end\nend", "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 test_no_request_retry_post\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=post-timeout\")\n assert_response_code(200, response)\n assert_equal(\"0\", response.body)\n\n response = Typhoeus.post(\"http://127.0.0.1:9080/api/timeout\", http_options)\n assert_response_code(504, response)\n\n # Ensure that the backend has only been called once.\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=post-timeout\")\n assert_response_code(200, response)\n assert_equal(\"1\", response.body)\n\n # Wait 5 seconds for any possible retry attempts that might be pending, and\n # then ensure the backend has still only been called once.\n sleep 5\n response = Typhoeus.get(\"http://127.0.0.1:9442/backend_call_count?id=post-timeout\")\n assert_response_code(200, response)\n assert_equal(\"1\", response.body)\n end", "def default_timeout_class; end", "def client_close_timeout\n super\n end" ]
[ "0.7373712", "0.72976816", "0.6759297", "0.67525446", "0.66723037", "0.66665757", "0.66437876", "0.6566575", "0.65500784", "0.65281385", "0.65281385", "0.6470986", "0.64634985", "0.64576036", "0.64485043", "0.6425141", "0.6394152", "0.63933957", "0.6325352", "0.6325352", "0.6325352", "0.6325352", "0.6325352", "0.6325352", "0.6325352", "0.6325352", "0.63147324", "0.63123596", "0.6305668", "0.6305668", "0.6280772", "0.6272043", "0.6270748", "0.625349", "0.6252982", "0.6209563", "0.6206477", "0.61945844", "0.61648655", "0.61505777", "0.6131962", "0.6127389", "0.6116533", "0.6112762", "0.61047894", "0.6103355", "0.6100033", "0.608457", "0.608457", "0.608457", "0.608457", "0.60842323", "0.60842323", "0.6081568", "0.60813254", "0.6072161", "0.6053156", "0.60499793", "0.60485893", "0.604049", "0.6036504", "0.60364443", "0.6012748", "0.6008639", "0.60025334", "0.59974855", "0.5985026", "0.5971729", "0.5969434", "0.5967183", "0.5945507", "0.59451914", "0.59394056", "0.5928241", "0.5919569", "0.5917309", "0.591691", "0.5916315", "0.59139264", "0.5911875", "0.5909623", "0.5895506", "0.58908516", "0.58885753", "0.58851", "0.5884637", "0.5879654", "0.5879654", "0.5879654", "0.5877919", "0.58778435", "0.5876402", "0.5875573", "0.5875573", "0.5875573", "0.58568925", "0.5846041", "0.5845928", "0.5843243", "0.5834582" ]
0.7299478
1
Resize the image to fit within the specified dimensions while retaining the aspect ratio of the original image. If necessary, crop the image in the larger dimension. Possible values for options[:gravity] are: NorthWest, North, NorthEast, West, Center, East, SouthWest, South, SouthEast
def resize(path) gravity = @options.key?(:gravity) ? @options[:gravity] : 'Center' img = MiniMagick::Image.open(@file) cols, rows = img[:dimensions] img.combine_options do |cmd| if @width != cols || @height != rows scale_x = @width/cols.to_f scale_y = @height/rows.to_f if scale_x >= scale_y cols = (scale_x * (cols + 0.5)).round rows = (scale_x * (rows + 0.5)).round cmd.resize "#{cols}" else cols = (scale_y * (cols + 0.5)).round rows = (scale_y * (rows + 0.5)).round cmd.resize "x#{rows}" end end cmd.quality @options[:quality] if @options.key?(:quality) cmd.gravity gravity cmd.background 'rgba(255,255,255,0.0)' cmd.extent "#{@width}x#{@height}" if cols != @width || rows != @height end img.write(path) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cut_to_fit(options)\n %Q{-thumbnail #{options.width}x#{options.height}^ \\\n -gravity #{options.gravity} \\\n -unsharp 0x.5 \\\n -auto-orient \\\n -extent #{options.width}x#{options.height}}\n end", "def resize_with_crop(w, h, options = {})\n gravity = options[:gravity] || :center\n\n w_original, h_original = [img[:width].to_f, img[:height].to_f]\n\n op_resize = ''\n\n # check proportions\n if w_original * h < h_original * w\n op_resize = \"#{w.to_i}x\"\n w_result = w\n h_result = (h_original * w / w_original)\n else\n op_resize = \"x#{h.to_i}\"\n w_result = (w_original * h / h_original)\n h_result = h\n end\n\n w_offset, h_offset = crop_offsets_by_gravity(gravity, [w_result, h_result], [ w, h])\n\n img.combine_options do |i|\n i.resize(op_resize)\n i.gravity(gravity)\n i.crop \"#{w.to_i}x#{h.to_i}+#{w_offset}+#{h_offset}!\"\n end\n\n img\n end", "def resize!(options)\n options = options.symbolize_keys\n raise ArgumentError, ':size must be included in resize options' unless options[:size]\n\n # load image\n img = rmagick_image.dup\n\n # Find dimensions\n x, y = size_to_xy(options[:size])\n\n # prevent upscaling unless :usample param exists.\n unless options[:upsample]\n x = img.columns if x > img.columns\n y = img.rows if y > img.rows\n end\n\n # Perform image resize\n case\n when options[:crop] && !options[:crop].is_a?(Hash) && img.respond_to?(:crop_resized!)\n # perform resize and crop\n scale_and_crop(img, [x, y], options[:offset])\n when options[:stretch]\n # stretch the image, ignoring aspect ratio\n stretch(img, [x, y]) \n else\n # perform the resize without crop\n scale(img, [x, y]) \n end\n\n if options[:format]\n img.format = options[:format].to_s.upcase\n img.strip!\n end\n\n options[:quality] ? img.to_blob { self.quality = options[:quality].to_i } : img.to_blob\n end", "def resize_to_fill(width, height, gravity=::Magick::CenterGravity)\n width = dimension_from width\n height = dimension_from height\n manipulate! do |img|\n img.crop_resized!(width, height, gravity)\n img = yield(img) if block_given?\n img\n end\n end", "def resize_to_fill!(image, width, height, gravity: \"Center\")\n with_minimagick(image) do |img|\n img.combine_options do |cmd|\n yield cmd if block_given?\n cmd.resize \"#{width}x#{height}^\"\n cmd.gravity gravity\n cmd.background \"rgba(255,255,255,0.0)\" # transparent\n cmd.extent \"#{width}x#{height}\"\n end\n end\n end", "def resize_image(image, options = {})\n processor = ::RedArtisan::CoreImage::Processor.new(image)\n size = options[:size]\n size = size.first if size.is_a?(Array) && size.length == 1\n if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))\n if size.is_a?(Fixnum)\n processor.fit(size)\n else\n processor.resize(size[0], size[1])\n end\n else\n new_size = get_image_size(image) / size.to_s\n processor.resize(new_size[0], new_size[1])\n end\n \n destination = options[:to] || @file\n AttachmentFu::Pixels::Image.new destination do |img|\n processor.render do |result|\n img.width, img.height = get_image_size(result)\n result.save destination, OSX::NSJPEGFileType\n end\n end\n end", "def resize_to_fit!(image, width, height)\n with_minimagick(image) do |img|\n img.combine_options do |cmd|\n yield cmd if block_given?\n cmd.resize \"#{width}x#{height}\"\n end\n end\n end", "def resize_to_fit(width, height)\n manipulate! do |image|\n resize_image image, width, height\n end\n self\n end", "def resize_to_fill(width, height, gravity = 'Center')\n manipulate! do |img|\n cols, rows = img.dimensions[:x].to_i, img.dimensions[:y].to_i\n opt={}\n if width != cols || height != rows\n scale = [width/cols.to_f, height/rows.to_f].max\n cols = (scale * (cols + 0.5)).round\n rows = (scale * (rows + 0.5)).round\n opt[:resize] = \"#{cols}x#{rows}\"\n end\n opt[:gravity] = gravity\n opt[:background] = \"rgba(255,255,255,0.0)\"\n opt[:extent] = \"#{width}x#{height}\" if cols != width || rows != height\n img.manipulate!(opt)\n img = yield(img) if block_given?\n img\n end\n end", "def resize_to_limit!(image, width, height)\n with_minimagick(image) do |img|\n img.combine_options do |cmd|\n yield cmd if block_given?\n cmd.resize \"#{width}x#{height}>\"\n end\n end\n end", "def resize!(*args)\n width, height = Geometry.new(*args).dimensions\n resize(\"#{width}x#{height}^\").crop(width, height).repage\n end", "def scale_to_fit(width, height)\n @image = @image.scale_to_fit(width, height)\n self\n end", "def resize_and_optimize(width, height)\n manipulate! do |img|\n img.format(\"jpg\") do |c|\n c.quality \"70\"\n c.resize \"#{width}x#{height}\"\n end\n\n img\n end\n end", "def resize\n @image.resize \"#{@placement[:a]}x#{OUTER}\\!\"\n end", "def fit\n if self.needs_to_be_resized?\n rmagick_img.resize_to_fit!(@x, @y)\n else\n rmagick_img.resize_to_fit(@x, @y)\n end\n end", "def resize_to_fit(new_width, new_height)\n manipulate! do |image|\n resize_image(image,new_width,new_height)\n end\n end", "def resize_to_fit(new_width, new_height)\n manipulate! do |image|\n resize_image(image,new_width,new_height)\n end\n end", "def resize_to_fill(width, height, gravity = 'Center')\n manipulate! do |img|\n img.resize(\"#{width}x#{height}^\")\n \t.gravity(gravity)\n \t.background(\"rgba(255,255,255,0.0)\")\n \t.extent(\"#{width}x#{height}\")\n img = yield(img) if block_given?\n img\n end\n end", "def crop_to_fit(width, height)\n @image = @image.crop_to_fit(width, height)\n self\n end", "def resize_to_limit(width, height)\n width = dimension_from width\n height = dimension_from height\n manipulate! do |img|\n geometry = Magick::Geometry.new(width, height, 0, 0, Magick::GreaterGeometry)\n new_img = img.change_geometry(geometry) do |new_width, new_height|\n img.resize(new_width, new_height)\n end\n destroy_image(img)\n new_img = yield(new_img) if block_given?\n new_img\n end\n end", "def resize_to_fit width, height\n process :resize_to_fit => [width, height]\n end", "def cut\n rmagick_img.crop_resized!(@x, @y, gravity)\n end", "def strict_resize image, w, h\n image.resize \"#{ w }x#{ h }!\"\n image\n end", "def resize_to_limit(width, height)\n manipulate! do |image|\n image = resize_image(image, width, height) if width < image.x_size || height < image.y_size\n image\n end\n self\n end", "def resize_to(width, height); end", "def resize(width, height); end", "def create_resized_image\n create_image do |xfrm|\n if size\n MiniMagick::Tool::Convert.new do |cmd|\n cmd << xfrm.path # input\n cmd.flatten\n cmd.resize(size)\n cmd << xfrm.path # output\n end\n end\n end\n end", "def resize_to_limit(new_width, new_height)\n manipulate! do |image|\n image = resize_image(image,new_width,new_height) if new_width < image.x_size || new_height < image.y_size\n image\n end\n end", "def resize_to_fit width, height\n manipulate! do |image|\n cols = image.width\n rows = image.height\n\n if width != cols or height != rows\n scale = [width/cols.to_f, height/rows.to_f].min\n cols = (scale * (cols + 0.5)).round\n rows = (scale * (rows + 0.5)).round\n image.resize cols, rows do |img|\n yield(img) if block_given?\n img.save current_path\n end\n end\n end\n end", "def resizeImage(width,height)\n if @image != nil\n @image.resize(width,height)\n @image.applyOn(@imageBox)\n end\n end", "def resize_image\n image = params[:fleet][:image]\n return if image.nil?\n\n begin\n image = MiniMagick::Image.new(image.tempfile.path)\n image.resize '175x260>'\n rescue MiniMagick::Error\n # errors here will be caught in model validation\n end\n end", "def resize(width, height, resize_method)\n cropping = (resize_method != :resize_scale)\n\n # Calculate aspect ratios\n source_ratio = size.width / size.height\n target_ratio = width / height\n\n # Determine what side of the source image to use for proportional scaling\n scale_width = (source_ratio <= target_ratio)\n\n # Proportionally scale source image\n scaled_width, scaled_height = nil, nil\n if cropping && scale_width\n scaling_factor = 1.0 / source_ratio\n scaled_width = width\n scaled_height = (width * scaling_factor).round\n else\n scaling_factor = source_ratio\n scaled_width = (height * scaling_factor).round\n scaled_height = height\n end\n scale_factor = scaled_height / size.height\n\n # Calculate compositing rectangles\n source_rect = nil\n if cropping\n dest_x, dest_y = nil, nil\n case resize_method\n when :resize_crop\n # Crop center\n dest_x = ((scaled_width - width) / 2.0).round\n dest_y = ((scaled_height - height) / 2.0).round\n when :resize_crop_start\n # Crop top or left (prefer top)\n if scale_width\n # Crop top\n dest_x = ((scaled_width - width) / 2.0).round\n dest_y = (scaled_height - height).round\n else\n # Crop left\n dest_x = 0.0\n dest_y = ((scaled_height - height) / 2.0).round\n end\n when :resize_crop_end\n # Crop bottom or right\n if scale_width\n # Crop bottom\n dest_x = 0.0\n dest_y = 0.0\n else\n # Crop right\n dest_x = (scaled_width - width).round\n dest_y = ((scaled_height - height) / 2.0).round\n end\n end\n source_rect = [dest_x / scale_factor, dest_y / scale_factor, width / scale_factor, height / scale_factor]\n else\n width = scaled_width\n height = scaled_height\n source_rect = [0, 0, size.width, size.height]\n end\n\n result = OSX::NSImage.alloc.initWithSize([width, height])\n result.lockFocus\n OSX::NSGraphicsContext.currentContext.setImageInterpolation(OSX::NSImageInterpolationHigh)\n drawInRect_fromRect_operation_fraction([0, 0, width, height], source_rect, OSX::NSCompositeSourceOver, 1.0)\n result.unlockFocus\n result\n end", "def grow_crop_area(size, crop_from, crop_size, gravity, closest_fit = false)\n max_growth = max_crop_area_growth(crop_from, crop_size)\n wanted_growth = wanted_crop_area_growth(size, crop_size, gravity, closest_fit)\n growth = actual_crop_area_growth(wanted_growth, max_growth)\n\n if has_wider_aspect_ratio?(size, crop_size) # => requested wider size, grow x\n crop_size[:width] += growth[:left] + growth[:right]\n crop_size[:height] = crop_size[:width] / aspect_ratio(size)\n else # => grow y\n crop_size[:height] += growth[:top] + growth[:bottom]\n crop_size[:width] = crop_size[:height] * aspect_ratio(size)\n end\n\n round_dimensions(crop_size)\n end", "def resize_to_limit(new_width, new_height)\n manipulate! do |image|\n image = resize_image(image,new_width,new_height) if new_width < image.width || new_height < image.height\n image\n end\n end", "def resize_to_limit(new_width, new_height)\n width, height = FastImage.size(self.current_path)\n if width > new_width || height > new_height\n resize_to_fit(new_width, new_height)\n end\n end", "def dynamic_resize_to_fit(size)\n resize_to_fit *(model.class::IMAGE_CONFIG[size])\n end", "def resize_to_fit(new_width, new_height)\n width, height = FastImage.size(self.current_path)\n width_ratio = new_width.to_f / width.to_f\n height_when_width_used = height * width_ratio\n if height_when_width_used <= new_height\n new_height = height_when_width_used\n else\n height_ratio = new_height.to_f / height.to_f\n new_width = width * height_ratio\n end\n FastImage.resize(self.current_path, self.current_path, new_width, new_height)\n end", "def resize_and_crop(size)\n manipulate! do |image|\n Rails.logger.error '----------- image:'\n Rails.logger.error image.inspect\n\n if image[:width] < image[:height]\n remove = ((image[:height] - image[:width]) / 2).round\n image.shave(\"0x#{remove}\")\n elsif image[:width] > image[:height]\n remove = ((image[:width] - image[:height]) / 2).round\n image.shave(\"#{remove}x0\")\n end\n image.resize(\"#{size}x#{size}\")\n image\n end\n end", "def resize_to_fit(width, height)\n width = dimension_from width\n height = dimension_from height\n manipulate! do |img|\n img.resize_to_fit!(width, height)\n img = yield(img) if block_given?\n img\n end\n end", "def fit_to(options = {})\n self.fit_to_width = options[:width] || 999\n self.fit_to_height = options[:height] || 999\n [@fit_to_width, @fit_to_height]\n end", "def resize(width, height)\n end", "def crop!(image, width, height, x_offset = 0, y_offset = 0, gravity: \"NorthWest\")\n with_minimagick(image) do |img|\n img.combine_options do |cmd|\n yield cmd if block_given?\n cmd.gravity gravity\n cmd.crop \"#{width}x#{height}+#{x_offset}+#{y_offset}\"\n end\n end\n end", "def resize_to_fit(width, height)\n manipulate! do |img|\n img.resize \"#{width}x#{height}\"\n img = yield(img) if block_given?\n img\n end\n end", "def scaleimage **opts\n Vips::Image.scale self, **opts\n end", "def resize_and_crop(size) \n manipulate! do |image| \n if image[:width] < image[:height]\n remove = (image[:height] - 135).round \n image.shave(\"0x#{remove}\") \n elsif image[:width] > image[:height] \n remove = ((image[:width] - image[:height])/2).round\n image.shave(\"#{remove}x0\")\n end\n image.resize(\"#{size}\")\n image\n end\n end", "def tile_crop_resize(image, dpi)\n size = {\n 'x' => image.columns,\n 'y' => image.rows\n }\n\n resize = false\n\n ['x', 'y'].each do |a|\n if (@field['size' + a])\n size[a] = @field['size' + a]*dpi\n resize = true\n end\n end\n\n if (@field['tile'])\n image = tile_image(image, dpi) if @field['tile']\n elsif (resize)\n scaleX = size['x']/image.columns\n scaleY = size['y']/image.rows\n\n scale = scaleX\n scale = scaleY if scaleY > scaleX\n\n image.resize!(image.columns*scale, image.rows*scale, Magick::LanczosFilter, 0.7)\n end\n\n image.crop!(Magick::CenterGravity, size['x'], size['y']) if (@field['crop'])\n\n return image\n end", "def resize_to_fit\n image = ManagedImage.from_path(params[:image])\n width = params[:width].to_i\n height = params[:height].to_i\n render json: image.resize_to_fit(width, height)\n end", "def default_preset(img)\n img.crop_resized(128, 128, params[:gravity]).quality(75)\n end", "def create_resized_image\n create_image do |xfrm|\n if size\n xfrm.flatten\n xfrm.resize(size)\n end\n end\n end", "def resize_to_fit(width, height)\n manipulate! do |img|\n img.manipulate!(:resize => \"#{width}x#{height}\")\n img = yield(img) if block_given?\n img\n end\n end", "def resize(*args)\n with_command %(-resize \"#{Geometry.new(*args)}\")\n end", "def resize_image uri, options = { }\n\n\t# parse id, mime type from image uri\n\tformat = uri.split('/').last.match(/\\.(.+)$/)[1]\n\tid = uri.split('/').last.sub(/\\..+$/, '').slugify\n\n\t# resize image and save to /tmp\n\timage = Image.read(uri)[0]\n\t\n\t# calculate width/height based on percentage of \n\t# difference of width from absolute value of 150\n\tif options[:width]\n\t\twidth = options[:width]\n\t\tscale = (image.page.width - width) / image.page.width.to_f\n\t\theight = image.page.height - (image.page.height * scale)\n\n\t\timage = image.thumbnail(width, height)\n\t\timage.write(\n\t\t\tpath = \"/tmp/#{id}-constrainedw.#{format}\"\n\t\t)\t\t\n\n\telsif options[:height]\n\t\theight = options[:height]\n\t\tscale = (image.page.height - height) / image.page.height.to_f\n\t\twidth = image.page.width - (image.page.width * scale)\n\n\t\timage = image.thumbnail(width, height)\n\t\timage.write(\n\t\t\tpath = \"/tmp/#{id}-thumbh.#{format}\"\n\t\t)\n\n\telse\n\t\twidth = 150\n\t\tscale = (image.page.width - width) / image.page.width.to_f\n\t\theight = image.page.height - (image.page.height * scale)\n\n\t\timage = image.thumbnail(width, height)\n\t\timage.write(\n\t\t\tpath = \"/tmp/#{id}-thumb.#{format}\"\n\t\t)\n\n\tend\n\n path\nend", "def processed_image(image, options = {})\n size = options[:size]\n upsample = !!options[:upsample]\n\n return image unless size.present? && has_convertible_format?\n\n if options[:crop]\n crop(size, options[:crop_from], options[:crop_size], upsample)\n else\n resize(size, upsample)\n end\n end", "def adjust_crop_area_to_aspect_ratio(size, crop_from, crop_size, gravity)\n old_crop_size = crop_size.clone\n\n case gravity[:size]\n when \"shrink\"\n crop_size = shrink_crop_area(size, crop_size)\n when \"closest_fit\"\n crop_size = grow_crop_area(size, crop_from, crop_size, gravity, true)\n when \"grow\"\n crop_size = grow_crop_area(size, crop_from, crop_size, gravity)\n end\n\n crop_from = crop_from_after_crop_area_resize(crop_from, crop_size, old_crop_size, gravity)\n\n [crop_from, crop_size]\n end", "def resize_and_pad(width, height, background=:transparent, gravity='Center')\n manipulate! do |img|\n opt={}\n opt[:thumbnail] = \"#{width}x#{height}>\"\n background == :transparent ? opt[:background] = \"rgba(255, 255, 255, 0.0)\" : opt[:background] = background\n opt[:gravity] = gravity\n opt[:extent] = \"#{width}x#{height}\"\n img.manipulate!(opt)\n img = yield(img) if block_given?\n img\n end\n end", "def crop_to(width, height)\n # Checks that crop area is defined and crop should be done.\n if ((crop_args[0] == crop_args[2]) || (crop_args[1] == crop_args[3]))\n # If not creates default image and saves it's dimensions.\n resize_to_fill_and_save_dimensions(width, height)\n else\n args = crop_args + [width, height]\n crop_and_resize(*args)\n end\n end", "def resize destination, dimensions\n # Require dimensions to be in ImageMagick-compatible format\n raise \"Invalid size for resized artwork\" unless dimensions =~ /\\d*x\\d*/\n\n # Check if convert exists\n raise \"convert: Command not found\" unless system( \"which convert &> /dev/null\" )\n\n # Resize artwork\n artworkResizeCommand = Array.new\n artworkResizeCommand.push \"convert\"\n artworkResizeCommand.push \"-resize #{dimensions}\"\n artworkResizeCommand.push Shellwords.escape File.join( @base_directory, @relative_path )\n artworkResizeCommand.push Shellwords.escape destination\n\n raise \"Resizing of artwork failed\" unless system( artworkResizeCommand.join( \" \" ) )\n end", "def my_resize(width, height)\n manipulate! do |img|\n img.resize \"#{width}x#{height}!\"\n img\n end\n end", "def resize_and_pad(width, height, background=:transparent, gravity=::Magick::CenterGravity)\n width = dimension_from width\n height = dimension_from height\n manipulate! do |img|\n img.resize_to_fit!(width, height)\n filled = ::Magick::Image.new(width, height) { |image| image.background_color = background == :transparent ? 'rgba(255,255,255,0)' : background.to_s }\n filled.composite!(img, gravity, ::Magick::OverCompositeOp)\n destroy_image(img)\n filled = yield(filled) if block_given?\n filled\n end\n end", "def shrink_to_fit(new_width, new_height, &block)\n new_width, new_height = scale_dimensions_to_fit(new_width, new_height)\n return block.call(self) if new_width >= width && new_height >= height\n squish(new_width, new_height, &block)\n end", "def scale_image(preferred_width, preferred_height)\n # Retrieve the current height and width\n image_data = ActiveStorage::Analyzer::ImageAnalyzer.new(image).metadata\n new_width = image_data[:width]\n new_height = image_data[:height]\n\n # Adjust the width\n if new_width > preferred_width\n new_width = preferred_width\n new_height = (new_height * new_width) / image_data[:width]\n end\n\n # Adjust the height\n if new_height > preferred_height\n old_height = new_height\n new_height = preferred_height\n new_width = (new_width * new_height) / old_height\n end\n\n # Return the resized image\n image.variant(resize_to_limit: [new_width, new_height])\n end", "def resize_to_fill(new_width, new_height)\n manipulate! do |image|\n\n image = resize_image image, new_width, new_height, :max\n\n if image.x_size > new_width\n top = 0\n left = (image.x_size - new_width) / 2\n elsif image.y_size > new_height\n left = 0\n top = (image.y_size - new_height) / 2\n else\n left = 0\n top = 0\n end\n\n image.extract_area(left, top, new_width, new_height)\n\n end\n end", "def resize_image(img, size)\n img.delete_profile('*')\n\n # resize_image take size in a number of formats, we just want\n # Strings in the form of \"crop: WxH\"\n if (size.is_a?(String) && size =~ /^crop: (\\d*)x(\\d*)/i) ||\n (size.is_a?(Array) && size.first.is_a?(String) &&\n size.first =~ /^crop: (\\d*)x(\\d*)/i)\n img.crop_resized!($1.to_i, $2.to_i)\n # We need to save the resized image in the same way the\n # orignal does.\n quality = img.format.to_s[/JPEG/] && get_jpeg_quality\n out_file = write_to_temp_file(img.to_blob { self.quality = quality if quality })\n self.temp_paths.unshift out_file\n else\n old_resize_image(img, size) # Otherwise let attachment_fu handle it\n end\n end", "def img_resize( dat, w, h, options = {} )\n quality = options[:quality]\n format = options[:format]\n\n begin\n img = GD2::Image.load(dat)\n if h == 0\n h = ( w / img.aspect ).to_i\n end\n\n puts \"resizing image… width: #{w}, height: #{h}, quality: #{quality}\" if $debug\n\n # make sure it doesn't upscale image\n res = img.size\n\n if res[0] < w and res[1] < h\n w = res[0]\n h = res[1]\n elsif res[0] < w\n w = res[0]\n h = (w / img.aspect).to_i\n elsif res[1] < h\n h = res[1]\n w = (h / img.aspect).to_i\n end\n\n nimg = img.resize( w, h )\n\n if img_type(dat) == :jpeg and quality\n nimg.jpeg( quality.to_i )\n else\n case img_type(dat)\n when :png\n nimg.png\n when :jpeg\n nimg.jpeg\n when :gif\n nimg.gif\n else\n raise 'img_resize(), unknown output format'\n end\n end\n rescue => errmsg\n puts \"error: resize failed. #{w} #{h} #{quality}\"\n p errmsg\n return nil\n end\nend", "def expand_to_fit(new_width, new_height, &block)\n new_width, new_height = scale_dimensions_to_fit(new_width, new_height)\n return block.call(self) if new_width <= width && new_height <= height\n squish(new_width, new_height, &block)\n end", "def resize_image(params)\n # The path of the image\n path = \"public/images/#{params[1]}/#{@tempo.id}_#{params[1]}.#{params[0]}\"\n # Read the image\n img = Magick::Image.read(\"public/images/original/#{@original_image_name}\").first\n # Resize and Crop the image\n target = Magick::Image.new(params[2], params[3])\n thumb = img.resize_to_fill!(params[2], params[3])\n target.composite(thumb, Magick::CenterGravity, Magick::CopyCompositeOp).write(path)\n # Insert the width and height into an object\n @tempo.width, @tempo.height = \"#{params[2]}\", \"#{params[3]}\"\n # Add the link and tags to its DB\n add_linkID_tagsID(path,params[1])\n # Delete the image after uploading it to the storage\n File.delete(path)\n end", "def scale_to_fit(new_width, new_height, &block)\n squish(*scale_dimensions_to_fit(new_width, new_height), &block)\n end", "def resize_to_limit(width, height)\n manipulate! do |img|\n img.resize \"#{width}x#{height}>\"\n img = yield(img) if block_given?\n img\n end\n end", "def resize_image(img, size)\n size = size.first if size.is_a?(Array) && size.length == 1 && !size.first.is_a?(Fixnum)\n if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))\n size = [size, size] if size.is_a?(Fixnum)\n img.thumbnail!(*size)\n elsif size.is_a?(String) && size =~ /^c.*$/ # Image cropping - example geometry string: c75x75\n dimensions = size[1..size.size].split(\"x\")\n img.crop_resized!(dimensions[0].to_i, dimensions[1].to_i)\n elsif size.is_a?(String) && size =~ /^b.*$/ # Resize w/border - example geometry string: b75x75\n dimensions = size[1..size.size].split(\"x\")\n img.change_geometry(dimensions.join(\"x\")) do |cols, rows, image|\n image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows )\n end\n img.background_color = \"black\"\n x_offset = (img.columns - dimensions[0].to_i) / 2\n y_offset = (img.rows - dimensions[1].to_i) / 2\n img = img.extent(dimensions[0].to_i, dimensions[1].to_i, x_offset, y_offset)\n else\n img.change_geometry(size.to_s) { |cols, rows, image| image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows) }\n end\n img.strip! unless attachment_options[:keep_profile]\n temp_paths.unshift write_to_temp_file(img.to_blob)\n end", "def set_image_dimensions\n\t\tif !self.image_width.is_a?(Numeric) || !self.image_file_name.nil?\t \n\t\t if !image.queued_for_write[:original].nil?\n\t\t geo = Paperclip::Geometry.from_file(image.queued_for_write[:original])\n\t\t self.image_width = geo.width\n\t\t self.image_height = geo.height\n\t\t end\n\t\tend\n\tend", "def wanted_crop_area_growth(size, crop_size, gravity, closest_fit = false)\n growth = { top: 0, right: 0, bottom: 0, left: 0 }\n\n if has_wider_aspect_ratio?(size, crop_size) # => requested wider size, grow x\n new_width = (crop_size[:width] * aspect_ratio(size) / aspect_ratio(crop_size))\n case gravity[:x]\n when \"left\"\n growth[:right] = new_width - crop_size[:width]\n when \"center\"\n growth[:left] = (new_width - crop_size[:width]) / 2\n growth[:right] = growth[:left]\n when \"right\"\n growth[:left] = new_width - crop_size[:width]\n end\n else # => grow y\n new_height = crop_size[:height] * aspect_ratio(crop_size) / aspect_ratio(size)\n case gravity[:y]\n when \"top\"\n growth[:bottom] = new_height - crop_size[:height]\n when \"center\"\n growth[:top] = (new_height - crop_size[:height]) / 2\n growth[:bottom] = growth[:top]\n when \"bottom\"\n growth[:top] = new_height - crop_size[:height]\n end\n end\n\n closest_fit ? halve_growth(growth) : growth\n end", "def display_image\n image.variant resize_to_limit: Settings.validation.post.img_resize\n end", "def resizeImage(imageName)\n image = MiniMagick::Image.open(imageName)\n height = image.height\n width = image.width\n\n if height > width\n ratio = 128.0 / height\n reHeight = (height * ratio).floor\n reWidth = (width * ratio).floor\n else\n ratio = 128.0 / width\n reHeight = (height * ratio).floor\n reWidth = (width * ratio).floor\n end\n\n image.resize(\"#{reHeight} x #{reWidth}\")\n image.write(\"resize.jpg\")\n end", "def resize_image(img, size)\n size = size.first if size.is_a?(Array) && size.length == 1 && !size.first.is_a?(Fixnum)\n if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))\n size = [size, size] if size.is_a?(Fixnum)\n img.thumbnail!(*size)\n elsif size.is_a?(String) && size =~ /^c.*$/ # Image cropping - example geometry string: c75x75\n dimensions = size[1..size.size].split(\"x\")\n img.crop_resized!(dimensions[0].to_i, dimensions[1].to_i)\n elsif size.is_a?(String) && size =~ /^b.*$/ # Resize w/border - example geometry string: b75x75\n dimensions = size[1..size.size].split(\"x\")\n img.change_geometry(dimensions.join(\"x\")) do |cols, rows, image| \n image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows ) \n end\n img.background_color = \"black\"\n x_offset = (img.columns - dimensions[0].to_i) / 2\n y_offset = (img.rows - dimensions[1].to_i) / 2\n img = img.extent(dimensions[0].to_i, dimensions[1].to_i, x_offset, y_offset)\n else\n img.change_geometry(size.to_s) { |cols, rows, image| image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows) }\n end\n img.strip! unless attachment_options[:keep_profile]\n temp_paths.unshift write_to_temp_file(img.to_blob)\n end", "def resize_image(img, size) \n # resize_image take size in a number of formats, we just want \n # Strings in the form of \"crop: WxH\" \n if (size.is_a?(String) && size =~ /^crop: (\\d*)x(\\d*)/i) || \n (size.is_a?(Array) && size.first.is_a?(String) && \n size.first =~ /^crop: (\\d*)x(\\d*)/i) \n img.crop_resized!($1.to_i, $2.to_i) \n # We need to save the resized image in the same way the \n # orignal does. \n self.temp_path = write_to_temp_file(img.to_blob) \n else \n super # Otherwise let attachment_fu handle it \n end \n end", "def fit_within(max_w, max_h)\n w, h = width, height\n\n if w > max_w.to_i or h > max_h.to_i\n\n w_ratio = max_w.quo(w)\n h_ratio = max_h.quo(h)\n\n if (w_ratio < h_ratio)\n h = (h * w_ratio)\n w = (w * w_ratio)\n else\n h = (h * h_ratio)\n w = (w * h_ratio)\n end\n end\n\n if block_given?\n self.resize(w, h) do |image|\n yield image\n end\n else\n self.resize(w, h)\n end\n end", "def scale_by_bounds(dimensions)\n x = options[:width] / dimensions[0].to_f\n y = options[:height] / dimensions[1].to_f\n x * dimensions[1] > options[:height] ? y : x\n end", "def resize_to_limit(width, height)\n manipulate! do |img|\n img.manipulate!(:resize => \"#{width}x#{height}>\")\n img = yield(img) if block_given?\n img\n end\n end", "def resize_to_fill\n image = ManagedImage.from_path(params[:image])\n width = params[:width].to_i\n height = params[:height].to_i\n render json: image.resize_to_fill(width, height)\n end", "def resize_image_to(screen_resolution, check_inclusion: true)\n raise ArgumentError, 'Argument is not an instance of ScreenResolution' unless screen_resolution.is_a?(ScreenResolution)\n if check_inclusion && !resizable_resolutions.include?(screen_resolution)\n return false\n end\n @resized_image = image.thumb(\"#{screen_resolution.to_geometry_s}\\##{image_gravity}\")\n @resized_image_resolution = screen_resolution\n true\n end", "def resize_all(size_constraint)\n require 'rmagick'\n\n Dir.new('.').each do |f|\n if f.match(/jpg/)\n if (i = Magick::Image.read(f).first)\n i.resize_to_fit!(size_constraint)\n i.write(f)\n end\n end\n end\nend", "def resize_to_fit(cols, rows = nil)\n rows ||= cols\n change_geometry(Geometry.new(cols, rows)) do |ncols, nrows|\n resize(ncols, nrows)\n end\n end", "def resize_to_fill(width, height)\n manipulate! do |image|\n image = resize_image image, width, height, :max\n top = 0\n left = 0\n\n if image.x_size > width\n left = (image.x_size - width) / 2\n elsif image.y_size > height\n top = (image.y_size - height) / 2\n end\n\n image.extract_area left, top, width, height\n end\n self\n end", "def resize_to_fill(new_width, new_height)\n manipulate! do |image|\n\n image = resize_image image, new_width, new_height, :max\n\n if image.width > new_width\n top = 0\n left = (image.width - new_width) / 2\n elsif image.height > new_height\n left = 0\n top = (image.height - new_height) / 2\n else\n left = 0\n top = 0\n end\n\n # Floating point errors can sometimes chop off an extra pixel\n # TODO: fix all the universe so that floating point errors never happen again\n new_height = image.height if image.height < new_height\n new_width = image.width if image.width < new_width\n\n image.extract_area(left, top, new_width, new_height)\n\n end\n end", "def shrink_crop_area(size, crop_size)\n if has_wider_aspect_ratio?(size, crop_size) # => requested wider size, shrink y\n crop_size[:height] = crop_size[:height] * aspect_ratio(crop_size) / aspect_ratio(size)\n else # => shrink x\n crop_size[:width] = crop_size[:width] * aspect_ratio(size) / aspect_ratio(crop_size)\n end\n\n round_dimensions(crop_size)\n end", "def resize!(w, h, resample = true)\n ptr = self.class.create_image_ptr(w, h, false)\n ::GD2::GD2FFI.send(resample ? :gdImageCopyResampled : :gdImageCopyResized,\n ptr, image_ptr, 0, 0, 0, 0, w.to_i, h.to_i, width.to_i, height.to_i)\n alpha_blending = alpha_blending?\n init_with_image(ptr)\n self.alpha_blending = alpha_blending\n self\n end", "def old_resize_image(img, size)\n size = size.first if size.is_a?(Array) && size.length == 1 && !size.first.is_a?(Fixnum)\n if size.is_a?(Fixnum) || (size.is_a?(Array) && size.first.is_a?(Fixnum))\n size = [size, size] if size.is_a?(Fixnum)\n img.thumbnail!(*size)\n elsif size.is_a?(String) && size =~ /^c.*$/ # Image cropping - example geometry string: c75x75\n dimensions = size[1..size.size].split(\"x\")\n img.crop_resized!(dimensions[0].to_i, dimensions[1].to_i)\n else\n img.change_geometry(size.to_s) { |cols, rows, image| image.resize!(cols<1 ? 1 : cols, rows<1 ? 1 : rows) }\n end\n self.width = img.columns if respond_to?(:width)\n self.height = img.rows if respond_to?(:height)\n img.strip! unless attachment_options[:keep_profile]\n quality = img.format.to_s[/JPEG/] && get_jpeg_quality\n out_file = write_to_temp_file(img.to_blob { self.quality = quality if quality })\n temp_paths.unshift out_file\n self.size = File.size(self.temp_path)\n end", "def resize!\n end", "def crop_from_after_crop_area_resize(crop_from, crop_size, old_crop_size, gravity)\n if old_crop_size[:width] != crop_size[:width]\n case gravity[:x]\n # No adjustment when left\n when \"center\"\n crop_from[:x] += (old_crop_size[:width] - crop_size[:width]) / 2\n when \"right\"\n crop_from[:x] += old_crop_size[:width] - crop_size[:width]\n end\n end\n\n if old_crop_size[:height] != crop_size[:height]\n case gravity[:y]\n # No adjustment when top\n when \"center\"\n crop_from[:y] += (old_crop_size[:height] - crop_size[:height]) / 2\n when \"bottom\"\n crop_from[:y] += old_crop_size[:height] - crop_size[:height]\n end\n end\n\n crop_from\n end", "def resizeImage(file, size)\n img_orig = Magick::Image.read(\"public/#{file}\").first\n \n width = img_orig.columns\n height = img_orig.rows\n \n if(width > size || height > size)\n if(width > height)\n height = size * height / width\n width = size\n else\n width = size * height / width\n height = size\n end\n \n img = img_orig.resize_to_fit(width, height)\n \n img.write(\"public/#{file}\")\n end\n end", "def scale_aspect_to_fill_size(aSize)\n if aSize.width/aSize.height > size.width/size.height\n croppedImg = image_by_cropping_to_center_size(CGSize.new(size.width, (size.width/aSize.width * aSize.height).to_i))\n else\n croppedImg = image_by_cropping_to_center_size(CGSize.new((size.height/aSize.height * aSize.width).to_i, size.height))\n end\n\n croppedImg.scale_to_size(aSize)\n end", "def execute_crop(image, crop, x, y, width, height)\n require 'RMagick'\n # load in the original image\n old_image = Magick::Image::read(self.send(image).path).first\n # crop it at the desired position\n new_image = old_image.crop(x.to_i, y.to_i, width.to_i, height.to_i, true)\n # scale the image to the correct size if needed\n desired_width, desired_height = Image.detailed_dimensions(self.class, image, crop)\n if desired_width\n clean_desired_width = desired_width.gsub(/\\D/, '').to_f\n if desired_width.include?('>')\n new_image.scale!(clean_desired_width/width.to_f) if (width > clean_desired_width)\n elsif desired_width.include?('^')\n new_image.scale!(clean_desired_width/width.to_f) if (width < clean_desired_width)\n else\n new_image.scale!(clean_desired_width/width.to_f)\n end\n elsif desired_height\n clean_desired_height = desired_height.gsub(/\\D/, '').to_f\n if desired_height.include?('>')\n new_image.scale!(clean_desired_height/height.to_f) if (height > clean_desired_height)\n elsif desired_height.include?('^')\n new_image.scale!(clean_desired_height/height.to_f) if (height < clean_desired_height)\n else\n new_image.scale!(clean_desired_height/height.to_f)\n end\n end\n \n # need to make sure the image is the size it wanted to be in the first place as a pixel or 2 can b lost in the maths from the views\n # only do this if the requested dims allow it.\n if desired_width.to_i != 0 && desired_height.to_i != 0\n new_image.scale!(desired_width.to_i, desired_height.to_i)\n end\n \n FileUtils.mkdir_p(File.dirname(self.send(image).path(crop).to_s))\n new_image.write(self.send(image).path(crop).to_s)\n end", "def resize_image\n unless logo.nil?\n if logo.height != 100\n self.logo = logo.thumb('x100') # resize height and maintain aspect ratio\n end\n end\n end", "def resize width = max_width, height = max_height\n @form.resize width, height\n self.write Mine::Key.RESIZE\n end", "def display_image \r\n self.image.variant(resize_to_limit: [1000, 1000]) \r\n end", "def resize_post_with_http_info(max_width, max_height, image_file, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ResizeApi.resize_post ...'\n end\n # verify the required parameter 'max_width' is set\n if @api_client.config.client_side_validation && max_width.nil?\n fail ArgumentError, \"Missing the required parameter 'max_width' when calling ResizeApi.resize_post\"\n end\n # verify the required parameter 'max_height' is set\n if @api_client.config.client_side_validation && max_height.nil?\n fail ArgumentError, \"Missing the required parameter 'max_height' when calling ResizeApi.resize_post\"\n end\n # verify the required parameter 'image_file' is set\n if @api_client.config.client_side_validation && image_file.nil?\n fail ArgumentError, \"Missing the required parameter 'image_file' when calling ResizeApi.resize_post\"\n end\n # resource path\n local_var_path = '/image/resize/preserveAspectRatio/{maxWidth}/{maxHeight}'.sub('{' + 'maxWidth' + '}', max_width.to_s).sub('{' + 'maxHeight' + '}', max_height.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/octet-stream'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params['imageFile'] = image_file\n\n # http body (model)\n post_body = nil\n auth_names = ['Apikey']\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 => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ResizeApi#resize_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def scale_within(new_size)\n target_size = SugarCube::CoreGraphics::Size(new_size)\n image_size = self.size\n\n if CGSizeEqualToSize(target_size, self.size)\n return self\n end\n\n width = image_size.width\n height = image_size.height\n\n target_width = target_size.width\n target_height = target_size.height\n\n width_factor = target_width / width\n height_factor = target_height / height\n\n if width_factor < height_factor\n scale_factor = width_factor\n else\n scale_factor = height_factor\n end\n\n if scale_factor == 1\n return self\n end\n\n scaled_size = CGSize.new(width * scale_factor, height * scale_factor)\n return scale_to(scaled_size)\n end", "def display_image\n image.variant(resize_to_limit: [500,500])\n end", "def set_offer_image_dimensions\n if offer_image.queued_for_write[:full_size]\n geometry = Paperclip::Geometry.from_file(offer_image.queued_for_write[:full_size])\n self.offer_image_width = geometry.width\n self.offer_image_height = geometry.height\n end\n end", "def resize_resize_simple(width, height, image_file, opts = {})\n data, _status_code, _headers = resize_resize_simple_with_http_info(width, height, image_file, opts)\n data\n end" ]
[ "0.68711936", "0.676364", "0.67492026", "0.6653965", "0.66281796", "0.65456635", "0.6379377", "0.63703144", "0.6335966", "0.6228251", "0.6186818", "0.6184387", "0.61810917", "0.6165767", "0.6144524", "0.60968006", "0.60968006", "0.6029723", "0.60177845", "0.60110766", "0.5991089", "0.59893113", "0.5981798", "0.59752816", "0.59342915", "0.59303576", "0.5929199", "0.5902771", "0.5898092", "0.58932376", "0.5877671", "0.5851509", "0.5848373", "0.5836981", "0.5831961", "0.5821283", "0.5820957", "0.5800783", "0.5798415", "0.5797631", "0.5750301", "0.5749462", "0.5720525", "0.5705143", "0.57021147", "0.5690965", "0.56860656", "0.567483", "0.56697476", "0.566935", "0.56170434", "0.5585256", "0.5561971", "0.55560905", "0.5545479", "0.55271614", "0.5496309", "0.5493265", "0.54797125", "0.5478872", "0.54670596", "0.54623413", "0.5461181", "0.54544836", "0.545329", "0.5430843", "0.5425511", "0.53915787", "0.53746027", "0.53695333", "0.53689986", "0.53591937", "0.53525263", "0.53523993", "0.5350382", "0.5345698", "0.53390723", "0.53271586", "0.5323164", "0.53178054", "0.5315335", "0.53138965", "0.5300216", "0.52900195", "0.5282297", "0.52811354", "0.52755344", "0.5262685", "0.52519315", "0.52438945", "0.5235208", "0.5229749", "0.5203481", "0.5202695", "0.51884896", "0.5184268", "0.51779604", "0.51660246", "0.5162899", "0.5160056" ]
0.65981674
5
A singleuse login link for Express accounts to access their Stripe dashboard
def login_link(**options) ::Stripe::Account.create_login_link(processor_id) rescue ::Stripe::StripeError => e raise Pay::Stripe::Error, e end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login_url\n generate_login_token unless login_token.present?\n ENV['RESERVE_URL'] + '/sign-in/' + login_token\n end", "def connect\n connector = StripeConnect.new( current_user )\n connect_url, error = connector.connect_url( redirect_uri: confirm_users_url )\n\n if connect_url.nil?\n flash[:error] = error\n redirect_to user_path( current_user )\n else\n redirect_to connect_url\n end\n end", "def stripe_account_link(account_id)\n \"https://dashboard.stripe.com/applications/users/\" + account_id\n end", "def standalone\n connector = StripeStandalone.new(current_customer)\n account = connector.create_account!(params[:country])\n\n if account\n flash[:notice] = \"Standalone StripeAccount account created! <a target='_blank' rel='platform-account' href='https://dashboard.stripe.com/test/applications/users/#{account.id}'>View in dashboard &raquo;</a>\"\n else\n flash[:alert] = 'Unable to create StripeAccount account!'\n end\n redirect_to customer_path(current_customer)\n end", "def idt_login\n show do\n title \"Prepare to order primer\"\n \n check \"Go to the <a href='https://www.idtdna.com/site/account' target='_blank'>IDT website</a>, log in with the lab account. (Username: #{IDT_USER}, password is #{IDT_PASS}).\"\n warning \"Ensure that you are logged in to this exact username and password!\"\n end\n end", "def demo\n user = User.find_by_email(params[:email])\n\n if user && user.authenticate(params[:password])\n sign_in user\n redirect_back_or main_dashboards_path, :gflash => { :success => { :value => \"This is a demo dry run mode. No actual launches to cloud happens. For full version, please signout and signup for a new account.\", :sticky => false, :nodom_wrap => true } }\n else\n flash[:error] = 'Invalid demo username and password combination'\n render 'new'\n end\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def login\n end", "def auto_login(account)\n request.env[\"keycard.authentication\"] = notary.waive(account)\n setup_session\n end", "def stripe_customer_link(customer_id)\n \"https://dashboard.stripe.com/customers/\" + customer_id\n end", "def login_into_alchemy\n visit '/alchemy/admin/login'\n fill_in('alchemy_user_session_login', :with => 'jdoe')\n fill_in('alchemy_user_session_password', :with => 's3cr3t')\n click_on('Login')\n end", "def login_user\n visit landing_page_path\n click_on 'Login'\n fill_in 'Email', with: users(:tony).email\n fill_in 'Password', with: 'password'\n click_on 'Log in'\n end", "def login\n options = {\n type: 'OneView',\n file_env_var: 'ONEVIEW_AUTH_FILE',\n env_var_url: 'ONEVIEW_URL',\n filename: '/login.json'\n }\n credentials = load_authentication_settings(options)\n credentials[:hardware_variant] ||= 'C7000'\n credentials[:hardware_variant] = credentials[:hardware_variant].to_s.capitalize\n credentials\nend", "def payout\n\t\t# if !current_user.merchant_id.blank?\n # \t\t\taccount = Stripe::Account.retrieve(current_user.merchant_id)\n # \t\t\t@login_link = account.login_links.create()\n\t\t# end\n end", "def login\n\n end", "def login\n\n end", "def index\n res = create_request2(root_url + '/login/auth', 'tequila.epfl.ch')\n redirect_to ('https://tequila.epfl.ch/cgi-bin/tequila/requestauth?request' + res)\n end", "def login\n end", "def log_user_in(user)\n set_omniauth_user user\n visit '/'\n click_link 'Log In'\n end", "def login\n redirect_to '/auth/azureactivedirectory'\n end", "def sign_in_admin\n get \"/en/users/sign_in\"\n post '/en/users/sign_in', 'user[email]' => 'admin@test.com', 'user[password]' => '12345678'\n follow_redirect!\n end", "def login\n if fetch_subscription(params) \n redirect_to \"/ssp/subscription\"\n else\n redirect_to \"/ssp/index?login=failed\"\n end \n end", "def show\n session = Stripe::Checkout::Session.create(\n payment_method_types: [\"card\"],\n customer_email: current_user.email,\n line_items: [\n {\n name: @plant.name,\n description: @plant.description,\n amount: @plant.price,\n currency: \"aud\",\n quantity: 1\n }\n ],\n payment_intent_data: {\n metadata: {\n user_id: current_user.id,\n plant_id: @plant.id\n }\n },\n success_url: \"#{root_url}payment/success?userId=#{current_user.id}&plantId=#{@plant.id}\",\n cancel_url: \"#{root_url}plant/#{@plant.id}\"\n )\n\n @session_id = session.id\n @public_key = Rails.application.credentials.dig(:stripe, :public_key)\n end", "def login_page\n end", "def loginpage\n end", "def login\n return redirect_to '/' if current_account && current_account.refresh_credentials(cookies) && !current_account.reviewer? && current_account.active?\n\n return render layout: 'new' unless request.post?\n next_url = (params[:next] && CGI.unescape(params[:next])) || '/'\n account = Account.log_in(params[:email], params[:password], session, cookies)\n return redirect_to(next_url) if account && account.active?\n if account && !account.active?\n flash[:error] = \"Your account has been disabled. Contact support@documentcloud.org.\"\n else\n flash[:error] = \"Invalid email or password.\"\n end\n begin\n if referrer = request.env[\"HTTP_REFERER\"]\n redirect_to referrer.sub(/^http:/, 'https:')\n end\n rescue RedirectBackError => e\n return render layout: 'new'\n end\n end", "def form_login(user, password)\n post '/goldberg/auth/login', :login => {\n :name => user,\n :password => password\n }\n end", "def login_url options\n email = options.delete(:email) or raise ArgumentError.new(\"No :email passed for user\")\n user_identifier = options.delete(:user_identifier) or raise ArgumentError.new(\"No :user_identifier passed for user\")\n\n authenticated_parameters = build_authenticated_parameters(email, user_identifier, options)\n\n [checkdin_landing_url, authenticated_parameters.to_query].join\n end", "def login; end", "def billing_portal_url(return_url = nil)\n assert_customer_exists\n\n session = Stripe::BillingPortal::Session.create({\n customer: stripe_id,\n return_url: return_url || '/',\n }, stripe_options)\n\n session.url\n end", "def login\n return redirect_to '/' if current_account && current_account.refresh_credentials(cookies) && !current_account.reviewer? && current_account.active?\n return render unless request.post?\n next_url = (params[:next] && CGI.unescape(params[:next])) || '/'\n account = Account.log_in(params[:email], params[:password], session, cookies)\n return redirect_to(next_url) if account && account.active?\n if account && !account.active?\n flash[:error] = \"Your account has been disabled. Contact support@documentcloud.org.\"\n else\n flash[:error] = \"Invalid email or password.\"\n end\n begin\n if referrer = request.env[\"HTTP_REFERER\"]\n redirect_to referrer.sub(/^http:/, 'https:')\n end\n rescue RedirectBackError => e\n # Render...\n end\n end", "def account_url\n return new_user_session_url unless user_signed_in?\n return :user_dashboard_url\n end", "def new_netid\n if Rails.env.development? || Rails.env.test?\n redirect_to \"/auth/developer\"\n else\n target = \"https://#{current_institution.fqdn}/auth/shibboleth/callback\"\n redirect_to \"/Shibboleth.sso/Login?target=#{target}\"\n end\n end", "def log_in(user)\n email = $credentials[user]['email']\n password = $credentials[user]['password']\n case user\n when 'User A'\n transporter.go_to_url(USER_A_HOST)\n set_field('identifier', email)\n click_btn('Next')\n set_field('password', password)\n click_btn('Next')\n when 'User B'\n transporter.go_to_url(USER_B_HOST)\n end\n end", "def signon\n user = Account.find_by_name( params[ :acc_name ].strip )\n if !!( user && user.authenticate( params[ :password ].strip ))\n return_to = session[ :return_to ] || base_url\n reset_session\n session[ :current_user_id ] = user.id\n session[ :keep_base_open ] = user.keep_base_open\n redirect_to return_to\n else\n flash[ :alert ] = t( 'home.signon.error' )\n redirect_to home_url\n end\n end", "def goldberg_login\n render :file => \"#{RAILS_ROOT}/vendor/plugins/goldberg/app/views/goldberg/auth/_login.rhtml\", :use_full_path => false\n end", "def verify_primary_account_holder\n redirect_to dashboard_path and return\n end", "def login\n abakus_config = YAML.load(File.open(\"./config/_abakus_account.yaml\"))\n username = abakus_config['app']['username']\n password = abakus_config['app']['password']\n \n login_page = @agent.get(\"https://abakus.no/user/login/\")\n login_form = login_page.form_with(:action => \"/user/login/\")\n login_form.username = username\n login_form.password = password\n login_form.submit\n end", "def login_user\n visit \"/login\"\n fill_in \"session[name]\", with: \"DJ\"\n fill_in \"session[password]\", with: \"pw\"\n click_link_or_button(\"Login\")\n end", "def display_resource(admin)\r\n admin.login\r\n end", "def do_login page\n page = page.form_with(action: \"/login\") do |f|\n f.userid = @@username\n f.password = @@password\n end.click_button \n end", "def do_login page\n page = page.form_with(action: \"/login\") do |f|\n f.userid = @@username\n f.password = @@password\n end.click_button \n end", "def login\n request_params = {\n host_url_with_protocol: host_url_with_protocol,\n host_url: host_url,\n entity_type: GlobalConstant::TemplateType.login_template_type\n }\n service_response = GlobalConstant::StTokenSale.get_client_details(request_params)\n\n # Check if error present or not?\n unless service_response.success?\n render_error_response(service_response)\n return\n end\n\n @presenter_obj = ::Web::Client::Setup.new(service_response, params)\n redirect_to '/token-sale-blocked-region', status: GlobalConstant::ErrorCode.temporary_redirect and return if @presenter_obj.is_blacklisted_ip?(get_ip_to_aml_countries)\n set_page_meta_info(@presenter_obj.custom_meta_tags)\n end", "def comp_signin_link\n click_link 'Sign in'\n end", "def feature_plain_sign_in(login, password, options = {})\n visit '/'\n fill_in 'educator_login_text', with: login\n fill_in 'educator_password', with: password\n if options[:login_code]\n fill_in 'educator_login_code', with: options[:login_code]\n end\n click_button 'Sign in'\n end", "def login_by_token\n\n end", "def show\n\n stripe_session = Stripe::Checkout::Session.create(\n payment_method_types: ['card'],\n client_reference_id: current_user ? current_user.id : nil,\n customer_email: current_user ? current_user.email : nil,\n\n line_items: [{ \n price_data: {\n unit_amount: @artefact.price.to_i * 100,\n currency: 'aud',\n product_data: { \n name: @artefact.name,\n description: @artefact.description\n },\n },\n quantity: 1\n }],\n\n payment_intent_data: {\n metadata: {\n artefact_id: @artefact.id,\n borrower_id: current_user ? current_user.profile.borrower.id : nil,\n loaner_id: current_user ? @artefact.loaner.id : nil\n }\n },\n mode: 'payment',\n success_url: \"#{root_url}payments/success?artefactId=#{@artefact.id}\",\n cancel_url: \"#{root_url}artefacts\"\n )\n\n @session_id = stripe_session.id\n pp stripe_session\n end", "def login_without_usr_psd\n click_login_btn\nend", "def login_as(email, password)\n click_link \"Log in\"\n fill_in 'Email', with: email\n fill_in 'Password', with: password\n click_button 'Log in'\n end", "def login_url_link\n link_to(t('mailers.login_here'), new_user_session_url, target: '_blank', rel: 'nofollow')\n end", "def user_login\n \"/users/login\"\nend", "def login_first\n redirect_to account_login_path(dest: (params[:dest] || request.path))\n end", "def login_instructions\n end", "def login\n\tend", "def login\n # show LOGIN form\n\n end", "def login\n if current_user and params[:return_to]\n # Already logged in; just need to send a token to the requesting\n # API client.\n #\n # FIXME: if current_user has never authorized this app before,\n # ask for confirmation here!\n\n send_api_token_to(params[:return_to], current_user)\n elsif params[:return_to]\n redirect_to \"/auth/joshid?return_to=#{CGI.escape(params[:return_to])}\"\n else\n redirect_to \"/auth/joshid\"\n end\n end", "def log_in(admin)\n visit new_admin_session_path\n fill_in 'Email', with: admins(admin).email\n fill_in 'Password', with: 'password'\n click_on 'Log in'\n end", "def dropbox_callback\n start_session(RegisterUser.call(get_web_auth.finish(params)))\n connect_client\n\t\tredirect_to user_dash_path(current_user)\n end", "def spree_signup_path\n main_app.login_path\n end", "def complete_stripe_sca\n find_sca_frame do\n click_on \"Complete authentication\"\n end\n end", "def require_login\n if session[:donor_id]\n # binding.pry\n redirect_to '/' if session[:donor_id] == nil\n end\n if session[:charityRep_id]\n redirect to '/' if session[:charityRep_id] == nil\n end\n end", "def mints_user_magic_link_login(hash)\r\n # Login in mints\r\n response = @mints_user.magic_link_login(hash)\r\n if response['data']\r\n # Set a cookie with the session token\r\n cookies[:mints_user_session_token] = { value: response['data']['api_token'], secure: true, httponly: true, expires: 1.day }\r\n redirect_to response['data']['redirect_url'] || '/'\r\n else\r\n redirect_to '/'\r\n end\r\n end", "def login\n make_login_call\n end", "def generate_bill\n if !user_signed_in?\n render :js => \"window.location = '/users/sign_in'\"\n end\n end", "def login\n if session[:token]\n reset_session \n end\n scope = 'https://www.google.com/analytics/feeds/'\n #next_url = 'http://localhost:3000/sites/select'\n next_url = 'http://greenalytics.heroku.com/sites/select'\n secure = false # set secure = true for signed AuthSub requests\n sess = true\n @authsub_link = GData::Auth::AuthSub.get_url(next_url, scope, secure, sess)\n end", "def oauth\n connector = StripeOauth.new(current_customer)\n\n logger.debug(connector)\n\n # logger.debug(\"===> #{stripe_confirm_url}\")\n\n url, error = connector.oauth_url(redirect_uri: stripe_confirm_url)\n\n if url.nil?\n flash[:alert] = error\n redirect_to customer_path(current_customer)\n else\n redirect_to url\n end\n end", "def login\n state_json = {\n redirect_url: params[:redirect_url],\n access_token: params[:access_token],\n ip: request.remote_ip\n }\n\n unless params[:mixpanel_id].blank?\n state_json.merge!(mp_id: params[:mixpanel_id])\n end\n\n encoded_state = LinkedAccount::Base.encode_state(state_json)\n\n case params[:provider]\n when 'github'\n redirect_to LinkedAccount::Github::User.oauth_url(scope: params[:scope], state: encoded_state)\n\n when 'facebook'\n redirect_to LinkedAccount::Facebook.oauth_url(scope: params[:scope], state: encoded_state)\n\n when 'twitter'\n redirect_to LinkedAccount::Twitter.oauth_url(scope: params[:scope], state: encoded_state)\n\n else render json: { error: 'Unsupported provider' }, status: :bad_request\n end\n end", "def login_url(params, session)\n req_token = get_request_token\n session[:request_token] = req_token.token\n session[:request_token_secret] = req_token.secret\n authorize_url({ request_token: req_token.token, request_token_secret: req_token.secret })\n end", "def make_login user, password\n server = Configuration.SERVER\n addr = Configuration.CLIOWL_ADDRESS\n \n HttpHelper.post \"http://#{server}#{addr}/login\", { 'user' => user, 'password' => password }\n end", "def log_in\n visit \"/gp/login.do\"\n fill_in \"id\", :with => @user\n fill_in \"clave\", :with => @password\n first(\".bLogin a\").click\n end", "def require_login\n end", "def login_url(prt, opts = {})\n plid = login_request(prt, :requested => opts.delete(:requested), :seed => opts.delete(:seed)).plid\n login_url_from_plid( plid, opts.delete(:demo) )\n end", "def demo_login\n if demo_mode?\n @user = User.find(params[:id])\n if UserSession.login(@user)\n record_action!(:demo_login, current_user)\n redirect_to after_login_url\n else\n render :action => :new\n end\n end\n end", "def login_guest()\n login(:guest)\n end", "def login\n begin\n # - Creating a JSON file with the proper fields and setting the environment variable ONEVIEW_AUTH_FILE to its path\n credentials = if ENV['ONEVIEW_AUTH_FILE']\n JSON.parse(File.read(File.absolute_path(ENV['ONEVIEW_AUTH_FILE'])), symbolize_names: true)\n # - Declaring each field as an environment variable\n elsif ENV['ONEVIEW_URL']\n environment_credentials\n # - Placing a JSON file in the directory you are running the manifests from\n else\n JSON.parse(File.read(File.expand_path(Dir.pwd + '/login.json', __FILE__)), symbolize_names: true)\n end\n rescue\n raise('The Oneview credentials could not be set. Please check the documentation for more information.')\n end\n credentials_parse(credentials)\nend", "def log_in_with(email, password, admin = nil)\n visit new_user_session_path(admin: admin)\n find('#login_email').set(email)\n find('#login_password').set(password)\n click_button 'Access Courses'\nend", "def default_login\n login(\"rohitsjce@gmail.com\",\"codetheoryio\")\n end", "def sign_in(user)\n visit Rails.application.routes.url_helpers.send(\"new_#{user.class.name.underscore}_session_path\")\n fill_in \"Email\", with: user.email\n fill_in \"Password\", with: user.password\n click_button \"Log in\"\nend", "def mints_user_magic_link_login(hash)\r\n # Login in mints\r\n response = @mints_user.magic_link_login(hash)\r\n if response['data'] && response['data']['redirect_url']\r\n # Set a cookie with the session token\r\n cookies[:mints_user_session_token] = { value: response['data']['api_token'], expires: 1.day, secure: true, httponly: true }\r\n redirect_to response['data']['redirect_url']\r\n else\r\n redirect_to '/'\r\n end\r\n end", "def login_url(params,session)\n req_token = self.get_request_token\n session[:request_token] = req_token.token\n session[:request_token_secret] = req_token.secret\n self.authorize_url({:request_token => req_token.token, :request_token_secret => req_token.secret})\n end", "def login\n redirect_to lato_core.root_path if core_controlSession\n end", "def login\n page = agent.get login_url\n page.form.field_with(name: \"username\").value = user\n page.form.field_with(name: \"password\").value = password\n page.form.submit\n unless agent.page.title.match(/Subscription Content/)\n raise \"Could not log in\"\n end\n agent\n end", "def stripe_config\n Lynr.config('app').stripe\n end", "def sign_in_as(user)\n visit '/'\n click_link 'Sign in'\n fill_in 'Email', with: user.email\n fill_in 'Password', with: 'topsecret'\n click_button \"Sign in\"\n end", "def login\n run \"cf api --skip-ssl-validation api.#{ENV['CF_DOMAIN']}\"\n run \"cf auth #{ENV['CF_USERNAME']} #{ENV['CF_PASSWORD']}\"\nend", "def get_dashboard\n # Setp 3: Try to access to the dashboard\n dashboard_req = setup_http_request($dashboard, @cookie)\n res = @http.request(dashboard_req)\n if res.code=='400' or res['location'] == \"https://www.blablacar.fr/identification\"\n raise AuthenticationError, \"Can't get logged in\"\n end\n res.body.force_encoding('utf-8')\n end", "def url_to_social_login( provider_key, on_success = nil )\n provider = Aerogel::Auth.providers[provider_key] || {}\n origin = on_success || params['on_success']\n query_string = origin ? \"?origin=#{origin}\" : ''\n \"/auth/#{provider_key}#{query_string}\"\nend", "def show\n session = Stripe::Checkout::Session.create(\n payment_method_types: ['card'],\n customer_email: current_user&.email,\n line_items: [{\n name: @product.product_name,\n description: @product.product_description,\n amount: @product.product_price,\n currency: 'aud',\n quantity: 1\n }],\n payment_intent_data: {\n metadata: {\n user_id: current_user&.id,\n product_id: @product.id\n }\n },\n success_url: \"#{root_url}/success?title=#{@product.product_name}\",\n cancel_url: \"#{root_url}/products\"\n )\n \n @session_id = session.id\n puts \"*******\"\n pp @session_id\n puts \"*******\"\n end", "def login(user)\n visit new_user_session_path\n fill_in 'user_email', with: user.email\n fill_in 'user_password', with: user.password\n click_button 'Log in'\n end", "def login_as\n unless session[:user] && session[:user].admin?\n redirect_to \"/\"\n return\n end\n\n user = params[:login_as]\n new_user = LinkedData::Client::Models::User.find_by_username(user).first\n\n if new_user\n session[:admin_user] = session[:user]\n session[:user] = new_user\n session[:user].apikey = session[:admin_user].apikey\n end\n\n #redirect_to request.referer rescue redirect_to \"/\"\n redirect_to \"/\"\n end", "def login_link\n if !authenticated?\n link = '<li><a href=\"https://github.com/login/oauth/authorize?scope=public_repo,admin:repo_hook&client_id=' + CLIENT_ID + '\">Log in with Github</a></li>'\n else\n link = '<li><a href=\"/logout\">Log out</a></li>'\n end\n end", "def setup\n case\n when session.delete(:only_dtu)\n request.env['omniauth.strategy'].options[:login_url] = '/login?only=dtu&template=dtu_user'\n when session.delete(:prefer_dtu)\n request.env['omniauth.strategy'].options[:login_url] = '/login?template=dtu_user'\n when session.delete(:public)\n request.env['omniauth.strategy'].options[:login_url] = '/login?template=local_user'\n else\n request.env['omniauth.strategy'].options[:login_url] = '/login'\n end\n\n render :text => \"Omniauth setup phase.\", :status => 404\n end", "def show\n # Remember where the user is so if they're not logged in here, we can bring them back after sign in.\n session[:return_to] = request.url\n end" ]
[ "0.64338595", "0.6402026", "0.6330011", "0.62373126", "0.6001847", "0.5928493", "0.5902392", "0.5902392", "0.5902392", "0.5902392", "0.5902392", "0.5902392", "0.5902392", "0.5902392", "0.5902392", "0.5894325", "0.5872273", "0.58568376", "0.5845082", "0.5832217", "0.58172125", "0.5812471", "0.5812471", "0.58090216", "0.58076805", "0.5779222", "0.57741284", "0.5768734", "0.57686484", "0.5739221", "0.57386565", "0.57336646", "0.57201374", "0.5716515", "0.57094693", "0.57083184", "0.56803674", "0.5676016", "0.5656484", "0.56526744", "0.5647496", "0.5633045", "0.56274444", "0.5617829", "0.561761", "0.5606138", "0.56050336", "0.56033397", "0.56033397", "0.56017035", "0.5599307", "0.55948216", "0.55847", "0.55734044", "0.5571648", "0.5562125", "0.5551494", "0.5547971", "0.55468917", "0.55332214", "0.5502549", "0.55018294", "0.5501019", "0.5498649", "0.54966646", "0.54823726", "0.54802865", "0.54777086", "0.5474308", "0.54640824", "0.54574233", "0.5457403", "0.5448471", "0.54454494", "0.54435575", "0.5441132", "0.5433859", "0.5428314", "0.54261446", "0.542568", "0.5423143", "0.5422078", "0.5421567", "0.54042834", "0.5402587", "0.5399487", "0.53975207", "0.53951645", "0.53898937", "0.5389516", "0.5386006", "0.5383291", "0.5381956", "0.5374891", "0.5374751", "0.53729075", "0.53727174", "0.5372705", "0.53725463", "0.537104" ]
0.6526143
0
Transfer money from the platform to this connected account
def transfer(amount:, currency: "usd", **options) ::Stripe::Transfer.create({ amount: amount, currency: currency, destination: processor_id }.merge(options)) rescue ::Stripe::StripeError => e raise Pay::Stripe::Error, e end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def transfer(amount,to,memo=nil)\n client.post(transaction_url,{:amount=>amount,:to=>to,:memo=>memo}) if client\n end", "def transfer(amount, other)\n @balance -= amount\n other.balance += amount\n puts \"#{@owner} your balance will be #{@balance} after the transfering to #{other.owner}\"\n end", "def transfer(amount, destination_account, options={})\n process('transfer', amount, options) do |gw|\n gw.transfer(amount.cents, destination_account, options)\n end\n end", "def transfer_to(account, amount)\n # `account.name` is accessing the name of the account we are transfering to\n debit amount, \"Transfer to #{account.name}\"\n account.credit amount, \"Transfer from #{@name}\"\n end", "def transfer(from_, to, amount)\n eth_sendTransaction(from: from_, to: to, value: amount)\n end", "def transfer( amount:, to:, from: )\n\t\tself.log.info \"%s --{%0.6f𝓩}--> %s\" % [ from, amount, to ]\n\t\tamount = normalize_amount( amount )\n\n\t\traise \"No such wallet #{to}\" unless self.wallets.include?( to )\n\t\traise \"No such wallet #{from}\" unless self.wallets.include?( from )\n\t\traise \"Can't transfer to same wallet #{to}\" if to == from\n\t\traise \"Wallet #{from} doesn't contain enough to cover #{amount}\" unless\n\t\t\tself.wallet_has_at_least?( from, amount )\n\n\t\tself.add_transaction( amount: amount, to: to, from: from )\n\t\tself.log.info \"transfer complete.\"\n\tend", "def transfer(amount, *args)\n do_transaction :transfer_out, amount, *args\n end", "def transferMoneyFromCard\n results1 = postTransaction(@current_user[\"id\"], @current_user[\"id\"], params[:money]) # create initial state\n transact = results1.parsed_response # transact object to get the id in the rest of the process\n if results1.code == 201\n logTransaction(\"Transfer\", transact[\"id\"], @current_user[\"id\"], @current_user[\"id\"], params[:money], \"initial\", 0)\n resultsGet = HTTParty.get(\"http://192.168.99.104:3003/credit_card?id=\"+params[:cardId].to_s)\n userA = (resultsGet[\"user_id\"])\n if userA != (@current_user[\"id\"])\n renderError(\"Forbidden\",403,\"current user has no access\")\n return -1\n else\n if (resultsGet[\"amount\"]<(params[:money]).to_i)\n renderError(\"Bad Request\", 400, \"The credit card do not have enough money\")\n else\n actualMoney=checkMoneyUser(userA)\n newMoneyUser=(actualMoney[\"money\"]).to_f + (params[:money]).to_i\n newMoneyCard=resultsGet[\"amount\"].to_i - (params[:money]).to_i\n optionsCd = {\n :body => {\"amount\": newMoneyCard}.to_json,\n :headers => {\n 'Content-Type' => 'application/json',\n 'Authorization' => request.headers['Authorization']\n }\n }\n resultCd = HTTParty.put(\"http://192.168.99.104:3003/credit_cards?id=\"+params[:cardId].to_s, optionsCd)#subtract money from card\n if resultCd.code == 204\n logUpdateCard(params[:cardId], newMoneyCard, 0)\n results2 = updateTransaction(\"pending\", transact[\"id\"])# put pending state\n if results2.code == 204\n logTransaction(\"Transfer\", transact[\"id\"], @current_user[\"id\"], @current_user[\"id\"], params[:money], \"pending\", 0)\n else\n ##########ERROR EN UPDATE TRANSACCION (pending)###### Se devuelve el dinero a la tarjeta, state incomplete\n undoUpdateCard(params[:cardId], newMoneyCard.to_i , newMoneyCard.to_i + (params[:money]).to_i)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: results4.parsed_response, status: results4.code\n ##########ERROR EN UPDATE TRANSACCION (pending)###### Se devuelve el dinero a la tarjeta, state incomplete\n end\n else\n ##########ERROR EN UPDATE A TARJETA###### Se devuelve el dinero a la tarjeta, state incomplete\n undoUpdateCard(params[:cardId], newMoneyCard.to_i , newMoneyCard.to_i + (params[:money]).to_i)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: resultCd.parsed_response, status: resultCd.code\n ##########ERROR EN UPDATE TRANSACCION (pending)###### Se devuelve el dinero a la tarjeta, state incomplete\n end\n resultUs = updateMoney(newMoneyUser, userA.to_s) #add money to user\n if resultUs.code == 204\n logUpdateMoney(userA.to_s, newMoneyUser, 0)\n results3 = updateTransaction(\"complete\", transact[\"id\"])# put complete state\n if results3.code == 204\n logTransaction(\"Transfer\", transact[\"id\"], @current_user[\"id\"], @current_user[\"id\"], params[:money], \"complete\", 0)\n subject = \"Transferencia de tarjeta de credito\"\n content = \"Has recibido una transferencia de la cuenta \" + params[:cardId].to_s + \" por valor de $\" + (params[:money]).to_s\n createNotification(@current_user[\"id\"],subject, content, @current_user_notification_key)\n head 201 # transaction created and state complete\n else\n ##########ERROR EN UPDATE TRANSACCION (complete)###### Se devuelve el dinero a la tarjeta, y se le resta al usuario state incomplete\n #le quita al que recibe\n undoUpdateMoney(params[:userid], newMoneyUser.to_f , newMoneyUser.to_f - (params[:money]).to_i)\n #le pone dinero de nuevo a la tarjeta\n undoUpdateCard(params[:cardId], newMoneyCard.to_i , newMoneyCard.to_i + (params[:money]).to_i)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: results3.parsed_response, status: results3.code\n ##########ERROR EN UPDATE TRANSACCION (complete)###### Se devuelve el dinero a la tarjeta, y se le resta al usuario state incomplete\n end\n else\n ##########ERROR EN UPDATE MONEY###### Se devuelve el dinero a la tarjeta, y se le resta al usuario state incomplete\n #le quita al que recibe\n undoUpdateMoney(params[:userid], newMoneyUser.to_f , newMoneyUser.to_f - (params[:money]).to_i)\n #le pone dinero de nuevo a la tarjeta\n undoUpdateCard(params[:cardId], newMoneyCard.to_i , newMoneyCard.to_i + (params[:money]).to_i)\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], params[:userid], params[:amount], \"incomplete\", 1)\n end\n render json: resultUs.parsed_response, status: resultUs.code\n ##########ERROR EN UPDATE MONEY###### Se devuelve el dinero a la tarjeta, y se le resta al usuario state incomplete\n end\n end\n end\n else\n resultsError = updateTransaction(\"incomplete\", transact[\"id\"])\n if resultsError.code == 204\n logTransaction(\"Transaction\", transact[\"id\"], @current_user[\"id\"], @current_user[\"id\"], params[:money], \"incomplete\", 1)\n end\n render json: results1.parsed_response, status: results1.code\n end\n end", "def transfer(amount, address)\n amount = cast_amount(amount)\n raise Mobius::Client::Error::InsufficientFunds if app_balance < amount\n submit_tx { |operations| operations << payment_op(amount, dest: address, src: user_keypair) }\n rescue Faraday::ClientError => err\n handle(err)\n end", "def transfer(amount, currency, wallet_from, wallet_to)\n params = {\n amount: amount.to_s,\n currency: currency.upcase,\n walletfrom: wallet_from.downcase,\n walletto: wallet_to.downcase\n }\n authenticated_post(\"transfer\", params: params).body\n end", "def transfer(to_account, amount)\n to_acc = Account.find_by(id: to_account)\n\n if to_acc.nil?\n self.errors.add(\"Transaction denied! Cannot get data of account.\")\n return\n end\n\n if self.balance<amount\n self.errors.add(\"Transaction denied! Insufficient ballance to cover transfer amount.\")\n return\n end\n\n Transaction.transfer(self.id, to_account, amount, \"A2A\")\n end", "def transfer_funds_to(amount, target)\n self.balance -= amount\n target.balance += amount\n Account.transaction do\n raise \"Transaction Failed\" unless self.save && target.save && self.balance >0\n end\n end", "def run_transfer_of(amount)\n self.balance += amount\n end", "def transferir(conta_destino, valor)\n sacar(valor)\n conta_destino.depositar(valor)\n end", "def transfer(amount, destination_account, options={})\n process('transfer', amount) do |gw|\n gw.transfer(amount, destination_account, options)\n end\n end", "def transfer_funds()\n vendor = Portfolio.find(self.seller_id)\n customer = Portfolio.find(self.buyer_id)\n amount = self.transaction_cost\n customer.balance -= amount\n vendor.balance += amount\n \n Transactor.transaction do \n raise \"Transaction of funds failed!\" unless customer.save && vendor.save\n end\n end", "def send_money(amount)\n fail unless amount >= 0\n self.credits += amount\n end", "def call!\n account_from.update_balance!(side: :-, amount: amount)\n account_to.update_balance!(side: :+, amount: amount)\n end", "def transfer_pending_to_money\n @pending_money.each do |coin, value|\n @money[coin] += value\n @pending_money[coin] = 0\n end\n update_pending\n update_money\n end", "def transfer(other_client)\n volume = @options[:volume]\n transfer_btc(volume, other_client)\n end", "def transfer(from, to, amount, options={})\n if from.is_a? PiggyBankAccount\n return from.transfer(to, amount, options)\n end\n false\n end", "def transfer_funds\n Dialog::space\n @acct_list = bank.account_list(@man_name, @man_pin)\n @account_id_array = Display::account_info(@acct_list)\n from = Dialog::transfer_acct_1\n to = Dialog::transfer_acct_2\n how_much = Dialog::transfer_ammount\n bank.money_transfer(from, to, how_much)\n end", "def transfer client\n interface.send_money client.address, @options[:volume]\n end", "def deposit(money)\n self.balance = (self.balance + money)\n end", "def deposit(money_to_deposit)\n @balance += money_to_deposit\n end", "def deposit(amount)\n @balance += amount\n end", "def deposit(amount)\n @balance += amount\n end", "def deposit(amount)\n @balance += amount\n end", "def deposit(amount)\n @balance += amount\n end", "def deposit(amount)\n @balance += amount\n end", "def deposit(amount)\n @balance += amount\n end", "def deposit(amount)\n @balance += amount\n end", "def transfer_to_stakeholders_account params\n Notifyer.print( 'Stake#transfer_to_stakeholders_account' , params: params ) if Rails.env.development?\n \n \n begin\n order_item = Shop::OrderItem.cached_find( params[:order_item_id] )\n params[:application_fee] = Admin.digiramp_fees( params[:amount] )\n\n \n # sending transfers with same sender and recipient will fail\n begin\n send_micro_transaction params\n rescue => e\n errored('Stake#transfer_to_stakeholders_account', e ) unless Rails.env.development?\n Notifyer.print( 'Stake#transfer_to_stakeholders_account' , \"Not sending money to origin account\" ) if Rails.env.development?\n end\n \n update_income params\n\n rescue => e\n errored('Stake#transfer_to_stakeholders_account', e )\n end \n end", "def transferir(conta, valor)\n \n if self.saldo > valor\n if valor > 1000 #Se a transferencia for maior que 1000 \n retirar_valor(valor+self.taxa)\n depositar_valor(conta,valor) \n else\n depositar_valor(conta,valor) \n retirar_valor(valor)\n end\n else\n p \"Nao e possivel transferir R$#{valor} para #{conta.proprietario}\" \n end\n \n end", "def deposit(cash)\n @balance += cash\n end", "def deposit(amount)\n @balance += amount\n @balance\n end", "def deposit(amount)\n @balance = @balance + amount\n end", "def give_back_money\n if(@transaction.sender)\n @transaction.sender.balance += @transaction.amount\n @transaction.sender.save\n \n end\n\n if(@transaction.receiver)\n @transaction.receiver.balance -= Monetize.parse(convert(Money.new(@transaction.amount,findCurrency(@transaction.sender_id,@transaction.receiver_id,'sent')), @transaction.receiver.currency)).fractional\n @transaction.receiver.save\n end\n end", "def add_bank_transfer(from, to, amount)\n amount = amount.round(2)\n logger.debug \"Transferring #{amount} from #{from} to #{to}\"\n @api.put('BankTransfers', {\n 'FromBankAccount' => { 'Code' => from },\n 'ToBankAccount' => { 'Code' => to },\n 'Amount' => amount,\n 'Date' => @export.date.strftime('%Y-%m-%d')\n })['BankTransfers'].first\n end", "def deposit(money)\n @balance += money\nend", "def cash_out\n player.wallet = @wallet\n end", "def transfer_logic(receiver_id, amount)\n receiver = User.find(receiver_id)\n sender = current_user\n sender.credits -= amount\n receiver.credits += amount\n sender.save\n receiver.save\n login(sender)\n end", "def transfer(*args)\n commit 'MassPay', build_mass_pay_request(*args)\n end", "def transfer(tx)\n pay_id = get_payment_id(tx.id)\n puts \" the transaction will be transferred here ... for payment id : \" , get_payment_id(tx.id) , \" the listing author is : \" , tx.listing_author_id\n seller_account = razorpay_accounts_api.get(person_id: tx.listing_author_id, community_id: tx.community_id).data\n if seller_account && seller_account[:verification_status] == \"activated\"\n razorpay_api.direct_transfer(community: tx.community_id, payment_id: pay_id, amount: order_total(tx).cents - order_commission(tx).cents, razorpay_account_id: seller_account[:razorpay_account_id])\n else \n raise \"The Seller Account is not verified\"\n end \n payment = {}\n Result::Success.new(payment)\n rescue => exception\n Result::Error.new(exception.message)\n end", "def transfer_funds\n @organizer = Organizer.find(params[:id])\n @amount = raw_price(params[:amount])\n @current = raw_price(params[:current])\n\n if params[:amount].nil?\n @status = \"danger\"\n @message_status = \"Você não especificou um valor\"\n return\n end\n\n @bank_account_active_id = @organizer.marketplace.bank_account_active.own_id\n if @bank_account_active_id.nil?\n @status = \"danger\"\n @message_status = \"Você não tem nenhuma conta bancária ativa no momento\"\n else\n if @amount <= @current\n bank_transfer_data = {\n \"amount\" => @amount,\n \"transferInstrument\" => {\n \"method\" => \"BANK_ACCOUNT\",\n \"bankAccount\" => {\n \"id\" => @bank_account_active_id,\n }\n }\n }\n response_transfer = RestClient.post(\"#{Rails.application.secrets[:moip_domain]}/transfers\", bank_transfer_data.to_json, :content_type => :json, :accept => :json, :authorization => \"OAuth #{@organizer.marketplace.token}\"){|response, request, result, &block|\n case response.code\n when 401\n @status = \"danger\"\n @message_status = \"Você não está autorizado a realizar esta transação\"\n @response_transfer_json = JSON.load response\n when 400\n @status = \"danger\"\n @message_status = \"Não foi possíel realizar a transferência\"\n @response_transfer_json = JSON.load response\n when 200\n @status = \"danger\"\n @message_status = \"Não foi possível realizar a transferência\"\n @response_transfer_json = JSON.load response\n when 201\n @status = \"success\"\n @message_status = \"Solicitação de transferência realizada com sucesso\"\n @response_transfer_json = JSON.load response\n MarketplaceMailer.transfer(@organizer, friendly_price(@response_transfer_json[\"amount\"]), l(@response_transfer_json[\"updatedAt\"].to_datetime, format: '%d de %B de %Y as %Hh%M')).deliver_now\n else\n @activation_message = \"Não conseguimos resposta do MOIP para a transferência soliticata, verifique os dados novamente.\"\n @activation_status = \"danger\"\n @response_transfer_json = JSON.load response\n end\n }\n else\n @status = \"danger\"\n @message_status = \"Você não tem fundos suficientes para realizar esta transferência\"\n end\n end\n\n end", "def deposit(amount_of_money)\n return @balance + amount_of_money\n end", "def transact(sender:, value:, to:)\n sender_account = find_account(sender)\n raise VMError.new(\"balance not enough\") if sender_account.balance < value\n add_touched_account(sender)\n add_touched_account(to)\n state.add_balance(sender, -value)\n state.add_balance(to, value)\n end", "def transfer ( bank, person, amount)\r\n\t\tif @bank_listing[person.id_number][:balance] >= amount\r\n\t\t\t@bank_listing[person.id_number][:balance]-=amount\r\n\t\t\tputs \"#{@bank_name}: #{person.name}, your transfer of #{amount} to #{bank.bank_name} is complete.\"\r\n\t\t\tbank.deposit(person, amount)\r\n\t\telse\r\n\t\t\tputs \"#{@bank_name}: Sorry #{person.name}, insufficient funds.\"\r\n\t\tend\r\n\t\t\t\r\n\tend", "def withdraw!(amount, destination_account_id, dedupe_id = SecureRandom.uuid)\n data = {\n amount: amount,\n destination_account_id: destination_account_id,\n dedupe_id: dedupe_id,\n }\n\n response = Monzo.client.put(\"/pots/#{@id}/withdraw\", data)\n parsed_response = parse_response(response)\n update_self(parsed_response)\n end", "def deposit (amount, account)\n if account == \"checking\"\n @checking_account_balance += amount\n elsif account == \"saving\"\n @saving_account_balance += amount\n else\n puts \"No account was selected\"\n end\n end", "def deposit(amt)\n @bank_acct += amt\n puts \"Your balance is #{@bank_acct}.\"\n end", "def transfer_credits_to(receiver, amount)\r\n fail if receiver.nil?\r\n raise TradeError, \"NOT_ENOUGH_CREDITS \" unless self.credits >= amount\r\n\r\n self.credits -= amount\r\n receiver.credits += amount\r\n end", "def deposit(amount)\n self.balance = (self.balance + amount).round(2)\n self.save!\n end", "def social_money_send\n parms = params.require(:sendMoney).permit(:accountid, :amount, :currency, :message, :global)\n social_money_send_internal(parms[:amount], parms[:message], parms[:global], parms[:accountid], parms[:currency])\n end", "def deposit(name, amount)\n find_account(name)[:balance] += amount\n end", "def will_transfer(amount, *args)\n do_scheduled_transaction :transfer_out, amount, *args\n end", "def payment(amount)\n @balance -= amount\n end", "def after_confirmation\n Transfer.create(\n receiver: self,\n amount: 1_000.0,\n source_currency: 'USD',\n target_currency: 'USD',\n exchange_rate: 1.0,\n status: Transfer::SUCCESS\n )\n super\n end", "def transfer\n @purchase = Purchase.find_by(invoice_id: params[:invoice_id])\n authorize(@purchase)\n @bank_account = BankAccount.first\n end", "def transfer_money\n\n @recipient_details = BankDetail.where(\"user_id =?\", params[:poster_id]).first\n\n @booking = Booking.find(params[:booking_id])\n\n if @recipient_details\n\n @price = @booking.price.to_i\n data = PaymentTransfer.transfer_money_to_poster(@booking,@recipient_details)\n if data.class == Stripe::InvalidRequestError\n redirect_to :back, :notice => \"Stripe error while creating customer: #{data.message}\"\n else\n redirect_to payement_transfers_path\n flash[:notice] = \"Payement was successfully transfered to #{@recipient_details.stripe_card_id_token}. Amount transfer to poster $#{data[0]} and commision is $#{data[1]}\"\n end\n else\n transfer_payment = @booking.update_columns(comment: \"Waiting for poster bank account.\")\n flash[:error] = \"No bank detail added for payment\"\n redirect_to payement_transfers_path\n\n end\n end", "def exchange_to(other_currency)\n self.class.bank.exchange(self, other_currency)\n end", "def sendEtherForGas(etherAccount)\n set_client(SUPPLIER_ADDRESS, SUPPLIER_PASSWORD)\n @client.eth_send_transaction({\n \"from\": SUPPLIER_ADDRESS,\n \"to\": etherAccount,\n \"value\": \"0x3b9aca00\"\n })\n puts \"Success send ether from #{SUPPLIER_ADDRESS} to #{etherAccount}\"\n end", "def transfer_funds!\n self.transfer = Stripe::Transfer.create(transfer_params)\n end", "def deposit(amount, *args)\n do_transaction :deposit, amount, *args\n end", "def execute_transaction\n#each transfer can only happen once\n if valid? && sender.balance > amount && self.status == \"pending\"\n receiver.balance += amount\n sender.balance -= amount\n self.status = \"complete\"\n else\n#rejects a transfer if the sender doesn't have a valid account\n reject_transfer\n end\n end", "def deposit(amount)\n \n #return if amount_is_not_valid(amount)\n ActiveRecord::Base.transaction do\n #note: need to use self or Account as a prefix when using balance, since it is not a variable or anythign defined in tis class\n self.update!(balance: self.balance + amount)\n end \n end", "def withdraw(amount)\n @balance = @balance - amount\n end", "def deshacer\n entidad.deposit monto, operadora\n end", "def put_money(amount, player)\n if amount > player.money\n amount = player.money\n end\n if amount + player.in_pot_current > self.high_bet # if player is new high bet (bets more than current highest)\n self.high_bet = amount + player.in_pot_current\n self.high_better = player.location\n end\n player.money -= amount # puts money in correct places and takes from player's pot\n player.in_pot_current += amount\n player.in_pot_hand += amount\n self.pot += amount\n player.save\n self.save\n end", "def transfer\n return false if @source_account_id == @destination_account_id\n return false unless @amount > 0\n return false unless Account.exists?(@source_account_id) &&\n Account.exists?(@destination_account_id)\n return false if AccountService.new(@source_account_id).balance < @amount\n\n create_traders\n end", "def deposit(amount)\n @balance += amount\n puts \"#{money_convert(balance)}\"\n return @balance\n end", "def deposit(amount)\n @balance += amount\n puts \"Deposit #{amount}. New Balance: $#{@balance}\"\n returned\n end", "def transfer(options = {})\n @operations << options.merge(type: :transfer, from: account_name)\n \n self\n end", "def transfer(options = {})\n @operations << options.merge(type: :transfer, from: account_name)\n \n self\n end", "def deposit(user, amount)\n user.with_lock do\n user.my_wallet.balance += amount.to_f\n user.my_wallet.save!\n end\n end", "def deposit(amount)\n @balance += amount\n return @balance\n end", "def add_money\n\t\t# get current user's money\n \t@user = current_user\n\t\t@money = @user.money\n\t\t# get refill limit\n\t\t@allowed = @user.money_refill\n\n\t\t# if limit has not been reached, add money to account\n\t\tif @allowed > 0\n\t\t\t@user.money = @money + 1000\n\t\t\t@user.money_refill = @allowed - 1\n\t\t\t@user.save\n\t\t\tgflash :success => \"Money Successfully Transferred to your account!\"\n\t\t\tredirect_to :action => 'profile', :username => @user.login\n\t\telse\n\t\t\t# otherwise flash pop up regarding depleted money reserve\n\t\t\tgflash :error => \"You have depleted your money reserve.\"\n\t\t\tredirect_to :action => 'profile', :username => @user.login\n\t\tend\n end", "def send_money(params)\n fail ArgumentError, 'Hash is expected as params' unless params.is_a?(Hash)\n fail ArgumentError, 'String is expected as :amount' unless params[:amount].is_a?(String)\n fail ArgumentError, 'String is expected as :address' unless params[:address].is_a?(String)\n fail ArgumentError, 'Invalid amount format' unless params[:amount] =~ /^\\d+\\.\\d+$/\n fail ArgumentError, 'Invalid address format' unless params[:address] =~ /^[A-Za-z0-9]+$/\n Cubits.connection.post(\n '/api/v1/send_money',\n amount: params[:amount], address: params[:address]\n )\n end", "def transfer(options={})\n self.transfer_amount = Money.new(0, self.person ? self.person.default_currency : 'USD') unless self.transfer_amount\n \n return Response.new(false, transfer_amount, :transfer, \n :description => self.errors.full_messages.to_sentence) unless self.valid?\n\n result = Response.new\n PiggyBankAccount.transaction do\n self.person.piggy_bank.lock!\n begin\n I18n.switch_locale(self.person.default_locale) do\n # transfer net transfer amount to paypal\n response = PaypalDepositAccount::gateway.transfer(\n self.net_transfer_amount, # money amount of type Money\n self.paypal_account, # paypal account (email)\n :subject => MESSAGE_PAYPAL_SUBJECT.t % {\n :name => self.person.name\n },\n :description => MESSAGE_PAYPAL_DESCRIPTION.t % {\n :account => self.paypal_account,\n :name => self.person.name,\n :gross_amount => self.gross_transfer_amount.format,\n :net_amount => self.net_transfer_amount.format,\n :fee => self.transaction_fee.abs.format,\n :date => Date.today.to_s(:short)\n }\n )\n \n if response.success?\n # withdraw gross transfer amount from user's piggy bank\n result = self.person.piggy_bank.withdraw(\n self.gross_transfer_amount,\n options.merge(\n :fee => false,\n :description => MESSAGE_USER_PIGGY_BANK_DESCRIPTION.t % {\n :account => self.paypal_account,\n :name => self.person.name,\n :gross_amount => self.gross_transfer_amount.format,\n :net_amount => self.net_transfer_amount.format,\n :fee => self.transaction_fee.abs.format,\n :date => Date.today.to_s(:short)\n }\n )\n )\n\n # ...and deposit the transaction fee to Probono's piggy bank\n if result.success?\n result.fee = self.transaction_fee\n probono_result = Organization.probono.piggy_bank.deposit(\n self.transaction_fee.abs,\n options.merge(\n :description => MESSAGE_PROBONO_PIGGY_BANK_DESCRIPTION.t % {\n :account => self.paypal_account,\n :name => self.person.name,\n :gross_amount => self.transfer_amount.format,\n :net_amount => (self.transfer_amount - self.transaction_fee.abs).format,\n :fee => self.transaction_fee.abs.format,\n :date => Date.today.to_s(:short)\n }\n )\n )\n end\n else\n result = Response.new(response.success?, self.transfer_amount, :transfer)\n result.authorization = response.authorization\n result.description = response.message\n result.params = response.params\n result.test = response.test?\n end\n end\n rescue ActiveMerchant::ActiveMerchantError => e\n result = Response.new(false, self.transfer_amount, :transfer)\n result.authorization = nil\n result.description = e.message\n result.params = {}\n result.test = PaypalDepositAccount::gateway.test?\n end\n end\n result\n end", "def add_money_to_wallet\n puts \"\\n-----------------------\".colorize(:blue)\n puts \"How much more money do you want to add?\".colorize(:red)\n print \"> $\"\n new_money = gets.to_i\n @player.wallet += new_money\n puts \"Your wallet now has: $#{@player.wallet}\".colorize(:blue)\n end", "def others_transfer_same_bank(client, client1, amount)\n puts \"Seleccione la cuenta origen de la cual trasladara los fondos (opciones ahorro o corriente):\"\n origin = gets.chomp.to_s.downcase\n puts \"Seleccione a que cuenta desea trasladar los fondos:\"\n puts \"Ahorro #{client1.saving_account} opcion 1\"\n puts \"Corriente #{client1.check_account} opcion 2\"\n destination = gets.chomp.to_i\n\n if origin == \"ahorro\" && destination == 1\n if client.saving_amount >= amount\n client.saving_amount -= amount\n client1.saving_amount += amount\n success_transfer\n else\n no_money\n end\n elsif origin == \"ahorro\" && destination == 2\n if client.check_amount >= amount\n client.saving_amount -= amount\n client1.check_amount += amount\n success_transfer\n else\n no_money\n end\n elsif origin == \"corriente\" && destination == 1\n if client.check_amount >= amount\n client.check_amount -= amount\n client1.saving_amount += amount\n success_transfer\n else\n no_money\n end\n elsif origin == \"corriente\" && destination == 2\n if client.saving_amount >= amount\n client.check_amount -= amount\n client1.check_amount += amount\n success_transfer\n else\n no_money\n end\n else \n return \"Las opciones validas son ahorro y corriente\"\n end \n end", "def update_transfer\n return unless $game_player.transfer?\n transfer_player\n end", "def close_account\n self.void_pending_authorizations\n if probono = Organization.probono\n if probono.piggy_bank && probono.piggy_bank.reload && probono.piggy_bank != self\n result = self.transfer(probono.piggy_bank, self.available_balance, :limits => false) if probono.piggy_bank\n raise BankError, \"remaining funds could not be transferred\" if !result || !result.success?\n end\n end\n end", "def deposit(deposit_amount)\n self.balance += deposit_amount\n end", "def money\n Spree::Money.new(amount, { currency: currency })\n end", "def withdraw(amount)\n @balance -= amount\n end", "def withdraw(amount)\n @balance -= amount\n end", "def deposit(account_id, accounts,action)\n account = accounts[account_id]\n show_message \"Enter amount to deposit in your account\"\n money_to_deposit = gets.chomp.to_i\n balance=account[:balance]\n #accounts[:account_id].store :balance ,balance+money_to_deposit\n account[:balance] = balance + money_to_deposit\n show_message \"wooow !!! transaction sucessful..your current balance is #{account[:balance]}\"\n create_history(account_id,accounts,action,money_to_deposit,account[:balance])\nend", "def deduct_wallet\n user = User::find(self.user_id)\n user.budget -= self.pending_money\n user.save\n\n self.pending_money = 0\n self.save\n end", "def send_money_to(receiver, amount, note=nil)\n debits.create!(receiver: receiver, amount: amount, note: note)\n end", "def create\n @transfer = Transfer.new(transfer_params)\n\n from_account = Account.find(@transfer.from_account_id)\n to_account = Account.find(@transfer.to_account_id)\n\n if (from_account.id != to_account.id)\n amount = BigDecimal.new(@transfer.amount)\n correlation = Rubybank::Utilities::generate_correlation_code(16)\n if from_account.balance > amount\n add_mutation = Mutation.new(\n account: to_account,\n correlation_code: correlation,\n from_account: from_account,\n comment: @transfer.comment,\n amount: amount\n )\n sub_mutation = Mutation.new(\n account: from_account,\n correlation_code: correlation,\n from_account: to_account,\n comment: @transfer.comment,\n amount: -amount\n )\n\n # Save them in one transaction then redirect\n Mutation.transaction do\n add_mutation.save!\n sub_mutation.save!\n end\n redirect_to from_account, notice: 'Transfer successfully executed.'\n else\n flash.notice = 'Balance is not enough to transfer this amount'\n render action: 'new'\n end\n else\n flash.notice = 'You cannot transfer money to the same account'\n render action: 'new'\n end\n end", "def deposit_cash(deposit_amount)\n @balance += deposit_amount\n end", "def place_bet(amount)\n @total_money -= amount\n end", "def self_transfer(client, amount)\n puts \"Seleccione la cuenta origen de la cual trasladara los fondos (opciones ahorro o corriente):\"\n origin = gets.chomp.to_s.downcase\n case origin\n when \"ahorro\"\n if client.saving_amount >= amount\n client.saving_amount -= amount\n client.check_amount += amount\n success_transfer\n else\n no_money\n end\n when \"corriente\"\n if client.check_amount >= amount\n client.check_amount -= amount\n client.saving_amount += amount\n success_transfer\n else\n no_money\n end\n else \n return \"Las opciones validas son ahorro y corriente\"\n end \n end", "def transfer(to, amount, options={})\n options = {:limits => [\n PiggyBankAccount::MIN_AMOUNT_TO_TRANSFER_IN_CENTS,\n PiggyBankAccount::MAX_AMOUNT_TO_TRANSFER_IN_CENTS\n ]}.symbolize_keys.merge(options)\n\n amount = amount.abs\n min_amount = if options[:limits].is_a?(Array) && options[:limits].first.is_a?(Money)\n Money.new(1, amount.currency) + options[:limits].first - Money.new(1, amount.currency)\n else\n Money.new((options[:limits] || [0, 0]).first || 0, amount.currency)\n end\n max_amount = if options[:limits].is_a?(Array) && options[:limits].last.is_a?(Money)\n Money.new(1, amount.currency) + options[:limits].last - Money.new(1, amount.currency)\n else\n Money.new((options[:limits] || [0, 0]).last || 0, amount.currency)\n end\n\n return Response.new(false, amount, :transfer, :description => I18n.t('activerecord.errors.messages.transfer_greater_or_equal_to') % {\n :count => min_amount.format\n }) if options[:limits] && amount < min_amount\n return Response.new(false, amount, :transfer, :description => I18n.t('activerecord.errors.messages.transfer_less_or_equal_to') % {\n :count => max_amount.format\n }) if options[:limits] && amount > max_amount\n return Response.new(false, amount, :transfer, :description => I18n.t('activerecord.errors.messages.transfer_destination_invalid')) unless to.is_a?(PiggyBankAccount)\n return Response.new(false, amount, :transfer, :description => I18n.t('activerecord.errors.messages.transfer_self_exclusion')) if to == self\n \n options.delete(:limits)\n result = nil\n transaction do\n I18n.switch_locale(self.owners_locale) do\n result = self.withdraw(amount, options.merge(\n :fee => false,\n :description => TRANSFER_MESSAGE.t % {\n :from_type => self.owner.class.human_name, :from_name => self.owners_name,\n :to_type => to.owner.class.human_name, :to_name => to.owners_name,\n :amount => amount.convert_to(self.currency).format, :original => amount.format}))\n end\n if result.success?\n I18n.switch_locale(to.owners_locale) do\n result = to.deposit(amount, options.merge(:description => TRANSFER_MESSAGE.t % {\n :from_type => self.owner.class.human_name, :from_name => self.owners_name,\n :to_type => to.owner.class.human_name, :to_name => to.owners_name, \n :amount => amount.convert_to(to.currency).format, :original => amount.format}))\n end\n end\n end\n if result.success?\n Response.new(true, amount, :transfer, :description => result.message)\n else\n result\n end\n end", "def deposit(amount)\n deposit_account = Account.find_by(account_type: :deposit)\n raise 'No deposit account, has the db been seeded?' if\n deposit_account.nil?\n\n create_transfer('deposit', amount, deposit_account, self)\n end", "def transfer\n @purchase = Purchase.find_by(invoice_id: params[:invoice_id])\n @bank_account = BankAccount.first\n end", "def transfer(raccount, amount, purpose = [])\n end", "def money\n\t\tif @wallet.neg?\n\t\t\t@in_debt = true\n\t\tend\n\t\treturn @wallet.amount\n\tend", "def deposit(amount)\n amount = amount.abs\n @balance = @balance + amount\n one_transaction\n return @balance\n end", "def remove_money(amount)\n @wallet -= amount\nend" ]
[ "0.70087665", "0.7006318", "0.69888043", "0.69229966", "0.69038266", "0.68295", "0.68111616", "0.67981184", "0.6719248", "0.66791123", "0.6669493", "0.66501474", "0.6639558", "0.6621356", "0.6602872", "0.656344", "0.6552691", "0.6551508", "0.65243673", "0.651749", "0.64946085", "0.64774084", "0.6446245", "0.6444279", "0.642062", "0.64065146", "0.64065146", "0.64053756", "0.6391161", "0.6390313", "0.6390313", "0.6390313", "0.63813466", "0.6378474", "0.6377814", "0.6349189", "0.6343687", "0.63188106", "0.6290868", "0.62865424", "0.6277137", "0.62726617", "0.6238731", "0.62385887", "0.62325406", "0.62202007", "0.62106144", "0.6202445", "0.6169176", "0.6134557", "0.61341435", "0.61201334", "0.6119505", "0.6104506", "0.6101034", "0.60738784", "0.60512817", "0.60445905", "0.6006728", "0.60063815", "0.5959059", "0.59570175", "0.5951775", "0.5948172", "0.5947694", "0.59296155", "0.5919701", "0.5918504", "0.59115094", "0.59059477", "0.5904586", "0.58968174", "0.58918285", "0.58918285", "0.5888548", "0.5883097", "0.58770126", "0.587147", "0.5870454", "0.5864281", "0.5855343", "0.5854352", "0.58488077", "0.584294", "0.5834486", "0.582577", "0.5824303", "0.58241177", "0.58223265", "0.5818455", "0.58114433", "0.58011585", "0.5788132", "0.57862854", "0.578191", "0.57807595", "0.5775627", "0.57732123", "0.57696116", "0.5768995", "0.5767153" ]
0.0
-1
Retourne true si l'user a une autorisation icarien
def has_autorisation_icarien?(duser) drequest = { where: {user_id: duser[:id], raison: 'ICARIEN ACTIF'} } table_autorisations_online.count(drequest) > 0 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def fully_authed?\n !(user.nil? || password.nil?)\n end", "def authorized?\n if $credentials != nil\n @Userz = User.first(:username => $credentials[0])\n if @Userz\n if @Userz.edit == true\n return true\n else\n return false\n end\n else\n return false\n end\n end\n end", "def ha_accedido?\n\t\t!usuario_actual.nil?\n\tend", "def status_getuser?()\n return true if (@status == TAC_PLUS_AUTHEN_STATUS_GETUSER)\n return false\n end", "def user?\n get_mode == :user\n end", "def user_authorized?(user)\n user == current_user || is_admin?\n end", "def is_user?\n user ? true : false\n end", "def logado?\n !admin_atual.nil?\n end", "def logado?\n !current_user.nil?\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 authorized\n\t\tif current_user\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\tend", "def authed?(irc)\n if !$user.caps(irc, 'op', 'owner').any?\n irc.reply \"You aren't allowed to use this command\"\n return false\n end\n true\n end", "def is_authorized\n (!current_user.nil? and auth_types.include? current_user.user_attributes[:bor_type])\n end", "def super_user?\n user = check_user\n # user.email == 'vetswithoutborderstamu@gmail.com'\n user.email == 'bryalara@tamu.edu'\n end", "def active_for_authentication?\n super && assigned?\n end", "def user_is_authenticated\r\n !!current_user\r\n end", "def auth?\n true\n end", "def user_is_authorized( user, txn, *args )\n\t\t\tself.log.notice \"No implementation of user_is_authorized for %s\" %\n\t\t\t\t[ self.class.signature.name ]\n\t\t\treturn false\n\t\tend", "def has_auth?\n !current_person.nil?\n end", "def authentication_successful?\n @user.present?\n end", "def cas_authed?\n !session[:cas_user].blank?\n end", "def restricted?\n return ( self.user_type == User::USER_TYPE_NORMAL )\n end", "def user_login?\n\t !!current_user\n\tend", "def authorized?(user)\n true\n end", "def is_potential_user?\n\t\ttrue\n\tend", "def user_is_logged_in()\n user = get_user()\n if user != nil\n true\n else\n false\n end\n end", "def authorize?(user)\n true\n #user.login == \"administrador\"\n end", "def authed_user?\n return true unless @data['hasPhone'].nil?\n\n false\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 authorized?\n logged_in? && current_user.login == \"ej0c\"\n end", "def auth?\n me != nil\n end", "def authorized?\n @current_user ||= User.first(:conditions => {:name => session[:cas_user]})\n !@current_user.nil?\n end", "def authorized?\n # TODO(samstern): Check for expired token.\n !(session[:user_id].nil?)\n end", "def is_valid?\n self.current_user && (self.user == self.current_user || self.current_user.admin?)\n end", "def authed?(irc)\n if !$user.caps(irc, 'phrases', 'op', 'owner').any?\n irc.reply \"You aren't allowed to use this command\"\n return false\n end\n true\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 authentication_successful?\n current_user.present?\n end", "def logged_in_normal_user?\n normal_user.present?\n end", "def user_authenticated?\n !session[:user_id].nil?\n end", "def auth?\n false\n end", "def is_user?\ncurrent_user.username == @userl.username\n end", "def autorun?\n instance.instance_variable_get(:@settings)[:autorun] || false\n end", "def authorized?(user)\n current_user == user\nend", "def check_correct_user(user)\n \tcurrent_user?(user)\n end", "def authorized?\n current_user.login == \"Admin\"\n end", "def authorized?\n true\n end", "def active_for_authentication?\n super && account_active?\n end", "def is_this_user\n\t\t@user.id == current_user.id\n\tend", "def authorized?(tmp_user)\n user == tmp_user\n end", "def admin?\n return false unless authenticated?\n User.exists?(cas_username: session['cas']['user'])\n end", "def current_user?(user)\n \tuser == current_user\n \tend", "def current_user?(user)\n \tuser == current_user\n \tend", "def user_present?\n current_user.present?\n end", "def enabled?\n user.present?\n end", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tuser == current_user\n\tend", "def current_user?(user)\n\t\tcurrent_user == user\n\tend", "def authorized?(user_id)\n logged_in_user_id == user_id\n end", "def authok?\n @authok\n end", "def authok?\n @authok\n end", "def authok?\n @authok\n end", "def authok?\n @authok\n end", "def authorized?\n !auth.nil?\n end", "def authorized?\n @authorized ||= User.get(@env).present?\n end", "def current_user?(user)\r\n user == current_user\r\n end", "def accessible_for?(user)\n user_id == user.id && !user.anonimous?\n end", "def current_user?(user)\n \t\tuser == current_user\n \tend", "def has_user?\n !user.nil?\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 programme_administrator_logged_in?\n User.programme_administrator_logged_in?\n end", "def user_active?\n\t\treturn true if teacher? && !activated\n\tend", "def user\n\t\tfalse\n\tend", "def current_user?(user)\n \t\tuser == current_user\n \tend", "def may_view_user?(user=nil)\n#\t\t\tself.is_user?(user) || self.may_administrate?\n\t\t\tself.is_user?(user) || self.may_administrate?\n\t\tend", "def user_authorised?(&callback)\n authorised = false\n begin\n xml = REXML::Document.new(Net::HTTP.get(URI(\"#{@url}/speaks_fors/#{_user_urn}\")))\n expires = REXML::XPath.first(xml, \"//credential/expires\").text\n authorised = Time.parse(expires) > Time.now\n rescue\n authorised = false\n end\n callback.call(authorised) if callback\n authorised\n end", "def type_authentication?()\n return(true) if(@type == TAC_PLUS_AUTHEN)\n return(false)\n end", "def active_for_authentication?\n super && bloqueado == 0\n end", "def force_authn?\n force_authn == true\n end", "def current_user?(user)\n\t\tuser==current_user\n\tend", "def active_for_authentication? \n super && (approved? || self.admin) \n end", "def active_for_authentication? \n \tsuper && approved?\n \t\n\tend", "def check_if_current_user\r\n User.current_user && User.current_user != self\r\n end", "def active_for_authentication?\n super and self.disponible?\n end", "def normal_user?\n self.admin ==false\n end", "def user?\n is_a?(Merit::User)\n end", "def authorized?\n\n current_user && current_user.is_admin?\n end", "def _is_login\n p session[:user]\n session[:user] ? true : false\n end", "def needs_login?() false end", "def current_user?(user)\n\t\tuser == self.current_user\n\t\t\n\tend", "def _user? name\n\t\tuid = DB[:_user].filter(:name => name).get(:uid)\n\t\tuid ? true : false\n\tend", "def current_user?(user)\n user == current_user\n end" ]
[ "0.75615644", "0.7354853", "0.72822124", "0.72623444", "0.72504246", "0.72224027", "0.71456814", "0.7091601", "0.7083509", "0.7068737", "0.7060223", "0.70302737", "0.70252806", "0.70240587", "0.70169854", "0.6987988", "0.6964478", "0.6964335", "0.6963867", "0.69626135", "0.6960118", "0.6959864", "0.69501406", "0.6943046", "0.6939972", "0.69116384", "0.6908654", "0.6905698", "0.6903276", "0.6900546", "0.6896539", "0.68799704", "0.68779296", "0.6875144", "0.68710756", "0.68655765", "0.6839296", "0.68279517", "0.6826984", "0.68141556", "0.6810255", "0.679917", "0.6795512", "0.67894864", "0.6783713", "0.67802864", "0.67758507", "0.6764432", "0.6760357", "0.675013", "0.6748982", "0.6748982", "0.67464244", "0.6742854", "0.6737981", "0.6737981", "0.6737981", "0.6737981", "0.6737981", "0.6737981", "0.6737981", "0.6737981", "0.6737981", "0.6737981", "0.67378455", "0.67370826", "0.67255086", "0.6725153", "0.6725153", "0.6725153", "0.6725153", "0.67213434", "0.6719062", "0.67160755", "0.6712356", "0.67100805", "0.67068833", "0.67045754", "0.6701993", "0.67018723", "0.6697344", "0.66961086", "0.6695935", "0.6693801", "0.66936505", "0.66899717", "0.6686188", "0.6682246", "0.66781014", "0.6676857", "0.6676244", "0.6666019", "0.66618854", "0.6661622", "0.665863", "0.66564536", "0.6655295", "0.6652578", "0.6641342", "0.6640375" ]
0.7055177
11
authenticate an end user through api (creator)
def authenticate_api_token if request.headers["Authorization"].present? auth_header = request.headers['Authorization'].split(' ').last #try to get the data from jwt token @payload = decode auth_header #couldnt get data for whatever reason if !@payload render json: { error: "Problem med autentiseringssträngen. Försök att logga in igen." }, status: :bad_request #success! else @payload end #no token was sent with header else render json: { error: "En autentiseringssträng krävs."}, status: :forbidden # The header isn´t present end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def api_auth\n creator = Creator.find_by(username: request.headers[:username])\n if creator && creator.authenticate(request.headers[:password])\n render json: { auth_token: encodeJWT(creator) }\n else\n render json: { error: 'Invalid username or password' }, status: :unauthorized\n end\n end", "def api_auth\n # output the APIkey from the header\n # puts request.headers[\"X-APIkey\"];\n creator = Creator.find_by(creator: request.headers[:creator])\n if creator && creator.authenticate(request.headers[:password])\n render json: { auth_token: encodeJWT(creator), id: creator.id}\n else\n render json: { error: 'Invalid username or password' }, status: :unauthorized\n end\n end", "def api_login\n creator = Creator.find_by(name: request.headers['name'])\n if creator && creator.authenticate(request.headers['password'])\n encode = encodeJWT(creator)\n selected_format({jwt: encode,creator_id: creator.id,name: creator.name,submits:creator.submits},:ok)\n else\n selected_format({ error: 'Invalid username or password' },:unauthorized)\n end\n end", "def create\n # login\n user = User.authenticate(params[:user][:email], params[:user][:password])\n\n respond_to do |format|\n if user\n # Create an api token for this user.\n user.enable_api!\n format.json { render :json => user }\n else\n format.json { head :unauthorized }\n end\n end\n end", "def create_non_admin_user_authenticate\n post '/users', 'username' => 'testuser', 'password' => 'testpassword', 'email_address' => 'test@toto.com'\n id_user = last_response.json_body['id']\n digest_authorize 'testuser', 'testpassword'\n id_user\nend", "def create\n user_response = API::V1::Users.authenticate params.as_json\n if user_response.success?\n json = HashWithIndifferentAccess.new(user_response.parsed_response)\n auth_response = API::V1::Auth.issue json[:data]\n respond_with auth_response.body, auth_response.code\n else\n respond_with nil, :unauthorized\n end\n end", "def authenticate\n api_token = request.headers[\"ApiToken\"]\n apiUser = ApiUser.where(api_token: api_token).first\n\n if !apiUser.nil?\n user =\n AuthenticateUser.new(auth_params[:email], auth_params[:password],apiUser.id, true).call\n\n render json: user\n else\n json_response({ message: Message.invalid_api_token }, 422)\n end \n end", "def auth\n end", "def auth\n end", "def authenticate\n #Hace el llamado de la clase AuthenticaUser, manda los parametros de :username y :password\n #Realiza el metodo call para obtener el Token del user_id\n #Arroja el token como Json_response\n auth_token = AuthenticateUser.new(auth_params[:username], auth_params[:password]).call \n json_response(auth_token: auth_token)\n end", "def authenticate\n json_response(\n auth_token: AuthenticateUser.new(\n auth_params[:username],\n auth_params[:password]\n ).call\n )\n end", "def authenticate_user\n @current_user = User.find_by_api_key(params[:api_key])\n end", "def authenticate!\n\t\t@current_user = AuthorizeApiRequest.call(request.headers).result\n\t\t# If unauthorized return an error to the front end\n\t\trender json: {error: 'Not Authorized'}, status: 401 unless @current_user\n\tend", "def api_auth \n # output the APIkey from the header\n # puts request.headers[\"X-APIkey\"]; \n user = User.find_by(email: params[:email].downcase)\n if user && user.authenticate(params[:password])\n render json: { auth_token: encodeJWT(user) }\n else\n render json: { error: 'Invalid username or password' }, status: :unauthorized\n end\n end", "def authenticate\n auth_token =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n json_response(auth_token: auth_token)\n end", "def authenticate\n auth_response =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n json_response(auth_token: auth_response[:token], user_name: auth_response[:user_name])\n end", "def authenticate\n\t\tauth_token =\n\t\t\tAuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n\t\tjson_response(auth_token: auth_token)\n\tend", "def authenticate\n auth_token =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n json_response(auth_token: auth_token)\n end", "def login_api\n @user = User.find_for_database_authentication({:username => params[:username].downcase})\n\n if (!@user.nil?)\n if (!@user.valid_password?(params[:password]))\n @user = nil\n end\n end\n\n if (@user.nil?)\n @user = User.find_by_auth_token(params[:auth_token]) unless params[:auth_token].nil?\n else\n @user.generate_auth_token\n end\n\n if @user.nil?\n # Do nothing\n error \"Your username or password was incorrect.\"\n else\n render json: @user\n end\n end", "def login_api\n @user = User.find_for_database_authentication({:username => params[:username].downcase})\n\n if (!@user.nil?)\n if (!@user.valid_password?(params[:password]))\n @user = nil\n end\n end\n\n if (@user.nil?)\n @user = User.find_by_auth_token(params[:auth_token]) unless params[:auth_token].nil?\n else\n @user.generate_auth_token\n end\n\n if @user.nil?\n # Do nothing\n error \"Your username or password was incorrect.\"\n else\n render json: @user\n end\n end", "def api_authenticate\n unless params[:api_key] == \"oz\" || api_user\n render :json => {:error => \"API key not found\"}, :status => :unauthorized\n end\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 authenticate_api!\n find_case\n return true if @case&.public? || current_user\n\n render json: { reason: 'Unauthorized!' },\n status: :unauthorized\n end", "def api_login\n employee = Employee.find_by(IDnum: params[:IDnum])\n if employee && employee.authenticate(params[:password])\n \tif employee.status = \"Active\"\n \t\ttoken = employee.generate_api_token\n \tdistribute_api_token(employee.IDnum, token)\n \trender(json: {\"api_token\" => employee.api_token}.to_json, status: 201)\n \telse\n \t\tmsg = { :status => \"ERROR\", :message => \"Access Denied: No longer active employee\" }\n \trender :json => msg, status: :forbidden\n \tend\n else\n msg = { :status => \"ERROR\", :message => \"Invalid ID number and password combination\" }\n render :json => msg, status: :forbidden\n end\n end", "def authenticate\n api_key = parse_auth_token(request.headers['HTTP_AUTHORIZATION'])\n return user_not_authorized if api_key.nil?\n @real_user = User.find_by(api_key: parse_auth_token(request.headers['HTTP_AUTHORIZATION']))\n user_not_authorized if @real_user.nil?\n end", "def create_with_api\n begin \n @num_users = User.all.size\n user = User.from_omniauth(request.env[\"omniauth.auth\"])\n log_in user\n if @num_users == (User.all.size - 1)\n redirect_to edit_user_path(user)\n flash[:success] = \"Log in successful! Please set a password and update \n any additional information.\"\n else \n redirect_back_or edit_user_path(user)\n end\n rescue\n flash[:warning] = \"There was an error during the authentication \n process. \"\n redirect_to root_url\n end\n end", "def api_auth\n\t\tauth ::UApi\n\tend", "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 authenticate_request\n auth_header_token = request.headers[\"Authorization\"]\n @current_user = AuthorizeApiRequest.new(auth_header_token).call\n render json: { error: \"Not Authorized\" }, status: 401 unless @current_user\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 authenticate\n end", "def authenticate\n authenticated_user = AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n response = { message: Message.logged_in, auth_token: authenticated_user[:auth_token], is_doctor: authenticated_user[:is_doctor], doctor_id: authenticated_user[:doctor_id], fullname: authenticated_user[:fullname], date_of_birth: authenticated_user[:date_of_birth] }\n json_response(response)\n end", "def prompt_user_authorisation\n\n require './app/routes/web'\n\n # Start local API\n Launchy.open(\"http://localhost:5000/cli/auth\")\n\n auth_thread = Thread.new do\n Linkedin2CV::Routes::Web.run!\n end\n\n auth_thread\n end", "def authenticate_user(username, password)\n api(\"AuthenticateUser\", username, password)\n end", "def create\n command = V1::Commands::AuthenticateUser.call(\n email: params.dig(:auth, :email),\n password: params.dig(:auth, :password)\n )\n\n if command.success?\n # render json: command.result, status: :created\n render_success_json(:created, result: command.result)\n else\n render_failure_json(:unauthorized)\n end\n end", "def authenticate\n email = auth_params[:email]\n password = auth_params[:password]\n auth_token = AuthenticateUser.new(email, password).call\n user = User.find_by(email: email)\n\n json_response({\n user: {\n **user.get_sanitized_user,\n auth_token: auth_token,\n }\n }, :accepted)\n end", "def current_api_user\n unless current_api_user?\n render json: { errors: \"Not authenticated\" },\n status: :unauthorized\n end\n end", "def authenticate\n user = User.find_by(email: auth_params[:email])\n auth_token =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n response = { :info => {:id => user.id, :email => user.email, :username => user.username}, \n :message => 'welcome',\n :auth_token => auth_token,\n :custom_fields => user.custom_fields,\n :favorites => favorites(user)}\n json_response(response, :created)\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 command = AuthenticateUser.call(params[:email], params[:password])\n\n if command.success?\n json_response(auth_token: command.result)\n else\n json_response({ error: command.errors }, :unauthorized)\n end\n end", "def login\n #localhost:3000/api/login -u 'admin:password'\n authenticate_or_request_with_http_basic do |username, password|\n if username.include? '%40'\n email = username.gsub('%40','@');\n @user = User.find_by_email(email.downcase)\n else\n @user = User.find_by_username(username.downcase)\n end\n\n if @user && @user.authenticate(password)\n remember_token = RememberToken.create(token: User.encrypt(User.new_remember_token), user_id: @user.id, accessed_at: Time.now)\n respond_to do |format|\n format.json { render :json => remember_token }\n end\n end\n end\n end", "def authenticate_with(identity, next_service, username); end", "def authenticate_request\n @current_user = AuthorizeApiRequest.call(request.headers).result\n render json: { error: 'Not Authorized' }, status: 401 unless @current_user\n end", "def authenticate\n @apikey = request.headers[:apikey]\n if @apikey==nil || @apikey!= APIKEY\n json_response={\n error: 'autorization error'\n }\n respond_with json_response, location: nil\n end\n end", "def auth\n\n @user = current_user\n render json: @user\n \n end", "def setup_api\n if white_listed?(path)\n @api = Api.new\n return\n end\n\n email, password = http_basic_auth_info\n\n if !email.blank? and !password.blank?\n user = User.find_by_email(email)\n if user.password == password\n @api = Api.new(user)\n else\n render(:nothing => true, :status => :unauthorized)\n return\n end\n else\n begin\n if current_user\n @api = Api.new(current_user)\n else\n render(:nothing => true, :status => :unauthorized)\n end\n rescue NameError\n @api = Api.new\n end\n end\n end", "def authenticate!\n # if the authentication header is an acceptible value\n if @env['HTTP_X_MY_API'] == 'foobar'\n user = { :id => 1, :name => \"some user\" }\n # warden doesn't care what the user is, so long as it's not nil.\n success! user, \"success\"\n end\n end", "def authorize\n if @api_user\n authorize_user\n else\n authorize_unauthenticated_user\n end\n end", "def autenticate_user\n auth_token = request.headers[:HTTP_AUTH_TOKEN] #auth_token in header\n return render_message ({status:ERR_STATUS, responseMessage: \"Sorry! You are not an authenticated user.\",responseCode: ERROR}) unless auth_token\n @user = User.find_by(auth_token: auth_token)\n unless @user\n return render_message({status:ERR_STATUS,responseMessage: UNAUTHORIZED_MESSAGE,responseCode: UNAUTHORIZED})\n end\n end", "def api_auth\n api_response(403, \"Invalid Authorization header\") unless api_user\n end", "def authenticate!\n client_id = params[:client_id] || params[:query][:client_id] rescue nil\n token = params[:token] || params[:query][:token] rescue nil\n user = User.get_user(client_id, token)\n unless user\n render json: { 'errors' => ['Authorized users only.'] }, status: 401\n end\n user\n end", "def call\n ap \"Llamando a Authentica User\"\n JsonWebToken.encode(usuario_id: usuario.id) if usuario\n end", "def authenticate_user_from_token!\n\t\t@api_token = ApiToken.find_by_token(params[:token])\n @user = @api_token.try(:user)\n if @user.nil?\n render json: { error: 'Not authorized' }, status: 401\n end\n end", "def authenticate\n auth_token =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n json_response(auth_token: auth_token, config: get_current_configuration, provider: 'email')\n end", "def authorize_request\n authenticate_with_http_token do |token, option|\n User.find_by(token: token)\n end\n end", "def authenticate\n RestClient.post @apiurl + \"authenticate\", \n :username => @username, \n :password => @password\n rescue RestClient::RequestFailed\n handle_error($!)\n return false\n end", "def authenticate(user)\n self.class.get(\"/v2/auth\", :query => generate_query(user))\n end", "def authenticate_with_api_key\n if @current_user.nil? && request.headers['Authorization'].nil?\n @current_user = authenticate_with_http_token(&method(:authenticator))\n end\n end", "def authenticate_user\n authenticate_or_request_with_http_token do |token, options|\n @user = User.find_by_auth_key(token)\n head :unauthorized unless @user\n return\n end\n end", "def create\n user = User.new(user_params)\n if user.save\n logger.info \"User Created....\"\n puts user.id\n user_id = user.id\n auth_token = AuthenticateUser.new(user.email, user.password).call()\n render json: { auth_token: auth_token.result, user_id: user.id.to_s }\n else\n render json: { error: user.errors.full_messages }, status: :not_acceptable\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 auth\n {:basic_auth => {:username => id, :password => password}}\n end", "def authenticate\n command = AuthenticateUser.call(params[:username], params[:password])\n\n if command.success?\n render json: { auth_token: command.result }\n else\n render json: { error: command.errors }, status: :unauthorized\n end\n end", "def authenticate\r\n if User.exists?(email: auth_params[:email])\r\n auth_token = AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\r\n render json: {\r\n code: 200,\r\n success: true,\r\n message: \"Logged in Successfully\",\r\n auth_token: auth_token\r\n }\r\n else\r\n render json: {\r\n code: 400,\r\n success: false,\r\n message: \"Invalid credentials\"\r\n }\r\n end\r\n end", "def authenticate\n \t# get token from header\n \tauthentication_token = request.headers['token']\n \t@user = User.find_by_authentication_token authentication_token if authentication_token\n \t\n \tunless @user\n \t\trender json: {success: false, message: I18n.t('unauthorized'), data: {}}, status: :unauthorized\n \t\treturn false\n \tend\n end", "def create\n if SessionService.authenticate(@user, params[:password])\n # TODO Add successful log in message\n logger.debug \"#{@user.email} is trying to create a API session\"\n root_path\n else\n logger.error \"** Failure** Attempt to login as #{params[:user_name]} - rejected\"\n render text: 'Login failed', status: :unauthorized\n end\n end", "def authorize(user,pass)\n @uri.path += 'auth'\n @uri.query = \"user=\" + user + \"&pass=\" + pass\n response = @caller.request_get(@uri)\n raise RestApiCallerError::AuthorizationError unless response.code == '200'\n @token = JSON.parse(response.body)[\"token\"]\n raise RestApiCallerError::AuthorizationError unless @token\n end", "def authorize_user\n puts \"AUTHORIZE USER\"\n puts \"params[:id] \" + params[:id].to_s\n # render json: { status: 401, message: 'Unauthorized' } unless get_current_user.id == params[:id].to_i\n render json: { status: 401, message: 'Unauthorized' } unless get_current_user\n end", "def authorize_request\n\t\tauthenticate_with_http_token do |token, options|\n\t\t\tUser.find_by(token: token)\n\t\tend\n\tend", "def oauth_authentication; end", "def auth_param; end", "def authenticate\n command = AuthenticateUser.call(params[:email].to_s.strip.downcase, params[:password])\n if command.success?\n @auth_token = command.result\n else\n render json: { error: command.errors }, status: :unauthorized\n end\n end", "def authenticate_request\n @current_user = AuthorizeApiRequest.call(request.headers).result\n render json: { error: 'Not Authorized' }, status: 401 unless @current_user\n end", "def create_with_api\n @user = User.find_or_create_from_auth_hash(request.env[\"omniauth.auth\"])\n if @user\n session[:user_id] = @user.id\n redirect_to @user\n else \n flash.now[:danger] = \"Whoops, something went wrong!\"\n render 'new'\n end\n end", "def api_authentication_required\n unauthorized unless current_user?\n end", "def auth(key)\n\t\t#TODO\n\t\t#return response\n\t\tstatus 201\n\tend", "def authenticate_request\n begin\n uid = JWT.decode(request.headers['Authorization'], Rails.application.secrets.secret_key_base)[0]['uid']\n @current_user = User.find_by(uid: uid)\n rescue JWT::DecodeError\n render json: 'authentication failed', status: 401\n end\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 authorize_request\n authenticate_with_http_token do |token, options|\n User.find_by(token: token)\n end\n end", "def authenticate\n # return if unauthorized?\n\n # render json: {\n # message: I18n.t('api.v1.error_messages.unauthorized')\n # }, status: :unauthorized\n end", "def auth()\n if(!authenticateAdmin(params[:admin_id], params[:admin_auth_key]))\n render json: {status: false, reason: \"Authentication Failed\", data: \"\"}\n return\n end\n render json: {status: true, reason: \"\", data: \"\"}\n end", "def create\n user = User.find_by email: params[:email]\n if user && user.authenticate(params[:password])\n reactivate(user)\n render json: user.session_api_key, status: 201\n else\n render json: {\n \"error\" => \"Unauthorized\"\n }, status: 401\n end\n end", "def create\n #create local variables which store the user_email and user_password entered as in the parameters for the /login API call\n user_email = params[:user_email]\n user_password = params[:password]\n\n #check to see if the user is authenticated via their entered email and password\n is_user_authenticated = User.authenticate(user_email, user_password)\n #if the user is authenticated, then return the token. The merchant will need this token as a parameter to view his/her campaigns\n if(is_user_authenticated)\n user = User.find_by_email(user_email)\n user_id = user.id\n user_hash = user.hash\n token = Digest::SHA2.hexdigest(user.hash)\n retIDandToken = {\"user_id\"=> user_id ,\"token\" => token}\n render json: retIDandToken\n\n else\n render json: password_auth_error, :status => 400\n end\n end", "def api_user\n user = active_user\n user.enable_api! if user.valid?\n user\n end", "def create\n if user&.valid_password?(params[:password])\n if turbo_native_app?\n sign_in_user\n render json: {location: after_sign_in_path_for(user), token: token_by_name(ApiToken::APP_NAME)}\n else\n render json: {token: token_by_name(ApiToken::DEFAULT_NAME)}\n end\n else\n render json: {error: error_message}, status: :unauthorized\n end\n end", "def create\n self.resource = warden.authenticate! \n render json: {success: true, user: resource}\n end", "def authenticate_api!\n Rails.logger.info(\"Enter Authenticate Api\")\n \n # just to test we are using HTTP_HOST in test mode as HTTP_ORIGIN cant be set\n Rails.env == \"test\" ? origin = request.env['HTTP_HOST'] : origin = request.env['HTTP_ORIGIN']\n\n if !params[\"token\"].blank? and origin.blank? # API Access\n\n account_id = AccountsCache.access_token(params[\"token\"])\n\n raise et(\"application.unauthorized\") if account_id.blank?\n \n # set account_id in params\n if params[:controller] == \"accounts\" and current_account\n params[:id] = current_account._id.to_s if params[:id].blank?\n else\n params[:account_id] = current_account._id.to_s if params[:account_id].blank?\n end\n\n # set the request type\n params[:request_type] = AppConstants.request_type_api\n\n # mark already authenticated\n set_authenticated\n\n # make api request synchronous as of now\n make_sync_request\n end\n rescue => e \n Rails.logger.error(\"**** ERROR **** #{er(e)}\")\n head :unauthorized\n end", "def authenticate\n auth_token = AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n user = User.find_by(email: auth_params[:email])\n # HTTP-only cookie stored with refresh_token\n # Note - May be needed before launching production: SameSite: \"Strict\"\n # cookies.signed[:jwt] = {value: auth_token, httponly: true, same_site: :none, expires: 2.hours.from_now}\n response.set_header('Authorization', auth_token)\n json_response(user, :ok, user_options)\n # render json: user, include: user_options\n # json_response(message: \"Successfully authenticated.\" , user_role: user.role,user_id: user.id)\n end", "def authenticate\n user = User.find_by(email: params[:email].to_s.downcase)\n\n if user && user.authenticate(params[:password])\n auth_token = JsonWebToken.encode({user_id: user.id})\n render json: {auth_token: auth_token, user: user}, status: :ok\n else\n render json: {error: 'Invalid username / password'}, status: :unauthorized\n end\n end", "def authenticate username, api_key, account: Conjur.configuration.account\n account ||= Conjur.configuration.account\n if Conjur.log\n Conjur.log << \"Authenticating #{username} to account #{account}\\n\"\n end\n JSON.parse url_for(:authn_authenticate, account, username).post(api_key, content_type: 'text/plain')\n end", "def authenticate\n user = User.find_by_email(auth_params[:email])\n return json_response({message: 'Invalid credentials'}, :unauthorized) if !user.present?\n user.last_login = Time.now\n user.save!\n auth_token = AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n render json: { auth_token: auth_token}\n end", "def authenticate\n auth_token =\n AuthenticateUser.new(auth_params[:email], auth_params[:password]).call\n render json: { auth_token: auth_token, user: find_user }\n end", "def authenticate\n response = post('login')\n @access_token = response['access-token']\n @client_id = response['client-id']\n end", "def auth\n\t\trequest_token = OAuth::RequestToken.from_hash(oauth_consumer, \n\t\t\t:oauth_token => session[:request_token], \n\t\t\t:oauth_token_secret => session[:request_secret])\n\t\tbegin\n\t\t\t@access_token = request_token.get_access_token\n\t\t\tsession.delete(:request_token)\n\t\t\tsession.delete(:request_secret)\n\t\t\tresponse = @access_token.get('/api/auth_user')\n\t\t\tdoc = Nokogiri::XML(response.body)\n\t\t\tuser_xml = doc.at_xpath('//user')\n\t\t\tgoodreads_user_id = user_xml.attributes[\"id\"].value\n\t\t\tname_xml = doc.at_xpath('//name')\n\t\t\tgoodreads_username = name_xml.children[0].inner_text\n\t\t\t@user = User.find_by(\tgoodreads_name: goodreads_username)\n\t\t\tif @user\n\t\t\t\tsession[:user_id] = @user.id\n\t\t\t\tredirect_to :home\n\t\t\telse\n\t\t\t\t@user = User.create( goodreads_name: goodreads_username,\n\t\t\t\t\tgoodreads_user_id: goodreads_user_id, \n\t\t\t\t\tauth_token: @access_token.token, \n\t\t\t\t\tauth_secret: @access_token.secret)\n\t\t\t\tsession[:user_id] = @user.id\n\t\t\t\tredirect_to :welcome\n\t\t\tend\n\t\trescue\n\t\t\tsession.delete(:request_token)\n\t\t\tsession.delete(:request_secret)\n\t\t\t@not_authorized = true\n\t\t\tredirect_to :home\n\t\tend\t\t\n\tend", "def authenticate(username, password)\n dest = \"#{base_url}/api/v#{api_version}/users/auth_token\"\n options = {\n userpwd: username + ':' + password,\n headers: { 'Accept' => 'application/json', 'Content-Type' => 'application/json' }\n }\n response = Typhoeus.post(dest, options)\n unless response.options[:response_code] == 201\n raise AuthenticationError.new(response)\n end\n\n @auth_token = JSON.parse(response.response_body)['name']\n self\n end", "def call\n JsonWebToken.encode(user_id: api_user.id) if api_user\n end", "def create\n # Validations\n if request.format != :json\n render( status: 406, json: { success: false, message: I18n.t(\"api.errors.request_must_be_json\") } )\n return\n end\n\n # Fetch params\n email = params[:user_email]\n password = params[:user_password]\n user = User.find_for_database_authentication( email: email ) if email.presence\n\n if email.nil? or password.nil?\n render( status: 400, json: { success: false, message: I18n.t(\"api.errors.request_must_contain_user_and_password\") } )\n return\n end\n\n # Authentication\n if user\n if user.valid_password?( password )\n # FIXME was: user.reset_authentication_token!\n# user.authentication_token = nil\n# user.save!\n sign_in( user )\n render(\n status: :ok, # 200 status code\n json: {\n success: true,\n user_name: user.name,\n user_token: user.authentication_token,\n message: I18n.t(\"api.errors.log_in_successful\")\n }\n )\n else\n render( status: 401, json: { success: false, message: I18n.t(\"api.errors.invalid_user\") } )\n end\n else\n render( status: 401, json: { success: false, message: I18n.t(\"api.errors.invalid_user\") } )\n end\n end", "def api_user\n @user\n end", "def create\n user = User.find_by(email: auth_params[:email])\n if user&.valid_password?(auth_params[:password])\n @token = user.api_tokens.find_or_create_by(name: (auth_params[:name] || \"default\")) do |token|\n token.make_token.save!\n end\n render json: {\n token: @token.token\n }\n else\n head :unauthorized\n end\n end", "def create\n # deny user creation if a user is logged in\n if current_user\n render json: { errors: \"You are currently logged in.\" }, status: 401\n else\n user = User.create(user_params)\n\n if !user.new_record?\n render json: user.find_api_key(params[:scope]), status: 201\n else\n render json: { errors: user.errors.messages }, status: 422\n end\n end\n end", "def authenticate\n\t\tusername = \"akiro.nakamura@pronto-hw.com\" \n\t\tpassword = \"1234\"\n\t\t\n\t\toauth = 'http://localhost:9001/rest/oauth/token?client_id=mobile_android&client_secret=secret&grant_type=password&username=' + username + '&password=' + password\n\t\tclient = RestClient::Resource.new(oauth,:verify_ssl => OpenSSL::SSL::VERIFY_NONE)\n\t\tresponse = client.get();\n\t\t@doc = Nokogiri::XML(response)\n\t\ttoken = \"Bearer \" + @doc.at_css(\"access__token\").content\n\n\tend" ]
[ "0.8111138", "0.79972166", "0.7672294", "0.7579332", "0.7407124", "0.7370928", "0.73388743", "0.73003125", "0.73003125", "0.72622067", "0.71878606", "0.7119684", "0.71135455", "0.70811915", "0.70805335", "0.706688", "0.7066381", "0.70249623", "0.70173377", "0.70173377", "0.69988525", "0.69684595", "0.69569296", "0.69462407", "0.692352", "0.6918883", "0.6910125", "0.6892814", "0.687228", "0.6870617", "0.6852143", "0.6849506", "0.6837797", "0.6831304", "0.68203497", "0.6815303", "0.68034154", "0.6796333", "0.67866725", "0.67817634", "0.67731637", "0.6757396", "0.6755238", "0.67487645", "0.67470783", "0.6733218", "0.6723517", "0.6723211", "0.6720256", "0.67187977", "0.67150086", "0.670924", "0.6708961", "0.6682194", "0.6678291", "0.66778237", "0.6675814", "0.6668782", "0.6663325", "0.6662366", "0.6660162", "0.6650975", "0.6645999", "0.6645423", "0.66433537", "0.664314", "0.6640808", "0.663303", "0.6625951", "0.6623804", "0.662371", "0.662291", "0.66188556", "0.6606406", "0.6606124", "0.66042954", "0.6597178", "0.6596726", "0.65920013", "0.65829355", "0.65752053", "0.65731573", "0.6572581", "0.65681845", "0.65663767", "0.6565924", "0.65629125", "0.6561476", "0.65597796", "0.65595245", "0.65594804", "0.6558364", "0.65577286", "0.65567327", "0.6552691", "0.65516853", "0.6548422", "0.65472305", "0.654661", "0.65454847", "0.65447724" ]
0.0
-1
encode jwt token with some user info.
def encode(creator) #data to be saved in JSON payload = { id: creator.id, userName: creator.userName, expires: 2.hours.from_now.to_i} #very much safe JWT.encode( payload, Rails.application.secrets.secret_key_base, "HS512") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def encode_token(payload) # arg is data identifying user — e.g., DB id and username\n \n JWT.encode(payload, secret,algorithm)\n end", "def encode_token(payload) #encodes your username\n JWT.encode(payload, ENV['SECRET'])\n end", "def encode_token(payload)\n # I expect something like payload => { userid: int }\n JWT.encode(payload, Rails.application.secrets.secret_key_base)\n end", "def encode_token(payload)\n JWT.encode(payload, \"secret\")\n end", "def encode_token(payload)\n JWT.encode(payload, 'yourSecret')\n end", "def encode_token(payload)\n JWT.encode(payload, 'secret')\n end", "def encode_token(payload)\n JWT.encode(payload, 'SECRET')\n end", "def encode_token(payload) \n # this method takes in a payload (a hash of key/values you want to save in the token) and signs a token using a secret key. (in production this should an ENV variable.)\n JWT.encode(payload, 'yourSecret') \n end", "def encode_token(payload)\n JWT.encode(payload, Rails.application.secrets.secret_key_base, 'HS256')\n end", "def encode_token(payload)\n #PAYLOAD => {salad: 'tomatoes'}\n JWT.encode(payload, ENV[\"JWT_SECRET\"])\n #jwt string: 'hdjgjdkgjgjsetc...'\n end", "def encode_token(payload)\n #! Environment variables will need to be set!\n JWT.encode(payload, ENV['SECRET_KEY_BASE'])\n end", "def auth_token \n JWT.encode({id: self.id}, \"9885ea7895518eaf88c4a8a2e8f62c82\")\n end", "def encode_token(payload)\n # Secret environment variable is found in config/application.yml\n JWT.encode(payload, ENV[\"SECRET\"])\n end", "def encode(payload)\n #return token\n JWT.encode(payload, secret_key, 'HS256')\n end", "def encode(payload)\n token = JWT.encode(payload, secret_key, 'HS256')\n end", "def encode_token(payload, exp = 24.hours.from_now)\n payload[:exp] = exp.to_i\n JWT.encode(payload, SECRET_KEY) \n end", "def auth_token\n JWT.encode({ id: self.id }, '65bc368fbc69306')\n end", "def token\n HVCrypto::JWT.encode(self[:token], audience)\n end", "def dev_jwt_token\n JWT.encode(\n {user_id: id},\n Rails.application.secrets.json_web_token_key,\n 'HS256'\n )\n end", "def jwt_encode(payload)\n JWT.encode(payload, Config.jwt_encode_key, Config.jwt_algorithm)\n end", "def make_token(user_id)\n payload = { user_id: user_id }\n JWT.encode(payload, hmac_secret, 'HS256')\n end", "def encode(payload)\n payload.reverse_merge!(meta)\n JWT.encode(payload, HMAC_SECRET)\n end", "def auth_token(payload = nil)\n if payload.nil?\n payload = {data: {authenticated: true, user: current_user_data}}\n end\n\n EchoCommon::Services::Jwt.encode payload\n end", "def encode_token_coach(payload)\n JWT.encode(payload, 'time-to-lift')\n end", "def get_jwt_token\n payload = { data: {user: {id: self.id, email: self.email}} }\n payload[:exp] = (Time.now + Settings.jwt_token_expiry.days).to_i\n\n JWT.encode payload, ENV[\"HMAC_SECRET\"], 'HS256'\n end", "def encode_token(payload)\n JWT.encode(payload, \"my_s3cre3t\")\n\n end", "def call\n Utils::TokenManager.encode(user_id: user.id) if user\n end", "def jwt_encode(payload)\n JWT.encode(payload, private_key, ALGORITHM, kid: jwk_kid)\n end", "def encode_token(playload)\n JWT.encode(playload, \"Git-Pet\")\n end", "def encode(payload)\n JWT.encode(payload, secret_key, 'HS512')\n end", "def call\n JsonWebToken.encode(user_id: user.id) if user\n end", "def call\n JsonWebToken.encode(user_id: user.id) if user\n end", "def issue_token payload\n JWT.encode(payload, secret, algorithm)\n end", "def encodeJWT(creator, exp=2.hours.from_now)\n # add the expire to the payload, as an integer\n payload = { creator_id: creator.id }\n payload[:exp] = exp.to_i\n\n # Encode the payload whit the application secret, and a more advanced hash method (creates header with JWT gem)\n JWT.encode( payload, Rails.application.secrets.secret_key_base, \"HS512\")\n\n end", "def create_token(user_id)\n payload = { user_id: user_id }\n # Creates a token. Encoding something just creates a token\n JWT.encode(payload, secret, 'HS256')\n end", "def create\n @user = User.new(user_params)\n if @user.save\n @token = encode_token({user_id: @user.id})\n render json: {user: @user, token: @token}\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def call\n\t\tJsonWebToken.encode(user_id: user.id) if user\t\n\tend", "def create_token(id, username)\n JWT.encode(payload(id, username), ENV['JWT_SECRET'], 'HS256')\n end", "def create_token(id, username)\n JWT.encode(payload(id, username), ENV['JWT_SECRET'], 'HS256')\n end", "def encode(payload)\n JWT.encode(payload, secret_key, 'HS256')\n end", "def encode(payload)\n JWT.encode(payload, secret_key, 'HS256')\n end", "def generate_token(user)\n payload = {user_id: user.id}\n JWT.encode(payload, ENV[\"SEC_KEY\"] , 'HS256')\n end", "def make_jwt\n token_payload = {\n 'tmcusr' => @username,\n 'tmctok' => @tmc_token,\n 'tmcuid' => @tmc_user_id,\n 'tmcadm' => @is_tmc_admin,\n 'exp' => @expires.to_i\n }\n jwt_string = JWT.encode(token_payload, @@jwt_secret, JWT_HASH_ALGO)\n jwt_string\n end", "def create\n user = User.create(user_params)\n wristband = encode_token({user_id: user.id})\n if user.valid?\n render json: {user: UserSerializer.new(user), token: wristband}\n else \n render json: {errors: user.errors.full_messages}\n end\n end", "def token\n JWT.encode(claims, rsa_key, 'RS512')\n end", "def jwt_payload\n super.merge('user' => { name: name, email: email })\n end", "def to_token_payload\n payload = {}\n # std jwt claims\n payload['sub'] = id.to_s\n payload['iat'] = Time.now.utc.to_i\n payload['iss'] = Rails.application.secrets.jwt_issuer\n # sombra claims\n payload['role'] = role\n payload['name'] = name\n payload\n end", "def jwt_encode(payload, headers = {})\n # Add security claims to payload\n payload.reverse_merge!(\n # Time at which the Issuer generated the JWT (epoch).\n iat: Time.now.to_i,\n\n # Expiration time on or after which the tool MUST NOT accept the ID Token for\n # processing (epoch). This is mostly used to allow some clock skew.\n exp: Time.now.to_i + 5.minutes.to_i,\n\n # String value used to associate a tool session with an ID Token, and to mitigate replay\n # attacks. The nonce value is a case-sensitive string.\n nonce: SecureRandom.uuid\n )\n\n # Add additional info into the headers\n headers.reverse_merge!(\n # Set the id of they key\n kid: jwk_kid\n )\n\n JWT.encode(payload, private_key, ALGORITHM, headers)\n end", "def token_generator(params)\n Auth::JsonWebToken.encode(params)\n end", "def generate_jwt(user)\n now = Time.current.to_i\n\n payload = { sub: user.id,\n iat: now,\n exp: now + Config.jwt_lifetime }\n\n payload.merge!(user.public_send(Config.jwt_additional_user_payload_action)) if Config.jwt_additional_user_payload_action\n\n { token: jwt_encode(payload),\n payload: payload }\n end", "def verification_token\n JWT.encode({ iat: Time.now.to_i }, config.secret, JWT_ALG)\n end", "def create\n user = User.new(user_params)\n if user.save\n payload = { user_id: user.id }\n\n hmac_secret = 'my$ecretK3ys'\n\n auth_token = JWT.encode(payload, hmac_secret)\n\n render json: { message: 'Account created successfully', auth_token: auth_token }\n else\n render json: { message: 'Something went wrong', errors: user.errors }, status: :unprocessable_entity\n end\n end", "def to_token_payload\n {\n sub: id,\n email: email,\n user_name: user_name\n }\n end", "def encode\n raise RuntimeError, 'secret key is not set' unless @secret\n\n payload = @claims.merge({\n iss: issuer,\n aud: audience,\n sub: user_uid,\n perms: permissions.map do |perm|\n # encode each set of permission into an array\n # first element - resource\n # remaining elements - actions granted\n [perm[:resource]].push(*perm[:actions])\n end\n })\n\n payload[:exp] = expiration.to_i if expiration\n\n JWT.encode payload, @secret, ALGORITHM\n end", "def encode_credentials(token, options = T.unsafe(nil)); end", "def token(secret, claims={})\n payload = {}\n payload.merge!(claims)\n puts secret\n JWT.encode payload, [secret].pack('H*').bytes.to_a.pack('c*'), 'HS256'\nend", "def issue_token(payload)\n JWT.encode(payload, Rails.application.credentials.secret_key_base)\n # JWT.encode(payload, ENV[\"SOME_SECRET\"], ENV[\"SOME_SUPER_SECRET\"])\nend", "def new_jwt\n Knock::AuthToken.new(payload: { sub: current_user.id }).token\n end", "def generate_token(_user)\n JsonWebToken.encode(login_payload, 3.days.from_now)\n end", "def jwt_auth_token( secret )\n\n # expire in 5 minutes\n exp = Time.now.to_i + 5 * 60\n\n # just a standard claim\n exp_payload = { exp: exp }\n\n return JWT.encode exp_payload, secret, 'HS256'\n\n end", "def generate_and_set_token(user=nil)\n user ||= create(:user_with_token)\n current_time = Time.now\n jwt_config = Rails.application.secrets.jwt\n token = JWT.encode({\"iat\" => current_time.to_i,\n \"iss\" => jwt_config['issuer'],\n \"exp\" => (current_time + 14.days).to_i,\n \"user_id\" => user.id},\n jwt_config['secret_key'],\n jwt_config['hmac_sha_algo'])\n request.headers['Authorization'] = \"Bearer #{token}\"\n end", "def encrypt_sso_token_for_user(user)\n sso_token = Encryptor.encrypt(user.id.to_s, key: token)\n Base64.urlsafe_encode64(sso_token)\n end", "def create\n user = User.new(username: params[:username])\n if user.save\n payload = {'user_id': user.id}\n token = JWT.encode(payload, 'chatapp')\n render json: {\n user: user,\n token: token\n }\n else \n render json: { message: 'There was an error creating your account' }\n end\n end", "def call\n JsonWebToken.encode(user_id: api_user.id) if api_user\n end", "def auth_bypass_token\n JWT.encode(\n {\n \"sub\" => auth_bypass_id,\n \"content_id\" => content_id,\n \"iat\" => Time.zone.now.to_i,\n \"exp\" => 1.month.from_now.to_i,\n },\n Rails.application.secrets.jwt_auth_secret,\n \"HS256\",\n )\n end", "def auth_bypass_token\n JWT.encode(\n {\n \"sub\" => auth_bypass_id,\n \"content_id\" => content_id,\n \"iat\" => Time.zone.now.to_i,\n \"exp\" => 1.month.from_now.to_i,\n },\n Rails.application.secrets.jwt_auth_secret,\n \"HS256\",\n )\n end", "def jwt_auth_header\n { Authorization: \"Bearer #{Quovo::Token.get}\" }\n end", "def create\n @user=User.new(name: user_params[:name], email: user_params[:email], type: user_params[:type], age: user_params[:age], password: user_params[:password])\n print @user.valid?\n if @user.save\n payload={user_id: @user.id}\n token = encode_token(payload)\n render json: {user: @user, jwt: token}\n else\n render json: User.all\n end\n end", "def token(expiration=nil)\n expiration ||= 1\n payload = {\n data: {\n id: id,\n discriminator: password_digest\n # discriminator used to detect password changes after token generation\n },\n exp: Time.now.to_i + expiration * 60 * 60\n }\n # HMAC using SHA-512 algorithm\n JWT.encode payload, User.hmac_key, 'HS512'\n end", "def generate_jwt\n JWT.encode({\n id: id, \n exp: 60.days.from_now.to_i\n }, \n Rails.application.secrets.secret_key_base\n )\n end", "def create\n @user = User.create(user_params)\n if @user.valid?\n payload = { id: @user.id}\n token = JWT.encode(payload, 'my$ecretK3y', 'HS256')\n render json: { id: @user.id, username: @user.username, token: token }\n else\n render json: { error: 'failed to create user' }, status: :not_acceptable\n end\n end", "def create\n @user = User.create(user_params)\n if @user.valid?\n token = encode_token({user_id: @user.id})\n render json: {user: @user, token: token}\n else\n render json: {error: \"Invalid username or password\"}\n end\n end", "def create\n @user = User.create(user_params)\n if @user.valid?\n token = encode_token({user_id: @user.id})\n render json: {user: @user, token: token}\n else\n render json: {error: \"Invalid username or password\"}\n end\n end", "def encode(payload, exp = 24.hours.from_now)\n payload[:exp] = exp.to_i\n JWT.encode(payload, private_key, ALGORITHM)\n end", "def create\n @user = User.create_or_find_by(user_params)\n my_token = issue_token(@user)\n\n render json: {user: @user, token: my_token}\n # render json: @user\n \n end", "def get_token\n # Get the user by email\n user = User.find_by_email(params[:email])\n \n # return unauthorized if the user was not found\n if !user \n render json: { error: 'unauthorized' }, status: :unauthorized\n return\n end\n \n # if the user is not authenticated via the authenticate method\n # then return unauthorized\n if !user.authenticate( params[:password] )\n render json: { error: 'unauthorized' }, status: :unauthorized\n return\n end\n \n # if our code gets here, we can generate a token and response.\n # JWT's include an expiry, we will expire the token in 24 hours\n token = jwt_encode({user_id: user.id}, 24.hours.from_now)\n render json: {token: token, exp: 24, username: user.email, userId: user.id},\n status: :ok\n \n end", "def create\n @user = User.new(user_params)\n if @user.save\n auth_token = Knock::AuthToken.new payload: { sub: @user.id }\n render json: { username: @user.username, jwt: auth_token.token }, status: :created\n else\n render json: @user.errors, status: :unprocessable_entity\n end\n end", "def authentication_token\n @authentication_token ||= JWT.encode(payload, secret, algorithm)\n end", "def generate_jwt\n JWT.encode({ id: id,\n exp: 60.days.from_now.to_i },\n Rails.application.secrets.secret_key_base)\n end", "def to_s\n JWT.encode(to_h, ENV['JWT_KEY'])\n end", "def generate_token (id, number_of_days)\n JWT.encode({ :user_id => id, :expires => expires_in(number_of_days) }, 'somesecrethere')\n end", "def generate_json_web_token(time)\n JWT.encode(\n {\n sub: key_info['oxtrust_client_id'],\n iss: key_info['oxtrust_client_id'],\n exp: time.to_i + 86_400,\n iat: time.to_i,\n jti: SecureRandom.hex(10),\n aud: 'https://localhost/oxauth/restv1/token'\n },\n load_auth_key,\n 'RS256',\n jwt_headers,\n )\n end", "def create\n @user = User.create(user_params)\n if @user.save\n token = JWT.encode({user_id: @user.id}, 'SECRET')\n response = { message: 'User has been successfully created' }\n render json: {user_id: @user.id, username: @user.username, type: @user.type, name: @user.name, jwt: token}\n else\n render json: {error: \"does not work\"}, status: 422\n end\n end", "def jwt\n return nil if params.format_version.zero?\n SimpleJWT.new(jwt_data, :mac => mac, :key => key, :key_id => key_id)\n end", "def to_token_payload\n payload = Hash.new\n\n payload[:sub] = self.email\n payload[:firstName] = self.first_name\n payload[:id] = self.id\n payload[:lastName] = self.last_name\n\n payload\n end", "def create\n @user = User.create(user_params)\n if @user.valid?\n @token = encode_token(user_id: @user.id)\n render json: { user: @user, jwt: @token}, status: :created\n # render json: { user: UserSerializer.new(@user), jwt: @token}, status: :created\n else \n render json: { error: 'That username already exists. Try again.' }, status: :not_acceptable\n end\n end", "def call(payload)\n payload_to_encode = merge_with_default_claims(payload)\n JWT.encode(payload_to_encode, secret, algorithm)\n end", "def access_token(user_id, exp = 5.minutes, type = \"access\")\n\t\tJWT.encode payload(user_id, exp, type), ENV['JWT_SECRET'], 'HS256'\n\tend", "def create_user_token(params)\n key = Time.now.strftime(\"%Y-%m-%d %H:%M:%S:\") + '%012d' % rand(10_000_000_000)\n { :user_token => { :username => params[:username],\n :key => key,\n :hash => Digest::SHA1.hexdigest(params[:password] + key) } }\n end", "def to_token_payload\n {\n user_id: id,\n sub: id,\n authorization: %w[admin user],\n type: 'account',\n exp: Knock.token_lifetime.from_now.to_i\n }\n end", "def call\n ap \"Llamando a Authentica User\"\n JsonWebToken.encode(usuario_id: usuario.id) if usuario\n end", "def get_jwt_token(data)\n payload = {data: data}\n secret_key = GlobalConstant::ExplorerApi.secret_key\n\n JWT.encode(payload, secret_key, 'HS256')\n end", "def jwt_subject\n auth0_id_string\n end", "def call\n # after user login, will pass the user-id to the JWT to create token\n return nil unless user\n\n return JsonWebToken.create_token(user_id: user.id), user\n end", "def new_jwt_token\n payload = {\n iat: Time.now.to_i, # Issued at time.\n exp: (10 * 60) + Time.now.to_i, # JWT expiration time.\n iss: APP_ID # Integration's GitHub identifier.\n }\n JWT.encode(payload, PRIVATE_KEY, 'RS256')\n end", "def auth_token\n AuthToken.new payload: { sub: user.id }\n end", "def create\n payload = {\n user: {\n name: Faker::Name.name,\n email: Faker::Internet.email\n }\n }\n\n jwt = Auth.issue(payload)\n\n render json: { jwt: jwt }\n end", "def generate_jwt(expires_in: nil)\n SolidusJwt.encode(payload: as_jwt_payload, expires_in: expires_in)\n end", "def signed_token(**payload)\n payload = {\n iss: 'The Identity Provider',\n iat: Time.now.to_i,\n exp: 1.hour.from_now.to_i,\n aud: ['example-api', 'user-api', 'calendar-api']\n }.merge(payload)\n private_key = OpenSSL::PKey::RSA.new(file_fixture('rsa1').read)\n JWT.encode(payload.to_h, private_key, 'RS256')\nend", "def token\n return nil if !id\n encode(id)\n end" ]
[ "0.84249854", "0.81916314", "0.81704336", "0.80670553", "0.80382407", "0.80230844", "0.78954375", "0.7851505", "0.7799227", "0.7790294", "0.76953954", "0.76314104", "0.7589528", "0.75711215", "0.7547424", "0.7483958", "0.7466236", "0.7420829", "0.74078274", "0.73513883", "0.73270744", "0.7298342", "0.7297195", "0.7210581", "0.72034985", "0.7199948", "0.7197413", "0.71955544", "0.7152986", "0.7140652", "0.7122636", "0.7122636", "0.7094846", "0.7087748", "0.7085794", "0.706024", "0.7045325", "0.70312834", "0.70312834", "0.7025071", "0.7025071", "0.7022973", "0.6983883", "0.6976329", "0.69696504", "0.69624245", "0.69529223", "0.69347924", "0.69285583", "0.6917736", "0.68774605", "0.68600506", "0.68528414", "0.6849692", "0.68446594", "0.6840996", "0.68116266", "0.6808869", "0.67801034", "0.67590755", "0.6746971", "0.67021453", "0.6695357", "0.6673616", "0.6666587", "0.6666587", "0.6653049", "0.6636292", "0.660948", "0.6564685", "0.6534915", "0.6530599", "0.6530599", "0.65287286", "0.65256643", "0.65190166", "0.6514267", "0.64880097", "0.64754057", "0.6466554", "0.6457767", "0.64510214", "0.64453954", "0.6437869", "0.64362264", "0.64303786", "0.6429339", "0.64287424", "0.6399564", "0.6395143", "0.6381051", "0.63773346", "0.6373406", "0.63693625", "0.6369192", "0.63668793", "0.63575345", "0.6350506", "0.6341812", "0.6316094" ]
0.7560801
14
check so jwt token looks ok
def decode(token) payload = JWT.decode(token, Rails.application.secrets.secret_key_base, "HS512") #check expiration time and return if still fresh if payload[0]["expires"] >= Time.now.to_i payload[0] #old token else false end #couldn't decode token rescue false end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def validate\n token = jwt\n return unless token\n token.validate\n end", "def verify_jwt_token\n head :unauthorized if request.headers['Authorization'].nil? ||\n !AuthToken.valid?(request.headers['Authorization'].split(' ').last)\n end", "def verify_jwt_token\n begin\n if request.format.json?\n token = request.headers['Authorization'].split(' ').last\n decoded_token = JWT.decode token, nil, false\n @current_user = User.find(decoded_token[0][\"user_id\"])\n head :unauthorized if request.headers['Authorization'].nil? || !AuthToken.valid?(token)\n else\n authenticate_user!\n end\n rescue => exception\n head :unauthorized \n end\n end", "def verify(bearer_token)\n JWT.decode(bearer_token, config.secret)\n rescue JWT::VerificationError, JWT::DecodeError\n false\n end", "def token_validation\n return errors.add(:base, I18n.t('token.invalid')) if jwt_string.blank? || token.all?(&:blank?)\n\n current_time = Time.current\n iat_time = Time.at(read('iat'))\n exp_time = Time.at(read('exp'))\n if exp_time < current_time\n errors.add(:base, I18n.t('token.expired'))\n elsif iat_time >= current_time && iat_time > exp_time\n errors.add(:base, I18n.t('token.invalid'))\n end\n rescue JWT::DecodeError\n errors.add(:base, I18n.t('token.invalid'))\n end", "def valid?\n JWT.decode(token, verification_key, true, jwt_options) && true\n rescue *RESCUE_JWT_EXCEPTIONS\n false\n end", "def token_validation\n if (!jwt_string.blank? && !(token.all? &:blank?))\n cur_time = Time.now\n iat_time = Time.at(token[0][\"iat\"])\n exp_time = Time.at(token[0][\"exp\"])\n if exp_time < cur_time\n errors.add(:base, I18n.t('token.expired'))\n elsif !(iat_time < cur_time && iat_time < exp_time)\n errors.add(:base, I18n.t('token.invalid'))\n end\n else\n errors.add(:base, I18n.t('token.invalid'))\n end\n rescue JWT::DecodeError\n errors.add(:base, I18n.t('token.invalid'))\n end", "def decodeJWT(token)\n# puts token\n payload = JWT.decode(token, Rails.application.secrets.secret_key_base, \"HS512\")\n# puts payload\n if payload[0]['exp'] >= Time.now.to_i\n payload\n else\n puts 'time expired on login'\n false\n end\n# catch the error if token is wrong\n rescue => error\n puts error\n nil\n end", "def check_auth_token\n token = decoded_auth_token\n render json: { error: 'Not Authorized' }, status: :unauthorized unless token\n end", "def verify_token\n token ||= request.env['HTTP_AUTHORIZATION']\n if token.nil?\n error 401, { :error => 'Unauthorized.' }.to_json\n else\n token = token.split(' ').last unless token.nil?\n begin\n @user = verify(token)\n rescue JWT::ExpiredSignature\n error 401, { :error => 'Expired token.' }.to_json\n end\n end\n end", "def jwt_token_authen!\n data = jwt_verify(headers[\"Token\"])\n return error!('401 Unauthorized', 401) if data.nil?\n end", "def validate_bearer_token(bearer_token)\n end", "def validate_token_hash\n if @token_request_at and\n @token_hash and @token_hash['expires_in'] and\n (Time.now - @token_request_at) > @token_hash['expires_in'].to_i\n @token_hash = nil\n elsif @token_request_at and\n @token_hash and @token_hash['expires_in']\n @token_hash['access_token']\n else\n puts \"start get token ...\"\n end\n end", "def http_get_token\n #verifico che stia arrivando un jwt con formato valido,altrimenti ritorno false\n if params['jwt'].present? && !(params['jwt'] =~ /^[A-Za-z0-9\\-_=]+\\.[A-Za-z0-9\\-_=]+\\.?[A-Za-z0-9\\-_.+=]*$/).nil?\n @http_get_token ||= params['jwt']\n else\n false\n end\n \n end", "def decodeJWT(token)\n payload = JWT.decode(token, Rails.application.secrets.secret_key_base, \"HS512\")\n #Kontrollerar tiden på token\n if payload[0][\"exp\"] >= Time.now.to_i\n payload\n else\n puts \"The token has expired, please log in again to get a new one\"\n false\n end\n #Fångar felet om token var fel\n rescue => error\n puts error\n nil\n end", "def valid_token?\r\n token = ::AuthToken.where(user_id: decoded_auth_token[:user_id]).newer.first\r\n token&.token == auth_token && token.expire_at >= Time.now if token.present?\r\n end", "def verify_auth_token\n halt 401 unless valid_user?(extracted_token)\n end", "def validate_token\n token = params[:token]\n return false if token.nil?\n \n user = User.validate_token(token)\n return false if user.nil?\n \n login_user(user)\n return true\n end", "def verify_jwt_token\n # token = request.headers['HB-UserToken']\n # if not token\n # render :status => 401, :json => {:message => \"User token required\"}\n # return\n # end\n \n #begin\n # jwt = JWT.decode(token, JWT_SECRET)\n #rescue JWT::DecodeError\n # render :status => :unauthorized, :json => {:message => \"Invalid token\"}\n # return\n #end\n \n #@current_user = User.find_by_authentication_token(jwt[0][\"user_token\"])\n @current_user = User.find_by_email('mercury.solar02@gmail.com')\n #if not @current_user\n # render :status => 401, :json => {:message => \"Invalid user token\"}\n # return\n #end\n \n @ability = Ability.new(@current_user)\n \n end", "def decodeJWT(token)\n # puts token\n payload = JWT.decode(token, Rails.application.secrets.secret_key_base, \"HS512\")\n # puts payload\n if payload[0][\"exp\"] >= Time.now.to_i\n payload\n else\n puts \"Timeout\"\n false\n end\n # catch the error if token is wrong\n rescue => error\n puts error\n nil\n end", "def verify_token\n associate = Associate.where(id: params[:associate_id])[0] if params[:associate_id]\n #checking signed_in user\n if user_signed_in?\n #checking token is nil or not.\n if params[:token].nil?\n #response in json format\n render :json=> { success: false, message: \"Token is required to proceed further.\" },:status=> 203\n return\n elsif associate && associate.associate_user == true\n return true\n #checking token with the current_user\n elsif current_user.authentication_token != params[:token]\n render :json=> { success: false, message: \"Problem with the authentication token.please check token.\" },:status=> 203\n return\n else\n end\n end\n end", "def check_token\n @usuario = Credentials.check_token(authorization: request.headers[\"Authorization\"])\n end", "def valid_token?\n five_minutes_ago = DateTime.now - 5.minutes\n params[:timestamp].to_i > five_minutes_ago.to_i &&\n params[:token] == Scalingo::SsoController.generate_authentication_token(params[:id], params[:timestamp])\n end", "def validate_token(token)\n object_from_response(Code42::TokenValidation, :get, \"authToken/#{token.to_s}\")\n end", "def validate_token_hash; end", "def valid_token?\n env['HTTP_TOKEN']\n end", "def check_weixin_token_valid?\n if token_string.blank?\n if token_model_instance.blank?\n render text: \"Forbidden\", status: 403\n return false\n end\n else\n if current_weixin_token != token_string\n render text: \"Forbidden\", status: 403\n return false\n end\n end\n true\n end", "def check_token\n end", "def validate_token\n if reg_params[:reg_token].blank?\n flash[:alert] = MESSAGES[:blank_token]\n redirect_to info_path\n return\n end\n\n begin\n @decoded_token = TokenService.decode reg_params[:reg_token]\n rescue JWT::DecodeError\n flash[:alert] = MESSAGES[:bad_token]\n redirect_to info_path\n return\n end\n\n if @decoded_token[:course_id].blank? or @decoded_token[:user_id].blank?\n flash[:alert] = MESSAGES[:bad_token]\n redirect_to info_path\n return\n end\n\n if reg_params[:course_id].to_i != @decoded_token[:course_id]\n flash[:alert] = MESSAGES[:bad_token]\n redirect_to info_path\n return\n end\n\n reg_count =\n Registration.\n where(course_id: @decoded_token[:course_id],\n user_id: @decoded_token[:user_id]).\n count\n\n if reg_count > 0\n flash[:alert] = MESSAGES[:already_registered]\n redirect_to info_path\n return\n end\n end", "def auth_token\n return token if token.present?\n\n false\n # raise(CustomException::MissingToken, 'token is missing')\n end", "def verify_token\n check_auth_token(request.headers['authtoken'],params[:profile_id])\n end", "def any_authenticity_token_valid?; end", "def decode_token(token, pub_key)\n begin\n decoded_payload, decoded_header = JWT.decode token, pub_key, true, { :algorithm => 'RS256' }\n return true\n rescue JWT::DecodeError\n puts 'Decode token: DecodeError'\n return false\n rescue JWT::ExpiredSignature\n puts 'Decode token: ExpiredSignature'\n return false\n rescue JWT::InvalidIssuerError\n puts 'Decode token: InvalidIssuerError'\n return false\n rescue JWT::InvalidIatError\n puts 'Decode token: InvalidIatError'\n return false\n end\nend", "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 validate_token\n token = params[:token]\n return false if token.nil?\n \n user = User.validate_token(token)\n return false if user.nil?\n \n login_user(user)\n return true\n end", "def valid_access_token?\n token_file = '/opt/gluu-server/etc/certs/api_token.json'\n return false unless File.exist? token_file\n\n token_config = JSON.parse(File.read(token_file))\n expired = token_config['exp'] < Time.now.to_i\n return false if expired\n\n return false unless token_config['token']\n\n true\n end", "def correct_login_token?(given_token)\n false\n end", "def invalid_token?\n @code == 401\n end", "def valid_authenticity_token?(session, encoded_masked_token); end", "def valid_to_proceed?\r\n decoded_auth_token.present? && decoded_auth_token[:user_id].present? && valid_token?\r\n end", "def validateToken(token)\n if (token.nil? or token.empty?)\n debug(\"Error: validateToken: nil/empty token.\")\n return\n end\n body, sig = token.split(\"&sig=\")\n if (body.nil? or sig.nil?)\n debug(\"Error: validateToken: Invalid token: #{token}\")\n return\n end\n sig = u64(sig)\n return token if (sig == signToken(body))\n debug(\"Error: validateToken: Signature did not match.\")\n return\n end", "def token_verify\r\n\r\n #render json: {id: params[\"user\"][\"id\"], params: params}\r\n \r\n user_tmp = User.find(params[:id])\r\n if user_tmp.authentication_token == params[:authentication_token]\r\n $granted = true\r\n render json: false\r\n else\r\n \r\n render json: false\r\n end\r\n end", "def api_authenticate\n if request.headers[\"Authorization\"].present?\n auth_header = request.headers['Authorization'].split(' ').last\n @token_payload = decodeJWT auth_header.strip\n if !@token_payload\n render json: { error: 'The provided token wasn´t correct' }, status: :bad_request \n end\n else\n render json: { error: 'Need to include the Authorization header' }, status: :forbidden # The header isn´t present\n end\n end", "def check_token\n input_token = request.headers['X-Auth-Token'] || params[:token]\n return unless input_token\n\n token = AuthenticationToken.find_by(token: input_token)\n return unless token\n\n # Count token usage\n token.inc(number_of_use: 1)\n # Update the updated_at because inc doesn't do it\n token.set(updated_at: Time.now.getlocal)\n\n # Sign in\n sign_in token.user\n end", "def verify(token, is_emulator: false)\n payload = decode(token, is_emulator).first\n sub = payload[\"sub\"]\n raise JWT::InvalidSubError, \"Invalid subject.\" unless sub.is_a?(String) && !sub.empty?\n payload[\"uid\"] = sub\n payload\n rescue JWT::ExpiredSignature => e\n raise expired_error, e.message\n rescue JWT::DecodeError => e\n raise invalid_error, e.message\n end", "def valid_key(token)\n @api_client && ActiveSupport::SecurityUtils.secure_compare(@api_client&.key, Digest::SHA512.hexdigest(token))\n end", "def token_valid?\n @session_token and @toodle_token_death > Time.now\n end", "def validate_token\n return true if @current_username\n token = get_token\n token.force_encoding('utf-8') if token\n token_object = AccessToken.find_by_token(token)\n if token_object && token_object.validated?\n @current_username = token_object.username\n return true\n else\n return false\n end\n end", "def client_has_valid_token?\n request.headers[\"Authorization\"] == Rails.application.credentials.guessing_access_token\n end", "def validate_token(provided_token)\n clear_expired_tokens\n token_object = access_tokens.find_by_token(provided_token)\n return false if !token_object\n token_object.update_attribute(:token_expire, Time.now + DEFAULT_TOKEN_EXPIRE)\n true\n end", "def check_token(token)\n params = \"token=#{token}&md5=#{Ivona::GetMd5.formula(token)}\"\n HTTParty.get(\"#{BASE_URL}/tokens?#{params}\")\n end", "def validate_authentication_token\n \n @user = User.find_by_services_authentification_token(params[:auth_token])\n bad_request if @user.nil?\n end", "def auth_token(client_token = '')\n\t\tif self.authen_token == client_token\n\t\t\treturn true\n\t\telse\n\n self.wrong_token_time += 1\n #debugger\n self.save\n if self.wrong_token_time >= 3\n self.generate_token\n end\n \n return false\n\t\tend\t\n\tend", "def check_magic_token\n params[:magic_token] == Rails.application.secrets.calendly_magic_token\n end", "def valid_token?\n\t\tif self.moves_token.presence\n\t\t\tresponse = HTTParty.get('https://api.moves-app.com/oauth/v1/tokeninfo?access_token='+\n\t\t\t\tself.moves_token)\n\t\t\tputs \"response.code: #{response.code}\"\n\t\t\tresponse.code == 200\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend", "def is_authorized?\n !!token && !token.expired?\n end", "def is_authorized?\n !!token && !token.expired?\n end", "def has_valid_token?\n !Slack::Config.token.nil? && Slack::Config.token == \"authorized\"\n end", "def validation_login\n validate_token User, params[:token]\n end", "def authorized?\n @user_id = nil\n @token = extract_token\n begin\n payload, header = JWT.decode(@token, settings.verify_key, true)\n\n @exp = header[\"exp\"]\n\n # check to see if the exp is set (we don't accept forever tokens)\n if @exp.nil?\n puts \"Access token doesn't have exp set\"\n return false\n end\n\n @exp = Time.at(@exp.to_i)\n\n # make sure the token hasn't expired\n if Time.now > @exp\n puts \"Access token expired\"\n return false\n end\n\n @user_id = payload[0]\n\n rescue JWT::DecodeError => e\n return false\n end\n true\n end", "def verification_token\n JWT.encode({ iat: Time.now.to_i }, config.secret, JWT_ALG)\n end", "def valid_token?\n return false unless token\n begin\n # We use rate limit as its a fast and free way to\n # test the GitHub token.\n octokit.rate_limit\n rescue Octokit::ClientError\n return false\n end\n true\n end", "def verify_authenticity_token; end", "def valid_token?(token)\n exists?(:token => token)\n end", "def is_token_valid? token\n @browser_token_db.has_token? token\n end", "def decode_jwt(jwt)\n #check the headers in post for jwt\n # byebug\n # if auth_header \n # token = cookies.signed[:jwt]\n # auth_header.split(' ')[1]\n begin\n # decode the token, return the decoded part\n JWT.decode(jwt, Rails.application.secrets.secret_key_base, true, algorithm: 'HS256')[0]\n rescue JWT::DecodeError \n # byebug \n # render json: {message: \"NOPE!!!! Really no!\"}, status: :unauthorized\n\n nil\n end\n # end\n end", "def api_authenticate\n if request.headers[\"Authorization\"].present?\n # Take the last part in The header (ignore Bearer)\n auth_header = request.headers['Authorization'].split(' ').last\n # Are we feeling alright!?\n @token_payload = decodeJWT auth_header.strip\n if !@token_payload\n render json: { error: 'The provided token wasn´t correct' }, status: :bad_request\n end\n else\n render json: { error: 'Need to include the Authorization header' }, status: :forbidden # The header isn´t present\n end\n end", "def verify\n incoming_token = ActiveSupport::JSON.decode(request.body.read)\n session = Session.where(nightcrew_token: incoming_token).first\n response = { valid: false }\n response[:valid] = true if session\n render :json => ActiveSupport::JSON.encode(response)\n end", "def is_token_valid?(token, options={})\n response = els_http_request(\"/isTokenValid\",\"tokenid=#{token}\",options)\n if response.code.eql? \"200\"\n true\n else\n false\n end\n end", "def decode_jwt_no_sig_check(token)\n JWT.decode(token, nil, false).first\n end", "def jwt_not_authenticated\n head :unauthorized\n end", "def authenticate_request!\n payload, header = JsonWebToken.verify(http_token)\n header if false # Commeent this line\n @requested_user = {\n email: payload['https://sassbox.com/email'],\n first_name: payload['https://sassbox.com/first_name'],\n last_name: payload['https://sassbox.com/last_name']\n }\n rescue JWT::VerificationError, JWT::DecodeError\n render json: { errors: ['Not Authenticated'] }, status: :unauthorized\n end", "def valid_token?(token)\n return false unless !token.nil? && token_looks_safe?(token)\n result = ApiToken.find_by(token: token)\n !result.nil? && result[:active]\n end", "def verify_access_token\n \tuser = User.find_by(auth_token: params[:session][:auth_token])\n\n \tif user\n \t\trender text: \"verified\", status: 200\n \telse\n \t\trender text: \"Invalid token\", status: 422\n \tend\n end", "def verify_access_token\n user = User.find_by(access_token: params[:session][:access_token])\n if user\n render json: user, status: :ok\n else\n render json: 'Token failed verification', status: :unprocessable_entity\n end\n end", "def valid_token?\n # we check against a copy invitation object\n match = Invitation.find_by_token(self.token)\n \n if !match\n errors.add :token, 'not found'\n return false\n elsif User.registered.find_by_invitation_id(match)\n errors.add :token, 'already used'\n return false\n end\n \n true\n end", "def authorization_token_valid?\n id = authorization_token_content.id\n\n return false if id.nil?\n\n user = User.find_by_id id\n\n !user.nil? && user.auth_token == authorization_token\n end", "def valid_token\n StatsManager::StatsD.time(Settings::StatsConstants.api['user']['valid_token']) do\n if ![\"facebook\"].include?(params[:provider]) # using include? allows us to do this for twitter/tumblr in the future\n return render_error(404, \"this route only currently supports facebook as a provider.\")\n end\n\n if auth = current_user.first_provider(params[:provider]) and auth.is_a? Authentication\n @token_valid = GT::UserFacebookManager.verify_auth(auth.oauth_token)\n @status = 200\n else\n return render_error(404, \"This user does not have a #{params[:provider]} authentication to check on\")\n end\n end\n end", "def test_authentication\n load_token\n return false if !@token || @token.empty?\n res = get '/'\n !res.key?('error')\n end", "def validate_token(token)\n request(\n __method__,\n :post,\n \"#{api_base}/auth/login\",\n {}.to_json,\n Authorization: token,\n content_type: :json\n )\n end", "def validate_token(token)\n request(\n __method__,\n :post,\n \"#{api_base}/auth/login\",\n {}.to_json,\n Authorization: token,\n content_type: :json\n )\n end", "def validate_access_token obj\n if obj[\"access_token\"] == request_details[:access_token]\n User.new(obj)\n else\n false\n end\n end", "def validate_token\n if self.transaction_token_created_at + 720.minutes > Time.now\n true\n else\n false\n end\n end", "def valid?\n @token.valid?\n end", "def check_access_token\r\n\t\t\t\ttoken = request.headers[\"X-Access-Token\"] || nil\r\n\t\t\t\t\r\n\t\t\t\tif token\r\n\t\t\t\t\tfind_token = ApiKey.find_by_access_token(token)\r\n\r\n\t\t\t\t\tif find_token.nil?\r\n\t\t\t\t\t\tinvalid_access_token\r\n\t\t\t\t\tend\r\n\t\t\t\telse\r\n\t\t\t\t\tinvalid_access_token\r\n\t\t\t\tend\r\n\t\t\tend", "def verify_header\n # normal header like sample ==> Authorization 'ddd$$%gggrghHFDSS.HHJHTTGGR'\n if headers['Authorization'].present?\n headers['Authorization'].split(' ').last\n else\n errors.add(:token, 'Missing Token')\n nil\n end\n end", "def verify_access_token\n debugger\n @user = User.find_by(access_token: params[:session][:access_token])\n if @user\n render text: \"verified\", status: 200\n else\n render text: \"Token failed verification\", status: 422\n end\n end", "def token_verification\n user = User.with_reset_password_token(params[:user][:reset_password_token])\n if user && user.email == params[:user][:email] && user.reset_password_period_valid?\n render_success_response({},\"Token is valid\")\n else\n json_response({\n success: false,\n message: \"Invalid Token\"\n }, 400)\n end\n end", "def verify_iat; end", "def verify_iat; end", "def valid_for_token_auth?\n token_authenticatable? && auth_token.present? && with_authentication_hash(:token_auth, token_auth_hash)\n end", "def test_token(token)\n Discordrb::API.validate_token(token)\n end", "def valid_auth_token?(request_auth_token)\n Devise.secure_compare(auth_token, request_auth_token) && !auth_token_expired?\n end", "def valid_token?(token)\n return token == 'TEST_ENV_VALID_TOKEN' if Rails.env.test?\n\n valid_token = config['security_token']\n raise 'Security token is not set! Please set it as soon as possible!' if valid_token.blank?\n\n token == valid_token\n end", "def authenticate_token\n render json: {message: \"Unauthorized\"}, status: 401 unless decode_token(bearer_token)\n end", "def require_token\n today = Time.now\n today_string = today.to_date.to_s\n yesterday_string = today.yesterday.to_date.to_s\n return false unless [today_string, yesterday_string].include?(params[:salt])\n params[:token] == token_with_salt(params[:salt])\n end", "def client_key_authentication\n if request.headers['JWT'].present?\n auth_header = request.headers['JWT'].split(' ').last\n @token_payload = decodeJWT auth_header.strip\n if @token_payload\n @creators_id = @token_payload[0]['creators_id']\n else\n selected_format({ error: 'The provided token wasn´t correct' },:bad_request)\n end\n else\n selected_format({ error: 'Need to include the Authorization header JWT with correct key' },:forbidden)\n end\n end", "def refresh_token_if_needed\n token_timestamp = decoded_jwt['exp']\n current_timestamp = DateTime.now.to_i\n return unless token_timestamp - current_timestamp <= 0\n\n refresh_token\n end", "def valid_new_token?(token)\n unique_token?(token) && token_looks_safe?(token)\n end", "def validate_token\n\n @manager = CacheManagement::Manager.new([@manager_id]).fetch[@manager_id]\n @manager_s = CacheManagement::ManagerSecure.new([@manager_id]).fetch[@manager_id]\n\n return unauthorized_access_response('am_vc_5') unless @manager.present? &&\n (@manager[:status] == GlobalConstant::Manager.active_status)\n\n return unauthorized_access_response('am_vc_10') if token_s.blank?\n\n @manager_device = CacheManagement::ManagerDeviceById.new([@manager_device_id]).fetch[@manager_device_id]\n\n return unauthorized_access_response('am_vc_13') if @manager_device.nil?\n\n @fingerprint = @manager_device[:fingerprint]\n\n evaluated_token = Manager.get_cookie_token(\n manager_id: @manager_id,\n current_client_id: @manager[:current_client_id],\n token_s: token_s,\n browser_user_agent: @browser_user_agent,\n manager_device_id: @manager_device_id,\n fingerprint: @fingerprint,\n last_session_updated_at: @manager_s[:last_session_updated_at],\n cookie_creation_time: @created_ts,\n auth_level: auth_level\n )\n\n return unauthorized_access_response('am_vc_6') unless (evaluated_token == @token)\n\n success\n\n end" ]
[ "0.8277854", "0.8028546", "0.7849945", "0.768868", "0.7674077", "0.7668755", "0.7651806", "0.7630365", "0.75399965", "0.74746734", "0.7453291", "0.741709", "0.73746973", "0.73735464", "0.73695624", "0.7356309", "0.7301621", "0.72854567", "0.7258933", "0.72148865", "0.7212866", "0.72081476", "0.7207129", "0.7198087", "0.7165154", "0.7139415", "0.71295303", "0.71267843", "0.70977885", "0.70976865", "0.7088584", "0.7037924", "0.70165044", "0.696941", "0.6967124", "0.69559807", "0.6945113", "0.6943712", "0.69166994", "0.6903604", "0.68980426", "0.68931556", "0.68895423", "0.68883634", "0.68756664", "0.6861949", "0.6852429", "0.68501025", "0.68499786", "0.68354535", "0.6831816", "0.68143433", "0.68120307", "0.6811932", "0.67994875", "0.678139", "0.678139", "0.6771153", "0.67663085", "0.6755073", "0.67447424", "0.6736159", "0.67269766", "0.67250717", "0.6718827", "0.6708903", "0.67063075", "0.67056847", "0.6704147", "0.67004466", "0.66958517", "0.6688038", "0.66854334", "0.66824096", "0.6681734", "0.66815126", "0.66788465", "0.6669526", "0.6667171", "0.6657529", "0.6657529", "0.6657272", "0.66379", "0.66371775", "0.6632147", "0.6625671", "0.6608557", "0.66080153", "0.66055334", "0.66055334", "0.6598881", "0.65973616", "0.6594673", "0.6577335", "0.6575969", "0.6568113", "0.6563638", "0.6547757", "0.6546372", "0.6546054" ]
0.7086127
31
converts 0terminated ASCII string to ruby string
def asciiz_to_str(asciiz) zero_byte_idx = asciiz.index("\x00") if zero_byte_idx != nil return asciiz[0, zero_byte_idx] else return asciiz end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def string(str)\n TYPE_STRING +\n word(str.length) +\n str.encode!(\"ASCII\")\n end", "def asciiz_to_str(asciiz)\n\t\t\t\t\t\t\tzero_byte_idx = asciiz.index(\"\\x00\")\n\t\t\t\t\t\t\tif zero_byte_idx != nil\n\t\t\t\t\t\t\t\treturn asciiz[0, zero_byte_idx]\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\treturn asciiz\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend", "def force_to_ascii s\n out = \"\"\n s.each_byte do |b|\n if (b & 128) != 0\n out << \"\\\\x#{b.to_s 16}\"\n else\n out << b.chr\n end\n end\n #out.force_encoding Encoding::UTF_8 if in_ruby19_hell? # not necessary?\n out\n end", "def to_ascii\n input.gsub(/[^\\x00-\\x7f]/u, &method(:decode)).strip\n end", "def weirdFixString(str)\n idx = str.index(\"\\000\\000\")\n idx.nil? ? str : str[0..idx]\n end", "def sterilize(str)\n str.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')\n str.gsub!(0x00.chr,'[NUL]')\n str.gsub!(0x01.chr,'[SOH]')\n str.gsub!(0x02.chr,'[STX]')\n str.gsub!(0x03.chr,'[ETX]')\n str.gsub!(0x04.chr,'[EOT]')\n str.gsub!(0x05.chr,'[ENQ]')\n str.gsub!(0x06.chr,'[ACK]')\n str.gsub!(0x07.chr,'[BEL]')\n # 0x08 is backspace\n # 0x09 is TAB\n # 0x10 is line feed\n str.gsub!(0x0B.chr,'[VT]')\n # 0x0c is form feed\n # 0x0d is carriage return\n str.gsub!(0x0E.chr,'[SO]')\n str.gsub!(0x0F.chr,'[SI]')\n str.gsub!(0x10.chr,'[DLE]')\n str.gsub!(0x11.chr,'[DC1]')\n str.gsub!(0x12.chr,'[DC2]')\n str.gsub!(0x13.chr,'[DC3]')\n str.gsub!(0x14.chr,'[DC4]')\n str.gsub!(0x15.chr,'[NAK]')\n str.gsub!(0x16.chr,'[SYN]')\n str.gsub!(0x17.chr,'[ETB]')\n str.gsub!(0x18.chr,'[CAN]')\n str.gsub!(0x19.chr,'[EM]')\n str.gsub!(0x1a.chr,'[SUB]')\n str.gsub!(0x1C.chr,'[FS]')\n str.gsub!(0x1D.chr,'[GS]')\n str.gsub!(0x1E.chr,'[RS]')\n str.gsub!(0x1F.chr,'[US]')\n str\n end", "def parseAscii str\n\tstr.chars.map { |c| c !~ /[[:print:]]/ ? \"0x\" + c.ord.to_s : c}.join\nend", "def rstring2cstr str, strmax, rs = nil\n return [[\"\".inspect, 0]] if str.empty?\n a = str.each_line rs\n a = a.to_a\n a.map! do |b|\n c = b.each_byte.each_slice strmax\n c.to_a\n end\n a.flatten! 1\n a.map! do |bytes|\n b = bytes.each_slice 80\n c = b.map do |d|\n d.map do |e|\n '\\\\x%x' % e\n #case e # this case statement is optimized\n #when 0x00 then '\\\\0'\n #when 0x07 then '\\\\a'\n #when 0x08 then '\\\\b'\n #when 0x09 then '\\\\t'\n #when 0x0A then '\\\\n'\n #when 0x0B then '\\\\v'\n #when 0x0C then '\\\\f'\n #when 0x0D then '\\\\r'\n #when 0x22 then '\\\\\"'\n #when 0x27 then '\\\\\\''\n #when 0x5C then '\\\\\\\\' # not \\\\\n #else\n #case e\n #when 0x20 ... 0x7F then '%c' % e\n #else '\\\\x%x' % e\n #end\n #end\n end\n end\n c.map! do |d|\n \"\\n \" '\"' + d.join + '\"'\n end\n if c.size == 1\n c.first.strip!\n end\n [ c.join, bytes.size, ]\n end\n a\n end", "def string(str)\n integer(str.bytesize, 0) + str.dup.force_encoding('binary')\n end", "def decode_string(bytes)\n bytes.map(&:chr)\n .join\n .gsub(/#{0.chr}*$/, '')\n end", "def string(buf)\n buf.read(integer(buf, 0)).force_encoding('utf-8')\n end", "def string(buf)\n buf.read(integer(buf, 0)).force_encoding('utf-8')\n end", "def make_string(s)\n s.split.map(&:chr).join\nend", "def string(str)\n integer(str.bytesize, 0) << str.dup.force_encoding('binary')\n end", "def cstr\n raise EOFError if @io.eof?\n\n @io.each_byte.take_while(&:nonzero?).pack('C*')\n end", "def encode(string)\n string.unpack('B*')[0].tr('01', \" \\n\")\n end", "def string\n str = basic_string\n if str.respond_to? :force_encoding\n str.force_encoding InternalEncoding\n end\n\n convert(str, @encoding)\n end", "def make_readable(string)\n # See String#encode\n encoding_options = {\n :invalid => :replace, # Replace invalid byte sequences\n :undef => :replace, # Replace anything not defined in ASCII\n :replace => '', # Use a blank for those replacements\n :universal_newline => true # Always break lines with \\n\n }\n return string.encode(Encoding.find('ASCII'), encoding_options)\n end", "def escape_bytea(str)\n # each_byte used instead of [] for 1.9 compatibility\n str.gsub(/[\\000-\\037\\047\\134\\177-\\377]/n){|b| \"\\\\#{sprintf('%o', b.each_byte{|x| break x}).rjust(3, '0')}\"}\n end", "def _db_zero_terminated(io)\n string = String.new\n while (char = io.read(2)) != \"\\x00\\x00\".encode(Encoding::ASCII_8BIT)\n string << char\n end\n Unxls::Biff8::Structure._encode_string(string)\n end", "def string(str)\n old = @pos\n @buffer << str.force_encoding('ASCII-8BIT')\n @pos = @buffer.bytesize\n return @pos, old\n end", "def string_value\n join(\"\\0\")\n end", "def to_ascii(string)\n\t\tstring.unpack(\"U*\").map do |c| \n\t\t\tc.chr if c < 128\n\t\tend.join\n\tend", "def to_native( str )\n\tstr.dup\nend", "def xlunicodestring(data)\n io = data.to_sio\n cch, flags = io.read(3).unpack('vC')\n _read_unicodestring(io, cch, flags)\n end", "def no_leading_spaces str\n return str.force_encoding('ASCII-8BIT').gsub(/\\302\\240/,'').strip # What a hack.\n end", "def strip_unprintable_characters(s)\n s.tr(8204.chr, \"\")\nend", "def to_ascii(string)\n require 'unidecode'\n\n begin\n #string.unpack(\"U*\").map{|c|c.chr}.join\n #Iconv.iconv(\"US-ASCII//TRANSLIT\", \"UTF-8\", string).first\n Unidecoder.decode(string).gsub(\"[?]\", \"\").gsub(/`/, \"'\").strip\n \n \n rescue => errmsg\n p errmsg\n string\n end\n end", "def get_string\n\n zero_byte = @buffer.index(\"\\0\",@position)\n\n if zero_byte == nil\n string = ''\n else\n string = get(zero_byte-@position)\n @position+=1\n end\n\n string\n\n\t\t\n\n end", "def strip_non_ascii_chars(s)\n # truncate the string at the first null character\n s = s[0, s.index(\"\\x00\")] if s.index(\"\\x00\")\n \n s.gsub(/[^\\x20-\\x7E]/,\"\")\n end", "def unescape_stringify(str)\n chars = {\n 'a' => \"\\x07\", 'b' => \"\\x08\", 't' => \"\\x09\", 'n' => \"\\x0a\", 'v' => \"\\x0b\", 'f' => \"\\x0c\",\n 'r' => \"\\x0d\", 'e' => \"\\x1b\", \"\\\\\\\\\" => \"\\x5c\", \"\\\"\" => \"\\x22\", \"'\" => \"\\x27\"\n }\n # Escape all the things\n str.gsub(/\\\\(?:([#{chars.keys.join}])|u([\\da-fA-F]{4}))|\\\\0?x([\\da-fA-F]{2})/) {\n if $1\n if $1 == '\\\\'\n then '\\\\'\n else\n chars[$1]\n end\n elsif $2\n [\"#$2\".hex].pack('U*')\n elsif $3\n [$3].pack('H2')\n end\n }\n end", "def read_string(pointer, length=nil)\n if is_null_pointer(pointer)\n return ''\n end\n\n unless length\n length = railgun.kernel32.lstrlenA(pointer)['return']\n end\n\n chars = read_array(:CHAR, length, pointer)\n return chars.join('')\n end", "def makestr(f, strptr)\n f.seek(strptr)\n str = \"\"\n b = f.read(1)\n if b != 0\n str = str + b\n end\n while b != \"\\000\"\n b = f.read(1)\n if b != \"\\000\"\n str = str + b\n end\n end\n return str\n end", "def to_ascii\n to_s.gsub(/[^\\t\\n\\r\\x20-\\x7E]/) { |c| UTF8_TO_ASCII[c] || \" \" }\n end", "def do_encoding(string)\n ## removing newline (needed for pty/expect newlines)\n string[0, 2] = '' if string.start_with? \"\\r\\n\"\n string[0, 3] = '' if string.start_with? \"\\r\\r\\n\"\n string.gsub!(\"\\r\\n\", \"\\n\")\n # string.chomp!\n string\n end", "def to_ascii; convert_format(UTF8, ASCII8BIT);end", "def read_ascii(cursor, size)\n lst_strings = @data[cursor..cursor+size-1].gsub(TRAILING_00_REGEXP, '').strip.split(NULL_TERMINATING_CHAR)\n return (lst_strings.size == 1) ? lst_strings[0] : lst_strings\n end", "def hex2string(str)\n i = 0; res = \"\"\n while i < str.length do\n res.concat(str.slice(i,2).hex.chr)\n i+=2\n end\n res\n end", "def make_utf8(str)\n return Kconv.toutf8(str.strip)\n end", "def String(p0) end", "def unpack_string(it)\n string = []\n while (byte = it.next) != 0\n string << byte\n end\n string.pack('c*')\n rescue StopIteration\n raise IndexError.new('Unexpected end of index data while reading null-terminated string')\n end", "def decode(string)\n [string.tr(\" \\n\", '01')].pack('B*')\n end", "def decode_quoted_printable\n self.unpack(\"M*\").first\n end", "def ascii_value(str)\n str.bytes.sum\nend", "def normalize_string(str)\n if str.respond_to?(:encoding)\n # These are to fix strings generated by the WriteExcel gem\n # which force encodes utf-8 to these two formats in different\n # places (As of v1.0.4).\n if str.encoding == Encoding::UTF_8\n input_encoding = nil\n input_encoding = Encoding::UTF_16LE if str.size > 1 && str[1] == \"\\0\"\n input_encoding = Encoding::UTF_16BE if !input_encoding && str.size > 0 && str[0] == \"\\0\"\n if input_encoding\n force_value = String.new(str).force_encoding(input_encoding)\n str = force_value.encode(Encoding::UTF_8) if force_value.valid_encoding?\n end\n end\n\n str = str.encode(@output_encoding, 'binary', undef: :replace) if @output_encoding && str.encoding != @output_encoding\n end\n\n str\n end", "def read_string\n strout = ''\n if next_char != '\\''\n raise UnpickleException, \"Couldn't find leading quote for string\"\n end\n while not at_end?\n c = next_char\n case c\n when \"\\\\\"\n opt = next_char\n case opt\n when 'x'\n strout += read_hex(2).chr\n when '0'\n num = ''\n while peek_char.match(/[0-7]/)\n num += next_char\n if num.length >= 3\n break\n end\n end\n unless (1..3).include?(num.length)\n raise UnpickleException, \"Bad \\\\0 sequence in string\"\n end\n strout += num.to_i(8).chr\n when 'n'\n strout += \"\\n\"\n when \"\\\\\"\n strout += \"\\\\\"\n when 't'\n strout += \"\\t\"\n when \"'\"\n strout += \"'\"\n else\n raise UnpickleException, \"Unexpected \\\\ escape: \\\\#{opt}\"\n end\n when \"'\"\n # valid end of string...\n break\n else\n strout += c\n end\n end\n if next_char != \"\\n\"\n raise UnpickleException, \"Expected \\\\n after string\"\n end\n return strout\n end", "def hex_s(ascii_s)\n ascii_s.unpack('H*')[0]\nend", "def str_value\n return @str_value unless @str_value.nil?\n if is_string != 0\n io = _parent.strings._io\n _pos = io.pos\n io.seek(value_or_ofs_value)\n @str_value = (io.read_bytes_term(0, false, true, true)).force_encoding(\"UTF-8\")\n io.seek(_pos)\n end\n @str_value\n end", "def ascii_value(string)\n string.chars.reduce(0) { |result, char| result += char.ord }\nend", "def xlunicodestringnocch(io, cch)\n flags = io.read(1).unpack('C').first\n _read_unicodestring(io, cch, flags)\n end", "def ascii_value(str)\n str.split('').reduce(0) {|sum,chr| sum + chr.ord }\nend", "def trim_id3v1_string(str)\n str.tr(\"\\x00\".b, '').strip\n end", "def to_ascii!; replace(to_ascii); end", "def binary_string; end", "def to_ascii\n options = {\n :invalid => :replace,\n :undef => :replace,\n :replace => '',\n :universal_newline => true\n }\n return self.encode(Encoding.find('ASCII'), options)\n end", "def read_string(data, offset, length, encoding)\n if \"UTF-16\".casecmp(encoding) == 0\n out = data[offset, length].unpack('v*').pack('U*')\n else\n out = data[offset, length].unpack('C*').pack('U*')\n end\n return out\n end", "def str_to_uni_z(str)\n\t\t\t\t\t\t\tenc = str.unpack(\"C*\").pack(\"v*\")\n\t\t\t\t\t\t\tenc += \"\\x00\\x00\"\n\t\t\t\t\t\t\treturn enc\n\t\t\t\t\t\tend", "def copy_string(start_pos, end_pos)\n res = @str[start_pos...end_pos]\n res.gsub!(/\\000/, '')\n res\n end", "def normalize_string str\n str.to_s.encode(\n invalid: :replace,\n undef: :replace,\n universal_newline: true\n )\n end", "def orig_text\n orig_data[4..orig_data.size-1].tr(\"\\x00\", '')\n end", "def do_encoding_terminal(string)\n string = string.to_s\n string.gsub!(\"\\r\\r\", \"\\r\")\n string.gsub!(\"\\r\\n\", \"\\n\")\n string.gsub!(\"\\r\\$\\s\", \"\")\n\n string.gsub!(/.\\r/, \"\")\n string.gsub!(/\\x1B\\[\\d*?[ABCDsuKJ]/, '')\n string\n end", "def cstr\n r = @data.unpack(\"@#{pos}Z*\")[0]\n @pos += r.bytesize + 1\n r\n end", "def shift_string(buffer)\n len = shift_short(buffer)\n str = shift_data(buffer, len)\n # Strings in MQTT v3.1 are all UTF-8\n str.force_encoding('UTF-8')\n end", "def to_utf8(str)\n str = str.force_encoding(ENCODING)\n return str if str.valid_encoding?\n str.encode(ENCODING, 'binary', invalid: :replace, undef: :replace,\n replace: '')\n end", "def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend", "def unansi(string = T.unsafe(nil)); end", "def unansi(string = T.unsafe(nil)); end", "def non_utf8_character\n [0x92].pack('C*')\n end", "def ascii_value(string)\n ascii_array = string.split('').map(&:ord)\n ascii_array.reduce(0) { |acc, elem| acc + elem }\nend", "def to_utf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\n end", "def str_to_uni_z(str)\n enc = str.encode('UTF-16LE').force_encoding('binary')\n enc += \"\\x00\\x00\"\n return enc\n end", "def normalize string\r\n begin\r\n string.dup.force_encoding('UTF-8')\r\n rescue ::Encoding::CompatibilityError, ::Encoding::UndefinedConversionError, ::Encoding::InvalidByteSequenceError => e\r\n # @todo Improve error handling\r\n Solargraph::Logging.logger.warn \"Normalize error: #{e.message}\"\r\n string\r\n end\r\n end", "def shift_string(buffer)\n len = shift_short(buffer)\n str = shift_data(buffer,len)\n # Strings in MQTT v3.1 are all UTF-8\n str.force_encoding('UTF-8')\n end", "def to_string(raw_string)\n processed_string = ''\n processed_string = raw_string.sub(\"\\n\", \" \") unless raw_string.nil?\n end", "def toUtf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\nend", "def encode_non_ascii_delimiter(str)\n return str if str.empty?\n # split would split the str without the specified delimiter while partition would output the delimiter as well\n partitioned_str = str.partition(' ') \n delimiter = 257.chr(Encoding::UTF_8)\n encoded_str = ''\n partitioned_str.each do |s|\n if s == \" \"\n encoded_str+= delimiter \n else\n encoded_str+= s\n end\n end\n encoded_str\nend", "def string\n Util.from_bytes :string, value\n end", "def shortxlunicodestring(io)\n cch, flags = io.read(2).unpack('CC')\n _read_unicodestring(io, cch, flags)\n end", "def purify\n #self.gsub!(\"\\u0000\", '').delete!('\\\\0').squeeze!('\\\\').tr!('\\\\','/').delete_at(length-1)\n self.gsub!(/(?:\\u0000)(.+)/,'')\n self.gsub!('\\\\n', 10.chr)\n self\n end", "def ascii_value(str)\n str.chars.map(&:ord).inject(0, &:+)\nend", "def parse_str(io, stop_quote)\n buf = ''\n loop do\n c = io.read_one_char\n if c.nil?\n raise Error, \"The IO ran out before the end of a literal string\"\n elsif buf.length > 0 && buf[-1..-1] == ESC # If this char was escaped\n # Trim the escape character at the end of the buffer\n buf = buf[0..-2] \n buf << c\n elsif c == stop_quote\n return buf\n else\n buf << c\n end\n end\n end", "def ascii_value(string)\n value = 0\n for i in (0..string.length-1)\n value += string[i].ord\n end\n value\nend", "def unescape(str, escaped = @regexp[:ESCAPED])\n str.gsub(escaped) { [$&[1, 2].hex].pack('C') }.force_encoding(str.encoding)\n end", "def getASCII(c)\n c.ord\nend", "def ctcp_decode(str)\n ctcp_dequote(str.delete(\"\\x01\"))\n end", "def string()\n len = self.uint32()\n self.bytes(len)\n end", "def _utf8(str)\n return str.force_encoding(Encoding::UTF_8)\nend", "def plaintext_ascii(delim=\"\\n\")\n plaintext(delim).encode('US-ASCII', invalid: :replace, undef: :replace, \n replace: '?')\n end", "def get_utf8_of(character)\n character.unpack('H*').first.upcase\nend", "def ascii!(replacement=\"\")\n n = bytes\n \n slice!(0..size)\n \n n.each { |b|\n if b < 33 || b > 127 then\n concat(replacement)\n else\n concat(b.chr)\n end\n }\n \n to_s\n end", "def ascii_value(string)\n string.each_char.reduce(0) { |sum, char| sum + char.ord }\nend", "def read_string(length)\n BinData::Stringz.read(read_and_advance(length))\n end", "def asciiz(str)\n aid = [str].pack('Z*')\n return string(aid)\n end", "def ascii_value(string)\n string.chars.inject(0) { |sum, char| sum += char.ord }\nend", "def string(str); end", "def to_s\n @int.chr(Encoding::UTF_8)\n end", "def quoted_printable(str) \n return [] if str.nil?\n \n buffer = \"\"\n lines = []\n \n 0.upto(str.bytesize - 1) do |i|\n char = \"\"\n\n case b = str.getbyte(i)\n when 10, 13\n # line feed ('\\n') or carriage return ('\\r')\n p = str.getbyte(i - 1)\n\n unless b == 10 && p == 13 || b == 13 && p == 10\n lines << buffer\n buffer = \"\"\n end\n\n when 9, 32\n # tab or whitespace\n n = str.getbyte(i + 1)\n\n if n.nil? || n == 10 || n == 13\n char = \"=#{hex(b)}\"\n else\n char = b.chr\n end\n\n when 33..60, 62..126\n # printable character ('!'..'~', except '=')\n char = b.chr\n\n else\n # any other character\n char = \"=#{hex(b)}\"\n end\n\n if buffer.length >= 78 - char.length\n lines << (buffer << \"=\")\n buffer = \"\"\n end\n buffer << char\n end\n\n\n lines << buffer\n end", "def ascii_s(hex_s)\n [hex_s].pack('H*')\nend", "def decode(input)\n decoded_string = ''\n seekable = PushableString.new(input.dup)\n while seekable.next?\n t = decode_char(seekable)\n if t.nil?\n decoded_string << seekable.next\n else\n decoded_string << t\n end\n end\n decoded_string\n end", "def reencode_string(input); end" ]
[ "0.6826558", "0.66348594", "0.66280144", "0.66049564", "0.6590987", "0.65588754", "0.6540646", "0.6517224", "0.65146315", "0.6509764", "0.6485041", "0.6485041", "0.63960546", "0.63591695", "0.63521105", "0.6332553", "0.63181746", "0.62761414", "0.6260183", "0.625749", "0.6233521", "0.6230168", "0.6217359", "0.62104356", "0.6190304", "0.6188918", "0.61884403", "0.61639553", "0.61636376", "0.6144598", "0.6112213", "0.6110863", "0.61094445", "0.6099192", "0.6055218", "0.605507", "0.6049743", "0.6041782", "0.60361826", "0.60111195", "0.6002958", "0.59940565", "0.59636444", "0.59584075", "0.5955599", "0.59360296", "0.5930209", "0.592929", "0.5928526", "0.584793", "0.58338535", "0.58276355", "0.5824777", "0.5815649", "0.5808916", "0.58019", "0.5797807", "0.5794252", "0.57882756", "0.5771547", "0.57626367", "0.57605207", "0.5756908", "0.5750253", "0.5749079", "0.5734972", "0.5734972", "0.57322586", "0.572916", "0.57155883", "0.5711841", "0.5708927", "0.5699756", "0.5692841", "0.569276", "0.5684556", "0.5683643", "0.5678259", "0.5677852", "0.56718403", "0.56709653", "0.5668886", "0.56683946", "0.5668264", "0.56671", "0.5663188", "0.5661783", "0.56576717", "0.5655116", "0.56528366", "0.5646601", "0.5643761", "0.5624476", "0.56232274", "0.5617774", "0.56115955", "0.5603487", "0.5591829", "0.55901194", "0.55855364" ]
0.673281
1
converts ruby string to zeroterminated WCHAR string
def str_to_uni_z(str) enc = str.encode('UTF-16LE').force_encoding('binary') enc += "\x00\x00" return enc end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def wide_string(str)\n # if given a nil string, assume caller wants to pass a nil pointer to win32\n return nil if str.nil?\n\n str.encode('UTF-16LE')\n end", "def toutf8(str)\n ::NKF::nkf('-wm', str)\n end", "def wputs(str)\n puts str.encode(\"cp866\", str.encoding)\nend", "def read_wstring(pointer, length = nil)\n # Return an empty string for null pointers\n if is_null_pointer(pointer)\n return ''\n end\n\n # If length not provided, use lstrlenW\n if length.nil?\n length = railgun.kernel32.lstrlenW(pointer)['return']\n end\n\n # Retrieve the array of characters\n chars = read_array(:WCHAR, length, pointer)\n\n # Concatenate the characters and convert to a ruby string\n str = uniz_to_str(chars.join(''))\n\n return str\n end", "def str_to_uni_z(str)\n\t\t\t\t\t\t\tenc = str.unpack(\"C*\").pack(\"v*\")\n\t\t\t\t\t\t\tenc += \"\\x00\\x00\"\n\t\t\t\t\t\t\treturn enc\n\t\t\t\t\t\tend", "def escape_shell_windows(str)\n str = str.to_s\n raise 'cannot escape control characters' if UNESCAPABLE_CHARS =~ str\n if QUOTE_CHARS_WINDOWS =~ str then\n '\"' + str.gsub(/\\\"/, '\"\"') + '\"'\n else\n String.new(str)\n end\n end", "def lpwidestring(data)\n io = data.to_sio\n cch = io.read(2).unpack('v').first\n _read_unicodestring(io, cch, 1) # has double-byte characters\n end", "def asm_generate_wchar_array(str)\n (str.to_s + \"\\x00\").\n unpack(\"C*\").\n pack(\"v*\").\n unpack(\"C*\").\n map{ |c| \"0x%.2x\" % c }.\n join(\",\")\n end", "def alloc_and_write_wstring(value)\n return nil if value == nil\n\n data = str_to_uni_z(value)\n result = railgun.kernel32.VirtualAlloc(nil, data.length, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE)\n if result['return'].nil?\n return nil\n end\n addr = result['return']\n if railgun.memwrite(addr, data, data.length)\n return addr\n else\n return nil\n end\n end", "def xlunicodestring(data)\n io = data.to_sio\n cch, flags = io.read(3).unpack('vC')\n _read_unicodestring(io, cch, flags)\n end", "def shortxlunicodestring(io)\n cch, flags = io.read(2).unpack('CC')\n _read_unicodestring(io, cch, flags)\n end", "def toutf16(str)\n ::NKF::nkf('-w16m', str)\n end", "def convert(string)\n\t# Adding space to handle words that end in a unicode character\n\tstring += \" \"\n\n\tword = \"\"\n\tunicode = false\n\tuni_string = \"\"\n\n\t# puts \"Starting each char...\"\n\tstring.each_char do |char|\n\t\t\n\t\t# puts \"char: #{char}\"\n\n\t\tif char != \"\\\\\" and !unicode\n\t\t\t# puts \"Adding #{char} to word\"\n\t\t\tword += convert_char(char)\n\n\t\telsif char == \"\\\\\"\n\t\t\t# puts \"Starting unicode string\"\n\t\t\tuni_string = \"\\\\\"\n\t\t\tunicode = true\n\n\t\telsif char != \" \" and unicode\n\t\t\t# puts \"Putting #{char} in unicode string: #{uni_string}\"\n\t\t\tuni_string += char\n\n\t\telsif unicode and char == \" \"\n\t\t\t# puts \"Found end of unicode string: #{uni_string}\"\n\t\t\tword += convert_char(uni_string)\n\t\t\tuni_string = \"\"\n\t\t\tunicode = false\n\t\telse\n\t\t\tputs \"Not sure what to do with #{char}\"\n\t\tend\n\tend\n\n\t# Strip to remove extra spaces\n\treturn word.strip\n\nend", "def make_utf8(str)\n return Kconv.toutf8(str.strip)\n end", "def convert_to_unicode(char)\n \n if char =~ /\\A\\\\/\n char = char.gsub(\"\\\\\",\"\") # Fix double escaping\n char = [char[0..-1].to_i(16)].pack(\"U\")\n end\n \n raise ArgumentError, \"You can only pass one character\" if char.size > 1\n \n char\n end", "def asciiz(str)\n aid = [str].pack('Z*')\n return string(aid)\n end", "def get_unicode_of(character)\n character.unpack('U*').first.to_s(16).rjust(4, '0').upcase\nend", "def escape_bytea(str)\n # each_byte used instead of [] for 1.9 compatibility\n str.gsub(/[\\000-\\037\\047\\134\\177-\\377]/n){|b| \"\\\\#{sprintf('%o', b.each_byte{|x| break x}).rjust(3, '0')}\"}\n end", "def unicode(str)\n\t\tRex::Text.to_unicode(str)\n\tend", "def unix2dos(string)\n string.gsub(\"\\r\", \"\").gsub(\"\\n\", \"\\r\\n\")\n end", "def get_windows_1252_of(character)\n begin\n \"0\" + character.encode('Windows-1252').unpack('H*').first.to_i(16).to_s\n rescue Encoding::InvalidByteSequenceError, Encoding::UndefinedConversionError\n \"\"\n end\nend", "def widen_char(c)\n c += 65248 if c.between? 33, 126 # character w/ fullwidth equivalent\n c.chr Encoding::UTF_8\nend", "def ret_ws\n result = ''\n func = get_func(Fiddle::TYPE_LONG)\n if func\n result = Types::WideChar.from_ptr(func.call(*@args))\n end\n result\n end", "def escape_string(str)\n str.gsub(/[\\0\\n\\r\\\\\\'\\\"\\x1a]/) do |s|\n case s\n when \"\\0\" then \"\\\\0\"\n when \"\\n\" then \"\\\\n\"\n when \"\\r\" then \"\\\\r\"\n when \"\\x1a\" then \"\\\\Z\"\n else \"\\\\#{s}\"\n end\n end\n end", "def escape_shell(str)\n case RUBY_PLATFORM\n when /mswin32|bccwin32/\n escape_shell_windows(str)\n else\n escape_shell_unix(str)\n end\n end", "def escape_string(str)\n str.gsub(/[\\0\\n\\r\\\\\\'\\\"\\x1a]/) do |s|\n case s\n when \"\\0\" then \"\\\\0\"\n when \"\\n\" then \"\\\\n\"\n when \"\\r\" then \"\\\\r\"\n when \"\\x1a\" then \"\\\\Z\"\n else \"\\\\#{s}\"\n end\n end\n end", "def unicode(str)\n Rex::Text.to_unicode(str)\n end", "def shell_escape\n inspect.gsub(/\\\\(\\d{3})/) { $1.to_i(8).chr }\n end", "def rstring2cstr str, strmax, rs = nil\n return [[\"\".inspect, 0]] if str.empty?\n a = str.each_line rs\n a = a.to_a\n a.map! do |b|\n c = b.each_byte.each_slice strmax\n c.to_a\n end\n a.flatten! 1\n a.map! do |bytes|\n b = bytes.each_slice 80\n c = b.map do |d|\n d.map do |e|\n '\\\\x%x' % e\n #case e # this case statement is optimized\n #when 0x00 then '\\\\0'\n #when 0x07 then '\\\\a'\n #when 0x08 then '\\\\b'\n #when 0x09 then '\\\\t'\n #when 0x0A then '\\\\n'\n #when 0x0B then '\\\\v'\n #when 0x0C then '\\\\f'\n #when 0x0D then '\\\\r'\n #when 0x22 then '\\\\\"'\n #when 0x27 then '\\\\\\''\n #when 0x5C then '\\\\\\\\' # not \\\\\n #else\n #case e\n #when 0x20 ... 0x7F then '%c' % e\n #else '\\\\x%x' % e\n #end\n #end\n end\n end\n c.map! do |d|\n \"\\n \" '\"' + d.join + '\"'\n end\n if c.size == 1\n c.first.strip!\n end\n [ c.join, bytes.size, ]\n end\n a\n end", "def ShellEscape(s)\n i = 0\n res = \"\"\n\n while Ops.less_than(i, Builtins.size(s))\n c = Builtins.substring(s, i, 1)\n c = Ops.add(\"\\\\\", c) if c == \"\\\"\" || c == \"$\" || c == \"\\\\\" || c == \"`\"\n res = Ops.add(res, c)\n i = Ops.add(i, 1)\n end\n res\n end", "def x\n\t\tt =\"\"; \n\t\tself.each_byte do |a| \n\t\t\tif a == \"\\r\"[0] then\n\t\t\t\tt << \"\\\\r\"\n\t\t\telsif a == \"\\t\"[0] then\n\t\t\t\tt << \"\\\\r\"\n\t\t\telsif a == \"\\n\"[0] then\n\t\t\t\tt << \"\\\\n\"\n\t\t\telsif a == \"\\b\"[0] then\n\t\t\t\tt << \"\\\\b\"\n\t\t\telsif a > 0 && a < 32 then\n\t\t\t\tt << (\"\\\\x%2.2d\" % a)\n\t\t\telse \n\t\t\t\tt << a.chr\n\t\t\tend\n\t\tend\n\t\tt\n\t\t#return gsub(/\\r/, \"\\\\r\").gsub(/\\n/, \"\\\\n\").gsub(/\\t/, \"\\\\t\")\n\tend", "def escape_string(str)\n return if str.nil?\n str.gsub(/[\\0\\n\\r\\\\\\'\\\"\\x1a]/) do |s|\n case s\n when \"\\0\" then \"\\\\0\"\n when \"\\n\" then \"\\\\n\"\n when \"\\r\" then \"\\\\r\"\n when \"\\x1a\" then \"\\\\Z\"\n else \"\\\\#{s}\"\n end\n end\nend", "def escape_string(str)\n str.gsub(/([\\0\\n\\r\\032\\'\\\"\\\\])/) do\n case $1\n when \"\\0\" then \"\\\\0\"\n when \"\\n\" then \"\\\\n\"\n when \"\\r\" then \"\\\\r\"\n when \"\\032\" then \"\\\\Z\"\n else \"\\\\\"+$1\n end\n end\n end", "def toutf7!\n self.tr!(CCHAR,CMAPP) if ( self =~ /[\\x00-\\x31]/)\n self.tr!(XCHAR,XMAPP) if ( self =~ /[\\x80-\\xFF]/)\n self\n end", "def uniz_to_str(uniz)\n uniz.force_encoding('UTF-16LE').encode('UTF-8')\n end", "def makeWindowsPathIntoMinGWPath(path)\n modifiedPath = path.gsub(/\\\\/, '/')\n modifiedPath.gsub(/^(\\w+):[\\\\\\/]/) { \"/#{$1.downcase}/\" }\nend", "def unencode_javascript_unicode_escape(str)\n if str.respond_to?(:gsub!)\n str.gsub!(/\\\\u([0-9a-fA-F]{4})/) do |s| \n int = $1.to_i(16)\n if int.zero? && s != \"0000\"\n s\n else\n [int].pack(\"U\")\n end\n end\n end\n str\n end", "def _w(str)\n _t(str).length.to_s\n end", "def from_string_to_wide_string(str, &block)\n str = wide_string(str)\n FFI::MemoryPointer.from_wide_string(str) { |ptr| yield ptr }\n\n # ptr has already had free called, so nothing to return\n nil\n end", "def str2warray(value)\n unquote_string(value).gsub(/ /, '\\\\ ')\n end", "def makeWindowsPathIntoMinGWPath(path)\n modified_path = path.tr('\\\\', '/')\n modified_path.gsub(%r{^(\\w+):[\\\\/]}) { \"/#{Regexp.last_match(1).downcase}/\" }\nend", "def to_windows_path(path)\n path.gsub('/', \"\\\\\")\n end", "def quote_zenkaku(str)\n if str.mbchar? >= 0\n \"「\" + str + \"」\"\n else\n \"'\" + str + \"'\"\n end\n end", "def shift_string(buffer)\n len = shift_short(buffer)\n str = shift_data(buffer,len)\n # Strings in MQTT v3.1 are all UTF-8\n str.force_encoding('UTF-8')\n end", "def unicode(str)\n Rex::Text.to_unicode(str)\n end", "def shift_string(buffer)\n len = shift_short(buffer)\n str = shift_data(buffer, len)\n # Strings in MQTT v3.1 are all UTF-8\n str.force_encoding('UTF-8')\n end", "def shellescape\n Shellwords.escape(self)\n end", "def new_character(unicode)\n {:width=>\"1000\", :flags=>\"W\", :layercount=>\"2\", :splineset=>\"\", :unicode=>unicode}\n end", "def get_utf8_of(character)\n character.unpack('H*').first.upcase\nend", "def encode(string)\n string.unpack('B*')[0].tr('01', \" \\n\")\n end", "def write_utf16le_string(*args)\n # Check for a cell reference in A1 notation and substitute row and column\n if args[0] =~ /^\\D/\n args = substitute_cellref(*args)\n end\n\n return -1 if (args.size < 3) # Check the number of args\n\n record = 0x00FD # Record identifier\n length = 0x000A # Bytes to follow\n\n row = args[0] # Zero indexed row\n col = args[1] # Zero indexed column\n str = args[2]\n format = args[3] # The cell format\n\n # Change from UTF16 big-endian to little endian\n str = str.unpack('n*').pack(\"v*\")\n\n return write_utf16be_string(row, col, str, format)\n end", "def convert_unicode(str)\n while true\n u_idx = str.index(/\\\\u[0-9a-fA-F]{4}/)\n break if u_idx == nil\n\n u_str = str.slice(u_idx, 6)\n str.sub!(u_str, u_str[2..5].hex.chr)\n end\n str\n end", "def putd_backslash str\n putd(str + \" \\\\\")\nend", "def escape_string(str)\n replacement = {\n ':)' => \"\\n\", ':>' => \"\\t\", ':o' => \"\\a\", ':\"' => '\"', '::' => ':'\n }\n str\n .gsub(/:[\\)>o\":]/, replacement)\n .gsub(/:\\(([0-9a-fA-F]+)\\)/) do |match|\n $1.to_i(16).chr(Encoding::UTF_8)\n end\n .gsub(/:\\[(.+?)\\]/) do |match|\n code = Unicode::DATA[$1]\n if code\n code.chr(Encoding::UTF_8)\n else\n $stderr.puts(\"Unknown Unicode normative name: #{$1}\")\n match\n end\n end\n end", "def xlunicodestringnocch(io, cch)\n flags = io.read(1).unpack('C').first\n _read_unicodestring(io, cch, flags)\n end", "def non_utf8_character\n [0x92].pack('C*')\n end", "def unicode_chr(val)\n\t\t[val].inject('') {|s, cp| s << cp }\n\tend", "def make_command_line_windows(ary)\n ary.collect { |str| escape_shell_windows(str) }.join(\" \")\n end", "def escape_shell_unix(str)\n str = str.to_s\n raise 'cannot escape control characters' if UNESCAPABLE_CHARS =~ str\n str.gsub(UNSAFE_CHARS_UNIX) { |x| \"\\\\#{x}\" }\n end", "def string(str)\n TYPE_STRING +\n word(str.length) +\n str.encode!(\"ASCII\")\n end", "def force_to_ascii s\n out = \"\"\n s.each_byte do |b|\n if (b & 128) != 0\n out << \"\\\\x#{b.to_s 16}\"\n else\n out << b.chr\n end\n end\n #out.force_encoding Encoding::UTF_8 if in_ruby19_hell? # not necessary?\n out\n end", "def normalize_string(str)\n if str.respond_to?(:encoding)\n # These are to fix strings generated by the WriteExcel gem\n # which force encodes utf-8 to these two formats in different\n # places (As of v1.0.4).\n if str.encoding == Encoding::UTF_8\n input_encoding = nil\n input_encoding = Encoding::UTF_16LE if str.size > 1 && str[1] == \"\\0\"\n input_encoding = Encoding::UTF_16BE if !input_encoding && str.size > 0 && str[0] == \"\\0\"\n if input_encoding\n force_value = String.new(str).force_encoding(input_encoding)\n str = force_value.encode(Encoding::UTF_8) if force_value.valid_encoding?\n end\n end\n\n str = str.encode(@output_encoding, 'binary', undef: :replace) if @output_encoding && str.encoding != @output_encoding\n end\n\n str\n end", "def mb_charify(text)\n if RUBY_VERSION >= '1.9'\n text.dup\n elsif text.respond_to?(:mb_chars)\n text.frozen? ? text.dup.mb_chars : text.mb_chars\n else\n raise \"StringUtils: No unicode support for strings\"\n end\n end", "def utf8str(code)\n if (code & ~(0x7f)) == 0\n # UCS-4 range 0x00000000 - 0x0000007F\n return(code.chr)\n end\n\n buf = \"\"\n if (code & ~(0x7ff)) == 0\n # UCS-4 range 0x00000080 - 0x000007FF\n buf << (0b11000000 | (code >> 6)).chr\n buf << (0b10000000 | (code & 0b00111111)).chr\n return(buf)\n end\n\n if (code & ~(0x000ffff)) == 0\n # UCS-4 range 0x00000800 - 0x0000FFFF\n buf << (0b11100000 | (code >> 12)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # Not used -- JSON only has UCS-2, but for the sake\n # of completeness\n if (code & ~(0x1FFFFF)) == 0\n # UCS-4 range 0x00010000 - 0x001FFFFF\n buf << (0b11110000 | (code >> 18)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n if (code & ~(0x03FFFFFF)) == 0\n # UCS-4 range 0x00200000 - 0x03FFFFFF\n buf << (0b11110000 | (code >> 24)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # UCS-4 range 0x04000000 - 0x7FFFFFFF\n buf << (0b11111000 | (code >> 30)).chr\n buf << (0b10000000 | ((code >> 24) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end", "def write(string)\n string.to_s.bytesize\n end", "def quote_if_windows(p)\n if RUBY_PLATFORM =~ /mswin32/\n '\"' + p + '\"'\n else\n p\n end\nend", "def asciiz_to_str(asciiz)\n\t\t\t\t\t\t\tzero_byte_idx = asciiz.index(\"\\x00\")\n\t\t\t\t\t\t\tif zero_byte_idx != nil\n\t\t\t\t\t\t\t\treturn asciiz[0, zero_byte_idx]\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\treturn asciiz\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend", "def as_hex_ewkb(allow_srid=true,allow_z=true,allow_m=true)\r\n \tas_ewkb(allow_srid, allow_z, allow_m).unpack('H*').join('').upcase\r\n end", "def write_word32_native(val)\n pw(val, 'L')\n end", "def get_utf8cstring(string,buffer,bufferSize)\n JavaScriptCore::Lib.JSStringGetUTF8CString(string,buffer,bufferSize)\n end", "def asciiz_to_str(asciiz)\n zero_byte_idx = asciiz.index(\"\\x00\")\n if zero_byte_idx != nil\n return asciiz[0, zero_byte_idx]\n else\n return asciiz\n end\n end", "def mssqlchar\n foo=[]\n self.asciime.split(',').each {|chr| foo << \"CHAR(#{chr})\" }\n foo.join('+')\n end", "def unescape\n bytes = escaped_path_to_bytes(path)\n str = bytes.pack('C*')\n str.force_encoding(Encoding::UTF_8)\n end", "def yy_unicode_s(char_code)\n \"U+#{\"%04X\" % char_code}\"\n end", "def to_cp1252(str)\n str.encode('cp1252')\n end", "def shellescape(str)\n # An empty argument will be skipped, so return empty quotes.\n return \"''\" if str.empty?\n\n str = str.dup\n\n # Treat multibyte characters as is. It is caller's responsibility\n # to encode the string in the right encoding for the shell\n # environment.\n str.gsub!(/([^A-Za-z0-9_\\-.,:\\/@\\n])/, \"\\\\\\\\\\\\1\")\n\n # A LF cannot be escaped with a backslash because a backslash + LF\n # combo is regarded as line continuation and simply ignored.\n str.gsub!(/\\n/, \"'\\n'\")\n\n return str\nend", "def decoder(string)\n string.gsub(/(WUB)+/, ' ').strip\nend", "def _LWSP_char\n\n _save = self.pos\n while true # choice\n _tmp = apply(:_SPACE)\n break if _tmp\n self.pos = _save\n _tmp = apply(:_HTAB)\n break if _tmp\n self.pos = _save\n break\n end # end choice\n\n set_failed_rule :_LWSP_char unless _tmp\n return _tmp\n end", "def escape_string (string)\n string.gsub(/([\\x00-\\x1f\\x21-\\x2f\\x3a-\\x40\\x5b-\\x5e\\x60\\x7b-\\x7f])/, '\\\\\\\\\\\\1')\n end", "def force_utf32=(_arg0); end", "def force_utf32=(_arg0); end", "def force_utf32=(_arg0); end", "def windStr \n \"windStr\" \n end", "def escape(str)\n str.dump[1..-2]\nend", "def uC\n NWRFCLib::Cutf16le_to_utf8.iconv(self).strip\n end", "def transliterate(string)\n ActiveSupport::Multibyte::Chars.new(string).tidy_bytes.normalize(:d).unpack(\"U*\").map do |char|\n ASCII_APPROXIMATIONS[char] || (char if char < 128)\n end.compact.flatten.pack(\"U*\")\n end", "def iconv() end", "def as_tr_cpp name\n q = name.dup\n q.force_encoding 'ASCII-8BIT'\n q.gsub! %r/[^a-zA-Z0-9_]/m, '_'\n q.gsub! %r/_+/, '_'\n q\n end", "def convert_string string\n return string unless @in_b or @in_em\n chars = if @in_b then\n string.chars.map do |char| \"#{char}\\b#{char}\" end\n elsif @in_em then\n string.chars.map do |char| \"_\\b#{char}\" end\n end\n\n chars.join\n end", "def windows_path(path)\n path.gsub(/\\//, '\\\\')\n end", "def shellescape(str)\n str = str.to_s\n\n # An empty argument will be skipped, so return empty quotes.\n return \"''\" if str.empty?\n\n str = str.dup\n\n # Treat multibyte characters as is. It is caller's responsibility\n # to encode the string in the right encoding for the shell\n # environment.\n str.gsub!(/([^A-Za-z0-9_\\-.,:\\/@\\n])/, \"\\\\\\\\\\\\1\")\n\n # A LF cannot be escaped with a backslash because a backslash + LF\n # combo is regarded as line continuation and simply ignored.\n str.gsub!(/\\n/, \"'\\n'\")\n\n return str\n end", "def to_s\n '<Twilio.Oauth.V1.DeviceCodePage>'\n end", "def unescape_stringify(str)\n chars = {\n 'a' => \"\\x07\", 'b' => \"\\x08\", 't' => \"\\x09\", 'n' => \"\\x0a\", 'v' => \"\\x0b\", 'f' => \"\\x0c\",\n 'r' => \"\\x0d\", 'e' => \"\\x1b\", \"\\\\\\\\\" => \"\\x5c\", \"\\\"\" => \"\\x22\", \"'\" => \"\\x27\"\n }\n # Escape all the things\n str.gsub(/\\\\(?:([#{chars.keys.join}])|u([\\da-fA-F]{4}))|\\\\0?x([\\da-fA-F]{2})/) {\n if $1\n if $1 == '\\\\'\n then '\\\\'\n else\n chars[$1]\n end\n elsif $2\n [\"#$2\".hex].pack('U*')\n elsif $3\n [$3].pack('H2')\n end\n }\n end", "def shellescape(str)\n Util.shellescape(str)\n end", "def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend", "def escape_shell_string(str)\n str = str.gsub(/\\\\/, \"\\\\\\\\\\\\\")\n str = str.gsub(/\"/, \"\\\\\\\"\")\n str = str.gsub(/`/, \"\\\\`\")\n str = str.gsub(/;/, \"\\\\;\")\n str = str.gsub(/&/, \"\\\\&\")\n str = str.gsub(/\\|/, \"\\\\|\")\n str = str.gsub(/\\$/, \"\\\\$\")\n str = str.gsub(/ /, \"\\\\ \")\n str\n end", "def write_utf16be_string(*args)\n # Check for a cell reference in A1 notation and substitute row and column\n if args[0] =~ /^\\D/\n args = substitute_cellref(*args)\n end\n\n return -1 if (args.size < 3) # Check the number of args\n\n record = 0x00FD # Record identifier\n length = 0x000A # Bytes to follow\n\n row = args[0] # Zero indexed row\n col = args[1] # Zero indexed column\n strlen = args[2].length\n str = args[2]\n xf = xf_record_index(row, col, args[3]) # The cell format\n encoding = 0x1\n str_error = 0\n\n # Check that row and col are valid and store max and min values\n return -2 if check_dimensions(row, col) != 0\n\n # Limit the utf16 string to the max number of chars (not bytes).\n if strlen > 32767* 2\n str = str[0..32767*2]\n str_error = -3\n end\n\n num_bytes = str.length\n num_chars = (num_bytes / 2).to_i\n\n # Check for a valid 2-byte char string.\n raise \"Uneven number of bytes in Unicode string\" if num_bytes % 2 != 0\n\n # Change from UTF16 big-endian to little endian\n str = str.unpack('n*').pack('v*')\n\n # Add the encoding and length header to the string.\n str_header = [num_chars, encoding].pack(\"vC\")\n str = str_header + str\n\n unless @str_table[str]\n @str_table[str] = str_unique\n add_str_unique(1)\n end\n\n add_str_total(1)\n \n header = [record, length].pack(\"vv\")\n data = [row, col, xf, @str_table[str]].pack(\"vvvV\")\n\n # Store the data or write immediately depending on the compatibility mode.\n if @compatibility != 0\n tmp = []\n tmp[col] = header + data\n @table[row] = tmp\n else\n append(header, data)\n end\n\n return str_error\n end", "def do_encoding_terminal(string)\n string = string.to_s\n string.gsub!(\"\\r\\r\", \"\\r\")\n string.gsub!(\"\\r\\n\", \"\\n\")\n string.gsub!(\"\\r\\$\\s\", \"\")\n\n string.gsub!(/.\\r/, \"\")\n string.gsub!(/\\x1B\\[\\d*?[ABCDsuKJ]/, '')\n string\n end", "def zen2n(s)\n '0123456789'.index(s)\n end", "def shellescape(str)\n # An empty argument will be skipped, so return empty quotes.\n return \"''\" if str.empty?\n\n str = str.dup\n\n # Process as a single byte sequence because not all shell\n # implementations are multibyte aware.\n str.gsub!(/([^A-Za-z0-9_\\-.,:\\/@\\n])/n, \"\\\\\\\\\\\\1\")\n\n # A LF cannot be escaped with a backslash because a backslash + LF\n # combo is regarded as line continuation and simply ignored.\n str.gsub!(/\\n/, \"'\\n'\")\n\n return str\n end" ]
[ "0.6431486", "0.6391995", "0.59874135", "0.5955165", "0.5926847", "0.5863911", "0.57815164", "0.5760506", "0.57093066", "0.5672315", "0.56306213", "0.5539554", "0.551608", "0.539294", "0.52962923", "0.5289942", "0.52657145", "0.5259343", "0.5255698", "0.524429", "0.52297443", "0.5225903", "0.52107173", "0.5200886", "0.51965255", "0.5185276", "0.51810896", "0.51755726", "0.5173908", "0.5148445", "0.5147738", "0.51298964", "0.5126422", "0.5122132", "0.51195216", "0.5115694", "0.5094098", "0.5093707", "0.50734776", "0.5055109", "0.5052753", "0.50510275", "0.503463", "0.5033211", "0.5032122", "0.5017424", "0.5004984", "0.50036466", "0.49894974", "0.49873045", "0.49785092", "0.49779645", "0.49767867", "0.49676952", "0.49533126", "0.49482983", "0.49415442", "0.49358878", "0.49212453", "0.49210224", "0.48796198", "0.48782977", "0.48647913", "0.48641592", "0.48494005", "0.48491243", "0.483534", "0.48261303", "0.4823428", "0.4821847", "0.48170432", "0.47944942", "0.47891107", "0.47549617", "0.4754235", "0.47431344", "0.47379422", "0.47266138", "0.47219306", "0.4720859", "0.4720859", "0.4720859", "0.47115546", "0.47071195", "0.46990862", "0.46967992", "0.46922892", "0.46784195", "0.46739757", "0.46712244", "0.46688038", "0.46667114", "0.4664308", "0.4652371", "0.46520904", "0.46519256", "0.4650846", "0.46432233", "0.46417218", "0.46269733" ]
0.60921353
2
converts 0terminated UTF16 to ruby string
def uniz_to_str(uniz) uniz.force_encoding('UTF-16LE').encode('UTF-8') end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def to_utf16\r\n Iconv.iconv(\"utf-16LE\", \"utf-8\", self).first + \"\\x00\\x00\"\r\n end", "def from_utf16\r\n ret = Iconv.iconv(\"utf-8\", \"utf-16le\", self).first\r\n if ret[-1] == 0\r\n ret = ret[0..-2]\r\n end\r\n end", "def from_utf16_buffer\r\n self[0..index(\"\\0\\0\\0\")+2].from_utf16\r\n end", "def read_string(data, offset, length, encoding)\n if \"UTF-16\".casecmp(encoding) == 0\n out = data[offset, length].unpack('v*').pack('U*')\n else\n out = data[offset, length].unpack('C*').pack('U*')\n end\n return out\n end", "def get_utf16_of(character)\n character.encode('UTF-16BE').unpack('H*').first.upcase\nend", "def to_utf16(str)\n if str.respond_to?(:encode)\n str.encode('UTF-16BE')\n else\n Iconv.conv('UTF-16BE', 'UTF-8', str)\n end\n end", "def toutf16; Kconv.toutf16(self) end", "def uC\n self.force_encoding('UTF-16LE').encode('UTF-8').strip\n end", "def str_to_uni_z(str)\n enc = str.encode('UTF-16LE').force_encoding('binary')\n enc += \"\\x00\\x00\"\n return enc\n end", "def to_utf8(raw_text)\n if raw_text.platform_id == 1 && raw_text.encoding_id == 0\n return raw_text\n else\n begin\n raw_text.encode(\"UTF-8\", \"UTF-16BE\")\n rescue\n raw_text\n end\n end\n end", "def toutf16(str)\n ::NKF::nkf('-w16m', str)\n end", "def read_binary_unicode_string(fname,fd,length)\n # The problem is: we get the length of the string IN CHARACTERS;\n # since a char in UTF-16 can be 16 or 32 bit long, we don't really know\n # how long the string is in bytes\n buff = fd.read(2*length)\n\n @unique_table[buff] = true unless @unique_table.has_key?(buff)\n return CFString.new(Binary.charset_convert(buff,\"UTF-16BE\",\"UTF-8\"))\n end", "def clean(str)\n st = str.encode('UTF-16', 'UTF-8', :invalid => :replace, :replace => '')\n return st.encode('UTF-8', 'UTF-16')\nend", "def write_utf16be_string(*args)\n # Check for a cell reference in A1 notation and substitute row and column\n if args[0] =~ /^\\D/\n args = substitute_cellref(*args)\n end\n\n return -1 if (args.size < 3) # Check the number of args\n\n record = 0x00FD # Record identifier\n length = 0x000A # Bytes to follow\n\n row = args[0] # Zero indexed row\n col = args[1] # Zero indexed column\n strlen = args[2].length\n str = args[2]\n xf = xf_record_index(row, col, args[3]) # The cell format\n encoding = 0x1\n str_error = 0\n\n # Check that row and col are valid and store max and min values\n return -2 if check_dimensions(row, col) != 0\n\n # Limit the utf16 string to the max number of chars (not bytes).\n if strlen > 32767* 2\n str = str[0..32767*2]\n str_error = -3\n end\n\n num_bytes = str.length\n num_chars = (num_bytes / 2).to_i\n\n # Check for a valid 2-byte char string.\n raise \"Uneven number of bytes in Unicode string\" if num_bytes % 2 != 0\n\n # Change from UTF16 big-endian to little endian\n str = str.unpack('n*').pack('v*')\n\n # Add the encoding and length header to the string.\n str_header = [num_chars, encoding].pack(\"vC\")\n str = str_header + str\n\n unless @str_table[str]\n @str_table[str] = str_unique\n add_str_unique(1)\n end\n\n add_str_total(1)\n \n header = [record, length].pack(\"vv\")\n data = [row, col, xf, @str_table[str]].pack(\"vvvV\")\n\n # Store the data or write immediately depending on the compatibility mode.\n if @compatibility != 0\n tmp = []\n tmp[col] = header + data\n @table[row] = tmp\n else\n append(header, data)\n end\n\n return str_error\n end", "def xlunicodestring(data)\n io = data.to_sio\n cch, flags = io.read(3).unpack('vC')\n _read_unicodestring(io, cch, flags)\n end", "def fix_utf_errors\n self.encode('UTF-16', 'UTF-8', :invalid => :replace, :replace => '').encode('UTF-8', 'UTF-16')\n end", "def string\n binary.map { |i| i.to_i.to_s(16) }.join('')\n end", "def re_encode_to_utf8(s)\n (s.valid_encoding? ?\n s :\n s.encode('UTF-16be', invalid: :replace, replace: '?')\n ).encode('UTF-8')\nend", "def to_utf8; convert_format(ASCII8BIT, UTF8); end", "def shortxlunicodestring(io)\n cch, flags = io.read(2).unpack('CC')\n _read_unicodestring(io, cch, flags)\n end", "def string\n str = basic_string\n if str.respond_to? :force_encoding\n str.force_encoding InternalEncoding\n end\n\n convert(str, @encoding)\n end", "def sterilize(str)\n str.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')\n str.gsub!(0x00.chr,'[NUL]')\n str.gsub!(0x01.chr,'[SOH]')\n str.gsub!(0x02.chr,'[STX]')\n str.gsub!(0x03.chr,'[ETX]')\n str.gsub!(0x04.chr,'[EOT]')\n str.gsub!(0x05.chr,'[ENQ]')\n str.gsub!(0x06.chr,'[ACK]')\n str.gsub!(0x07.chr,'[BEL]')\n # 0x08 is backspace\n # 0x09 is TAB\n # 0x10 is line feed\n str.gsub!(0x0B.chr,'[VT]')\n # 0x0c is form feed\n # 0x0d is carriage return\n str.gsub!(0x0E.chr,'[SO]')\n str.gsub!(0x0F.chr,'[SI]')\n str.gsub!(0x10.chr,'[DLE]')\n str.gsub!(0x11.chr,'[DC1]')\n str.gsub!(0x12.chr,'[DC2]')\n str.gsub!(0x13.chr,'[DC3]')\n str.gsub!(0x14.chr,'[DC4]')\n str.gsub!(0x15.chr,'[NAK]')\n str.gsub!(0x16.chr,'[SYN]')\n str.gsub!(0x17.chr,'[ETB]')\n str.gsub!(0x18.chr,'[CAN]')\n str.gsub!(0x19.chr,'[EM]')\n str.gsub!(0x1a.chr,'[SUB]')\n str.gsub!(0x1C.chr,'[FS]')\n str.gsub!(0x1D.chr,'[GS]')\n str.gsub!(0x1E.chr,'[RS]')\n str.gsub!(0x1F.chr,'[US]')\n str\n end", "def uC\n NWRFCLib::Cutf16le_to_utf8.iconv(self).strip\n end", "def string(buf)\n buf.read(integer(buf, 0)).force_encoding('utf-8')\n end", "def string(buf)\n buf.read(integer(buf, 0)).force_encoding('utf-8')\n end", "def force_to_ascii s\n out = \"\"\n s.each_byte do |b|\n if (b & 128) != 0\n out << \"\\\\x#{b.to_s 16}\"\n else\n out << b.chr\n end\n end\n #out.force_encoding Encoding::UTF_8 if in_ruby19_hell? # not necessary?\n out\n end", "def to_ascii; convert_format(UTF8, ASCII8BIT);end", "def asciiz_to_str(asciiz)\n zero_byte_idx = asciiz.index(\"\\x00\")\n if zero_byte_idx != nil\n return asciiz[0, zero_byte_idx]\n else\n return asciiz\n end\n end", "def utf8str(code)\n if (code & ~(0x7f)) == 0\n # UCS-4 range 0x00000000 - 0x0000007F\n return(code.chr)\n end\n\n buf = \"\"\n if (code & ~(0x7ff)) == 0\n # UCS-4 range 0x00000080 - 0x000007FF\n buf << (0b11000000 | (code >> 6)).chr\n buf << (0b10000000 | (code & 0b00111111)).chr\n return(buf)\n end\n\n if (code & ~(0x000ffff)) == 0\n # UCS-4 range 0x00000800 - 0x0000FFFF\n buf << (0b11100000 | (code >> 12)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # Not used -- JSON only has UCS-2, but for the sake\n # of completeness\n if (code & ~(0x1FFFFF)) == 0\n # UCS-4 range 0x00010000 - 0x001FFFFF\n buf << (0b11110000 | (code >> 18)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n if (code & ~(0x03FFFFFF)) == 0\n # UCS-4 range 0x00200000 - 0x03FFFFFF\n buf << (0b11110000 | (code >> 24)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end\n\n # UCS-4 range 0x04000000 - 0x7FFFFFFF\n buf << (0b11111000 | (code >> 30)).chr\n buf << (0b10000000 | ((code >> 24) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 18) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 12) & 0b00111111)).chr\n buf << (0b10000000 | ((code >> 6) & 0b00111111)).chr\n buf << (0b10000000 | (code & 0b0011111)).chr\n return(buf)\n end", "def non_utf8_character\n [0x92].pack('C*')\n end", "def get_unicode_of(character)\n character.unpack('U*').first.to_s(16).rjust(4, '0').upcase\nend", "def convert_to_unicode(char)\n \n if char =~ /\\A\\\\/\n char = char.gsub(\"\\\\\",\"\") # Fix double escaping\n char = [char[0..-1].to_i(16)].pack(\"U\")\n end\n \n raise ArgumentError, \"You can only pass one character\" if char.size > 1\n \n char\n end", "def get_utf8_of(character)\n character.unpack('H*').first.upcase\nend", "def get_string\n\n zero_byte = @buffer.index(\"\\0\",@position)\n\n if zero_byte == nil\n string = ''\n else\n string = get(zero_byte-@position)\n @position+=1\n end\n\n string\n\n\t\t\n\n end", "def decode_string(bytes)\n bytes.map(&:chr)\n .join\n .gsub(/#{0.chr}*$/, '')\n end", "def to_hexstr\n Common.unpackbytes(to_s)\n end", "def get\n self.data.force_encoding(Encoding::UTF_16BE).encode(Encoding::UTF_8)\n end", "def fix_encoding!(str)\n\t#str.force_encoding(\"UTF-8\")\n\t#pp str.encoding, str.valid_encoding?\n\tstr.encode!(\"UTF-16BE\", :invalid=>:replace, :replace=>\"?\")\n\tstr.encode!(\"UTF-8\")\nend", "def wide_string(str)\n # if given a nil string, assume caller wants to pass a nil pointer to win32\n return nil if str.nil?\n\n str.encode('UTF-16LE')\n end", "def asciiz_to_str(asciiz)\n\t\t\t\t\t\t\tzero_byte_idx = asciiz.index(\"\\x00\")\n\t\t\t\t\t\t\tif zero_byte_idx != nil\n\t\t\t\t\t\t\t\treturn asciiz[0, zero_byte_idx]\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\treturn asciiz\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend", "def string()\n len = self.uint32()\n self.bytes(len)\n end", "def to_utf (str)\n encoded_str = ''\n str.split('').each {|char| \n encoded_char = char.encode('UTF-8')\n encoded_char.bytes.each {|byte|\n encoded_str << \"%#{byte.to_s(16)}\"\n }\n }\n return encoded_str\nend", "def shift_string(buffer)\n len = shift_short(buffer)\n str = shift_data(buffer, len)\n # Strings in MQTT v3.1 are all UTF-8\n str.force_encoding('UTF-8')\n end", "def make_utf8(str)\n return Kconv.toutf8(str.strip)\n end", "def shift_string(buffer)\n len = shift_short(buffer)\n str = shift_data(buffer,len)\n # Strings in MQTT v3.1 are all UTF-8\n str.force_encoding('UTF-8')\n end", "def convert_unicode(str)\n while true\n u_idx = str.index(/\\\\u[0-9a-fA-F]{4}/)\n break if u_idx == nil\n\n u_str = str.slice(u_idx, 6)\n str.sub!(u_str, u_str[2..5].hex.chr)\n end\n str\n end", "def string_value\n join(\"\\0\")\n end", "def force_utf32=(_arg0); end", "def force_utf32=(_arg0); end", "def force_utf32=(_arg0); end", "def str_value\n return @str_value unless @str_value.nil?\n if is_string != 0\n io = _parent.strings._io\n _pos = io.pos\n io.seek(value_or_ofs_value)\n @str_value = (io.read_bytes_term(0, false, true, true)).force_encoding(\"UTF-8\")\n io.seek(_pos)\n end\n @str_value\n end", "def utf8read(x)\n File.open(x,\"rb\"){|f|\n if f.getbyte!=0xef || f.getbyte!=0xbb || f.getbyte!=0xbf\n f.pos=0 # skip UTF-8 byte order mark\n end\n data=f.read\n ec1=Encoding::Converter.new(\"utf-8\",\"utf-16\",{\n :undef=>:replace,\n :invalid=>:replace\n })\n ec2=Encoding::Converter.new(\"utf-16\",\"utf-8\",{\n :undef=>:replace,\n :invalid=>:replace,\n :replace=>\"\\uFFFD\"\n })\n data=ec1.convert(data)\n data=ec2.convert(data)\n return data\n }\nend", "def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend", "def to_s(off=nil)\n @rendered_offset = off || 0\n\n min = resolve(@min)\n max = resolve(@max)\n uni = resolve(@unicode)\n val = (resolve(@value) || \"\").to_s\n val = val.clone # gross!\n pad = resolve(@padding)\n nul = resolve(@nul_terminated)\n pto = resolve(@pad_to)\n\n val << \"\\x00\" if nul and val[-1] != 0\n\n val = val.to_utf16 if uni\n\n while min and val.size < min\n val << pad\n end\n\n if pto\n while ((val.size % pto) != 0) # this is some shameful shit right here\n val << pad\n end\n end\n\n val = val[0...max] if max\n\n if off\n return val, off + val.size\n else\n return val\n end\n end", "def hex2string(str)\n i = 0; res = \"\"\n while i < str.length do\n res.concat(str.slice(i,2).hex.chr)\n i+=2\n end\n res\n end", "def to_s\n @int.chr(Encoding::UTF_8)\n end", "def toUtf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\nend", "def to_utf8!; replace(to_utf8); end", "def write_utf16le_string(*args)\n # Check for a cell reference in A1 notation and substitute row and column\n if args[0] =~ /^\\D/\n args = substitute_cellref(*args)\n end\n\n return -1 if (args.size < 3) # Check the number of args\n\n record = 0x00FD # Record identifier\n length = 0x000A # Bytes to follow\n\n row = args[0] # Zero indexed row\n col = args[1] # Zero indexed column\n str = args[2]\n format = args[3] # The cell format\n\n # Change from UTF16 big-endian to little endian\n str = str.unpack('n*').pack(\"v*\")\n\n return write_utf16be_string(row, col, str, format)\n end", "def translate_data(data)\n if data[0..3] == \"\\x4c\\x6f\\xa7\\x94\"\n # EBCDIC\n data = _ebcdic_to_ascii(data)\n elsif data[0..3] == \"\\x00\\x3c\\x00\\x3f\"\n # UTF-16BE\n data = uconvert(data, 'utf-16be', 'utf-8')\n elsif data.size >= 4 and data[0..1] == \"\\xfe\\xff\" and data[2..3] != \"\\x00\\x00\"\n # UTF-16BE with BOM\n data = uconvert(data[2..-1], 'utf-16be', 'utf-8')\n elsif data[0..3] == \"\\x3c\\x00\\x3f\\x00\"\n # UTF-16LE\n data = uconvert(data, 'utf-16le', 'utf-8')\n elsif data.size >=4 and data[0..1] == \"\\xff\\xfe\" and data[2..3] != \"\\x00\\x00\"\n # UTF-16LE with BOM\n data = uconvert(data[2..-1], 'utf-16le', 'utf-8')\n elsif data[0..3] == \"\\x00\\x00\\x00\\x3c\"\n # UTF-32BE\n data = uconvert(data, 'utf-32be', 'utf-8')\n elsif data[0..3] == \"\\x3c\\x00\\x00\\x00\"\n # UTF-32LE\n data = uconvert(data, 'utf-32le', 'utf-8')\n elsif data[0..3] == \"\\x00\\x00\\xfe\\xff\"\n # UTF-32BE with BOM\n data = uconvert(data[4..-1], 'utf-32BE', 'utf-8')\n elsif data[0..3] == \"\\xff\\xfe\\x00\\x00\"\n # UTF-32LE with BOM\n data = uconvert(data[4..-1], 'utf-32LE', 'utf-8')\n elsif data[0..2] == \"\\xef\\xbb\\xbf\"\n # UTF-8 with BOM\n data = data[3..-1]\n else\n # ASCII-compatible\n end\n return data\nend", "def iconv_utf8(s)\n Iconv.new('UTF-8//IGNORE', 'US-ASCII').iconv(s + ' ')[0..-2]\n end", "def unescape_stringify(str)\n chars = {\n 'a' => \"\\x07\", 'b' => \"\\x08\", 't' => \"\\x09\", 'n' => \"\\x0a\", 'v' => \"\\x0b\", 'f' => \"\\x0c\",\n 'r' => \"\\x0d\", 'e' => \"\\x1b\", \"\\\\\\\\\" => \"\\x5c\", \"\\\"\" => \"\\x22\", \"'\" => \"\\x27\"\n }\n # Escape all the things\n str.gsub(/\\\\(?:([#{chars.keys.join}])|u([\\da-fA-F]{4}))|\\\\0?x([\\da-fA-F]{2})/) {\n if $1\n if $1 == '\\\\'\n then '\\\\'\n else\n chars[$1]\n end\n elsif $2\n [\"#$2\".hex].pack('U*')\n elsif $3\n [$3].pack('H2')\n end\n }\n end", "def new_string_offset\n last_string_index = @data[last_string_index_offset, 4].unpack1('V')\n offset = @offset + @string_start + last_string_index\n\n u16len, o16 = ResStringPool.utf16_len(@data[offset, 4])\n # To insert a new string at the end of the string section, we need to start at the current\n # last string entry, and add o16 (number of length bytes), u16len * 2(number of string bytes),\n # and 2 bytes for the terminating null-bytes.\n offset + o16 + u16len * 2 + 2\n end", "def toutf8; Kconv.toutf8(self) end", "def to_utf8(v)\n return v unless v.is_a?(String)\n return v if (enc = v.encoding) == (utf = Encoding::UTF_8)\n Encoding::Converter.new(enc, utf).convert(v) rescue v.dup.force_encoding(utf)\nend", "def transcode(str)\n str.force_encoding('UTF-8')\nend", "def cstr\n raise EOFError if @io.eof?\n\n @io.each_byte.take_while(&:nonzero?).pack('C*')\n end", "def unescape(str, escaped = @regexp[:ESCAPED])\n str.gsub(escaped) { [$&[1, 2].hex].pack('C') }.force_encoding(str.encoding)\n end", "def _db_zero_terminated(io)\n string = String.new\n while (char = io.read(2)) != \"\\x00\\x00\".encode(Encoding::ASCII_8BIT)\n string << char\n end\n Unxls::Biff8::Structure._encode_string(string)\n end", "def to_utf8(s)\n return force_encoding(s.gsub(/&(.*?)-/n) {\n if $1.empty?\n \"&\"\n else\n base64 = $1.tr(\",\", \"/\")\n x = base64.length % 4\n if x > 0\n base64.concat(\"=\" * (4 - x))\n end\n base64.unpack(\"m\")[0].unpack(\"n*\").pack(\"U*\")\n end\n }, \"UTF-8\")\n end", "def string\n Util.from_bytes :string, value\n end", "def cstr\n r = @data.unpack(\"@#{pos}Z*\")[0]\n @pos += r.bytesize + 1\n r\n end", "def force_utf32; end", "def force_utf32; end", "def force_utf32; end", "def binary_string; end", "def _utf8(str)\n return str.force_encoding(Encoding::UTF_8)\nend", "def to_utf8(str)\n str = str.force_encoding(ENCODING)\n return str if str.valid_encoding?\n str.encode(ENCODING, 'binary', invalid: :replace, undef: :replace,\n replace: '')\n end", "def quote_binary(v)\n X_AND_SINGLE_QUOTE + v.unpack(\"H*\")[0] + SINGLE_QUOTE\n end", "def quote_binary(v)\n X_AND_SINGLE_QUOTE + v.unpack(\"H*\")[0] + SINGLE_QUOTE\n end", "def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end", "def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end", "def makestr(f, strptr)\n f.seek(strptr)\n str = \"\"\n b = f.read(1)\n if b != 0\n str = str + b\n end\n while b != \"\\000\"\n b = f.read(1)\n if b != \"\\000\"\n str = str + b\n end\n end\n return str\n end", "def quote_binary(v)\n X_AND_SINGLE_QUOTE + v.unpack(\"H*\")[0] + SINGLE_QUOTE\n end", "def utf8_safe\n encode('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')\n end", "def unicode_text(pdf, str, options={})\n pdf.text(e(\"\\xfe\\xff#{str}\", :encoding => 'UTF-16BE'), options) # start Unicode UTF-16BE encoding\n end", "def str_to_uni_z(str)\n\t\t\t\t\t\t\tenc = str.unpack(\"C*\").pack(\"v*\")\n\t\t\t\t\t\t\tenc += \"\\x00\\x00\"\n\t\t\t\t\t\t\treturn enc\n\t\t\t\t\t\tend", "def to_utf8(str)\n str = str.force_encoding('UTF-8')\n return str if str.valid_encoding?\n str.encode(\"UTF-8\", 'binary', invalid: :replace, undef: :replace, replace: '')\n end", "def force_twilio_ucs2_encoding(message)\n punctuation_space = \"\\u{2008}\"\n \"#{message}#{punctuation_space}\"\n end", "def singleq2utf\n self.gsub(\"'\", '%EF%BC%87')\n end", "def get_windows_1252_of(character)\n begin\n \"0\" + character.encode('Windows-1252').unpack('H*').first.to_i(16).to_s\n rescue Encoding::InvalidByteSequenceError, Encoding::UndefinedConversionError\n \"\"\n end\nend", "def fix_utf8\n str = force_encoding(\"UTF-8\")\n return str if str.valid_encoding?\n\n str.encode(\"UTF-8\", \"binary\",\n invalid: :replace, undef: :replace, replace: \"\")\n end", "def orig_text\n orig_data[4..orig_data.size-1].tr(\"\\x00\", '')\n end", "def prepare_source_string data\n return [] if data.nil_or_empty?\n if (leading_2_bytes = (leading_bytes = data.unpack 'C3').slice 0, 2) == BOM_BYTES_UTF_16LE\n data = (data.byteslice 2, data.bytesize).encode UTF_8, ::Encoding::UTF_16LE\n elsif leading_2_bytes == BOM_BYTES_UTF_16BE\n data = (data.byteslice 2, data.bytesize).encode UTF_8, ::Encoding::UTF_16BE\n elsif leading_bytes == BOM_BYTES_UTF_8\n data = data.byteslice 3, data.bytesize\n data = data.encode UTF_8 unless data.encoding == UTF_8\n elsif data.encoding != UTF_8\n data = data.encode UTF_8\n end\n [].tap {|lines| data.each_line {|line| lines << line.rstrip } }\n end", "def xlunicodestringnocch(io, cch)\n flags = io.read(1).unpack('C').first\n _read_unicodestring(io, cch, flags)\n end", "def iconv() end", "def transcode_to_utf8(s)\n unless s.nil?\n s.encode(Encoding::UTF_8, :invalid => :replace, :undef => :replace)\n end\n end", "def string(str)\n TYPE_STRING +\n word(str.length) +\n str.encode!(\"ASCII\")\n end", "def bin_to_hex(s)\r\n s.each_byte.map { |b| b.to_s(16) }.join\r\n #puts s.bin_to_hex\r\nend", "def fix_utf8(s=nil)\n s=self if s.nil? #if we are included\n if String.method_defined?(:scrub)\n #Ruby 2.1\n #cf http://ruby-doc.org/core-2.1.0/String.html#method-i-scrub\n return s.scrub {|bytes| '<'+bytes.unpack('H*')[0]+'>' }\n else\n return DR::Encoding.to_utf8(s)\n end\n end" ]
[ "0.77126575", "0.7271607", "0.7269446", "0.7199437", "0.7115227", "0.6987118", "0.69070077", "0.68631154", "0.662868", "0.6573966", "0.6479391", "0.62668204", "0.6221663", "0.62088335", "0.62075686", "0.6115668", "0.6109874", "0.6107324", "0.60561806", "0.605347", "0.6009152", "0.599896", "0.59898895", "0.5981073", "0.5981073", "0.5955167", "0.59322375", "0.5897458", "0.5889066", "0.58606446", "0.5818135", "0.5753881", "0.5750236", "0.5747801", "0.5720396", "0.5717882", "0.57165015", "0.5690828", "0.56826603", "0.5678382", "0.56648844", "0.56601346", "0.56582826", "0.56414586", "0.5639038", "0.5616459", "0.56045675", "0.55945975", "0.55945975", "0.55945975", "0.55876684", "0.55651814", "0.55444694", "0.55273837", "0.5520461", "0.55171293", "0.5505484", "0.55009073", "0.5499941", "0.54957616", "0.5462395", "0.54505634", "0.54501003", "0.54462063", "0.54441637", "0.54435647", "0.5436317", "0.543567", "0.5430025", "0.5427698", "0.54240566", "0.54186094", "0.54136175", "0.54136175", "0.54136175", "0.53898245", "0.53588974", "0.53588724", "0.5355737", "0.5355737", "0.5351241", "0.5351241", "0.5349978", "0.534881", "0.53382677", "0.53280675", "0.53270185", "0.5321914", "0.5315352", "0.53101456", "0.5308124", "0.5303917", "0.5294261", "0.529112", "0.5285852", "0.52851456", "0.5283832", "0.5270471", "0.5270072", "0.5268182" ]
0.6867994
7
parses a number param and returns the value raises an exception if the param cannot be converted to a number examples: nil => 0 3 => 3 "MB_OK" => 0 "SOME_CONSTANT | OTHER_CONSTANT" => 17 "tuna" => !!!!!!!!!!Exception Parameter "consts_mgr" is a ConstantManager
def param_to_number(v, consts_mgr = @consts_mgr) if v.class == NilClass then return 0 elsif v.kind_of? Integer then return v # ok, it's already a number elsif v.kind_of? String then dw = consts_mgr.parse(v) # might raise an exception if dw != nil return dw else raise ArgumentError, "Param #{v} (class #{v.class}) cannot be converted to a number. It's a string but matches no constants I know." end else raise "Param #{v} (class #{v.class}) should be a number but isn't" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_numeric_constant\n if peek?(:LIT_INT)\n ExprInt.new(expect(:LIT_INT))\n else\n ExprFloat.new(expect(:LIT_FLOAT))\n end\n end", "def parseNumber _args\n \"parseNumber _args;\" \n end", "def number\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 1 )\n value = nil\n __DEC_NUMBER1__ = nil\n __HEX_NUMBER2__ = nil\n\n begin\n # at line 22:2: ( DEC_NUMBER | HEX_NUMBER )\n alt_1 = 2\n look_1_0 = @input.peek( 1 )\n\n if ( look_1_0 == DEC_NUMBER )\n alt_1 = 1\n elsif ( look_1_0 == HEX_NUMBER )\n alt_1 = 2\n else\n raise NoViableAlternative( \"\", 1, 0 )\n end\n case alt_1\n when 1\n # at line 22:4: DEC_NUMBER\n __DEC_NUMBER1__ = match( DEC_NUMBER, TOKENS_FOLLOWING_DEC_NUMBER_IN_number_180 )\n # --> action\n value = __DEC_NUMBER1__.text.to_i \n # <-- action\n\n when 2\n # at line 23:4: HEX_NUMBER\n __HEX_NUMBER2__ = match( HEX_NUMBER, TOKENS_FOLLOWING_HEX_NUMBER_IN_number_187 )\n # --> action\n value = __HEX_NUMBER2__.text[2..-1].to_i(16) \n # <-- action\n\n end\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__, 1 )\n\n end\n \n return value\n end", "def string_catch(num)\n if num == \"\"\n return 0\n elsif\n num.to_i == 0 && num != \"0\"\n abort(\"That's not a number\")\n else\n return num.to_i\n end\nend", "def parse(*args)\n Integer(*params[:args]) rescue nil\nend", "def get_num\n value = \"\"\n\n return expected(\"Integer\") unless is_digit($lookahead)\n\n while is_digit($lookahead)\n value << $lookahead\n lookahead\n end\n\n skip_white\n\n value\nend", "def parse_number\n self.lex_state = :expr_end\n\n case\n when src.scan(/[+-]?0[xXbBdD]\\b/) then\n rb_compile_error \"Invalid numeric format\"\n when src.scan(/[+-]?(?:(?:[1-9][\\d_]*|0)(?!\\.\\d)\\b|0[Dd][0-9_]+)/) then\n int_with_base(10)\n when src.scan(/[+-]?0x[a-f0-9_]+/i) then\n int_with_base(16)\n when src.scan(/[+-]?0[Bb][01_]+/) then\n int_with_base(2)\n when src.scan(/[+-]?0[Oo]?[0-7_]*[89]/) then\n rb_compile_error \"Illegal octal digit.\"\n when src.scan(/[+-]?0[Oo]?[0-7_]+|0[Oo]/) then\n int_with_base(8)\n when src.scan(/[+-]?[\\d_]+_(e|\\.)/) then\n rb_compile_error \"Trailing '_' in number.\"\n when src.scan(/[+-]?[\\d_]+\\.[\\d_]+(e[+-]?[\\d_]+)?\\b|[+-]?[\\d_]+e[+-]?[\\d_]+\\b/i) then\n number = src.matched\n if number =~ /__/ then\n rb_compile_error \"Invalid numeric format\"\n end\n self.yacc_value = number.to_f\n :tFLOAT\n when src.scan(/[+-]?[0-9_]+(?![e])/) then\n int_with_base(10)\n else\n rb_compile_error \"Bad number format\"\n end\n end", "def get_num\n la = $lookahead\n\n return expected(\"Integer\") unless is_digit(la)\n\n lookahead\n\n la\nend", "def to_number_or_nil(value)\n # case/when copied from Puppet::Parser::Scope::number?\n case value\n when /^-?\\d+(:?\\.\\d+|(:?\\.\\d+)?e\\d+)$/\n value.to_f\n when /^0x[0-9a-f]+$/i\n value.to_i(16)\n when /^0[0-7]+$/\n value.to_i(8)\n when /^-?\\d+$/\n value.to_i\n else\n nil\n end\n end", "def getNumber _args\n \"getNumber _args;\" \n end", "def ensure_number(wannabe_number)\n\n wannabe_number or raise(NilEvaluationError)\n\n if wannabe_number.is_a?(String)\n get_value_from_variable(wannabe_number)\n\n elsif wannabe_number.respond_to?(:number)\n wannabe_number.number\n\n else\n wannabe_number\n end\n end", "def to_int(string)\n Integer(string)\nrescue ArgumentError\n nil\nend", "def default_num_value from_string, to_f = false\n if from_string == nil\n return nil\n end\n\n num = to_f ? from_string.to_f : from_string.to_i\n return num == -1? nil : num\nend", "def default_num_value from_string, to_f = false\n if from_string == nil\n return nil\n end\n\n num = to_f ? from_string.to_f : from_string.to_i\n return num == -1? nil : num\nend", "def convert_string_to_number(str); end", "def get_num\n value = 0\n\n return expected(\"Integer\") unless is_digit($lookahead)\n\n while is_digit($lookahead)\n value = 10 * value + $lookahead.to_i\n lookahead\n end\n\n value\nend", "def string_to_int(param, default = 0)\n param.nil? ? default : Integer(param)\n end", "def consume_number\n repr = ''\n type = :integer\n\n repr << @s.consume if @s.peek =~ RE_NUMBER_SIGN\n repr << (@s.scan(RE_DIGIT) || '')\n\n if match = @s.scan(RE_NUMBER_DECIMAL)\n repr << match\n type = :number\n end\n\n if match = @s.scan(RE_NUMBER_EXPONENT)\n repr << match\n type = :number\n end\n\n [repr, convert_string_to_number(repr), type]\n end", "def consume_number\n repr = String.new\n type = :integer\n\n repr << @s.consume if @s.peek =~ RE_NUMBER_SIGN\n repr << (@s.scan(RE_DIGIT) || '')\n\n if match = @s.scan(RE_NUMBER_DECIMAL)\n repr << match\n type = :number\n end\n\n if match = @s.scan(RE_NUMBER_EXPONENT)\n repr << match\n type = :number\n end\n\n [repr, convert_string_to_number(repr), type]\n end", "def check_num_str(m)\n if m.to_i == 0\n m.to_s\n else\n m.to_i\n end\n end", "def my_parse_int(string)\n string.respond_to?(:to_i) ? string.to_i : \"NaN\"\nend", "def getParamValue(param_type, intcode, index)\n if param_type == 0\n return intcode[intcode[index]]\n elsif param_type == 1\n return intcode[index]\n else\n raise \"Uh oh...bad param_type\"\n end\nend", "def parse_number(num)\n if num.is_float?\n num.to_f\n else\n num.to_i\n end\n end", "def parse_value value\r\n case value\r\n when /\\d+/\r\n value.to_f\r\n else\r\n value\r\n end\r\n end", "def int_value(param)\n return \"$#{param.to_s}\"\nend", "def check_numeric_value(field, params, default_value = nil)\n @properties[field] = params[field].present? ? params[field].to_i : default_value\n end", "def str_to_number(s)\r\n\t\tval_str = s.to_s()\r\n\t\tif INT_REGEX.match(val_str)\r\n\t\t\treturn val_str.to_i()\r\n\t\telsif FLOAT_REGEX.match(val_str)\r\n\t\t\treturn val_str.to_f()\r\n\t\telse\r\n\t\t\traise ArgumentError, \"can't understand numeric format '#{s}'\"\r\n\t\tend\r\n\tend", "def consume_numeric; end", "def parse_number(string)\n if string.include? \".\"\n string.to_f\n elsif string.include? \"E\"\n Complex(string).to_f\n else\n string.to_i\n end\n end", "def collect_number(mat)\n is_f = mat.include? '.'\n\n # Throw a fit if there's more than one decimal point\n fail \"Invalid number encountered: #{str}\" if mat =~ /.*\\..*\\./\n\n is_f ? Token.new(:float, mat.to_f) : Token.new(:integer, mat.to_i)\n end", "def funcion_que_recibe_un_numero numero\n if numero.is_a? Numeric\n puts 'es un numero!'\n else\n # Esta linea genera una excepción de la clase ArgumentError con el contenido 'NO ES UN NUMERO!'\n raise ArgumentError, 'NO ES UN NÚMERO!'\n end\nend", "def _reduce_21(val, _values, result)\n n = val[0]; result = n.count('.') > 0 ? n.to_f : n.to_i \n result\nend", "def const(n1)\n # Raise error if the input is not an integer\n if not(n1.is_a?(Integer))\n raise \"can only calculate int\"\n else\n @number = n1\n return self\n end\n end", "def must_be_number(val, name)\n if !val.respond_to?(:to_f)\n raise(ArgumentError, \"#{name} must be a number\")\n end\n end", "def get_int_noerr(arg)\n b = @frame ? @frame.binding : nil\n val = Integer(eval(arg, b))\n rescue SyntaxError\n nil\n rescue \n nil\n end", "def numerify(number_string, leading_zero: T.unsafe(nil)); end", "def cast_to_num(str)\n Integer(str)\n rescue ArgumentError\n Float(str)\n rescue ArgumentError\n nil\n end", "def try_a_number(v)\n ((float = Float(v)) && (float % 1.0 == 0) ? float.to_i : float) rescue v\n end", "def parse(v)\n ((float = Float(v)) && (float % 1.0 == 0) ? float.to_i : float) rescue v\nend", "def convert_number_string_to_integer(number_string)\n Integer(number_string.gsub(\" \", \"\"))\nend", "def consume_numeric\n number = consume_number\n repr = number[0]\n value = number[1]\n type = number[2]\n\n if type == :integer\n value = value.to_i\n else\n value = value.to_f\n end\n\n if start_identifier?(@s.peek(3))\n create_token(:dimension,\n :repr => repr,\n :type => type,\n :unit => consume_name,\n :value => value)\n\n elsif @s.peek == '%'\n @s.consume\n\n create_token(:percentage,\n :repr => repr,\n :type => type,\n :value => value)\n\n else\n create_token(:number,\n :repr => repr,\n :type => type,\n :value => value)\n end\n end", "def number!\r\n # -> uncomment the next line to manually enable rule tracing\r\n # trace_in( __method__, 2 )\r\n\r\n type = NUMBER\r\n channel = ANTLR3::DEFAULT_CHANNEL\r\n\r\n \r\n # - - - - main rule block - - - -\r\n # at line 11:10: ( '0' .. '9' )+\r\n # at file 11:10: ( '0' .. '9' )+\r\n match_count_1 = 0\r\n while true\r\n alt_1 = 2\r\n look_1_0 = @input.peek( 1 )\r\n\r\n if ( look_1_0.between?( 0x30, 0x39 ) )\r\n alt_1 = 1\r\n\r\n end\r\n case alt_1\r\n when 1\r\n # at line 11:11: '0' .. '9'\r\n match_range( 0x30, 0x39 )\r\n\r\n else\r\n match_count_1 > 0 and break\r\n eee = EarlyExit(1)\r\n\r\n\r\n raise eee\r\n end\r\n match_count_1 += 1\r\n end\r\n\r\n\r\n \r\n @state.type = type\r\n @state.channel = channel\r\n\r\n ensure\r\n # -> uncomment the next line to manually enable rule tracing\r\n # trace_out( __method__, 2 )\r\n\r\n end", "def number_check(num)\n begin\n num = gets.chomp\n if num.include?(\".\")\n return num = Float(num)\n else\n return num = Integer(num)\n end\n rescue\n puts \"Please enter a number\"\n retry\n end\nend", "def get_int_value (value_string, current_total)\n case value_string\n # reg exp for 2-10, better way to do this? \n when /[2-9]|[1][0]/ \n value = value_string.to_i \n # face cards\n when /[JQK]/\n value = 10\n # aces\n when \"A\"\n if current_total + 11 <= 21\n value = 11\n else\n value = 1\n end\n end\n value\nend", "def float_or_interger(str)\n if str.include?\".\"\n num =str.to_f\n else\n num = str.to_i\n end\n return num\nend", "def number_or_nil(string)\n\t Integer(string)\n\t\trescue ArgumentError\n\t \tnil\n\tend", "def check_number( num )\n if num.to_f != 0 || [\"0\", \"0.0\"].include?(num)\n is_float = false\n if num.include? \".\"\n is_float = true\n end\n if is_float\n as_number = num.to_f\n else\n as_number = num.to_i\n end\n return {number_ok: true, as_number: as_number}\n else\n return {number_ok: false}\n end\nend", "def read_number(token)\n current = @marker.character\n is_float = current == ?.\n is_exponent = false\n token.kind = is_float ? :float_lit : :integer_lit\n\n while (current = peek_next())\n case current\n # Float lit\n when ?.\n break if is_float == true\n is_float = true\n token.kind = :float_lit\n read_next()\n\n # Digit\n when ?0, ?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9\n read_next()\n\n # Exponent\n when ?e, ?E\n if is_exponent\n token.kind = :invalid\n raise_error(:duplicate_exponent,\n \"Malformed number literal: exponent already provided\")\n end\n\n is_exponent = true\n token.kind = is_float ? :float_exp_lit : :integer_exp_lit\n\n read_next()\n current = read_next()\n current = read_next() if current == ?- || current == ?+\n\n if current < ?0 || current > ?9\n raise_error(:malformed_exponent, \"Malformed number literal: exponent expected but not provided\")\n end\n\n else break\n end\n end\n\n token.value = @source[(token.from .. @marker.source_index)]\n end", "def number\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 32 )\n return_value = NumberReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n begin\n # at line 154:12: ( ( DIGIT )* ( '.' ( DIGIT )+ )? )\n # at line 154:12: ( ( DIGIT )* ( '.' ( DIGIT )+ )? )\n # at line 154:14: ( DIGIT )* ( '.' ( DIGIT )+ )?\n # at line 154:14: ( DIGIT )*\n while true # decision 40\n alt_40 = 2\n look_40_0 = @input.peek(1)\n\n if (look_40_0 == DIGIT)\n alt_40 = 1\n\n end\n case alt_40\n when 1\n # at line 154:14: DIGIT\n match(DIGIT, TOKENS_FOLLOWING_DIGIT_IN_number_1205)\n\n else\n break # out of loop for decision 40\n end\n end # loop for decision 40\n # at line 154:21: ( '.' ( DIGIT )+ )?\n alt_42 = 2\n look_42_0 = @input.peek(1)\n\n if (look_42_0 == T__33)\n alt_42 = 1\n end\n case alt_42\n when 1\n # at line 154:23: '.' ( DIGIT )+\n match(T__33, TOKENS_FOLLOWING_T__33_IN_number_1210)\n # at file 154:27: ( DIGIT )+\n match_count_41 = 0\n while true\n alt_41 = 2\n look_41_0 = @input.peek(1)\n\n if (look_41_0 == DIGIT)\n alt_41 = 1\n\n end\n case alt_41\n when 1\n # at line 154:27: DIGIT\n match(DIGIT, TOKENS_FOLLOWING_DIGIT_IN_number_1212)\n\n else\n match_count_41 > 0 and break\n eee = EarlyExit(41)\n\n\n raise eee\n end\n match_count_41 += 1\n end\n\n\n end\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look(-1)\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__, 32 )\n\n end\n\n return return_value\n end", "def get_int_noerr(arg)\n b = @frame ? @frame.binding : nil\n val = Integer(eval(arg, b))\n rescue SyntaxError\n nil\n rescue\n nil\n end", "def string_to_number(s)\n s.to_i\nend", "def string_to_number(s)\n s.to_i\nend", "def number\n @number ||= parse(read)\n end", "def match_integer( val )\n\t\treturn Integer( val ) rescue nil\n\tend", "def handle_int(int, lineno_column)\n Literal.new int.to_i\n end", "def _reduce_34(val, _values, result)\n result = IntegerLiteral.new(val[0].to_i) \n result\nend", "def test_error_number\n tokenizer = Tokenizer.new\n tokenizer.text = \"20.000 0767 431abc\"\n tokenizer.tokenize\n tokens = tokenizer.tokens\n\n assert_equal(\"ErrorToken\", tokens[1].class.name)\n assert_equal(\"ErrorToken\", tokens[2].class.name)\n assert_equal(\"20.0\", tokens.first.val)\n assert_equal(\"00\", tokens[1].val)\n assert_equal(\"0\", tokens[2].val)\n assert_equal(\"431\", tokens[4].val)\n end", "def convert_to_integer(string)\n unless /^-?\\d+$/ =~ string\n raise \"'#{string}' is not an integer.\" #(1)\n end\n string.to_i\nend", "def string_to_number(string)\n string.to_i\nend", "def parseValuedParam(param)\n re = /(?<type>\\w+)([:,](?<value>\\d+))?/\n values = re.match(param)\n if values\n [values[:type], values[:value].to_i]\n else\n [nil, nil]\n end\nend", "def check_type (num)\n # convert to float if validated number contains a decimal\n if num =~ /\\./\n return num = Float(num)\n else\n return num = Integer(num)\n end\nend", "def number_or_string(input) #helper for pick_a_story\n new_input = input.gsub(/[^\\d]/, \"\")\n if new_input.empty?\n input\n else #return a valid number\n new_input.to_i.between?(1,146) ? new_input.to_i : 555\n end\n end", "def validate_positive_number_including_zero(name, value)\n puts \"Error: parameter #{name} must be positive or zero.\" if value < 0\n return value\n end", "def convert_to_integer(value)\n if value == \"0\"\n value = 0\n elsif value.to_i == 0\n # Set to -1 as we are dealing with range 0-255 so -1 will raise error\n value = -1\n else\n value = value.to_i\n end\n return value\nend", "def consume_number; end", "def single_integer_param(param_name, default, description = \"\")\n value = single_param(param_name, description)\n return default if value.nil?\n\n value = parse_positive_integer(value, %(parameter \"#{param_name}\"#{description}))\n return default if value.nil?\n\n value\n end", "def categorize_number(num)\n case num\n when Fixnum then 'fixed number!'\n when Float then 'floating point!'\n end\nend", "def number=(_arg0); end", "def number\n result = ''\n while @current_char and @current_char =~ /[[:digit:]]/\n result << @current_char\n advance\n end\n\n if @current_char == '.'\n result << @current_char\n advance\n while @current_char and @current_char =~ /[[:digit:]]/\n result << @current_char\n advance\n end\n Token.new(:real_const, result.to_f)\n else\n Token.new(:integer_const, result.to_i)\n end\n end", "def convert_string_input_to_integer(str)\n is_string_a_valid_integer?(str) ? str.to_i : nil\nend", "def number_params\n params[:number].to_f\n end", "def param_check_nb(param, value)\n value = (param[:type] == 'int' ? value.to_i : value.to_f)\n if value < param[:min_value] || value > param[:max_value]\n write_output \"the value cannot be < #{param[:min_value]} or > #{param[:max_value]} for #{param[:string]} (#{param[:id]})\"\n return false\n end\n param_exec_value_change(param, value)\n end", "def interpret\r\n return @number.to_i\r\n end", "def validate_param(declared_param, input_param)\n case declared_param[1]\n when :integer\n return input_param.to_i if integer?(input_param)\n when :letter\n return input_param if letter?(input_param)\n end\n raise ArgumentError, \"Param #{declared_param[0]} must be a #{declared_param[1]}\"\n end", "def number\n number = number.to_s\n if number.includes?('.')\n number = number.to_f\n else\n number = number.to_i\n end\nend", "def basic_validate_number(entity_val, validations)\n max = validations[GlobalConstant::CmsConfigurator.max_key]\n return error_result_obj(\"Number cannot be more than #{max}\") if max && entity_val && entity_val.to_i > max\n\n min = validations[GlobalConstant::CmsConfigurator.min_key]\n return error_result_obj(\"Number cannot be less than #{min}\") if min && entity_val && entity_val.to_i < min\n\n basic_validate_includes(entity_val, validations)\n end", "def param_to_dword(v)\n\t\t\t\t\t\t\tif v.class == Fixnum then\n\t\t\t\t\t\t\t\treturn v # ok, it's already a number\n\t\t\t\t\t\t\telsif v.class == Bignum then\n\t\t\t\t\t\t\t\treturn v # ok, it's already a number\n\t\t\t\t\t\t\telsif v.class == String then\n\t\t\t\t\t\t\t\tdw = @win_consts.parse(v) # might raise an exception\n\t\t\t\t\t\t\t\tif dw != nil\n\t\t\t\t\t\t\t\t\treturn dw\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\traise \"Param #{v} (class #{v.class}) cannot be converted to DWORD. It's a string but matches no constants I know.\"\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\traise \"Param #{v} (class #{v.class}) should be a number but isn't\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend", "def initialize(number_or_string)\n if number_or_string.is_a?(Numeric)\n @factor = number_or_string\n else\n @factor = parse(number_or_string)\n @source_string = number_or_string\n end\n end", "def parse_or_nil(value)\n if value.nil? || value.to_i == 0 then nil else value.to_i end\n end", "def validate_positive_number_excluding_zero(name, value)\n puts \"Error: parameter #{name} must be positive and not zero.\" if value <= 0\n return value\n end", "def number\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 29 )\n return_value = NumberReturnValue.new\n\n # $rule.start = the first token seen before matching\n return_value.start = @input.look\n\n begin\n # at line 126:12: ( digits ( DOT digits )? )\n # at line 126:12: ( digits ( DOT digits )? )\n # at line 126:14: digits ( DOT digits )?\n @state.following.push( TOKENS_FOLLOWING_digits_IN_number_1255 )\n digits\n @state.following.pop\n # at line 126:21: ( DOT digits )?\n alt_44 = 2\n look_44_0 = @input.peek( 1 )\n\n if ( look_44_0 == DOT )\n alt_44 = 1\n end\n case alt_44\n when 1\n # at line 126:23: DOT digits\n match( DOT, TOKENS_FOLLOWING_DOT_IN_number_1259 )\n @state.following.push( TOKENS_FOLLOWING_digits_IN_number_1261 )\n digits\n @state.following.pop\n\n end\n\n # - - - - - - - rule clean up - - - - - - - -\n return_value.stop = @input.look( -1 )\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__, 29 )\n\n end\n \n return return_value\n end", "def validate_input\n\t\tif @options[:num].is_a?(Integer) and @options[:num] >= 0 \n\t\t\t@num = @options[:num].to_i.abs \n\n\t\telse\n\t\t\t@num = \"NAN\"\n\n\t\tend\n\tend", "def entero_pelado(num)\n if num.is_a? String\n num.replace(',', '') if num.include? ','\n num = num.to_f if num.include? '.'\n end\n num.to_i\nend", "def single_integer_param(param_name, default, description=\"\")\n value = single_param(param_name, description)\n unless value.nil?\n value = parse_positive_integer(value, %{parameter \"#{param_name}\"#{description}})\n end\n if value.nil?\n return default\n end\n value\n end", "def string_to_number(string)\n string.to_f\nend", "def post_process_integer( val )\n\t\t\treturn Integer( val.to_s )\n\t\tend", "def on_numeric(n)\n n\n end", "def on_numeric(n)\n n\n end", "def integer_parsers\n @integer = action(seq(1..9, rep0(0..9))) do |ast|\n ast.flatten.join('').to_i\n end\n end", "def to_number(exception = nil)\n res = super(context,self,exception)\n return res\n end", "def call\n clean_value = remove_commas\n PURE_NUMERIC_REGEX.match?(clean_value) ? clean_value : @original_value\n end", "def isNumber(text)\r\n @@log.debug(\"XmlRuleVisitor::isNumber\")\r\n @@log.debug(text.inspect)\r\n\r\n if (nil != text.index('.'))\r\n num = text.to_f\r\n if (num.to_s == text)\r\n @@log.debug(\"isNumber: float: #{num.to_s}\")\r\n return num\r\n end # if num\r\n end # if nil\r\n\r\n num = text.to_i\r\n if (num.to_s == text)\r\n @@log.debug(\"isNumber: int: #{num.to_s}\")\r\n return num\r\n end # if num\r\n\r\n return nil\r\n\r\n end", "def my_parse_int(string)\n noSpaceString = string.gsub /\\s/, ''\n if noSpaceString =~ /\\D/\n return \"NaN\"\n else\n if string.split(\" \").length > 1\n return \"NaN\"\n else\n return string.to_i\n end\n end\nend", "def assert_numeric(value, pos)\n if value =~ /^0[xX]/\n lex_error(Issues::INVALID_HEX_NUMBER, {:value => value}, pos) unless value =~ /^0[xX][0-9A-Fa-f]+$/\n\n elsif value =~ /^0[^.]/\n lex_error(Issues::INVALID_OCTAL_NUMBER, {:value => value}, pos) unless value =~ /^0[0-7]+$/\n\n elsif value =~ /^\\d+[eE.]/\n lex_error(Issues::INVALID_DECIMAL_NUMBER, {:value => value}, pos) unless value =~ /^\\d+(?:\\.\\d+)?(?:[eE]-?\\d+)?$/\n\n else\n lex_error(Issues::ILLEGAL_NUMBER, {:value => value}, pos) unless value =~ /^\\d+$/\n end\n end", "def number!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 99 )\n\n type = NUMBER\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 908:3: ( ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+ )? | ( '.' )? ( '0' .. '9' )+ ( ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+ )? | '0' ( 'x' | 'X' ) ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+ )\n alt_28 = 3\n alt_28 = @dfa28.predict( @input )\n case alt_28\n when 1\n # at line 908:5: ( '0' .. '9' )+ '.' ( '0' .. '9' )* ( ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+ )?\n # at file 908:5: ( '0' .. '9' )+\n match_count_17 = 0\n while true\n alt_17 = 2\n look_17_0 = @input.peek( 1 )\n\n if ( look_17_0.between?( 0x30, 0x39 ) )\n alt_17 = 1\n\n end\n case alt_17\n when 1\n # at line 908:6: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n match_count_17 > 0 and break\n eee = EarlyExit(17)\n\n\n raise eee\n end\n match_count_17 += 1\n end\n\n match( 0x2e )\n # at line 908:21: ( '0' .. '9' )*\n while true # decision 18\n alt_18 = 2\n look_18_0 = @input.peek( 1 )\n\n if ( look_18_0.between?( 0x30, 0x39 ) )\n alt_18 = 1\n\n end\n case alt_18\n when 1\n # at line 908:22: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n break # out of loop for decision 18\n end\n end # loop for decision 18\n # at line 908:33: ( ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+ )?\n alt_21 = 2\n look_21_0 = @input.peek( 1 )\n\n if ( look_21_0 == 0x45 || look_21_0 == 0x65 )\n alt_21 = 1\n end\n case alt_21\n when 1\n # at line 908:35: ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+\n if @input.peek(1) == 0x45 || @input.peek(1) == 0x65\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n # at line 908:47: ( '+' | '-' )?\n alt_19 = 2\n look_19_0 = @input.peek( 1 )\n\n if ( look_19_0 == 0x2b || look_19_0 == 0x2d )\n alt_19 = 1\n end\n case alt_19\n when 1\n # at line \n if @input.peek(1) == 0x2b || @input.peek(1) == 0x2d\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n\n end\n # at file 908:60: ( '0' .. '9' )+\n match_count_20 = 0\n while true\n alt_20 = 2\n look_20_0 = @input.peek( 1 )\n\n if ( look_20_0.between?( 0x30, 0x39 ) )\n alt_20 = 1\n\n end\n case alt_20\n when 1\n # at line 908:61: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n match_count_20 > 0 and break\n eee = EarlyExit(20)\n\n\n raise eee\n end\n match_count_20 += 1\n end\n\n\n end\n\n when 2\n # at line 909:5: ( '.' )? ( '0' .. '9' )+ ( ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+ )?\n # at line 909:5: ( '.' )?\n alt_22 = 2\n look_22_0 = @input.peek( 1 )\n\n if ( look_22_0 == 0x2e )\n alt_22 = 1\n end\n case alt_22\n when 1\n # at line 909:5: '.'\n match( 0x2e )\n\n end\n # at file 909:10: ( '0' .. '9' )+\n match_count_23 = 0\n while true\n alt_23 = 2\n look_23_0 = @input.peek( 1 )\n\n if ( look_23_0.between?( 0x30, 0x39 ) )\n alt_23 = 1\n\n end\n case alt_23\n when 1\n # at line 909:11: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n match_count_23 > 0 and break\n eee = EarlyExit(23)\n\n\n raise eee\n end\n match_count_23 += 1\n end\n\n # at line 909:22: ( ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+ )?\n alt_26 = 2\n look_26_0 = @input.peek( 1 )\n\n if ( look_26_0 == 0x45 || look_26_0 == 0x65 )\n alt_26 = 1\n end\n case alt_26\n when 1\n # at line 909:24: ( 'e' | 'E' ) ( '+' | '-' )? ( '0' .. '9' )+\n if @input.peek(1) == 0x45 || @input.peek(1) == 0x65\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n # at line 909:36: ( '+' | '-' )?\n alt_24 = 2\n look_24_0 = @input.peek( 1 )\n\n if ( look_24_0 == 0x2b || look_24_0 == 0x2d )\n alt_24 = 1\n end\n case alt_24\n when 1\n # at line \n if @input.peek(1) == 0x2b || @input.peek(1) == 0x2d\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n\n end\n # at file 909:49: ( '0' .. '9' )+\n match_count_25 = 0\n while true\n alt_25 = 2\n look_25_0 = @input.peek( 1 )\n\n if ( look_25_0.between?( 0x30, 0x39 ) )\n alt_25 = 1\n\n end\n case alt_25\n when 1\n # at line 909:50: '0' .. '9'\n match_range( 0x30, 0x39 )\n\n else\n match_count_25 > 0 and break\n eee = EarlyExit(25)\n\n\n raise eee\n end\n match_count_25 += 1\n end\n\n\n end\n\n when 3\n # at line 910:5: '0' ( 'x' | 'X' ) ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+\n match( 0x30 )\n if @input.peek(1) == 0x58 || @input.peek(1) == 0x78\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n # at file 910:21: ( '0' .. '9' | 'a' .. 'f' | 'A' .. 'F' )+\n match_count_27 = 0\n while true\n alt_27 = 2\n look_27_0 = @input.peek( 1 )\n\n if ( look_27_0.between?( 0x30, 0x39 ) || look_27_0.between?( 0x41, 0x46 ) || look_27_0.between?( 0x61, 0x66 ) )\n alt_27 = 1\n\n end\n case alt_27\n when 1\n # at line \n if @input.peek( 1 ).between?( 0x30, 0x39 ) || @input.peek( 1 ).between?( 0x41, 0x46 ) || @input.peek( 1 ).between?( 0x61, 0x66 )\n @input.consume\n else\n mse = MismatchedSet( nil )\n recover mse\n raise mse\n end\n\n\n\n else\n match_count_27 > 0 and break\n eee = EarlyExit(27)\n\n\n raise eee\n end\n match_count_27 += 1\n end\n\n\n end\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__, 99 )\n\n end", "def get_number_in_exception\r\n # Prepare query url.\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/error/numberInException'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n\r\n # Validate response against endpoint and global error codes.\r\n if _context.response.status_code == 444\r\n raise ExceptionWithNumberException.new(\r\n 'number in exception',\r\n _context\r\n )\r\n end\r\n validate_response(_context)\r\n\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body) unless\r\n _context.response.raw_body.nil? ||\r\n _context.response.raw_body.to_s.strip.empty?\r\n decoded\r\n end", "def consume_numeric\n number = consume_number\n\n if start_identifier?\n create_token(:dimension,\n :repr => number[0],\n :type => number[2],\n :unit => consume_name,\n :value => number[1])\n\n elsif @s.peek == '%'\n @s.consume\n\n create_token(:percentage,\n :repr => number[0],\n :type => number[2],\n :value => number[1])\n\n else\n create_token(:number,\n :repr => number[0],\n :type => number[2],\n :value => number[1])\n end\n end", "def to_float_or_int str\n Integer(str) rescue Float(str) rescue nil\n end", "def find_value_given_node_no(node_num)\n value_given_node_no_support(node_num)\n end", "def is_number?(tok)\n #check number format: correct types of digits\n if tok[0] == 36 # $\n return nil if( (tok.sub(\"$\",\"\") =~ /[^A-Fa-f0-9]/) != nil)\n elsif tok[0] == 67 # C\n return nil if ( (tok.sub(\"C\",\"\") =~ /[^0-7]/) != nil)\n elsif tok[0] == 66 # B\n return nil if ( (tok.sub(\"B\",\"\") =~ /[^01]/) != nil) \n elsif tok[0] >= 48 and tok[0] <= 57\n return nil if ( (tok =~ /[^0-9]/) != nil) \n else\n #can raise exceptions here:\n return nil\n end\n \n return get_number_system(tok)\n end" ]
[ "0.62339985", "0.6207843", "0.60914016", "0.60410696", "0.602025", "0.5942447", "0.5900362", "0.58967775", "0.58392525", "0.5786673", "0.5775598", "0.57234186", "0.57106143", "0.57106143", "0.56917995", "0.5656442", "0.5652993", "0.56514347", "0.56455946", "0.5641099", "0.56364733", "0.56343037", "0.56340146", "0.5633602", "0.5628081", "0.56047535", "0.55935466", "0.5518109", "0.5513623", "0.5489046", "0.5465692", "0.546255", "0.5460253", "0.54570895", "0.54550517", "0.5447561", "0.5446371", "0.5440932", "0.54353005", "0.54283977", "0.5424498", "0.54236686", "0.5421375", "0.5421103", "0.5420097", "0.5401124", "0.53954375", "0.53800505", "0.53733724", "0.53679734", "0.53617036", "0.53617036", "0.5359262", "0.5358792", "0.5357393", "0.5329312", "0.532554", "0.5322554", "0.5320191", "0.531912", "0.5318011", "0.53156", "0.5314041", "0.5305037", "0.5295288", "0.52927405", "0.5288727", "0.52852297", "0.5284914", "0.5281591", "0.52700907", "0.52663594", "0.5260755", "0.5257057", "0.52547824", "0.5254003", "0.52507585", "0.5248542", "0.52430457", "0.5240937", "0.524", "0.5228545", "0.5221903", "0.52171886", "0.5213483", "0.52079666", "0.5202815", "0.5202815", "0.5195897", "0.51885426", "0.5188414", "0.51817286", "0.5175509", "0.5155442", "0.5150568", "0.5150381", "0.5146055", "0.5132192", "0.51307386", "0.512718" ]
0.7642137
0
assembles the buffers "in" and "inout"
def assemble_buffer(direction, function, args) layout = {} # paramName => BufferItem blob = "" #puts " building buffer: #{direction}" function.params.each_with_index do |param_desc, param_idx| #puts " processing #{param_desc[0]} #{param_desc[1]} #{param_desc[2]}" # we care only about inout buffers if param_desc[2] == direction buffer = nil # Special case: # The user can choose to supply a Null pointer instead of a buffer # in this case we don't need space in any heap buffer if param_desc[0][0,1] == 'P' # type is a pointer if args[param_idx] == nil next end end case param_desc[0] # required argument type when "PDWORD" dw = param_to_number(args[param_idx]) buffer = [dw].pack('V') when "PWCHAR" raise "param #{param_desc[1]}: string expected" unless args[param_idx].class == String buffer = str_to_uni_z(args[param_idx]) when "PCHAR" raise "param #{param_desc[1]}: string expected" unless args[param_idx].class == String buffer = str_to_ascii_z(args[param_idx]) when "PBLOB" raise "param #{param_desc[1]}: please supply your BLOB as string!" unless args[param_idx].class == String buffer = args[param_idx] # other types (non-pointers) don't reference buffers # and don't need any treatment here end if buffer != nil #puts " adding #{buffer.length} bytes to heap blob" layout[param_desc[1]] = BufferItem.new(param_idx, blob.length, buffer.length, param_desc[0]) blob += buffer # sf: force 8 byte alignment to satisfy x64, wont matter on x86. while( blob.length % 8 != 0 ) blob += "\x00" end #puts " heap blob size now #{blob.length}" end end end #puts " built buffer: #{direction}" return [layout, blob] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def out_buffers; @out_buffers; end", "def receive_out_arguments(*types)\n\n #Create a pointer to each of the requested types.\n pointers = types.map { |type| FFI::MemoryPointer.new(type) }\n\n #Yield each of the pointers to the given block.\n yield(*pointers)\n\n #Read each of the byte-buffers given. \n results = types.zip(pointers).map do |type, pointer|\n\n #If we've been passed a buffer type as a symbol, use the\n #symbol name to figure out the appropriate reading method.\n if type.kind_of?(Symbol)\n\n #Compute the method name by adding \"get_\" to the device type,\n #as the the FFI convention.\n method_name = 'read_' + type.to_s\n\n #And return the contents of the byte buffer.\n next pointer.send(method_name)\n \n #Otherwise, return the data in raw binary. \n else \n next pointer.get_string(0, type)\n end\n\n end\n\n #If we have a single-element array, return the element directly;\n #otherwise, return the array. This format works well with multiple \n #assignment.\n (results.count == 1) ? results.first : results\n\n end", "def gets_buffer(*a)\n @device.buffer\n end", "def assemble_buffer(direction, function, args)\n\t\t\t\t\t\t\tlayout = {} # paramName => BufferItem\n\t\t\t\t\t\t\tblob = \"\"\n\t\t\t\t\t\t\t#puts \" building buffer: #{direction}\"\n\t\t\t\t\t\t\tfunction.params.each_with_index do |param_desc, param_idx|\n\t\t\t\t\t\t\t\t#puts \" processing #{param_desc[0]} #{param_desc[1]} #{param_desc[2]}\"\n\t\t\t\t\t\t\t\t# we care only about inout buffers\n\t\t\t\t\t\t\t\tif param_desc[2] == direction\n\t\t\t\t\t\t\t\t\tbuffer = nil\n\n\t\t\t\t\t\t\t\t\t# Special case:\n\t\t\t\t\t\t\t\t\t# The user can choose to supply a Null pointer instead of a buffer\n\t\t\t\t\t\t\t\t\t# in this case we don't need space in any heap buffer\n\t\t\t\t\t\t\t\t\tif param_desc[0][0,1] == 'P' # type is a pointer\n\t\t\t\t\t\t\t\t\t\tif args[param_idx] == nil\n\t\t\t\t\t\t\t\t\t\t\tnext\n\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t\tcase param_desc[0] # required argument type\n\t\t\t\t\t\t\t\t\t\twhen \"PDWORD\"\n\t\t\t\t\t\t\t\t\t\t\tdw = param_to_dword(args[param_idx])\n\t\t\t\t\t\t\t\t\t\t\tbuffer = [dw].pack('V')\n\t\t\t\t\t\t\t\t\t\twhen \"PWCHAR\"\n\t\t\t\t\t\t\t\t\t\t\traise \"param #{param_desc[1]}: string expected\" unless args[param_idx].class == String\n\t\t\t\t\t\t\t\t\t\t\tbuffer = str_to_uni_z(args[param_idx])\n\t\t\t\t\t\t\t\t\t\twhen \"PCHAR\"\n\t\t\t\t\t\t\t\t\t\t\traise \"param #{param_desc[1]}: string expected\" unless args[param_idx].class == String\n\t\t\t\t\t\t\t\t\t\t\tbuffer = str_to_ascii_z(args[param_idx])\n\t\t\t\t\t\t\t\t\t\twhen \"PBLOB\"\n\t\t\t\t\t\t\t\t\t\t\traise \"param #{param_desc[1]}: please supply your BLOB as string!\" unless args[param_idx].class == String\n\t\t\t\t\t\t\t\t\t\t\tbuffer = args[param_idx]\n\t\t\t\t\t\t\t\t\t\t# other types (non-pointers) don't reference buffers\n\t\t\t\t\t\t\t\t\t\t# and don't need any treatment here\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\tif buffer != nil\n\t\t\t\t\t\t\t\t\t\t#puts \" adding #{buffer.length} bytes to heap blob\"\n\t\t\t\t\t\t\t\t\t\tlayout[param_desc[1]] = BufferItem.new(param_idx, blob.length, buffer.length, param_desc[0])\n\t\t\t\t\t\t\t\t\t\tblob += buffer\n\t\t\t\t\t\t\t\t\t\t#puts \" heap blob size now #{blob.length}\"\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t#puts \" built buffer: #{direction}\"\n\t\t\t\t\t\t\treturn [layout, blob]\n\t\t\t\t\t\tend", "def buffer; end", "def buffer; end", "def buffer; end", "def output_buffer=(_arg0); end", "def output_buffer=(_arg0); end", "def gets_buffer_data(*a)\n @device.buffer.map { |msg| msg[:data] }\n end", "def open_buffer\n @out_buffers ||= []\n @out_buffers.push(@out)\n @out = \"\"\n end", "def binding_buffer(op)\n # @buffer_lookup[op.input(ANTIBODY).sample][BINDING_BUFFER]\n op.input(BINDING_BUFFER).item\n end", "def read_buffer; end", "def with_output_buffer(buf = T.unsafe(nil)); end", "def _buffer( the_binding )\n @_buffer = eval( \"_buf\", the_binding )\n end", "def initialize_buffers\n @eof = false\n @sync = true # FIXME: hax\n @rbuffer = ''.force_encoding(Encoding::ASCII_8BIT)\n @wbuffer = ''.force_encoding(Encoding::ASCII_8BIT)\n end", "def output_buffer; end", "def output_buffer; end", "def gets_buffer_s(*a)\n @device.buffer.map { |msg| msg[:data] = TypeConversion.numeric_byte_array_to_hex_string(msg[:data]); msg }\n end", "def pointer_inputs; end", "def add_args_to_command(cmd, data, has_args, has_info, version)\n if has_info then\n cmd.buffers||= []\n cmd.pid||= false\n cmd.ininterfaces||= []\n cmd.outinterfaces||= []\n cmd.inhandles||= []\n cmd.outhandles||= []\n cmd.inargs||= []\n cmd.outargs||= []\n end\n data.each do |arg|\n type = arg[0]\n info = arg[1]\n if info then\n case info.before\n when \"Buffer\"\n index = SwIPC::parse_int(info.inside[0])\n tx_type = SwIPC::parse_int(info.inside[1])\n size = SwIPC::parse_int(info.inside[2])\n data_type = nil\n \n if type then\n case type.before\n when \"Out\"\n data_type = type.inside[0].to_s\n when \"InArray\"\n data_type = type.inside[0].to_s + \"[]\"\n when \"OutArray\"\n data_type = type.inside[0].to_s + \"[]\"\n when \"InBuffer\"\n data_type = \"bytes\"\n when \"OutBuffer\"\n data_type = \"bytes\"\n else\n data_type = type.to_s\n end\n data_type = cmd.context.get_or_infer_type(data_type)\n data_type.assert_size_on(version, size == 0 ? nil : size)\n end\n cmd.buffers[index] = SwIPC::Buffer.new(data_type, tx_type, size)\n when \"InRaw\" # <size, alignment, position>\n size = SwIPC::parse_int(info.inside[0])\n alignment = SwIPC::parse_int(info.inside[1])\n position = SwIPC::parse_int(info.inside[2])\n data_type = nil\n if type then\n data_type = cmd.context.get_or_infer_type(type.to_s)\n data_type.assert_size_on(version, size)\n data_type.assert_alignment_on(version, alignment)\n end\n cmd.inargs.push(SwIPC::Command::Arg.new(size, alignment, position, data_type))\n cmd.inargs.sort_by! do |a| a.position end\n when \"OutRaw\"\n size = SwIPC::parse_int(info.inside[0])\n alignment = SwIPC::parse_int(info.inside[1])\n position = SwIPC::parse_int(info.inside[2])\n if type then\n if type.before != \"Out\" then\n raise \"invalid OutRaw type\"\n end\n data_type = cmd.context.get_or_infer_type(type.inside[0].to_s)\n data_type.assert_size_on(version, size)\n data_type.assert_alignment_on(version, alignment)\n end\n cmd.outargs.push(SwIPC::Command::Arg.new(size, alignment, position, data_type))\n cmd.outargs.sort_by! do |a| a.position end\n when \"InObject\"\n if_type = nil\n if type then\n if type.before != \"SharedPointer\" then\n raise \"invalid InObject type\"\n end\n if_type = type.inside[0].to_s\n end\n cmd.ininterfaces[SwIPC::parse_int(info.inside[0])]||= if_type\n when \"OutObject\"\n of_type = nil\n if type then\n if type.before != \"Out\" then\n raise \"invalid OutObject type: \" + type.to_s\n end\n if type.inside[0].before != \"SharedPointer\" then\n raise \"invalid OutObject type: \" + type.to_s\n end\n of_type = type.inside[0].inside[0].to_s\n end\n cmd.outinterfaces[SwIPC::parse_int(info.inside[0])]||= of_type\n when \"InHandle\"\n # type is uninteresting\n cmd.inhandles[SwIPC::parse_int(info.inside[0])] = SwIPC::parse_int(info.inside[1])\n when \"OutHandle\"\n # type is uninteresting\n cmd.outhandles[SwIPC::parse_int(info.inside[0])] = SwIPC::parse_int(info.inside[1])\n else\n raise \"invalid info type: \" + info.before\n end\n else\n # TODO: infer?\n end\n end\nend", "def get_buffers()\n Rula.log(Logger::DEBUG,\"Getting buffers\",self)\n @buffers\n end", "def source_buffer=(_arg0); end", "def flush_next_in\n\t\t@in_pos = @input_buffer.length\n\t\t@finished = true\n\t\tret = @input_buffer.pack(\"c*\")\n\t\t@input_buffer = []\n\t\tret\n\tend", "def buffers\n @buffers ||= fetch_buffers\n end", "def write_buffer(io = T.unsafe(nil)); end", "def flush_next_in\n\t\t\t@in_pos = @input_buffer.length\n\t\t\t@finished = true\n\t\t\tret = @input_buffer.pack(\"c*\")\n\t\t\t@input_buffer = []\n\t\t\tret\n\t\tend", "def process_function_call(function, args)\n\t\t\t\t\t\t\traise \"#{function.params.length} arguments expected. #{args.length} arguments provided.\" unless args.length == function.params.length\n\t\t\t\t\t\t\t#puts \"process_function_call(function.windows_name,#{PP.pp(args, \"\")})\"\n\n\t\t\t\t\t\t\t# We transmit the immediate stack and three heap-buffers:\n\t\t\t\t\t\t\t# in, inout and out. The reason behind the separation is bandwidth.\n\t\t\t\t\t\t\t# We don't want to transmit uninitialized data in or no-longer-needed data out.\n\n\t\t\t\t\t\t\t# out-only-buffers that are ONLY transmitted on the way BACK\n\t\t\t\t\t\t\tout_only_layout = {} # paramName => BufferItem\n\t\t\t\t\t\t\tout_only_size_bytes = 0\n\t\t\t\t\t\t\t#puts \" assembling out-only buffer\"\n\t\t\t\t\t\t\tfunction.params.each_with_index do |param_desc, param_idx|\n\t\t\t\t\t\t\t\t#puts \" processing #{param_desc[1]}\"\n\n\t\t\t\t\t\t\t\t# Special case:\n\t\t\t\t\t\t\t\t# The user can choose to supply a Null pointer instead of a buffer\n\t\t\t\t\t\t\t\t# in this case we don't need space in any heap buffer\n\t\t\t\t\t\t\t\tif param_desc[0][0,1] == 'P' # type is a pointer\n\t\t\t\t\t\t\t\t\tif args[param_idx] == nil\n\t\t\t\t\t\t\t\t\t\tnext\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t# we care only about out-only buffers\n\t\t\t\t\t\t\t\tif param_desc[2] == \"out\"\n\t\t\t\t\t\t\t\t\traise \"error in param #{param_desc[1]}: Out-only buffers must be described by a number indicating their size in bytes \" unless args[param_idx].class == Fixnum\n\t\t\t\t\t\t\t\t\tbuffer_size = args[param_idx]\n\t\t\t\t\t\t\t\t\tif param_desc[0] == \"PDWORD\"\n\t\t\t\t\t\t\t\t\t\traise \"Please pass 4 for 'out' PDWORDS, since they require a buffer of size 4\" unless buffer_size == 4\n\t\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t\tout_only_layout[param_desc[1]] = BufferItem.new(param_idx, out_only_size_bytes, buffer_size, param_desc[0])\n\t\t\t\t\t\t\t\t\tout_only_size_bytes += buffer_size\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\ttmp = assemble_buffer(\"in\", function, args)\n\t\t\t\t\t\t\tin_only_layout = tmp[0]\n\t\t\t\t\t\t\tin_only_buffer = tmp[1]\n\n\t\t\t\t\t\t\ttmp = assemble_buffer(\"inout\", function, args)\n\t\t\t\t\t\t\tinout_layout = tmp[0]\n\t\t\t\t\t\t\tinout_buffer = tmp[1]\n\n\n\t\t\t\t\t\t\t# now we build the stack\n\t\t\t\t\t\t\t# every stack dword will be described by two dwords:\n\t\t\t\t\t\t\t# first dword describes second dword:\n\t\t\t\t\t\t\t#\t0 - literal,\n\t\t\t\t\t\t\t#\t1 = relative to in-only buffer\n\t\t\t\t\t\t\t#\t2 = relative to out-only buffer\n\t\t\t\t\t\t\t#\t3 = relative to inout buffer\n\n\t\t\t\t\t\t\t# (literal numbers and pointers to buffers we have created)\n\t\t\t\t\t\t\tliteral_pairs_blob = \"\"\n\t\t\t\t\t\t\t#puts \" assembling literal stack\"\n\t\t\t\t\t\t\tfunction.params.each_with_index do |param_desc, param_idx|\n\t\t\t\t\t\t\t\t#puts \" processing (#{param_desc[0]}, #{param_desc[1]}, #{param_desc[2]})\"\n\t\t\t\t\t\t\t\tbuffer = nil\n\t\t\t\t\t\t\t\t# is it a pointer to a buffer on our stack\n\t\t\t\t\t\t\t\tif [\"PDWORD\", \"PWCHAR\", \"PCHAR\", \"PBLOB\"].include? param_desc[0]\n\t\t\t\t\t\t\t\t\t#puts \" pointer\"\n\t\t\t\t\t\t\t\t\tif args[param_idx] == nil # null pointer?\n\t\t\t\t\t\t\t\t\t\tbuffer = [0].pack('V') # type: DWORD (so the dll does not rebase it)\n\t\t\t\t\t\t\t\t\t\tbuffer += [0].pack('V') # value: 0\n\t\t\t\t\t\t\t\t\telsif param_desc[2] == \"in\"\n\t\t\t\t\t\t\t\t\t\tbuffer = [1].pack('V')\n\t\t\t\t\t\t\t\t\t\tbuffer += [in_only_layout[param_desc[1]].addr].pack('V')\n\t\t\t\t\t\t\t\t\telsif param_desc[2] == \"out\"\n\t\t\t\t\t\t\t\t\t\tbuffer = [2].pack('V')\n\t\t\t\t\t\t\t\t\t\tbuffer += [out_only_layout[param_desc[1]].addr].pack('V')\n\t\t\t\t\t\t\t\t\telsif param_desc[2] == \"inout\"\n\t\t\t\t\t\t\t\t\t\tbuffer = [3].pack('V')\n\t\t\t\t\t\t\t\t\t\tbuffer += [inout_layout[param_desc[1]].addr].pack('V')\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\traise \"unexpected direction\"\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t#puts \" not a pointer\"\n\t\t\t\t\t\t\t\t\t# it's not a pointer\n\t\t\t\t\t\t\t\t\tbuffer = [0].pack('V')\n\t\t\t\t\t\t\t\t\tcase param_desc[0]\n\t\t\t\t\t\t\t\t\t\twhen \"DWORD\"\n\t\t\t\t\t\t\t\t\t\t\tdw = param_to_dword(args[param_idx])\n\t\t\t\t\t\t\t\t\t\t\tbuffer += [dw].pack('V')\n\t\t\t\t\t\t\t\t\t\twhen \"WORD\"\n\t\t\t\t\t\t\t\t\t\t\tdw = param_to_dword(args[param_idx])\n\t\t\t\t\t\t\t\t\t\t\tbuffer += [dw % 65536].pack('V')\n\t\t\t\t\t\t\t\t\t\twhen \"BYTE\"\n\t\t\t\t\t\t\t\t\t\t\tdw = param_to_dword(args[param_idx])\n\t\t\t\t\t\t\t\t\t\t\tbuffer += [dw % 256].pack('V')\n\t\t\t\t\t\t\t\t\t\twhen \"BOOL\"\n\t\t\t\t\t\t\t\t\t\t\tcase args[param_idx]\n\t\t\t\t\t\t\t\t\t\t\t\twhen true\n\t\t\t\t\t\t\t\t\t\t\t\t\tbuffer += [1].pack('V')\n\t\t\t\t\t\t\t\t\t\t\t\twhen false\n\t\t\t\t\t\t\t\t\t\t\t\t\tbuffer += [0].pack('V')\n\t\t\t\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\t\t\t\traise \"param #{param_desc[1]}: true or false expected\"\n\t\t\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\t\traise \"unexpected type for param #{param_desc[1]}\"\n\t\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t\t#puts \" adding pair to blob\"\n\t\t\t\t\t\t\t\tliteral_pairs_blob += buffer\n\t\t\t\t\t\t\t\t#puts \" buffer size %X\" % buffer.length\n\t\t\t\t\t\t\t\t#puts \" blob size so far: %X\" % literal_pairs_blob.length\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\t#puts \"\\n\\nsending Stuff to meterpreter\"\n\t\t\t\t\t\t\trequest = Packet.create_request('railgun_api')\n\t\t\t\t\t\t\trequest.add_tlv(TLV_TYPE_RAILGUN_SIZE_OUT, out_only_size_bytes)\n\n\t\t\t\t\t\t\trequest.add_tlv(TLV_TYPE_RAILGUN_STACKBLOB, literal_pairs_blob)\n\t\t\t\t\t\t\trequest.add_tlv(TLV_TYPE_RAILGUN_BUFFERBLOB_IN, in_only_buffer)\n\t\t\t\t\t\t\trequest.add_tlv(TLV_TYPE_RAILGUN_BUFFERBLOB_INOUT, inout_buffer)\n\n\t\t\t\t\t\t\trequest.add_tlv(TLV_TYPE_RAILGUN_DLLNAME, @dll_path )\n\t\t\t\t\t\t\trequest.add_tlv(TLV_TYPE_RAILGUN_FUNCNAME, function.windows_name)\n\n\n\t\t\t\t\t\t\tresponse = @client.send_request(request)\n\n\t\t\t\t\t\t\t#puts \"receiving Stuff from meterpreter\"\n\t\t\t\t\t\t\t#puts \"out_only_layout:\"\n\t\t\t\t\t\t\t#puts out_only_layout\n\n\t\t\t\t\t\t\trec_inout_buffers = response.get_tlv_value(TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_INOUT)\n\t\t\t\t\t\t\trec_out_only_buffers = response.get_tlv_value(TLV_TYPE_RAILGUN_BACK_BUFFERBLOB_OUT)\n\t\t\t\t\t\t\trec_return_value = response.get_tlv_value(TLV_TYPE_RAILGUN_BACK_RET)\n\t\t\t\t\t\t\trec_last_error = response.get_tlv_value(TLV_TYPE_RAILGUN_BACK_ERR)\n\n\t\t\t\t\t\t\t#puts \"received stuff\"\n\t\t\t\t\t\t\t#puts \"out_only_layout:\"\n\t\t\t\t\t\t\t#puts out_only_layout\n\n\t\t\t\t\t\t\t# The hash the function returns\n\t\t\t\t\t\t\treturn_hash={\"GetLastError\" => rec_last_error}\n\n\t\t\t\t\t\t\t#process return value\n\t\t\t\t\t\t\tcase function.return_type\n\t\t\t\t\t\t\t\twhen \"DWORD\"\n\t\t\t\t\t\t\t\t\treturn_hash[\"return\"] = rec_return_value\n\t\t\t\t\t\t\t\twhen \"WORD\"\n\t\t\t\t\t\t\t\t\treturn_hash[\"return\"] = rec_return_value % 65536\n\t\t\t\t\t\t\t\twhen \"BYTE\"\n\t\t\t\t\t\t\t\t\treturn_hash[\"return\"] = rec_return_value % 256\n\t\t\t\t\t\t\t\twhen \"BOOL\"\n\t\t\t\t\t\t\t\t\treturn_hash[\"return\"] = (rec_return_value != 0)\n\t\t\t\t\t\t\t\twhen \"VOID\"\n\t\t\t\t\t\t\t\t\treturn_hash[\"return\"] = nil\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\traise \"unexpected return type: #{function.return_type}\"\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t#puts return_hash\n\t\t\t\t\t\t\t#puts \"out_only_layout:\"\n\t\t\t\t\t\t\t#puts out_only_layout\n\n\n\t\t\t\t\t\t\t# process out-only buffers\n\t\t\t\t\t\t\t#puts \"processing out-only buffers:\"\n\t\t\t\t\t\t\tout_only_layout.each_pair do |param_name, buffer_item|\n\t\t\t\t\t\t\t\t#puts \" #{param_name}\"\n\t\t\t\t\t\t\t\tbuffer = rec_out_only_buffers[buffer_item.addr, buffer_item.length_in_bytes]\n\t\t\t\t\t\t\t\tcase buffer_item.datatype\n\t\t\t\t\t\t\t\t\twhen \"PDWORD\"\n\t\t\t\t\t\t\t\t\t\treturn_hash[param_name] = buffer.unpack('V')[0]\n\t\t\t\t\t\t\t\t\twhen \"PCHAR\"\n\t\t\t\t\t\t\t\t\t\treturn_hash[param_name] = asciiz_to_str(buffer)\n\t\t\t\t\t\t\t\t\twhen \"PWCHAR\"\n\t\t\t\t\t\t\t\t\t\treturn_hash[param_name] = uniz_to_str(buffer)\n\t\t\t\t\t\t\t\t\twhen \"PBLOB\"\n\t\t\t\t\t\t\t\t\t\treturn_hash[param_name] = buffer\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\traise \"unexpected type in out-only buffer of #{param_name}: #{buffer_item.datatype}\"\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t#puts return_hash\n\n\t\t\t\t\t\t\t# process in-out buffers\n\t\t\t\t\t\t\t#puts \"processing in-out buffers:\"\n\t\t\t\t\t\t\tinout_layout.each_pair do |param_name, buffer_item|\n\t\t\t\t\t\t\t\t#puts \" #{param_name}\"\n\t\t\t\t\t\t\t\tbuffer = rec_inout_buffers[buffer_item.addr, buffer_item.length_in_bytes]\n\t\t\t\t\t\t\t\tcase buffer_item.datatype\n\t\t\t\t\t\t\t\t\twhen \"PDWORD\"\n\t\t\t\t\t\t\t\t\t\treturn_hash[param_name] = buffer.unpack('V')[0]\n\t\t\t\t\t\t\t\t\twhen \"PCHAR\"\n\t\t\t\t\t\t\t\t\t\treturn_hash[param_name] = asciiz_to_str(buffer)\n\t\t\t\t\t\t\t\t\twhen \"PWCHAR\"\n\t\t\t\t\t\t\t\t\t\treturn_hash[param_name] = uniz_to_str(buffer)\n\t\t\t\t\t\t\t\t\twhen \"PBLOB\"\n\t\t\t\t\t\t\t\t\t\treturn_hash[param_name] = buffer\n\t\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\t\traise \"unexpected type in in-out-buffer of #{param_name}: #{buffer_item.datatype}\"\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\t#puts return_hash\n\t\t\t\t\t\t\t#puts \"finished\"\n\n\t\t\t\t\t\t\treturn return_hash\n\t\t\t\t\t\tend", "def buffer(buffer_name = nil)\n #@_out_buf\n #buffer_name ||= Tilt.current_template.instance_variable_get('@outvar') || @outvar || Vue::Helpers.default_outvar\n buffer_name ||=\n ((ct = Tilt.current_template) && ct.instance_variable_get(:@outvar)) ||\n Thread.current.instance_variable_get(:@current_eoutvar) ||\n Vue::Helpers.default_outvar\n #puts \"BUFFER thread-ivars: #{Thread.current.instance_variables}, thread-local-vars: #{Thread.current.send(:local_variables)}\"\n #puts \"BUFFER chosen: #{buffer_name}, controller/view ivars: #{instance_variables}, controller/view local-vars: #{local_variables}\"\n #instance_variable_get(buffer_name)\n instance_variable_get(buffer_name.to_s)\n end", "def buffer=(buffer)\n @io = buffer\n end", "def reset\n\t\t@out_pos = -1\n\t\t@in_pos = -1\n\t\t@input_buffer = []\n\t\t@output_buffer = []\n\tend", "def create_buffer(contents)\n end", "def initialize(context)\n @context = context\n @out = context.output_buffer\n end", "def flush_buffer; self.input_buffer = \"AAAA\"; end", "def close_and_write_buffer\n nested_buffer = @out\n @out = @out_buffers.pop\n @out << nested_buffer\n end", "def add_buffer(id)\n buffers[id] ||= []\n DSP[id] = buffers[id]\n end", "def reset\n\t\t\t@out_pos = -1\n\t\t\t@in_pos = -1\n\t\t\t@input_buffer = []\n\t\t\t@output_buffer = []\n\t\tend", "def unmarshall_buffer(buf)\n buf = buf.dup\n if buf[0] == ?l\n endianness = LIL_END\n else\n endianness = BIG_END\n end\n pu = PacketUnmarshaller.new(buf, endianness)\n dummy, @message_type, @flags, @protocol, @body_length, @serial,\n headers = pu.unmarshall(MESSAGE_SIGNATURE)\n headers.each do |struct|\n case struct[0]\n when PATH\n @path = struct[1]\n when INTERFACE\n @interface = struct[1]\n when MEMBER\n @member = struct[1]\n when ERROR_NAME\n @error_name = struct[1]\n when REPLY_SERIAL\n @reply_serial = struct[1]\n when DESTINATION\n @destination = struct[1]\n when SENDER\n @sender = struct[1]\n when SIGNATURE\n @signature = struct[1]\n end\n end\n pu.align(8)\n if @body_length > 0 and @signature\n @params = pu.unmarshall(@signature, @body_length)\n end\n [self, pu.idx]\n end", "def push_input data\n @in_buffer << data\n drain\n end", "def message_buffer; end", "def receive_data(data)\n buffer.concat(data)\n end", "def init_vertex_buffers\n\t\t#vao_id = GL30.gl_gen_vertex_arrays\n\t\t#GL30.gl_bind_vertex_array(vao_id)\n\n\t\t@buffer_id = GL15.gl_gen_buffers\n\t\tGL15.gl_bind_buffer(GL15::GL_ARRAY_BUFFER, @buffer_id)\n\n\t\tfloat_buffer = BufferUtils.create_float_buffer(@vertex_positions.size)\n\t\tfloat_buffer.put(@vertex_positions.to_java(:float))\n\n\t\t#MUST FLIP THE BUFFER! THIS PUTS IT BACK TO THE BEGINNING!\n\t\tfloat_buffer.flip\n\n\t\tGL15.gl_buffer_data(GL15::GL_ARRAY_BUFFER, float_buffer, GL15::GL_STATIC_DRAW)\n\n\t\t# cleanup\n\t\tGL15.gl_bind_buffer(GL15::GL_ARRAY_BUFFER, 0)\n\t\t#GL30.gl_bind_vertex_array(0)\n\tend", "def add_buffers!(name)\n Vedeu::Buffers::Buffer.new(name: name).store\n end", "def add_buffers!(name)\n Vedeu::Buffers::Buffer.new(name: name).store\n end", "def source_buffer; end", "def source_buffer; end", "def source_buffer; end", "def data_buffer\n @data_buffer ||= {}\n end", "def buffer=(input)\n @buffer = input\n @words = nil\n end", "def pack(p0) end", "def close_buffer\n buf = @out\n @out = @out_buffers.pop\n return buf\n end", "def write_buffer(io = T.unsafe(nil), encrypter = T.unsafe(nil)); end", "def read(count = T.unsafe(nil), _buffer = T.unsafe(nil)); end", "def open_buffer(io, options = T.unsafe(nil)); end", "def convert_from_buffer(tensor, result)\n if result.buffer.is_a?(TensorStream::Evaluator::OutputGroup)\n converted_outputs = result.buffer.outputs.zip(result.buffer.data_types).map do |output, data_type|\n convert_to_opencl([output].flatten, shape_eval(output), data_type: data_type, name: tensor.name)\n end\n TensorStream::Evaluator::OutputGroup.new(converted_outputs, result.buffer.data_types)\n else\n convert_to_opencl([result.buffer].flatten, shape_eval(result.buffer), data_type: result.data_type, name: tensor.name)\n end\n end", "def create_buffer!\n @buffer = Hash.new { |h, k| h[k] = Array.new }\n end", "def flush_next_out\n\t\t@out_pos = @output_buffer.length\n\t\t@finished = true\n\t\tret = @output_buffer.pack(\"c*\")\n\t\t@output_buffer = []\n\t\tret\n\tend", "def initialize_buffered_io; end", "def setio(input, output)\n @@input = input\n @@output = output\n end", "def unpack(p0) end", "def to_buffer(item)\n\n #Try to convert the item to an array, and then to a string,\n #if it supports it. This allows us to easily get a byte string\n #from most Ruby types.\n #\n #Strings _shouldn't_ support either of these methods, and thus will\n #pass unaltered.\n # \n item = item.to_a if item.respond_to?(:to_a)\n item = item.pack(\"C*\") if item.respond_to?(:pack)\n \n #Create a new buffer, and fill it with our byte string.\n buffer = FFI::MemoryPointer.new(item.byte_size)\n buffer.put_bytes(0, item)\n\n #And return the filled buffer.\n return buffer\n \n end", "def flush_next_out\n\t\t\t@out_pos = @output_buffer.length\n\t\t\t@finished = true\n\t\t\tret = @output_buffer.pack(\"c*\")\n\t\t\t@output_buffer = []\n\t\t\tret\n\t\tend", "def avail_in\n\t\t@input_buffer.length - @in_pos\n\tend", "def buffer\n swap if back?\n\n if front?\n [front.render]\n\n elsif previous?\n [previous.render]\n\n else\n []\n\n end\n end", "def test_io_022\n @vc.parse <<EOF\n: test \n ['] (utx!) (tx!) ! ['] (urx@) (rx@) ! \n refill if bl parse then \n save-input ;\nEOF\n @vc.compile\n inp = \"this is a test\\r\"\n out = \"\"\n @vc.vm.redirect(inp,out)\n @vc.run_limit = @vc.run_limit * 100\n @vc.run\n assert_equal(:halt, @vc.vm.state)\n assert_equal(12, @vc.vm.depth)\n assert_equal(9, @vc.vm.tos)\n assert_equal(5, @vc.vm.nos)\n assert_equal(0, @vc.vm.pick(2))\n assert_equal(0, @vc.vm.pick(3))\n assert_equal(14, @vc.vm.pick(6) - @vc.vm.pick(7))\n assert_not_equal(0, @vc.vm.pick(7))\n # ignoring (src0), (srcend)\n assert_equal(4, @vc.vm.pick(10))\n assert_not_equal(0, @vc.vm.pick(11))\n assert_equal(\"this is a test \", out)\n buf = @vc.vm.pick(11)\n assert_equal(inp[0].ord, @vc.vm.c_fetch(buf + 0))\n assert_equal(inp[1].ord, @vc.vm.c_fetch(buf + 1))\n assert_equal(inp[2].ord, @vc.vm.c_fetch(buf + 2))\n assert_equal(inp[3].ord, @vc.vm.c_fetch(buf + 3))\n end", "def initialize\n @in_stack = []\n @out_stack = []\n end", "def buffer_concat(txt)\n @_out_buf << txt if buffer?\n end", "def input=(_arg0); end", "def to_buffer\n validate_binary_operations\n @request.perform(binary: true)\n end", "def initialize( buffers, driver )\n @buffers = buffers\n @driver = driver\n end", "def buffer_info\n @buffer_info ||= BufferInfo.new\n end", "def initialize_buffered_io\n @input = Net::SSH::Buffer.new\n @input_errors = []\n @output = Net::SSH::Buffer.new\n @output_errors = []\n end", "def clean_buffer; self.input_buffer = self.input_buffer[self.input_buffer.length-4,self.input_buffer.length-1]; end", "def pack\n end", "def getInput\n $game_player.clean_buffer if $game_player.input_buffer.length > 10\n $game_player.flush_buffer if $game_player.iframes == 0\n case Input.dir8\n when 2; $game_player.buffer('D')\n when 4; $game_player.buffer('L')\n when 6; $game_player.buffer('R')\n when 8; $game_player.buffer('U')\n end\n $game_player.iframes -= 1 if $game_player.iframes > 0 \nend", "def get_raw_buffer\n @buffer\n end", "def copy_out(iovec, argsz)\n tok = []\n if type == 'char **'\n tok << \"char *tmp_#{name} = malloc(#{argsz});\"\n tok << \"#{iovec}.iov_base = tmp_#{name};\"\n tok << \"#{iovec}.iov_len = #{argsz};\"\n else\n tok << \"#{iovec}.iov_base = #{name};\"\n tok << \"#{iovec}.iov_len = sizeof(*#{name});\"\n end\n tok\n end", "def data\n data = \"\".b\n txdata = @transaction.data\n data << WireFormat.encode_string(txdata)\n @inputs.each do |ain|\n data << ain.assets_data\n end\n @outputs.each do |aout|\n if !aout.marker?\n data << aout.assets_data\n end\n end\n data\n end", "def buffer=(data)\n if !@buffer || data.bytesize>@buffer.size\n free_buffer\n @buffer = FFI::MemoryPointer.new(data.bytesize, 1, false)\n end\n @buffer.put_bytes(0, data)\n @transfer[:buffer] = @buffer\n @transfer[:length] = data.bytesize\n end", "def send_io(p0) end", "def io=(_arg0); end", "def io=(_arg0); end", "def unpack\n if ! @unpacked && @sec_buffer && @struct\n dataBufferSize, dType, dataBuffer, tokenBufferSize, tType, tokenBuffer = @sec_buffer.unpack(\"LLPLLP\")\n dataBufferSize, dType, dataBuffer, tokenBufferSize, tType, tokenBuffer = @sec_buffer.unpack(\"LLP#{dataBufferSize}LLP#{tokenBufferSize}\")\n # Form the buffer stream as required by server\n @buffer = [tokenBufferSize].pack(\"L\")\n @buffer << tokenBuffer << dataBuffer\n @struct = nil\n @sec_buffer = nil\n @unpacked = true\n end\n end", "def rx_buffer\n v = nil\n @mutex.synchronize do\n v = @rx_buffer\n @rx_buffer = [] if @rx_buffer\n end\n v\n end", "def convert_from_buffer(_tensor, _result)\n raise \"need implementation\"\n end", "def set_data(data_pointer, element_count, buffer_usage = GL::STREAM_DRAW)\r\n @element_count = element_count\r\n GL.BindBuffer(@buffer_target, @buffer_id)\r\n GL.BufferData(@buffer_target, @element_count * @element_size, data_pointer, buffer_usage)\r\n GL.BindBuffer(@buffer_target, 0)\r\n end", "def avail_out\n\t\t@output_buffer.length - @out_pos\n\tend", "def initialize_buffer\r\n @buffer = []\r\n @pointer = 0\r\n def @buffer.clear\r\n @pointer = 0\r\n super\r\n end\r\n end", "def inp(pointer, pmodes)\n args = get_parameters(pointer, pmodes)\n @err&.print PROMPT\n @ram[args[0]] = Integer(@input.gets) # NOTE: INP is a special case in terms of output\n pointer + 2\n end", "def save_buffer\n @_out_buf, buf_was = '', @_out_buf\n buf_was\n end", "def stdin(*); end", "def stdin(*); end", "def buffered!(len=nil, buffer_name=:default, opts={}, &block)\n semaphore.synchronize {\n ret, still_to_get = buffer(buffer_name, opts[:type]).offset!(len)\n if still_to_get > 0\n src_data = Support::Utils.send_all_or_no_args(block, still_to_get)\n called_for = src_data.slice!(0, still_to_get)\n ret.concat(called_for)\n buffer(buffer_name).concat(src_data)\n end\n ret\n }\n end", "def write_cmd(buf)\n\tend", "def writebuffers(lod, groundsurfaces, wallsurfaces, roofsurfaces, floorsurfaces, outerfloorsurfaces, intbuildinginstallations, buildinginstallations, doors, windows, ceilingsurfaces, interiorwallsurfaces, nosurfacetype, actbuildingid)## doplneny pozadovany typ\n return if(groundsurfaces.size == 0 and wallsurfaces.size == 0 and roofsurfaces.size == 0 and floorsurfaces.size == 0 and outerfloorsurfaces.size == 0 and intbuildinginstallations.size == 0 and buildinginstallations.size == 0 and doors.size == 0 and windows.size == 0 and ceilingsurfaces.size == 0 and interiorwallsurfaces.size == 0 and nosurfacetype == \"\")\n if(nosurfacetype != \"\")\n @handle << \"<#{lod}>\\n\"\n if(@gmlType == 1)\n @handle << \"<gml:CompositeSolid>\\n\"\n else\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n end\n \n @handle << nosurfacetype\n \n if(@gmlType == 1)\n @handle << \"</gml:CompositeSolid>\\n\"\n else\n @handle << \"</gml:MultiSurface>\\n\"\n end\n \n @handle << \"</#{lod}>\\n\"\n end\n #Gibt es Surfaces mit Typ, werden diese im boundedBy-Tag gespeichert ## doplneny pozadovany typ\n if(wallsurfaces.size > 0 or roofsurfaces.size > 0 or floorsurfaces.size > 0 or outerfloorsurfaces.size > 0 or groundsurfaces.size > 0 or intbuildinginstallations.size > 0 or buildinginstallations.size > 0 or doors.size > 0 or windows.size > 0 or ceilingsurfaces.size > 0 or interiorwallsurfaces.size > 0)\n \n if(wallsurfaces.size > 0)\n wallsurfaces.each_pair {|key, value|\n if(key != \"\" and key != nil and !@noid)\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or (key == nil and !@generate) )\n @handle << \"<bldg:WallSurface>\\n\"\n else\n @handle << \"<bldg:WallSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n \n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << value\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:WallSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n else\n if(!@groupsurfaces)\n pos = 1\n value.each do |v|\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:WallSurface>\\n\"\n else\n key = \"#{actbuildingid}_WallSurface_#{pos}\" if(@generate)\n pos += 1\n @handle << \"<bldg:WallSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << v\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:WallSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n else\n pos = 1\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:WallSurface>\\n\"\n else\n key = \"#{actbuildingid}_WallSurface_#{pos}\" if(@generate)\n @handle << \"<bldg:WallSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n value.each do |v|\n @handle << v\n end\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:WallSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n end\n }\n end\n\n\n if(roofsurfaces.size > 0)\n roofsurfaces.each_pair {|key, value|\n if(key != \"\" and key != nil and !@noid)\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or (key == nil and !@generate) )\n @handle << \"<bldg:RoofSurface>\\n\"\n else\n @handle << \"<bldg:RoofSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << value\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:RoofSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n else\n if(!@groupsurfaces)\n pos = 1\n value.each do |v|\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate )\n @handle << \"<bldg:RoofSurface>\\n\"\n else\n key = \"#{actbuildingid}_RoofSurface_#{pos}\" if(@generate)\n pos += 1\n @handle << \"<bldg:RoofSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << v\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:RoofSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n else\n pos = 1\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate )\n @handle << \"<bldg:RoofSurface>\\n\"\n else\n key = \"#{actbuildingid}_RoofSurface_#{pos}\" if(@generate)\n @handle << \"<bldg:RoofSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n value.each do |v|\n\n @handle << v\n\n end\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:RoofSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n end\n }\n end\n\n if(groundsurfaces.size > 0)\n groundsurfaces.each_pair {|key, value|\n if(key != \"\" and key != nil and !@noid)\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or (key == nil and !@generate) )\n @handle << \"<bldg:GroundSurface>\\n\"\n else\n @handle << \"<bldg:GroundSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << value\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:GroundSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n else\n if(!@groupsurfaces)\n pos = 1\n value.each do |v|\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate )\n @handle << \"<bldg:GroundSurface>\\n\"\n else\n key = \"#{actbuildingid}_GroundSurface_#{pos}\" if(@generate)\n pos += 1\n @handle << \"<bldg:GroundSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << v\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:GroundSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n else\n pos = 1\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate )\n @handle << \"<bldg:GroundSurface>\\n\"\n else\n key = \"#{actbuildingid}GroundSurface_#{pos}\" if(@generate)\n @handle << \"<bldg:GroundSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n value.each do |v|\n @handle << v\n end\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:GroundSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n end\n }\n end\n## doplneny pozadovany typ pro celou funkci\n\t\tif(floorsurfaces.size > 0)\n floorsurfaces.each_pair {|key, value|\n if(key != \"\" and key != nil and !@noid)\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or (key == nil and !@generate) )\n @handle << \"<bldg:FloorSurface>\\n\"\n else\n @handle << \"<bldg:FloorSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n \n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << value\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:FloorSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n else\n if(!@groupsurfaces)\n pos = 1\n value.each do |v|\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:FloorSurface>\\n\"\n else\n key = \"#{actbuildingid}_FloorSurface_#{pos}\" if(@generate)\n pos += 1\n @handle << \"<bldg:FloorSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << v\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:FloorSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n else\n pos = 1\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:FloorSurface>\\n\"\n else\n key = \"#{actbuildingid}_FloorSurface_#{pos}\" if(@generate)\n @handle << \"<bldg:FloorSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n value.each do |v|\n @handle << v\n end\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:FloorSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n end\n }\n end\n \n if(outerfloorsurfaces.size > 0)\n outerfloorsurfaces.each_pair {|key, value|\n if(key != \"\" and key != nil and !@noid)\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or (key == nil and !@generate) )\n @handle << \"<bldg:OuterFloorSurface>\\n\"\n else\n @handle << \"<bldg:OuterFloorSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n \n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << value\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:OuterFloorSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n else\n if(!@groupsurfaces)\n pos = 1\n value.each do |v|\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:OuterFloorSurface>\\n\"\n else\n key = \"#{actbuildingid}_OuterFloorSurface_#{pos}\" if(@generate)\n pos += 1\n @handle << \"<bldg:OuterFloorSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << v\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:OuterFloorSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n else\n pos = 1\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:FloorSurface>\\n\"\n else\n key = \"#{actbuildingid}_OuterFloorSurface_#{pos}\" if(@generate)\n @handle << \"<bldg:OuterFloorSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n value.each do |v|\n @handle << v\n end\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:OuterFloorSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n end\n }\n end\n\n \n###interiorwallsurfaces\n\nif(interiorwallsurfaces.size > 0)\n interiorwallsurfaces.each_pair {|key, value|\n if(key != \"\" and key != nil and !@noid)\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or (key == nil and !@generate) )\n @handle << \"<bldg:InteriorWallSurface >\\n\"\n else\n @handle << \"<bldg:InteriorWallSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n \n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << value\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:InteriorWallSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n else\n if(!@groupsurfaces)\n pos = 1\n value.each do |v|\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:InteriorWallSurface>\\n\"\n else\n key = \"#{actbuildingid}_InteriorWallSurface_#{pos}\" if(@generate)\n pos += 1\n @handle << \"<bldg:InteriorWallSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << v\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:InteriorWallSurface >\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n else\n pos = 1\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:InteriorWallSurface>\\n\"\n else\n key = \"#{actbuildingid}_InteriorWallSurface_#{pos}\" if(@generate)\n @handle << \"<bldg:InteriorWallSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n value.each do |v|\n @handle << v\n end\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:InteriorWallSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n end\n }\n end\n \n \n \n ###konec interiorwallsurfaces\n \n ###ceilingsurfaces\n if(ceilingsurfaces.size > 0)\n ceilingsurfaces.each_pair {|key, value|\n if(key != \"\" and key != nil and !@noid)\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or (key == nil and !@generate) )\n @handle << \"<bldg:CeilingSurface>\\n\"\n else\n @handle << \"<bldg:CeilingSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n \n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << value\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:CeilingSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n else\n if(!@groupsurfaces)\n pos = 1\n value.each do |v|\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:CeilingSurface>\\n\"\n else\n key = \"#{actbuildingid}_CeilingSurface_#{pos}\" if(@generate)\n pos += 1\n @handle << \"<bldg:CeilingSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << v\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:CeilingSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n else\n pos = 1\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:CeilingSurface>\\n\"\n else\n key = \"#{actbuildingid}_CeilingSurface_#{pos}\" if(@generate)\n @handle << \"<bldg:CeilingSurface gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n value.each do |v|\n @handle << v\n end\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:CeilingSurface>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n end\n }\n end\n \n ## konec ceilingsurfaces\n \n ##doors\n if(doors.size > 0)\n doors.each_pair {|key, value|\n if(key != \"\" and key != nil and !@noid)\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or (key == nil and !@generate) )\n @handle << \"<bldg:Door>\\n\"\n else\n @handle << \"<bldg:Door gml:id=\\\"#{key}\\\">\\n\"\n end\n \n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << value\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:Door>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n else\n if(!@groupsurfaces)\n pos = 1\n value.each do |v|\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:Door>\\n\"\n else\n key = \"#{actbuildingid}_Door_#{pos}\" if(@generate)\n pos += 1\n @handle << \"<bldg:Door gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << v\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:Door>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n else\n pos = 1\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:Door>\\n\"\n else\n key = \"#{actbuildingid}_Door_#{pos}\" if(@generate)\n @handle << \"<bldg:Door gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n value.each do |v|\n @handle << v\n end\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:Door>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n end\n }\n end\n ##konec doors\n \n ##windows\n if(windows.size > 0)\n windows.each_pair {|key, value|\n if(key != \"\" and key != nil and !@noid)\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or (key == nil and !@generate) )\n @handle << \"<bldg:Window>\\n\"\n else\n @handle << \"<bldg:Window gml:id=\\\"#{key}\\\">\\n\"\n end\n \n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << value\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:Window>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n else\n if(!@groupsurfaces)\n pos = 1\n value.each do |v|\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:Window>\\n\"\n else\n key = \"#{actbuildingid}_Window_#{pos}\" if(@generate)\n pos += 1\n @handle << \"<bldg:Window gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << v\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:Window>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n else\n pos = 1\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:Window>\\n\"\n else\n key = \"#{actbuildingid}_Window_#{pos}\" if(@generate)\n @handle << \"<bldg:Window gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n value.each do |v|\n @handle << v\n end\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:Window>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n end\n }\n end\n \n ##konec windows\n \n ##intBuildingInstallation\n \n if(intbuildinginstallations.size > 0)\n intbuildinginstallations.each_pair {|key, value|\n if(key != \"\" and key != nil and !@noid)\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or (key == nil and !@generate) )\n @handle << \"<bldg:IntBuildingInstallation>\\n\"\n else\n @handle << \"<bldg:IntBuildingInstallation gml:id=\\\"#{key}\\\">\\n\"\n end\n \n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << value\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:IntBuildingInstallation>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n else\n if(!@groupsurfaces)\n pos = 1\n value.each do |v|\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:IntBuildingInstallation>\\n\"\n else\n key = \"#{actbuildingid}_IntBuildingInstallation_#{pos}\" if(@generate)\n pos += 1\n @handle << \"<bldg:IntBuildingInstallation gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << v\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:IntBuildingInstallation>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n else\n pos = 1\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:IntBuildingInstallation>\\n\"\n else\n key = \"#{actbuildingid}_IntBuildingInstallation_#{pos}\" if(@generate)\n @handle << \"<bldg:IntBuildingInstallation gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n value.each do |v|\n @handle << v\n end\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:IntBuildingInstallation>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n end\n }\n end\n \n ##konec intBuildingInstallation\n \n ##BuildingInstallation\n \n if(buildinginstallations.size > 0)\n buildinginstallations.each_pair {|key, value|\n if(key != \"\" and key != nil and !@noid)\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or (key == nil and !@generate) )\n @handle << \"<bldg:BuildingInstallation>\\n\"\n else\n @handle << \"<bldg:BuildingInstallation gml:id=\\\"#{key}\\\">\\n\"\n end\n \n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << value\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:BuildingInstallation>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n else\n if(!@groupsurfaces)\n pos = 1\n value.each do |v|\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:BuildingInstallation>\\n\"\n else\n key = \"#{actbuildingid}_BuildingInstallation_#{pos}\" if(@generate)\n pos += 1\n @handle << \"<bldg:BuildingInstallation gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n @handle << v\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:BuildingInstallation>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n else\n pos = 1\n @handle << \"<bldg:boundedBy>\\n\"\n if(@noid or !@generate)\n @handle << \"<bldg:BuildingInstallation>\\n\"\n else\n key = \"#{actbuildingid}_BuildingInstallation_#{pos}\" if(@generate)\n @handle << \"<bldg:BuildingInstallation gml:id=\\\"#{key}\\\">\\n\"\n end\n\n @handle << \"<#{lod}>\\n\"\n @handle << \"<gml:MultiSurface\"\n coordinateSystemString()\n @handle << \">\\n\"\n value.each do |v|\n @handle << v\n end\n @handle << \"</gml:MultiSurface>\\n\"\n @handle << \"</#{lod}>\\n\"\n @handle << \"</bldg:BuildingInstallation>\\n\"\n @handle << \"</bldg:boundedBy>\\n\"\n end\n end\n }\n end\n \n ## konec BuildingInstallation\n \n \n \n end\n #Inhalte löschen ## doplneny pozadovany typ\n nosurfacetype = \"\"\n groundsurfaces.clear\n wallsurfaces.clear\n roofsurfaces.clear\n\t floorsurfaces.clear\n outerfloorsurfaces.clear\n intbuildinginstallations.clear\n buildinginstallations.clear\n doors.clear\n windows.clear\n ceilingsurfaces.clear\n interiorwallsurfaces.clear\n end", "def encode_block(state, buf)\n\t\tbuf\n\tend", "def initialize(buffer)\n @buf = ArrayIStream.new(buffer)\n end", "def with_output_buffer(buf = '')\n @_out_buf, old_buffer = buf, @_out_buf\n yield\n @_out_buf\n ensure\n @_out_buf = old_buffer\n end", "def avail_in\n\t\t\t@input_buffer.length - @in_pos\n\t\tend", "def buffer=(buf)\n @buffer = buf\n @snippet_loader.current_snippets.each do |snippet|\n snippet.buffer = buf\n end\n @manipulators.each { |man| man.buffer = buf }\n monkey_patch_buffer!\n @buffer\n end" ]
[ "0.70660084", "0.66418654", "0.6359748", "0.62572575", "0.6142362", "0.6142362", "0.6142362", "0.61342454", "0.61342454", "0.60732245", "0.59306526", "0.5913204", "0.5861195", "0.58545095", "0.5722738", "0.56917465", "0.56917065", "0.56917065", "0.5688953", "0.5663412", "0.56085914", "0.5567541", "0.555641", "0.55443", "0.55060893", "0.5465702", "0.54514384", "0.541197", "0.5411071", "0.5385193", "0.53830874", "0.53470796", "0.53461194", "0.5322194", "0.5297532", "0.5293603", "0.5263645", "0.5253014", "0.5246153", "0.51769763", "0.51742315", "0.51697445", "0.5154467", "0.5154467", "0.5137983", "0.5137983", "0.5137983", "0.5104557", "0.50787985", "0.5075103", "0.505207", "0.5045773", "0.5034649", "0.5032295", "0.5025764", "0.49982518", "0.49855936", "0.49731904", "0.49730456", "0.4942006", "0.49336305", "0.49065483", "0.49056664", "0.49036708", "0.48970118", "0.48858565", "0.48820266", "0.4878479", "0.48568976", "0.48508662", "0.48488227", "0.48444006", "0.48354203", "0.48293576", "0.48272607", "0.48149586", "0.480566", "0.4804089", "0.47914556", "0.47819158", "0.4772906", "0.4772906", "0.476464", "0.47639298", "0.47614643", "0.4745996", "0.47438043", "0.47407764", "0.47383168", "0.47375607", "0.47323078", "0.47323078", "0.47270143", "0.4722926", "0.47227737", "0.47217658", "0.47192636", "0.47169518", "0.47148687", "0.47132775" ]
0.59630877
10
RESEARCHERS don't have a profile, but they shouldn't have a U.Va. computing id.
def virginia_borrower? # @profile !~ /^[a-z]{2,3}([0-9][a-z]{1,2})?$/i profile.match?(/Virginia Borrower|Other VA Faculty|Alum/i) || profile.blank? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def find_profile (profile_name)\n # Find the matching profile\n profile_data = @master_data.select { |p, d| p[/^#{profile_name}/] }\n profile_count = profile_data.count\n if profile_count > 1\n puts \"Profile match not specific enough. Please refine match\"\n exit 1\n elsif profile_count < 1\n puts \"Unable to find profile\"\n exit 1\n end\n return profile_data.first\nend", "def team_profiles\n profiles.reject { |p| p == profile }\n end", "def ensure_self_is_not_in_exposed_profiles\n if exposed_profiles.include?(id)\n errors.add(:exposed_profiles, 'should not include self')\n end\n end", "def inactive_reviewers\n unless @results_with_inactive_users\n @results_with_inactive_users =\n self.design_review_results.select { |drr| drr.reviewer && !drr.reviewer.active? }\n end\n @results_with_inactive_users.collect { |drr| drr.reviewer }\n end", "def has_profile?\n vips_image.get_fields.include?('icc-profile-data')\n end", "def no_self_recommendation\n errors.add(:user_id, I18n.t('recommendation.no_self_recommendation_message')) if user_id == domain.mecano_profile.user_id\n end", "def validate_profile(page, first_name, last_name, employer, title)\n full_name = I18n.transliterate(\"#{first_name} #{last_name}\").alnum\n profile_name = I18n.transliterate(page.at_css(\"#name\").text).alnum\n puts '############# ACCESS GRANTED ############'\n puts profile_name\n positions = page.css(\"#experience .positions .position\")\n match = false\n unless split_string_comp(profile_name, full_name) == true\n return match\n end\n positions.each do |position|\n if position.at_css(\"header .item-title a\") && position.at_css(\"header .item-subtitle\")\n profile_title = I18n.transliterate(position.at_css(\"header .item-title a\").text).alnum\n profile_employer = I18n.transliterate(position.at_css(\"header .item-subtitle\").text).alnum\n title = I18n.transliterate(title).alnum\n employer = I18n.transliterate(employer).alnum\n if split_string_comp(profile_title, title) && split_string_comp(profile_employer, employer)\n match = true\n end\n end\n end\n return match\nend", "def sufficient_rhizomes_validation\n unless profiles_assigned?\n rhizome_s = recipe.schedule.equipment_profiles.length == 1 ? 'Rhizome' : 'Rhizomes'\n errors.add(:recipe, \"requires #{recipe.schedule.equipment_profiles.length} #{rhizome_s}\")\n end\n end", "def research_starters_match_in_profile\n @info.available_related_content_types.include? 'rs'\n end", "def validate_profile(page, first_name, last_name, employer, title)\n full_name = I18n.transliterate(\"#{first_name} #{last_name}\").alnum\n return false unless page.at_css(\"#name\")\n profile_name = I18n.transliterate(page.at_css(\"#name\").text).alnum\n puts '############# ACCESS GRANTED ############'\n puts profile_name\n return false unless page.css(\"#experience .positions .position\")\n positions = page.css(\"#experience .positions .position\")\n match = false\n unless split_string_comp(profile_name, full_name) == true\n return match\n end\n positions.each do |position|\n begin\n if position.at_css(\"header .item-title a\") && position.at_css(\"header .item-subtitle\")\n profile_title = I18n.transliterate(position.at_css(\"header .item-title a\").text).alnum\n profile_employer = I18n.transliterate(position.at_css(\"header .item-subtitle\").text).alnum\n title = I18n.transliterate(title).alnum\n employer = I18n.transliterate(employer).alnum\n if split_string_comp(profile_title, title) && split_string_comp(profile_employer, employer)\n match = true\n end\n end\n rescue Exception => e\n puts e\n end\n end\n return match\nend", "def userless_people\n people.select{|p| p.user.nil?}\n end", "def reviewer; fund_source ? fund_source.organization : nil; end", "def check_name_existence\n users = Center.joins(:profile).where(institution_id: institution_id).where('profiles.firstname =?',firstname)\n errors.add(:firstname,\"already taken for this entrys\") if !users.blank? and self.id != users.first.id\n end", "def paks_with_no_regions\n sql =\n \"select mem_id, mem_passport_prefix, mem_passport, mem_name, mem_schoolname, \" +\n \" con_first_name, con_last_name, add_city, add_zip \" +\n \" from user_table, contact, membership, address \" +\n \"where mem_affiliate=? \" +\n \" and mem_region is null \" +\n \" and mem_admin = user_id \" +\n \" and mem_state != '#{StateNameTable::Suspended}'\" +\n \" and user_contact = con_id \" +\n \" and con_mail = add_id \" +\n \"order by mem_passport\"\n\n res = $store.raw_select(sql, @data_object.aff_id)\n \n i = -1\n res.map do |row|\n i += 1\n { \n \"mem_id\" => row[0],\n \"full_passport\" => row[1] + \"-\" + row[2],\n \"mem_name\" => row[3],\n \"mem_schoolname\" => row[4],\n \"coordinator\" => row[5] + \" \" + row[6],\n \"con_city\" => row[7],\n \"con_zip\" => row[8],\n \"reg_#{i}\" => NONE,\n \"i\" => i,\n }\n end\n end", "def name_should_exist\n\t agent = Mechanize.new { |agent| agent.user_agent_alias = \"Windows Chrome\" }\n searchPage = agent.get('http://www.lolking.net/')\n\t#search for player with the user name keyword\n\tsearchBox = searchPage.forms.first\n\tsearchBox['name'] = name\n\tresultPage = searchBox.submit\n\tresultBody = resultPage.body\n\tresult_doc = Nokogiri::HTML(resultBody)\n\n\trank = result_doc.xpath(\"//li[contains(@class, 'featured')]/div[3]/div[1]\").text.strip\n \t if rank.length == 0\n \t errors.add(:name, \"Error: We could not find a North America summoner with the name #{name}\")\n \t end\n end", "def company?\n Profile.find_by_name('Entreprise financière').id == profile_id.to_i rescue false\n end", "def used?\n !InterviewerUser.joins(:candidates_interviews).where(:interviewer_users => {:interviewer_id => id}).empty?\n end", "def known_identities; end", "def ensure_only_owned_profile_ids_in_exposed_profiles\n owned_profile_ids = user.profiles.pluck(:id)\n exposed_profiles.each do |profile_id|\n if not owned_profile_ids.include?(profile_id.to_i)\n errors.add(:exposed_profiles, 'can only contain valid profiles')\n break\n end\n end\n end", "def inactive_reviewers?\n self.inactive_reviewers unless @results_with_inactive_users\n @results_with_inactive_users.size > 0\n end", "def has_embedded_profile?\n image.get_typeof(\"icc-profile-data\") != 0\n end", "def service_learners\n service_learning_positions.collect(&:placements).flatten.collect(&:person).compact.uniq\n end", "def get_people(entry_id, search_term2)\n\n begin\n\n q = \"relatedAgentFor_ssim:#{entry_id}\"\n if @display_type == 'matched records'\n q = \"relatedAgentFor_ssim:#{entry_id} AND (person_as_written_search:*#{search_term2}* or person_role_search:*#{search_term2}* or person_descriptor_search:*#{search_term2}* or person_descriptor_same_as_search:*#{search_term2}* or person_note_search:*#{search_term2}* or person_same_as_search:*#{search_term2}* or person_related_place_search:*#{search_term2}* or person_related_person_search:*#{search_term2}*)\"\n end\n fl = 'id, person_as_written_tesim, person_role_new_tesim, person_descriptor_new_tesim, person_descriptor_same_as_tesim, person_note_tesim, person_same_as_new_tesim, person_related_place_tesim, person_related_person_tesim'\n\n person_as_written_string = ''\n person_role_string = ''\n person_descriptor_string = ''\n person_descriptor_same_as_string = ''\n person_note_string = ''\n person_same_as_string = ''\n person_related_place_string = ''\n person_related_person_string = ''\n\n SolrQuery.new.solr_query(q, fl, 1000)['response']['docs'].map do |result|\n person_as_written_string = person_as_written_string + get_place_or_person_string(result['person_as_written_tesim'], person_as_written_string)\n person_role_string = person_role_string + get_place_or_person_string(result['person_role_new_tesim'], person_role_string)\n person_descriptor_string = person_descriptor_string + get_place_or_person_string(result['person_descriptor_new_tesim'], person_descriptor_string)\n person_descriptor_same_as_string = person_descriptor_same_as_string + get_place_or_person_string(result['person_descriptor_same_as_tesim'], person_descriptor_same_as_string)\n person_note_string = person_note_string + get_place_or_person_string(result['person_note_tesim'], person_note_string)\n person_same_as_string = person_same_as_string + get_place_or_person_string(result['person_same_as_new_tesim'], person_same_as_string)\n person_related_place_string = person_related_place_string + get_place_or_person_string(result['person_related_place_tesim'], person_related_place_string)\n person_related_person_string = person_related_person_string + get_place_or_person_string(result['person_related_person_tesim'], person_related_person_string)\n end\n\n @element_array << person_as_written_string\n @element_array << person_role_string\n @element_array << person_descriptor_string\n @element_array << person_descriptor_same_as_string\n @element_array << person_note_string\n @element_array << person_same_as_string\n @element_array << person_related_place_string\n @element_array << person_related_person_string\n\n rescue => error\n log_error(__method__, __FILE__, error)\n raise\n end\n\n end", "def isResearcher?\n return account_type == 1\n end", "def has_profile?(*profiles)\r\n@has_profiles ||= {}\r\nprofile = profiles.shift\r\nreturn true if self.new_record? && profile == 'Not Logged'\r\n@has_profiles[profile] = case profile\r\nwhen nil\r\n false\r\nwhen Fixnum\r\n self.profile_ids.include?(profile)\r\nwhen String\r\n self.profiles.where(:name => profile).select('id').first\r\nwhen Profile\r\n self.profiles.where(:id => profile).select('id').first\r\nend unless @has_profiles.has_key?(profile)\r\nreturn @has_profiles[profile] || profiles.find{|t| self.has_profile?(t) }\r\nend", "def exists?(profile)\n @repository_xml.root.elements[\"profile[@id='#{profile}']\"]\n end", "def profile_name\n name.present? ? name : identifier\n end", "def basic_profile_completeness\n cal_completeness(SadhakProfile::REQUIRED_FIELD_FOR_BASIC_PROFILE)\n end", "def has_profile?\n return self.profile.present?\n end", "def participants\n people.select{|person| !person.guide }\n end", "def incomplete_profile?\n dob == nil\n end", "def incomplete_profile?\n dob == nil\n end", "def grants_gov_pi\n self.find_all { |user| !user[1][:primary_department_code].nil? &&\n !user[1][:phones].find{|phone| phone[:type]=='Work'}.nil? &&\n !user[1][:emails].find{|email| email[:type]=='Work'}.nil? &&\n !user[1][:era_commons_user_name].nil?\n }.shuffle[0][0]\n end", "def additional_identity?\n secondary_identity? && participant_profiles.blank?\n end", "def reviewed?(profile)\n self.reviews.find_by_profile_id(profile.id)\n end", "def results_with_inactive_users\n self.inactive_reviewers unless @results_with_inactive_users\n @results_with_inactive_users\n end", "def vivo_profile(uri)\n g = RDF::Graph.new\n q = rdf_subject_select(uri)\n solutions = RDF_REPO.client.query(q)\n solutions.each do |s|\n p = s[:p]\n o = s[:o]\n g << [uri, p, o]\n if vivo_profile_expand_object?(o)\n g << rdf_subject_graph(o) if o.node?\n g << rdf_subject_graph(o) if o.uri?\n end\n end\n g\nend", "def verify_freelancer_profile(freelancers)\n Logbook.step(\"Verify freelancer #{@freelancer_profile[:name]} profile\")\n freelancer = freelancers.find { |freelancer| freelancer[:name] == @freelancer_profile[:name] }\n Logbook.message(\"*****Profile page of #{freelancer[:name]}*****\")\n @freelancer_profile.each do |key, value|\n if value.include?(freelancer[key.to_sym])\n Logbook.message(\"+ Profile field #{key} matches with the same field from preview.\")\n else\n Logbook.message(\"- Profile field #{key} does not match with the same field from preview.\")\n end\n end\n end", "def erased?\n !@profile\n end", "def publication_match_in_profile\n @info.available_related_content_types.include? 'emp'\n end", "def test_find_phantom_mrn_filter\n # add an MRN\n site = defaults.registration.participant.participant_medical_identifiers.first.site\n @pnt.add_mrn(site, Jinx::UID.generate.to_s)\n # save the patient\n verify_save(@pnt)\n # fetch the saved patient\n svd = @pnt.copy(:identifier)\n svd.find\n # the phantom PMI should be removed\n phantom = @pnt.participant_medical_identifiers.detect { |pmi| pmi.medical_record_number.nil? }\n assert_nil(phantom, \"#{svd} phantom PMI #{phantom} was not filtered out\")\n end", "def compare_profile(freelancersStored, freelancerProfile)\n\n result = true\n i = 1\n while (i <= freelancersStored.length)\n result = true\n\n if !freelancerProfile[\"Name\"].downcase().include? freelancersStored[i][\"Name\"].downcase().strip\n result = false\n end \n\n if !freelancerProfile[\"JobTitle\"].downcase().include? freelancersStored[i][\"JobTitle\"].downcase().strip\n result = false\n end\n\n if !freelancerProfile[\"Overview\"].downcase().include? (freelancersStored[i][\"Overview\"].downcase().gsub(\"...\", \"\").strip)\n result = false\n end\n\n if !freelancerProfile[\"Country\"].downcase().include? freelancersStored[i][\"Country\"].downcase().strip\n result = false\n end\n\n if !freelancerProfile[\"Skills\"].downcase().include? freelancersStored[i][\"Skills\"].downcase().strip\n result = false\n end\n\n if !freelancerProfile[\"Rate\"].downcase().include? freelancersStored[i][\"Rate\"].downcase().strip\n result = false\n end\n\n if !freelancerProfile[\"Earned\"].downcase().include? freelancersStored[i][\"Earned\"].downcase().strip\n result = false\n end\n\n if result\n i = i + freelancersStored.length\n end \n\n i = i + 1 \n\n end\n\n return result\n end", "def by_profile\n profile.gists\n end", "def unassigned_review_committee_members\n offering.review_committee.members - reviewers.collect{|r| r.committee_member rescue nil}\n end", "def profile?(profile=RC.current_profile)\n self.profile == (profile || 'default').to_s\n end", "def fallback_reviewers\n return @fallback_reviewers\n end", "def fallback_reviewers\n return @fallback_reviewers\n end", "def find_reviewers(topic)\n User.all.collect{|u| u if u.reviews.count > 0}.compact\n end", "def reviewers_for(app)\n res = Array.new(self.reviewers)\n res = res.delete_if {|r| app.mentors.collect(&:person).include?(r.person)} unless allow_to_review_mentee\n res = res.delete_if {|r| app.reviewers.collect(&:person).include?(r.person)}\n end", "def validate_precincts(precincts)\n uniq_precincts = []\n precincts.each do |precinct|\n if (uid_exists?(\"precinct\", pid = precinct[\"ident\"].to_s))\n if (uniq_precincts.include?(precinct))\n val_warn(\"Duplicate Precinct Declaration\", pid, \"in Jurisdiction Definition\")\n else\n val_err(\"Non-Unique Precinct UID\", pid, \"in Jurisdiction Definition\")\n end\n else\n uniq_precincts.push(precinct)\n uid_add(\"precinct\", pid)\n end\n end\n end", "def associated_person_name_for_solr\n return FinderHelper.strip(role.person.full_name) if !role.person.blank?\n end", "def sampled_ineligible?\n sampled_persons_ineligibilities.count > 0\n end", "def cps_as_reviewer\n self.roles_as_reviewer.collect { |x| CriticalProcess.where(:cp_secondary_id => x.critical_process_id) }.flatten.uniq\n end", "def validate_profile(params)\n db = connect_to_db()\n db.results_as_hash = true\n\n result = db.execute('SELECT id FROM users where id=?', params[\"id\"].to_i)\n\n if !result.empty?()\n return true\n else\n return false\n end\n end", "def add_person_proxy\n search_response = mpi_service.find_profile_by_attributes_with_orch_search(first_name: user_first_name,\n last_name: user_last_name,\n birth_date: user_birth_date,\n ssn: user_ssn,\n edipi: user_edipi)\n if search_response.ok?\n @mvi_response = search_response\n add_response = mpi_service.add_person_proxy(last_name: search_response.profile.family_name,\n ssn: search_response.profile.ssn,\n birth_date: search_response.profile.birth_date,\n icn: search_response.profile.icn,\n edipi: search_response.profile.edipi,\n search_token: search_response.profile.search_token,\n first_name: search_response.profile.given_names.first)\n add_ids(add_response) if add_response.ok?\n add_response\n else\n search_response\n end\n end", "def rights_facet\n raw = @xml.at('//userestrict[1]').to_s\n open('/tmp/output', 'a') { |f| f << \"!! #{raw}\\n\" } \n if raw=~/[Pp]ublic [Dd]omain/ \n return \"Public Domain\"\n elsif raw=~/[Pp]ublic [Rr]ecord/ \n return \"Public Records\"\n elsif raw=~/Creator retains literary rights/\n return \"Creator retains literary rights.\"\n else\n return \"Other\"\n end\n end", "def all_competitor_results\n nil\n end", "def all_competitor_results\n nil\n end", "def all_competitor_results\n nil\n end", "def name_of_guru_completeness\n cal_completeness(SadhakProfile::REQUIRED_FIELD_FOR_NAME_OF_GURU)\n end", "def all_competitor_results\n nil\n end", "def all_competitor_results\n nil\n end", "def find_bad_students(data)\n students = Set.new(Student.where(hidden: false).all.pluck(:user_name))\n data.map { |_, *memberships| memberships }.flatten.reject { |student| students.include?(student) }\n end", "def index\n @profile = Profile.exclude_blank_profiles.where.not(id: current_runner.profile.id)\n if params[:q].present?\n p params[:q][:username_eq]\n @profile = @profile.where(:pace => params[:q][:pace_eq]) if params[:q][:pace_eq].present?\n @profile = @profile.where(:gender => params[:q][:gender_eq]) if params[:q][:gender_eq].present?\n @profile = @profile.where(:age => params[:q][:age_eq]) if params[:q][:age_eq].present?\n @profile = @profile.where(:runningregion => params[:q][:runningregion_eq]) if params[:q][:runningregion_eq].present?\n @profile = @profile.where(\"username ILIKE ?\", \"%#{params[:q][:username_eq]}%\") if params[:q][:username_eq].present?\n else\n params[:q] = { :pace_eq => \"\", :gender_eq => \"\", :age_eq => \"\", :runningregion_eq => \"\", :username_eq => \"\" }\n end\n # @profile = Profile.all\n # if params[:q].present?\n # p params[:q]\n # @profile = Profile.all\n # end\n # @search = Profile.search(params[:q])\n end", "def profile\n if @profile\n return @profile\n end\n\n @profile ||= begin\n h = profile_xml_to_hash(@catalog.search @route => @name )\n @new = false\n h\n rescue RestClient::ResourceNotFound\n # The resource is new\n @new = true\n {}\n end.freeze\n end", "def ssn_merge_bad\n\t\t@objs = Person.find(:all, :conditions => ['ssn in (?)', BAD_SSNS], :order => 'id desc')\n\tend", "def most_likely_duplicate\n possible_matching_people.first\n end", "def is_reviewer?\n self.reviewer_role != nil\n end", "def get_bad_requirements(profile)\n bad_reqs = []\n @requirements.each do |rk, v|\n k = rk.to_sym\n expected = k != :vuln_test ? v : 'true'\n\n vprint_status(\"Comparing requirement: #{k}=#{expected} vs #{k}=#{profile[k]}\")\n\n if k == :activex\n bad_reqs << k if has_bad_activex?(profile[k])\n elsif k == :vuln_test\n bad_reqs << k unless profile[k].to_s == 'true'\n elsif v.is_a? Regexp\n bad_reqs << k if profile[k] !~ v\n elsif v.is_a? Proc\n bad_reqs << k unless v.call(profile[k])\n else\n bad_reqs << k if profile[k] != v\n end\n end\n\n bad_reqs\n end", "def profile; end", "def profile; end", "def notators\n find_related_frbr_objects( :is_notated_by, :which_roles?) \n end", "def get_recommender( recommender )\n if ( !(recommender[:id]==\"private\") and \n !(recommender[:firstName]==\"private\") and \n !(recommender[:lastName]==\"private\") ) \n Rails.logger.debug \"DEBUG Recommender Info Availabling, making dispatch\"\n @countdown.add(1)\n dispatch_recommender( recommender[:id])\n end\n end", "def clean_user_profile(profile)\n keys = %w(jobTitle gender aboutMe phoneNumber mobile street city email\n state familyName country givenName postalCode)\n\n profile.delete_if { |k, _v| !keys.include?(k) }\n end", "def profile(name)\n @statistics[:profiles][name] ||= 0\n end", "def skip_user_details?\n org_details[:skip_user_details]\n end", "def no_users\n return User.find_by_sql(\"SELECT users.*, ru.*\n FROM users users\n LEFT OUTER JOIN roles_users AS ru ON users.id=ru.user_id\n WHERE ru.role_id IS NULL OR ru.role_id not in (select id from roles where name = '#{self.name}')\")\n end", "def is_reviewer?(user)\n review_result = self.design_review_results.detect { |drr| drr.reviewer == user }\n review_result != nil\n end", "def parse_profile\n load_profile_data\n # get the buddies\n @buddies = @profile_data.search(\"div[@class='buddies']//a\").map{|b| b['href'].split('/').last; }\n @buddies.reject!{|b| b.to_i == 0}\n # title and genre are in the same element\n titlegenre = @profile_data.search(\"div[@class='titlegenre']\").text.split(\"Genre:\")\n unless titlegenre.empty?\n @genre[:name] = titlegenre.last.strip\n @novel[:title] = titlegenre.first.gsub('Novel:','').strip\n else\n @genre[:name] = \"\"\n @novel[:title] = \"\"\n end\n # finally, the region is annoying to grab\n @rid = @profile_data.search(\"div[@class='infoleft']//a\").first['href'].split('/').last\n nil\n end", "def compare_profile_data\n puts \"Step 11: Comparing Freelancer Profile data\"\n parent = $freelancers_card_data[@index]\n child = @profile_data\n puts \"for freelancer #{parent[:name]}, comparing results page fields with internal page fields:\"\n [:description, :title, :skills].each do |field|\n verify_details(parent, child, field, parent[:name])\n end\n puts \"All results are printed successfully\"\n\n end", "def test_validate_new_profile\n u = users(:user_without_profile)\n p = u.profile\n assert p.valid?, \"new blank profile starts off valid\"\n end", "def viewers #returns people\n people = Rating.all.map do |rating|\n if rating.title == self.title\n rating.viewer\n end\n end\n people.map do |peo|\n peo.full_name\n end.uniq\n end", "def vamp_test(prof)\n\tresults = \"Results inconclusive.\"\n\tif $vamp_names.include?(prof[:name])\n\t\tresults = \"Definitely a vampire.\"\n\telsif prof[:is_age] == false && prof[:likes_garlic] ==\"n\" && prof[:wants_insurance] == \"n\"\n\t\tresults = \"Almost certainly a vampire.\"\n\telsif prof[:allergies].include?(\"sunshine\") || (prof[:is_age] == false && (prof[:likes_garlic] == \"n\" || prof[:wants_insurance] == \"n\"))\n\t\tresults = \"Probably a vampire.\"\t\n\telsif prof[:is_age] != false && (prof[:likes_garlic] == \"y\" || prof[:wants_insurance] == \"y\")\n\t\tresults = \"Probably not a vampire.\"\n\telse\n\t\tresults\n\tend\nend", "def profiles; end", "def xml_query_profile(xml) \n if current_user \n profile_name = (xml.root.get_elements('AccessProfile').first || empty).text \n profile_name = 'public' unless profile_name \n @profile = current_user.profiles.find_by_title(profile_name) \n return render(:text => \"<Response>bad profile</Response>\") unless @profile \n \n properties = @profile.properties.map{|p| p.property_type.title }.join(',') \n return render(:text => \"<Response>#{properties}</Response>\") \n end \n render(:text => \"<Response>Internal Error</Response>\") \n end", "def competitor_result(_competitor)\n nil\n end", "def competitor_result(_competitor)\n nil\n end", "def my_peer_results(user)\n results = []\n (self.my_roles(user) - self.my_assigned_roles(user)).each do |role|\n results << self.design_review_results.detect { |drr| drr.role == role }\n end\n results\n end", "def test_unexistent_non_member_registering\n\t\tregistering_non_member = Enrollment.new(:participantID => \"abc12345\", :courseID => \"yoga0123\")\n\t\tassert Course.find_by(courseID: registering_non_member.courseID), \"Course is not in Courses database\"\n\t\tassert !Participant.find_by(participantID: registering_non_member.participantID), \"non existent non member was found in Participant database\"\n\tend", "def reshare_institution_names(model)\n # Get unique names where the parent is null\n model::Reshare::DirectoryEntry.select(:de_name)\n .where(de_parent: nil)\n .where.not(de_name: 'Ivy Plus Libraries Confederation')\n .group(:de_name)\n .order(:de_name)\n .count\n .keys\n end", "def find_paternal_uncle(person)\n parent = find_parent(person)\n parentObject = find_person(parent)\n\n if parentObject.female?\n parent = find_spouse(parent)&.name\n end\n\n find_sibling_brothers(parent)\n .reject { |sibling| sibling == parent }\n end", "def improvisors\n find_related_frbr_objects( :is_improvised_by, :which_roles?) \n end", "def improvisors\n find_related_frbr_objects( :is_improvised_by, :which_roles?) \n end", "def retro_add(community)\n i = 0\n users = community.users.reject { |u| u.resident.present? }\n\n users.each do |u|\n i += 1\n if i % 10 == 0\n puts \"Record ##{i}\"\n end\n\n addr = u.address_correlate\n\n r = Resident.create(\n :community => community,\n :first_name => u.first_name,\n :last_name => u.last_name,\n :address => u.address,\n :email => u.email,\n :street_address => addr,\n :user => u,\n :community_id => community.id\n )\n end\nend", "def fetch_profiles\n UI.message \"Fetching profiles...#{Sigh.config[:app_identifier]}\"\n results = profile_type.find_by_bundle_id(Sigh.config[:app_identifier])\n\n #Take the provisioning profile name into account\n #if Sigh.config[:provisioning_name].to_s.length > 0\n #filtered = results.select { |p| p.name.strip == Sigh.config[:provisioning_name].strip }\n #if Sigh.config[:ignore_profiles_with_different_name]\n #results = filtered\n #else\n #results = filtered if (filtered || []).count > 0\n #end\n #end\n\n if results \n return [results]\n else\n return []\n end\n \n\n\n #return results if Sigh.config[:skip_certificate_verification]\n\n #return results.find_all do |a|\n ## Also make sure we have the certificate installed on the local machine\n #installed = false\n #a.certificates.each do |cert|\n #file = Tempfile.new('cert')\n #file.write(cert.download_raw)\n #file.close\n #installed = true if FastlaneCore::CertChecker.installed?(file.path)\n #end\n #installed\n #end\n end", "def set_profile\n @profile = Profile.includes(user: {reviewee: {reviewer: [:profile]}}).find(params[:id])\n end", "def non_registered_ad_users\n all_active_directory_users.select{|user| user.non_registered?}\n end", "def siri_require_profanity_filter\n return @siri_require_profanity_filter\n end", "def which_profile(other_user)\n #Currently runs two database queries to return the viewable profile of the other...can it be done faster/more efficiently?\n return self.next_closest_profile(self.which_ring(other_user))\n\n # if other_user == self\n # return this_profile(1)\n # elsif is_mutual_friend?(other_user) == true \n # friendship_ring = self.which_ring(other_user)\n # return this_profile(friendship_ring)\n # else\n # return self.profiles.find_by_ring(self.preference.rings)\n # end\n end", "def competitor_result(competitor)\n nil\n end" ]
[ "0.57742465", "0.55844605", "0.5362191", "0.52931607", "0.52541614", "0.52518713", "0.52007985", "0.5175641", "0.51248634", "0.5113948", "0.509429", "0.50562435", "0.50559705", "0.5047303", "0.50360304", "0.5018535", "0.50017405", "0.4994866", "0.4987648", "0.49832666", "0.4979732", "0.49604684", "0.49540433", "0.49534312", "0.4937071", "0.49113753", "0.49113002", "0.49068254", "0.49067363", "0.4890672", "0.4869384", "0.4869384", "0.4867342", "0.48550388", "0.4837802", "0.48376778", "0.48373577", "0.48364335", "0.48345983", "0.483222", "0.48305613", "0.4825847", "0.48002753", "0.47960156", "0.47894955", "0.4786245", "0.4786245", "0.47823912", "0.47685713", "0.47660676", "0.47640812", "0.4753851", "0.4749549", "0.47495455", "0.47489405", "0.47485214", "0.47460684", "0.47460684", "0.47460684", "0.47460684", "0.47460684", "0.47460684", "0.47459608", "0.47420558", "0.4721719", "0.47211197", "0.47175518", "0.4717194", "0.4697673", "0.46941444", "0.46941444", "0.46939677", "0.468845", "0.4687287", "0.46839803", "0.46836066", "0.4682591", "0.4676318", "0.4669156", "0.46656117", "0.4665186", "0.46629906", "0.46615767", "0.46603817", "0.46599486", "0.46597087", "0.46597087", "0.4658582", "0.46525365", "0.4649653", "0.4647319", "0.46438643", "0.46438643", "0.4640512", "0.46345216", "0.46340126", "0.4632459", "0.46265694", "0.46207452", "0.46193662" ]
0.62510306
0
Indicate whether the user can make LEO requests.
def can_use_leo? faculty? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_access?\n allows_current_user_access_to? :access\n end", "def can_make_leaderbit_active?\n system_admin?\n end", "def requestable?\n (ill? || available? || recallable? ||\n processing? || on_order? || offsite? || ezborrow?)\n end", "def has_access?\n true\n end", "def has_access?\n true\n end", "def can_access user\n return self.users.include? user\n end", "def request_allowed?(request)\n true\n end", "def can_request\n return true if is_requested\n\n return true if both_user_verified? && !friend_request_exists?\n\n false\n end", "def can_open?\n\t\treturn true\n\tend", "def can_request?(user)\n self.is_active &&\n self.is_visible &&\n user.is_captain? &&\n ! self.teams.include?(user.team) &&\n ! self.is_finished?\n end", "def can_access?(user)\n user == self.user\n end", "def allow_access\n !current_cas_user.nil?\n end", "def open_to_public?\n allow_external_students? || allow_external_volunteers?\n end", "def allow_access\n !@current_user.nil?\n end", "def allows_current_user_access_to?(_perform, _with_options = nil)\n return true unless master_user\n end", "def allows_response?(responder=nil)\n self.active? && self.open?\n end", "def can?\n current_user\n end", "def has_privilege?\n has_all? || has_direct?\n end", "def open_access_pending?\n !open_access? && request_for_visibility_change==Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC\n end", "def has_access\n if !current_user\n return false\n elsif current_user.mtu_id != @player.mtu_id && !Player.exists?(mtu_id: current_user.mtu_id, committee: true)\n return false\n end\n return true\n end", "def privileged_access?\n connected? || PrismicService.access_token\n end", "def can_edit?\n return !@energy_usage.approved? || current_user.manager? \n end", "def loan_officers?\n\t\t!!current_admin || !!current_loan_manager || !!current_accountant\n\tend", "def enable_on_behalf_requestors_to_add_access\n return @enable_on_behalf_requestors_to_add_access\n end", "def can_create_competitors_at_lane_assignment?\n usa?\n end", "def can_create_competitors_at_lane_assignment?\n usa?\n end", "def action_allowed?\n current_user_has_ta_privileges?\n end", "def action_allowed?\n current_user_has_ta_privileges?\n end", "def viewable_by?(user)\n Sugar.public_browsing? || user ? true : false\n end", "def from_expert?\n !anonymous? && user.is_expert?\n end", "def publicly_available?\n return false unless access_rights.present?\n\n access_rights.none? do |value|\n value == 'deny' || %w[allow:icus allow:pdus].include?(value)\n end\n end", "def check_can_access\n res = false\n read_actions = [ \"index\", \"list\", \"edit\" ]\n new_actions = [ \"new\", \"create\" ]\n edit_actions = [ \"edit\", \"update\", \"destroy\", \"update_logo\" ]\n\n res ||= (action_name == \"show_logo\")\n res ||= current_user.admin?\n\n if current_user.option_externalclients?\n res ||= (current_user.read_clients? and read_actions.include?(action_name))\n res ||= (current_user.edit_clients? and edit_actions.include?(action_name))\n res ||= (current_user.create_clients? and new_actions.include?(action_name))\n end\n\n if !res\n flash[\"notice\"] = _(\"Access denied\")\n redirect_from_last\n end\n end", "def access action\n\t\tif current_user\n \treturn true\n else\n \treturn false\n end\n\n\tend", "def manage?\n super || (@user && @user.is_curator?)\n end", "def otr_api_call?\n current_user.present? && request.headers['X-0-Hub'] == '1'\n end", "def has_access\n if !current_user\n redirect_to \"/error\"\n return false;\n end\n return true\n end", "def can_be_accessed_by?(advocate)\n !!accessors.find(:first, :conditions => [\"accesses.requestor_id = ?\", advocate.id])\n end", "def authority?\n false\n end", "def can_super_admin?\n can_add_orgs? || can_grant_api_to_orgs? || can_change_org?\n end", "def can_access user\n list = List.find(self.list_id)\n\n return list.can_access user\n end", "def allowed?(request)\n name = request.call.intern\n namespace = request.handler.intern\n method = request.method.intern\n\n read\n\n if @rights.include?(name)\n return @rights[name].allowed?(request.name, request.ip)\n elsif @rights.include?(namespace)\n return @rights[namespace].allowed?(request.name, request.ip)\n end\n false\n end", "def can_activate?\n if custom?\n unless server.blank? || port.blank? || username.blank? || password.blank? || from_address.blank?\n true\n else\n false\n end\n elsif wundercoach_standard?\n unless replyto_address.blank?\n true\n else\n false\n end\n end\n end", "def can_super_admin?\n return self.can_add_orgs? || self.can_grant_api_to_orgs? || self.can_change_org?\n end", "def can_be_accessed_by?(user)\n if visibility == 'public'\n return true\n elsif visibility == 'buddies' && organization.battle_buddy_list.include?(user.organization_id)\n return true\n elsif visibility == 'shared' && buddy_list.split(',').include?(user.organization_id.to_s)\n return true\n elsif visibility == 'executive' && user.is_executive? && organization.users.include?(user)\n return true\n elsif ['private','buddies','shared'].include?(visibility) && organization.users.include?(user)\n return true\n else\n return false\n end\n end", "def read_allowed?(user)\n true\n end", "def isAllowUser(request) \n return httpRequest('check_newuser',request)\n end", "def has_direct?\n @privileges.fetch(@target).include?(@requisite)\n end", "def active_leave_org_request_present?\n return false if @context.guest?\n\n current_user.active_leave_org_request.present?\n end", "def guest_access?\n guest_access == :can_join\n end", "def traveler?\n !admin_or_staff? && !superuser?\n end", "def viewable?\n !!status[:viewable]\n end", "def user_authorizes_the_request?(request)\n request.post? && referrer_is_self?(request)\n end", "def allows?(uri)\n return true if everyone_allowed_everywhere?\n return false if noone_allowed_anywhere\n return true if current_agent_allowed?(uri) \n end", "def can_be_assigned?(_user)\n false # any user can complete operation\n end", "def has_access(developer)\r\n current_user.id == developer.id\r\n end", "def has_leave_plugin_access\r\n\t\t\t\tcan_create_leave_requests || can_manage_leave_requests || can_be_consulted_leave_requests || can_be_notified_leave_requests\r\n\t\t\tend", "def has_admin_access?\n admin? || moderator?\n end", "def can_access?(space = object)\n space.accessible_by_user?(current_user)\n end", "def user_can_see?(user)\n !self.private || self.is_owner?(user)\n end", "def can_access?(kase)\n ca = self.access_to?(kase)\n ca || (!ca && (self.total_contacts_count > 0 || self.can_purchase_flex_contacts? || self.unlimited_premium_contacts?))\n end", "def check_service_learning_position_permission \n unless @current_user.in_unit?(Unit.find_by_abbreviation(\"carlson\")) || @current_user.in_unit?(Unit.find_by_abbreviation(\"pipeline\")) || @current_user.in_unit?(Unit.find_by_abbreviation(\"bothell\"))\n require_user_unit @unit\n end\n end", "def enabled?\n user.present?\n end", "def can_user_access?(user)\n if user.is_account_holder_or_administrator? || self.is_user_tagged_to_team?(user)\n true\n else\n false\n end\n end", "def can_add_orgs?\n perms.include? Perm.add_orgs\n end", "def can_add_orgs?\n perms.include? Perm.add_orgs\n end", "def ensure_is_authorized_to_view\n @is_member_of_company = (@relation == :company_admin_own_site || @relation == :company_employee || @relation == :rentog_admin_own_site)\n\n # ALLOWED\n return if @relation == :rentog_admin ||\n @relation == :rentog_admin_own_site ||\n @relation == :domain_supervisor ||\n @relation == :company_admin_own_site\n\n\n # NOT ALLOWED\n # with error message\n flash[:error] = t(\"listing_events.you_have_to_be_company_member\")\n redirect_to root\n return false\n end", "def manage_brandreach?\n user.admin? || user.super_admin?\n end", "def can_grant_api_to_orgs?\n perms.include? Perm.grant_api\n end", "def can_grant_api_to_orgs?\n perms.include? Perm.grant_api\n end", "def check_user_access\n check_access_and_redirect(@request)\n end", "def viewable?(user)\n !deleted && !hidden?\n end", "def actions_available?(user)\n actions_allowable?(user)\n end", "def able_to_operate?(_entity, _train, _name)\n true\n end", "def is_view_permitted?(given_user = nil)\n given_user ||= self.current_actor\n\n # Guests can't see circles unless they log in\n return false if given_user.guest?\n \n # Oh look, it's me\n return true if given_user.is_self_or_owner?(self.user)\n \n # Fine, let's check the db\n return Relationship.has_follower?(self.user, given_user, self.levels_can_see)\n end", "def can_approve_member?\n\t\t[1,2].include? level\n\tend", "def create?\n @current_user.permission('Donor', :clerk)\n end", "def define_eccept\n if current_user.info.id == @resource.id || can_manage_has_one(current_user.info, @resource, Info)\n true\n else\n redirect_to root_path\n end\n end", "def tiene_permiso?\n if not protect?(action_name)\n return true\n end\n if @session['user'] and autorizado?(@session['user'], controller_name)\n return true\n end\n store_location\n access_denied\n return false\n end", "def is_potential_user?\n\t\ttrue\n\tend", "def request?\n self.operation == OP_REQUEST\n end", "def valid?\n target_in_privileges? && has_privilege?\n end", "def define_eccept\n if current_user.info.id==@resource.id || can_manage_has_one(current_user.info, @resource, @model)\n return true\n else\n redirect_to root_path \n end\n end", "def is_staff?\n can_manage_course? ||\n can_manage_assignments? ||\n can_grade_submissions? ||\n can_view_other_submissions?\n end", "def user_can_view?(_check_user)\n true # everyone can view these\n end", "def canBeReadBy? user\n unless user.class == Modeles::User\n username = user.to_s\n user = Modeles::User.find_by_name username\n unless user\n @errors << \"User #{username} doesn't exists\"\n return false\n end\n end\n if user.isAdmin == 1\n return true\n elsif user.name == @user\n if @userRights >= 4\n return true\n else\n return false\n end\n elsif isIncludedIn? user.groups, @group\n if @groupRights >= 4\n return true\n else\n return false\n end\n else\n if @othersRights >= 4\n return true\n else\n return false\n end\n end\n end", "def local_request?\n current_user && current_user.has_role?('Admin')\n end", "def permission?()\n return nil\n end", "def create?\n @current_user.permission('Fdp', :clerk)\n end", "def made_request?(user)\n all_users.include?(user)\n end", "def manage?\n @user && @user.is_admin?\n end", "def authorize?(user)\n user && user.moderator?\n end", "def can_org_admin?\n return self.can_grant_permissions? || self.can_modify_guidance? ||\n self.can_modify_templates? || self.can_modify_org_details?\n end", "def liaison?\n role == 'liaison'\n end", "def gr_is_visible?\n eval_policy(:read_access)\n end", "def can_lock?\n SpaceRequestPolicy.can_lock?(current_user, object)\n end", "def openable?\n resp = connection.get do |req|\n req.url \"#{base_path}/openable\"\n end\n\n raise_exception_based_on_response!(resp) unless resp.success?\n\n case resp.body\n when 'true'\n true\n when 'false'\n false\n else\n raise MalformedResponse, \"Expected true or false, not #{resp.body}\"\n end\n end", "def create?\n @current_user.permission('Commodity', :clerk)\n end", "def can_mint_doi?\n open_access?\n end", "def readable_by?(user)\n !resource.archived? || (user.is_admin? || is_mill?(user))\n end", "def create_preliminary_result?\n record.unlocked? && view_access?\n end" ]
[ "0.6835903", "0.68082494", "0.67199904", "0.66991717", "0.66991717", "0.6541649", "0.6534193", "0.65265447", "0.64978856", "0.64619035", "0.6459172", "0.6442419", "0.64302295", "0.6411048", "0.640631", "0.6359368", "0.63518286", "0.63334036", "0.6331683", "0.63188004", "0.6307138", "0.6305506", "0.630513", "0.6300826", "0.629716", "0.629716", "0.62901783", "0.62901783", "0.62846947", "0.62797785", "0.6267801", "0.62643903", "0.625216", "0.62509274", "0.6241022", "0.6238244", "0.6235826", "0.6229621", "0.6229247", "0.6202202", "0.6184209", "0.6183737", "0.6168194", "0.6150932", "0.61454785", "0.61414", "0.6141185", "0.6135331", "0.6131366", "0.6128025", "0.6126134", "0.6124502", "0.6123622", "0.61203045", "0.61180365", "0.6113579", "0.610313", "0.6097644", "0.60966766", "0.60962546", "0.6089563", "0.6084634", "0.6084416", "0.6083829", "0.6083829", "0.60825324", "0.6081475", "0.6076643", "0.6076643", "0.6074333", "0.6072545", "0.60709745", "0.60698265", "0.60680306", "0.60662264", "0.6062203", "0.605518", "0.6051459", "0.6050351", "0.60441864", "0.604024", "0.6034821", "0.60300803", "0.6026478", "0.60223156", "0.6018311", "0.60156465", "0.601491", "0.6011722", "0.60102373", "0.6009636", "0.60025334", "0.5991033", "0.59892094", "0.598909", "0.598863", "0.5985625", "0.5982783", "0.597233", "0.5971278" ]
0.6672446
5
Indicate whether the user can make Interlibrary Loan requests.
def can_use_ill? !virginia_borrower? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_access?\n allows_current_user_access_to? :access\n end", "def rollcall_isd_required\n if current_user.has_non_public_role?(:rollcall)\n return true\n else\n redirect_to :action => \"unauthorized\", :controller => 'rollcall/rollcall_app'\n return false\n end\n end", "def loan_officers?\n\t\t!!current_admin || !!current_loan_manager || !!current_accountant\n\tend", "def can_make_leaderbit_active?\n system_admin?\n end", "def can_request_scanning?\n true # TODO: Should this be !virginia_borrower? ?\n end", "def has_access?\n true\n end", "def has_access?\n true\n end", "def otr_api_call?\n current_user.present? && request.headers['X-0-Hub'] == '1'\n end", "def privileged_access?\n connected? || PrismicService.access_token\n end", "def can_access?(kase)\n ca = self.access_to?(kase)\n ca || (!ca && (self.total_contacts_count > 0 || self.can_purchase_flex_contacts? || self.unlimited_premium_contacts?))\n end", "def nocirc_loan?\n @type.present? && @type['id'] == '2e48e713-17f3-4c13-a9f8-23845bb210a4'\n end", "def publicly_available?\n return false unless access_rights.present?\n\n access_rights.none? do |value|\n value == 'deny' || %w[allow:icus allow:pdus].include?(value)\n end\n end", "def can_open?\n\t\treturn true\n\tend", "def allow_access\n !current_cas_user.nil?\n end", "def can_approve_member?\n\t\t[1,2].include? level\n\tend", "def rollcall_required\n if current_user.is_rollcall_user?\n return true\n else\n redirect_to :action => \"unauthorized\", :controller => 'rollcall/rollcall_app'\n return false\n end\n end", "def can_request\n return true if is_requested\n\n return true if both_user_verified? && !friend_request_exists?\n\n false\n end", "def allows?(uri)\n return true if everyone_allowed_everywhere?\n return false if noone_allowed_anywhere\n return true if current_agent_allowed?(uri) \n end", "def can_mint_doi?\n open_access?\n end", "def requestable?\n (ill? || available? || recallable? ||\n processing? || on_order? || offsite? || ezborrow?)\n end", "def can?\n current_user\n end", "def can_be_loaned_for_solr\n result = \"no\"\n result = \"yes\" if available_for_loan == true\n result\n end", "def luxury_search_authorized?\n authorized_for?(:action => :read)\n end", "def check_access\n permission_denied unless can_census?(year)\n end", "def can_request?(user)\n self.is_active &&\n self.is_visible &&\n user.is_captain? &&\n ! self.teams.include?(user.team) &&\n ! self.is_finished?\n end", "def is_rollcall_admin?\n is_admin?('rollcall')\n end", "def loyalty_enabled?\n @loyalty_indicator\n end", "def can_view_patient_laboratories?\n has_role?(:public_health) || has_role?(:public_health_enroller)\n end", "def request_allowed?(request)\n true\n end", "def allows_response?(responder=nil)\n self.active? && self.open?\n end", "def must_authenticate \n if @authenticated_user && (@user_is_viewing_themselves != false)\n return true\n else\n request_http_basic_authentication(\"Social bookmarking service\") \n return false\n end \n end", "def rollcall_admin_required\n if current_user.is_rollcall_admin?\n return true\n else\n redirect_to :action => \"unauthorized\", :controller => 'rollcall/rollcall_app'\n return false\n end\n end", "def active_for_authentication? \n \tsuper && approved?\n \t\n\tend", "def authority?\n false\n end", "def can_precheck_borrow_direct?(request)\n return false unless @use_bd_api\n\n isbn(request).present?\n end", "def liaison?\n role == 'liaison'\n end", "def allow_access\n !@current_user.nil?\n end", "def open_to_public?\n allow_external_students? || allow_external_volunteers?\n end", "def action_allowed?\n current_user_has_ta_privileges?\n end", "def action_allowed?\n current_user_has_ta_privileges?\n end", "def can_use_api?\n perms.include? Perm.use_api\n end", "def can_use_api?\n perms.include? Perm.use_api\n end", "def allows_current_user_access_to?(_perform, _with_options = nil)\n return true unless master_user\n end", "def has_privilege?\n has_all? || has_direct?\n end", "def isAllowUser(request) \n return httpRequest('check_newuser',request)\n end", "def active_for_authentication?\n # User is approved when harp_id is assigned.\n # Approved flag is set programmatically when harp_id is set by an admin.\n super && is_approved?\n end", "def alert_user?\n # check the three necessary conditions\n # in order of increasing cost\n self.enabled? && have_statuses_changed?\n end", "def can_view_patient_close_contacts?\n has_role?(:public_health) || has_role?(:public_health_enroller)\n end", "def active_for_authentication?\n super && !banned\n end", "def can_log_in?\n !disabled\n end", "def check_can_access\n res = false\n read_actions = [ \"index\", \"list\", \"edit\" ]\n new_actions = [ \"new\", \"create\" ]\n edit_actions = [ \"edit\", \"update\", \"destroy\", \"update_logo\" ]\n\n res ||= (action_name == \"show_logo\")\n res ||= current_user.admin?\n\n if current_user.option_externalclients?\n res ||= (current_user.read_clients? and read_actions.include?(action_name))\n res ||= (current_user.edit_clients? and edit_actions.include?(action_name))\n res ||= (current_user.create_clients? and new_actions.include?(action_name))\n end\n\n if !res\n flash[\"notice\"] = _(\"Access denied\")\n redirect_from_last\n end\n end", "def from_expert?\n !anonymous? && user.is_expert?\n end", "def check_service_learning_position_permission \n unless @current_user.in_unit?(Unit.find_by_abbreviation(\"carlson\")) || @current_user.in_unit?(Unit.find_by_abbreviation(\"pipeline\")) || @current_user.in_unit?(Unit.find_by_abbreviation(\"bothell\"))\n require_user_unit @unit\n end\n end", "def open_access_pending?\n !open_access? && request_for_visibility_change==Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC\n end", "def access action\n\t\tif current_user\n \treturn true\n else\n \treturn false\n end\n\n\tend", "def can_grant_api_to_orgs?\n perms.include? Perm.grant_api\n end", "def can_grant_api_to_orgs?\n perms.include? Perm.grant_api\n end", "def locally_available?(request)\n UmlautBorrowDirect.locally_available? request\n end", "def enable_on_behalf_requestors_to_add_access\n return @enable_on_behalf_requestors_to_add_access\n end", "def lent_out?\n @@on_loan.include?(self)\n end", "def can_donate?\n\t\tprovider.in? [\"facebook\", \"twitter\"]\n\tend", "def authorize?(user)\n user && user.moderator?\n end", "def active_for_authentication?\n super && !banned?\n end", "def inbound_request?\n requester == 'inbound'\n end", "def active_for_authentication?\n super && self.approved?\n end", "def access\n if @ajar == true || if @unlocked == false\n raise ArgumentError.new(\"Further permissions required\")\n elsif @ajar == false && if @unlocked == true\n puts \"your wish is granted\"\n return @ajar = true\n end\n end\n end\n end", "def lent_out?\n if @@on_loan.include?(self) == true\n true\n else\n false\n end\n end", "def lent_out?\n if @@on_loan.include?(self)\n return true\n else\n return false\n end\n end", "def last_request_update_allowed?\n !session[:sudo]\n end", "def can_edit?\n return !@energy_usage.approved? || current_user.manager? \n end", "def lent_out?\n return @@on_loan.include?(self)\n end", "def has_access\n if !current_user\n redirect_to \"/error\"\n return false;\n end\n return true\n end", "def has_loan_type_conditions?\n loan_type_uids != LOAN_TYPE_UIDS\n end", "def current_user_can(access_types)\n current_user.id == @list.user_id || access_types.include?(current_user.access_to_list(@list))\n end", "def can_use_leo?\n faculty?\n end", "def active_for_authentication? \n super && is_approved? \n end", "def can_create_opinion_note?\n allow! if permission_action.subject == :opinion_note\n end", "def rollcall_student_required\n if current_user.is_rollcall_epi? || current_user.is_rollcall_health_officer? || current_user.is_rollcall_nurse? ||\n current_user.is_rollcall_admin?\n return true\n else\n redirect_to :action => \"unauthorized\", :controller => 'rollcall/rollcall_app'\n return false\n end\n end", "def authorization_required\n authorized? || authorization_denied\n end", "def needs_permission_badge?\n solr_document.visibility != Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC\n end", "def active_for_authentication?\n super && approved?\n end", "def active_for_authentication?\n super && approved?\n end", "def active_for_authentication?\n super && approved?\n end", "def active_for_authentication?\n super && approved?\n end", "def active_for_authentication?\n super && approved?\n end", "def active_for_authentication?\n super && approved?\n end", "def active_for_authentication?\n super && approved?\n end", "def can_access user\n list = List.find(self.list_id)\n\n return list.can_access user\n end", "def is_rollcall_user?\n has_application?(:rollcall)\n end", "def manage?\n super || (@user && @user.is_curator?)\n end", "def viewable_by?(user)\n Sugar.public_browsing? || user ? true : false\n end", "def active_for_authentication?\n super && un_blocked?\n end", "def show\n authorize @labor_request\n end", "def active_for_authentication?\n super && approved?\n end", "def can_remind_patient?\n has_role?(:public_health) || has_role?(:public_health_enroller)\n end", "def has_direct?\n @privileges.fetch(@target).include?(@requisite)\n end", "def is_denied?\n return false if moderation_flag || moderation_flag == nil\n true\n end", "def permission?()\n return nil\n end", "def allowed?(request)\n name = request.call.intern\n namespace = request.handler.intern\n method = request.method.intern\n\n read\n\n if @rights.include?(name)\n return @rights[name].allowed?(request.name, request.ip)\n elsif @rights.include?(namespace)\n return @rights[namespace].allowed?(request.name, request.ip)\n end\n false\n end", "def gr_is_visible?\n eval_policy(:read_access)\n end" ]
[ "0.6588476", "0.6532069", "0.6531698", "0.6522074", "0.6485742", "0.6448632", "0.6448632", "0.64459956", "0.6398791", "0.6386855", "0.63670903", "0.6344715", "0.6311231", "0.6307324", "0.63029677", "0.6298655", "0.627857", "0.62715656", "0.6265863", "0.6244471", "0.6242587", "0.6239049", "0.6228338", "0.6225554", "0.6204869", "0.6162338", "0.6159861", "0.6130912", "0.6115309", "0.61147773", "0.6109209", "0.60931563", "0.6092211", "0.6091722", "0.6090722", "0.6090649", "0.6089574", "0.6076434", "0.6073941", "0.6073941", "0.60683835", "0.60683835", "0.6055063", "0.604571", "0.60396683", "0.60394055", "0.60366315", "0.60348606", "0.60330683", "0.6026272", "0.60242623", "0.6020187", "0.60176116", "0.6016072", "0.6007988", "0.6005416", "0.6005416", "0.5988383", "0.5986937", "0.5981274", "0.5980038", "0.596667", "0.59664327", "0.5963184", "0.59563565", "0.5950426", "0.59503853", "0.59476525", "0.5945999", "0.5943872", "0.59401447", "0.59380645", "0.5935432", "0.5927031", "0.5923952", "0.59169495", "0.5909796", "0.59075505", "0.59075063", "0.5905458", "0.5900904", "0.5900904", "0.5900904", "0.5900904", "0.5900904", "0.5900904", "0.5900904", "0.5900696", "0.58978647", "0.5884555", "0.58840156", "0.58821106", "0.58757675", "0.5874408", "0.586455", "0.5863266", "0.5855344", "0.5855285", "0.5854804", "0.5853212" ]
0.6187547
25
Indicate whether the user can place items on course reserve.
def can_make_reserves? !undergraduate? && !virginia_borrower? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_add_course?\n self.available_courses > 0 || self.clearance?\n end", "def can_create_reserve_schedule?\n kit_schedule = KitSchedule.new\n kit_schedule.current_user = User.current_user\n return kit_schedule.can_create_reserve?(self.center_ids)\n end", "def quantity_cat_allowed?(reservations = [])\n max = equipment_model.category.maximum_per_user\n return true if max == \"unrestricted\"\n #count number in category for given and reserver's reservations, excluding those that don't overlap\n if same_category_count(get_overlapping_reservations(reservations)) > max\n errors.add(:base, \"Cannot reserve more than \" + equipment_model.category.maximum_per_user.to_s + \" \" + equipment_model.category.name.pluralize + \".\\n\")\n return false\n end\n return true\n end", "def user_may_view_item?\n @pcp_item.pcp_step.released? || @pcp_item.pcp_step.in_commenting_group?\n end", "def can_supply?(required)\n total_on_hand >= required || backorderable?\n end", "def can_equip?(item, slot)\n item.allowed_slot == slot && items.include?(item)\n end", "def too_may_guests_in_room__true()\n if @guests.check_in_count() > @capacity\n return true\n end\n return false\n end", "def can_be_assigned?(_user)\n false # any user can complete operation\n end", "def check_buyable\n raise PermissionDeniedError, \"出品したアイテムはサポートできません\" if @item.owner?(current_user)\n end", "def can_reserve\n if !@contestproblem.in_correction? && !@contestproblem.in_recorrection? && !@contestsolution.official?\n redirect_to @contestproblem\n end\n end", "def has_places?\n capacity > 0\n end", "def item_usable?\r\n user.usable?(item) && item_effects_valid?\r\n end", "def item_usable?\n user.usable?(item) && item_effects_valid?\n end", "def valid?\n court && slot\n end", "def permit_equips(item)\n permit_plus = feature_array(:allow_equip_type).uniq\n item.w_types.each do |tipo|\n return true if permit_plus.include?(tipo)\n end\n false\n end", "def create?\n\t\tuser.course_grants > 0\n\tend", "def is_available?\n return self.available_inventory > 0\n end", "def collectable?\n can_supply? && collection? && !(on_hold? || fully_shipped?)\n end", "def restaurant_must_be_within_capacity\n unless self.restaurant.is_available?(self.begin_time, self.people)\n errors.add(:begin_time, \"is not available for \" + pluralize(self.people, \"person\"))\n end\n end", "def can_buy?(item)\r\n item.buyable_by?(self)\r\n end", "def acceptable_by?(user)\n return false unless user.has_role?(:admin, user.unit)\n resource.pending?\n end", "def permission_required \n render_403 unless admin? || @item.is_editable_by?(current_user)\n end", "def can_request_purchase?\n true # TODO: Should this be !virginia_borrower? ?\n end", "def can_buy?(item)\n item.buyable_by?(self)\n end", "def quantity_eq_model_allowed?(reservations = [])\n max = equipment_model.maximum_per_user\n return true if max == \"unrestricted\"\n #count number of model for given and reserver's reservations, excluding those that don't overlap\n if same_model_count(get_overlapping_reservations(reservations)) > max\n errors.add(:base, \"Cannot reserve more than \" + equipment_model.maximum_per_user.to_s + \" \" + equipment_model.name.pluralize + \".\\n\")\n return false\n end\n return true\n end", "def shippable?\n can_supply? && !(on_hold? || collection?)\n end", "def valid?\n court_slots.any?\n end", "def canRegister\n\t\tif(num_enrolled.to_i<capacity.to_i)\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\t\tend", "def plan_to_take_course?(course)\n taking_courses.where(:course_id => course).size >0\n end", "def reserved?(product)\n product.status == 'Reserved'\n end", "def is_permitted_for?( user )\n return true if user.privileged?\n\n # User is restricted. User can only see this object if it\n # has at least one task associated with it and at least one\n # of those associated tasks appears in the user's permitted\n # task list, so check the intersection of the two arrays.\n\n return ( self.tasks & user.tasks ).length > 0\n end", "def can_edit?(item)\r\n item.editable_by?(self)\r\n end", "def can_authorize?(user, a)\n user != self and may_authorize and\n (abilities | ADMIN_TASKS).include?(a)\n end", "def authorized?\n if !@extra_page.editable_by? current_user, current_cookbook\n redirect_to sections_path, alert: \"You are not allowed to edit this extra page.\"\n end\n end", "def seats_available?\n (capacity - total_enrollments) > 0\n end", "def can_activate?(item)\r\n item.activatable_by?(self)\r\n end", "def enable?(item)\n CookingManager.quantity(item) > 0\n end", "def is_admin\n \tif current_user.nil? or !current_user.user_attributes[:room_reserve_admin]\n return false\n else\n return true\n end\n end", "def can_edit?(item)\n item.editable_by?(self)\n end", "def course_is_available?(node)\n instructor_for_course?(node) || ta_for_course?(node)\n end", "def item_can_use?(item)\n return false unless item.is_a?(RPG::Item)\n return false if item_number(item) == 0\n if $game_temp.in_battle\n return item.battle_ok?\n else\n return item.menu_ok?\n end\n end", "def check_visibility\n raise Helpedia::ItemNotVisible unless @user.visible_for?(current_user)\n end", "def usable_item_conditions_met?(item)\r\n movable? && occasion_ok?(item)\r\n end", "def inventoriable?\n inventory?\n end", "def can_activate?(item)\n item.activatable_by?(self)\n end", "def action_allowed?\n ['Instructor',\n 'Teaching Assistant',\n 'Administrator'].include? current_role_name\n end", "def action_allowed?\n ['Instructor',\n 'Teaching Assistant',\n 'Administrator'].include? current_role_name\n end", "def action_allowed?\n ['Instructor',\n 'Teaching Assistant',\n 'Administrator'].include? current_role_name\n end", "def can_edit?\n return !@energy_usage.approved? || current_user.manager? \n end", "def action_allowed?\n ['Instructor', 'Teaching Assistant', 'Administrator'].include? current_role_name\n end", "def can_edit?(user)\n course.can_edit? user\n end", "def over_capacity\n if @students.count >= @capacity\n true\n else\n false\n end\n end", "def can_edit(user)\n\t\tif user\n\t\t\tcan_edit = user.courses.include?(self)\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend", "def volunteering_allowed?\n # As of today, cannot volunteer if project is in 'parking lot'\n if self.event.nil? then\n return false\n else\n return self.event.volunteering_enabled?\n end\n end", "def can_create_overdue_or_under_repair_schedule?\n kit_schedule = KitSchedule.new\n kit_schedule.current_user = User.current_user\n return kit_schedule.can_create_overdue_or_under_repair?(self.center_ids)\n end", "def requirements_unlocked_or_can_be?\n true\n end", "def can_create_competitors_at_lane_assignment?\n usa?\n end", "def can_create_competitors_at_lane_assignment?\n usa?\n end", "def create_items_page?\n items_shortcut != inventory_shortcut\n end", "def permitted_for_research_object?(item = self)\n if item.is_downloadable?\n item.can_download?(nil)\n else\n item.can_view?(nil)\n end\n end", "def view_allowed?(item)\n @view_allowed.to_a.map(&:to_sym).include?(item.to_sym)\n end", "def order_completable?\n force_completion || actual_end_at || reserve_end_at < Time.current\n end", "def inventory_item_is_available\n \tif self.inventory_item.present? && self.inventory_item.is_available?(project.rental_delivery, project.rental_pickup) == false\n \t\terrors.add(:inventory_item, \"is not available within this project's duration\")\n \telsif self.inventory_item.blank?\n \t\tself.inventory_item = inventory_style.find_available(project.rental_delivery, project.rental_pickup)\n \t\terrors.add(:inventory_style, \"has no available items within this project's duration\") if self.inventory_item.blank?\n \tend\n end", "def action_allowed?\n current_user_has_student_privileges?\n end", "def updatable_by?(user)\n user.admin_for?(resource.course)\n end", "def displace_item_must_be_displaceable\n return unless displace_item && fund_item\n unless displaceable_items.include?( displace_item )\n errors.add :displace_item, \"cannot be displaced by this item\"\n end\n end", "def available?\n self.available_product_supplies.length > 0 and not self.delete?\n end", "def within_limit_of?(item, user)\r\n @member_limits.fetch(user.email).has_resources_for?(item.price)\r\n end", "def can_edit?\n head(:forbidden) unless current_user.review_space_admin? || @space.editable_by?(current_user)\n end", "def available?(reservations = [])\n return true if self.class == Reservation && self.status != 'reserved'\n all_res = reservations.dup\n all_res << self if self.class != Reservation\n all_res.uniq!\n eq_objects_needed = same_model_count(all_res)\n if equipment_model.num_available(start_date, due_date) < eq_objects_needed\n errors.add(:base, equipment_model.name + \" is not available for the full time period requested.\\n\")\n return false\n end\n return true\n end", "def check_item_condition?\n # disallow usage if item button disabled\n return false if !$game_system.item_button\n # disallow usage\n item_condition = false\n # if using direct hotkeys\n if BlizzABS::Config::DIRECT_HOTKEYS\n # check direct hotkeys\n item_condition = self.item_hotkeys?\n # if item button pressed\n elsif Input.trigger?(Input::Item)\n # allow usage\n item_condition = true\n end\n # return result\n return item_condition\n end", "def is_authorized_to_create_offerings_at location\n if location.is_a? Store\n @a = Authorization.find_by_target_id_and_target_type_and_user_id(location, 'Store', id)\n end\n location = location.id if location.is_a? Location\n return true if authorized_to_authorize(Location.find(location))\n return true if is_authorized_to_edit_locations_of(Location.find(location).store_id)\n @a ||= Authorization.find_by_target_id_and_target_type_and_user_id(location, 'Location', id)\n @a && [1, 2, 10].include(@a.authorization_type)\n end", "def enable?(item)\n true#$game_party.usable?(item)\n end", "def has_resources_for?(price)\r\n return true if @organisation.limit.nil? || @organisation.is_admin?(@user)\r\n\r\n resources = @organisation.limit - (@spend + price)\r\n resources > 0\r\n end", "def permitted_to_publish?\n @pcp_subject.user_is_owner_or_deputy?( current_user, @pcp_subject.current_step.acting_group_index )\n end", "def can_supply?\n if has_variants?\n variants.any?(&:in_stock?)\n else\n master.in_stock?\n end\n end", "def create?\n @current_user.permission('Commodity', :clerk)\n end", "def request_permitted?(item)\n true\n end", "def licensed_by?(context)\n if context.guest?\n false\n else\n accepted_licenses.exists?(user_id: context.user_id, state: [nil, 'active'])\n end\n end", "def displayable_to_user?(user, cat=catalog)\n at_least_editor = user.catalog_role_at_least?(cat, 'editor')\n at_least_editor || !restricted?\n end", "def test_can_buy_org_item\n user = User.named(\"user\")\n org = Organization.named(\"org\")\n\n item = org.propose_item(\"Item\", 20, :fixed, nil, nil)\n item.activate\n\n assert(user.can_buy?(item))\n\n user.work_on_behalf_of(org)\n assert(!user.on_behalf_of.can_buy?(item))\n end", "def valid_assign(course_id,current_user)\n if current_user.typeofuser == \"admin\" then\n if current_user.tenant.pricing_plan.plan_group == \"assessment_only_plan\" then\n #uncomment the below code if we want to stop the admin while assigning only\n # if current_user.tenant.remaining_learner_credit > 0 then\n # return true\n # else\n # return false\n # end\n return true\n else\n max_learners_to_be_assigned = current_user.tenant.pricing_plan.no_of_users\n total_leaners_assigned = current_user.user.find(:all,:conditions=>[\"deactivated_at IS ?\",nil]).length\n\n if total_leaners_assigned <= max_learners_to_be_assigned\n return true\n else\n return false\n end\n end\n\n elsif current_user.typeofuser == \"individual buyer\" or current_user.typeofuser == \"corporate buyer\" then\n max_learners_to_be_assigned = BuyerSeller.find_by_course_id_and_buyer_user_id(course_id,current_user.id).no_of_license\n total_leaners_assigned = Learner.find_all_by_admin_id_and_course_id(current_user.id,course_id).length\n if total_leaners_assigned < max_learners_to_be_assigned - 1\n return true\n else\n return false\n end\n end\n end", "def duration_allowed?\n max_duration = equipment_model.category.maximum_checkout_length\n if max_duration == \"unrestricted\" || (self.class == Reservation && self.checked_in)\n return true\n elsif self.duration > max_duration\n errors.add(:base, equipment_model.name + \"cannot be reserved for more than \" + max_duration.to_s + \" days at a time.\\n\")\n return false\n else\n return true\n end\n end", "def has_stuff_required_for(item_class)\n item_class.required_supplies.each do |requirement|\n @supplies.any?{|s| s.is_a? requirement }\n end\n end", "def can_accept?\n SpaceMembershipPolicy.can_accept?(object, space_membership)\n end", "def can_add_product(p) \n university_id && \n ! products_unshipped_and_uncancelled.include?(p) &&\n ( ! p.premium? || univ_premium? ) # we can add non-prem products to any univ, or premium prods to premium univs\n end", "def enable?(item)\n return false if item.nil?\n return false unless has_recipebook?\n return false if item.tocrafting_gold_fee > $game_party.gold\n return false if $game_party.item_max?(item)\n return false unless have_tools?(item)\n return false unless have_actors?(item)\n return true if item.ingredient_list.empty?\n return have_ingredients?(item)\n end", "def editable_by?(user)\n !shipped? && !delivered?\n end", "def course_ok?(course)\n if course.publishable?\n true\n else\n flash[:error] = \"The course doesn't have any activities. Add some before publishing.\"\n false\n end\n end", "def can_read?(user)\n assignment.grades_released? || can_grade?(user)\n end", "def can_rent_truck?\n !license.expired? && age >= 60 && license.to_drive_truck?\n end", "def show?\n @current_user.permission('Commodity', :guest)\n end", "def not_renewable?\n return true unless self.class == CartReservation || self.status == \"reserved\"\n reserver.reservations.each do |res|\n if res.equipment_model == self.equipment_model && res.due_date.to_date == self.start_date.to_date && res.is_eligible_for_renew?\n errors.add(:base, res.equipment_model.name + \" should be renewed instead of re-checked out.\\n\")\n return false\n end\n end\n return true\n end", "def can_create_course?\n ptainstructors = Ptainstructor.find_by_semester_id(self.id)\n teachers = Teacher.find_by_semester_id(self.id)\n if ((ptainstructors == nil) or (teachers == nil))\n return false\n end\n return true\n end", "def canMakeTreasureVisible(t)\n \n end", "def can_put_in_foundation?\n (@pile_beneath.empty? && @card_to_drop.rank.ace?) ||\n (@card_beneath && foundation_conditions?(@card_beneath))\n end", "def valid?\r\n (forcing && item) || subject.usable?(item)\r\n end", "def publicly_available?\n return false unless access_rights.present?\n\n access_rights.none? do |value|\n value == 'deny' || %w[allow:icus allow:pdus].include?(value)\n end\n end", "def authorize_customer\n unless @reservation.customer == current_customer\n redirect_to reservations_url, notice: 'No touchy!'\n # edit this?\n end\n end", "def university_pending?\n university && line_items_pending_any?\n end" ]
[ "0.695287", "0.6828737", "0.67396617", "0.6489839", "0.64477384", "0.63922393", "0.63138723", "0.63077044", "0.627996", "0.62151104", "0.6207479", "0.6204981", "0.6193661", "0.61868215", "0.61826515", "0.61429346", "0.6136469", "0.6124357", "0.6121084", "0.6102407", "0.60767883", "0.6076406", "0.6062977", "0.60546285", "0.60244614", "0.6015443", "0.6003551", "0.6000729", "0.5980148", "0.5975851", "0.5968129", "0.596548", "0.59626764", "0.5962361", "0.59604067", "0.5953406", "0.5946624", "0.5939725", "0.5933158", "0.5923283", "0.5916979", "0.59103173", "0.5883758", "0.5878709", "0.5873338", "0.5867396", "0.5867396", "0.5867396", "0.58598167", "0.5845743", "0.5842681", "0.58418053", "0.58392173", "0.5833987", "0.58228004", "0.5821243", "0.57995176", "0.57995176", "0.5797679", "0.5795712", "0.5793513", "0.57879263", "0.57860225", "0.5785313", "0.57825035", "0.5782237", "0.5780293", "0.57758284", "0.577417", "0.57716465", "0.57699436", "0.57670414", "0.5759066", "0.57559353", "0.57394433", "0.5730788", "0.5722072", "0.571797", "0.57172096", "0.5716105", "0.5714416", "0.57109106", "0.57077813", "0.570341", "0.5698313", "0.56964236", "0.5691574", "0.5691356", "0.5689372", "0.5688512", "0.56807727", "0.5678545", "0.5675943", "0.56667835", "0.56624097", "0.565393", "0.5645946", "0.5645881", "0.56436837", "0.5639653" ]
0.6440669
5
Indicate whether the user can recommend an item for purchase.
def can_request_purchase? true # TODO: Should this be !virginia_borrower? ? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_buy?(item)\r\n item.buyable_by?(self)\r\n end", "def recommendable?() false end", "def can_buy?(item)\n item.buyable_by?(self)\n end", "def item_usable?\r\n user.usable?(item) && item_effects_valid?\r\n end", "def item_usable?\n user.usable?(item) && item_effects_valid?\n end", "def recommended?(user_id)\n return self.article_recommendations.exists?(user_id: user_id)\n end", "def recommendations_enabled\n return @recommendations_enabled\n end", "def enable?(item)\n CookingManager.quantity(item) > 0\n end", "def is_favoritable?\n true\n end", "def has_discounts?\n rpg_shop.permit_sales\n end", "def purchased?(product)\n purchase_items.exists?(product_id: product.id)\n end", "def enable?(item)\n return (item.price > 0)\n end", "def premium?\n product == \"premium\"\n end", "def item_need_review\n return @item_need_review\n end", "def recommended_by_current_user\n if current_user\n extract = Csvarchive.find(params[:id])\n e_rec = extract.recommendations\n u_rec = current_user.recommendations\n all_rec = e_rec & u_rec\n if !all_rec.empty?\n @recommended = true\n else\n @recommended = false\n end\n else\n @recommended = false\n end\n end", "def shares_available_for_purchase?\n if Stock.all.find_by(id: trade.stock_id).shares_available < trade.num_shares\n return false\n else\n return true\n end\n end", "def can_activate?(item)\r\n item.activatable_by?(self)\r\n end", "def enable?(item)\n return false if item.nil?\n return false unless has_recipebook?\n return false if item.tocrafting_gold_fee > $game_party.gold\n return false if $game_party.item_max?(item)\n return false unless have_tools?(item)\n return false unless have_actors?(item)\n return true if item.ingredient_list.empty?\n return have_ingredients?(item)\n end", "def is_recommendation_enabled\n return @is_recommendation_enabled\n end", "def user_may_view_item?\n @pcp_item.pcp_step.released? || @pcp_item.pcp_step.in_commenting_group?\n end", "def enable?(item)\n item && item.price > 0\n end", "def can_activate?(item)\n item.activatable_by?(self)\n end", "def purchased?\n state == \"purchased\" or stolen == true\n end", "def permitted_for_research_object?(item = self)\n if item.is_downloadable?\n item.can_download?(nil)\n else\n item.can_view?(nil)\n end\n end", "def premium?\n premium\n end", "def can_sell_drug?(drug)\n drug.can_be_sold?\n end", "def should_i_buy?(item)\n !!list[item.to_sym]\n end", "def check_item_condition?\n # disallow usage if item button disabled\n return false if !$game_system.item_button\n # disallow usage\n item_condition = false\n # if using direct hotkeys\n if BlizzABS::Config::DIRECT_HOTKEYS\n # check direct hotkeys\n item_condition = self.item_hotkeys?\n # if item button pressed\n elsif Input.trigger?(Input::Item)\n # allow usage\n item_condition = true\n end\n # return result\n return item_condition\n end", "def pro_rating?\n safe_rating >= Elo.config.pro_rating_boundry\n end", "def suggestion_check?\n session[:suggested_item].empty?\n end", "def validate_item_results?\n if @item.user.private\n authenticate_user!\n if !current_user.subscribed_to(@item.user)\n return false\n end\n end\n return true\n end", "def price_to_be_announced?\n unless self.product_supplies.empty? || self.product_supplies.first.supply_details.empty?\n unpriced_item_type = self.product_supplies.first.supply_details.first.unpriced_item_type\n end\n unpriced_item_type ? unpriced_item_type.human==\"PriceToBeAnnounced\" : false\n end", "def item_can_use?(item)\n return false unless item.is_a?(RPG::Item)\n return false if item_number(item) == 0\n if $game_temp.in_battle\n return item.battle_ok?\n else\n return item.menu_ok?\n end\n end", "def check_buyable\n raise PermissionDeniedError, \"出品したアイテムはサポートできません\" if @item.owner?(current_user)\n end", "def enable?(item)\n return false if item.nil?\n return false if $game_party.gold < item.dismantle_gold_fee \n return item.dismantlable?\n end", "def can_be_approved?\n self.applied?\n end", "def invited_for_interview?\n if offering.uses_interviews?\n application_review_decision_type.nil? ? false : application_review_decision_type.yes_option\n else\n false\n end\n end", "def reserved?(product)\n product.status == 'Reserved'\n end", "def enable?(item)\n if item.is_a?(RPG::Item)\n return true if !item.key_item?\n elsif item.is_a?(RPG::Weapon) || item.is_a?(RPG::Armor)\n return true\n else\n return false\n end\n end", "def require_product?\n !!!catalog_request?\n end", "def require_product?\n !!!catalog_request?\n end", "def has_editorial_or_stock_for_sale\n return false if self.requests.length == 0\n self.requests.each do |r|\n return false if r.state == \"denied\"\n end\n true\n end", "def in_use?\n published? || has_answers? || has_choices?\n end", "def premium?\n \t! free?\n end", "def enable?(item)\n end", "def within_limit_of?(item, user)\r\n @member_limits.fetch(user.email).has_resources_for?(item.price)\r\n end", "def current_item_enabled?\n return true\n end", "def recommendations_enabled=(value)\n @recommendations_enabled = value\n end", "def can_supply?(required)\n total_on_hand >= required || backorderable?\n end", "def bought?\n # paym\n end", "def eligible?(product)\n @product_codes.include?(product.product_code)\n end", "def canViewWriteReviewButtonForItem(user, item)\n\t \t\t\tif item.nil?\n\t \t\t\t\treturn false\n\t \t\t\tend\n\n\t \t\t\tif user.nil?\n\t \t\t\t\t# different than above, b/c we handle login differently\n\t \t\t\t\treturn false\n\t \t\t\tend\n\t \t\t\tif isStoreManager(user) || isStoreOwner(user)\n\t \t\t\t\treturn \"store managers cannot review items\"\n\t \t\t\tend\n\n\t \t\t\tpreviousreview = item.store_item_reviews.find_by user_id: user.id\n\t \t\t\tif previousreview.nil?\n\t \t\t\t\treturn true\n\t \t\t\telse\n\t \t\t\t\treturn \"you've already reviewed this item\"\n\t \t\t\tend\n\t \t\tend", "def has_met_requirement?\n yeas >= required_votes\n end", "def enable?(item)\n true\n end", "def enable?(item)\n true\n end", "def has_buyer_review?\n buyer_reviews.present?\n end", "def renewal_or_review_mandatory?\n existing_agreement? && waste_producer_water_discount?\n end", "def current_item_enabled?\n true\n end", "def donatable?\n show_donation_basket? && has_an_approved_account_set? && money_approved?\n end", "def should_notify?\n (article.recommendations_count > 0 and\n article.recommendations_count.modulo(5) == 0)\n end", "def rateable_by?(user)\n self.user.rateable_by?(user)\n end", "def rateable_by?(user)\n self.user.rateable_by?(user)\n end", "def valid_recommendation_hash? input\n (input[:action] == RECOMMEND_ACTION && input[:customer_name] && input[:invitee_name]) ||\n (input[:action] == ACCEPT_ACTION && input[:customer_name])\n end", "def enable?(item)\n return true\n end", "def enable?(item)\n return true\n end", "def can_afford_to_rent?(movie)\n end", "def is_recommendation_enabled=(value)\n @is_recommendation_enabled = value\n end", "def can_review?\n reviewer? || moderator? || administrator?\n end", "def available?(object)\n line_items = object_to_line_items(object)\n return false if line_items.nil?\n\n weight_rate = get_rate(get_total_weight(line_items), AdditionalCalculatorRate::WEIGHT)\n !weight_rate.nil? # available only if the weight rate is not nil\n end", "def available?\n self.available_product_supplies.length > 0 and not self.delete?\n end", "def must_buy_train?(entity)\n must_buy_power?(entity)\n end", "def custom_order?\n order_items.all? { |oi| oi.purchasable_type == 'Effective::Product' }\n end", "def fulfilled?\n user.donations.active.count >= quantity\n end", "def enable?(item); true; end", "def usable_item_conditions_met?(item)\r\n movable? && occasion_ok?(item)\r\n end", "def has_item?(item)\n return true if drops_item?(item)\n return true if can_steal_item?(item)\n false\n end", "def include?(item)\n case @category\n when :item\n item.is_a?(RPG::Item) && !item.key_item? && item.dismantlable?\n when :weapon\n item.is_a?(RPG::Weapon) && item.dismantlable?\n when :armor\n item.is_a?(RPG::Armor) && item.dismantlable?\n when :key_item\n item.is_a?(RPG::Item) && item.key_item? && item.dismantlable?\n else\n false\n end\n end", "def available?\n self.active == true and self.quantity_available > 0\n end", "def can_user_buy_photos?(user)\n return true if who_can_buy == WHO_EVERYONE\n return true if who_can_buy == WHO_OWNER && user && admin?(user.id)\n return true if who_can_buy == WHO_VIEWERS && user && can_view_or_not_private?(user.id)\n\n return false\n end", "def may_purchase?(_company)\n false\n end", "def is_purchasing_credit?\n sku_type.to_s == Product::SKU_TYPE_PURCHASING_CREDIT && self.internal?\n end", "def rated?\n liked_by_count > 0 || disliked_by_count > 0\n end", "def item_usable?\n return false unless @item\n return @actor ? @actor.usable?(@item) : $game_player.usable?(@item)\n end", "def has_discount?\n !discount.nil? && (!discount.product_list? || discount.product_ids.include?(line_item.product_id))\n end", "def available?\n self.in_stock? || self.backorderable?\n end", "def enable?(item)\n true#$game_party.usable?(item)\n end", "def canYouGiveMeATreasure\n !getVisibleTreasures.empty?\n end", "def licensed?\n end", "def under_review?(item = nil)\n # noinspection RubyMismatchedArgumentType\n super(item || self)\n end", "def can_sell?\n inventory.any? { |inv| inv.price > 0 }\n end", "def offers_reward?\n !self.rewards.visible.empty?\n end", "def voted_on?(user)\n return !self.ratings.find_by_user_id(user.id).nil?\n end", "def under_review?(item)\n state_group(item) == :review\n end", "def user_meets_criteria?(user)\n user.credits > 0\n end", "def can_supply?\n payment_received? || payment_on_account?\n end", "def redeemable?\n [AVAILABLE, EXPIRED].include?(status) and started? and delay_passed?\n end", "def sold?(product)\n product.status == 'Sold'\n end", "def approved?\n closed? && has_met_requirement?\n end", "def rating_checked?(rating)\n @selected_ratings.has_key?(rating)\n end", "def recommendations_for(obj)\n recommend_by_item_based obj\n end" ]
[ "0.7157503", "0.7148289", "0.7135049", "0.68390083", "0.6827606", "0.66412073", "0.6575622", "0.65648973", "0.6534497", "0.6449945", "0.64439887", "0.6420681", "0.63699496", "0.63678914", "0.6348184", "0.6330634", "0.6326045", "0.631778", "0.63173556", "0.63016737", "0.6295547", "0.6280972", "0.62651604", "0.62580764", "0.6228964", "0.621769", "0.6185939", "0.61818296", "0.613762", "0.6115583", "0.61040443", "0.61035925", "0.6097516", "0.6092808", "0.60500866", "0.6046043", "0.60429233", "0.60255706", "0.6015206", "0.60151035", "0.60151035", "0.6013756", "0.60047805", "0.5997057", "0.599381", "0.5991887", "0.5982159", "0.5976384", "0.5976112", "0.59735507", "0.5972734", "0.59719646", "0.5967236", "0.5951377", "0.5951377", "0.5949628", "0.59488964", "0.5942727", "0.5942559", "0.5937809", "0.59308124", "0.59308124", "0.59289074", "0.59262925", "0.59262925", "0.5925081", "0.5921658", "0.5916248", "0.5913436", "0.5913428", "0.59122306", "0.59122294", "0.58996826", "0.58979404", "0.58880806", "0.58810717", "0.5879438", "0.5872137", "0.58692294", "0.5868313", "0.58601165", "0.58572674", "0.58546203", "0.58539987", "0.5852824", "0.5844589", "0.58444977", "0.58425015", "0.5832107", "0.5820247", "0.581987", "0.5812441", "0.58107156", "0.5810298", "0.5807469", "0.5804405", "0.58035856", "0.57960606", "0.5794641", "0.57936364" ]
0.63130325
19
Indicate whether the user can request item scanning.
def can_request_scanning? true # TODO: Should this be !virginia_borrower? ? end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resource_allowed?(scan_result)\n logger.debug scan_result\n (scan_result['response_code'] < 1) || !contains_in_bases?(scan_result)\n end", "def validate_item_results?\n if @item.user.private\n authenticate_user!\n if !current_user.subscribed_to(@item.user)\n return false\n end\n end\n return true\n end", "def scan_to_check_id(item)\n 5.times do \n show do\n title 'Take Item'\n note \"Take item #{get_barcode_id(item)}\"\n note 'Scan item'\n end\n return true if true #TODO make actually work if scan is correct then true\n end\n end", "def item_usable?\r\n user.usable?(item) && item_effects_valid?\r\n end", "def item_usable?\n user.usable?(item) && item_effects_valid?\n end", "def can_fulfill_request?(request)\r\n matching_items= self.overlay.active_items_by_name_and_user(request.name, self)\r\n matching_items.size > 0\r\n end", "def requestable?\n # Sometimes a PUBFI002 error code isn't really an error,\n # but just means not available. \n if response_hash && response_hash[\"Error\"] && (response_hash[\"Error\"][\"ErrorNumber\"] == \"PUBFI002\")\n return false\n end\n\n # Items that are available locally, and thus not requestable via BD, can\n # only be found by looking at the RequestMessage, bah \n if locally_available?\n return false\n end\n\n return response_hash[\"Available\"].to_s == \"true\"\n end", "def requestable?\n (ill? || available? || recallable? ||\n processing? || on_order? || offsite? || ezborrow?)\n end", "def check_buyable\n raise PermissionDeniedError, \"出品したアイテムはサポートできません\" if @item.owner?(current_user)\n end", "def allowed?(request)\n whitelisted?(request) && !blacklisted?(request) && meets_quota?\n end", "def enable?(item)\n return true\n end", "def enable?(item)\n return true\n end", "def actions_available?(user)\n actions_allowable?(user)\n end", "def enable?(item)\n end", "def can_request?(user)\n self.is_active &&\n self.is_visible &&\n user.is_captain? &&\n ! self.teams.include?(user.team) &&\n ! self.is_finished?\n end", "def can_request_purchase?\n true # TODO: Should this be !virginia_borrower? ?\n end", "def enable?(item)\n true\n end", "def enable?(item)\n true\n end", "def actions_available?(user)\n return false if status == Constants.TASK_STATUSES.on_hold && !on_timed_hold?\n\n actions_allowable?(user)\n end", "def can_activate?(item)\r\n item.activatable_by?(self)\r\n end", "def check_if_user_can_perform_action_on_resources\n if @item && @item.is_a?(Typus.user_class)\n check_if_user_can_perform_action_on_user\n else\n not_allowed if admin_user.cannot?(params[:action], @resource.model_name)\n end\n end", "def allow?(item)\n @whitelist.include?(item) || !@blacklist.include?(item)\n end", "def current_item_enabled?\n return true\n end", "def check_item_condition?\n # disallow usage if item button disabled\n return false if !$game_system.item_button\n # disallow usage\n item_condition = false\n # if using direct hotkeys\n if BlizzABS::Config::DIRECT_HOTKEYS\n # check direct hotkeys\n item_condition = self.item_hotkeys?\n # if item button pressed\n elsif Input.trigger?(Input::Item)\n # allow usage\n item_condition = true\n end\n # return result\n return item_condition\n end", "def enable?(item); true; end", "def can_activate?(item)\n item.activatable_by?(self)\n end", "def request_allowed?(request)\n true\n end", "def can_buy?(item)\r\n item.buyable_by?(self)\r\n end", "def is_available?\n count_available > 0\n end", "def can_buy?(item)\n item.buyable_by?(self)\n end", "def read_allowed?(user)\n true\n end", "def user_may_view_item?\n @pcp_item.pcp_step.released? || @pcp_item.pcp_step.in_commenting_group?\n end", "def request_permitted?(item)\n true\n end", "def current_item_enabled?\n true\n end", "def inbound_request?\n requester == 'inbound'\n end", "def can_access?\n allows_current_user_access_to? :access\n end", "def gr_is_visible?\n eval_policy(:read_access)\n end", "def item_can_use?(item)\n return false unless item.is_a?(RPG::Item)\n return false if item_number(item) == 0\n if $game_temp.in_battle\n return item.battle_ok?\n else\n return item.menu_ok?\n end\n end", "def permitted_for_research_object?(item = self)\n if item.is_downloadable?\n item.can_download?(nil)\n else\n item.can_view?(nil)\n end\n end", "def requesting?(user)\n attempted_interpreters.include?(user)\n end", "def enable?(item)\n CookingManager.quantity(item) > 0\n end", "def can_request\n return true if is_requested\n\n return true if both_user_verified? && !friend_request_exists?\n\n false\n end", "def is_per_device_acceptance_required\n return @is_per_device_acceptance_required\n end", "def check_visibility\n raise Helpedia::ItemNotVisible unless @user.visible_for?(current_user)\n end", "def is_available?\n return @status == :AVAILABLE\n end", "def can_be_read_by?(attempting_user)\n if attempting_user\n published? && (is_public? || is_protected? || member?(attempting_user) || attempting_user.is_admin? ||\n (is_subscription_only? && attempting_user.is_paid_subscriber?))\n else\n published? && is_public?\n end\n end", "def has_access?\n true\n end", "def has_access?\n true\n end", "def enable?(item)\n item.enabled?\n end", "def enable?(item)\n item.enabled?\n end", "def publicly_available?\n return false unless access_rights.present?\n\n access_rights.none? do |value|\n value == 'deny' || %w[allow:icus allow:pdus].include?(value)\n end\n end", "def current_item_enabled?\r\n enable?(index)\r\n end", "def can_be_assigned?(_user)\n false # any user can complete operation\n end", "def current_item_enabled?\n enable?(@index)\n end", "def enable?(item)\n true#$game_party.usable?(item)\n end", "def within_limit_of?(item, user)\r\n @member_limits.fetch(user.email).has_resources_for?(item.price)\r\n end", "def current_item_enabled?() target end", "def can_accept_showing?\n profile.valid? && valid_bank_token? && !blocked?\n end", "def enable?(item)\n return false if item.nil?\n return true\n end", "def enable?(item)\n return false if item.nil?\n return true\n end", "def redeemable?\n [AVAILABLE, EXPIRED].include?(status) and started? and delay_passed?\n end", "def suggestion_check?\n session[:suggested_item].empty?\n end", "def can?\n current_user\n end", "def allowed?\n allowed\n end", "def allowed?\n true\n end", "def allowed?(key)\n @status[key] == :allowed\n end", "def action_allowed?\n current_user_has_student_privileges?\n end", "def luxury_search_authorized?\n authorized_for?(:action => :read)\n end", "def can_recover?\n self.lapsed? and not self.blacklisted\n end", "def allowed?\n true\n end", "def allowed?\n true\n end", "def allow_access\n !@current_user.nil?\n end", "def access action\n\t\tif current_user\n \treturn true\n else\n \treturn false\n end\n\n\tend", "def public_requested?\r\n return (self.public_status == PUBLIC_STATUS_REQUESTED) ? true : false\r\n end", "def available?\n status == :available\n end", "def allowed?(request)\n case\n when whitelisted?(request) then true\n when blacklisted?(request) then false\n else true # override in subclasses\n end\n end", "def check_can_access\n res = false\n read_actions = [ \"index\", \"list\", \"edit\" ]\n new_actions = [ \"new\", \"create\" ]\n edit_actions = [ \"edit\", \"update\", \"destroy\", \"update_logo\" ]\n\n res ||= (action_name == \"show_logo\")\n res ||= current_user.admin?\n\n if current_user.option_externalclients?\n res ||= (current_user.read_clients? and read_actions.include?(action_name))\n res ||= (current_user.edit_clients? and edit_actions.include?(action_name))\n res ||= (current_user.create_clients? and new_actions.include?(action_name))\n end\n\n if !res\n flash[\"notice\"] = _(\"Access denied\")\n redirect_from_last\n end\n end", "def view_allowed?(item)\n @view_allowed.to_a.map(&:to_sym).include?(item.to_sym)\n end", "def requires_storage_for_scan?\n true\n end", "def acceptable_by?(user)\n return false unless user.has_role?(:admin, user.unit)\n resource.pending?\n end", "def current_item_enabled?\n true#enable?(@data[index])\n end", "def in_progress?\n allowed_page?\n end", "def permitted?\n appctrl_not_permitted() if ( @current_user.restricted? )\n end", "def available?\n true\n end", "def whitelisted?(request)\n false\n end", "def privileged_access?\n connected? || PrismicService.access_token\n end", "def blacklisted?(request)\n false\n end", "def odk_awaiting_media?\n params[\"*isIncomplete*\"] == \"yes\"\n end", "def canRegister\n\t\tif(num_enrolled.to_i<capacity.to_i)\n\t\t\treturn true\n\t\telse\n\t\t\treturn false\n\t\tend\n\t\tend", "def viewable_by?(user)\n Sugar.public_browsing? || user ? true : false\n end", "def can_authorize?(user, a)\n user != self and may_authorize and\n (abilities | ADMIN_TASKS).include?(a)\n end", "def in_accessioning?\n (2..5).cover?(status)\n end", "def aquired?\n acquired?\n end", "def current_item_enabled?\n enable?(@data[index])\n end", "def current_item_enabled?\n enable?(@data[index])\n end", "def current_item_enabled?\n enable?(@data[index])\n end", "def current_item_enabled?\n enable?(@data[index])\n end", "def current_item_enabled?\n enable?(@data[index])\n end", "def current_item_enabled?\n enable?(@data[index])\n end", "def needs_permission_badge?\n solr_document.visibility != Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC\n end" ]
[ "0.6683219", "0.64934236", "0.6476095", "0.6403977", "0.63911766", "0.6346303", "0.63239706", "0.6288409", "0.6245314", "0.6237274", "0.6226871", "0.6226871", "0.620057", "0.61792797", "0.6166664", "0.6158132", "0.61561495", "0.61561495", "0.61387146", "0.6111477", "0.6111416", "0.6096666", "0.6086802", "0.60553014", "0.6044732", "0.60434", "0.6020542", "0.6018686", "0.6018198", "0.6001219", "0.598107", "0.5969901", "0.59688747", "0.5962781", "0.5961977", "0.5961665", "0.59605956", "0.5957423", "0.5945514", "0.5939897", "0.59264237", "0.5925553", "0.5921151", "0.5887182", "0.5877546", "0.5875737", "0.5867421", "0.5867421", "0.5860947", "0.5860947", "0.5858712", "0.5851007", "0.5838996", "0.58073586", "0.5802812", "0.58006513", "0.579561", "0.57932746", "0.57906085", "0.57898426", "0.57831854", "0.5781015", "0.5775061", "0.57734454", "0.57672226", "0.5765697", "0.57655734", "0.5764886", "0.5763193", "0.57572645", "0.57572645", "0.5757182", "0.5756212", "0.57492346", "0.5748349", "0.57452166", "0.57192147", "0.57171816", "0.5716478", "0.57105654", "0.5703676", "0.5697376", "0.5695727", "0.56941706", "0.5689985", "0.5689008", "0.5688018", "0.5687565", "0.56823456", "0.568212", "0.5678942", "0.5672228", "0.56622905", "0.56598914", "0.56598914", "0.56598914", "0.56598914", "0.56598914", "0.56598914", "0.5658098" ]
0.7451331
0
Notice how it's currently impossible to tell if a key is simply mistyped as a public or private key, or if it's a badly formatted key. Too bad.
def test_bogus_raise bogus_key = "Oh hey I'm a key. Ok, not really." assert_raise OpenSSL::PKey::PKeyError do Net::SSH::Utils::Key.fingerprint(:data => bogus_key) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def valid_key?(key)\n return false unless key.is_a?(String)\n return false unless key = encoded_key(key)\n key.length >= 2 && key.length <= 255 && (key !~ BAD_KEY_RE rescue false)\n end", "def valid_key(key)\n valid_rsa_key(key) && (key['x5c']&.length || (key['n'] && key['e']))\n end", "def validate_key!(key)\n unless key.is_a?(String) or key.is_a?(Symbol)\n raise SketchUpJSON::JSONEncodeError, \"This hash can not generate valid JSON\"\n end\n end", "def verify_key; end", "def verify_key; end", "def valid_rsa_key(key)\n key['use'] == 'sig' && key['kty'] == 'RSA' && key['kid']\n end", "def validate_key_bytes(key_bytes); end", "def sanitize(key)\n # E.g. cur/1263444769.M975543P58179Q11.gnt.local:2,\n unless KEY_VALIDATORS.any?{|validator| key.match(validator) }\n content_type \"text/plain\"\n halt 403, \"Malformed key: #{key}\"\n end\n end", "def assert_key(key)\n return if key.is_a?(String) && !SSH_KEY_REGEX.match(key).nil?\n raise Chef::Exceptions::ValidationFailed,\n 'ssh_authorize_key: key parameter must be a valid SSH public key! '\\\n \"You passed #{key.inspect}.\"\n end", "def verify_key(key, _context = nil)\n key && String(key)\n end", "def ensure_valid_key( key )\n key.to_s.index( /\\./ ) ? key.to_s.gsub( /\\./, '_' ) : key\n end", "def valid\n if self.key\n key_pieces = self.key.split(\" \")\n small_key = key_pieces[0] + \" \" + key_pieces[1]\n #if small_key =~ /^(ssh-\\w+ [a-zA-Z0-9\\/\\+]+==?).*$/\n if small_key =~ /^(ssh-\\w+ [a-zA-Z0-9\\/\\+].*)$/\n return true\n else\n return false\n end\n else\n return false\n end\n end", "def verify_key(key, context = nil)\n key && String(key)\n end", "def verify_server_key(key); end", "def invalid_key(system_key)\n fail InvalidSyntax, \"`#{system_key}` must be a String or a Symbol.\"\n end", "def issueKey_test(key, no_throw = false)\n if key.nil? || !(/^[A-Z]+-[0-9]+$/i =~ key)\n raise Jiralicious::JiraError.new(\"The key #{key} is invalid\") unless no_throw\n return false\n end\n return true\n end", "def any_unrecognized_keys?(expected, given)\n unrecognized_keys(expected, given).any?\n end", "def check_key_valid\n @key_warning = false unless defined?(@key_warning)\n if !configuration.valid_api_key? && !@key_warning\n configuration.warn(\"No valid API key has been set, notifications will not be sent\")\n @key_warning = true\n end\n end", "def identifier_valid?(key)\n key = key.to_s\n ForbiddenChars.each_char do |char|\n return false if key.include?(char)\n end\n end", "def test_if_valid_api_key_is_accepted\n real_key_value = \"abcdefgh-ijkl-mnop-qrst-uvwxyz012345\"\n\n begin\n Yo.api_key = real_key_value\n api_key = Yo.api_key\n rescue YoException => e\n api_key = \"\"\n end\n\n assert_equal api_key, real_key_value, \"Yo.api_key does not accept a valid Yo API key\"\n end", "def unqualify?(key)\n key[0, 1] == \":\"\n end", "def validate_keys(*valid_keys)\n valid_keys.flatten!\n @hash.each_key do |k|\n unless valid_keys.include?(k)\n raise ArgumentError.new(\"Unknown key: #{k.inspect}. Valid keys are: #{valid_keys.map(&:inspect).join(', ')}\")\n end\n end\n end", "def not_valid?\n tst = @potential_key.split('')\n\n tst.each do |check|\n if @@low_alpha[check].nil? && @@up_alpha[check].nil?\n @result = true\n break\n else \n @result = false\n @valid_key = @potential_key\n end\n end\n\n @result\n end", "def key_not_found?\n ->(body) { body =~ /#{INVALID[:key_not_found]}/ }\n end", "def key_valid?\n token_valid? and @key\n end", "def check_key_validity(key_info)\n if key_info[:key_name] == :aws\n return 'error', \"can't find this key\" if @keys_data_index[key_info[:key_value].to_sym].nil?\n if (DateTime.now - @days_to_validate) > (@keys_data_index[key_info[:key_value].to_sym][:created_date])\n return 'invalid', nil\n else\n return 'valid', nil\n end\n else\n ['error', 'key unknown']\n end\n end", "def verify_keyfile! keyfile\n if keyfile.nil?\n fail \"You must provide a keyfile to connect with.\"\n elsif !::File.file?(keyfile)\n fail \"The keyfile '#{keyfile}' is not a valid file.\"\n end\n end", "def validate_ssl_connection\n pubkey = @connection.http.peer_cert.public_key\n pubkey_hash = Digest::SHA2.hexdigest(pubkey.to_s)\n expected_pubkey_hash = @vsphere_expected_pubkey_hash\n if pubkey_hash != expected_pubkey_hash then\n raise Fog::Vsphere::Errors::SecurityError, \"The remote system presented a public key with hash #{pubkey_hash} but we're expecting a hash of #{expected_pubkey_hash || '<unset>'}. If you are sure the remote system is authentic set vsphere_expected_pubkey_hash: <the hash printed in this message> in ~/.fog\"\n end\n end", "def splunk_encrypted?(key)\n !key.nil? && key.match?(/^\\$\\d\\$/)\n end", "def raise_key_file_error(key_file)\n is_abs = ::File.absolute_path(key_file) == key_file\n raise \"json_key_file must be an absolute path: #{key_file}\" unless is_abs\n\n exists = ::File.exist? key_file\n raise \"json_key_file does not exist: #{key_file}\" unless exists\n end", "def incorrect_keys(the_input, invalid_hash = Array.new, the_array)\n the_input.each_key do |key|\n unless the_array.include?(key.to_s)\n invalid_hash << key\n end\n end\n raise K2IncorrectParams.new(invalid_hash) if invalid_hash.present?\n end", "def is_error?(key, value)\n case key\n when 'api_token_secret_key' then true if value.empty? ||\n value !~ /\\Askey_[a-zA-Z0-9]+\\z/\n\n when 'account_alias' then true if value.empty? ||\n value.length > 15 ||\n value !~ /\\A[a-z0-9]+\\z/\n\n when 'recipe' then true if value.empty? ||\n value.length > 25 ||\n value !~ /\\A[a-zA-Z0-9_]+\\z/\n\n when 'server' then true if !value.empty? &&\n value !~ /\\A[a-zA-Z0-9_]+\\z/\n\n when 'groups' then true if !value.empty? &&\n value !~ /\\A[a-zA-Z0-9_\\s\\,]+\\z/\n else\n false\n end\n end", "def safe_key?\n CONFIG[\"#{params[:action]}_key\"] == Base64.decode64(params[:key])\n end", "def require_key\n fail 'No private key loaded' unless @private_key\n end", "def assert_keytype(keytype)\n return if allowed_keytypes.include?(keytype)\n raise Chef::Exceptions::ValidationFailed,\n 'ssh_authorize_key: keytype parameter must be equal to one of: '\\\n \"#{allowed_keytypes.join(', ')}! You passed #{keytype.inspect}.\"\n end", "def checkKeys()\r\n\r\n data = nil\r\n if (@cafile.nil? || @cafile.empty? || !File.exists?(@cafile) || OpenSSL::X509::Certificate.new(File.read(@cafile)).nil?)\r\n raise SecurityError, \"CA Public key NOT OK!\"\r\n else\r\n _dprint(\"CA Public Key OK\")\r\n end\r\n\r\n if (@keyfile.nil? || @keyfile.empty? || !File.exists?(@keyfile) || OpenSSL::X509::Certificate.new(File.read(@keyfile)).nil?)\r\n raise SecurityError, \"Public key NOT OK!\"\r\n else\r\n _dprint(\"Public Key OK\")\r\n end\r\n\r\n if (!File.exists?(@keyfile) || OpenSSL::PKey::RSA.new(File.read(@keyfile), @keypass).nil?)\r\n raise SecurityError, \"Private key NOT OK!\"\r\n else\r\n _dprint(\"Private Key OK\")\r\n end\r\n\r\n end", "def fast_assert_valid_keys(valid_keys)\n unknown_keys = keys - valid_keys\n raise(ArgumentError, \"Unknown key(s): #{unknown_keys.join(\", \")}\") unless unknown_keys.empty?\n end", "def test_invalid_key\n e = assert_raise(RuntimeError) { load_config('test_configs/bad-key-config.conf') }\n assert_equal('Invalid key: = /srv/var/tmp/', e.message)\n end", "def valid_key? key\n (not key.nil?) and (FileCreator::valid_key?(key.to_sym))\n end", "def output_key(key)\n STDOUT.write \"# Private key (d, n): #{'%X' % key.d} #{'%X' % key.n}\\n\"\n STDOUT.write \"key #{'%X' % key.e} #{'%X' % key.n}\\n\"\nend", "def valid_key?(match_data)\n match_data[:key].to_i == (97 - match_data[1..-2].join.to_i) % 97\nend", "def key_must_be_a_possible_key_from_the_phone_model\n phone_model = self.sip_account.phone.phone_model\n if !phone_model.phone_model_keys.exists?(self.phone_model_key_id)\n errors.add( :phone_model_key_id, \"Is not a valid PhoneModelKey for the PhoneModel #{phone_model.name} (ID #{phone_model.id}).\" )\n end\n end", "def default_key_format(key)\n snake(key)\n end", "def host_key_verifier; end", "def verified?\n key == '1'\n end", "def valid_xonly_pubkey?(pub_key)\n pubkey = pub_key.htb\n return false unless pubkey.bytesize == X_ONLY_PUBKEY_SIZE\n begin\n ECDSA::Format::PointOctetString.decode(pubkey, ECDSA::Group::Secp256k1)\n rescue Exception\n return false\n end\n true\n end", "def ssn_key_valid?(ssn_number)\n key = ssn_number[-2..-1].to_i\n ssn_without_key = ssn_number[0..-3].delete(\" \").to_i\n remainder_of_calculation = (97 - ssn_without_key) % 97\n remainder_of_calculation == key\nend", "def validate_key_wrap(key_wrap_schema, key)\n if key.is_a? OpenSSL::PKey::RSA\n unless key_wrap_schema == :rsa_oaep_sha1\n raise ArgumentError, ':key_wrap_schema must be set to :rsa_oaep_sha1 for RSA keys.'\n end\n else\n unless key_wrap_schema == :aes_gcm\n raise ArgumentError, ':key_wrap_schema must be set to :aes_gcm for AES keys.'\n end\n end\n\n case key_wrap_schema\n when :rsa_oaep_sha1 then 'RSA-OAEP-SHA1'\n when :aes_gcm then 'AES/GCM'\n when :kms_context\n raise ArgumentError, 'A kms_key_id is required when using :kms_context.'\n else\n raise ArgumentError, \"Unsupported key_wrap_schema: #{key_wrap_schema}\"\n end\n end", "def allowed_keys_errors\n return {} if parser_class != Parser || ( allowed_keys && allowed_keys.is_a?(Array) )\n {\n allowed_keys: 'allowed keys must be set to an array of values'\n }\n end", "def credential_data_valid? data\n data.each do |hash|\n hash.each do |k,v|\n abort <<-MSG unless KEYS.include? k\nProbably have a typo in #{CREDENTIAL_FILE}: #{k}\nValid yaml keys: #{KEYS.join(\", \")}.\n MSG\n abort \"Please fill in #{k} in #{CREDENTIAL_FILE}\" unless v\n end\n end\n\n return true\n end", "def raw_key\n key = read['pem']\n raise \"There is no key for some reason for user @#{@login}\" if key.nil?\n key\n end", "def validate_json_credentials(json_key)\n json_key_hash = Fog::JSON.decode(json_key)\n\n unless json_key_hash.key?(\"client_email\") || json_key_hash.key?(\"private_key\")\n raise ArgumentError.new(\"Invalid Google JSON key\")\n end\n end", "def test_incorrect_current_hash\n hash_string = '10|cb0f|281974>443914(6):SYSTEM>572872(100)|1553188611.607041000'\n assert_raises BlockFormatError do\n verify_current_hash(hash_string, 'd5e', 10, PreHash.new)\n end\n end", "def validate(exemplar, hash, message)\n hash.each_key do |k|\n fail NebulousError, \"#{message} key '#{k}'\" unless exemplar.include?(k)\n end\n end", "def verify_api_key\n # Confirm that it's a json request. This is irrelevant otherwise.\n if request.format && request.format.symbol && request.format.symbol == :json\n # We must have a key, either way. If no key, pass forbidden response.\n if params[:key].nil? && (request.env['HTTP_REFERER'] =~ Regexp.new(request.env['HTTP_HOST'])).nil?\n render :json => { :errors => \"Invalid API key.\" }, :status => :forbidden\n else\n if (request.env['HTTP_REFERER'] =~ Regexp.new(request.env['HTTP_HOST'])).nil?\n # Find by key\n @key = ApiKey.find_by_key(params[:key])\n if @key.nil?\n # Throw error if no key found.\n render :json => { :errors => \"Invalid API key.\" }, :status => :forbidden\n end\n end\n end\n end\n end", "def key_check\n logger.debug \"checking authorization key \"\n unauthorized \"No authorization key provided. Please pass the API token as GET parameter named 'key'. Example: ?key=abcdef\" if params[:key].nil?\n logger.debug \"token is \" + params[:key] unless params[:key].nil?\n end", "def check_syntax_hash_key(key, schema, datum, depth, trace)\n check_syntax_trace(\"check_syntax_hash_#{key}\", schema, datum, depth, trace)\n ((!key.is_a?(String)) ?\n check_syntax_error(9, schema, datum, trace, key) :\n ((key =~ /^\\|ALT.*\\|/) ?\n ((datum.key?(schema[key].keys[0])) ?\n ((datum.key?(schema[key].keys[1])) ?\n check_syntax_error(15, schema, datum, trace) :\n (check_syntax_hash_key(schema[key].keys[0], schema[key], datum, depth, trace) ||\n check_syntax_error(14, schema, datum, trace, \"First\"))) :\n ((datum.key?(schema[key].keys[1])) ?\n (check_syntax_hash_key(schema[key].keys[1], schema[key], datum, depth, trace) ||\n check_syntax_error(14, schema, datum, trace, \"Second\")) :\n check_syntax_error(13, schema, datum, trace))) :\n ((key =~ /^\\|OPT.*\\|/) ?\n ( ! datum.key?(schema[key].keys[0]) ||\n (check_syntax_hash_key(schema[key].keys[0], schema[key], datum, depth, trace) ||\n check_syntax_error(12, schema, datum, trace))) :\n (datum.key?(key) ?\n (check_syntax_internal(schema[key], datum[key], depth, trace) ||\n check_syntax_error(11, schema, datum, trace, key)) :\n check_syntax_error(10, schema, datum, trace, key)))))\n end", "def validate(keys)\n errors = []\n\n keys.each do |k|\n pretty_key = k.to_s.gsub(/_/, ' ').gsub(/\\w+/){ |w| (w =~ /(ssh)|(aws)/i) ? w.upcase : w.capitalize }\n if Chef::Config[:knife][k].nil? and config[k].nil?\n errors << \"You did not provide a valid '#{pretty_key}' value.\"\n end\n end\n\n if errors.empty?\n return true\n else\n return false\n end\n end", "def valid_keys?(passport)\n (REQ - passport.keys).length === 0\n end", "def read_key(key)\n raise RuntimeError.new(\"read_key not implemented!\")\n end", "def private_key; end", "def private_key; end", "def verify_server_key(key) # :nodoc:\n unless matching?(key.ssh_type, algorithms.host_key)\n raise Net::SSH::Exception, \"host key algorithm mismatch '#{key.ssh_type}' != '#{algorithms.host_key}'\"\n end\n\n blob, fingerprint = generate_key_fingerprint(key)\n\n unless connection.host_key_verifier.verify(key: key, key_blob: blob, fingerprint: fingerprint, session: connection)\n raise Net::SSH::Exception, 'host key verification failed'\n end\n end", "def parse_key(key)\n end", "def get_key_file_error(json_key_file)\n return nil if json_key_file.nil? || json_key_file == ''\n\n abs = ::File.absolute_path json_key_file\n unless abs == json_key_file\n return \"json_key_file must be an absolute path: #{json_key_file}\"\n end\n\n unless ::File.exist? json_key_file\n return \"json_key_file does not exist: #{json_key_file}\"\n end\n\n nil\n end", "def validate_redis_key\n valid_fields = redis_fields_config.select{|k,v| v != :array && v != :hash }.keys\n bad_fields = redis_key_config - valid_fields\n raise ArgumentError, \"Sorry, but you cannot use as redis key [nonexisting | array | hash] fields: [#{bad_fields.join(\",\")}], availible are: #{valid_fields.join(\", \")}\" unless bad_fields.size == 0\n end", "def sanitize_key key\n key.gsub! '-', '_'\n key.gsub! ' ', ''\n key.gsub! ',', ''\n key.downcase!\n return key\n end", "def clever_validate_keys(ssh_keys)\n ssh_keys.is_a? Array and\n # check each entry\n ssh_keys.map { |entry|\n not entry.nil? and\n entry['key'].is_a? String and entry['key'].length > 0 and\n entry['type'].is_a? String and entry['type'].length > 0 and\n (entry['comment'].nil? or\n (entry['comment'].is_a? String and entry['comment'].length > 0))\n # any false results invalidates the whole set\n }.reduce(:&)\n end", "def private_key?\n !!@private_key\n end", "def check_for_illegal_keys!(options)\n if any_unrecognized_keys?(ALLOWED_KEYS, options)\n raise \"Unrecognized options in add_method_tracer_call: #{unrecognized_keys(ALLOWED_KEYS, options).join(', ')}\"\n end\n end", "def hash_correct?(hash)\n hash.keys.all? { |key| ALLOWED_KEYS.include?(key) }\n end", "def normalize_key(k)\n k.to_s.gsub('-', '_').gsub(INVALID_PATTERN, '').to_sym\n end", "def is_key_entry(aliaz)\n\n end", "def test_mismatched_public_keys_throws_exception\n ca = Puppet::Network::Handler.ca.new\n\n # First initialize the server\n client = Puppet::Network::Client.ca.new :CA => ca\n client.request_cert\n File.unlink(Puppet[:hostcsr])\n\n # Now use a different cert name\n Puppet[:certname] = \"my.host.com\"\n client = Puppet::Network::Client.ca.new :CA => ca\n firstcsr = client.csr\n File.unlink(Puppet[:hostcsr]) if FileTest.exists?(Puppet[:hostcsr])\n\n assert_nothing_raised(\"Could not get cert\") do\n ca.getcert(firstcsr.to_s)\n end\n\n # Now get rid of the public key, forcing a new csr\n File.unlink(Puppet[:hostprivkey])\n\n client = Puppet::Network::Client.ca.new :CA => ca\n\n second_csr = client.csr\n\n assert(firstcsr.to_s != second_csr.to_s, \"CSR did not change\")\n\n assert_raise(Puppet::Error, \"CA allowed mismatched keys\") do\n ca.getcert(second_csr.to_s)\n end\n end", "def missing_keys; end", "def require_keys(*p_valid_keys)\n l_missing_keys = []\n p_valid_keys.flatten!\n p_valid_keys.each do |k|\n l_missing_keys << k unless self.has_key?(k)\n end\n\n unless l_missing_keys.empty?\n raise ArgumentError.new(\"Missing required key(s): #{l_missing_keys.map(&:inspect).join(', ')}\")\n end\n\n end", "def key_note(note)\n # Specify valid tonics.\n valid_keys = [:cb, :b, :c, :cs, :db, :d, :ds, :eb, :e, :f, :fs, :gb, :g, :gs, :ab, :a, :as, :bb]\n if valid_keys.include?(note)\n # If the key is valid, we must also check for consistency with the type of scale.\n if @metadata[:key_type] == nil\n # No type specified so this is valid.\n @metadata[:key_note] = note\n elsif @metadata[:key_type] == :major\n if note != :gs && note != :ds && note != :as\n # The note is valid for a major key.\n @metadata[:key_note] = note\n else\n raise \"Key note #{ note } not valid for a #{ @metadata[:key_type] } key.\"\n end\n elsif @metadata[:key_type] == :minor\n if note != :cb || note != :gb || note != :db\n # The note is valid for a minor key.\n @metadata[:key_note] = note\n else\n raise \"Key note #{ note } not valid for a #{ @metadata[:key_type] } key.\"\n end\n else\n raise \"Invalid key type.\"\n end\n else\n raise \"The key: #{ note } is not valid.\"\n end\n return self\n end", "def decode_string_public_key(raw, offset=0, algo=nil)\n key_raw, str_read = decode_string(raw, offset)\n key, cert_read = decode_public_key(key_raw, 0, algo)\n\n if cert_read != key_raw.bytesize\n raise DecodeError, \"unexpected trailing data\"\n end\n\n [key, str_read]\n end", "def invalid_api_params?(allow_api, key)\n if allow_api\n key.to_s.length < 6\n else\n (1...6).include?(key.to_s.length)\n end\n end", "def bad_record! key, *args\n warn \"Bad record #{args.inspect[0..400]}\"\n puts [\"bad_record-\"+key.to_s, *args].join(\"\\t\")\n end", "def unmatched_keys; end", "def bad_record! key, *args\n warn \"Bad record #{args.inspect[0..400]}\"\n puts [\"bad_record-\"+key, *args].join(\"\\t\")\n end", "def private_key\n\t '-----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,3D37CD3A313CADA2 7c1TAxzv6Gn2OmZzVNtEnU9lqrEwRL65huGc9ewQQ7senY3rkBgIqBzqVarAfS0I 6OMimI57q7XywAiFn7CZ+L7fbXdNuvmGx5JDNRwylgGWR+hPi9JMKEAP1yjdJPRS 608pDXIliz5bO0GdvufQxQ91MPjE4Bs5AT8TIE3bzuFllBYJD/mLpkK4bOjLHswI 7W7afVctpYaRAwzb64Z+gUQZL0BIcQzG2wYvFU3vAs5sCtEy9o7riY/bBi78EEH6 go01DkgYLt8M7ApTwblJNJR0G/8bwy3oDgdieM42sFLzftxwjeBhIiF1ExH+KuYA ftAcROOfr8rduvNNc6jJcx2lyze+4joPjHDBXZr27bg3o3SwOQCIXUHe0DHG0PHn TbZkL2btHH36mTMq0j6P9R4t1wLhJ8Pq2LjLDwLhXw3Tb8aIX1tpShxyy9Yv8F84 Q6dfBLe4yqmvW1Db2nGmZ++gPua2OGWuNXwjivt2XrZ0fGAGri5j9bsqyvDsHwUS aRs8PaG97rgmyRGHYUoicBdgeFZhBHSLlU5F6RNUTOgK9QAHP4+bdKbMQxvhveh8 +v9o7Xa7BlqEvUYXIfBwEbHZoJx4t90XSndSS3chlfoEb6vcxOBmplUZlWs55aSL U7dW1MaE48Afav6TtM2VsN9RzwU8QSplpm7z9C9xkYVBMN6UcKIbnHH1yXdhTGEG uaEvPrtSh+BroAx1OmMjkmb0s1PjgDqLEtaYifP1OXgSS3uTqPBcpgUZDnuYQZmW Ihv7SvGdyWVQUgpv5LukyZPhXdlsCQ+8TlEYn4MOl87uxqo3KCVzVdmhAx2PWS/q wLcyOq0wJuvgAAtmI4/EnXVaP5P6WQ7rixfxdDfR1nI5TnDQkgs2xquyb0cms0J+ hXkIGvQOMAzq2Js3Ad7qyiklDASR20zZt6JPKTgZpLq682Fx+LJCCryAqjye2nAI 0w5SHEd80J/lAUEYo/HrNDBWS0JzD4lfERwUxgXxvynFI1ak38h0YP9RR2ka0pMI DJ8G6/w3Ir1qgLM/E+bTvp1YE683J/j1+vdYC/eoAbki2wgJAitYFdexLpw/qMvj xonY4iyhVkgzQb0GObesjPhr0CQ1gRC8p/A68Pk4cXejKTO95gUnD682Mu6lgYXQ e3rEnNVUruiPEzMKbkPLIsaWfUKfGRb0okQmuISXEfjyLfjkUgD6bxes+9KuHdvj pZze3dOgB1W6ZGsbrQ8ooXAOewYbhDcEqVsPOItVBoZ14CmCSd1X8RiW1dnfZBLa 5W8L7HaVLgiKUWlu2N6BE3etMK/fzhLh1K8WT6PxqzqVfJZZ9TYwVSYbcJuej0Hf ioHwYgqO22aZrp+ciJplCyOooFOKVVW45iLPtSHX64aE6FKbdPEPcndIOl0J9ah0 Hwicaw0ADP4STb83NysAZdHO2UVNEERkp2P4XmgeeH3gYHhPv3xCbbDejrrRJjeq VRer8i6HxiuJ/SxNKvbiwztF/44nWJ+9m2FoNqumTITdQAx7VU3681uEsO9ZbsJU Lbt0zwxna4X6WEtjdy5ExqLlU+wnzWgG+I11vgXSarye2oTuGPK8wjBkfEqdRTxs -----END RSA PRIVATE KEY----- '\n\tend", "def ssh_key_nice\n nice_key = \"\"\n ssh_key.split(\"\\n\").each do |key_slice|\n if key_slice.size < 20\n nice_key += key_slice + \"\\n\"\n else\n i = 0\n while i < key_slice.size\n nice_key += key_slice.slice(i..i+20) + \"\\n\"\n i += 21\n end\n end\n end \n return nice_key\n end", "def key_pem; end", "def test_key\n mrn = '5555'\n pmi = @pnt.add_mrn(defaults.tissue_bank, '5555')\n assert_equal(pmi.key, @pnt.key, 'Person key is not the MRN')\n # add the preferred SSN key\n expected = @pnt.social_security_number = '555-55-5555'\n assert_equal(expected, @pnt.key, 'Person key is not the SSN')\n end", "def schema_is_valid_key_value?(key, value, trace)\n schema_valid_trace(\"schema_is_valid_key_value?\", value, trace, key)\n ((key.is_a?(String)) ?\n ((key =~ /^\\|OPT.*\\|/) ?\n ((value.is_a?(Hash) && (value.keys.length == 1)) ?\n schema_is_valid_hash?(value, trace) :\n schema_valid_error(value, \"Schema OPT value not 1-keyed Hash\", trace)) :\n ((key =~ /^\\|ALT.*\\|/) ?\n ((value.is_a?(Hash) && (value.keys.length == 2)) ?\n schema_is_valid_hash?(value, trace) :\n schema_valid_error(value, \"Schema ALT Value not 2-keyed Hash\", trace)) :\n schema_is_valid_internal?(value, trace))) :\n schema_valid_error(key, \"Schema key not of type String\", trace))\n end", "def valid_keys?(message)\n [:sender, :sent_to, :type, :uid] - message.keys == []\n end", "def unrecognized_keys(expected, given)\n given.keys - expected\n end", "def always_return_actual?(key)\n key.start_with?('errors.', 'support.', 'number.', 'javascript.', 'date.formats.',\n 'time.formats.') ||\n # The html passed to the key should always be returned.\n key.end_with?('_html')\n end", "def keys_valid?\n valid = true\n msg = []\n required_keys = %w(EMAIL_SMTP_DOMAIN EMAIL_SMTP_PORT FEEDBACK_FROM_EMAIL FEEDBACK_SMTP_AUTH_USER FEEDBACK_SMTP_AUTH_PASSWORD FEEDBACK_TO_EMAIL BACKUP_TYPE SERVER_NAME S3_BUCKET_PREFIX S3_BUCKET_SEPARATOR S3CMD_PATH ROOT_DIR TMP_DIR LOG_DIR BACKUP_SERVER_TIME)\n mysql_keys = %w(MYSQL_USER MYSQL_PASSWORD)\n mitb_keys = %w(MAIL_IN_A_BOX_BACKUP_DIRECTORY MAIL_IN_A_BOX_S3_DIRECTORY)\n missing_keys = []\n keys = required_keys\n if variable_is_true?('HAS_MYSQL')\n keys << mysql_keys\n end\n if variable_is_true?('HAS_MAIL_IN_A_BOX')\n keys << mitb_keys\n end\n keys.flatten!\n keys.each do |key|\n if !variable_exists? key\n missing_keys << key\n end\n end\n\n if missing_keys.length > 0\n msg << \"ERROR: the following keys are missing values: #{missing_keys.join(', ')}\"\n valid = false\n end\n\n\n # make sure the required directories exist\n if !File.exists? ENV['TMP_DIR']\n msg << \"ERROR: the tmp directory '#{ENV['TMP_DIR']}' does not exist and must be created before running this script\"\n valid = false\n end\n if !File.exists? ENV['LOG_DIR']\n msg << \"ERROR: the log directory '#{ENV['LOG_DIR']}' does not exist and must be created before running this script\"\n valid = false\n end\n if variable_is_true?('HAS_MAIL_IN_A_BOX') && !File.exists?(ENV['MAIL_IN_A_BOX_BACKUP_DIRECTORY'])\n msg << \"ERROR: the Mail-In-A-Box backup directory '#{ENV['MAIL_IN_A_BOX_BACKUP_DIRECTORY']}' does not exist and must be created before running this script\"\n valid = false\n end\n\n return valid, msg\nend", "def validate_keys(ssh_keys)\n return false unless ssh_keys.is_a? Array\n ssh_keys.each do |entry|\n return false if entry.nil?\n return false if not\n (entry['key'].is_a? String and entry['key'].length > 0)\n return false if not\n (entry['type'].is_a? String and entry['type'].length > 0)\n return false if not\n (entry['comment'].nil? or\n (entry['comment'].is_a? String and entry['comment'].length > 0))\n end\n true\n end", "def key?(key)\n public_method_defined?(key.to_sym)\n end", "def validate_api_key\n unless self.api_key #&& (api_key[\"-\"] || self.api_endpoint)\n raise KeyyoError, \"You must set an api_key prior to making a call\"\n end\n end", "def valid_key(token)\n @api_client && ActiveSupport::SecurityUtils.secure_compare(@api_client&.key, Digest::SHA512.hexdigest(token))\n end", "def verify_root_key\r\n root_key_file = File.expand_path(File.join(File.dirname(__FILE__), \"..\", \"..\", \"root_key.rsa\"))\r\n if File.exist?(root_key_file)\r\n raise ApplicationSetupError, \"\\n\\n**Error: The file #{root_key_file} must be moved out of the root folder. Keep it in a secure location for emergency password recovery.**\\n\\n\\n\"\r\n end \r\n end", "def verify_signature\n @spki.verify(public_key)\n end", "def valid_format_for_credentials(possible_credentials)\n required_fields = [\"table\", \"hostname\", \"ips\", \"keyname\"]\n required_fields.each { |field|\n if !possible_credentials[field]\n return false\n end\n }\n\n return true\n end", "def handle_sync_key enc_key\n PRIVATE_KEY.private_decrypt enc_key\n end", "def ecdh_public_key_bytes; end" ]
[ "0.7068131", "0.698523", "0.66918844", "0.6560176", "0.6560176", "0.65575236", "0.6521562", "0.64730006", "0.64236367", "0.6412967", "0.6370177", "0.6334298", "0.63255316", "0.6294084", "0.6239767", "0.6216906", "0.61859053", "0.6165006", "0.60283136", "0.6022161", "0.6019604", "0.6006948", "0.5978312", "0.59305364", "0.5897526", "0.58733237", "0.5863884", "0.5855892", "0.58315384", "0.580321", "0.57958984", "0.5780408", "0.5752377", "0.574918", "0.57440764", "0.57414657", "0.5716249", "0.57150567", "0.5709237", "0.5700857", "0.569753", "0.5682781", "0.56821936", "0.56720567", "0.56409365", "0.5640203", "0.56383055", "0.56307286", "0.56202954", "0.560851", "0.560795", "0.56051314", "0.56043446", "0.55999684", "0.55969054", "0.55849415", "0.55755997", "0.5563566", "0.55614555", "0.55587053", "0.5557489", "0.5557489", "0.5546164", "0.55359685", "0.5530405", "0.55271035", "0.5517475", "0.551747", "0.55107", "0.55068916", "0.5506071", "0.550142", "0.549477", "0.54911476", "0.54837936", "0.5483682", "0.5477687", "0.5473501", "0.547271", "0.54710585", "0.5466968", "0.5458405", "0.54474026", "0.5443332", "0.54278976", "0.54276425", "0.5424525", "0.54238737", "0.54040843", "0.5402454", "0.53983444", "0.5397238", "0.539478", "0.53909713", "0.5378282", "0.5376621", "0.53749615", "0.53724897", "0.53590065", "0.5357915" ]
0.64606845
8
Update properties of this object
def update!(**args) @audit_log_configs = args[:audit_log_configs] if args.key?(:audit_log_configs) @service = args[:service] if args.key?(:service) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end", "def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end", "def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end", "def update\n # TODO: implement update\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update\n \n end", "def refresh\n set_attributes\n end", "def update(attrs)\n @attrs.update(attrs)\n self\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end", "def update_resource object, attributes\n object.update attributes\n end", "def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end", "def update\n \n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end", "def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end", "def update\n @objects.map(&:update);\n end", "def update\n raise NotImplementedError\n end", "def update\n raise NotImplementedError\n end", "def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end", "def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update\n end", "def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def modified_properties=(value)\n @modified_properties = value\n end", "def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end", "def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end", "def update\n\t\t\n\t\tend", "def set_props(props)\n @props.merge!(props)\n end", "def update() end", "def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end", "def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end", "def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end", "def update_attributes(attrs)\n super({})\n end", "def update\n @dirty = true\n end", "def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end", "def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end", "def update\n super\n end", "def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end", "def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end", "def properties=(value)\n @properties = value\n end", "def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end", "def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update ; end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def update_with(attributes)\n assign_attributes(attributes)\n end", "def update\n # don't need to update; hash is shared\n end", "def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end", "def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update\n raise NotImplementedError\n end", "def update_attributes attributes\n @attributes.merge! attributes\n end", "def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end", "def update\r\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end", "def update\n raise NotImplemented\n end", "def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end", "def update_values\n end", "def update_values\n end", "def update\n raise NotImplementedError\n end", "def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end", "def update attributes, collection #:nodoc:\n 0\n end", "def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end", "def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end", "def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end", "def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end", "def update\n set_deltatime\n set_last_update_at\n end" ]
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328", "0.6319025", "0.6283673", "0.6269463", "0.62639254", "0.62410724", "0.62170374", "0.62152076", "0.6210263", "0.6204041", "0.6204041", "0.62021106", "0.62017816", "0.62017", "0.61730784", "0.61730784", "0.6159277", "0.6156169", "0.61445665", "0.6125433", "0.61241156", "0.6121413", "0.6110477", "0.6105694", "0.61016303", "0.60845226", "0.6084427", "0.6065455", "0.6059506", "0.6054869", "0.6051708", "0.6051708", "0.60413384", "0.6030853", "0.6022535", "0.6015561", "0.59932375", "0.59898263", "0.5976479", "0.5973787", "0.59678394", "0.5963291", "0.5962048", "0.5961157", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.59500545", "0.59443134", "0.59443134", "0.59424853", "0.59424853", "0.593523", "0.5926413", "0.5924831", "0.592427", "0.59233046", "0.59233046", "0.5921224", "0.59144294", "0.59142506", "0.58887535", "0.58854496", "0.5883008", "0.58792305", "0.5876954", "0.5876954", "0.58744955", "0.5857968", "0.5845542", "0.5841629", "0.58363605", "0.5829255", "0.582919", "0.5822138", "0.58208305" ]
0.0
-1
Update properties of this object
def update!(**args) @exempted_members = args[:exempted_members] if args.key?(:exempted_members) @log_type = args[:log_type] if args.key?(:log_type) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end", "def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end", "def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end", "def update\n # TODO: implement update\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update\n \n end", "def refresh\n set_attributes\n end", "def update(attrs)\n @attrs.update(attrs)\n self\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end", "def update_resource object, attributes\n object.update attributes\n end", "def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end", "def update\n \n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end", "def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end", "def update\n @objects.map(&:update);\n end", "def update\n raise NotImplementedError\n end", "def update\n raise NotImplementedError\n end", "def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end", "def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update\n end", "def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def modified_properties=(value)\n @modified_properties = value\n end", "def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end", "def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end", "def update\n\t\t\n\t\tend", "def set_props(props)\n @props.merge!(props)\n end", "def update() end", "def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end", "def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end", "def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end", "def update_attributes(attrs)\n super({})\n end", "def update\n @dirty = true\n end", "def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end", "def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end", "def update\n super\n end", "def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end", "def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end", "def properties=(value)\n @properties = value\n end", "def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end", "def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update ; end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def update_with(attributes)\n assign_attributes(attributes)\n end", "def update\n # don't need to update; hash is shared\n end", "def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end", "def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update\n raise NotImplementedError\n end", "def update_attributes attributes\n @attributes.merge! attributes\n end", "def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end", "def update\r\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end", "def update\n raise NotImplemented\n end", "def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end", "def update_values\n end", "def update_values\n end", "def update\n raise NotImplementedError\n end", "def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end", "def update attributes, collection #:nodoc:\n 0\n end", "def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end", "def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end", "def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end", "def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end", "def update\n set_deltatime\n set_last_update_at\n end" ]
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328", "0.6319025", "0.6283673", "0.6269463", "0.62639254", "0.62410724", "0.62170374", "0.62152076", "0.6210263", "0.6204041", "0.6204041", "0.62021106", "0.62017816", "0.62017", "0.61730784", "0.61730784", "0.6159277", "0.6156169", "0.61445665", "0.6125433", "0.61241156", "0.6121413", "0.6110477", "0.6105694", "0.61016303", "0.60845226", "0.6084427", "0.6065455", "0.6059506", "0.6054869", "0.6051708", "0.6051708", "0.60413384", "0.6030853", "0.6022535", "0.6015561", "0.59932375", "0.59898263", "0.5976479", "0.5973787", "0.59678394", "0.5963291", "0.5962048", "0.5961157", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.59500545", "0.59443134", "0.59443134", "0.59424853", "0.59424853", "0.593523", "0.5926413", "0.5924831", "0.592427", "0.59233046", "0.59233046", "0.5921224", "0.59144294", "0.59142506", "0.58887535", "0.58854496", "0.5883008", "0.58792305", "0.5876954", "0.5876954", "0.58744955", "0.5857968", "0.5845542", "0.5841629", "0.58363605", "0.5829255", "0.582919", "0.5822138", "0.58208305" ]
0.0
-1
Update properties of this object
def update!(**args) @condition = args[:condition] if args.key?(:condition) @members = args[:members] if args.key?(:members) @role = args[:role] if args.key?(:role) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end", "def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end", "def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end", "def update\n # TODO: implement update\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update\n \n end", "def refresh\n set_attributes\n end", "def update(attrs)\n @attrs.update(attrs)\n self\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end", "def update_resource object, attributes\n object.update attributes\n end", "def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end", "def update\n \n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end", "def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end", "def update\n @objects.map(&:update);\n end", "def update\n raise NotImplementedError\n end", "def update\n raise NotImplementedError\n end", "def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end", "def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update\n end", "def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def modified_properties=(value)\n @modified_properties = value\n end", "def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end", "def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end", "def update\n\t\t\n\t\tend", "def set_props(props)\n @props.merge!(props)\n end", "def update() end", "def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end", "def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end", "def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end", "def update_attributes(attrs)\n super({})\n end", "def update\n @dirty = true\n end", "def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end", "def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end", "def update\n super\n end", "def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end", "def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end", "def properties=(value)\n @properties = value\n end", "def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end", "def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update ; end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def update_with(attributes)\n assign_attributes(attributes)\n end", "def update\n # don't need to update; hash is shared\n end", "def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end", "def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update\n raise NotImplementedError\n end", "def update_attributes attributes\n @attributes.merge! attributes\n end", "def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end", "def update\r\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end", "def update\n raise NotImplemented\n end", "def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end", "def update_values\n end", "def update_values\n end", "def update\n raise NotImplementedError\n end", "def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end", "def update attributes, collection #:nodoc:\n 0\n end", "def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end", "def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end", "def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end", "def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end", "def update\n set_deltatime\n set_last_update_at\n end" ]
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328", "0.6319025", "0.6283673", "0.6269463", "0.62639254", "0.62410724", "0.62170374", "0.62152076", "0.6210263", "0.6204041", "0.6204041", "0.62021106", "0.62017816", "0.62017", "0.61730784", "0.61730784", "0.6159277", "0.6156169", "0.61445665", "0.6125433", "0.61241156", "0.6121413", "0.6110477", "0.6105694", "0.61016303", "0.60845226", "0.6084427", "0.6065455", "0.6059506", "0.6054869", "0.6051708", "0.6051708", "0.60413384", "0.6030853", "0.6022535", "0.6015561", "0.59932375", "0.59898263", "0.5976479", "0.5973787", "0.59678394", "0.5963291", "0.5962048", "0.5961157", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.59500545", "0.59443134", "0.59443134", "0.59424853", "0.59424853", "0.593523", "0.5926413", "0.5924831", "0.592427", "0.59233046", "0.59233046", "0.5921224", "0.59144294", "0.59142506", "0.58887535", "0.58854496", "0.5883008", "0.58792305", "0.5876954", "0.5876954", "0.58744955", "0.5857968", "0.5845542", "0.5841629", "0.58363605", "0.5829255", "0.582919", "0.5822138", "0.58208305" ]
0.0
-1
Update properties of this object
def update!(**args) @matched_permissions = args[:matched_permissions] if args.key?(:matched_permissions) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end", "def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end", "def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end", "def update\n # TODO: implement update\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update\n \n end", "def refresh\n set_attributes\n end", "def update(attrs)\n @attrs.update(attrs)\n self\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end", "def update_resource object, attributes\n object.update attributes\n end", "def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end", "def update\n \n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end", "def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end", "def update\n @objects.map(&:update);\n end", "def update\n raise NotImplementedError\n end", "def update\n raise NotImplementedError\n end", "def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end", "def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update\n end", "def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def modified_properties=(value)\n @modified_properties = value\n end", "def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end", "def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end", "def update\n\t\t\n\t\tend", "def set_props(props)\n @props.merge!(props)\n end", "def update() end", "def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end", "def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end", "def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end", "def update_attributes(attrs)\n super({})\n end", "def update\n @dirty = true\n end", "def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end", "def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end", "def update\n super\n end", "def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end", "def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end", "def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end", "def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end", "def properties=(value)\n @properties = value\n end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update ; end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def update_with(attributes)\n assign_attributes(attributes)\n end", "def update\n # don't need to update; hash is shared\n end", "def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end", "def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update\n raise NotImplementedError\n end", "def update_attributes attributes\n @attributes.merge! attributes\n end", "def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end", "def update\r\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end", "def update\n raise NotImplemented\n end", "def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end", "def update_values\n end", "def update_values\n end", "def update\n raise NotImplementedError\n end", "def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end", "def update attributes, collection #:nodoc:\n 0\n end", "def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end", "def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end", "def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end", "def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end", "def update\n set_deltatime\n set_last_update_at\n end" ]
[ "0.70124525", "0.69187176", "0.69187176", "0.69187176", "0.69187176", "0.69187176", "0.6738901", "0.67084897", "0.67084897", "0.66983044", "0.66983044", "0.66983044", "0.66983044", "0.66188794", "0.6571416", "0.6538292", "0.65194744", "0.63953435", "0.63903284", "0.63903284", "0.63344294", "0.63216114", "0.6284898", "0.6271445", "0.62648237", "0.624251", "0.6218843", "0.6217826", "0.6211294", "0.6204883", "0.6204883", "0.6203174", "0.6203085", "0.6202945", "0.61754346", "0.61754346", "0.6159627", "0.61573356", "0.6146927", "0.61265624", "0.61233723", "0.61213213", "0.6110708", "0.61082405", "0.610203", "0.6087213", "0.60851586", "0.606328", "0.60598475", "0.6056013", "0.605159", "0.605159", "0.60428274", "0.6032607", "0.6025175", "0.6016861", "0.59932756", "0.5991629", "0.5977848", "0.59746736", "0.5967899", "0.59640163", "0.5963087", "0.59628224", "0.59534305", "0.59534305", "0.59534305", "0.59534305", "0.59534305", "0.59534305", "0.59534305", "0.59534305", "0.59529036", "0.594494", "0.594494", "0.59420687", "0.59420687", "0.59377116", "0.5927631", "0.5926637", "0.592564", "0.59237856", "0.59237856", "0.5923722", "0.59169865", "0.591586", "0.58917314", "0.58872443", "0.58862734", "0.58807427", "0.5880232", "0.5880232", "0.5877138", "0.5860484", "0.5846987", "0.58439326", "0.58367634", "0.58300084", "0.5829718", "0.58233184", "0.5822193" ]
0.0
-1
Update properties of this object
def update!(**args) @description = args[:description] if args.key?(:description) @expression = args[:expression] if args.key?(:expression) @location = args[:location] if args.key?(:location) @title = args[:title] if args.key?(:title) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end", "def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end", "def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end", "def update\n # TODO: implement update\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update\n \n end", "def refresh\n set_attributes\n end", "def update(attrs)\n @attrs.update(attrs)\n self\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end", "def update_resource object, attributes\n object.update attributes\n end", "def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end", "def update\n \n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end", "def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end", "def update\n @objects.map(&:update);\n end", "def update\n raise NotImplementedError\n end", "def update\n raise NotImplementedError\n end", "def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end", "def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update\n end", "def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def modified_properties=(value)\n @modified_properties = value\n end", "def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end", "def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end", "def update\n\t\t\n\t\tend", "def set_props(props)\n @props.merge!(props)\n end", "def update() end", "def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end", "def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end", "def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end", "def update_attributes(attrs)\n super({})\n end", "def update\n @dirty = true\n end", "def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end", "def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end", "def update\n super\n end", "def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end", "def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end", "def properties=(value)\n @properties = value\n end", "def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end", "def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update ; end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def update_with(attributes)\n assign_attributes(attributes)\n end", "def update\n # don't need to update; hash is shared\n end", "def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end", "def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update\n raise NotImplementedError\n end", "def update_attributes attributes\n @attributes.merge! attributes\n end", "def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end", "def update\r\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end", "def update\n raise NotImplemented\n end", "def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end", "def update_values\n end", "def update_values\n end", "def update\n raise NotImplementedError\n end", "def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end", "def update attributes, collection #:nodoc:\n 0\n end", "def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end", "def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end", "def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end", "def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end", "def update\n set_deltatime\n set_last_update_at\n end" ]
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328", "0.6319025", "0.6283673", "0.6269463", "0.62639254", "0.62410724", "0.62170374", "0.62152076", "0.6210263", "0.6204041", "0.6204041", "0.62021106", "0.62017816", "0.62017", "0.61730784", "0.61730784", "0.6159277", "0.6156169", "0.61445665", "0.6125433", "0.61241156", "0.6121413", "0.6110477", "0.6105694", "0.61016303", "0.60845226", "0.6084427", "0.6065455", "0.6059506", "0.6054869", "0.6051708", "0.6051708", "0.60413384", "0.6030853", "0.6022535", "0.6015561", "0.59932375", "0.59898263", "0.5976479", "0.5973787", "0.59678394", "0.5963291", "0.5962048", "0.5961157", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.59500545", "0.59443134", "0.59443134", "0.59424853", "0.59424853", "0.593523", "0.5926413", "0.5924831", "0.592427", "0.59233046", "0.59233046", "0.5921224", "0.59144294", "0.59142506", "0.58887535", "0.58854496", "0.5883008", "0.58792305", "0.5876954", "0.5876954", "0.58744955", "0.5857968", "0.5845542", "0.5841629", "0.58363605", "0.5829255", "0.582919", "0.5822138", "0.58208305" ]
0.0
-1
Update properties of this object
def update!(**args) @explanation = args[:explanation] if args.key?(:explanation) @policy = args[:policy] if args.key?(:policy) @project = args[:project] if args.key?(:project) @resource = args[:resource] if args.key?(:resource) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end", "def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end", "def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end", "def update\n # TODO: implement update\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update\n \n end", "def refresh\n set_attributes\n end", "def update(attrs)\n @attrs.update(attrs)\n self\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end", "def update_resource object, attributes\n object.update attributes\n end", "def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end", "def update\n \n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end", "def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end", "def update\n @objects.map(&:update);\n end", "def update\n raise NotImplementedError\n end", "def update\n raise NotImplementedError\n end", "def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end", "def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update\n end", "def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def modified_properties=(value)\n @modified_properties = value\n end", "def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end", "def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end", "def update\n\t\t\n\t\tend", "def set_props(props)\n @props.merge!(props)\n end", "def update() end", "def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end", "def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end", "def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end", "def update_attributes(attrs)\n super({})\n end", "def update\n @dirty = true\n end", "def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end", "def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end", "def update\n super\n end", "def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end", "def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end", "def properties=(value)\n @properties = value\n end", "def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end", "def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update ; end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def update_with(attributes)\n assign_attributes(attributes)\n end", "def update\n # don't need to update; hash is shared\n end", "def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end", "def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update\n raise NotImplementedError\n end", "def update_attributes attributes\n @attributes.merge! attributes\n end", "def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end", "def update\r\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end", "def update\n raise NotImplemented\n end", "def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end", "def update_values\n end", "def update_values\n end", "def update\n raise NotImplementedError\n end", "def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end", "def update attributes, collection #:nodoc:\n 0\n end", "def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end", "def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end", "def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end", "def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end", "def update\n set_deltatime\n set_last_update_at\n end" ]
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328", "0.6319025", "0.6283673", "0.6269463", "0.62639254", "0.62410724", "0.62170374", "0.62152076", "0.6210263", "0.6204041", "0.6204041", "0.62021106", "0.62017816", "0.62017", "0.61730784", "0.61730784", "0.6159277", "0.6156169", "0.61445665", "0.6125433", "0.61241156", "0.6121413", "0.6110477", "0.6105694", "0.61016303", "0.60845226", "0.6084427", "0.6065455", "0.6059506", "0.6054869", "0.6051708", "0.6051708", "0.60413384", "0.6030853", "0.6022535", "0.6015561", "0.59932375", "0.59898263", "0.5976479", "0.5973787", "0.59678394", "0.5963291", "0.5962048", "0.5961157", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.59500545", "0.59443134", "0.59443134", "0.59424853", "0.59424853", "0.593523", "0.5926413", "0.5924831", "0.592427", "0.59233046", "0.59233046", "0.5921224", "0.59144294", "0.59142506", "0.58887535", "0.58854496", "0.5883008", "0.58792305", "0.5876954", "0.5876954", "0.58744955", "0.5857968", "0.5845542", "0.5841629", "0.58363605", "0.5829255", "0.582919", "0.5822138", "0.58208305" ]
0.0
-1
Update properties of this object
def update!(**args) @permissions = args[:permissions] if args.key?(:permissions) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end", "def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end", "def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end", "def update\n # TODO: implement update\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update\n \n end", "def refresh\n set_attributes\n end", "def update(attrs)\n @attrs.update(attrs)\n self\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end", "def update_resource object, attributes\n object.update attributes\n end", "def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end", "def update\n \n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end", "def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end", "def update\n @objects.map(&:update);\n end", "def update\n raise NotImplementedError\n end", "def update\n raise NotImplementedError\n end", "def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end", "def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update\n end", "def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def modified_properties=(value)\n @modified_properties = value\n end", "def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end", "def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end", "def update\n\t\t\n\t\tend", "def set_props(props)\n @props.merge!(props)\n end", "def update() end", "def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end", "def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end", "def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end", "def update_attributes(attrs)\n super({})\n end", "def update\n @dirty = true\n end", "def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end", "def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end", "def update\n super\n end", "def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end", "def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end", "def properties=(value)\n @properties = value\n end", "def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end", "def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update ; end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def update_with(attributes)\n assign_attributes(attributes)\n end", "def update\n # don't need to update; hash is shared\n end", "def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end", "def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update\n raise NotImplementedError\n end", "def update_attributes attributes\n @attributes.merge! attributes\n end", "def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end", "def update\r\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end", "def update\n raise NotImplemented\n end", "def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end", "def update_values\n end", "def update_values\n end", "def update\n raise NotImplementedError\n end", "def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end", "def update attributes, collection #:nodoc:\n 0\n end", "def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end", "def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end", "def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end", "def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end", "def update\n set_deltatime\n set_last_update_at\n end" ]
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328", "0.6319025", "0.6283673", "0.6269463", "0.62639254", "0.62410724", "0.62170374", "0.62152076", "0.6210263", "0.6204041", "0.6204041", "0.62021106", "0.62017816", "0.62017", "0.61730784", "0.61730784", "0.6159277", "0.6156169", "0.61445665", "0.6125433", "0.61241156", "0.6121413", "0.6110477", "0.6105694", "0.61016303", "0.60845226", "0.6084427", "0.6065455", "0.6059506", "0.6054869", "0.6051708", "0.6051708", "0.60413384", "0.6030853", "0.6022535", "0.6015561", "0.59932375", "0.59898263", "0.5976479", "0.5973787", "0.59678394", "0.5963291", "0.5962048", "0.5961157", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.59500545", "0.59443134", "0.59443134", "0.59424853", "0.59424853", "0.593523", "0.5926413", "0.5924831", "0.592427", "0.59233046", "0.59233046", "0.5921224", "0.59144294", "0.59142506", "0.58887535", "0.58854496", "0.5883008", "0.58792305", "0.5876954", "0.5876954", "0.58744955", "0.5857968", "0.5845542", "0.5841629", "0.58363605", "0.5829255", "0.582919", "0.5822138", "0.58208305" ]
0.0
-1
Update properties of this object
def update!(**args) @audit_configs = args[:audit_configs] if args.key?(:audit_configs) @bindings = args[:bindings] if args.key?(:bindings) @etag = args[:etag] if args.key?(:etag) @version = args[:version] if args.key?(:version) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end", "def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end", "def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end", "def update\n # TODO: implement update\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update\n \n end", "def refresh\n set_attributes\n end", "def update(attrs)\n @attrs.update(attrs)\n self\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end", "def update_resource object, attributes\n object.update attributes\n end", "def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end", "def update\n \n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end", "def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end", "def update\n @objects.map(&:update);\n end", "def update\n raise NotImplementedError\n end", "def update\n raise NotImplementedError\n end", "def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end", "def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update\n end", "def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def modified_properties=(value)\n @modified_properties = value\n end", "def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end", "def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end", "def update\n\t\t\n\t\tend", "def set_props(props)\n @props.merge!(props)\n end", "def update() end", "def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end", "def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end", "def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end", "def update_attributes(attrs)\n super({})\n end", "def update\n @dirty = true\n end", "def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end", "def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end", "def update\n super\n end", "def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end", "def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end", "def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end", "def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end", "def properties=(value)\n @properties = value\n end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update ; end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def update_with(attributes)\n assign_attributes(attributes)\n end", "def update\n # don't need to update; hash is shared\n end", "def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end", "def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update\n raise NotImplementedError\n end", "def update_attributes attributes\n @attributes.merge! attributes\n end", "def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end", "def update\r\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end", "def update\n raise NotImplemented\n end", "def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end", "def update_values\n end", "def update_values\n end", "def update\n raise NotImplementedError\n end", "def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end", "def update attributes, collection #:nodoc:\n 0\n end", "def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end", "def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end", "def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end", "def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end", "def update\n set_deltatime\n set_last_update_at\n end" ]
[ "0.70124525", "0.69187176", "0.69187176", "0.69187176", "0.69187176", "0.69187176", "0.6738901", "0.67084897", "0.67084897", "0.66983044", "0.66983044", "0.66983044", "0.66983044", "0.66188794", "0.6571416", "0.6538292", "0.65194744", "0.63953435", "0.63903284", "0.63903284", "0.63344294", "0.63216114", "0.6284898", "0.6271445", "0.62648237", "0.624251", "0.6218843", "0.6217826", "0.6211294", "0.6204883", "0.6204883", "0.6203174", "0.6203085", "0.6202945", "0.61754346", "0.61754346", "0.6159627", "0.61573356", "0.6146927", "0.61265624", "0.61233723", "0.61213213", "0.6110708", "0.61082405", "0.610203", "0.6087213", "0.60851586", "0.606328", "0.60598475", "0.6056013", "0.605159", "0.605159", "0.60428274", "0.6032607", "0.6025175", "0.6016861", "0.59932756", "0.5991629", "0.5977848", "0.59746736", "0.5967899", "0.59640163", "0.5963087", "0.59628224", "0.59534305", "0.59534305", "0.59534305", "0.59534305", "0.59534305", "0.59534305", "0.59534305", "0.59534305", "0.59529036", "0.594494", "0.594494", "0.59420687", "0.59420687", "0.59377116", "0.5927631", "0.5926637", "0.592564", "0.59237856", "0.59237856", "0.5923722", "0.59169865", "0.591586", "0.58917314", "0.58872443", "0.58862734", "0.58807427", "0.5880232", "0.5880232", "0.5877138", "0.5860484", "0.5846987", "0.58439326", "0.58367634", "0.58300084", "0.5829718", "0.58233184", "0.5822193" ]
0.0
-1
Update properties of this object
def update!(**args) @next_page_token = args[:next_page_token] if args.key?(:next_page_token) @results = args[:results] if args.key?(:results) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end", "def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end", "def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end", "def update\n # TODO: implement update\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update\n \n end", "def refresh\n set_attributes\n end", "def update(attrs)\n @attrs.update(attrs)\n self\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end", "def update_resource object, attributes\n object.update attributes\n end", "def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end", "def update\n \n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end", "def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end", "def update\n @objects.map(&:update);\n end", "def update\n raise NotImplementedError\n end", "def update\n raise NotImplementedError\n end", "def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end", "def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update\n end", "def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def modified_properties=(value)\n @modified_properties = value\n end", "def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end", "def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end", "def update\n\t\t\n\t\tend", "def set_props(props)\n @props.merge!(props)\n end", "def update() end", "def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end", "def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end", "def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end", "def update_attributes(attrs)\n super({})\n end", "def update\n @dirty = true\n end", "def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end", "def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end", "def update\n super\n end", "def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end", "def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end", "def properties=(value)\n @properties = value\n end", "def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end", "def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update ; end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def update_with(attributes)\n assign_attributes(attributes)\n end", "def update\n # don't need to update; hash is shared\n end", "def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end", "def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update\n raise NotImplementedError\n end", "def update_attributes attributes\n @attributes.merge! attributes\n end", "def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end", "def update\r\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end", "def update\n raise NotImplemented\n end", "def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end", "def update_values\n end", "def update_values\n end", "def update\n raise NotImplementedError\n end", "def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end", "def update attributes, collection #:nodoc:\n 0\n end", "def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end", "def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end", "def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end", "def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end", "def update\n set_deltatime\n set_last_update_at\n end" ]
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328", "0.6319025", "0.6283673", "0.6269463", "0.62639254", "0.62410724", "0.62170374", "0.62152076", "0.6210263", "0.6204041", "0.6204041", "0.62021106", "0.62017816", "0.62017", "0.61730784", "0.61730784", "0.6159277", "0.6156169", "0.61445665", "0.6125433", "0.61241156", "0.6121413", "0.6110477", "0.6105694", "0.61016303", "0.60845226", "0.6084427", "0.6065455", "0.6059506", "0.6054869", "0.6051708", "0.6051708", "0.60413384", "0.6030853", "0.6022535", "0.6015561", "0.59932375", "0.59898263", "0.5976479", "0.5973787", "0.59678394", "0.5963291", "0.5962048", "0.5961157", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.59500545", "0.59443134", "0.59443134", "0.59424853", "0.59424853", "0.593523", "0.5926413", "0.5924831", "0.592427", "0.59233046", "0.59233046", "0.5921224", "0.59144294", "0.59142506", "0.58887535", "0.58854496", "0.5883008", "0.58792305", "0.5876954", "0.5876954", "0.58744955", "0.5857968", "0.5845542", "0.5841629", "0.58363605", "0.5829255", "0.582919", "0.5822138", "0.58208305" ]
0.0
-1
Update properties of this object
def update!(**args) @next_page_token = args[:next_page_token] if args.key?(:next_page_token) @results = args[:results] if args.key?(:results) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end", "def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end", "def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end", "def update\n # TODO: implement update\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update\n \n end", "def refresh\n set_attributes\n end", "def update(attrs)\n @attrs.update(attrs)\n self\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end", "def update_resource object, attributes\n object.update attributes\n end", "def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end", "def update\n \n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end", "def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end", "def update\n @objects.map(&:update);\n end", "def update\n raise NotImplementedError\n end", "def update\n raise NotImplementedError\n end", "def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end", "def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update\n end", "def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def modified_properties=(value)\n @modified_properties = value\n end", "def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end", "def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end", "def update\n\t\t\n\t\tend", "def set_props(props)\n @props.merge!(props)\n end", "def update() end", "def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end", "def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end", "def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end", "def update_attributes(attrs)\n super({})\n end", "def update\n @dirty = true\n end", "def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end", "def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end", "def update\n super\n end", "def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end", "def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end", "def properties=(value)\n @properties = value\n end", "def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end", "def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update ; end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def update_with(attributes)\n assign_attributes(attributes)\n end", "def update\n # don't need to update; hash is shared\n end", "def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end", "def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update\n raise NotImplementedError\n end", "def update_attributes attributes\n @attributes.merge! attributes\n end", "def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end", "def update\r\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end", "def update\n raise NotImplemented\n end", "def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end", "def update_values\n end", "def update_values\n end", "def update\n raise NotImplementedError\n end", "def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end", "def update attributes, collection #:nodoc:\n 0\n end", "def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end", "def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end", "def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end", "def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end", "def update\n set_deltatime\n set_last_update_at\n end" ]
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328", "0.6319025", "0.6283673", "0.6269463", "0.62639254", "0.62410724", "0.62170374", "0.62152076", "0.6210263", "0.6204041", "0.6204041", "0.62021106", "0.62017816", "0.62017", "0.61730784", "0.61730784", "0.6159277", "0.6156169", "0.61445665", "0.6125433", "0.61241156", "0.6121413", "0.6110477", "0.6105694", "0.61016303", "0.60845226", "0.6084427", "0.6065455", "0.6059506", "0.6054869", "0.6051708", "0.6051708", "0.60413384", "0.6030853", "0.6022535", "0.6015561", "0.59932375", "0.59898263", "0.5976479", "0.5973787", "0.59678394", "0.5963291", "0.5962048", "0.5961157", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.59500545", "0.59443134", "0.59443134", "0.59424853", "0.59424853", "0.593523", "0.5926413", "0.5924831", "0.592427", "0.59233046", "0.59233046", "0.5921224", "0.59144294", "0.59142506", "0.58887535", "0.58854496", "0.5883008", "0.58792305", "0.5876954", "0.5876954", "0.58744955", "0.5857968", "0.5845542", "0.5841629", "0.58363605", "0.5829255", "0.582919", "0.5822138", "0.58208305" ]
0.0
-1
Update properties of this object
def update!(**args) @additional_attributes = args[:additional_attributes] if args.key?(:additional_attributes) @asset_type = args[:asset_type] if args.key?(:asset_type) @description = args[:description] if args.key?(:description) @display_name = args[:display_name] if args.key?(:display_name) @labels = args[:labels] if args.key?(:labels) @location = args[:location] if args.key?(:location) @name = args[:name] if args.key?(:name) @network_tags = args[:network_tags] if args.key?(:network_tags) @project = args[:project] if args.key?(:project) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_properties(hash)\n hash.each do |key, value|\n setter_method = \"#{key}=\"\n if self.respond_to?(setter_method)\n self.send(setter_method, value)\n end\n end\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n end", "def refresh\n self.class.base_properties.each_with_index do |prop, prop_id|\n @properties[prop] = get_property(prop_id)\n end\n refresh_features\n refresh_status\n refresh_config\n self\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update!(**args)\n @subobject_properties = args[:subobject_properties] if args.key?(:subobject_properties)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update(attrs)\n super(attrs)\n end", "def update_properties!(branch_id=nil)\n properties = fetch_properties(false, branch_id)\n length = properties.length\n counter = 0\n properties.each do |property|\n counter += 1\n if Vebra.debugging?\n puts \"[Vebra]: #{counter}/#{length}: live updating property with Vebra ref: #{property.attributes[:vebra_ref]}\"\n end\n live_update!(property)\n Vebra.set_last_updated_at(Time.now) if counter == length\n end\n end", "def update_self obj\n obj.each do |k,v|\n instance_variable_set(\"@#{k}\", v) if v\n end\n end", "def update_attributes(properties_hash)\n self.class.get_class_properties.each do |property|\n key = property[:name].to_sym\n if properties_hash.has_key? key\n self.setValue(properties_hash[key], forKey:key)\n end\n end\n end", "def update\n # TODO: implement update\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @states = args[:states] if args.key?(:states)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @object = args[:object] if args.key?(:object)\n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @total_value_count = args[:total_value_count] if args.key?(:total_value_count)\n @value = args[:value] if args.key?(:value)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update\n \n end", "def refresh\n set_attributes\n end", "def update(attrs)\n @attrs.update(attrs)\n self\n end", "def update!(**args)\n @properties = args[:properties] if args.key?(:properties)\n @source = args[:source] if args.key?(:source)\n end", "def update_resource object, attributes\n object.update attributes\n end", "def update(attrs)\n @attrs ||= {}\n @attrs.update(attrs)\n self\n end", "def update\n \n end", "def update!(**args)\n @property = args[:property] if args.key?(:property)\n @schema = args[:schema] if args.key?(:schema)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def update!(**args)\n @name = args[:name] if args.key?(:name)\n @options = args[:options] if args.key?(:options)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def _update!\n self.class.properties.each do |property, predicate|\n if dirty?(property)\n self.class.repository_or_fail.delete([subject, predicate[:predicate], nil])\n if self.class.is_list?(property)\n repo = RDF::Repository.new\n attribute_get(property).each do |value|\n repo << RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(value, self.class.properties[property][:type]))\n end\n self.class.repository_or_fail.insert(*repo)\n else\n self.class.repository_or_fail.insert(RDF::Statement.new(subject, predicate[:predicate], self.class.build_rdf_value(attribute_get(property), self.class.properties[property][:type])))\n end\n end\n @dirty[property] = nil\n @attributes[:original][property] = attribute_get(property)\n end\n self.class.repository_or_fail.insert(RDF::Statement.new(@subject, RDF.type, type)) unless type.nil?\n end", "def update(attributes = {})\n super(attributes)\n retrieve!\n self\n end", "def update\n @objects.map(&:update);\n end", "def update\n raise NotImplementedError\n end", "def update\n raise NotImplementedError\n end", "def live_update!(property)\n property_class = Vebra.models[:property][:class].to_s.camelize.constantize\n\n # ensure we have the full property attributes\n property.get_property if !property.attributes[:status] && property.attributes[:action] != 'deleted'\n\n # find & update or build a new property\n property_model = property_class.find_or_initialize_by_vebra_ref(property.attributes[:vebra_ref])\n\n # make sure property object is not empty\n return false if !property.attributes || !property.attributes[:property_type]\n\n # if the property has been deleted, mark it appropriately and move on\n if property.attributes[:action] == 'deleted'\n return property_model.destroy\n end\n\n # extract accessible attributes for the property\n property_accessibles = property_class.accessible_attributes.map(&:to_sym)\n property_attributes = property.attributes.inject({}) do |result, (key, value)|\n result[key] = value if property_accessibles.include?(key)\n result\n end\n\n # update the property model's attributes\n property_model.no_callbacks = true if property_model.respond_to?(:no_callbacks)\n property_model.update_attributes(property_attributes)\n\n # find & update or build a new address\n if Vebra.models[:address]\n address_class = Vebra.models[:address][:class].to_s.camelize.constantize\n address_model = property_model.send(Vebra.models[:property][:address_method])\n address_model = property_model.send(\"build_#{Vebra.models[:property][:address_method]}\") unless address_model\n\n # extract accessible attributes for the address\n address_accessibles = address_class.accessible_attributes.map(&:to_sym)\n address_attributes = property.attributes[:address].inject({}) do |result, (key, value)|\n result[key] = value if address_accessibles.include?(key)\n result\n end\n\n # update the address model's attributes\n address_model.update_attributes(address_attributes)\n end\n\n # find & update or build new rooms\n if Vebra.models[:room]\n room_class = Vebra.models[:room][:class].to_s.camelize.constantize\n\n # accessible attributes for the rooms\n room_accessibles = room_class.accessible_attributes.map(&:to_sym)\n\n # delete any rooms which are no longer present\n property_rooms = property.attributes[:rooms] || []\n property_model_rooms = property_model.send(Vebra.models[:property][:rooms_method])\n refs_to_delete = property_model_rooms.map(&:vebra_ref) - property_rooms.map { |r| r[:vebra_ref] }\n property_model_rooms.each do |room|\n room.destroy if refs_to_delete.include?(room.vebra_ref)\n end\n\n # find & update or build new rooms\n property_rooms.each do |room|\n room_model = room_class.find_by_property_id_and_vebra_ref(property_model.id, room[:vebra_ref])\n room_model = property_model_rooms.build unless room_model\n\n # extract accessible attributes for the room\n room_attributes = room.inject({}) do |result, (key, value)|\n result[key] = value if room_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n room_model.update_attributes(room_attributes)\n end\n end\n\n # find & update or build new file attachments\n if Vebra.models[:file]\n file_class = Vebra.models[:file][:class].to_s.camelize.constantize\n\n # accessible attributes for the files\n file_accessibles = file_class.accessible_attributes.map(&:to_sym)\n\n # first normalize the collection (currently nested collections)\n property_files = property.attributes[:files].inject([]) do |result, (kind, collection)|\n collection.each do |file|\n file[:type] = kind.to_s.singularize.camelize if file_accessibles.include?(:type)\n file[\"remote_#{Vebra.models[:file][:attachment_method]}_url\".to_sym] = file.delete(:url)\n # if file[:type] is set, it means the attachment file class can be subclassed. In this\n # case we need to ensure that the subclass exists. If not, we ignore this file\n begin\n file[:type].constantize if file_accessibles.include?(:type)\n result << file\n rescue NameError => e\n # ignore - this means the subclass does not exist\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n\n result\n end\n\n # delete any files which are no longer present\n property_model_files = property_model.send(Vebra.models[:property][:files_method])\n refs_to_delete = property_model_files.map(&:vebra_ref) - property_files.map { |f| f[:vebra_ref] }\n property_model_files.each do |file|\n file.destroy if refs_to_delete.include?(file.vebra_ref)\n end\n\n # find & update or build new files\n property_files.each do |file|\n begin\n file_model = property_model_files.find_by_vebra_ref(file[:vebra_ref])\n file_model = property_model_files.build unless file_model\n\n # extract accessible attributes for the file\n file_attributes = file.inject({}) do |result, (key, value)|\n result[key] = value if file_accessibles.include?(key)\n result\n end\n\n # update the room model's attributes\n file_model.update_attributes(file_attributes)\n rescue CarrierWave::ProcessingError, OpenURI::HTTPError => e\n # just ignore the file\n puts \"[Vebra]: #{e.message}\" if Vebra.debugging?\n end\n end\n end\n\n property_model.no_callbacks = false if property_model.respond_to?(:no_callbacks)\n property_model.save\n return property_model\n end", "def update!(**args)\n @id = args[:id] if args.key?(:id)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update\n end", "def update!(**args)\n @mid = args[:mid] if args.key?(:mid)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def modified_properties=(value)\n @modified_properties = value\n end", "def apply_properties!(properties)\n # Non-commutitivity etc. eventually.\n end", "def set_properties(hash)\n hash.each do |key, value|\n add_or_remove_ostruct_member(key, value)\n end\n rest_reset_properties\n end", "def update\n\t\t\n\t\tend", "def set_props(props)\n @props.merge!(props)\n end", "def update() end", "def update!(**args)\n @property_definitions = args[:property_definitions] if args.key?(:property_definitions)\n end", "def assign_properties\n self.properties ||= {}\n listing_properties.each do |prop|\n self.properties[prop.key] ||= prop.value\n end\n end", "def change_properties(new_current_floor, new_next_floor, new_movement)\n @current_floor = new_current_floor\n @next_floor = new_next_floor\n @movement = new_movement\n end", "def update!(**args)\n @property_value = args[:property_value] if args.key?(:property_value)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update!(**args)\n @property_name = args[:property_name] if args.key?(:property_name)\n end", "def update(attributes)\n (@attributes ||= {}).merge! attributes\n\n (self.class.attr_initializables & attributes.keys).each do |name|\n instance_variable_set :\"@#{name}\", attributes[name]\n end\n\n self\n end", "def update_attributes(attrs)\n super({})\n end", "def update\n @dirty = true\n end", "def update\n\n # Run through the mixin updates\n colourable_update\n movable_update\n\n end", "def set(props)\n props.each do |prop, val|\n self.send(:\"#{ prop }=\", val)\n end\n end", "def update\n super\n end", "def update!(**args)\n @property_id = args[:property_id] if args.key?(:property_id)\n @value_status = args[:value_status] if args.key?(:value_status)\n end", "def update!(**args)\n @object_size_bytes = args[:object_size_bytes] if args.key?(:object_size_bytes)\n @object_version = args[:object_version] if args.key?(:object_version)\n end", "def movable_update\n\n # Work through the different aspects we update\n movable_location_update\n movable_size_update\n movable_angle_update\n\n end", "def properties=(value)\n @properties = value\n end", "def update(attrs)\n attrs.each_pair do |key, value|\n send(\"#{key}=\", value) if respond_to?(\"#{key}=\")\n # attributes[key] = value <- lets make use of virtual attributes too\n end\n end", "def update(context={})\n self.pre_cast_attributes\n m2o = @relations.reject{|k, v| !self.class.many2one_relations.has_key?(k)}\n vals = @attributes.reject {|key, value| key == 'id'}.merge(m2o.merge(m2o){|k, v| v.is_a?(Array) ? v[0] : v})\n self.class.rpc_execute('write', self.id, vals, context)\n reload_from_record!(self.class.find(self.id, :context => context))\n end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update; end", "def update ; end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def update!(**args)\n @freshness_duration = args[:freshness_duration] if args.key?(:freshness_duration)\n @freshness_property = args[:freshness_property] if args.key?(:freshness_property)\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def method_missing(method, *args)\n super if @updated\n set_up_properties_from(@client.get(@path))\n self.send method, *args\n end", "def update_with(attributes)\n assign_attributes(attributes)\n end", "def update\n # don't need to update; hash is shared\n end", "def update(attributes)\n HashProxy.with(attributes) do |proxy|\n self.class.attribute_names.each do |name|\n send(\"#{name}=\", proxy[name]) if proxy.key?(name)\n end\n end\n save\n end", "def update!(**args)\n @object_id_prop = args[:object_id_prop] if args.key?(:object_id_prop)\n @relation = args[:relation] if args.key?(:relation)\n @subject_id = args[:subject_id] if args.key?(:subject_id)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update!(**args)\n @boolean_property_options = args[:boolean_property_options] if args.key?(:boolean_property_options)\n @date_property_options = args[:date_property_options] if args.key?(:date_property_options)\n @display_options = args[:display_options] if args.key?(:display_options)\n @double_property_options = args[:double_property_options] if args.key?(:double_property_options)\n @enum_property_options = args[:enum_property_options] if args.key?(:enum_property_options)\n @html_property_options = args[:html_property_options] if args.key?(:html_property_options)\n @integer_property_options = args[:integer_property_options] if args.key?(:integer_property_options)\n @is_facetable = args[:is_facetable] if args.key?(:is_facetable)\n @is_repeatable = args[:is_repeatable] if args.key?(:is_repeatable)\n @is_returnable = args[:is_returnable] if args.key?(:is_returnable)\n @is_sortable = args[:is_sortable] if args.key?(:is_sortable)\n @is_suggestable = args[:is_suggestable] if args.key?(:is_suggestable)\n @is_wildcard_searchable = args[:is_wildcard_searchable] if args.key?(:is_wildcard_searchable)\n @name = args[:name] if args.key?(:name)\n @object_property_options = args[:object_property_options] if args.key?(:object_property_options)\n @text_property_options = args[:text_property_options] if args.key?(:text_property_options)\n @timestamp_property_options = args[:timestamp_property_options] if args.key?(:timestamp_property_options)\n end", "def update\n raise NotImplementedError\n end", "def update_attributes attributes\n @attributes.merge! attributes\n end", "def update!(**args)\n @async_options = args[:async_options] if args.key?(:async_options)\n @input_mappings = args[:input_mappings] if args.key?(:input_mappings)\n @name_property = args[:name_property] if args.key?(:name_property)\n @validation_options = args[:validation_options] if args.key?(:validation_options)\n end", "def update\r\n end", "def update!(**args)\n @hash_prop = args[:hash_prop] if args.key?(:hash_prop)\n @type = args[:type] if args.key?(:type)\n end", "def update\n raise NotImplemented\n end", "def update_obj\n mean, sd = rating.to_glicko_rating\n @obj.rating = mean\n @obj.rating_deviation = sd\n @obj.volatility = volatility\n end", "def update_values\n end", "def update_values\n end", "def update\n raise NotImplementedError\n end", "def update!(**args)\n @answers_header_signals = args[:answers_header_signals] if args.key?(:answers_header_signals)\n @property_value = args[:property_value] if args.key?(:property_value)\n @response_meaning_application = args[:response_meaning_application] if args.key?(:response_meaning_application)\n end", "def update!(**args)\n @create_time = args[:create_time] if args.key?(:create_time)\n @method_prop = args[:method_prop] if args.key?(:method_prop)\n @name = args[:name] if args.key?(:name)\n @state = args[:state] if args.key?(:state)\n end", "def update attributes, collection #:nodoc:\n 0\n end", "def update_property_groups(roll)\n @property_groups.each { |_, v| v.update_rent(roll) }\n end", "def update!(**args)\n @source_property = args[:source_property] if args.key?(:source_property)\n end", "def update_info(update_attr_hash)\n update_attr_hash.each do |k,v| \n\t\t\tself.send(\"#{k}=\",v)\n\t\tend\n end", "def update_properties(path, properties)\n prop_patch = PropPatch.new(properties)\n emit('propPatch', [path, prop_patch])\n prop_patch.commit\n\n prop_patch.result\n end", "def update\n set_deltatime\n set_last_update_at\n end" ]
[ "0.7012263", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.69181895", "0.67403597", "0.6709326", "0.6709326", "0.6696149", "0.6696149", "0.6696149", "0.6696149", "0.6618882", "0.6571848", "0.65386343", "0.65178275", "0.6394807", "0.6389745", "0.6389745", "0.63328", "0.6319025", "0.6283673", "0.6269463", "0.62639254", "0.62410724", "0.62170374", "0.62152076", "0.6210263", "0.6204041", "0.6204041", "0.62021106", "0.62017816", "0.62017", "0.61730784", "0.61730784", "0.6159277", "0.6156169", "0.61445665", "0.6125433", "0.61241156", "0.6121413", "0.6110477", "0.6105694", "0.61016303", "0.60845226", "0.6084427", "0.6065455", "0.6059506", "0.6054869", "0.6051708", "0.6051708", "0.60413384", "0.6030853", "0.6022535", "0.6015561", "0.59932375", "0.59898263", "0.5976479", "0.5973787", "0.59678394", "0.5963291", "0.5962048", "0.5961157", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.5950731", "0.59500545", "0.59443134", "0.59443134", "0.59424853", "0.59424853", "0.593523", "0.5926413", "0.5924831", "0.592427", "0.59233046", "0.59233046", "0.5921224", "0.59144294", "0.59142506", "0.58887535", "0.58854496", "0.5883008", "0.58792305", "0.5876954", "0.5876954", "0.58744955", "0.5857968", "0.5845542", "0.5841629", "0.58363605", "0.5829255", "0.582919", "0.5822138", "0.58208305" ]
0.0
-1
In JRuby HTMLScanner is somehow loaded before this class and all String returned do not use StringFormatter refinement. Mapping HTMLScanner output with `to_s` method ensures those strings are using the StringFormatter refinement.
def periods @periods ||= HTMLScanner.new(thead).all("th").map { |e| e.to_s.strip_html.squish } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def html_simple\n HtmlFormatter.new(self, options).to_s\n end", "def to_s\n @parser ||= WikitextParser.new\n @parsed ||= @parser.parse(@string).to_s\n end", "def html_string\n @html.join(\"\")\n end", "def html2text\n doc = self.scrape.hdoc\n text = node_to_text(doc)\n# text.gsub!(NamedCharRegex){|s| \"#{lookup_named_char(s)}\"}\n # clean up white space\n text.gsub!(\"\\r\",\" \")\n text.squeeze!(\" \")\n text.strip!\n ret = ''\n text.split(/\\n/).each do |l|\n l.strip!\n next if l == ''\n next if l =~ /^\\?+$/\n ret += \"#{l}\\n\"\n end\n return ret\n end", "def to_string(html, features, version)\n self.parse(html).accept(Visitors::ToString.new(features, version))\n end", "def ansi_to_html(string); end", "def html_to_ansi(string); end", "def html_to_pretty_text(html_string)\n Loofah.fragment(html_string).to_text\n end", "def to_s\n to_html\n end", "def to_s\r\n pretty_output\r\n end", "def to_s\n contents.to_s\n end", "def render_to_string(*)\n result = super\n if result.respond_to?(:each)\n string = +\"\"\n result.each { |r| string << r }\n string\n else\n result\n end\n end", "def html\n HtmlFormatter.new(self, options.merge(:highlight_words => true)).to_s\n end", "def to_s\n text.to_s\n end", "def stextilize(text)\n if text.blank?\n \"\"\n else\n if ENV['RAILS_ENV'] == 'test'\n # For some reason, the call to :sanitize_html causes problems in tests. Weird.\n textilized = RedCloth.new(text, [ :hard_breaks, :filter_styles ])\n else\n textilized = RedCloth.new(text, [ :hard_breaks, :sanitize_html, :filter_styles ])\n end\n textilized.to_html\n end\n end", "def plain_html\n self.class.to_html.to_html(text.dup)\n end", "def to_html\n map { |x| x.output(\"\") }.join\n end", "def to_s\n output || content || \"\"\n end", "def normalise_html(html)\n Nokogiri::HTML5.fragment(html).to_s\n end", "def to_s\n text\n end", "def as_displayed\n strip_html.unescape_html.strip_squeeze\n end", "def convert_html_safe(str)\n return str.html_safe\n end", "def to_html\n @html ||= format_html\n end", "def to_s\n @str\n end", "def to_html text\n html = (''.encode text.encoding).dup\n\n encoded = RDoc::Text::TO_HTML_CHARACTERS[text.encoding]\n\n s = StringScanner.new text\n insquotes = false\n indquotes = false\n after_word = nil\n\n until s.eos? do\n case\n when s.scan(/<(tt|code)>.*?<\\/\\1>/) then # skip contents of tt\n html << s.matched.gsub('\\\\\\\\', '\\\\')\n when s.scan(/<(tt|code)>.*?/) then\n warn \"mismatched <#{s[1]}> tag\" # TODO signal file/line\n html << s.matched\n when s.scan(/<[^>]+\\/?s*>/) then # skip HTML tags\n html << s.matched\n when s.scan(/\\\\(\\S)/) then # unhandled suppressed crossref\n html << s[1]\n after_word = nil\n when s.scan(/\\.\\.\\.(\\.?)/) then\n html << s[1] << encoded[:ellipsis]\n after_word = nil\n when s.scan(/\\(c\\)/i) then\n html << encoded[:copyright]\n after_word = nil\n when s.scan(/\\(r\\)/i) then\n html << encoded[:trademark]\n after_word = nil\n when s.scan(/---/) then\n html << encoded[:em_dash]\n after_word = nil\n when s.scan(/--/) then\n html << encoded[:en_dash]\n after_word = nil\n when s.scan(/&quot;|\"/) then\n html << encoded[indquotes ? :close_dquote : :open_dquote]\n indquotes = !indquotes\n after_word = nil\n when s.scan(/``/) then # backtick double quote\n html << encoded[:open_dquote]\n after_word = nil\n when s.scan(/(?:&#39;|'){2}/) then # tick double quote\n html << encoded[:close_dquote]\n after_word = nil\n when s.scan(/`/) then # backtick\n if insquotes or after_word\n html << '`'\n after_word = false\n else\n html << encoded[:open_squote]\n insquotes = true\n end\n when s.scan(/&#39;|'/) then # single quote\n if insquotes\n html << encoded[:close_squote]\n insquotes = false\n elsif after_word\n # Mary's dog, my parents' house: do not start paired quotes\n html << encoded[:close_squote]\n else\n html << encoded[:open_squote]\n insquotes = true\n end\n\n after_word = nil\n else # advance to the next potentially significant character\n match = s.scan(/.+?(?=[<\\\\.(\"'`&-])/) #\"\n\n if match then\n html << match\n after_word = match =~ /\\w$/\n else\n html << s.rest\n break\n end\n end\n end\n\n html\n end", "def to_s\n to_text\n end", "def formatter; end", "def formatter; end", "def formatter; end", "def to_s\n\t\t# String to return\n\t\tstr = String.new\n\n\t\t# For each line in the current page\n\t\t# Concat it to the String to return\n\t\t@pages[ @ptr ].each do |line|\n\t\t\tstr += line\n\t\tend\n\t\n\t\t# Return result\n\t\tstr\n\n\tend", "def as_html_deprecated #use TextEncoder.convert_to_html instead.\n return self if self.blank?\n mytext = self\n #mytext = CGI.escapeHTML(mytext)\n mytext.gsub!(NpbConstants::URL_DETECTION){|web_link| %{ <a href=\"#{web_link.strip}\">#{web_link.strip}</a> }}\n #mytext.gsub!(NpbConstants::EMAIL_DETECTION){|email| %{\\1<a href=\"mailto:#{email.strip}\">#{email.strip}</a>}}\n mytext.gsub!(NpbConstants::EMAIL_DETECTION){|email| %{#{$1}<a href=\"mailto:#{email.strip}\">#{email.strip}</a>}}\n mytext.gsub!(/\\A +/) {|l_spaces| (\"&nbsp;\"*l_spaces.size)} \n mytext.gsub!(/\\n +/) {|l_spaces| (\"\\n\" + (\"&nbsp;\"*(l_spaces.size-1)))}\n mytext.gsub!(/\\n{2,}/,'</p><p>')\n mytext.gsub!(/(\\n)([^\\n])/, '<br/>\\2')\n mytext\n end", "def stringOutput\n\t\tend", "def stringOutput\n\t\tend", "def to_format(format)\n if format == :html\n text = @text\n get_variables(text)\n text = includes(text)\n text = output_variables(text)\n text\n end\n\n # Second way: #{parse(@text)}\n end", "def to_s ; format ; end", "def to_s\n text\n end", "def to_s\n io = StringIO.new\n write io\n io.string\n end", "def to_s\n self.__str__.rubify\n rescue PythonError, NoMethodError\n RubyPython::PyMain.str(self).rubify\n end", "def to_s\n \"#{text}\"\n end", "def to_s\n \"#{text}\"\n end", "def to_s\n text\n end", "def to_s\n @output.inject('') { |r, entry| r << entry.to_s }\n end", "def html_safe\n self\n end", "def to_s\n if self.class._equal?(String)\n self\n else\n String.new(self)\n end\n end", "def to_s()\n prettify()\n end", "def to_s\n str\n end", "def to_html\n fail NoMethodError, \"Engines need to implement this method\"\n end", "def result_to_string(object)\n if object.is_a?(String) then\n return object\n else\n if defined?(awesome_inspect)\n return object.awesome_inspect({:plain=>true, :index=>false})\n elsif defined?(pretty_inspect)\n return object.pretty_inspect.chomp # Remove new line that PrettyInspect adds at the end https://www.ruby-forum.com/topic/113429\n else\n return object.inspect\n end\n end\n end", "def to_s\n content.to_s\n end", "def to_str() end", "def to_str() end", "def to_str; end", "def to_str; end", "def to_str; end", "def to_str; end", "def to_str; end", "def to_str; end", "def to_str; end", "def to_str; end", "def to_str; end", "def to_s\n Utils::Escape.html(@content)\n end", "def to_html\n __html__.dup.scrub!(:escape).to_html\n end", "def dumpAsHTML\n\t\tvalue = dumpAsString\n\t\treturn CGI.escapeHTML(value)\n\tend", "def to_s\n @to_s ||= traite_to_text\n end", "def html2text(html)\n\n result = ''\n begin\n web_doc = Hpricot(html)\n web_doc.search(\"//comment()\").remove\n web_doc.search(\"script\").remove\n web_doc.search(\"style\").remove\n web_doc.search(\"noscript\").remove\n web_doc.search(\"object\").remove\n web_doc.search(\"embed\").remove\n web_doc.search(\"head\").remove\n\n web_doc.traverse_text do |e| \n\n begin\n if e.content\n result += e.content+\"\\n\"\n end\n rescue\n # ignore errors\n end\n end\n rescue Exception => e\n # ignore errors\n warn \"html2text() - Exception '#{e.message}' trying to parse '#{html}'\"\n end\n\n if result == ''\n # Use a simple regular-expression approach to remove all tags\n result = html.gsub(/<[^>]*>/, '')\n end\n\n coder = HTMLEntities.new\n result = coder.decode(result)\n\n result.gsub!(/\\n[\\r\\n \\t]*/, \"\\n\")\n\n result\nend", "def html_escape\n return to_s\n end", "def html_escape\n return to_s\n end", "def dumpAsString\n\t\tmarkup = \"\"\n\t\t@Value.each do |line|\n\t\t\tmarkup += \"#{line}<br />\\n\"\n\t\tend\n\t\treturn markup\n\tend", "def detextilize(str)\n RedCloth.new(str).to_html\n end", "def prettify(str); end", "def to_s\n string.to_s\n end", "def sanitize(html)\n HTML5::HTMLParser.\n parse_fragment(html, :tokenizer => HTML5::HTMLSanitizer, :encoding => 'utf-8').\n to_s\n end", "def sanitize(html)\n HTML5::HTMLParser.\n parse_fragment(html, :tokenizer => HTML5::HTMLSanitizer, :encoding => 'utf-8').\n to_s\n end", "def to_s(&blk)\n # The @__to_s variable is used as a cache. \n # If it's useful we should add a test for it. -ac\n return @__to_s if @__to_s\n render(&blk)\n @__to_s = @doc.to_s\n end", "def to_s\n @str\n end", "def to_s\n @str\n end", "def to_s\n redacted_string(:to_s)\n end", "def to_s\n redacted_string(:to_s)\n end", "def scan(string, options = {})\n return string if !options[:converters] or options[:converters].empty?\n\n doc = Nokogiri::HTML.fragment(string)\n\n doc.search('.//text()').each do |el|\n t = el.text\n if t.strip.size > 0\n t = convert(t, options) if convertable?(el)\n end\n el.replace(t)\n end\n\n doc.to_html\n end", "def normalise_html(html)\n Nokogiri::HTML5.fragment(html).to_s.gsub(\"\\n\", \"\")\n end", "def raw_output(s)\n s\n end", "def to_s\n soup = @@boards_templates[1].to_s.scan(/...../)\n soup.each {|x| puts \"#{x}\\n\"} \n end", "def convert\n Converters::HtmlConverter.new(input: to_html)\n end", "def to_html; end", "def to_s() @out.to_s end", "def html_parser; end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end", "def to_s; end" ]
[ "0.65539694", "0.6337547", "0.60731256", "0.6029887", "0.59733486", "0.58989763", "0.5893461", "0.5859967", "0.5849473", "0.57687694", "0.56923485", "0.5690252", "0.56864876", "0.56626284", "0.56611425", "0.5656557", "0.56231284", "0.5603021", "0.558099", "0.5562777", "0.5558411", "0.55565566", "0.5553198", "0.5535351", "0.5517", "0.5507409", "0.5504621", "0.5504621", "0.5504621", "0.54968995", "0.5493836", "0.54930365", "0.54930365", "0.54909885", "0.54874486", "0.54863834", "0.54779744", "0.54776806", "0.5472529", "0.5472529", "0.5466421", "0.5465989", "0.545684", "0.5455771", "0.54536694", "0.5448049", "0.5445412", "0.54401743", "0.5432508", "0.54312754", "0.54312754", "0.542918", "0.542918", "0.542918", "0.542918", "0.542918", "0.542918", "0.542918", "0.542918", "0.542918", "0.5428883", "0.54248905", "0.54209286", "0.5416001", "0.5409525", "0.54035324", "0.54035324", "0.5384938", "0.53841364", "0.5383515", "0.537748", "0.5376636", "0.5376636", "0.5374061", "0.53713435", "0.53713435", "0.5364059", "0.5364059", "0.5356007", "0.5355601", "0.53520215", "0.5348813", "0.5343616", "0.5340761", "0.53382844", "0.5335968", "0.5332702", "0.5332702", "0.5332702", "0.5332702", "0.5332702", "0.5332702", "0.5332702", "0.5332702", "0.5332702", "0.5332702", "0.5332702", "0.5332702", "0.5332702", "0.5332702", "0.5332702" ]
0.0
-1
Basically, the rest of the functions here are simply implementing Enumerable. You can probalbly skip reading these, but start reading again at the "private" keywordthere are plenty of methods there that you may want to know about.
def [] which @activity_log[which] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def iterator()\n raise NotImplementedError\n end", "def enumerator ; end", "def enumerator ; end", "def enumerator; end", "def get_iterator\n\t\tend", "def through; end", "def each # And define each on top of next\n loop {yield self.next }\n end", "def list\n return @enumerable\n end", "def each(*) end", "def iterate\n raise \"You should implement this\"\n end", "def private; end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def each(&block); end", "def collect; end", "def my_map\n array = []\n self.my_each do |item|\n array << (yield item)\n end\n array\n end", "def each_identity; end", "def each\n raise 'Not implemented'\n end", "def generators; end", "def generators; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each; end", "def each # And define each on top of next\n loop { yield self.next }\n end", "def each\n# And define each on top of next\nloop { yield self.next }\nend", "def each\n# And define each on top of next\nloop { yield self.next }\nend", "def filter_generator; end", "def initialize(enumerable)\n @enumerable = enumerable\n end", "def next() end", "def next() end", "def traverse; end", "def list(*) end", "def deep_each\n \n end", "def each()\n self.to_a.each { |elt| yield elt }\n end", "def my_map\n arr = []\n self.my_each {|x| arr << yield(x)}\n arr\n end", "def my_select(coll)\n # your code here!\n mod_coll = []\n i=0\n while i < coll.length\n if (yield(coll[i]))\n mod_coll.push(coll[i])\n end\n i = i+1\n end\n mod_coll\nend", "def map(collection)\n result = []\n collection.each { |el| result << yield(el)}\n result\nend", "def my_select\n result = []\n i = 0\n while i < self.to_a.length\n if yield self.to_a[i] \n result << self.to_a[i]\n end\n i += 1\n end\n result\n end", "def map\n cur = self\n while cur\n yield(cur)\n cur = cur.next\n end\n self\n end", "def iterator?() end", "def find_all\n \n end", "def my_each\n return to_enum unless block_given?\n\n i = 0\n arr = to_a\n while i <= arr.length - 1\n yield (arr[i])\n i += 1\n end\n self\nend", "def ordered_list; end", "def list; end", "def list; end", "def list; end", "def list; end", "def list; end", "def each(&a_proc); end", "def map\n reset_iteration\n return enum_for(:collect) unless block_given?\n [].tap { |ret| loop { ret << yield(self.next) } }\n end", "def collection\n iterator.next\n end", "def each\n yield self\n end", "def each\n (0...size).each {|i| yield(self[i])}\n nil\n end", "def collections; end", "def each\n to_a.each\n end", "def each\n to_a.each\n end", "def each\n to_a.each\n end", "def each\n for each element\n yield(element)\n end\nend", "def each_set\n \n end", "def set(enumerable); end", "def collect!(&block)\n unless block_given?\n return ArrayEnumerator.new(self, :collect! ) # for 1.8.7\n end\n i = 0\n sz = self.__size\n enum_res = self.each { | elem | # use self.each to handle break in block\n self.__at_put(i, block.call( elem ) )\n i += 1\n }\n if i < sz\n return enum_res\n end\n self\n end", "def each\n\t\titems = @items.dup\n\t\t@items = @items.entries\n\t\traise LocalJumpError, \"no block given\" unless block_given?\n\n\t\t#self.log.debug \"Iterating over @items = %p\" % [ @items ]\n\n\t\t# Save this point so #restart can jump back here later. This is in a\n\t\t# loop because it needs to be remade after it's used the first time.\n\t\tuntil @marker\n\t\t\t@marker = callcc {|cc| cc}\n\t\tend\n\t\t@iterating = true\n\t\t@iteration = 0\n\n\t\t# Mark the outer loop for #break\n\t\tcatch( :break ) {\n\t\t\tuntil @iteration >= @items.length\n\n\t\t\t\t# Catch a skip with the number of items to skip. Unskipped\n\t\t\t\t# iterations \"skip\" 0 items.\n\t\t\t\tn = catch( :skip ) {\n\t\t\t\t\t@lastItem\t= self.first? ? nil : @items[ @iteration - 1 ]\n\t\t\t\t\t@item\t\t= @items[ @iteration ]\n\t\t\t\t\t@nextItem\t= self.last? ? nil : @items[ @iteration + 1 ]\n\n\t\t\t\t\tif @item.is_a?( Array )\n\t\t\t\t\t\tyield( self, *@item )\n\t\t\t\t\telse\n\t\t\t\t\t\tyield( self, @item )\n\t\t\t\t\tend\n\n\t\t\t\t\t0\n\t\t\t\t}\n\n\t\t\t\t# Set the skipped flag for next iteration if we're skipping\n\t\t\t\t@skipped = n.nonzero?\n\t\t\t\t@iteration += n + 1\n\t\t\tend\n\t\t}\n\n\t\t#self.log.debug \"Returning from Iterator#each\"\n\n\t\treturn @items\n\tensure\n\t\t@items\t\t= items\n\t\t@iteration\t= nil\n\t\t@lastItem\t= nil\n\t\t@item\t\t= nil\n\t\t@nextItem\t= nil\n\t\t@iterating\t= false\n\t\t@skipped\t= false\n\t\t@marker\t\t= nil\n\tend", "def each(&block)\nend", "def take_all; end", "def my_map\n if block_given?\n new_array = []\n self.my_each{|item| new_array << yield(item)}\n new_array\n else\n # if no block given return enumerator\n \"#<Enumerator: #{self}:my_map>\"\n end\n end", "def each(&block)\n raise NotImplementedError\n end", "def elements; end", "def elements; end", "def elements; end", "def private_method; end", "def all_items\n # retzrb => [ \"item23\", \"item42\", \"item17\", (...) ]\n raise \"implemented in subclass\"\n end", "def each_pair(*) end", "def my_select\n arr = []\n self.my_each {|x| arr << x if yield x}\n arr\n end", "def iterator\n AlphabeticalOrderIterator.new(@collection)\n end", "def my_map_v1 \n selfArr = self.entries\n (0...selfArr.length).each do |i|\n selfArr[i] = yield(selfArr[i])\n end\n return selfArr\n end", "def find_all\n end", "def items\n items, iter = [], @obj.items\n while (i = iter.next) do\n items << i\n end\n items\n end", "def iterating_method?(name); end", "def list\n raise NotImplementedError\n end", "def next()\n \n end", "def next()\n \n end", "def each(&block)\n raise NotImplementedError\n end", "def my_select\n\ti = 0\n\tarr = Array.new\n\tself.my_each do |a| \n\t\tif yield (a)\n\t\t\tarr[i] = a\n\t\t\ti +=1\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend\n\tarr\nend", "def each(&block)\n\n end", "def each()\n yield izq\n yield der\n end", "def all_items\n raise NotImplementedError, \"You should implement #{__method__} method\"\n end", "def each(&block) # block into proc\n\nend", "def collect\n nha = self.class.new\n (0...self.length).each { |i| nha << yield(self.fetch(i)) }\n nha\n end", "def my_select\n i = 0\n result = []\n self.my_each do |x|\n if yield(x)\n result[i] = x\n i += 1\n end\n end\n return result\n end", "def my_map\n return self unless block_given?\n mapped = []\n for m in self\n mapped << yield(m)\n end\n return mapped\n end" ]
[ "0.65930915", "0.62626314", "0.62626314", "0.6219581", "0.62102324", "0.6177583", "0.59968305", "0.59596276", "0.5875629", "0.58463424", "0.5828805", "0.57927144", "0.57927144", "0.57927144", "0.57927144", "0.57927144", "0.57927144", "0.5755338", "0.5699245", "0.5689466", "0.56868106", "0.5681165", "0.5681165", "0.56682354", "0.56682354", "0.56682354", "0.56682354", "0.56682354", "0.56682354", "0.56682354", "0.56682354", "0.56682354", "0.56682354", "0.56682354", "0.56144667", "0.5605887", "0.5605887", "0.5603226", "0.56012404", "0.55727434", "0.55727434", "0.557253", "0.55607563", "0.55582285", "0.55556655", "0.5547718", "0.55461603", "0.5531167", "0.55294", "0.55263364", "0.55138594", "0.5499253", "0.5498476", "0.54910266", "0.5485862", "0.5485862", "0.5485862", "0.5485862", "0.5485862", "0.54718405", "0.54622567", "0.54569596", "0.54478586", "0.54419667", "0.5426773", "0.5425895", "0.5425895", "0.5425895", "0.54197466", "0.54137063", "0.5407547", "0.54059905", "0.5394795", "0.5393814", "0.5386098", "0.537914", "0.5374327", "0.5370656", "0.5370656", "0.5370656", "0.5355529", "0.5355419", "0.53544694", "0.53524226", "0.5347426", "0.5337086", "0.5330677", "0.53293383", "0.5327094", "0.53244853", "0.5323159", "0.5323159", "0.5321693", "0.53171015", "0.5313809", "0.53128195", "0.5305376", "0.52940726", "0.529341", "0.5271052", "0.5265238" ]
0.0
-1
GET /skydata/1 GET /skydata/1.json
def show @skydatum = Skydatum.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @skydatum } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_surf_data\n url = \"http://magicseaweed.com/api/#{ENV['MAGIC_SEAWEED_API_KEY']}/forecast/?spot_id=6128&units=UK\"\n uri = URI(url)\n\n response = Net::HTTP.get(uri)\n ActiveSupport::JSON.decode(response) if response != ''\n end", "def index \n\t@skyrequest = Skyrequest::Connector.all.first\n end", "def index\n render json: WeatherDatum.all\n end", "def index\n @skies = Sky.all\n end", "def index\n @weather_station = WeatherStation.find(params[:weather_station_id])\n @meteo_data = []\n @meteo_data = @weather_station.meteo_datums.order('created_at desc').limit(100) unless @weather_station.blank?\n\n render 'api/v1/meteo_data/index', params: [@weather_station, @meteo_data]\n end", "def darksky_response\n connect_darksky.get(\"/forecast/#{ENV[\"DARK_SKY_API_KEY\"]}/#{@lat},#{@lng}\")\n end", "def index\n weathers = Weather.all\n render json: weathers, status: 200\n end", "def show\n @profile = Profile.find_by_user_id(current_user.id)\n \n @options = { units: \"metric\", APPID: '58d05a1cb6c05328945b2f9f3de5ff72' }\n #City id or name can be acquirred from a database, i did not\n #have time to do this but once done this is how it would retrieve weather\n @city_id = \"7778677\"\n #@data = OpenWeather::Current.city(\"Dublin, IE\", @options)\n @data = OpenWeather::Current.city_id(@city_id, @options)\n puts @data\n puts @data.keys\n\n @json = JSON.parse(@data.to_json)\n @temp = @json['main']['temp']\n @city = @json['name']\n @description = @json['weather'][0]['description']\n end", "def index\n\n require 'net/http'\n require 'json'\n\n @measures = Measure.all.order(\"created_at DESC\")\n weatherData\n\n end", "def new\n @skydatum = Skydatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @skydatum }\n end\n end", "def show\n render 'api/v1/meteo_data/show', params: @meteo_datum\n end", "def route\n hitch = Hitch.find(params[:hitch_id])\n render json: hitch.geojson\n end", "def index\n if params[:q]\n url = \"http://api.worldweatheronline.com/premium/v1/tz.ashx?q=#{params[:q]}&format=json&key=2c46659bd90a41a0bcf132257162410\"\n @json = ActiveSupport::JSON.decode(open(url).read)\n else\n end\n end", "def show\n @weather = Weather.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @weather }\n end\n end", "def show\n @weather = Weather.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @weather }\n end\n end", "def show\n @traces = Trace.find_by(id: params[:id])\n url_string = ''\n response = HTTParty.get(url_string)\n data = {\n \"latitude\": @traces.latitude,\n \"longitude\": @traces.longitude,\n \"elevation\": response.body.to_i\n }\n render json: data\n end", "def show\n @gethotelstaticdatagd = Gethotelstaticdatagd.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @gethotelstaticdatagd }\n end\n end", "def index \n local = params[:local]\n \n if (local.to_s.empty?)\n render json: 'Not found', status: 404 \n else\n params = {:query => local, :access_key => \"f613d33c4f74fc5b648685dc3428d345\"}\n conn = Faraday.get(\"http://api.weatherstack.com/current\", params) do |req|\n req.headers['Content-Type'] = 'application/json'\n end\n render json: conn.body \n end\n end", "def data\n @gesturedata = Gesture.select('data').where(\"id =?\" , params[:id])\n render json: @gesturedata[0][:data]\n end", "def weather\n # empty array dates is still fine, not a reason for 400 (happens for venues without courts)\n render json: {} and return if params.dig(:dates).blank?\n\n forecast = WeatherForecaster.call(venue, [*params.require(:dates)])\n json = forecast.transform_values do |value|\n value ? value.slice(*%w(icon temperature)) : nil\n end\n render json: json\n end", "def set_sky\n @sky = Sky.find(params[:id])\n end", "def get_weather\n weather_forecast = WeatherForecast.new(params[:location_id])\n response = weather_forecast.city_weather\n puts body = JSON.parse(response.body)\n \t@city = body['city']['name']\n \t@main_temperature_parameters = body['list'][0]['main']\n \trespond_to do |format|\n format.js\n format.json { render json: @main_temperature_parameters }\n \tend\n end", "def show\n @project = Project.find(params[:id])\n @drawings = @project.drawings\n weather = JSON.parse(open(\"http://api.openweathermap.org/data/2.5/weather?lat=\"+@project.latitude.to_s+\"&lon=\"+@project.longitude.to_s).read)\n data = {\n name: @project.name,\n id: @project.id,\n desc: @project.desc,\n drawings: @project.drawings.size,\n address: @project.address,\n latitude: @project.latitude,\n longitude: @project.longitude,\n weather: weather\n }\n respond_to do |format|\n format.json { render json: data }\n format.html # show.html.erb\n format.mobile { render json: data, callback: params[:callback] }\n end\n end", "def getJson\n render json: getData()\n end", "def show\n @site = Site.find(params[:id])\n\n respond_to do |format|\n format.html { render layout: false }\n format.json\n format.geojson\n end\n end", "def show\n @energy_datum = EnergyDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @energy_datum }\n end\n end", "def load_station_data\n data = Net::HTTP.get(URI.parse(stations_url))\n JSON.parse(data)[\"result\"]\n end", "def index\n @stations = Station.all\n\n render json: @stations\n end", "def getJson(url)\n\t\tencoded_url = URI.encode(\"https://cryptic-mountain-56365.herokuapp.com/api/v1\"+url)\n\t\turi = URI.parse(encoded_url)\n\t\tjson = Net::HTTP.get(uri)\n\tend", "def index\n @flights = Flight.all\n render json: @flights\n end", "def show\n lat = @airport.latitude_deg\n lng = @airport.longitude_deg\n \n @map_markers = Gmaps4rails.build_markers(@airport) do |airport,marker|\n marker.lat lat\n marker.lng lng\n end\n response = RestClient.get \"http://api.openweathermap.org/data/2.5/weather\", :params => {:lat => lat, :lon => lng}\n @weather = Crack::JSON.parse(response.body) \n end", "def show\n @temperature_sensor = TemperatureSensor.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @temperature_sensor }\n end\n end", "def show_dataset\n @dataset = Dataset.find(params[:dataset_id])\n @data = (ActiveRecord::Base.connection.select_all(\"SELECT * from dataset_#{@dataset.id} ORDER BY id ASC\")).to_json\n render :inline => @data\n end", "def index\n @data = Datum.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @data }\n end\n end", "def index\n @lights = Light.all\n\n render json: @lights\n end", "def show\n @county = Entity.where(id: params[:id]).where(entity_type: 'County').first\n respond_with(@county) do |format|\n format.geojson { render text: @county.to_geojson }\n end\n end", "def create\n @sky = Sky.new(sky_params)\n\n respond_to do |format|\n if @sky.save\n format.html { redirect_to @sky, notice: 'Sky was successfully created.' }\n format.json { render :show, status: :created, location: @sky }\n else\n format.html { render :new }\n format.json { render json: @sky.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n \t\n @json_data = Need.find(params[:id])\n render_json\n end", "def show\n @pix = Pix.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pix }\n end\n end", "def fetch_json\n res = open(\"http://www.cleanairmakemore.com/widget_json.cfm\").read\n\n # Documented in views/burn/phx/data.json.\n s = res.index(\"facts\")\n json = res[0, s-4] + \"}\"\n\n # json = File.read(\"views/burn/phx/data.json\")\n json\n end", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n puts JSON.pretty_generate(result)\n result\nend", "def show\n @traffic = Traffic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @traffic }\n end\n end", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def get_json(path)\n puts \"*** GET #{path}\"\n\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n puts \"HTTP #{response.code}\"\n\n #puts JSON.pretty_generate(result)\n result\nend", "def index\n @stations = Station.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @stations }\n end\n end", "def get_weather\n\t if params[:city] && params[:date]\n\t @weather = WeatherForecast.get_weather(params[:date], params[:city])\n\t else\n\t \t# if the parameters are not defined, a default result is return\n\t \t@weather = WeatherForecast.get_weather(\"20170101\", \"Paris\")\n\t end\n\t # render 'application/test'\n\t render json: @weather\n\tend", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dataset }\n end\n end", "def show\n @cloud = Cloud.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @cloud }\n end\n end", "def show\n render json: @air_quality\n end", "def index\n @air_qualities = AirQuality.all\n\n render json: @air_qualities\n end", "def get_measurements\n render json: @data_source.measurements\n end", "def get_one\n test_data = @test.get_one\n return render json: test_data\n end", "def get_json(path)\n response = Net::HTTP.get_response(build_uri(path))\n result = JSON.parse(response.body)\n #puts \"🤖 GET #{path}\"\n #puts \"HTTP #{response.code}\"\n #puts JSON.pretty_generate(result)\n result\nend", "def set_weather_datum\n render json: WeatherDatum.find(params[:id])\n end", "def show\n sensorType = params[:sensor_type]\n id = params[:id]\n since = params[:since]\n\n table = getSensorTable(sensorType)\n if table == nil\n # raise ActionController::RoutingError.new('Unrecognized Sensor')\n # TODO remove this once testing is done\n r = Random.new\n data = [{sensor_reading: (1 + r.rand(500)/100.0) ,\"timestamp\": Time.now}]\n else\n data = table.where([\"device_id = ? and timestamp > ?\", id, since]).select(\"timestamp, sensor_reading\")\n end\n\n respond_to do |format|\n format.json do\n render json: data\n end\n end\n end", "def show\n @daylight = Daylight.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @daylight }\n end\n end", "def index\n @line_stations = LineStation.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @line_stations }\n end\n end", "def view\n res = @client.get(path)\n @attributes = res.json if res.success?\n end", "def show\n @thermo_oil_distribution_year = ThermoOilDistributionYear.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @thermo_oil_distribution_year }\n end\n end", "def show\n @city_measurement = CityMeasurement.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @city_measurement }\n end\n end", "def show\n @spatial_coverage = SpatialCoverage.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @spatial_coverage }\n end\n end", "def index\n @data_points = DataPoint.recent # cached_recent\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @data_points }\n end\n end", "def get_data(path)\n begin\n res = RestClient.get(path, headers=@header)\n rescue RestClient::BadRequest\n return {\"error\" => \"Unknown user\"}\n end\n\n return {\"error\" => \"Unknown error\"} if !res or res.code != 200\n\n JSON.load res.body\n end", "def show\n if (params[:redirect] == \"on\")\n sql = <<-SQL\n with src AS (SELECT daughters(ear_num)\n FROM kine WHERE id = #{params[:id]})\n select json_agg(src) FROM src;\n SQL\n render json: ActiveRecord::Base.connection.select_value(sql)\n end\n end", "def show\n @plate = Plate.find(params[:id])\n\n render json: @plate\n end", "def index\n @zones = Zone.all\n render json: @zones\n #@zones\n end", "def show\n @raw_datum = RawDatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @raw_datum }\n end\n end", "def index\n @datasets = Dataset.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @datasets }\n end\n end", "def show\n @datum = Datum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @datum }\n end\n end", "def show\n @datum = Datum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @datum }\n end\n end", "def show\n if current_user == nil\n head(:unauthorized)\n return\n end\n \n @sensor = Sensor.find(params[:id])\n render json: @sensor, status: :ok\n end", "def show\n @weather_record = WeatherRecord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @weather_record }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dbh_measurement }\n end\n end", "def destroy\n @skydatum = Skydatum.find(params[:id])\n @skydatum.destroy\n\n respond_to do |format|\n format.html { redirect_to skydata_url }\n format.json { head :no_content }\n end\n end", "def index\n @pictures = Picture.where(foodscape_id: params[:foodscape_id])\n render json: @pictures\n end", "def show\n @flight = Flight.find(params[:id])\n render json: @flight\n end", "def get_json(state, city)\n HTTParty.get(\"http://api.wunderground.com/api/b0938627f87459c4/conditions/q/#{state}/#{city}.json\").parsed_response\nend", "def show\n @data_point = DataPoint.find(params[:id])\n\n if @data_point\n render json: @data_point\n else\n render json: @data_point, status: 404\n end\n end", "def index\n @jsons = Json.all\n end", "def show\n @hot_water_demand = HotWaterDemand.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @hot_water_demand }\n end\n end", "def show\n @curve = Curve.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @curve }\n end\n end", "def show\n # base url of the remote data\n # append the 'id' to this to generate the remote url\n baseUrl = 'https://api.gojimo.net/api/v4/'\n\n # request the meta data from the remote server and\n # extract the time its data was last updated\n meta = open(\"#{baseUrl}#{params[:id]}\").meta\n update_at = meta[\"last-modified\"].to_date\n\n # request new data when the local data timestamp pre dates the remote data\n requires_refresh = params[:update_at].blank? || update_at > params[:update_at].to_date\n\n # request the remote data if it is newer than the local copy\n data = open(\"#{baseUrl}#{params[:id]}\").read if requires_refresh\n # parse any data since we are going to add the data to an object which is then converted to json\n data = JSON.parse(data) unless data.blank?\n\n # return any data together with timestamps and a flag to show whetjer new data was retrieved\n render json: {new_data: requires_refresh, data: data, update_at: update_at.strftime('%a %d %b %Y'), check_at: Time.now.strftime('%H:%M %a %d %b %Y')}\n\n end", "def show\n @study = Study.find(params[:id])\n render json: @study\n end", "def showJSON\n\n\t\trender json: UrlDataModel.find(params[:id])\n\n\tend", "def show\n @basin = Basin.find(params[:id])\n\n @client = YahooWeather::Client.new \n @response = @client.fetch_by_location('Massingir, Gaza, Mz','c')\n @reponse2 = @client.fetch_by_location('Louis Trichardt, Limpopo, South Africa','c')\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @basin }\n\n end\n end", "def index\n @devices = Device.all\n render json: @devices\n end", "def movie_data\n response = RestClient.get(\"critics.api.mks.io/movie-genres\")\n JSON.parse(response)\nend", "def show\n @layers = Layer.where(:soil_id => params[:id])\n respond_to do |format|\n\t redirect_to @layers\n format.json { render json: @layers }\n end\n end", "def index\n @zones = Zone.all\n\n render json: @zones\n end", "def show\n @heat_source = HeatSource.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @heat_source }\n end\n end", "def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sensor }\n end\n end", "def show\n @daily_statistic = DailyStatistic.find(params[:id])\n\n render json: @daily_statistic\n end", "def show\n @forecast = Forecast.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @forecast }\n end\n end", "def semesters\n uni_year = UniYear.find_by_id(params[:uni_year_id])\n @semesters = uni_year ? uni_year.semesters : []\n \n respond_to do |format|\n format.json { render json: @semesters }\n end\n end", "def get\n\t\t\t result = Status.find_by(windmillid: params[:windmillid]) \n \t\t\trender json: [result.as_json(only: [:status,:power,:gen,:frequency,:rotor,:wind,:pitch])]\n\tend", "def get_weather\n @single_city_data['weather']\n end", "def index\n @jsons = Json.all\n\n\n end", "def get_full_data(data)\n case @client.api_version\n when \"1.2\"\n # in this version returned id=>{...}\n result = @client.api_request(:method => \"template.get\", :params => {:filter => data, :output => \"extend\"})\n result.empty? ? [] : result.values \n else\n @client.api_request(:method => \"template.get\", :params => {:filter => data, :output => \"extend\"})\n end\n end", "def index\n @earthquake_data = EarthquakeDatum.filter(params[:year], params[:mag])\n end", "def show\n @climate = Climate.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @climate }\n end\n end" ]
[ "0.6829497", "0.6247083", "0.6238176", "0.61522734", "0.6127507", "0.6115243", "0.6096944", "0.6081085", "0.60582757", "0.6055503", "0.60550386", "0.6037855", "0.6026869", "0.5995837", "0.5995837", "0.59456366", "0.59098107", "0.5899252", "0.58925456", "0.5881252", "0.58667326", "0.5847548", "0.58467835", "0.58441776", "0.5842607", "0.58372045", "0.58360356", "0.58229274", "0.5818342", "0.5808368", "0.5788128", "0.5779066", "0.57787865", "0.5756977", "0.5753746", "0.5751837", "0.57474804", "0.57424927", "0.57406646", "0.5740212", "0.57387507", "0.5732732", "0.57315165", "0.57315165", "0.5728928", "0.5725678", "0.5724458", "0.57075423", "0.56985086", "0.56971073", "0.569344", "0.5691715", "0.56861734", "0.5684837", "0.568248", "0.56804645", "0.5668721", "0.5667559", "0.56625473", "0.56608367", "0.56601113", "0.5653384", "0.56520045", "0.56507593", "0.564927", "0.56477314", "0.56460744", "0.564552", "0.564357", "0.564357", "0.5643492", "0.564217", "0.5642165", "0.5641811", "0.5636235", "0.5632996", "0.5627468", "0.56187326", "0.56163836", "0.5612088", "0.56109643", "0.560814", "0.56071705", "0.56025815", "0.55994725", "0.55985314", "0.55968106", "0.5590158", "0.55896616", "0.5587078", "0.5583647", "0.55817413", "0.5579825", "0.55787265", "0.55759084", "0.5574232", "0.55721706", "0.5569341", "0.55689585", "0.5559603" ]
0.71188694
0
GET /skydata/new GET /skydata/new.json
def new @skydatum = Skydatum.new respond_to do |format| format.html # new.html.erb format.json { render json: @skydatum } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @skydatum = Skydatum.new(params[:skydatum])\n\n respond_to do |format|\n if @skydatum.save\n format.html { redirect_to @skydatum, notice: 'Skydatum was successfully created.' }\n format.json { render json: @skydatum, status: :created, location: @skydatum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @skydatum.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @cloud = Cloud.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @cloud }\n end\n end", "def new\n @weather = Weather.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @weather }\n end\n end", "def new\n @weather = Weather.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @weather }\n end\n end", "def new\n @weather = Weather.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @weather }\n end\n end", "def create\n @sky = Sky.new(sky_params)\n\n respond_to do |format|\n if @sky.save\n format.html { redirect_to @sky, notice: 'Sky was successfully created.' }\n format.json { render :show, status: :created, location: @sky }\n else\n format.html { render :new }\n format.json { render json: @sky.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @hoge = Hoge.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hoge }\n end\n end", "def new\n @spdatum = Spdatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spdatum }\n end\n end", "def new\n @garbage = Garbage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @garbage }\n end\n end", "def new\n @dataset = Dataset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dataset }\n end\n end", "def new\n @datum = Datum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @datum }\n end\n end", "def new\n @datum = Datum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @datum }\n end\n end", "def new\n @beasts = Beast.all\n @noise = Noise.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @noise }\n end\n end", "def new\n @raw_datum = RawDatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @raw_datum }\n end\n end", "def new\n @traffic = Traffic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @traffic }\n end\n end", "def new\n @monkey = Monkey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @monkey }\n end\n end", "def new\n # @gethotelstaticdatagd = Gethotelstaticdatagd.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gethotelstaticdatagd }\n end\n end", "def new\n @stone = Stone.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stone }\n end\n end", "def new\n @weather_record = WeatherRecord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @weather_record }\n end\n end", "def new\n @line_station = LineStation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @line_station }\n end\n end", "def new\n @get = Get.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @get }\n end\n end", "def new\n @flower = Flower.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @flower }\n end\n end", "def new\n @observation = Observation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @observation }\n end\n end", "def new\n @observation = Observation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @observation }\n end\n end", "def new\n @pix = Pix.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pix }\n end\n end", "def new\n @serving = Serving.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serving }\n end\n end", "def new\n @forecast = Forecast.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @forecast }\n end\n end", "def new\n @datastore = Datastore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @datastore }\n end\n end", "def new\n @station = Station.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @station }\n end\n end", "def new\n @station = Station.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @station }\n end\n end", "def new\n @flight = Flight.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @flight }\n end\n end", "def new\n @climate = Climate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @climate }\n end\n end", "def new\n @major = Major.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @major }\n end\n end", "def new\n @sitecity = Sitecity.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sitecity }\n end\n end", "def new\n @heat_source = HeatSource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @heat_source }\n end\n end", "def new\n # open data/default_ecosystems.json and parse\n # object returned is an array of hashes... Ex:\n # p @ecosystems[0] # will return a Hash\n # p @ecosystems[0][\"category\"] # => \"native\"\n #@ecosystems = JSON.parse( File.open( \"#{Rails.root}/public/data/default_ecosystems.json\" , \"r\" ).read )\n #@name_indexed_ecosystems = JSON.parse( File.open( \"#{Rails.root}/public/data/name_indexed_ecosystems.json\" , \"r\" ).read )\n #@ecosystem = @ecosystems[0]\n\n respond_to do |format|\n format.html\n end\n end", "def new\n @seed = Seed.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seed }\n end\n end", "def new\n @backend_planet = Backend::Planet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @backend_planet }\n end\n end", "def new\n @hot_water_demand = HotWaterDemand.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hot_water_demand }\n end\n end", "def new\n @toy_zone = ToyZone.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @toy_zone }\n end\n end", "def new\n @smallmap = Smallmap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @smallmap }\n end\n end", "def new\n @git_datum = GitDatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @git_datum }\n end\n end", "def new\n @zone = Zone.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @zone }\n end\n end", "def new\n @daylight = Daylight.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @daylight }\n end\n end", "def new\n @surface = Surface.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @surface }\n end\n end", "def new\n @gas_station = GasStation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gas_station }\n end\n end", "def new\n @strain = Strain.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @strain }\n end\n end", "def new\n @specie = Specie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @specie }\n end\n end", "def new\n @distro = Distro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @distro }\n end\n end", "def new\n @distro = Distro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @distro }\n end\n end", "def new\n if current_user.access == 2\n redirect_to \"/users/indexU\"\n end\n @timetable = Timetable.new\n puts @timetable.to_json\n end", "def new\n @therapist = Therapist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @therapist }\n end\n end", "def new\n @county = County.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @county }\n end\n end", "def new\n @predict = Predict.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @predict }\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 new\n @dart = Dart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dart }\n end\n end", "def new\n @site = Site.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @site }\n end\n end", "def new\n @historical = Historical.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @historical }\n end\n end", "def new\n @island = Island.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @island }\n end\n end", "def new\n do_new_resource\n get_project_if_exists\n do_set_attributes\n do_authorize_instance\n\n # initialize lat/lng to Brisbane-ish\n @site.longitude = 152\n @site.latitude = -27\n respond_to do |format|\n format.html\n format.json { respond_new }\n end\n end", "def new\n @stable = Stable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stable }\n end\n end", "def new\n @energy_datum = EnergyDatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @energy_datum }\n end\n end", "def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @site }\n end\n end", "def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @site }\n end\n end", "def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @site }\n end\n end", "def new\n @site = Site.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @site }\n end\n end", "def new\n @database = Database.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @database }\n end\n end", "def new\n @database = Database.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json=> @database }\n end\n end", "def new\n @seo_datum = SeoDatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seo_datum }\n end\n end", "def new\n @lac_temperature = @lac.lac_temperatures.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lac_temperature }\n end\n end", "def new\n @supplysite = Supplysite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @supplysite }\n end\n end", "def new\n @feature = Feature.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feature }\n end\n end", "def new\n @feature = Feature.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @feature }\n end\n end", "def new\n @timetable = Timetable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @timetable }\n end\n end", "def new\n @substrate = Substrate.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @substrate }\n end\n end", "def new\n @green = Green.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @green }\n end\n end", "def new\n @wine = Wine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wine }\n end\n end", "def new\n @wine = Wine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wine }\n end\n end", "def new\n @hot_water_distribution = HotWaterDistribution.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hot_water_distribution }\n end\n end", "def new\n @meteorological_data = MeteorologicalData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @meteorological_data }\n end\n end", "def new\n @foam = Foam.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @foam }\n end\n end", "def new\n fetch_data\n @payment = Payment.new(:payment_date => Date.today)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @payment }\n end\n end", "def new\n @trade = Trade.new\n\n render json: @trade\n end", "def new\n @data_provider = DataProvider.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @data_provider }\n end\n end", "def new\n @curve = Curve.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @curve }\n end\n end", "def new\n @spatial_coverage = SpatialCoverage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spatial_coverage}\n end\n end", "def new\n @tinymap = Tinymap.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tinymap }\n end\n end", "def new\n @tiezi = Tiezi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tiezi }\n end\n end", "def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end", "def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end", "def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end", "def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end", "def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end", "def new\n @stock = Stock.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock }\n end\n end", "def new\n @skid = Skid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @skid }\n end\n end", "def new\n @tower = Tower.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @tower }\n end\n end", "def new\n @goat = Goat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @goat }\n end\n end", "def new\n @layer = Layer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @layer }\n end\n end", "def new\n @lookup = Lookup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lookup }\n end\n end", "def new\n @server_info = ServerInfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @server_info }\n end\n end" ]
[ "0.6810448", "0.6803557", "0.67507285", "0.6744339", "0.6744339", "0.6675255", "0.6573055", "0.6561094", "0.6553184", "0.6551011", "0.6516404", "0.6516404", "0.6513286", "0.6508919", "0.6491953", "0.6461754", "0.64489913", "0.6439948", "0.6439326", "0.64370465", "0.64351285", "0.642818", "0.6426093", "0.6426093", "0.642392", "0.64197946", "0.6400739", "0.6398326", "0.63866806", "0.63866806", "0.6373039", "0.637224", "0.6365814", "0.6361781", "0.6360376", "0.6355909", "0.63458055", "0.63347846", "0.6330201", "0.63274956", "0.6325728", "0.63255554", "0.6323237", "0.63232267", "0.63117146", "0.63099205", "0.63017946", "0.6301064", "0.62963176", "0.62963176", "0.6295305", "0.6293082", "0.6290338", "0.6288164", "0.6285843", "0.6284097", "0.6282758", "0.627279", "0.6269023", "0.6265769", "0.62614447", "0.6251074", "0.6246416", "0.6246416", "0.6246416", "0.6246416", "0.62463576", "0.62424046", "0.6239734", "0.6238742", "0.62382454", "0.6234571", "0.6234571", "0.6228996", "0.622895", "0.62209237", "0.6220406", "0.6220406", "0.6220155", "0.6218343", "0.6216983", "0.6213775", "0.62122935", "0.6210908", "0.62099403", "0.6204314", "0.62005913", "0.61988395", "0.6196553", "0.6196553", "0.6196553", "0.6196553", "0.6196553", "0.6196553", "0.619622", "0.61950153", "0.61898273", "0.61870646", "0.6185037", "0.6183016" ]
0.75690526
0
POST /skydata POST /skydata.json
def create @skydatum = Skydatum.new(params[:skydatum]) respond_to do |format| if @skydatum.save format.html { redirect_to @skydatum, notice: 'Skydatum was successfully created.' } format.json { render json: @skydatum, status: :created, location: @skydatum } else format.html { render action: "new" } format.json { render json: @skydatum.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @sky = Sky.new(sky_params)\n\n respond_to do |format|\n if @sky.save\n format.html { redirect_to @sky, notice: 'Sky was successfully created.' }\n format.json { render :show, status: :created, location: @sky }\n else\n format.html { render :new }\n format.json { render json: @sky.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meteo_datum = MeteoDatum.new(meteodatum_params)\n @meteo_datum.weather_station_id = params[:weather_station_id]\n\n if @meteo_datum.save\n render json: @meteo_datum, status: :created\n else\n render json: @meteo_datum.errors, status: :unprocessable_entity\n end\n end", "def sky_params\n params.require(:sky).permit(:location_id, :month, :sky, :min, :max)\n end", "def new\n @skydatum = Skydatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @skydatum }\n end\n end", "def get_surf_data\n url = \"http://magicseaweed.com/api/#{ENV['MAGIC_SEAWEED_API_KEY']}/forecast/?spot_id=6128&units=UK\"\n uri = URI(url)\n\n response = Net::HTTP.get(uri)\n ActiveSupport::JSON.decode(response) if response != ''\n end", "def transmit_data\n body = {body: {datum:{data_type:\"float\", value: rand, virtual_entity_id: 1}}}\n self.class.post(API+'/data', body)\n end", "def update\n respond_to do |format|\n if @sky.update(sky_params)\n format.html { redirect_to @sky, notice: 'Sky was successfully updated.' }\n format.json { render :show, status: :ok, location: @sky }\n else\n format.html { render :edit }\n format.json { render json: @sky.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_sky\n @sky = Sky.find(params[:id])\n end", "def create\n respond_to do |format|\n if @input_datum.update(params[:input_data].keys, params[:input_data].values)\n format.html { redirect_to @input_datum, notice: 'Input datum was successfully created.' }\n format.json { render :show, status: :created, location: @input_datum }\n else\n format.html { render :new }\n format.json { render json: @input_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_data(data, api_key)\n mutation = Mutations::CREATE_EVENT\n Client.query(mutation, api_key, {\n \"sessionId\": data[:session_id],\n \"eventInput\": {\n \"input\": data\n }\n })\n end", "def post(path, data = {})\n request 'POST', path, body: data.to_json\n end", "def create\n data = []\n trace_params.each do |p|\n hash = {\n latitude: p[\"latitude\"],\n longitude: p[\"longitude\"]\n }\n data << hash\n end\n\n if Trace.upload_data(data)\n render json: {status: 'OK'}\n else\n render json: @trace.errors, status: :unprocessable_entity\n end\n end", "def create_sky_table\n @sky_table = sky_client.create_table(:name => sky_table_name)\n @sky_table.create_property(:name => 'channel', :transient => true, :data_type => 'factor')\n @sky_table.create_property(:name => 'resource', :transient => true, :data_type => 'factor')\n @sky_table.create_property(:name => 'action', :transient => true, :data_type => 'factor')\n @sky_table.create_property(:name => 'href', :transient => true, :data_type => 'factor')\n @sky_table.create_property(:name => 'anonymous', :transient => true, :data_type => 'boolean')\n @sky_table.create_property(:name => 'url', :transient => true, :data_type => 'factor')\n end", "def weather_datum_params\n params.require(:weather_datum).permit(:temp, :humidity, :location)\n end", "def create\n @sensor_data = SensorData.new(sensor_data_params)\n\n respond_to do |format|\n if @sensor_data.save\n format.html { redirect_to @sensor_data, notice: 'Sensor data was successfully created.' }\n format.json { render :show, status: :created, location: @sensor_data }\n else\n format.html { render :new }\n format.json { render json: @sensor_data.errors, status: :unprocessable_entity }\n end\n end\n end", "def geo_datum_params\n params.require(:geo_datum).permit(:geoId, :geoYear, :geoName, :geoValue, :dataId, :dataYear, :dataName, :dataValue)\n end", "def destroy\n @skydatum = Skydatum.find(params[:id])\n @skydatum.destroy\n\n respond_to do |format|\n format.html { redirect_to skydata_url }\n format.json { head :no_content }\n end\n end", "def sensor_datum_params\n params.require(:sensor_datum).permit(:sensor_find_id, :timestamp, :data)\n end", "def post(path, json, params = {})\n if path.include?('covid19')\n request = Net::HTTP::Post.new(path, @headers)\n else\n request = Net::HTTP::Post.new('/v2' + path, @headers)\n end\n request.add_field('Content-Type', 'application/json')\n request.body = json\n params.each do |k, v|\n request[k] = v\n end\n send_request(request)\n end", "def transmit(path, data)\n http_post (host + path),\n {'Content-Type' => 'application/json'},\n [data.to_json]\n end", "def collected_datum_params\n params.require(:collected_datum).permit(:turtle_id, :temperature, :deep, :light, :latitude, :longitude, :date)\n end", "def update\n @skydatum = Skydatum.find(params[:id])\n\n respond_to do |format|\n if @skydatum.update_attributes(params[:skydatum])\n format.html { redirect_to @skydatum, notice: 'Skydatum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @skydatum.errors, status: :unprocessable_entity }\n end\n end\n end", "def earthquake_datum_params\n params.require(:earthquake_datum).permit(:Date, :Time, :Latitude, :Longitude, :Depth, :Magnitude, :Magnitude, :Type, :SourceId, :Source, :SameDayAs)\n end", "def show\n @skydatum = Skydatum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @skydatum }\n end\n end", "def create\n @wind = Wind.new(wind_params)\n\n respond_to do |format|\n if @wind.save\n format.html { redirect_to @wind, notice: 'Wind was successfully created.' }\n format.json { render :show, status: :created, location: @wind }\n else\n format.html { render :new }\n format.json { render json: @wind.errors, status: :unprocessable_entity }\n end\n end\n end", "def rain_datum_params\n params.require(:rain_datum).permit(:station, :date, :rain, :source_data, :source_data_url)\n end", "def create\n seth_server_rest.post_rest(\"data\", self)\n self\n end", "def parsed_darksky_response_data\n JSON.parse(darksky_response.body, symbolize_names: true)\n end", "def create\n @geo_datum = GeoDatum.new(geo_datum_params)\n\n respond_to do |format|\n if @geo_datum.save\n format.html { redirect_to @geo_datum, notice: 'Geo datum was successfully created.' }\n format.json { render :show, status: :created, location: @geo_datum }\n else\n format.html { render :new }\n format.json { render json: @geo_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def tsunami_params\n params.require(:tsunami).permit(:Date, :Time, :SameDayAs, :Focal_Depth, :Primary_Magnitude, :Country, :Location_Name, :Latitude, :Longitude, :Maximum_Water_Height, :Total_Deaths, :Total_Injuries, :Total_Damage_Million_Dollars, :Total_Houses_Destroyed, :Total_Houses_Damaged)\n end", "def create\n request_image = params[:image]\n url_hash = SecureRandom.urlsafe_base64(6)\n name = url_hash + \"-\" + request_image.original_filename.downcase\n\n File.open(\"#{Rails.root}/public/theta/#{name}\", 'wb') do |f|\n f.write(request_image.read)\n end\n\n theta = Theta.create!(url_hash: url_hash, image_url: name)\n render json: {url: \"http://www.rakugaki.tk/h/#{theta.url_hash}\"}, status: 201\n end", "def set_weather_datum\n render json: WeatherDatum.find(params[:id])\n end", "def create_datafactory(name) \n\n factory_create = {\n \"location\": \"centralus\"\n }\n\n response = HTTParty.put(\"https://management.azure.com/subscriptions/#{subscriptionId}/resourceGroups/#{resourceGroupName}/providers/Microsoft.DataFactory/factories/#{name}?api-version=2018-06-01\", {\n\n body: factory_create.to_json,\n\n headers: {\n \"Authorization\" => \"Bearer #{bearerToken}\",\n \"Content-Type\" => 'application/json', \n \"Accept\" => '*/*',\n \"Cache-Control\" => 'no-cache',\n \"Connection\" => 'keep-alive',\n \"cache-control\" => 'no-cache'\n },\n \n verify: true,\n })\n\n return JSON.parse response.read_body\n end", "def forecasting_params\n params.require(:forecasting).permit(:data, :name, :latitude, :longitude)\n end", "def create\n @city = City.create(params[:city])\n get_data\n end", "def darksky_response\n connect_darksky.get(\"/forecast/#{ENV[\"DARK_SKY_API_KEY\"]}/#{@lat},#{@lng}\")\n end", "def create\n @web_datas = WebData.new(web_datas_params)\n\n respond_to do |format|\n if @web_datas.save\n format.html { redirect_to @web_datas, notice: 'Web datas was successfully created.' }\n format.json { render :show, status: :created, location: @web_datas }\n else\n format.html { render :new }\n format.json { render json: @web_datas.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @energy_datum = EnergyDatum.new(params[:energy_datum])\n\n respond_to do |format|\n if @energy_datum.save\n format.html { redirect_to @energy_datum, notice: 'Energy datum was successfully created.' }\n format.json { render json: @energy_datum, status: :created, location: @energy_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @energy_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def cam_datum_params\n params.require(:cam_datum).permit(:datum_id, :path_data, :slicer_id, :print_time, :name)\n end", "def post_data; end", "def create\n @plate = Plate.new(params[:plate])\n\n if @plate.save\n render json: @plate, status: :created, location: @plate\n else\n render json: @plate.errors, status: :unprocessable_entity\n end\n end", "def create\n @country = Country.create(params[:country])\n get_data\n end", "def response_key_value_data(code)\n HTTParty.post(\"https://www.googleapis.com/qpxExpress/v1/trips/search?key=#{ENV[\"GOOGLE_FLIGHT_API_KEY\"]}\",\n { \n :body => request_data(code).to_json,\n :headers => { 'Content-Type' => 'application/json', 'Accept' => 'application/json'}\n })\nend", "def api_post(path, data = {})\n api_request(:post, path, :data => data)\n end", "def create\n @weather = Weather.new(params[:weather])\n\n respond_to do |format|\n if @weather.save\n format.html { redirect_to @weather, notice: 'Weather was successfully created.' }\n format.json { render json: @weather, status: :created, location: @weather }\n else\n format.html { render action: \"new\" }\n format.json { render json: @weather.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @weather = Weather.new(params[:weather])\n\n respond_to do |format|\n if @weather.save\n format.html { redirect_to @weather, notice: 'Weather was successfully created.' }\n format.json { render json: @weather, status: :created, location: @weather }\n else\n format.html { render action: \"new\" }\n format.json { render json: @weather.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @meteorological_data = MeteorologicalData.new(params[:meteorological_data])\n\n respond_to do |format|\n if @meteorological_data.save\n format.html { redirect_to(@meteorological_data, :notice => 'MeteorologicalData was successfully created.') }\n format.xml { render :xml => @meteorological_data, :status => :created, :location => @meteorological_data }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @meteorological_data.errors, :status => :unprocessable_entity }\n end\n end\n end", "def snowfall_params\n params.require(:snowfall).permit(:title, :location, :amount, :temp)\n end", "def weather_params\n params.require(:weather).permit(:field_id, :latitude, :longitude, :simulation_final_year, :simulation_initial_year, :station_id, :station_way, :way_id)\n end", "def json_params\n params.require(:json).permit(:type, :data)\n end", "def create\n @daylight = Daylight.new(daylight_params)\n\n respond_to do |format|\n if @daylight.save\n format.html { redirect_to @daylight, notice: 'Daylight was successfully created.' }\n format.json { render json: @daylight, status: :created, location: @daylight }\n else\n format.html { render action: \"new\" }\n format.json { render json: @daylight.errors, status: :unprocessable_entity }\n end\n end\n end", "def post operation, data={}\n body = case data\n when String\n body = data\n else\n Yajl::Encoder.encode(data)\n end\n\n request = new_request operation, body\n request.sign sts\n hydra.queue request\n hydra.run\n response = request.response\n puts response.inspect if @debug\n\n if response.code == 200\n Yajl::Parser.parse response.body\n else\n raise_error response\n end\n end", "def create\n @data_ukt = DataUkt.new(data_ukt_params)\n\n respond_to do |format|\n if @data_ukt.save\n format.html { redirect_to @data_ukt, notice: 'Data ukt was successfully created.' }\n format.json { render :show, status: :created, location: @data_ukt }\n else\n format.html { render :new }\n format.json { render json: @data_ukt.errors, status: :unprocessable_entity }\n end\n end\n end", "def emit_flood(event, time, sink)\n data = {\n \"time\": time.to_s,\n \"id\": event[\"site_no\"] + time.to_s.gsub(\" \", \"\"),\n \"type\": \"flood\",\n \"lat\": event[\"dec_lat_va\"],\n \"long\": event[\"dec_long_va\"],\n # \"measure\": (event[\"stage\"] - event[\"floodstage\"].to_f).round(2), # Something's wrong with the API, changing for now until fixed\n \"measure\": event[\"flow\"],\n \"metadata\": event.to_json\n }\n\n puts \"data: #{data}\"\n\n @logger.info(\"Sending message to #{sink}\")\n r = HTTParty.post(sink, \n :headers => {\n 'Content-Type' => 'text/plain',\n 'ce-specversion' => '0.2',\n 'ce-type' => 'dev.knative.naturalevent.flood',\n 'ce-source' => 'dev.knative.flood'\n },\n :body => data.to_json\n )\n\n if r.code != 200 or r.code != 202\n @logger.error(\"Error! #{r.code} - #{r}\")\n @logger.error(\"Body: #{r.body}\")\n end\nend", "def create\n @ge_city_api = GeCityApi.new(ge_city_api_params)\n\n respond_to do |format|\n if @ge_city_api.save\n format.html { redirect_to @ge_city_api, notice: 'Ge city api was successfully created.' }\n format.json { render :show, status: :created, location: @ge_city_api }\n else\n format.html { render :new }\n format.json { render json: @ge_city_api.errors, status: :unprocessable_entity }\n end\n end\n end", "def data_to_api(snack_name, snack_location, snack_optional)\n RestClient.post ENV['NERDERY_API'], { name: snack_name,\n location: snack_location,\n optional: snack_optional\n }.to_json, content_type: :json\n end", "def post_data(params)\n {\n gateway_username: options[:login],\n gateway_password: options[:password],\n payload: encrypt(params.to_json)\n }.to_json\n end", "def create_credentials\n post_url = URI(\"http://#{FBPi::Settings.meshblu_url}/devices\")\n res = Net::HTTP.post_form(post_url, {})\n json = JSON.parse(res.body).deep_symbolize_keys\n File.open(credentials_file, 'w+') { |file| file.write(json.to_yaml) }\n load_credentials\n json\n end", "def create\n create\n @weather = Weather.new(weather_params)\n\n respond_to do |format|\n if @weather.save\n format.html { redirect_to @weather, notice: 'Weather was successfully created.' }\n format.json { render json: @weather, status: :created, location: @weather }\n else\n format.html { render action: \"new\" }\n format.json { render json: @weather.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @dataset_datum = DatasetDatum.new(dataset_datum_params)\n\n respond_to do |format|\n if @dataset_datum.save\n format.html { redirect_to @dataset_datum, notice: 'Dataset datum was successfully created.' }\n format.json { render action: 'show', status: :created, location: @dataset_datum }\n else\n format.html { render action: 'new' }\n format.json { render json: @dataset_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @turkey = Turkey.new(turkey_params)\n\n respond_to do |format|\n if @turkey.save\n format.html { redirect_to @turkey, notice: 'Turkey was successfully created.' }\n format.json { render :show, status: :created, location: @turkey }\n else\n format.html { render :new }\n format.json { render json: @turkey.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @asos_datum = AsosDatum.new(asos_datum_params(asos_station))\n\n respond_to do |format|\n if @asos_datum.save\n format.html { redirect_to @asos_datum, notice: 'Asos datum was successfully created.' }\n format.json { render action: 'show', status: :created, location: @asos_datum }\n else\n format.html { render action: 'new' }\n format.json { render json: @asos_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @shade = Shade.new(shade_params)\n @shade.created_by = @current_user.id\n\n if @shade.save\n render :show, status: :created, location: v1_shade_url(@shade)\n else\n render json: @shade.errors, status: :unprocessable_entity\n end\n end", "def post(path, data = {}, params = {})\n body = data.to_json\n path = File.join(@prefix, path)\n\n response = @conn.post(path, body) do |req|\n req.params = params\n req.headers['Content-Type'] = 'application/json'\n end\n\n JSON.parse response.body\n end", "def weather_params\n params.require(:weather).permit(:city_id, :date, :temperature, :type)\n end", "def create\n @spice = Spice.new(spice_params)\n\n if @spice.save\n render json: @spice, status: :created\n else\n render json: @spice.errors, status: :unprocessable_entity\n end\n end", "def create\n @raw_datum = RawDatum.new(params[:raw_datum])\n\n respond_to do |format|\n if @raw_datum.save\n format.html { redirect_to @raw_datum, notice: 'Raw datum was successfully created.' }\n format.json { render json: @raw_datum, status: :created, location: @raw_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @raw_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @cam_datum = CamDatum.new(cam_datum_params)\n\n respond_to do |format|\n if @cam_datum.save\n format.html { redirect_to @cam_datum, notice: 'Cam datum was successfully created.' }\n format.json { render :show, status: :created, location: @cam_datum }\n else\n format.html { render :new }\n format.json { render json: @cam_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def weather_params\n # params.require(:weather).permit(:area, :date, :ave_temperature, :max_temperature, :min_temperature, :rainfall, :max_rainfall, :day_length, :insolation, :max_snow, :total_snow, :ave_wind_speed, :max_wind_speed, :max_wind_direction, :momentary_wind_speed, :momentary_wind_direction, :most_direction, :ave_stream_pressure, :ave_humidity, :min_himidity, :ave_pressure, :ave_sea_pressure, :min_sea_pressure, :ave_cloud_amount, :outline06_18, :outline18_06)\n end", "def weather\n # empty array dates is still fine, not a reason for 400 (happens for venues without courts)\n render json: {} and return if params.dig(:dates).blank?\n\n forecast = WeatherForecaster.call(venue, [*params.require(:dates)])\n json = forecast.transform_values do |value|\n value ? value.slice(*%w(icon temperature)) : nil\n end\n render json: json\n end", "def trace_params\n params.require(:_json).map do |p|\n p.permit(:latitude, :longitude)\n end\n end", "def create\n @datum = Datum.new(params[:datum])\n\n respond_to do |format|\n if @datum.save\n format.html { redirect_to @datum, notice: 'Datum was successfully created.' }\n format.json { render json: @datum, status: :created, location: @datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @daty = current_user.daties.build(daty_params)\n\n respond_to do |format|\n if @daty.save\n format.html { redirect_to @daty, notice: 'Daty was successfully created.' }\n format.json { render :show, status: :created, location: @daty }\n else\n format.html { render :new }\n format.json { render json: @daty.errors, status: :unprocessable_entity }\n end\n end\n end", "def sensor_data_params\n params.require(:sensor_data).permit(:user_id_id, :position, :time, :measurement)\n end", "def datum_params\n params.require(:datum).permit(:name, :value)\n end", "def destroy\n @sky.destroy\n respond_to do |format|\n format.html { redirect_to skies_url, notice: 'Sky was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def snowflake_params\n params.require(:snowflake).permit(:shape)\n end", "def post_json(url, data)\n JSON.parse(post(url, data, :json, :json))\n end", "def create\n @aws_datum = AwsDatum.new(aws_datum_params)\n\n respond_to do |format|\n if @aws_datum.save\n format.html { redirect_to @aws_datum, notice: 'Aws datum was successfully created.' }\n format.json { render :show, status: :created, location: @aws_datum }\n else\n format.html { render :new }\n format.json { render json: @aws_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create(url, data)\n RestClient.post ENV['APIBASE']+url, data, :content_type => :json\nend", "def create\n @live_datum = LiveDatum.new(live_datum_params)\n\n respond_to do |format|\n if @live_datum.save\n format.html { redirect_to @live_datum, notice: 'Live datum was successfully created.' }\n format.json { render :show, status: :created, location: @live_datum }\n else\n format.html { render :new }\n format.json { render json: @live_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @datum = Datum.new(datum_params)\n\n respond_to do |format|\n if @datum.save\n format.html { redirect_to @datum, notice: 'Datum was successfully created.' }\n format.json { render :show, status: :created, location: @datum }\n else\n format.html { render :new }\n format.json { render json: @datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @fish_poly = FishPoly.new(fish_poly_params)\n\n respond_to do |format|\n if @fish_poly.save\n format.html { redirect_to @fish_poly, notice: 'Fish poly was successfully created.' }\n format.json { render :show, status: :created, location: @fish_poly }\n else\n format.html { render :new }\n format.json { render json: @fish_poly.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @zone = Zone.new(zone_params)\n\n if @zone.save\n render json: @zone, status: :created, location: @zone\n else\n render json: @zone.errors, status: :unprocessable_entity\n end\n end", "def create\n # {\"vcpus\": 1, \"disk\": 1, \"name\": \"test\", \"rxtx_factor\": 1, \"OS-FLV-EXT-DATA:ephemeral\": 1, \"ram\": 512, \"id\": 6, \"swap\": 1}}'\n @flavor = compute.create_flavor(\"rxtx_factor\"=>1,\"OS-FLV-EXT-DATA:ephemeral\"=>params[:ephemeral],:vcpus=>params[:vcpus],:disk=>params[:disk],:name=>params[:name],:ram=>params[:ram],:id=>params[:id],:swap=>params[:swap])\n\n respond_to do |format|\n format.html { redirect_to flavors_path, :notice => 'Flavor was successfully created.' }\n format.json { render :json => @flavor, :status => :created, :location => @flavor }\n end\n end", "def create\n\n @tracked_datum = TrackedDatum.new(tracked_datum_params)\n\n respond_to do |format|\n if @tracked_datum.save\n format.html { redirect_to @tracked_datum, notice: 'Tracked datum was successfully created.' }\n format.json { render :show, status: :created, location: @tracked_datum }\n else\n format.html { render :new }\n format.json { render json: @tracked_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_json(path, body)\n uri = build_uri(path)\n #puts \"🤖 POST #{path}\"\n #puts JSON.pretty_generate(body)\n\n post_request = Net::HTTP::Post.new(uri, 'Content-Type' => 'application/json')\n post_request.body = JSON.generate(body)\n\n response = Net::HTTP.start(uri.hostname, uri.port, :use_ssl => true) do |http|\n http.request(post_request)\n end\n\n #puts \"HTTP #{response.code}\"\n result = JSON.parse(response.body)\n #puts result[:result]\n result\nend", "def create\n @weather_test = WeatherTest.new(weather_test_params)\n\n respond_to do |format|\n if @weather_test.save\n format.html { redirect_to @weather_test, notice: 'Weather test was successfully created.' }\n format.json { render :show, status: :created, location: @weather_test }\n else\n format.html { render :new }\n format.json { render json: @weather_test.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n product_name = competitor_params[:title]\n honestbee_datas = get_honestbee_data (product_name)\n predict_catalog = get_predict_catalog ( product_name )\n save_data_in_postgres (predict_catalog)\n render :json => honestbee_datas\n end", "def ga_datum_params\n params.require(:ga_datum).permit(:ga_label_id, :profile, :json)\n end", "def create\n @sensor_datum = SensorDatum.new(sensor_datum_params)\n\n create_save(@sensor_datum, \"Sensor datum\")\n end", "def create\n store_location_for :user, request.url\n @forecast = Forecast.request(params[:forecast])\n debug_me = true\n end", "def create\n @cloud = Cloud.new(cloud_params)\n @cloud.user_id = session[:user_id]\n respond_to do |format|\n if @cloud.save\n format.html { redirect_to @cloud, notice: 'Cloud was successfully created.' }\n format.json { render :show, status: :created, location: @cloud }\n else\n format.html { render :new }\n format.json { render json: @cloud.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_from_darksky(historical_dates=[Date.today-1], forecast=true)\n darksky_secret = ApiKey.where(:service => 'Darksky').first.key\n hydra = Typhoeus::Hydra.new\n requests = Hash.new\n forecast_request = nil\n\n logger.debug(\"Updating Station #{name} for dates: #{historical_dates}\")\n \n # Construct the HTTP requests to Darksky: one for each of the past days we care about, and one for today to get the forecast\n historical_dates.each do |d|\n endpoint = \"https://api.darksky.net/forecast/#{darksky_secret}/#{self.latitude},#{self.longitude},#{d.to_time.to_i}\"\n request = Typhoeus::Request.new(endpoint) \n hydra.queue(request)\n requests[d] = request\n end\n forecast_request = Typhoeus::Request.new(\"https://api.darksky.net/forecast/#{darksky_secret}/#{self.latitude},#{self.longitude}\")\n hydra.queue(forecast_request) if forecast\n\n # Run the whole lot of them!\n hydra.run\n\n # Parse out the observed precipitation from the historical queries\n reports = []\n requests.each_pair do |d, request|\n if request.response.timed_out?\n logger.error \"Request to Darksky timed out: #{request}\"\n next\n end\n if request.response.nil?\n logger.error \"No response from Darksky for request #{request}\"\n next\n end\n if request.response.code != 200\n logger.error \"Unable to fetch weather data from #{request.base_url}: #{request.response.code} #{request.response.status_message}\"\n next\n end\n\n # With error trapping done, let's parse the body and update the db with the report data.\n data = JSON.load(request.response.body)\n data['daily']['data'].each do |report|\n logger.debug(report)\n d = Time.at(report['time']).to_date\n datestamp = \"#{d.year}#{d.month.to_s.rjust(2,'0')}#{d.day.to_s.rjust(2,'0')}\"\n logger.debug(\"Using timestamp #{datestamp}\")\n # We want to update an existing row in place if we've previously computed one\n r = weather_reports.find_or_create_by(\n :latitude => self.latitude,\n :longitude => self.longitude,\n :date => datestamp,\n )\n \n \n # TODO: multiply by the actual number of hours in the time period.\n precip = report['precipIntensity'] # This is in inches per hour\n logger.debug(\"Extracted precipitation report: #{precip} from report #{report}\")\n r.precip = precip * 24.0\n logger.debug(\"Constructed WeatherReport: #{r}\")\n logger.debug(\"Coordinates: #{r.latitude},#{r.longitude}\")\n logger.debug(\"Datestamp: #{r.date}\")\n logger.debug(\"Recorded Precip: #{r.precip}\")\n \n r.save\n reports.push(r)\n end\n end\n\n # Add the forecast data as well\n forecasts = []\n if forecast\n logger.info(\"Parsing forecasts for station #{self}\")\n logger.debug(\"Got response: #{forecast_request.response}\")\n if forecast_request.response.timed_out?\n logger.error \"Request to Darksky timed out: #{forecast_request}\"\n return\n end\n if forecast_request.response.nil?\n logger.error \"No response from Darksky for request #{forecast_request}\"\n return\n end\n if forecast_request.response.code != 200\n logger.error \"Unable to fetch weather data from #{forecast_request.base_url}: #{forecast_request.response.code} #{forecast_request.response.message}\"\n return\n end\n\n logger.debug(\"Successful response from Darksky\")\n data = JSON.load(forecast_request.response.body)\n data['daily']['data'].each do |report|\n logger.debug(report)\n d = Time.at(report['time']).to_date\n datestamp = \"#{d.year}#{d.month.to_s.rjust(2,'0')}#{d.day.to_s.rjust(2,'0')}\"\n r = weather_reports.find_or_create_by(\n :latitude => self.latitude,\n :longitude => self.longitude,\n :date => datestamp,\n )\n r.precip = report['precipIntensity'] * 24.0 # The Darksky report gives us inches per hour\n\n logger.debug(\"Created forecast object: #{r}\")\n r.save\n forecasts.push(r)\n end\n end\n\n # TODO: add a column that we can record when this update was last run, for display on the webpage.\n {:reports => reports, :forecasts => forecasts}\n end", "def post_request(options, path, post_data)\n\n result = {}\n\n http = Net::HTTP.new(ENV['NESSUS_HOST'], options[:port])\n http.use_ssl = @use_ssl\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n http.start do |http|\n req = Net::HTTP::Post.new(path)\n\n req['X-ApiKeys'] = \"accessKey=#{ENV['NESSUS_ACCESS_KEY']}; secretKey=#{ENV['NESSUS_SECRET_KEY']}\"\n req.body = post_data\n \n resp, data = http.request(req)\n \n if resp.code.eql? '200'\n #print \"Data: \" + JSON.pretty_generate(JSON.parse(resp.body.to_s))\n result = JSON.parse(resp.body.to_s)\n else\n puts \"Error: \" + resp.code.to_s + \"\\n\" + resp.body\n end\n end\n\n return result\n end", "def site_datum_params\n params.require(:site_datum).permit(:inventory, :pappy, :pappyType)\n end", "def create\n @flight = Flight.new(params[:flight])\n\n if @flight.save\n render json: @flight, status: :created, location: @flight\n else\n render json: @flight.errors, status: :unprocessable_entity\n end\n end", "def save_data(data)\n raw = JSON.dump(data)\n File.open(FILENAME, 'w') do |file|\n file.write(raw)\n end\nend", "def create\n @seo_datum = SeoDatum.new(params[:seo_datum])\n\n respond_to do |format|\n if @seo_datum.save\n format.html { redirect_to @seo_datum, notice: 'Seo datum was successfully created.' }\n format.json { render json: @seo_datum, status: :created, location: @seo_datum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @seo_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @kata = Kata.new(kata_params)\n\n respond_to do |format|\n if @kata.save\n format.html { redirect_to @kata, notice: 'Kata was successfully created.' }\n format.json { render action: 'show', status: :created, location: @kata }\n else\n format.html { render action: 'new' }\n format.json { render json: @kata.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.69015986", "0.6075114", "0.5954964", "0.5856782", "0.55876577", "0.558316", "0.55304563", "0.5490992", "0.5442317", "0.54271805", "0.5388965", "0.53783524", "0.5361033", "0.5328871", "0.53170747", "0.53074276", "0.53010297", "0.52858555", "0.528165", "0.5276898", "0.5271143", "0.52686524", "0.5261063", "0.52031684", "0.51815856", "0.51657104", "0.51575553", "0.5131233", "0.5123295", "0.5119219", "0.5094949", "0.5083486", "0.50827444", "0.5029976", "0.50286263", "0.50215423", "0.50129616", "0.5012487", "0.5010774", "0.50051916", "0.49990913", "0.4995435", "0.4994543", "0.49930322", "0.49846324", "0.49846324", "0.497803", "0.49691013", "0.4968054", "0.49598536", "0.49585298", "0.4956779", "0.49549365", "0.49509665", "0.4931969", "0.49286625", "0.49270427", "0.49234354", "0.49231935", "0.49161634", "0.49138108", "0.49074233", "0.49065775", "0.49064448", "0.4905408", "0.49046078", "0.4904135", "0.48963", "0.48952004", "0.48924798", "0.48920414", "0.48886263", "0.48866233", "0.48860708", "0.4885989", "0.48859382", "0.48845166", "0.4884349", "0.48824567", "0.48814192", "0.48777097", "0.48748124", "0.48716065", "0.48713818", "0.48638466", "0.48592892", "0.4858337", "0.48540488", "0.48530072", "0.48470578", "0.48467234", "0.48399284", "0.48298606", "0.48272508", "0.48255903", "0.48237294", "0.48224217", "0.48100713", "0.48087662", "0.48038247" ]
0.6743967
1
PUT /skydata/1 PUT /skydata/1.json
def update @skydatum = Skydatum.find(params[:id]) respond_to do |format| if @skydatum.update_attributes(params[:skydatum]) format.html { redirect_to @skydatum, notice: 'Skydatum was successfully updated.' } format.json { head :no_content } else format.html { render action: "edit" } format.json { render json: @skydatum.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @sky.update(sky_params)\n format.html { redirect_to @sky, notice: 'Sky was successfully updated.' }\n format.json { render :show, status: :ok, location: @sky }\n else\n format.html { render :edit }\n format.json { render json: @sky.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path, data = {})\n request 'PUT', path, body: data.to_json\n end", "def update(url, data)\n RestClient.put url, data, :content_type => :json\nend", "def set_sky\n @sky = Sky.find(params[:id])\n end", "def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def api_put(path, data = {})\n api_request(:put, path, :data => data)\n end", "def actualizacion \n fiesta.update (params[:id]) \n render json: fiesta\n end", "def update\n if @sensor.update(sensor_params)\n render json: { status: :ok }\n else\n render json: { status: :unprocessable_entity }\n end\n end", "def update\n dream = Dream.find params[:id]\n dream.update dream_params\n render json: {dream: dream}\n end", "def update\n if @spice.update(spice_params)\n head :no_content\n else\n render json: @spice.errors, status: :unprocessable_entity\n end\n end", "def create\n @sky = Sky.new(sky_params)\n\n respond_to do |format|\n if @sky.save\n format.html { redirect_to @sky, notice: 'Sky was successfully created.' }\n format.json { render :show, status: :created, location: @sky }\n else\n format.html { render :new }\n format.json { render json: @sky.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end", "def put(path, data=nil)\n request(:put, path, data)\n end", "def put endpoint, data\n do_request :put, endpoint, data\n end", "def update\n respond_to do |format|\n if @sensor_data.update(sensor_data_params)\n format.html { redirect_to @sensor_data, notice: 'Sensor data was successfully updated.' }\n format.json { render :show, status: :ok, location: @sensor_data }\n else\n format.html { render :edit }\n format.json { render json: @sensor_data.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(attrs, path=nil)\n resp = api_client.put(path || url, JSON.dump(attrs))\n refresh(JSON.load(resp.body))\n end", "def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update\n \n \n\n #puts '*****************cartodb22************************'\n #response = HTTParty.get('https://cantina23.cartodb.com/api/v2/sql?q=SELECT name FROM premas_projects&api_key=83a1b3e6c95613255bef720617d34adb0a7b87c1')\n #puts response\n #puts '*****************cartodb22************************'\n\n #puts '*****************cartodb22************************'\n #response = HTTParty.get(\"https://cantina23.cartodb.com/api/v2/sql?q=UPDATE premas_projects SET value=33333 WHERE cartodb_id=2&api_key=83a1b3e6c95613255bef720617d34adb0a7b87c1\")\n #puts response\n #puts '*****************cartodb22************************'\n\n \n \n \n \n respond_to do |format|\n if @project.update(project_params)\n format.html { redirect_to @project, notice: 'Project was successfully updated.' }\n format.json { render :show, status: :ok, location: @project }\n else\n format.html { render :edit }\n format.json { render json: @project.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @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(data = :object || :json)\n end", "def put(*args)\n request :put, *args\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 http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end", "def update(data, &block)\n request :put, @data[:id], data, &block\n end", "def update\n @set.update_attributes({ :data => params[:data] })\n render_json :entry => @set and return\n end", "def update\n @set.update_attributes({ :data => params[:data] })\n render_json :entry => @set and return\n end", "def update\n @meteorological_data = MeteorologicalData.find(params[:id])\n\n respond_to do |format|\n if @meteorological_data.update_attributes(params[:meteorological_data])\n format.html { redirect_to(@meteorological_data, :notice => 'MeteorologicalData was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @meteorological_data.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update(*args)\n put(*args)\n end", "def update(*args)\n put(*args)\n end", "def update\n @flight = Flight.find(params[:id])\n\n if @flight.update(params[:flight])\n head :no_content\n else\n render json: @flight.errors, status: :unprocessable_entity\n end\n end", "def update\n if spot = SkateSpot.where(:id => params[:id]).first and info = parse_input(params)\n if info.has_key?(:alt_names)\n info[:alt_names].map! { |n| SpotName.find_or_create_by(:name => n, :spot => spot) }\n end\n\n if info[:name]\n info[:name] = SpotName.find_or_create_by(:name => info[:name], :spot => spot) \n end\n\n if info.has_key?(:obstacles)\n info[:obstacles].map! { |o|\n Obstacle.find_or_create_by(:type => ObstacleType.where(:name => o['type']).first, :geometry => o['geometry'], :spot => spot)\n }\n end\n\n render :json => { :status => (spot.update(info) == true ? :success : :unprocessable_entity) }\n else\n render :json => { :status => :unprocessable_entity }\n end\n\n rescue ActiveRecord::RecordNotSaved\n render :json => { :status => :unprocessable_entity }\n end", "def update\n mountain = Mountain.find(params[:id])\n mountain.update(\n name: params[:name],\n country: params[:country],\n elevation: params[:elevation],\n pointyness: params[:pointyness],\n image: params[:image]\n )\n #Create has no template of its own\n redirect_to(mountain_path(mountain))\n end", "def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end", "def put(id, json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\" \n return HTTParty.put(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end", "def update\n @space_station = SpaceStation.find(params[:id])\n\n if @space_station.update(space_station_params)\n head :no_content\n else\n render json: @space_station.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n format.html { redirect_to @dataset, notice: 'Dataset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dataset.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sphere = Sphere.find(params[:id])\n\n respond_to do |format|\n if @sphere.update_attributes(params[:sphere])\n format.html { redirect_to @sphere, notice: 'Sphere a été édité avec succès.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sphere.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # { clinic: {id: references, \"license_id\"=>nil, \"name\"=>string } }\n \n if @clinic.update_attributes(params[:clinic].except(:api_license_id))\n head :no_content\n else\n render json: clinic.errors.full_messages, status: :unprocessable_entity\n end\n end", "def 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 update\n respond_to do |format|\n if @kota_stone.update(kota_stone_params)\n format.html { redirect_to kota_stones_url, notice: 'Kota stone was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kota_stone.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n\n format.json { render json: Axis.find(params[:id]).update( name: params[:name]) }\n end\n\n # end\n end", "def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @json.update(json_params)\n format.html { redirect_to @json, notice: 'Json was successfully updated.' }\n format.json { render :show, status: :ok, location: @json }\n else\n format.html { render :edit }\n format.json { render json: @json.errors, status: :unprocessable_entity }\n end\n end\n end", "def put_json_in_path(path, json_data)\n res = nil\n uri = URI(@url + path)\n req = Net::HTTP::Post.new(uri)\n req['X-Vault-Token'] = @token\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|\n req.body = if json_data.class == Hash\n json_data.to_json\n else\n json_data\n end\n http.request(req)\n end\n res.code.to_i\n end", "def put(*args)\n request(:put, *args)\n end", "def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end", "def update!(**args)\n @data = args[:data] if args.key?(:data)\n @metadata = args[:metadata] if args.key?(:metadata)\n end", "def update\n render json: Alien.update(params[\"id\"], params[\"alien\"])\n end", "def update!(**args)\n @data = args[:data] if args.key?(:data)\n @id = args[:id] if args.key?(:id)\n end", "def destroy\n @skydatum = Skydatum.find(params[:id])\n @skydatum.destroy\n\n respond_to do |format|\n format.html { redirect_to skydata_url }\n format.json { head :no_content }\n end\n end", "def update\n @serving = Serving.find(params[:id])\n\n respond_to do |format|\n if @serving.update_attributes(params[:serving])\n format.html { redirect_to @serving, notice: 'Serving was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @serving.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @kata.update(kata_params)\n format.html { redirect_to @kata, notice: 'Kata was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @kata.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n trip = Trip.find_by_id(params[:trip_id])\n trip.title = params[:title]\n trip.city = params[:city]\n trip.state = params[:state]\n trip.country = params[:country]\n trip.start_date = params[:start_date]\n trip.end_date = params[:end_date]\n trip.description = params[:description]\n trip.link = params[:link]\n if params[:photo_base]\n trip.photo = params[:photo_base]\n end\n trip.save!\n render json: trip\n end", "def update\n respond_to do |format|\n if @sekilas_info.update(sekilas_info_params)\n format.html { redirect_to @sekilas_info, notice: 'Sekilas info was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sekilas_info.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @cloud = Cloud.find(params[:id])\n\n respond_to do |format|\n if @cloud.update_attributes(params[:cloud])\n format.html { redirect_to @cloud, :notice => 'Cloud was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @cloud.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @dataset.update(dataset_params)\n format.html { redirect_to @dataset, notice: 'Dataset was successfully updated.' }\n format.json { render :show, status: :ok, location: @dataset }\n else\n format.html { render :edit }\n format.json { render json: @dataset.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path, data = {})\n self.class.put path, :body => data.merge(:u => access_token)\n end", "def update\n respond_to do |format|\n if @iot_datum.update(iot_datum_params)\n format.html { redirect_to @iot_datum, notice: 'Iot datum was successfully updated.' }\n format.json { render :show, status: :ok, location: @iot_datum }\n else\n format.html { render :edit }\n format.json { render json: @iot_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @file = @map.meta_data\n # binding.pry\n\n @meta_data = []\n @kind = @map.kind\n fips_to_hc_key\n @map.meta_data = @meta_data\n\n respond_to do |format|\n if @map.update(map_params)\n format.html { redirect_to @map, notice: 'Map was successfully updated.' }\n format.json { render :show, status: :ok, location: @map }\n else\n format.html { render :edit }\n format.json { render json: @map.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n query = {\n 'name' => params[:name]\n }\n response = HTTParty.put(url, :query => query, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n\n if response.code == 200\n redirect_to unit_path(params[:id]), notice: 'Unit was successfully updated.'\n else\n redirect_to unit_path(params[:id]), notice: 'Sheesh! Minor hiccup...run that again!'\n end\n end", "def update\n @supermarket = Supermarket.find(params[:id]) \n respond_to do |format|\n if @supermarket.update(supermarket_params)\n format.json { render json: @supermarket, status: :ok }\n end\n end\n end", "def update\n @city = City.find(params[:id])\n @city.update_attributes(params[:city])\n get_data\n end", "def update\n respond_to do |format|\n if @earth.update(earth_params)\n format.html { redirect_to earths_path, notice: 'Earth was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @earth.errors, status: :unprocessable_entity }\n end\n end\n end", "def update options={}\n client.put(\"/#{id}\", options)\n end", "def update\n put :update\n end", "def update\n render json: Company.update(params[\"id\"], params[\"company\"])\n end", "def create\n @skydatum = Skydatum.new(params[:skydatum])\n\n respond_to do |format|\n if @skydatum.save\n format.html { redirect_to @skydatum, notice: 'Skydatum was successfully created.' }\n format.json { render json: @skydatum, status: :created, location: @skydatum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @skydatum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @serving.update(serving_params)\n format.html { redirect_to @serving, notice: 'Serving was successfully updated.' }\n format.json { render :show, status: :ok, location: @serving }\n else\n format.html { render :edit }\n format.json { render json: @serving.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @snowfall.update(snowfall_params)\n format.html { redirect_to @snowfall, notice: 'Snowfall was successfully updated.' }\n format.json { render :show, status: :ok, location: @snowfall }\n else\n format.html { render :edit }\n format.json { render json: @snowfall.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @cloud.update(cloud_params)\n format.html { redirect_to @cloud, notice: 'Cloud was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cloud.errors, status: :unprocessable_entity }\n end\n end\n end", "def put(path, *data, &block)\n map(path, R3::PUT, *data, &block)\n end", "def update!(**args)\n @json_schemas = args[:json_schemas] if args.key?(:json_schemas)\n @schema = args[:schema] if args.key?(:schema)\n end", "def update!(**args)\n @geometries = args[:geometries] if args.key?(:geometries)\n @id = args[:id] if args.key?(:id)\n @type = args[:type] if args.key?(:type)\n end", "def update\n if @person.seat\n render json: {errors: 'Cannot update a seated person'}, status: 422\n else\n @person.update person_params\n render json: @person\n end\n end", "def update\n respond_to do |format|\n if @dataset_datum.update(dataset_datum_params)\n format.html { redirect_to @dataset_datum, notice: 'Dataset datum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @dataset_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n planet = Planet.find params[:id]\n planet.update(\n name: params[:name],\n image: params[:image],\n orbit: params[:orbit],\n diameter: params[:diameter],\n mass: params[:mass],\n moons: params[:moons]\n )\n\n # Redirect to the show page: /planets/:id\n redirect_to planet_path(planet.id)\n\n end", "def update\n respond_to do |format|\n if @sensor.update(sensor_params)\n format.html { redirect_to @sensor, notice: 'Sensor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sensor.update(sensor_params)\n format.html { redirect_to @sensor, notice: 'Sensor was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sensor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if params[:kid][:id]\n @kid = Kid.find(params[:kid][:id])\n else\n @kid = Kid.find_by_user_id_and_local_id(params[:kid][:user_id],params[:kid][:local_id])\n end\n params[:kid].delete(:user_id)\n params[:kid].delete(:id)\n if @kid.update_attributes(params[:kid])\n render json: @kid\n else\n render json: @kid.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @fish_poly.update(fish_poly_params)\n format.html { redirect_to @fish_poly, notice: 'Fish poly was successfully updated.' }\n format.json { render :show, status: :ok, location: @fish_poly }\n else\n format.html { render :edit }\n format.json { render json: @fish_poly.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @country = Country.find(params[:id])\n @country.update_attributes(params[:country])\n get_data\n end", "def update\n @sensor = Sensor.find(params[:id])\n\n if @sensor.update(params[:sensor])\n head :no_content\n $redis.publish('sensors.update', { :name => @sensor.name, :value => @sensor.value, :id => @sensor.id}.to_json)\n else\n render json: @sensor.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @sphere.update(sphere_params)\n format.html { redirect_to @sphere, notice: 'Sphere was successfully updated.' }\n format.json { render :show, status: :ok, location: @sphere }\n else\n format.html { render :edit }\n format.json { render json: @sphere.errors, status: :unprocessable_entity }\n end\n end\n end", "def UpdateView params = {}\n \n APICall(path: 'views.json',method: 'PUT',payload: params.to_json)\n \n end", "def update\n @data = @recipe.update(params[:id], recipe_params)\n render json: @data\n end", "def update\n respond_to do |format|\n if @cloud.update(cloud_params)\n format.html { redirect_to @cloud, notice: 'Cloud was successfully updated.' }\n format.json { render :show, status: :ok, location: @cloud }\n else\n format.html { render :edit }\n format.json { render json: @cloud.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @aws_datum.update(aws_datum_params)\n format.html { redirect_to @aws_datum, notice: 'Aws datum was successfully updated.' }\n format.json { render :show, status: :ok, location: @aws_datum }\n else\n format.html { render :edit }\n format.json { render json: @aws_datum.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @station = Station.find(params[:id])\n\n if @station.update(station_params)\n head :no_content\n else\n render json: @station.errors, status: :unprocessable_entity\n end\n end", "def update\n @seance = Seances::UseCases::Update.new.call(id: params[:id], params: seance_params)\n\n if @seance.valid?\n render jsonapi: @seance\n else\n render jsonapi_errors: @seance.errors, status: :unprocessable_entity\n end\n end", "def update\n update_save(@sensor_datum, sensor_datum_params, \"Sensor datum\")\n end", "def update\n @asset.update(price: params[:asset][:price])\n json_response(@asset,:created)\n end", "def update_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by(id: params[:id])\n suggested_pathway.name = params[:name]\n suggested_pathway.year = params[:year]\n suggested_pathway.course_id = params[:course_id]\n suggested_pathway.data = params[:data]\n suggested_pathway.save\n render json: suggested_pathway\n end", "def update\n @stone = Stone.find(params[:id])\n\n respond_to do |format|\n if @stone.update_attributes(params[:stone])\n format.html { redirect_to @stone, notice: 'Stone was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stone.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @ocean.update(ocean_params)\n format.html { redirect_to @ocean, notice: 'Ocean was successfully updated.' }\n format.json { render :show, status: :ok, location: @ocean }\n else\n format.html { render :edit }\n format.json { render json: @ocean.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance/{tenantId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update\n @hoge = Hoge.find(params[:id])\n\n respond_to do |format|\n if @hoge.update_attributes(params[:hoge])\n format.html { redirect_to @hoge, notice: 'Hoge was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @hoge.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_array_for_tenant(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/{tenantId}/arrays/{arrayId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend", "def update\n @jetty = Jetty.find(params[:id])\n\n respond_to do |format|\n if @jetty.update_attributes(params[:jetty])\n format.html { redirect_to @jetty, notice: 'Jetty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @jetty.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @click_data = ClickData.find(params[:id])\n\n if @click_data.update(click_data_params)\n head :no_content\n else\n render json: @click_data.errors, status: :unprocessable_entity\n end\n end" ]
[ "0.6673671", "0.6190524", "0.6128267", "0.60708034", "0.59574443", "0.5956493", "0.59364563", "0.57902145", "0.57610625", "0.57604295", "0.5743673", "0.5713474", "0.5699177", "0.56764513", "0.56631386", "0.5649809", "0.5641391", "0.56283784", "0.5625239", "0.56158745", "0.5611257", "0.56076235", "0.56057", "0.5605086", "0.5600693", "0.55780977", "0.55780977", "0.55731374", "0.5570189", "0.5570189", "0.5567843", "0.55634147", "0.5561518", "0.55570996", "0.553818", "0.55350935", "0.55211973", "0.55195254", "0.5516683", "0.5516398", "0.5497695", "0.54960483", "0.5492502", "0.5492502", "0.5487714", "0.5487041", "0.5482143", "0.5465857", "0.5457624", "0.5456705", "0.54503083", "0.54499084", "0.54430026", "0.5440723", "0.5438578", "0.54307544", "0.54296684", "0.5428684", "0.54236054", "0.5419487", "0.5416398", "0.5413438", "0.5410588", "0.5405045", "0.5402722", "0.54013413", "0.5395128", "0.539265", "0.5391712", "0.5390952", "0.5385742", "0.5385411", "0.5385204", "0.53850657", "0.53845507", "0.53835034", "0.53753763", "0.5375257", "0.5375257", "0.537398", "0.5354552", "0.5352914", "0.5351547", "0.53509605", "0.5350801", "0.53496087", "0.53476715", "0.53445524", "0.5343964", "0.53421706", "0.5341142", "0.5338796", "0.5336484", "0.5335015", "0.5313375", "0.5309792", "0.5309311", "0.53081226", "0.5307508", "0.53063416" ]
0.66098225
1
DELETE /skydata/1 DELETE /skydata/1.json
def destroy @skydatum = Skydatum.find(params[:id]) @skydatum.destroy respond_to do |format| format.html { redirect_to skydata_url } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end", "def delete_data\n response = WebPay.client.delete([path, 'data'].join('/'))\n response['deleted']\n end", "def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end", "def destroy\n @sky.destroy\n respond_to do |format|\n format.html { redirect_to skies_url, notice: 'Sky was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend", "def destroy\n @datum.destroy\n respond_to do |format|\n format.html { redirect_to data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dataset_datum.destroy\n respond_to do |format|\n format.html { redirect_to dataset_data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @datum = Datum.find(params[:id])\n @datum.destroy\n\n respond_to do |format|\n format.html { redirect_to data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @datum = Datum.find(params[:id])\n @datum.destroy\n\n respond_to do |format|\n format.html { redirect_to data_url }\n format.json { head :no_content }\n end\n end", "def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def delete\n client.delete(\"/#{id}\")\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @raw_datum = RawDatum.find(params[:id])\n @raw_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to raw_data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @gethotelstaticdatagd = Gethotelstaticdatagd.find(params[:id])\n @gethotelstaticdatagd.destroy\n\n respond_to do |format|\n format.html { redirect_to gethotelstaticdatagds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @kota_stone.destroy\n respond_to do |format|\n format.html { redirect_to kota_stones_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @daty.destroy\n respond_to do |format|\n format.html { redirect_to daties_url, notice: 'Daty was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @datapoint.destroy\n respond_to do |format|\n format.html { redirect_to datapoints_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n path = relativize_path path\n\n Precog.connect self do |http|\n uri = Addressable::URI.new\n uri.query_values = { :apiKey => api_key }\n\n http.delete \"/ingest/v#{VERSION}/fs/#{path}?#{uri.query}\"\n end\n end", "def destroy\n @datafile.destroy\n respond_to do |format|\n format.html { redirect_to datafiles_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @datastore = Datastore.find(params[:id])\n @datastore.destroy\n\n respond_to do |format|\n format.html { redirect_to datastores_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @energy_datum = EnergyDatum.find(params[:id])\n @energy_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to energy_data_url }\n format.json { head :no_content }\n end\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def delete(path, data = {})\n self.class.delete path, :body => data.merge(:u => access_token)\n end", "def destroy\n @asos_datum.destroy\n respond_to do |format|\n format.html { redirect_to asos_data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @seo_datum = SeoDatum.find(params[:id])\n @seo_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to seo_data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @storage = @client.storages.find(params[:id])\n @storage.destroy\n\n respond_to do |format|\n format.html { redirect_to client_url(@client) }\n format.json { head :no_content }\n end\n end", "def destroy\n @stone = Stone.find(params[:id])\n @stone.destroy\n\n respond_to do |format|\n format.html { redirect_to stones_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(url)\n @deleted = true\nend", "def destroy\n @sensor_data.destroy\n respond_to do |format|\n format.html { redirect_to sensor_data_url, notice: 'Sensor data was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_demo(id)\n delete_record \"/demos/#{id}\"\n end", "def delete(path)\n RestClient.delete request_base+path\n end", "def destroy\n @cloud.delete\n respond_to do |format|\n format.html { redirect_to clouds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @forest.destroy\n respond_to do |format|\n format.html { redirect_to forests_url }\n format.json { head :no_content }\n end\n end", "def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end", "def destroy\n @spdatum = Spdatum.find(params[:id])\n @spdatum.destroy\n\n respond_to do |format|\n format.html { redirect_to spdata_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @git_datum = GitDatum.find(params[:id])\n @git_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to git_data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @three.destroy\n respond_to do |format|\n format.html { redirect_to threes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dataset.destroy\n respond_to do |format|\n format.html { redirect_to study_path(@dataset.study), notice: 'Dataset was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @datum = Datum.find(params[:id])\n verify_user(@datum.user.id)\n @datum.destroy\n\n respond_to do |format|\n format.html { redirect_to data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @aws_datum.destroy\n respond_to do |format|\n format.html { redirect_to aws_data_url, notice: 'Aws datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @database = Database.find(params[:id])\n path = @database.path\n delete = %x[rm -R #{path}]\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end", "def delete\n render json: Alien.delete(params[\"id\"])\n end", "def destroy\n @datum.destroy\n respond_to do |format|\n format.html { redirect_to data_url, notice: 'Datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @vertices_scene1.destroy\n respond_to do |format|\n format.html { redirect_to vertices_scene1s_url, notice: 'Vertices scene1 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @server1 = Server1.find(params[:id])\n @server1.destroy\n\n respond_to do |format|\n format.html { redirect_to server1s_url }\n format.json { head :no_content }\n end\n end", "def delete(path, params)\n headers = {:Authorization => \"token #{token}\", :content_type => :json, :accept => :json}\n res = RestClient.delete(\"#{github_api_uri}/#{path}\", params.to_json, headers)\n Yajl.load(res)\n end", "def destroy\n @dbh_measurement.destroy\n respond_to do |format|\n format.html { redirect_to dbh_measurements_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @line_station_2.destroy\n respond_to do |format|\n format.html { redirect_to line_station_2s_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @htc.destroy\n respond_to do |format|\n format.html { redirect_to htcs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bg_measurement.destroy\n respond_to do |format|\n format.html { redirect_to bg_measurements_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @bg_measurement.destroy\n respond_to do |format|\n format.html { redirect_to bg_measurements_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dart = Dart.find(params[:id])\n @dart.destroy\n\n respond_to do |format|\n format.html { redirect_to darts_url }\n format.json { head :no_content }\n end\n end", "def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end", "def destroy\n @unity3d.destroy\n respond_to do |format|\n format.html { redirect_to unity3ds_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @kata.destroy\n respond_to do |format|\n format.html { redirect_to katas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @data_store = DataStore.find(params[:id])\n @data_store.destroy\n\n respond_to do |format|\n format.html { redirect_to data_sources_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @hoge = Hoge.find(params[:id])\n @hoge.destroy\n\n respond_to do |format|\n format.html { redirect_to hoges_url }\n format.json { head :ok }\n end\n end", "def destroy\n @fixture = Fixture.find(params[:id])\n @fixture.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @asthenium.destroy\n respond_to do |format|\n format.html { redirect_to asthenia_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @cow.destroy\n respond_to do |format|\n format.html { redirect_to kine_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @v1_chore = Chore.where(id: params[:id])\n if @v1_chore.destroy\n head(:ok)\n else\n head(:unprocessable_entity)\n end\n end", "def destroy\n @forest = Forest.find(params[:id])\n @forest.destroy\n\n respond_to do |format|\n format.html { redirect_to forests_url }\n format.json { head :no_content }\n end\n end", "def delete_json(url)\n JSON.parse(delete(url, :json, :json))\n end", "def destroy\n @content_datum = ContentDatum.find(params[:id])\n @content_datum.destroy\n\n respond_to do |format|\n format.html { redirect_to content_data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @geo_datum.destroy\n respond_to do |format|\n format.html { redirect_to geo_data_url, notice: 'Geo datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @moonwalk.destroy\n respond_to do |format|\n format.html { redirect_to moonwalks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @datafile.destroy\n respond_to do |format|\n format.html { redirect_to datafiles_url, notice: 'Datafile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(path, data={})\n request(:delete, path, data)\n end", "def destroy\n @sensor.destroy\n respond_to do |format|\n format.html { redirect_to sensors_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sensor.destroy\n respond_to do |format|\n format.html { redirect_to sensors_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @earth.destroy\n respond_to do |format|\n format.html { redirect_to earths_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @request_datum.destroy\n respond_to do |format|\n format.html { redirect_to request_data_url }\n format.json { head :no_content }\n end\n end", "def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end", "def destroy\n @unstructured_datum.destroy\n respond_to do |format|\n format.html { redirect_to unstructured_data_url, notice: 'Unstructured datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete(name)\n raise('wrong type: String required') unless name.is_a?(String)\n raise('wrong value: name must be valid') unless !name.nil? && !name.empty?\n\n @client.post({\n 'action' => 'del',\n 'object' => 'htpl',\n 'values' => name,\n }.to_json)\n end", "def destroy\n #Finds selected data file\n @data_file = DataFile.find(params[:id])\n #destroys data file\n @data_file.destroy\n respond_to do |format|\n format.html { redirect_to '/admin' }\n format.json { head :ok }\n end\n end", "def destroy\n @diagnoz = Diagnoz.find(params[:id])\n @diagnoz.destroy\n\n respond_to do |format|\n format.html { redirect_to diagnozs_url }\n format.json { head :no_content }\n end\n end", "def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end", "def destroy\n id = params[:id]\n @datacenter = Datacenter.any_of({_id: id}, {name: id.gsub('-', '.')}).first\n @datacenter.destroy\n\n respond_to do |format|\n format.html { redirect_to datacenters_url }\n format.json { head :ok }\n end\n end", "def destroy\n @datashows = Datashow.find(params[:id])\n @datashows.destroy\n\n respond_to do |format|\n format.html { redirect_to(datashows_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n respond_to do |format|\n @data_dictionary.update_columns( :del_flg => 1)\n format.html { redirect_to data_dictionaries_path(:dictid => @data_dictionary.parent_code), notice: 'Data dictionary was successfully destroyed.' }\n format.json { head :no_content }\n end\n \n end", "def destroy\n @line_station = LineStation.find(params[:id])\n @line_station.destroy\n\n respond_to do |format|\n format.html { redirect_to line_stations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @strosek.destroy\n respond_to do |format|\n format.html { redirect_to stroseks_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @dataload_ga = DataloadGa.find(params[:id])\n @dataload_ga.destroy\n\n respond_to do |format|\n format.html { redirect_to dataload_gas_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @weather = Weather.find(params[:id])\n @weather.destroy\n\n respond_to do |format|\n format.html { redirect_to weathers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @weather = Weather.find(params[:id])\n @weather.destroy\n\n respond_to do |format|\n format.html { redirect_to weathers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @weather = Weather.find(params[:id])\n @weather.destroy\n\n respond_to do |format|\n format.html { redirect_to weathers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n\n @scene.destroy\n\n respond_to do |format|\n format.html { redirect_to action: \"index\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @four.destroy\n respond_to do |format|\n format.html { redirect_to fours_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @nowscene.destroy\n respond_to do |format|\n format.html { redirect_to nowscenes_url, notice: 'Nowscene was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end", "def destroy\n @dato = Dato.find(params[:id])\n @dato.destroy\n\n respond_to do |format|\n format.html { redirect_to datos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @test_meta_datum.destroy\n respond_to do |format|\n format.html { redirect_to test_meta_data_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @tracked_datum.destroy\n respond_to do |format|\n format.html { redirect_to tracked_data_url, notice: 'Tracked datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.7065175", "0.70328176", "0.6761301", "0.6746985", "0.66991705", "0.6678536", "0.6649326", "0.66250056", "0.66250056", "0.66237664", "0.6608072", "0.6595052", "0.6554437", "0.65450907", "0.65388983", "0.65388983", "0.6516033", "0.6509626", "0.6499219", "0.64822525", "0.64803547", "0.6478592", "0.647612", "0.6458792", "0.6455968", "0.6455968", "0.6455968", "0.6455968", "0.6450084", "0.6448569", "0.6445661", "0.6434825", "0.64165133", "0.64150834", "0.64098185", "0.640784", "0.64029366", "0.6401815", "0.6399982", "0.63990754", "0.6393533", "0.6391572", "0.6374858", "0.63732773", "0.6372993", "0.6371316", "0.6368857", "0.63625854", "0.63579565", "0.6357945", "0.63571644", "0.6357102", "0.6355142", "0.63434774", "0.6341092", "0.6339674", "0.6339674", "0.63379294", "0.6336612", "0.633367", "0.6332145", "0.63319516", "0.6331193", "0.6327991", "0.6326539", "0.63214415", "0.6321234", "0.63086766", "0.6303936", "0.63030684", "0.6299672", "0.629965", "0.6299213", "0.62972593", "0.6293983", "0.6293983", "0.62914157", "0.62907016", "0.6290498", "0.6281026", "0.62800306", "0.6278349", "0.6276764", "0.6274746", "0.62746155", "0.62722945", "0.6269085", "0.62665063", "0.6263589", "0.62635636", "0.62635285", "0.62635285", "0.62635285", "0.6262887", "0.62617034", "0.6259683", "0.62582904", "0.6257752", "0.6249573", "0.624868" ]
0.7398046
0