query
stringlengths
7
9.55k
document
stringlengths
10
363k
metadata
dict
negatives
listlengths
0
101
negative_scores
listlengths
0
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Increments an integer value in the cache. Note that it uses binary collection interface, therefore will fail if the value is not represented as ASCIIencoded number using +:raw+.
def increment(name, amount = 1, expires_in: nil, initial: nil, **options) instrument :increment, name, amount: amount do failsafe :increment do key = normalize_key(name, options) res = collection.binary.increment( key, ::Couchbase::Options::Increment(delta: amount, expiry: expires_in, initial: initial) ) @last_mutation_token = res.mutation_token res.content end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def increment\n Dictionary.db.zincrby @key, 1, @value\n end", "def _inc(key,value)\n _set(key, (_get(key) || 0) + value)\n end", "def test_increment_existing_numeric\n @cache.add('Key', '100', 0, Time.now.to_i + 60)\n result = @cache.increment('Key', '1')\n cache = @cache.get('Key').args\n\n assert_true result.success\n assert_equal 'STORED', result.message.chomp.split(\"\\s\")[0]\n assert_equal 101, cache.data\n end", "def incr(key, value = 1)\n mon_synchronize do\n perform [\"incr\", key, value], :proc => T_INT\n end\n end", "def incr(key, value = 1)\n mon_synchronize do\n perform [\"incr\", key, value], proc: T_INT\n end\n end", "def increment\n @value += 1\n end", "def zincrby(key, increment, member); end", "def zincrby(key, increment, member); end", "def incr\n add(1)\n end", "def increment(key, inc_value = 1, expires_in = nil, initial = nil)\n puts \"Rails.cache.increment(#{key}, #{inc_value}, {expires_in: #{get_ttl(expires_in)}, initial: #{initial}, raw: false})\"\n return Rails.cache.increment(key, inc_value, {expires_in: get_ttl(expires_in), initial: initial, raw: false})\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: increment: K: #{key}. M: #{exc.message}, I: #{exc.inspect}\" }\n return nil\n end", "def increment\n curr_value = counter\n self.counter = curr_value + 1\n save\n curr_value\n end", "def incr(x) x + 1 end", "def incr(key); end", "def incr(key); end", "def increment\n cache_updated_successfully =\n with_cache_store do |store|\n begin\n store.incr(cache_key) ||\n # When the key doesn't exit in the cache because of cache expirations/clean-ups/restarts\n store.add(cache_key, value_in_db + 1) ||\n # In rare cases, the value for the key is updated by other client and we have to fail immediately, not to\n # run into race-conditions.\n raise(ConcurrentCacheWriteError, \"Failing not to enter a race condition while writing a value for the key #{cache_key}\")\n rescue store.error_class => e\n false\n end\n end\n\n begin\n if cache_updated_successfully\n # When this database transaction failed afterward, we have to rollback the incrementation by decrementing\n # the value in the cached.\n # Without the rollback, we'll fall into an inconsistent state between the database and the cache.\n on_error_rollback_by(:decrement_in_cache)\n\n # As we have successfully incremented the value in the cache, we can rely on the cache in order to\n # get/show the latest value.\n # Therefore, we have no need to update the database record in realtime and we can achieve\n # incrementing the counter with a little row-lock.\n increment_in_db_later\n else\n # The cache service seems to be down, but we don't want to stop the application service.\n # That's why we fall back to increment the value in the database which requires a bigger row-lock.\n increment_in_db\n end\n rescue => e\n raise e\n end\n end", "def hincrby(key, field, increment); end", "def hincrby(key, field, increment); end", "def increase key, amount=1\n @lock.write_sync do\n return unless @data[key].nil? || Numeric === @data[key]\n @data[key] ||= 0\n @data[key] += amount\n end\n end", "def inc(v = 1)\n sync { @v += v }\n end", "def zincr(key, member, score = 1)\n mon_synchronize do\n perform [\"zincr\", key, member, score], :proc => T_INT\n end\n end", "def increment(key, offset=1)\n ret, value = Lib.memcached_increment(@struct, key, offset)\n check_return_code(ret, key)\n value\n rescue => e\n tries ||= 0\n raise unless tries < options[:exception_retry_limit] && should_retry(e)\n tries += 1\n retry\n end", "def incr(att)\n raise ArgumentError unless counters.include?(att)\n write_local(att, db.incr(key(att)))\n end", "def zincr(key, member, score = 1)\n mon_synchronize do\n perform [\"zincr\", key, member, score], proc: T_INT\n end\n end", "def incrby(key, increment); end", "def incrby(key, increment); end", "def incr_counter!(name, val = 1)\n counter = self.send(name.to_sym)\n counter.incr(val)\n save\n counter.reconcile!\n end", "def increment!\n @value += @increment\n \n self\n end", "def incr(key, increment=nil)\n timeout_retry(3, 3){\n if increment\n write \"INCRBY #{key} #{increment}\\r\\n\"\n else\n write \"INCR #{key}\\r\\n\"\n end \n integer_reply\n }\n end", "def inc(key)\n \n end", "def incr(key)\n send_command([:incr, key])\n end", "def increment(by=1, &block)\n allow_expiration do\n val = redis.incrby(key, by).to_i\n block_given? ? rewindable_block(:decrement, by, val, &block) : val\n end\n end", "def increment(key)\n @counter[key] += 1\n end", "def INC\n operand = unwrap_integer evaluation_stack.pop\n evaluation_stack.push operand + 1\n end", "def incr(key)\n node_for(key).incr(key)\n end", "def encode\n index = e_byte(@idx)\n e_byte(NEW_CACHE)+index+@value.encode\n end", "def increment_processed_items\n processed_items = $redis.hgetall(redis_key)['processed_items'].to_i\n processed_items += 1\n\n $redis.hset(redis_key, :processed_items, processed_items)\n end", "def inc_value(iIncrement = 1)\n super\n end", "def speed_incr _value\n send_cmd(\"speed_incr #{_value}\")\n end", "def cache_id\n index + 1\n end", "def increment(v = 1)\n if @value.kind_of?(String)\n @value = (to_f_or_i(@value) + v).to_s if to_f_or_i(@value)\n else\n @value += v\n end\n end", "def increment\n @counter = @counter + 1\n end", "def increment_for(obj)\n # decide the time of event asap\n ts = Time.now.ceil.to_i\n\n if obj.class.ancestors.include?MongoMapper::Document\n args = obj.key_attributes.collect { |k,v| v.to_s }\n cache_key = generate_key(ts, obj.class.name, *args)\n\n val = Cequel::Record.redis.get(cache_key)\n if val.nil?\n val = 1\n else\n val = val.to_i + 1\n end\n\n ttl = (time_window + 1) * 60\n\n # Update a sharded counter\n MongoMapper::Document.redis.setex(cache_key, ttl, val)\n\n # Optionally, update the index\n index_key = generate_index_key(ts, obj.class.name, *args)\n index_present = MongoMapper::Document.redis.get(index_key).try(:to_i)\n if index_present != 1\n MongoMapper::Document.redis.setex(index_key, ttl, 1)\n end\n end\n\n end", "def increment_counter(key)\n if @counters.key?(key)\n @counters[key] += 1\n else\n @counters[key] = 1\n end\n end", "def increment(att, count = 1)\n key[:counters].call(\"HINCRBY\", att, count)\n end", "def hincrby(key, field, increment)\n node_for(key).hincrby(key, field, increment)\n end", "def zincrby(key, increment, member)\n call(key, [:zincrby, key, increment, member], transform: Redis::Floatify)\n end", "def zincrby(key, increment, member)\n node_for(key).zincrby(key, increment, member)\n end", "def incr(key, timestamp, set_name)\n redis.zadd(set_name, timestamp, key)\n redis.incr(key).to_i\n end", "def increment!(subject, val = 1)\n $redis.incrby(key(subject), val)\n end", "def increment(cache_key, amount, options)\n counter = counter(cache_key, options)\n counter[:bucket] += amount\n Prop::Limiter.cache.write(cache_key, counter)\n counter\n end", "def increment_counter\n unless self.count.nil?\n self.count += 1\n else\n self.count = 1\n end\n end", "def increment_counter(counter_name, id)\n update_all \"#{counter_name} = #{counter_name} + 1\", \"#{primary_key} = #{id}\"\n end", "def hincrby(key, field, increment)\n send_command([:hincrby, key, field, Integer(increment)])\n end", "def hincrbyfloat(key, field, increment); end", "def hincrbyfloat(key, field, increment); end", "def incrby(key, increment)\n node_for(key).incrby(key, increment)\n end", "def incr_count\n @count ||= 0\n @count += 1\n end", "def increment(key, val)\n self[key] += _floatify(val)\n end", "def increment(metric, value = 1)\n @adapter.increment metric, value\n end", "def inc(ptr, amount=1)\n ptr = Convert(ptr, :pointer)\n val = @builder.load(ptr)\n @builder.store(add(val, amount), ptr)\n return ptr\n end", "def put_i32(arg)\n @data += [arg].pack(\"N\")\n self\n end", "def inc( date ) \n rounded_date = round( date ) \n begin\n @sequence[ rounded_date ] += 1\n rescue NoMethodError # can't add one to nil\n self << rounded_date # sweeps cache\n retry\n else \n @values = nil # sweep cache \n end \n end", "def increment_counter(counter)\n\tcounter += 1\n\treturn counter\nend", "def vm_do_increment\r\n inc_raw = self.pop\r\n\r\n unless (inc_value = inc_raw.to_foorth_n)\r\n error \"F40: Cannot convert a #{inc_raw.foorth_name} to a Numeric instance\"\r\n end\r\n\r\n if inc_value > 0\r\n inc_value\r\n else\r\n error \"F41: Invalid loop increment value: #{inc_value}\"\r\n end\r\n end", "def increment(k, amount = 1, ignored_options = nil)\n handle_fork\n new_v = _get(k).to_i + amount\n _set k, new_v, 0\n new_v\n end", "def value\n redis.get(key).to_i\n end", "def increment(name, amount = 1, options = nil) # :nodoc:\n options = merged_options(options)\n response = instrument(:increment, name, :amount => amount) do\n @data.incrby(namespaced_key(name, options), amount)\n end\n rescue => e\n logger.error(\"Error incrementing cache entry in redis: #{e}\") if logger\n nil\n end", "def increment_and_save!\n update_and_save { self.last_value = (last_value || 0) + 1 }\n end", "def increment_id!\n self.id = (self.id + 1) % 0x10000\n end", "def is_incr=(value)\n @children['is-incr'][:value] = value\n end", "def incrby(key, increment)\n send_command([:incrby, key, Integer(increment)])\n end", "def increase(attr)\n raise NoMethodError, \"undefined method `#{attr}` for #{self}\" unless self.respond_to?(attr)\n raise NotCounterbleError, \"not countable attributs `#{attr}` for #{self}\" unless countable.include? attr\n self.send(\"#{attr}=\", self.send(attr).send(:+, 1))\n end", "def increment \n\t\t@counter = @counter + 1\n\tend", "def incr(key, window=@max_window)\n key = key.to_s\n now = Time.now.to_f\n @redis.multi do\n @redis.zadd(key, now, SecureRandom.uuid)\n @redis.expire(key, @max_window.ceil)\n do_get(key, now, window)\n end.last\n end", "def incr(key, amt = 1, ttl = nil, default = nil)\n check_positive!(amt)\n\n perform(:incr, key, amt.to_i, ttl_or_default(ttl), default)\n end", "def increment!(name,amount=1)\n raise ArgumentError, \"Only integer fields can be incremented.\" unless self.class.fields.include?({:name => name.to_s, :type => :integer})\n redis.incr(field_key(name), amount)\n end", "def add_integer(key, value)\n int = QueuedEmailInteger.find_by(queued_email_id: id, key: key.to_s)\n unless int\n int = QueuedEmailInteger.new\n int.queued_email_id = id\n int.key = key.to_s\n end\n int.value = value.to_i\n int.save\n int\n end", "def increment_counter!\n # Increment the counter\n sql(:execute, %(\n INSERT INTO knifeswitch_counters (name,counter)\n VALUES (?, 1)\n ON DUPLICATE KEY UPDATE counter=counter+1\n ), namespace)\n\n # Possibly open the circuit\n sql(\n :execute,\n %(\n UPDATE knifeswitch_counters\n SET closetime = ?\n WHERE name = ? AND COUNTER >= ?\n ),\n DateTime.now + error_timeout.seconds,\n namespace, error_threshold\n )\n end", "def inc\n $i + 1\n end", "def call_inc(reg_key, addr, i_reg, m_spec)\n reg = @registers[reg_key]\n val = get_mem_addr(addr, i_reg) + reg.word.to_i\n reg.word.from_int(val)\n end", "def increment(name)\n update(name)\n end", "def inc(value=1) \n if valid?\n #raise CustomError::InvalidBar unless valid?\n _set(:start_at, Time.now.to_f) unless _get(:start_at)\n _set(:current_at, Time.now.to_f)\n inc_value = _inc(:current,value)\n mylog(\"inc inc_value: #{inc_value}\")\n inc_value\n end \n end", "def increment\n self.class.increment(self)\n end", "def increase(custom_field_id, cells)\n ActiveRecord::Base.transaction do\n custom_field = CustomFields::AutoNumbering.find(custom_field_id)\n \n if self.unset_cells(custom_field, cells).empty?\n value = format_value(custom_field, cells)\n\n key_hash = AutoNumberRunning.key_hash(custom_field.format_key, value)\n\n auto_number_running = custom_field.auto_number_runnings.find(:first,\n :conditions => {\n :auto_number_runnings => { :key_hash => key_hash }\n }\n )\n auto_number_running ||= AutoNumberRunning.new(\n :key_hash => key_hash,\n :current => (custom_field.start_value - custom_field.increment)\n )\n\n custom_field.auto_number_runnings << auto_number_running if auto_number_running.new_record?\n auto_number_running.current = auto_number_running.current + custom_field.increment\n\n auto_number_running.save\n\n format_value(auto_number_running, cells)\n end\n end.to_s\n end", "def increment_integer(user_id)\n user = User.find user_id\n user.integer_value += 1\n user.save\n\n user\n end", "def incrbyfloat(key, increment); end", "def incrbyfloat(key, increment); end", "def increment(node)\n change_by node, 1\n end", "def increment(field, amount = 1)\n #value = (self[field] || 0) + amount\n #self[field] = value\n #if !@parse_object_id\n # # TODO - warn that the object must be stored first\n # return nil\n #end\n\n body = {field => Parse::Increment.new(amount)}.to_json\n data = Parse.client.request(self.uri, :put, body)\n parse data\n self\n end", "def increment_order!\n @current += 1\n end", "def __to_inc__\n self\n end", "def mutate(num)\n num += 1\n end", "def set_integer!(value)\n @objects = nil\n @memory = nil\n\n if value < 0\n self[:type] = :negative_integer\n self[:values][:i64] = value\n else\n self[:type] = :positive_integer\n self[:values][:u64] = value\n end\n end", "def increment(name, amount = T.unsafe(nil), options = T.unsafe(nil)); end", "def hash_data_add(hash, key)\n if hash.has_key?(key)\n hash[key] = hash[key] + 1\n else \n hash[key] = 1\n end\n end", "def update_counting_hash(hash, key)\n hash[key] ? hash[key] += 1 : hash[key] = 1\n hash\nend", "def increment element\n element.perform :increment\n end", "def increment!(attribute, by = 1, touch: nil)\n increment(attribute, by)\n change = public_send(attribute) - (public_send(:\"#{attribute}_in_database\") || 0)\n self.class.update_counters(id, attribute => change, touch: touch)\n public_send(:\"clear_#{attribute}_change\")\n self\n end", "def next!\r\n @cur = @cache[@idx+=1]\r\n end", "def increment(request_id, value)\n unless has_request_id? request_id\n self.counts[actor][\"total\"] += value\n self.counts[actor][\"requests\"] << request_id\n end\n end" ]
[ "0.7057279", "0.7033475", "0.6877507", "0.67166203", "0.67045677", "0.6575232", "0.64644945", "0.64644945", "0.6450084", "0.6442746", "0.64252675", "0.6388007", "0.63565826", "0.63565826", "0.6354197", "0.63503367", "0.63503367", "0.62753695", "0.61862975", "0.61835223", "0.61676764", "0.61398554", "0.61289775", "0.6117214", "0.6117214", "0.60802513", "0.60690707", "0.60419667", "0.60093623", "0.6006085", "0.6000849", "0.5991363", "0.5987547", "0.597388", "0.5940329", "0.5939535", "0.5914898", "0.5909229", "0.58880883", "0.58876604", "0.5882379", "0.58735055", "0.58682936", "0.5864089", "0.5845439", "0.5833015", "0.58273995", "0.5824151", "0.5779393", "0.5776348", "0.57406926", "0.5732545", "0.57016265", "0.5698618", "0.5698618", "0.56948864", "0.5694735", "0.56907785", "0.56871367", "0.5685582", "0.5680841", "0.56790787", "0.56704", "0.5664482", "0.565339", "0.5641659", "0.56256235", "0.56217015", "0.56058455", "0.559946", "0.55944216", "0.5574712", "0.5573597", "0.5557351", "0.55412793", "0.55348045", "0.55273116", "0.552399", "0.5494868", "0.5481739", "0.5477789", "0.5477736", "0.5472142", "0.54600716", "0.5459508", "0.5446396", "0.5446396", "0.54441607", "0.54303885", "0.54286104", "0.54255205", "0.54131323", "0.5412033", "0.5406621", "0.5403796", "0.54029304", "0.5396066", "0.5390837", "0.53907806", "0.53898895" ]
0.53901947
99
Decrements an integer value in the cache. Note that it uses binary collection interface, therefore will fail if the value is not represented as ASCIIencoded number using +:raw+. Note that the counter represented by nonnegative number on the server, and it will not cycle to maximum integer when decrementing zero.
def decrement(name, amount = 1, expires_in: nil, initial: nil, **_options) instrument :decrement, name, amount: amount do failsafe :decrement do key = normalize_key(name, options) res = collection.binary.decrement( key, ::Couchbase::Options::Decrement(delta: amount, expiry: expires_in, initial: initial) ) @last_mutation_token = res.mutation_token res.content end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def decr(key, value = 1)\n mon_synchronize do\n perform [\"decr\", key, value], :proc => T_INT\n end\n end", "def decr(key, value = 1)\n mon_synchronize do\n perform [\"decr\", key, value], proc: T_INT\n end\n end", "def _dec(key,value)\n _set(key, (_get(key) || 0) - value)\n end", "def decrement(key, value = 1, expires_in = nil, initial = nil)\n puts \"Rails.cache.decrement(#{key}, #{value}, {expires_in: #{get_ttl(expires_in)}, initial: #{initial}, raw: false})\"\n return Rails.cache.decrement(key, value, {expires_in: get_ttl(expires_in), initial: initial, raw: false})\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: decrement: K: #{key}. M: #{exc.message}, I: #{exc.inspect}\" }\n return nil\n end", "def decrement(key)\n msg = 'Trying to reduce count below zero.'\n raise RangeError, msg if @counter[key] == 0\n @counter[key] -= 1\n end", "def decrement\n @value -= 1\n end", "def decr_counter!(name, decr = 1)\n counter = self.send(name.to_sym)\n counter.decr(val)\n save\n counter.reconcile!\n end", "def decrement(key, offset=1)\n ret, value = Lib.memcached_decrement(@struct, key, offset)\n check_return_code(ret, key)\n value\n rescue => e\n tries ||= 0\n raise unless tries < options[:exception_retry_limit] && should_retry(e)\n tries += 1\n retry\n end", "def decrement_counter(counter_name, id)\n update_all \"#{counter_name} = #{counter_name} - 1\", \"#{primary_key} = #{id}\"\n end", "def decrement\n @counter = @counter - 1\n end", "def decrement\n cache_updated_successfully =\n with_cache_store do |store|\n begin\n store.decr(cache_key) ||\n store.add(cache_key, value_in_db - 1) ||\n raise(ConcurrentCacheWriteError, \"Failing not to enter a race condition while writing a value for the key #{cache_key}\")\n rescue store.error_class => e\n false\n end\n end\n\n begin\n if cache_updated_successfully\n on_error_rollback_by(:increment_in_cache)\n\n decrement_in_db_later\n else\n decrement_in_db\n end\n rescue => e\n raise e\n end\n end", "def dec(v = 1)\n sync { @v -= v }\n end", "def decrement!\n @value -= @increment\n \n self\n end", "def decrement(by=1, &block)\n allow_expiration do\n val = redis.decrby(key, by).to_i\n block_given? ? rewindable_block(:increment, by, val, &block) : val\n end\n end", "def decr(att)\n raise ArgumentError unless counters.include?(att)\n write_local(att, db.decr(key(att)))\n end", "def decrement\n\n c = data['count']\n return false unless c\n\n c = c - 1\n data['count'] = c\n self[:status] = s = (c > 0) ? 'active' : 'consumed'\n\n self.update(\n content: Flor::Storage.to_blob(@flor_model_cache_data),\n status: s)\n\n c < 1\n end", "def decrement_counter(counter_name, id)\n update_counters(id, counter_name.to_sym => -1)\n end", "def decrement\n @mutex.synchronize {\n raise 'Counter already at 0' if @cnt == 0\n @cnt -= 1\n @cond_var.broadcast if @cnt == 0\n }\n end", "def decrement_counter(counter_name, id)\n rec = collection.findOne({:_id => id})\n rec[counter_name] -= 1\n collection.save(rec)\n end", "def decr(key, increment=nil)\n timeout_retry(3, 3){\n if increment\n write \"DECRBY #{key} #{increment}\\r\\n\"\n else\n write \"DECR #{key}\\r\\n\"\n end \n integer_reply\n }\n end", "def decrby(key, decrement); end", "def decrby(key, decrement); end", "def decrease key, amount=1\n @lock.write_sync do\n return unless @data[key].nil? || Numeric === @data[key]\n @data[key] ||= 0\n @data[key] -= amount\n end\n end", "def decrease(counter)\r\n counter - 1\r\nend", "def decrement(name, amount = 1, options = nil) # :nodoc:\n options = merged_options(options)\n response = instrument(:decrement, name, :amount => amount) do\n @data.decrby(namespaced_key(name, options), amount)\n end\n rescue => e\n logger.error(\"Error decrementing cache entry in redis: #{e}\") if logger\n nil\n end", "def decrease(counter)\n counter - 1\nend", "def decrease(counter)\n counter - 1\nend", "def decrease(counter)\n counter - 1\nend", "def decrease(counter)\n counter - 1\nend", "def decrease(counter)\n counter - 1\nend", "def decrease(counter)\n counter -= 1\nend", "def decrement_count(current_count)\n current_count.to_i - 1\n end", "def decrby(key, decrement)\n send_command([:decrby, key, Integer(decrement)])\n end", "def decrement_counter(counter_name, id, by: 1, touch: nil)\n update_counters(id, counter_name => -by, touch: touch)\n end", "def decrement!(name,amount=1)\n raise ArgumentError, \"Only integer fields can be decremented.\" unless self.class.fields.include?({:name => name.to_s, :type => :integer})\n redis.decr(field_key(name), amount)\n end", "def decrement_counter\n if self.class.column_names.include? (\"cares_count\")\n self.class.decrement_counter(\"cares_count\", self.id)\n end\n end", "def decrease(counter)\n counter[0] -= 1\nend", "def decrement\n with_update { with_progressables(:decrement) }\n end", "def decr_by major, minor, value\n def_zero major, minor\n @stats[major][minor] -= value\n end", "def zdecr(key, member, score = 1)\n mon_synchronize do\n perform [\"zdecr\", key, member, score], :proc => T_INT\n end\n end", "def zdecr(key, member, score = 1)\n mon_synchronize do\n perform [\"zdecr\", key, member, score], proc: T_INT\n end\n end", "def _dec\n @data = @_p_nz = (@data - 1) & 0xff\n end", "def decrement(name, amount = 1, options = nil)\n options = merged_options(options)\n\n instrument(:decrement, name, :amount => amount) do\n @client.decr(name, amount)\n end\n rescue Spymemcached::Error => e\n logger.error(\"Spymemcached::Error (#{e}): #{e.message}\") if logger\n nil\n end", "def delete(entry)\n deleted_index = @cache.delete(key_for(entry))\n if deleted_index\n @cache.each do |key, index|\n @cache[key] -= 1 if index > deleted_index\n end\n end\n deleted_index\n end", "def decr(key); end", "def decr(key); end", "def lrem(key, count, value)\n send_command([:lrem, key, Integer(count), value])\n end", "def decrement(key, amount = 1, options = {})\n increment(key, -amount, options)\n end", "def decrby(key, decrement)\n node_for(key).decrby(key, decrement)\n end", "def reset(value=0)\n @counter = value.to_i\n end", "def decrement(id, options = DecrementOptions.new)\n resp = @backend.document_decrement(@collection.bucket_name, \"#{@collection.scope_name}.#{@collection.name}\", id,\n options.timeout,\n {\n delta: options.delta,\n initial_value: options.initial,\n expiry: options.expiry,\n durability_level: options.durability_level,\n })\n CounterResult.new do |res|\n res.cas = resp[:cas]\n res.content = resp[:content]\n res.mutation_token = @collection.send(:extract_mutation_token, resp)\n end\n end", "def decremented_value_of(prev_value)\n @debug ? (prev_value-1) : nil\n end", "def decr(key, amt = 1, ttl = nil, default = nil)\n check_positive!(amt)\n\n perform(:decr, key, amt.to_i, ttl_or_default(ttl), default)\n end", "def decrement(name, amount = 1, options = nil)\n options ||= {}\n name = expanded_key name\n\n if ttl = options.delete(:expires_in)\n options[:ttl] ||= ttl\n end\n options[:create] = true\n instrument(:decrement, name, options) do |payload|\n payload[:amount] = amount if payload\n @data.decr(name, amount, options)\n end\n rescue ::Couchbase::Error::Base => e\n logger.error(\"#{e.class}: #{e.message}\") if logger\n raise if @raise_errors\n false\n end", "def decrement(name, amount = 1, options = nil)\n options = merged_options(options)\n instrument(:decrement, name, amount: amount) do\n rescue_error_with nil do\n @data.with { |c| c.decr(normalize_key(name, options), amount, options[:expires_in], 0) }\n end\n end\n end", "def down\n self.x = (x+1)%10\n end", "def get(key)\n return -1 unless @cache.key?(key)\n val = @cache[key]\n @cache.delete(key)\n @cache[key] = val\n val\n end", "def delete(val)\n count = self.lrem(0, val)\n if count > 0\n val\n else\n nil\n end\n end", "def decrement(k, amount = 1, ignored_options = nil)\n increment k, -amount\n end", "def decrement(stats, sample_rate = 1)\n update_counter stats, -1, sample_rate\n end", "def decrement(stats, sample_rate = 1)\n update_counter stats, -1, sample_rate\n end", "def decrement(att, count = 1)\n increment(att, -count)\n end", "def decrement(key, amount = 1, options = {})\n invoke(:decrement, key) do |store|\n alter(store, key, -amount, options)\n end\n end", "def call_dec(reg_key, addr, i_reg, m_spec)\n reg = @registers[reg_key]\n val = reg.word.to_i - get_mem_addr(addr, i_reg)\n reg.word.from_int(val)\n end", "def DEC\n operand = unwrap_integer evaluation_stack.pop\n evaluation_stack.push operand - 1\n end", "def decrement(name, amount = T.unsafe(nil), options = T.unsafe(nil)); end", "def decrement(node)\n change_by node, -1\n end", "def dec(key)\n \n end", "def decrement_counters\n if followable_type == \"User\"\n user = User.find(followable_id)\n follower = User.find(follower_id)\n user.update_attribute(:followers_count_cache, user.followers_count)\n follower.update_attribute(:following_count_cache, follower.following_users_count)\n end\n end", "def decr(key)\n node_for(key).decr(key)\n end", "def decrement(name, amount = 1, options = nil)\n key = expand_key(name)\n\n begin\n amount.times do |v|\n @gibson.dec key\n end\n rescue\n\n end\n end", "def remove(value)\n connection.zrem(key_label, value)\n end", "def decrement!(name,amount=1)\n raise ArgumentError, \"Only integer fields can be decremented.\" unless self.class.fields.include?({:name => name.to_s, :type => :integer})\n store.update_count(field_key(name), -amount)\n end", "def -(value)\n check_pre((\n (value.int?)\n ))\n\n from_index(normalize_index(to_index - value))\n end", "def decrement_clock\n clock[-1] -= 1\n carry_over\n end", "def decode_uinteger_value(value)\n build_integer(value, 0, value.length)\n end", "def decrement(stat, sample_rate=1); count stat, -1, sample_rate end", "def value\n redis.get(key).to_i\n end", "def debit!(value, request_id=nil)\n self.update!(value * -1, request_id)\n end", "def decrement_counter(following)\n User.decrement_counter(:followings_count,following.user_id)\n User.decrement_counter(:inverse_followings_count,following.follower_id) \n end", "def decrement(by: 1)\n return increment(by: -by.to_i)\n end", "def downvote(id)\n @redis.hincrby(\"id:\"+id,\"score\",-1)\n end", "def decrement element\n element.perform :decrement\n end", "def decrement(field, amount = 1)\n increment(field, -amount)\n end", "def lrem(key, count, value); end", "def lrem(key, count, value); end", "def delete\n \ttemp = @cbuf.delete_at(@s)\n \t@s += 1\n \ttemp\n end", "def reset_counter!\n return if counter == 0\n sql(:execute, %(\n INSERT INTO knifeswitch_counters (name,counter)\n VALUES (?, 0)\n ON DUPLICATE KEY UPDATE counter=0\n ), namespace)\n end", "def remove(key)\n \txk = key % 10001 \n xk = (xk + 1) % 10001 while @arr[xk].first != nil && @arr[xk].first != key \n @arr[xk] = [nil, -1] if @arr[xk].first == key\n end", "def _update_counts_after_destroy\n _wrap_in_counter_culture_active do\n self.class.after_commit_counter_cache.each do |hash|\n # decrement counter cache\n change_counter_cache(hash.merge(:increment => false))\n end\n end\n end", "def decrement(name, amount = 1, options=nil)\n options ||= {}\n name = namespaced_key(name, options)\n initial = options.has_key?(:initial) ? options[:initial] : 0\n expires_in = options[:expires_in]\n instrument_with_log(:decrement, name, :amount => amount) do\n with { |c| c.decr(name, amount, expires_in, initial) }\n end\n rescue Dalli::DalliError => e\n log_dalli_error(e)\n instrument_error(e) if instrument_errors?\n raise if raise_errors?\n nil\n end", "def pull(_d, _i)\n c = @c[_d][_i]\n\n # pull from @Cp\n @Cp[_d][c] -= 1\n\n # pull from @Ce\n vkey = Array.new(@d){|d| 0}\n vkey[_d] = _i\n begin\n ckey = vkey2ckey(vkey)\n @Ce[ckey][ @A[vkey] ] -= 1\n end while (vkey = succ_vkey_d(vkey, _d)) != nil\n\n @c[_d][_i] = nil\n end", "def rem(key, value)\n log(\"get :Deltas, #{key}, #{cache_name(value)}\")\n timestamp = connection.get(:Deltas, key, cache_name(value))\n\n log(\"remove :Deltas, #{key} -> #{timestamp_name(timestamp)}\")\n connection.remove(:Deltas, key, timestamp_name(timestamp))\n\n log(\"remove :Deltas, #{key} -> #{cache_name(value)}\")\n connection.remove(:Deltas, key, cache_name(value))\n end", "def lrem(key, count, value)\n node_for(key).lrem(key, count, value)\n end", "def somaDecrementa\n\t# regiao critica\n\t$var1 += 1\n\t$var2 -= 1\nend", "def decr major, minor\n decr_by major, minor, 1\n end", "def remove(data)\n set data, 0\n end", "def Subtract(val)\n self.value -= val\n end", "def dec(ptr, amount=1)\n ptr = Convert(ptr, :pointer)\n val = @builder.load(ptr)\n @builder.store(sub(val, amount), ptr)\n return ptr\n end", "def decrement(m)\n matches = m.message.scan(/\\([^)]+\\)--|\\S+--/)\n \n matches.each do |element|\n element.downcase!\n if element =~ /\\((.+)\\)--/\n if @@karma_db.has_key? $1\n if @@karma_db[$1] == \"1\"\n @@karma_db.delete $1 \n else\n @@karma_db[$1] = (@@karma_db[$1].to_i - 1).to_s\n end\n else\n @@karma_db[$1] = \"-1\"\n end\n elsif element =~ /(\\S+)--/\n if @@karma_db.has_key? $1\n if @@karma_db[$1] == \"1\"\n @@karma_db.delete $1 \n else\n @@karma_db[$1] = (@@karma_db[$1].to_i - 1).to_s\n end\n else\n @@karma_db[$1] = \"-1\"\n end\n end\n end\n\n end" ]
[ "0.70615005", "0.70514256", "0.6881012", "0.67374736", "0.6720277", "0.6688909", "0.6557013", "0.6502052", "0.6488873", "0.6480518", "0.64728826", "0.64721453", "0.639025", "0.63682127", "0.6363964", "0.63257253", "0.6307742", "0.6255738", "0.6215971", "0.621369", "0.60852164", "0.60852164", "0.60684496", "0.60482585", "0.6006212", "0.5895511", "0.5895511", "0.5895511", "0.5895511", "0.5895511", "0.5878928", "0.5842161", "0.58276945", "0.5798668", "0.578002", "0.57465684", "0.5745485", "0.56814176", "0.568126", "0.56698316", "0.5642728", "0.56200993", "0.56134796", "0.55936545", "0.55847096", "0.55847096", "0.5547933", "0.5519939", "0.54750425", "0.5474937", "0.5465189", "0.5440518", "0.53267777", "0.5322763", "0.5319339", "0.53052396", "0.52974355", "0.5280078", "0.5255234", "0.5253215", "0.5253215", "0.52523905", "0.5238559", "0.52321845", "0.52287674", "0.5177952", "0.51739144", "0.5170082", "0.5165309", "0.51647824", "0.51571286", "0.5150212", "0.514878", "0.5129462", "0.5120461", "0.5111454", "0.5097676", "0.50969744", "0.5089499", "0.5084422", "0.5080791", "0.5076445", "0.5068161", "0.50596434", "0.5034942", "0.5034942", "0.50304884", "0.5027466", "0.5025499", "0.5022355", "0.5021617", "0.50099593", "0.50062066", "0.50016314", "0.49992326", "0.4995664", "0.49937624", "0.49814263", "0.49802765", "0.49713328" ]
0.5635099
41
Clears the entire cache. Be careful with this method since it could affect other processes if shared cache is being used. When +use_flush+ option set to +true+ it will flush the bucket. Otherwise, it uses N1QL query and relies on default index.
def clear(use_flush: false, **_options) failsafe(:clear) do if use_flush cluster.buckets.flush_bucket(@couchbase_options[:bucket_name]) else operation_options = ::Couchbase::Options::Query.new operation_options.consistent_with(::Couchbase::MutationState.new(@last_mutation_token)) if @last_mutation_token cluster.query("DELETE FROM #{scope_qualifier}", operation_options) end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cache_clear\n @client.flushall\n end", "def clear\r\n @cache.flush\r\n end", "def clear\n @cache.clear\n end", "def clear\n cache.clear\n end", "def clearQueryCache\r\n result = request(\"DELETE\", \"_api/query-cache\")\r\n return return_delete(result)\r\n end", "def cache_clear\n @store.clear\n end", "def clear\n @cache.clear\n entries.clear\n self\n end", "def clear_cached\n Rails.cache.delete(self.cache_key, opts_for_cache)\n end", "def cache_clear\n @store.delete\n end", "def clear(options = nil)\n @client.flush_all\n rescue Spymemcached::Error => e\n logger.error(\"Spymemcached::Error (#{e}): #{e.message}\") if logger\n nil\n end", "def clear\n @cache.clear\n self\n end", "def clear_cache!\n # this should be overridden by concrete adapters\n end", "def clear\n @metadata = {}\n clear_cache\n end", "def cache_clear\n @dataset.delete\n end", "def cache_clear\n @dataset.delete\n end", "def clear\n @redis.del @options[:key_name]\n end", "def clear\n @redis.del @options[:key_name]\n end", "def clear!\n @cache = {}\n end", "def cache_clear\n @store.flush_all\n rescue ::MemCache::MemCacheError => e\n Log.error(e)\n nil\n end", "def clear\n @cache = {}\n end", "def clear\n @redis.flushdb\n end", "def memcache_flush\n memcache_key = self.singleton_class.get_memcache_key_object.key_template % {\n shard_identifier: self.singleton_class.shard_identifier,\n aml_search_uuid: aml_search_uuid\n }\n Memcache.delete(memcache_key)\n end", "def flush!\n unless @cache.empty?\n $stderr.puts \" FLUSHING CACHE!\"\n @cache.clear\n end\n self\n end", "def clear_cache\n Rails.cache.delete(self.class.cache_key(self.key))\n end", "def flush\n redis.del(bucket_key)\n end", "def clear\n # TODO: this is rather brutal, in future need to be able to revert\n Rails.logger.info(\"Clearing OpenbisMedataStore at #{filestore_path}\")\n # cache.delete_matched(/.*/)\n # need to add an entry to empty cache otherwise the clear failes on unexisting deak\n cache.fetch('fake') { '' } unless File.exist?(cache.cache_path)\n cache.clear\n end", "def clear_cache\n $redis.del self.id\n end", "def clear_cache\n $redis.del self.id\n end", "def clear_cache!\n @cache = {}\n end", "def clear_cache!\n @cache = {}\n end", "def clear_cache\n ccs.each(&:clear_cache)\n end", "def clear_cache\n @cache = {}\n end", "def clear_cache\n @all = nil\n end", "def clear_cache; end", "def clear!\n @cache.delete(current_store_id)\n end", "def memcache_flush\n ukcd_memcache_key = self.singleton_class.get_by_ued_memcache_key_object.key_template % {\n user_extended_detail_id: self.user_extended_detail_id,\n shard_identifier: self.singleton_class.shard_identifier\n }\n Memcache.delete(ukcd_memcache_key)\n end", "def clear!\n Goalkeeper.redis.del(key)\n end", "def purge_cache\n return unless self.respond_to? :tracked_cache_keys\n\n self.delete_from_cache(*self.tracked_cache_keys, after_commit: true)\n end", "def clear\n\n set_id_to_cache_key_map\n\n @id_to_cache_key_map.each do |_, keys|\n Memcache.delete(keys[:kit])\n Memcache.delete_from_all_instances(keys[:saas])\n end\n\n nil\n\n end", "def flush!\n @_cache = {}\n end", "def clear\n self.lock_acquire_time = nil\n\n redis.del(key)\n end", "def clear\n @fetch = nil\n reset_query\n self\n end", "def clear(_options = nil)\n # TODO: Support namespaces\n @client.delete_by_query index: @index_name, type: 'entry', body: { query: { match_all: {} } }\n end", "def clear_block_cache(table_name)\n @admin.clearBlockCache(org.apache.hadoop.hbase.TableName.valueOf(table_name)).toString\n end", "def clear_all!\n @cache = Cache.new\n end", "def clear\n @hash.del\n @index.del\n end", "def clear\n with_redis { |redis| redis.del(@set_key) }\n end", "def clear\n @fetch = nil\n @query = {}\n @query[:q] = []\n self\n end", "def clear\n @fetch = nil\n @query = {}\n @query[:q] = []\n self\n end", "def clear\n FileUtils.rm_f(cache_file)\n initialize!\n end", "def clear\n @redis.delete_matched(\"#{@key}:*\")\n end", "def memoize_cache_clear\n __memoize_cache__.clear\n self\n end", "def test_clear_also_clears_local_cache\n key = SecureRandom.uuid\n cache = lookup_store(raw: true)\n stub_called = false\n\n client(cache).stub(:flush_all, -> { stub_called = true; client.delete(\"#{@namespace}:#{key}\") }) do\n cache.with_local_cache do\n cache.write(key, SecureRandom.alphanumeric)\n cache.clear\n assert_nil cache.read(key)\n end\n assert_nil cache.read(key)\n end\n assert stub_called\n end", "def clear\n synchronize_block do\n @data.clear\n @key_access_store.clear\n end\n end", "def clear_item(**opt)\n cache_delete(**opt)\n end", "def clear_cache() @cache = {}; end", "def clear(options = nil)\n rescue_error_with(nil) { @data.with { |c| c.flush_all } }\n end", "def clear_cache!\n super\n # Make sure all query plans are *really* gone\n @connection.execute 'DEALLOCATE ALL' if active?\n end", "def clear\n return if check_locked\n @entries.clear\n self\n end", "def clear_cache\n if !block_given?\n @j_del.java_method(:clearCache, []).call()\n return self\n end\n raise ArgumentError, \"Invalid arguments when calling clear_cache()\"\n end", "def clear\n @redis.del @name\n end", "def clear(options = {})\n invoke(:clear, '*') do |store|\n if options[:async]\n store.flushdb(async: true)\n else\n store.flushdb\n end\n end\n end", "def reset\r\n @cache.reset\r\n end", "def clear\n instrument(:clear, nil, nil) do\n failsafe(:clear) do\n with(&:flushdb)\n end\n end\n end", "def clear_cache!(new_connection: false)\n if @statements\n @lock.synchronize do\n if new_connection\n @statements.reset\n else\n @statements.clear\n end\n end\n end\n end", "def clear\n if warning?\n warn(\"This operation can run for a very long time if the namespace contains lots of keys! \" +\n \"It should be used in tests, or when the namespace is small enough \" +\n \"and you are sure you know what you are doing.\")\n end\n\n batch_size = 1000\n\n if supports_scan?\n cursor = \"0\"\n begin\n cursor, keys = scan(cursor, count: batch_size)\n del(*keys) unless keys.empty?\n end until cursor == \"0\"\n else\n all_keys = keys(\"*\")\n all_keys.each_slice(batch_size) do |keys|\n del(*keys)\n end\n end\n end", "def clear_cache(uri)\n if last_cached(uri) > 0\n cache_store.delete(cache_key([uri, last_cached(uri)]))\n cache_store.delete(cache_key(uri))\n end\n end", "def clear(options = nil)\n @data.flushdb\n end", "def reset\n hash.clear\n expire_cache!\n self\n end", "def memcache_flush\n memcache_key = self.singleton_class.get_memcache_key_object.key_template % {\n shard_identifier: self.singleton_class.shard_identifier,\n user_kyc_detail_id: self.user_kyc_detail_id,\n user_extended_detail_id: self.user_extended_detail_id\n }\n Memcache.delete(memcache_key)\n end", "def clear\n\n set_id_to_cache_key_map\n\n cache_response = fetch\n @id_to_cache_key_map.each do |id, key|\n Memcache.delete(key)\n Memcache.delete(\"ca_sa_shared_de_sa_cs_#{cache_response[id][:api_key]}\")\n end\n\n nil\n\n end", "def flush(name=nil, *args)\n return if Rails.env == 'development'\n \n name = name.to_sym\n cache = Cacheable.cache[self]\n if name.nil?\n cache.each do |method, params|\n params.clear\n end\n elsif args.nil? || args.empty?\n cache[name].clear\n else\n cache[name].delete(args)\n end\n end", "def _clear_cache\n @cache_parent.clear\n end", "def cache_clear\n @moneta.clear\n end", "def clear_cache\n @access.refresh\n end", "def clear_cache\n @access.refresh\n end", "def clear_cache *keys\n keys.size == 0 ?\n cache_pool.clear :\n keys.each { |key| cache_pool.delete key }\n end", "def clear_cache\n\t\tprint \"Clearing cache...\"\n\t\turl = get_url(\"clear\", @uid, @password, @sid)\n\t\trun_1010(url, \"\") { puts \"done\" }\n\tend", "def memcache_flush\n client_memcache_key = ClientKycPassSetting.get_memcache_key_object.key_template % {client_id: self.client_id}\n Memcache.delete(client_memcache_key)\n end", "def clear_cache\n $redis.del \"posts\"\n end", "def clear_caches\n self.log.debug \"Clearing entry and values caches.\"\n\t\t@entry = nil\n\t\t@values.clear\n\tend", "def reset\n @entry_cache.clear\n end", "def clear_cache! *keys\n clear_cache *keys\n ipcm_trigger :clear_cache, *keys\n end", "def flush\n write_cache if @dirty\n @dirty = false\n end", "def clear_cache!\n @sorted = false\n end", "def clear_all_caches\n $CACHE.clear\n remove_cached_feeds\n remove_cached_list_of_taxon_concepts\n if ActionController::Base.cache_store.class == ActiveSupport::Cache::MemCacheStore\n ActionController::Base.cache_store.clear\n return true\n else\n return false\n end\n end", "def clear(opts = {}) \n save(setup_commit_options({:message => \"all clear\"}.merge(opts))) do |index|\n if tree = index.current_tree\n tree.contents.each do |entry|\n index.delete(key_for(entry.name))\n end\n end\n end\n end", "def clear(opts = {}) \n save(setup_commit_options({:message => \"all clear\"}.merge(opts))) do |index|\n if tree = index.current_tree\n tree.contents.each do |entry|\n index.delete(key_for(entry.name))\n end\n end\n end\n end", "def reset!\n redis_cmd do |redis|\n redis.del(key)\n end\n end", "def flush_memos\n CACHE.clear\n end", "def clear_cache\n @current_site.set_meta(cache_key, nil)\n end", "def clear!(resource)\n @cache.delete(resource)\n end", "def clear\n do_clear\n end", "def clear_cache\n @results = nil\n @result_ids = nil\n @num_results = nil\n @letters = nil\n end", "def clear(options=nil)\n instrument_with_log(:clear, 'flushing all keys') do\n with { |c| c.flush_all }\n end\n rescue Dalli::DalliError => e\n log_dalli_error(e)\n instrument_error(e) if instrument_errors?\n raise if raise_errors?\n nil\n end", "def clear(options = nil)\n @hash.destroy\n end", "def clear_cache_like! *keys\n clear_cache_like *keys\n ipcm_trigger :clear_cache_like, *keys\n end", "def reset!\n @cache = nil\n end", "def clear_cache\n Rails.cache.clear\n invoke_callbacks(:clear_cache, :after)\n head :no_content\n end", "def clear()\n merge(clear: 'true')\n end" ]
[ "0.7180498", "0.67801994", "0.6739185", "0.668363", "0.65690064", "0.65552306", "0.65313053", "0.6516901", "0.6507856", "0.6496872", "0.6467607", "0.64550734", "0.6424165", "0.6414535", "0.6414535", "0.641091", "0.641091", "0.6392268", "0.6362332", "0.6361445", "0.63609797", "0.6359642", "0.63338494", "0.6311248", "0.6310166", "0.62819576", "0.6262955", "0.6262955", "0.6249688", "0.6249688", "0.62406534", "0.62224793", "0.6188305", "0.6177404", "0.6145754", "0.6126417", "0.61234444", "0.6091973", "0.60709965", "0.6070685", "0.60575455", "0.60573125", "0.6044704", "0.60439384", "0.60354626", "0.6033228", "0.6030639", "0.60189515", "0.60189515", "0.6008356", "0.6007262", "0.59992754", "0.5985414", "0.5981378", "0.59799945", "0.59761536", "0.59721273", "0.5962084", "0.59492266", "0.5944353", "0.593741", "0.591695", "0.58991086", "0.5895471", "0.58786875", "0.5866689", "0.5862794", "0.5860904", "0.58576566", "0.58387595", "0.58193564", "0.5818292", "0.581803", "0.5817716", "0.58033085", "0.58033085", "0.57942533", "0.5790181", "0.577142", "0.5756863", "0.5754642", "0.5712279", "0.57111573", "0.57092875", "0.5706929", "0.5706843", "0.57064015", "0.57064015", "0.5702031", "0.5701163", "0.568793", "0.56820375", "0.5675647", "0.56723464", "0.56690687", "0.5664819", "0.56645", "0.56637794", "0.56591463", "0.5643384" ]
0.7751576
0
Reads an entry from the cache
def read_entry(key, **options) deserialize_entry(read_serialized_entry(key, **options), **options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read(key)\n @cache[key]\n end", "def cache_read(key)\n @mutex.synchronize do\n @cache[key]\n end\n end", "def read_entry(key, options) # :nodoc:\n deserialize_entry(@data.get(key))\n rescue => e\n logger.error(\"Error reading cache entry from redis: #{e}\") if logger\n nil\n end", "def read(key)\n return if @expires[key] && @expires[key] < Faulty.current_time\n\n @cache[key]\n end", "def read_entry(key, options)\n if cache = local_cache\n cache.fetch_entry(key) { super }\n else\n super\n end\n end", "def cache_read(key: cache_key, **)\n Rails.cache.read(key, namespace: namespace) if validate_key(key)\n end", "def read_entry(key, options) # :nodoc:\n entry = with { |c| c.get(key, options) }\n # NB Backwards data compatibility, to be removed at some point\n entry.is_a?(ActiveSupport::Cache::Entry) ? entry.value : entry\n rescue Dalli::DalliError => e\n log_dalli_error(e)\n instrument_error(e) if instrument_errors?\n raise if raise_errors?\n nil\n end", "def read(key)\n File.read(cache_path(key))\n rescue Errno::ENOENT\n nil\n end", "def [](key)\n File.read(cache_path(key))\n rescue Errno::ENOENT\n nil\n end", "def get(key)\n @cache[key]\n end", "def read_cache_file key\n f = File.open( cache_file(key), \"r\" )\n f.flock(File::LOCK_SH)\n out = f.read\n f.close\n return out\n end", "def find_cached_entry(key, name, options)\n instrument(:read, name, options) do |payload|\n payload[:super_operation] = :fetch if payload\n res = read_entry(key, options)\n payload[:hit] = !!res if payload\n res\n end\n end", "def read(key, _marshaling = true)\n Rails.cache.read(key)\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: read: K: #{key}. M: #{exc.message}, I: #{exc.inspect}\" }\n nil\n end", "def read(key, _marshaling = true)\n Rails.cache.read(key)\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: read: K: #{key}. M: #{exc.message}, I: #{exc.inspect}\" }\n nil\n end", "def get(key)\n # Return nothing if not in the cache or it has expired.\n return if key.nil?\n\n entry = @cache[key]\n return unless entry\n return if entry.expired?\n\n # Otherwise return the cached object.\n # We don't delete the cached entry because we might need to force its use if its expired and offline\n entry.object\n end", "def get(key)\n @cache[key]\n end", "def cache_get(key)\n data = @memcache.get(key)\n Merb.logger.info(\"cache: #{data.nil? ? \"miss\" : \"hit\"} (#{key})\")\n data\n end", "def cache_get(key)\n if @cache.key?(key)\n _data, _expire = *cache_read(key)\n if _expire.nil? || Time.now < _expire\n Merb.logger.info(\"cache: hit (#{key})\")\n return _data\n end\n @mutex.synchronize do @cache.delete(key) end\n end\n Merb.logger.info(\"cache: miss (#{key})\")\n nil\n end", "def read_from_cache\n result = if cache.is_a?(Proc)\n cache.call(nil)\n elsif File.exist?(cache.to_s)\n File.read(cache)\n end\n result if valid_rates?(result)\n end", "def [](entry)\n @cache[key_for(entry)]\n end", "def cache_get(ck)\n cache_op(:get, ck)\n end", "def cache_get(key)\n cache_file = @config[:cache_directory] / \"#{key}.cache\"\n if File.file?(cache_file)\n _data, _expire = Marshal.load(cache_read(cache_file))\n if _expire.nil? || Time.now < _expire\n Merb.logger.info(\"cache: hit (#{key})\")\n return _data\n end\n FileUtils.rm_f(cache_file)\n end\n Merb.logger.info(\"cache: miss (#{key})\")\n nil\n end", "def read_cache\n @cache_file = select_cache_file\n begin\n\topen(@cache_file, \"rb\") { |f| load_local_cache(f) } || {}\n rescue StandardError => ex\n\t{}\n end\n end", "def read_rl(key)\n $redis_cache_rl.get(key)\n rescue => exc\n @logger.error { \"REDIS-ERROR: read: K: #{key}. M: #{exc.message}, I: #{exc.inspect}\" }\n nil\n end", "def get(key, mtime)\n return nil unless @cache.key?(key)\n\n if @cache[key][:mtime] >= mtime\n @cache[key][:value]\n else\n delete(key)\n nil\n end\n end", "def cache_get(k)\n synchronize{@cache[k]}\n end", "def read_entry(key, options) # :nodoc:\n deserialize_entry(@client.get(key))\n rescue Spymemcached::Error => e\n logger.error(\"Spymemcached::Error (#{e}): #{e.message}\") if logger\n nil\n end", "def cache_fetch(key, expires_in:, &block)\n if ret = mload(key)\n ret\n else\n val = block.call\n mdump(key, val)\n expire(key, expires_in)\n val\n end\n end", "def get(resource, key)\n @cache[resource][key]\n end", "def [](key)\n\thash = hash(key)\n\n\tvalue = nil\n\tif File.exist?(File.join(@cache_dir, hash))\n\t value = ''\n\t File.open(File.join(@cache_dir, hash), 'rb') { |f|\n\t\tvalue += f.read\n\t }\n\tend\n\n\treturn value\n end", "def get(key)\n unless @store[key].present?\n path = path_for_key(key)\n if File.exists?(path)\n begin\n data = File.open(path, 'r') { |f| Marshal.load(f) }\n @store[key] = data\n rescue Exception => e\n Honeybadger.notify(\"Something went wrong reading RSSCache file from disk: #{path} #{e}\")\n end\n end\n end\n @store[key]\n end", "def cache_read(cache_file)\n _data = nil\n File.open(cache_file, \"r\") do |cache_data|\n cache_data.flock(File::LOCK_EX)\n _data = cache_data.read\n cache_data.flock(File::LOCK_UN)\n end\n _data\n end", "def lut_read_cache_item(lut_key, lut_item_key)\n prefix = lut_options(lut_key)[:prefix]\n\n Rails.cache.read(\"#{prefix}#{lut_key}/#{lut_item_key}\")\n end", "def get(key)\n return -1 unless @cache.key?(key)\n val = @cache[key]\n @cache.delete(key)\n @cache[key] = val\n val\n end", "def retrieve(key)\n raise NotImplementedError.new 'Implement retrieve(key) in your CacheManager'\n end", "def fetch(&block)\n Rails.cache.fetch(cache_key, &block)\n end", "def fetch_from_cache\n get_cache_object().get make_key\n end", "def fetch(name)\n load_cache(name)\n end", "def read(key, opts = {})\n opts.symbolize_keys!\n result = nil\n getMutex(key).synchronize do\n result = read_from_cache_or_cookies(key, opts) \n end \n return result\n end", "def [](key)\n data = @cache.get key\n Marshal.load Base64.decode64(data) if data\n end", "def read(cache_key)\n @pg.exec_prepared(@read_statement_name, [object_to_cache_key(cache_key)]) do |result|\n return nil unless result.ntuples.eql?(1)\n bytea_unmarshal(result.getvalue(0,0))\n end\n end", "def read\n @_cache ||= (value = read_value) ? serializer_class.load(read_value) : {}\n end", "def cached_fetch(key)\n fetch(key) do\n return yield unless h = self[:cache]\n Sequel.synchronize{return h[key] if h.has_key?(key)}\n value = yield\n Sequel.synchronize{h[key] = value}\n end\n end", "def read_entry(key, options) # :nodoc:\n @data.get(key, options)\n rescue ::Couchbase::Error::Base => e\n logger.error(\"#{e.class}: #{e.message}\") if logger\n raise if @raise_errors\n nil\n end", "def index(entry)\n @cache[entry]\n end", "def get(key = '')\n if key != '' && ::File.exists?(@cache_dir+key)\n # Is the File older than a day?\n if file_age(@cache_dir+key) > 1\n # Delete and return a cache miss\n File.delete(@cache_dir+key)\n return false\n end\n\n puts \"Reading from cache with key: #{key}\" if ENV['DEBUG']\n data = ::File.read(@cache_dir+key)\n return (data.length > 0) ? data : false\n end\n\n return false\n end", "def read_cache(url, json: true)\n filename = cache_filename(url, json)\n if File.exist?(filename)\n logger.debug(\"Reading cache #{filename}\")\n if json\n JSON.parse(IO.read(filename))\n else\n IO.read(filename)\n end\n end\n end", "def get_from_cache(cache_file, cache_ttl=5)\n if File.exists?(cache_file)\n now = Time.now\n file_mtime = File.mtime(cache_file)\n file_age = now - file_mtime\n if ((cache_ttl < 0) || (file_age <= cache_ttl))\n file = File.open(cache_file, \"r:UTF-8\")\n return file.read\n else\n # Return False if the cache is old\n return false\n end\n else\n # Return False if the cache file doesn't exist\n return false\n end\n end", "def fetch( key )\n key = key.to_s.strip unless key.nil?\n raise \"Invalid key\" if key.nil? or key == ''\n\n id,value,hits = @db.get_first_row(\n \"SELECT id,value,hits \"+\n \"FROM #{TABLE_NAME} \"+\n \"WHERE key=?\",\n key.to_s.strip\n )\n\n # Return nil if there is cache MISS.\n return nil if value.nil?\n \n # Increment the number of hits\n if @count_hits\n @db.execute(\n \"UPDATE #{TABLE_NAME} SET hits=?, updated_at=? WHERE id=?\",\n hits.to_i+1, Time.now.to_i, id\n )\n end\n\n # Otherwise if there is a HIT, parse the YAML into an object\n return YAML::load(value)\n end", "def cache_fetch(key, default = nil)\n # Retrieve the data and return it\n record = @store[:key => namespaced(key)]\n record.value rescue default\n end", "def read_cache_mtime key\n return nil unless File.exists?(cache_file(key))\n File.mtime( cache_file(key) )\n end", "def retrieve_from_cache\n retrieved = false\n return retrieved if @_cache_key.nil?\n\n data = Taupe::Cache.get(@_cache_key) || nil\n unless data.nil? || data.empty?\n @_values = data\n retrieved = true\n end\n\n retrieved\n end", "def read(cache_key)\n ::Gitlab::Redis::RateLimiting.with do |redis|\n redis.get(cache_key).to_i\n end\n end", "def force_get(key)\n # Return nothing if not in the cache or it has expired.\n return if key.nil?\n\n entry = @cache[key]\n return unless entry\n entry.object\n end", "def smart_fetch_from_cache(opts={}, &block)\n id = opts[:id]\n key = cache_key id\n force_write = opts[:force_write]\n expiration = self.expires_in\n Rails.logger.debug \"#{self.name} cache_key will be #{key}, expiration #{expiration}\"\n unless force_write\n entry = Rails.cache.read key\n if entry\n Rails.logger.debug \"#{self.name} Entry is already in cache: #{key}\"\n return (entry == NilClass) ? nil : entry\n end\n end\n wrapped_response = handling_exceptions(key, opts, &block)\n response = wrapped_response[:response]\n if wrapped_response[:exception]\n Rails.logger.debug \"#{self.name} Error occurred; writing entry to cache with short lifespan: #{key}\"\n expiration = Settings.cache.expiration.failure\n else\n Rails.logger.debug \"#{self.name} Writing entry to cache: #{key}\"\n end\n response = process_response_before_caching(response, opts)\n cached_entry = (response.nil?) ? NilClass : response\n Rails.cache.write(key,\n cached_entry,\n :expires_in => expiration,\n :force => true)\n response\n end", "def retrieve(*args)\n return @provider.retrieve(*args) if !@provider.nil?\n @cache[args]\n end", "def read_from_cache\n if config.cache.is_a?(Proc)\n config.cache.call(nil)\n elsif (config.cache.is_a?(String) || config.cache.is_a?(Pathname)) &&\n File.exist?(file_path)\n open(file_path).read\n end\n end", "def read_cache(obj, options = {})\n k = key(obj)\n\n ret = storage.get(k) || save_cache(obj)\n\n if options[:deserialized]\n serializer.deserialize(ret)\n else\n ret\n end\n end", "def read_entry(key, options)\n @hash[key]\n end", "def get(key)\n path = File.join(@root, \"#{key}.cache\")\n\n value = safe_open(path) do |f|\n begin\n EncodingUtils.unmarshaled_deflated(f.read, Zlib::MAX_WBITS)\n rescue Exception => e\n @logger.error do\n \"#{self.class}[#{path}] could not be unmarshaled: \" +\n \"#{e.class}: #{e.message}\"\n end\n nil\n end\n end\n\n if value\n FileUtils.touch(path)\n value\n end\n end", "def get(key)\n node = @cache[key]\n return -1 if node.nil?\n move_to_head(node)\n node.value\n end", "def get\n raise StandardError, \"Implement '.get' in your Cache!\"\n end", "def fetch(key, default = nil)\n return default unless entry = @cache[\"#{@cache_name}:#{key}\"]\n return entry[:value] if entry[:expires].nil? || entry[:expires] > Time.now\n @cache.delete(\"#{@cache_name}:#{key}\")\n default\n end", "def get_cache(key)\n treecache.fetch(key)\n end", "def retrieve (url)\n @semaphor.lock()\n if(@cache.has_key?(url))\n response = @cache[url].response\n @semaphor.unlock()\n update(url, response, Time.now())\n return response\n else\n @semaphor.unlock()\n return nil\n end\n \n end", "def fetch_from_cache(id=nil, force_write=false)\n key = cache_key id\n expiration = self.expires_in\n Rails.logger.debug \"#{self.name} cache_key will be #{key}, expiration #{expiration}, forced: #{force_write}\"\n value = Rails.cache.fetch(\n key,\n :expires_in => expiration,\n :force => force_write\n ) do\n if block_given?\n response = yield\n response = process_response_before_caching(response, {id: id, force_write: force_write})\n cached_entry = response.nil? ? NilClass : response\n cached_entry\n end\n end\n (value == NilClass) ? nil : value\n end", "def get\n Rails.cache.read(session_id, namespace: 'check-in-cache')\n end", "def get_cached_data(uri)\n Rails.cache.fetch(uri, {expires_in: 24.hours, raw: true}) { JSON.parse(RestClient::Resource.new(uri).get) }\n end", "def get!(key)\n record = object(key)\n return nil unless record\n record.rewrite_cache\n record.value\n end", "def get\n @cached_value ||= RedisModel::Base.connection.get(key_label)\n end", "def fetch(key, ttl = nil, req_options = nil)\n req_options = req_options.nil? ? CACHE_NILS : req_options.merge(CACHE_NILS) if cache_nils\n val = get(key, req_options)\n return val unless block_given? && not_found?(val)\n\n new_val = yield\n add(key, new_val, ttl_or_default(ttl), req_options)\n new_val\n end", "def read_cache\n @html = File.read(@cache_file) if cache_exist?\n parse_html unless @html.nil?\n end", "def read(path)\n entries[self.class.path(path)]\n end", "def load_cache\n q = @client.caches.get(:name=>name)\n @client.logger.debug \"GOT Q: \" + q.inspect\n @data = q.raw\n q\n end", "def cache_get(key)\n nil\n end", "def read(name)\n Oj.load(@redis.get(name))\n end", "def get(key, expires_in = 0, &block)\n\n #look for the cache item in the store\n items = @store.select { |i| i[:key] == build_key(key) }\n item = if !items.empty? then items[0] else nil end\n #check if a valid item was found in the store\n if item == nil || (item[:expires] != nil && item[:expires] <= Time.now.utc)\n #a valid item wasn't found so check if a hydration block was specified.\n if block_given?\n #create the item from the block\n value = yield\n #put the item in the store\n set(build_key(key), value, expires_in)\n return value\n else\n #no hydration block was specified\n\n #check if an expired item was found\n if item != nil\n #remove the expired item from the store\n remove(build_key(key))\n end\n return nil\n end\n end\n\n #return the item\n return item[:value]\n end", "def read_entry(key, options) # :nodoc:\n Marshal.load(@data.get(key))\n rescue => e\n logger.error(\"KyotoTycoonError (#{e}): #{e.message}\") if logger\n nil\n end", "def get_cached(args)\n cache_key = gen_cache_key(args)\n\n begin\n cached_val = MongoMapper::Document.redis.get(cache_key)\n rescue Exception\n cached_val = nil\n end\n\n unless cached_val\n res = where(args)\n result_count = res.count\n if result_count == 0\n return nil\n elsif result_count == 1\n cached_val = Octo::Utils.serialize(res.first)\n MongoMapper::Document.redis.setex(cache_key, get_ttl, cached_val)\n elsif result_count > 1\n cached_val = Octo::Utils.serialize(res)\n MongoMapper::Document.redis.setex(cache_key, get_ttl, cached_val)\n end\n end\n begin\n Octo::Utils.deserialize(cached_val)\n rescue Exception => e\n Octo.logger.error e\n nil\n end\n end", "def get(key, lifetime: 2**32, dirty: false, &block)\n if block_given?\n return @hash[key][:value] if (dirty || @dirty) && locked? && expired?(key) && @hash.key?(key)\n synchronized { calc(key, lifetime, &block) }\n else\n rec = @hash[key]\n if expired?(key)\n return rec[:value] if dirty || @dirty\n @hash.delete(key)\n rec = nil\n end\n raise 'The key is absent in the cache' if rec.nil?\n rec[:value]\n end\n end", "def get_item(**opt)\n cache_read(**opt) || default\n end", "def cached\n @cached ||= Rails.cache.read(self.cache_key, opts_for_cache)\n end", "def cache_fetch\n ver = current_version\n key = Loader.make_cache_key(self.user.id, self.album_type, ver)\n cache_man.logger.info(\"Fetching albums cache key: #{key}\")\n json = CacheWrapper.read(key)\n z = ZZ::ZZA.new\n if(json.nil?)\n cache_man.logger.info(\"Cache miss key: #{key}\")\n z.track_event(\"cache.miss.album\", key)\n else\n cache_man.logger.info(\"Cache hit key: #{key}\")\n z.track_event(\"cache.hit.album\", key)\n return json\n end\n\n return nil\n end", "def cache_get(key)\n @messages[key] if @messages.has_key?(key)\n end", "def get_data(key) \n filename = _find_file_key(key)\n return nil if filename.nil?\n file = File.open(@cache_dir + filename, \"rb\")\n contents = file.read\n return Marshal.load(contents)\n end", "def read_entry(key, options)\n query = Google::Cloud::Datastore::Key.new @datastore_kind_name, key\n entities = dataset.lookup query\n return nil unless entities.any?\n entity = entities.first\n entry = deserialize_entry( entity[:_value], entity[:_format] )\n return entry\n end", "def fetch(key, &block)\n result = cache.read(key) if should_cache?\n\n if result.nil?\n if block_given?\n ActiveRecord::Base.connection.with_master do\n result = yield\n end\n result = map_cached_nil_for(result)\n\n if should_cache?\n cache.write(key, result)\n end\n end\n logger.debug \"[IdentityCache] cache miss for #{key}\"\n else\n logger.debug \"[IdentityCache] cache hit for #{key}\"\n end\n\n unmap_cached_nil_for(result)\n end", "def get key\n if key.is_a? Array\n ret = {}\n key.each do |k|\n ret[k] = Marshal::load(read_cache_file(k)) unless expired?(k)\n end\n\n raise if ret.empty?\n return ret\n end\n\n raise if expired?(key)\n\n return Marshal::load(read_cache_file(key))\n rescue\n raise Diskcached::NotFound\n ensure\n flush_expired if gc_auto\n end", "def lookup(path)\n unless @cached.has_key?(path)\n @cached[path] = _lookup!(path)\n end\n return @cached[path]\n end", "def fetch(*key)\n @cache[key] ||= yield\n end", "def fetch (fei)\n\n @cache[fei.short_hash]\n end", "def cache_look(src, dst)\n #p 'cache'\n res = @redis.get redis_key(src, dst)\n res.to_f if res\n end", "def cache_get_pk(pk)\n cache[pk]\n end", "def cache_fetch(key, default = nil)\n nkey = namespaced(key)\n\n # Delete expired rows\n @dataset.select.filter(:key => nkey) do\n expires < Time.now\n end.delete\n\n # Get remaining row (if any)\n result = @dataset.select(:value).filter(:key => nkey).limit(1)\n\n if result.empty?\n return default\n else\n return deserialize(result.first[:value])\n end\n end", "def cache_fetch(key, default = nil)\n nkey = namespaced(key)\n\n # Delete expired rows\n @dataset.select.filter(:key => nkey) do\n expires < Time.now\n end.delete\n\n # Get remaining row (if any)\n result = @dataset.select(:value).filter(:key => nkey).limit(1)\n\n if result.empty?\n return default\n else\n return deserialize(result.first[:value])\n end\n end", "def fetch(key)\n result.fetch(key)\n end", "def cache_fetch(key, default = nil)\n value = @store[key]\n value.nil? ? default : value\n rescue ::MemCache::MemCacheError => e\n Log.error(e)\n nil\n end", "def read_cache_file\n return nil unless File.file? @cache_file\n\n cache = YAML.load_file(@cache_file)\n\n return nil unless cache.is_a? Hash\n return nil unless cache[:userid] == @userid\n\n @token = cache[:token]\n @prev_account_info = cache[:account_info]\n @remote_folders = cache[:remote_folders]\n @remote_contexts = cache[:remote_contexts]\n @last_sync = cache[:last_sync]\n end", "def [](string)\n return nil unless cache_on?\n\n @mutex.synchronize { @cache[string] }\n end", "def read(key, options = nil)\n key = key.join(':') if key.is_a?(Array)\n super\n @data.get(key, raw?(options))\n rescue MemCache::MemCacheError => e\n logger.error(\"MemCacheError (#{e}): #{e.message}\")\n nil\n end", "def getcached(url)\n _cached = instance_variable_get \"@cached_#{hashed(url)}\"\n return _cached unless _cached.nil?\n path = CACHE_FILE + \"#{hashed(url)}.json\"\n if File.exists?(path)\n File.open(path, \"r:UTF-8\") do |f|\n _cached = JSON.parse(f.read)\n instance_variable_set(\"@cached_#{hashed(url)}\", _cached)\n return _cached\n end \n end\n return nil\n end" ]
[ "0.82879543", "0.80549276", "0.77597314", "0.7743806", "0.7681336", "0.7637326", "0.76272464", "0.76076245", "0.7509261", "0.74261063", "0.7415713", "0.7410827", "0.7386746", "0.7386746", "0.7369477", "0.73349637", "0.7243369", "0.7207706", "0.7184428", "0.7182006", "0.71132183", "0.71109694", "0.7050218", "0.6975866", "0.69656515", "0.6948464", "0.6945015", "0.69166344", "0.6905484", "0.6905218", "0.688503", "0.68640083", "0.68589354", "0.6847672", "0.6842873", "0.684134", "0.6835196", "0.6791531", "0.6777056", "0.6752256", "0.6749738", "0.67458814", "0.6744019", "0.67215455", "0.6711735", "0.6706428", "0.6687439", "0.6682179", "0.6678213", "0.66632694", "0.6654961", "0.665075", "0.6635682", "0.6593026", "0.658402", "0.65825415", "0.6580284", "0.65685236", "0.65575296", "0.65445346", "0.65306145", "0.65280354", "0.65276057", "0.65264946", "0.6524132", "0.65042675", "0.65005004", "0.64878595", "0.6471862", "0.64665544", "0.64616525", "0.6451048", "0.6438968", "0.6429003", "0.642847", "0.64174014", "0.64123225", "0.6394253", "0.6389536", "0.63878125", "0.636012", "0.6344394", "0.6344027", "0.6342837", "0.63317645", "0.6329256", "0.6328631", "0.6323247", "0.6320993", "0.63168466", "0.631533", "0.63112324", "0.6310846", "0.6304227", "0.6304227", "0.62963223", "0.6283544", "0.6277157", "0.6276325", "0.6258323", "0.6257186" ]
0.0
-1
Reads multiple entries from the cache implementation. Subclasses MAY implement this method.
def read_multi_entries(names, **options) return {} if names.empty? keys = names.map { |name| normalize_key(name, options) } return_value = {} failsafe(:read_multi_entries, returning: return_value) do results = collection.get_multi(keys, ::Couchbase::Options::GetMulti(transcoder: nil)) results.each_with_index do |result, index| next unless result.success? entry = deserialize_entry(result.content, raw: options[:raw]) unless entry.nil? || entry.expired? || entry.mismatched?(normalize_version(names[index], options)) return_value[names[index]] = entry.value end end return_value end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_multi(*names)\n options = names.extract_options!\n return {} if names == []\n\n keys = names.map{|name| normalize_key(name, options)}\n args = [keys, options]\n args.flatten!\n\n instrument(:read_multi, names) do |payload|\n failsafe(:read_multi, returning: {}) do\n values = with { |c| c.mget(*args) }\n values.map! { |v| v.is_a?(ActiveSupport::Cache::Entry) ? v.value : v }\n\n Hash[names.zip(values)].reject{|k,v| v.nil?}.tap do |result|\n payload[:hits] = result.keys if payload\n end\n end\n end\n end", "def read_multi(keys, _marshaling = true)\n t_start = Time.now.to_f\n ret = Rails.cache.read_multi(*keys)\n Rails.logger.debug \"Memcache multi get took #{Time.now.to_f - t_start} s\"\n return ret\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: read_multi: K: #{keys}. M: #{exc.message}, I: #{exc.inspect}\" }\n return {}\n end", "def read_multi(*names)\n options = names.extract_options!\n mapping = names.inject({}) { |memo, name| memo[namespaced_key(name, options)] = name; memo }\n instrument_with_log(:read_multi, mapping.keys) do\n results = {}\n if local_cache\n mapping.each_key do |key|\n if value = local_cache.read_entry(key, options)\n results[key] = value\n end\n end\n end\n\n data = with { |c| c.get_multi(mapping.keys - results.keys) }\n results.merge!(data)\n results.inject({}) do |memo, (inner, _)|\n entry = results[inner]\n # NB Backwards data compatibility, to be removed at some point\n value = (entry.is_a?(ActiveSupport::Cache::Entry) ? entry.value : entry)\n memo[mapping[inner]] = value\n local_cache.write_entry(inner, value, options) if local_cache\n memo\n end\n end\n end", "def read_multi(names)\n @redis.mget(*names).map{|value| Oj.load(value)}\n end", "def get(keys)\n log(\"get :Cache, #{keys.inspect}\")\n connection.multi_get(:Cache, Array(keys)).values.map { |v| v['blob'] }\n end", "def all_fetched_entries\n @entry_cache.all_entries\n end", "def cache_read_multi(collection_serializer, adapter_instance, include_directive)\n return {} if ActiveModelSerializers.config.cache_store.blank?\n\n keys = object_cache_keys(collection_serializer, adapter_instance, include_directive)\n\n return {} if keys.blank?\n\n ActiveModelSerializers.config.cache_store.read_multi(*keys)\n end", "def read_multi_entries(names, **options)\n names.each_with_object({}) do |name, results|\n key = normalize_key(name, options)\n entry = read_entry(key, **options)\n\n next unless entry\n\n version = normalize_version(name, options)\n\n if entry.expired?\n delete_entry(key, **options)\n elsif !entry.mismatched?(version)\n results[name] = entry.value\n end\n end\n end", "def prefetch_multiple_keys(cache_keys)\n if controller.should_refresh_cache or !Rails.configuration.action_controller.perform_caching\n {}\n else\n Rails.cache.read_multi(cache_keys.collect { |key| timestamp_key(key[0],key[1]) })\n end\n end", "def get_multi(*keys)\n codes = @backend.get(keys)\n return [] if codes.empty?\n parser.decode_multi(codes.values)\n rescue ::Memcached::Error\n nil\n end", "def cache_read_multi(collection_serializer, adapter_instance, include_tree)\n return {} if ActiveModelSerializers.config.cache_store.blank?\n\n keys = object_cache_keys(collection_serializer, adapter_instance, include_tree)\n\n return {} if keys.blank?\n\n ActiveModelSerializers.config.cache_store.read_multi(*keys)\n end", "def read_multi(*names)\n options = names.extract_options!\n names = names.flatten.map{|name| expanded_key(name)}\n options[:assemble_hash] = true\n if options.delete(:raw)\n options[:format] = :plain\n end\n instrument(:read_multi, names, options) do\n @data.get(names, options)\n end\n rescue ::Couchbase::Error::Base => e\n logger.error(\"#{e.class}: #{e.message}\") if logger\n raise if @raise_errors\n false\n end", "def fetch_multi(*keys, &block)\n return {} if keys.size == 0\n result = {}\n result = cache.read_multi(*keys) if should_cache?\n\n missed_keys = keys - result.select {|key, value| value.present? }.keys\n\n if missed_keys.size > 0\n if block_given?\n replacement_results = nil\n ActiveRecord::Base.connection.with_master do\n replacement_results = yield missed_keys\n end\n missed_keys.zip(replacement_results) do |(key, replacement_result)|\n if should_cache?\n replacement_result = map_cached_nil_for(replacement_result )\n cache.write(key, replacement_result)\n logger.debug \"[IdentityCache] cache miss for #{key} (multi)\"\n end\n result[key] = replacement_result\n end\n end\n else\n result.keys.each do |key|\n logger.debug \"[IdentityCache] cache hit for #{key} (multi)\"\n end\n end\n\n result.keys.each do |key|\n result[key] = unmap_cached_nil_for(result[key])\n end\n\n result\n end", "def cache_read(key)\n @mutex.synchronize do\n @cache[key]\n end\n end", "def cache_read(key: cache_key, **)\n Rails.cache.read(key, namespace: namespace) if validate_key(key)\n end", "def read_multi(*names)\n @hash[*names]\n end", "def getCache\n keys = Rails.cache.instance_variable_get(:@data).keys\n data = [keys.length]\n\n #If a city parameter is detected and it matches data in the city field in the cache then \n #that city and its corresponding ip address and country are pushed onto the array\n if params[\"city\"]\n city = params[\"city\"]\n keys.each do |key|\n curr = Rails.cache.read(key)\n if curr[\"city\"] == city\n data.push(Rails.cache.read(key))\n end\n end\n #If a country parameter is detected and it matches data in the country field in the cache then \n #that country and its corresponding ip address and city are pushed onto the array\n elsif params[\"country\"]\n city = params[\"country\"]\n keys.each do |key|\n curr = Rails.cache.read(key)\n if curr[\"country\"] == city\n data.push(Rails.cache.read(key))\n end\n end\n #If no parameters are detected then push cache onto array\n else\n keys.each do |key|\n data.push(Rails.cache.read(key))\n end\n end\n\n @cache = data\n \n end", "def read_multi(*names)\n options = names.extract_options!\n options = merged_options(options)\n keys_to_names = Hash[names.map{|name| [namespaced_key(name, options), name]}]\n raw_values = @client.get_multi(keys_to_names.keys)\n values = {}\n raw_values.each do |key, value|\n entry = deserialize_entry(value)\n values[keys_to_names[key]] = entry.value unless entry.expired?\n end\n values\n end", "def getMany(*ks)\n\t \tself.ready\n self.evict(*ks) if @evictWhen[:get]\n self.instance_exec(ks, &@getMany)\n end", "def read_entry(key, options)\n if cache = local_cache\n cache.fetch_entry(key) { super }\n else\n super\n end\n end", "def fetch\n\n set_id_to_cache_key_map\n\n cache_keys_to_fetch = []\n @id_to_cache_key_map.each do |_, keys|\n cache_keys_to_fetch.push(keys[:kit])\n end\n\n data_from_cache = Memcache.read_multi(cache_keys_to_fetch)\n\n ids_for_cache_miss = []\n @ids.each do |id|\n ids_for_cache_miss << id if data_from_cache[@id_to_cache_key_map[id][:kit]].nil?\n end\n\n if ids_for_cache_miss.any?\n\n fetch_data_rsp = fetch_from_db(ids_for_cache_miss)\n\n data_to_set = fetch_data_rsp.data || {}\n\n # to ensure we do not always query DB for invalid ids being cached, we would set {} in cache against such ids\n @ids.each do |id|\n data_to_set[id] = {} if data_from_cache[@id_to_cache_key_map[id][:kit]].nil? && data_to_set[id].nil?\n end\n\n set_cache(data_to_set) if fetch_data_rsp.success?\n\n end\n\n @ids.inject({}) do |data, id|\n data[id] = data_from_cache[@id_to_cache_key_map[id][:kit]] || data_to_set[id]\n data\n end\n\n end", "def read\n super\n\n self.fetch\n\n self.items\n end", "def read_multi(*names)\n options = names.extract_options!\n options = merged_options(options)\n keys_to_names = Hash[names.map{|name| [namespaced_key(name, options), name]}]\n raw_values = @data.mget(keys_to_names.keys)\n values = {}\n raw_values.each do |key, value|\n entry = deserialize_entry(value)\n values[keys_to_names[key]] = entry.value unless entry.expired?\n end\n values\n end", "def fetch_multi(*ids)\n options = ids.extract_options!\n if IdentityCache.should_cache?\n\n require_if_necessary do\n cache_keys = ids.map {|id| rails_cache_key(id) }\n key_to_id_map = Hash[ cache_keys.zip(ids) ]\n\n objects_by_key = IdentityCache.fetch_multi(*key_to_id_map.keys) do |unresolved_keys|\n ids = unresolved_keys.map {|key| key_to_id_map[key] }\n records = find_batch(ids, options)\n records.compact.each(&:populate_association_caches)\n records\n end\n\n cache_keys.map {|key| objects_by_key[key] }.compact\n end\n\n else\n find_batch(ids, options)\n end\n end", "def read(key)\n @cache[key]\n end", "def read_cache\n @cache_file = select_cache_file\n begin\n\topen(@cache_file, \"rb\") { |f| load_local_cache(f) } || {}\n rescue StandardError => ex\n\t{}\n end\n end", "def cache_fetch(*args)\n super { |key| @store[key] }\n end", "def fetch_all(key); end", "def cache_content\n csv = CSV.parse(@cache.get, :headers => true)\n csv = csv.first # Only one line.\n\n # Clean-up\n csv = csv.map{|key, value| [key.strip, value.strip]}\n .delete_if{|key, _| key.empty?}\n\n date_entry, *quotations = *csv\n _, date = date_entry\n\n time = Time.parse(date + ' ' + self.class.new_rates_time_of_day_s(date))\n quotations.map!{|cur,rate| [cur, BigDecimal.new(rate)]}\n\n [time, quotations]\n rescue\n raise InvalidCacheError\n end", "def read_multi(*names)\n return {} if names.empty?\n\n options = names.extract_options!\n options = merged_options(options)\n\n instrument_multi :read_multi, names, options do |payload|\n read_multi_entries(names, **options, event: payload).tap do |results|\n payload[:hits] = results.keys\n end\n end\n end", "def entries\n Rails.cache.instance_variable_get(:@data).size\n end", "def get(*keys)\n unless keys.length == @num_keys\n arg_count = keys.length\n fail \"Opscode::Rackspace::Monitoring::CMCache.get: Key count mismatch (#{@num_keys}:#{arg_count})\"\n end\n\n unless defined?(@cache)\n return nil\n end\n\n eval_str = '@cache'\n (0...@num_keys).each do |i|\n key = keys[i]\n cval = eval(eval_str)\n unless cval.key?(key.to_s)\n return nil\n end\n\n eval_str += \"[\\\"#{key}\\\"]\"\n end\n\n Chef::Log.debug(\"Opscode::Rackspace::Monitoring::CMCache.get: Returning cached value from #{eval_str}\")\n return eval(eval_str)\n end", "def fetch(*key)\n @cache[key] ||= yield\n end", "def read(count = limit)\n docs = redis.lrange(name, 0, count - 1)\n docs.collect { |json| entry_from_json(json) }\n end", "def read_multi_entries(names, **options)\n keys_to_names = names.index_by { |name| normalize_key(name, options) }\n\n raw_values = @data.with { |c| c.get_multi(keys_to_names.keys) }\n values = {}\n\n raw_values.each do |key, value|\n entry = deserialize_entry(value, raw: options[:raw])\n\n unless entry.nil? || entry.expired? || entry.mismatched?(normalize_version(keys_to_names[key], options))\n values[keys_to_names[key]] = entry.value\n end\n end\n\n values\n end", "def get_set_memcached_multi(keys, ttl = 0, marshaling = true)\n raise 'block not given to get_set_memcached' unless block_given?\n\n Rails.cache.fetch_multi(*keys, {expires_in: get_ttl(ttl), raw: !marshaling}) do\n yield\n end\n\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: fetch_multi: K: #{keys.inspect}. M: #{exc.message}, I: #{exc.inspect}\" }\n nil\n end", "def [](entry)\n @cache[key_for(entry)]\n end", "def all\n @cache ||= Request.get('/data')\n\n end", "def fetch_multi(*keys)\n keys.flatten!(1)\n return {} if keys.empty?\n\n result = if should_use_cache?\n fetch_in_batches(keys.uniq) do |missed_keys|\n results = yield missed_keys\n results.map { |e| map_cached_nil_for(e) }\n end\n else\n results = yield keys\n Hash[keys.zip(results)]\n end\n\n result.each do |key, value|\n result[key] = unmap_cached_nil_for(value)\n end\n\n result\n end", "def cache\n rows.each(&:cache)\n end", "def fetch_multi(*names)\n options = names.extract_options!\n mapping = names.inject({}) { |memo, name| memo[namespaced_key(name, options)] = name; memo }\n\n instrument_with_log(:fetch_multi, mapping.keys) do\n with do |connection|\n results = connection.get_multi(mapping.keys)\n\n connection.multi do\n mapping.inject({}) do |memo, (expanded, name)|\n memo[name] = results[expanded]\n if memo[name].nil?\n value = yield(name)\n memo[name] = value\n options = options.merge(:connection => connection)\n write_entry(expanded, value, options)\n end\n\n memo\n end\n end\n end\n end\n end", "def each(mode = nil)\n mode = @default_caching_mode unless mode\n\n if mode != SCAN_DB_ONLY\n for key, value in @read_cache\n\t@write_cache[key] = value if mode == UPDATE\n\tyield key, value\n end\n end\n\n if mode != SCAN_CACHE_ONLY\n @db.each do |key, obj|\n\tnext unless mode == SCAN_DB_ONLY or @read_cache[key] == NULL\n\t@read_cache[key] = obj if mode == READ_CACHING\n\t@write_cache[key] = obj if mode == UPDATE\n\tyield key, obj\n end\n end\n end", "def fetch_entries\n entries.inject([]){ |all, entry| all << entry << addendas[entry] }.flatten.compact\n end", "def fetch_data(key_list)\n data = self\n key_list.each { |key| data = fetch_key_with_initialization(key, data) }\n data\n end", "def read(key, options = nil)\n key = key.join(':') if key.is_a?(Array)\n super\n @data.get(key, raw?(options))\n rescue MemCache::MemCacheError => e\n logger.error(\"MemCacheError (#{e}): #{e.message}\")\n nil\n end", "def multiget(keys)\n data = @client.get_multi(keys)\n keys.map { |k| Marshal.load data[k] }\n end", "def load_static_cache_rows\n if rows = Sequel.synchronize{@static_cache_cache[name]}\n rows.map{|row| call(row)}.freeze\n else\n rows = dataset.all.freeze\n raw_rows = rows.map(&:values)\n Sequel.synchronize{@static_cache_cache[name] = raw_rows}\n rows\n end\n end", "def fetch_multi(*ids)\n ensure_base_model\n raise_if_scoped\n raise NotImplementedError, \"fetching needs the primary index enabled\" unless primary_cache_index_enabled\n options = ids.extract_options!\n ids.flatten!(1)\n records = if IdentityCache.should_use_cache?\n require_if_necessary do\n cache_keys = ids.map {|id| rails_cache_key(id) }\n key_to_id_map = Hash[ cache_keys.zip(ids) ]\n key_to_record_map = {}\n\n coders_by_key = IdentityCache.fetch_multi(cache_keys) do |unresolved_keys|\n ids = unresolved_keys.map {|key| key_to_id_map[key] }\n records = find_batch(ids)\n key_to_record_map = records.compact.index_by{ |record| rails_cache_key(record.id) }\n records.map {|record| coder_from_record(record) }\n end\n\n cache_keys.map{ |key| key_to_record_map[key] || record_from_coder(coders_by_key[key]) }\n end\n else\n find_batch(ids)\n end\n records.compact!\n prefetch_associations(options[:includes], records) if options[:includes]\n records\n end", "def latest_entries\n unless @latest_entries\n @latest_entries = Rails.cache.fetch([@account.cache_key, '/latest_entries'], :expires_in => 10.minutes) do\n Entry.paginate(:all, :from => \"/accounts/#{@account.account_resource_id.to_s}/entries.xml\", :params => { :page => 1, :per_page => 5}) \n end\n end\n @latest_entries\n end", "def cached_data(list)\n @klass.where(object_key: list) if @klass\n end", "def fetch_values(*key_list, &block)\n if array_index?(key_list)\n key_list.map { |key| fetch(key, &block) }\n elsif block_given?\n __fetch_values__(*key_list) { |key| yield(key) }\n else\n __fetch_values__(*key_list)\n end\n end", "def read(entry); end", "def fetch(*args, &block)\n @values.fetch(*args, &block)\n end", "def retrieve(*args)\n return @provider.retrieve(*args) if !@provider.nil?\n @cache[args]\n end", "def entries\n MicroQ.redis do |r|\n r.lrange(QUEUES[:entries], 0, -1)\n end.collect(&MicroQ::Util.json_parse)\n end", "def fetch(key, page, page_size, record_klass, records_counter)\n page, page_size = process_page_params(page, page_size, record_klass)\n return [] if exceeds_max_pages?(page, page_size, records_counter)\n\n start, stop = get_range(page, page_size)\n rs = read_records(key, start, stop, record_klass)\n return rs if rs.present?\n\n if block_given?\n ActiveRecord::Base.with_advisory_lock(\"list/cache/#{key}/#{page}/#{page_size}\", timeout_seconds: 3) do\n rs = read_records(key, start, stop, record_klass)\n return rs if rs.present?\n\n records = yield\n return [] if records.blank?\n\n load_records(key, page, page_size, records, record_klass)\n end\n end\n end", "def fetch(*key)\n if block_given?\n @cache[key] ||= yield\n else\n @cache[key]\n end\n end", "def reads\n (1..read_count).to_a\n end", "def all_rows\n cache.all_rows\n end", "def build_cache\n []\n end", "def read_all(start = 0, size = -1)\n a = []\n size = count - start if size == -1\n result = rds.exists hpk_tag\n return a unless result and size > 0\n\n # read all nonces as list\n nonces = rds.hkeys hpk_tag\n limit = start+size <= nonces.length ? start + size : nonces.length\n\n # read all messages requested in atomic transaction\n res = runMbxTransaction(@hpk, 'read_all') do\n for i in (start...limit)\n rds.get msg_tag nonces[i]\n end\n end\n\n # decode each item from base64 and check for null values\n # left by expired messages\n res.each do |item|\n next unless item\n msg = parse item\n yield msg if block_given?\n a.push msg\n end\n return a\n end", "def cache_instances\n [*Pages.all_instances, *([BlogArticle, Industry, Team].map{|p| p.all })]\n end", "def read_entry(key, options) # :nodoc:\n entry = with { |c| c.get(key, options) }\n # NB Backwards data compatibility, to be removed at some point\n entry.is_a?(ActiveSupport::Cache::Entry) ? entry.value : entry\n rescue Dalli::DalliError => e\n log_dalli_error(e)\n instrument_error(e) if instrument_errors?\n raise if raise_errors?\n nil\n end", "def cache_all\n begin\n @mutex.synchronize do\n while ele = @enum.next\n @length_cache += 1\n @eles << ele\n end\n end\n rescue StopIteration\n @end = true\n end\n end", "def all(requested_by)\n key = cache_key(requested_by.party_refno)\n Rails.logger.debug { \"Getting cache data for #{key}\" }\n Rails.cache.fetch(key, expires_in: cache_expiry_time) do\n Rails.logger.debug { \"Cache miss for #{key}, fetching back office data\" }\n back_office_data(requested_by)\n end\n end", "def read_many(query)\n adapter.read_many(query)\n end", "def read_many(query)\n adapter.read_many(query)\n end", "def fetch_data(key)\n map { |om| om.fetch_data(key) }.flatten.compact\n end", "def entries\n load_client\n load_entries\n load_preferences\n end", "def read_entry(key, options) # :nodoc:\n deserialize_entry(@data.get(key))\n rescue => e\n logger.error(\"Error reading cache entry from redis: #{e}\") if logger\n nil\n end", "def cache_read(cache_file)\n _data = nil\n File.open(cache_file, \"r\") do |cache_data|\n cache_data.flock(File::LOCK_EX)\n _data = cache_data.read\n cache_data.flock(File::LOCK_UN)\n end\n _data\n end", "def read(path)\n entries[self.class.path(path)]\n end", "def list\n Enumerator.new do |y|\n @cache.each_value do |re|\n y << [re['address'], re['name']]\n end\n end\n end", "def index(entry)\n @cache[entry]\n end", "def batch_reads(client, key_prefix, bin_name,\tsize)\n # Batch gets into one call.\n keys = []\n (0...size).each do |i|\n keys << Key.new(Shared.namespace, Shared.set_name, key_prefix+(i+1).to_s)\n end\n\n records = client.batch_get(keys, [bin_name])\n\n\n (0...records.length).each do |i|\n key = keys[i]\n record = records[i]\n\n level = :err\n if record\n level = :info\n value = record.bins[bin_name]\n end\n\n log(level, \"Record: ns=#{key.namespace} set=#{key.set_name} key=#{key.user_key} bin=#{bin_name} value=#{value}\")\n end\n\n if records.length != size\n Shared.logger.fatal(\"Record size mismatch. Expected #{size}. Received #{records.length}.\")\n exit\n end\nend", "def read_cache(login)\n redis = Redis.new\n repos = redis.keys(\"#{login}:*/*\").map do |key|\n _, fullname = key.split(':', 2)\n begin\n { name: fullname, times: Marshal.load(redis.get(key)) }\n rescue ArgumentError, TypeError\n { name: fullname, times: nil }\n # TODO: Could we just next or nil here and then repos.compact! later?\n # Is there any case where we would serialize a nil object into redis?\n end\n end\n repos.reject! { |repo| repo[:times].nil? }\n repos.map! do |repo|\n { name: repo[:name],\n total: repo[:times].total_time,\n commits: repo[:times].commits,\n average: repo[:times].average_time\n }\n end\n repos.to_json\nend", "def get(file)\n binding.pry\n #return the values from cached first\n @cached[file] || \n @file_metadata[file] || \n read_metadata_from_yaml(file) || \n cache(file, read_metadata_from_disk(file)) \n end", "def read_cache_fixtures!\n files = cache_files\n files.each do |file|\n cache_key = get_cache_key_from_filename(file)\n responses[cache_key] = Marshal.load(File.read(file))\n end\n end", "def multi_zget(key, members)\n members = Array(members) unless members.is_a?(Array)\n mon_synchronize do\n perform [\"multi_zget\", key, *members], multi: true, proc: T_MAPINT, args: [members]\n end\n end", "def load_cache\n a = dataset.all\n h = {}\n a.each{|o| h[o.pk.freeze] = o.freeze}\n @all = a.freeze\n @cache = h.freeze\n end", "def get_specified_values(arr)\n @redis.read_multi(*arr, retain_nils: true)\n end", "def multi_zget(key, members)\n members = Array(members) unless members.is_a?(Array)\n mon_synchronize do\n perform [\"multi_zget\", key, *members], :multi => true, :proc => T_MAPINT, :args => [members]\n end\n end", "def entries\n @redis.keys('*')\n end", "def read_all(&block); end", "def retrieve(anns)\t\t\n\t\tresults = anns.collect do |ann|\n\t\t\tif @results_cache.include? ann[:requested_query]\n\t\t\t\tget_from_cache(ann[:requested_query], ann[:original_query], ann[:offset], ann[:sim])\n\t\t\telse\n\t\t\t\tsearch_db(ann[:requested_query], ann[:original_query], ann[:offset], ann[:sim])\n\t\t\tend\n\t\tend\n\t\tresults.reject { |ann| ann == [] }\n\t\tresults.flatten\n\tend", "def lut_read_cache_item(lut_key, lut_item_key)\n prefix = lut_options(lut_key)[:prefix]\n\n Rails.cache.read(\"#{prefix}#{lut_key}/#{lut_item_key}\")\n end", "def get_cached_data(uri)\n Rails.cache.fetch(uri, {expires_in: 24.hours, raw: true}) { JSON.parse(RestClient::Resource.new(uri).get) }\n end", "def fetch(*args)\n hash.fetch(*args)\n end", "def data_caches\n (@data_caches || [])\n end", "def get_by_ids(entry_ids)\n\t\t\tkparams = {}\n\t\t\t# Comma separated string of entry ids\n\t\t\tclient.add_param(kparams, 'entryIds', entry_ids);\n\t\t\tclient.queue_service_action_call('baseentry', 'getByIds', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend", "def [](row_number)\n if fully_cached?\n cache[row_number]\n else\n to_a[row_number]\n end\n end", "def fetch_from_db(cache_miss_ids)\n\n db_records = ::ClientAddress.where(\n client_id: cache_miss_ids, status: GlobalConstant::ClientAddress.active_status\n )\n\n aggregated_cache_data = {}\n\n db_records.each do |db_record|\n\n r = Aws::Kms.new('api_key','user').decrypt(db_record.address_salt)\n next unless r.success?\n\n r = LocalCipher.new(r.data[:plaintext]).decrypt(db_record.ethereum_address)\n next unless r.success?\n\n encrypt_rsp = encryptor_obj.encrypt(r.data[:plaintext])\n next unless encrypt_rsp.success?\n\n aggregated_cache_data[db_record.client_id] = {\n ethereum_address_e: encrypt_rsp.data[:ciphertext_blob],\n hashed_ethereum_address: db_record.hashed_ethereum_address\n }\n\n end\n\n success_with_data(aggregated_cache_data)\n\n end", "def retrieve(key)\n raise NotImplementedError.new 'Implement retrieve(key) in your CacheManager'\n end", "def read_cache_file key\n f = File.open( cache_file(key), \"r\" )\n f.flock(File::LOCK_SH)\n out = f.read\n f.close\n return out\n end", "def all\n response = run\n\n while continue?(response)\n @options[:exclusive_start_key] = response.last_evaluated_key\n response = run(response)\n end\n\n @collection.deserialize(response.entities)\n end", "def fetch_hash_all\n fetch_many0(nil, Hash)\n end", "def read_from_cache\n result = if cache.is_a?(Proc)\n cache.call(nil)\n elsif File.exist?(cache.to_s)\n File.read(cache)\n end\n result if valid_rates?(result)\n end", "def [](*args)\n args = args.first if (args.size == 1)\n return super(args) if args.is_a?(Hash)\n ck = cache_key(args)\n if obj = @cache_store.get(ck)\n return obj\n end\n if obj = super(args)\n @cache_store.set(ck, obj, @cache_ttl)\n end \n obj\n end", "def find_cached_entry(key, name, options)\n instrument(:read, name, options) do |payload|\n payload[:super_operation] = :fetch if payload\n res = read_entry(key, options)\n payload[:hit] = !!res if payload\n res\n end\n end", "def read_many(query)\n Collection.new(query) do |set|\n read(query, set, true)\n end\n end" ]
[ "0.72037786", "0.71382344", "0.70031166", "0.67433906", "0.6733432", "0.63727015", "0.63149184", "0.6310927", "0.6240829", "0.62241054", "0.6194542", "0.6142272", "0.6059888", "0.6029876", "0.59996563", "0.59968984", "0.5987757", "0.5987068", "0.5980668", "0.5945351", "0.5926162", "0.5912602", "0.5878025", "0.5876467", "0.58701277", "0.58622754", "0.5851352", "0.58393204", "0.58286726", "0.5821503", "0.58207", "0.5819909", "0.57897925", "0.57706827", "0.5755051", "0.57531506", "0.5747488", "0.5747076", "0.5725574", "0.568094", "0.568042", "0.5680223", "0.56783074", "0.5672701", "0.565935", "0.56517804", "0.5650855", "0.563447", "0.562979", "0.56293404", "0.5617619", "0.5615927", "0.5614767", "0.5612635", "0.5587389", "0.55546916", "0.55542254", "0.554723", "0.55201656", "0.550319", "0.5499999", "0.54888743", "0.54836875", "0.5467263", "0.5466804", "0.5464953", "0.5464953", "0.5452196", "0.5452003", "0.54515076", "0.54483706", "0.5445287", "0.54389817", "0.5428153", "0.5423556", "0.54099417", "0.54095113", "0.54011506", "0.54006416", "0.53992057", "0.53930694", "0.5386849", "0.5380577", "0.53682375", "0.5356925", "0.535265", "0.5328216", "0.5326792", "0.5322789", "0.5321494", "0.53213656", "0.5319829", "0.5318715", "0.53162587", "0.53129065", "0.53092235", "0.53072697", "0.53049564", "0.5302291", "0.53014666" ]
0.60689557
12
Writes an entry to the cache
def write_entry(key, entry, raw: false, **options) write_serialized_entry(key, serialize_entry(entry, raw: raw, **options), raw: raw, **options) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_entry(key, entry, options) # :nodoc:\n value = serialize_entry(entry)\n if (options && options[:expires_in])\n expires_in = options[:expires_in].to_i\n response = @data.setex(key, expires_in, value)\n else\n response = @data.set(key, value)\n end\n rescue => e\n logger.error(\"Error writing cache entry to redis: #{e}\") if logger\n false\n end", "def write(key, value)\n @cache[key] = value\n end", "def write_entry(key, entry, options = nil)\n method = (options && options[:unless_exist]) ? :add : :set\n value = options[:raw] ? entry.value.to_s : entry\n @cache.send(method, key, value, expires_in(options), marshal?(options))\n true\n rescue Memcached::Error => e\n log_error(e)\n raise\n end", "def write_entry(key, entry, options = nil)\n method = (options && options[:unless_exist]) ? :add : :set\n value = options[:raw] ? entry.value.to_s : entry\n\n @cache.send(method, key, value, expires_in(options), marshal?(options))\n true\n rescue Memcached::Error => e\n log_error(e)\n false\n end", "def cache_write(value, key: cache_key, **)\n Rails.cache.write(key, value, namespace: namespace) if validate_key(key)\n end", "def cache_write(key, data)\n @mutex.synchronize do\n @cache[key] = data\n end\n end", "def write_entry(key, entry, options) # :nodoc:\n method = options && options[:unless_exist] ? :add : :set\n expires_in = options[:expires_in].to_i\n expires_in = nil if expires_in == 0\n entry = Marshal.dump(entry)\n @data.send(method, key, entry, expires_in)\n rescue => e\n logger.error(\"KyotoTycoonError (#{e}): #{e.message}\") if logger\n false\n end", "def write_entry(key, entry, options) # :nodoc:\n method = options && options[:unless_exist] ? :add : :set\n value = options[:raw] ? entry.value.to_s : entry\n expires_in = options[:expires_in].to_i\n if expires_in > 0 && !options[:raw]\n # Set the memcache expire a few minutes in the future to support race condition ttls on read\n expires_in += 5.minutes\n end\n @client.send(method, key, value, expires_in, options)\n rescue Spymemcached::Error => e\n logger.error(\"Spymemcached::Error (#{e}): #{e.message}\") if logger\n false\n end", "def write(key, value, expires_in: nil)\n @cache[key] = value\n @expires[key] = Faulty.current_time + expires_in unless expires_in.nil?\n end", "def put(namespace, key, entry)\n @lock.synchronize do\n now = Time.now.utc.to_i\n prune_expired(now)\n @entries[full_key(namespace, key)] = entry\n prune_size\n end\n end", "def write(key, value, ttl = 0, marshaling = true)\n Rails.cache.write(key, value, {expires_in: get_ttl(ttl), raw: !marshaling})\n nil\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: write: K: #{key}. M: #{exc.message}, I: #{exc.inspect}\" }\n nil\n end", "def write_entry(key, value, options) # :nodoc:\n method = if options[:unless_exists] || options[:unless_exist]\n :add\n else\n :set\n end\n if ttl = options.delete(:expires_in)\n options[:ttl] ||= ttl\n end\n @data.send(method, key, value, options)\n rescue ::Couchbase::Error::Base => e\n logger.error(\"#{e.class}: #{e.message}\") if logger\n raise if @raise_errors\n false\n end", "def write_entry(key, value, options) # :nodoc:\n # cleanup LocalCache\n cleanup if options[:unless_exist]\n method = options[:unless_exist] ? :add : :set\n expires_in = options[:expires_in]\n connection = options.delete(:connection)\n connection.send(method, key, value, expires_in, options)\n rescue Dalli::DalliError => e\n log_dalli_error(e)\n instrument_error(e) if instrument_errors?\n raise if raise_errors?\n false\n end", "def write_cache\n data = cache_data\n open(writable_file, \"wb\") do |f|\n\tf.puts Marshal.dump(data)\n end\n end", "def write(key, value, opts = {})\n _key = Digest::SHA1.hexdigest key\n ttl = opts[:ttl] || @default_ttl\n \n # We don't want to cache errors\n return if value.is_a?(Faraday::Response) && !value.success?\n\n if (value.is_a?(Faraday::Response) && !value.headers['expires'].nil?)\n resp_ttl = DateTime.parse(value.headers['expires']).to_time.to_i - Time.now.to_i\n ttl = resp_ttl if resp_ttl > 0\n end\n\n _value = Marshal.dump value\n\n @memory_store[_key] = value\n $LOG.debug \"Writing to JDG cache hashed #{_key} for #{key}\"\n @conn.put do |req|\n req.url \"/rest/jbossdeveloper/#{@profile}_#{_key}\"\n req.headers['Content-Type'] = opts[:content_type] || 'application/ruby+object'\n req.headers['timeToLiveSeconds'] = ttl.to_s # need to see if we're actually a request and full from that\n req.body = _value\n end\n end", "def write_entry(key, entry, options)\n value, format = serialize_entry( entry )\n obj = dataset.entity @datastore_kind_name, key do |t|\n t[\"_expires\"] = entry.expires_at\n t[\"_format\"] = format\n t[\"_value\"] = value\n t[\"_json\"] = entry.to_json unless Rails.env.production? || entry.to_json.size >= 1500\n end\n dataset.save obj\n return true\n rescue Exception => e\n return false\n end", "def write\n return unless Dir.exist?(File.dirname(cache_file))\n @cache[\"version\"] = VERSION\n File.open(cache_file, \"w\") do |fh|\n fh.puts(JSON.dump(@cache))\n end\n end", "def write(entry)\n data = entry_as_json(entry)\n json = MultiJson.dump(data)\n redis.multi do |transaction|\n transaction.lpush(name, json)\n transaction.ltrim(name, 0, limit - 1)\n transaction.expire(name, ttl) if ttl && ttl > 0\n end\n end", "def save(key, value)\n return if @capacity <= 0\n\n @cache_mutex.synchronize do\n @map.delete(key) if @map.key?(key)\n\n @map[key] = CacheElement.new(value)\n\n @map.delete(@map.first[0]) if @map.size > @capacity\n nil\n end\n end", "def write_entry(key, entry, options)\n if options && options[:unless_exist]\n @hash.add(key, entry)\n else\n @hash[key] = entry\n end\n end", "def write(entry)\n @entry_buffer << entry\n\n # Write buffer to disk every 10 entries or 300 seconds\n if @entry_buffer.length >= 10 || (Time.now.to_i - @last_write) > 300\n # Write buffer\n write_buffer\n\n # Clear buffer\n @entry_buffer = []\n @last_write = Time.now.to_i\n end\n end", "def put(key = '', data = '')\n if key != '' && data != ''\n puts \"Writing into cache with key: #{key}\" if ENV['DEBUG']\n return ::File.write(@cache_dir+key, data)\n end\n\n return false\n end", "def write_cache_file key, content\n f = File.open( cache_file(key), \"w+\" )\n f.flock(File::LOCK_EX)\n f.write( content )\n f.close\n return content\n end", "def store(request, response)\n return unless response.cachable?\n\n entries = cache_entries_for(request)\n entries[request] = response\n\n @memcache[request.to_mc_key] = entries\n end", "def put(key, object, ttl = nil)\n @cache[key] = CacheEntry.new(object, ttl) unless key.nil? || object.nil?\n end", "def write_cache\n File.write(CACHE_PATH, @data.to_json)\n end", "def write(key, value, options = nil)\r\n super\r\n method = (options && options[:unless_exist]) ? :add : :set\r\n @cache.send(method, valid_key(key), value, expires_in(options), marshal?(options))\r\n true\r\n rescue Memcached::Error => e\r\n log_error(e)\r\n false\r\n end", "def write(request, response)\n key = cache_key_for(request)\n value = @serializer.dump(response.serializable_hash)\n @cache.write(key, value)\n end", "def write_entry(key, entry, **options)\n write_serialized_entry(key, serialize_entry(entry, **options), **options)\n end", "def put(key, value)\n if @table[key].nil?\n insert_into_cache(key, value)\n else\n update_cache(key, value)\n end\n end", "def put(namespace, key, entry); end", "def store(value, *key)\n @cache[key] = value\n end", "def _write(key, value, options = nil)\n method = options && options[:unless_exist] ? :add : :set\n response = @data.send(method, key, value, expires_in(options), raw?(options))\n return true if response.nil?\n response == Response::STORED\n rescue MemCache::MemCacheError => e\n logger.error(\"MemCacheError (#{e}): #{e.message}\")\n false\n end", "def cached_set(key, value)\n return unless h = self[:cache]\n Sequel.synchronize{h[key] = value}\n end", "def []=(entry, index)\n if valid?(entry)\n @cache[key_for(entry)] = index\n end\n end", "def write_entry(key, entry, options) # :nodoc:\n cleanup(@max_cleanup_time)\n\n method = exist?(key) ? :update : :insert\n\n @data.send(method, {key: key, value: Marshal.dump(entry)})\n true\n rescue Sequel::Error => e\n logger.error(\"Sequel::Error (#{e}): #{e.message}\") if logger\n false\n end", "def write_entry(key, entry, **options)\n raise NotImplementedError.new\n end", "def write(entry)\n raise NotImplementedError\n end", "def write(entry)\n raise NotImplementedError\n end", "def write_cache(resource, content)\n expanded_path = cache_path_for(resource)\n return false unless expanded_path\n FileUtils.mkdir_p(File.dirname(expanded_path))\n @logger.info(self.class) { \"Caching #{content.length} B for #{resource}\" }\n File.write(expanded_path, content)\n end", "def index(entry)\n @cache[entry]\n end", "def <<(entry)\n if index = @cache[entry]\n entries[index] = entry\n else\n @cache[entry] = size\n entries << entry\n end\n self\n end", "def update (url, response, timestamp)\n \n @semaphor.synchronize(){||\n if @cache.has_key?(url)\n # then this url is already in the cache and we simply update the timestamp\n new_entry = CacheEntry.new(url, response, timestamp)\n @cache[url] = new_entry\n else\n new_entry = CacheEntry.new(url, response, timestamp)\n # ensure that this object is not too large\n return if new_entry.response.bytesize() > max_object_size \n # remove items from the cache until this new entry fits.\n while @current_load + new_entry.response.bytesize() > max_load do\n evict()\n end\n @current_load = @current_load + new_entry.response.bytesize()\n @cache[url] = new_entry\n end\n }\n end", "def write(key, value, options = {})\n entry = ::Elephas::Entry.ensure(value, key, options)\n entry.refresh\n @data[key] = entry\n entry\n end", "def put(key, value)\n return if @capacity.zero?\n @cache.delete(key)\n @cache.shift while @cache.size >= @capacity\n @cache[key] = value\n end", "def set key, value\n begin\n write_cache_file( key, Marshal::dump(value) )\n flush_expired if gc_auto\n return true\n rescue\n flush_expired if gc_auto\n return false\n end\n end", "def []=(key, entry)\n key = key_for(key) unless valid_key?(key)\n @hash[key] = entry if key\n end", "def cache_write(cache_file, data)\n File.open(cache_file, \"w+\") do |cache_data|\n cache_data.flock(File::LOCK_EX)\n cache_data.write(data)\n cache_data.flock(File::LOCK_UN)\n end\n true\n end", "def write(cache_key, env, response)\n payload = Payload.from_response(response).tap do\n _1.comment = \"#{env.method.upcase} #{env.url}\"\n end\n cache.write(cache_key, payload)\n end", "def write\n File.write(cache_file, @cache_log.to_json)\n end", "def write_cache_file\n open(@cache_file, 'w') do |f|\n f.puts({ \n :userid => @userid,\n :token => @token,\n :account_info => @account_info,\n :remote_folders => @remote_folders,\n :remote_contexts => @remote_contexts,\n :last_sync => Time.now.to_i ,\n }.to_yaml)\n end\n end", "def cache(key, value)\n @cache[key] = value\n end", "def write(key, value)\n key.freeze if key.is_a? String\n\n @memory_store[key] = value\n @file_store.transaction do\n @file_store[key] = value\n end\n end", "def store(key, contents)\n raise NotImplementedError.new 'Implement store(key, contents) in your CacheManager'\n end", "def set(key, value)\n path = File.join(@root, \"#{key}.cache\")\n\n # Ensure directory exists\n FileUtils.mkdir_p File.dirname(path)\n\n # Check if cache exists before writing\n exists = File.exist?(path)\n\n # Serialize value\n marshaled = Marshal.dump(value)\n\n # Compress if larger than 4KB\n if marshaled.bytesize > 4 * 1024\n deflater = Zlib::Deflate.new(\n Zlib::BEST_COMPRESSION,\n Zlib::MAX_WBITS,\n Zlib::MAX_MEM_LEVEL,\n Zlib::DEFAULT_STRATEGY\n )\n deflater << marshaled\n raw = deflater.finish\n else\n raw = marshaled\n end\n\n # Write data\n PathUtils.atomic_write(path) do |f|\n f.write(raw)\n @size = size + f.size unless exists\n end\n\n # GC if necessary\n gc! if size > @max_size\n\n value\n end", "def write_cache(url, data, json: true)\n filename = cache_filename(url, json)\n logger.debug(\"Writing cache #{filename}\")\n FileUtils.mkdir_p(File.dirname(filename))\n if json\n IO.write(filename, JSON.dump(data))\n else\n IO.binwrite(filename, data)\n end\n end", "def set(key, value, mtime)\n @cache[key] = {\n value: value,\n mtime: mtime\n }\n end", "def cache(gist, file, data)\n cache_file = get_cache_file_for gist, file\n File.open(cache_file, \"w\") do |io|\n io.write data\n end\n end", "def write_rl(key, value)\n $redis_cache_rl.set(key, value)\n $redis_cache_rl.expire(key, 24.hours.to_i) if value == 1\n true\n rescue => exc\n @logger.error { \"REDIS-ERROR: write: K: #{key}. M: #{exc.message}, I: #{exc.inspect}\" }\n nil\n end", "def save(key, maybe_param, blob, etag)\n $logger.debug(\"Cache write: #{key},#{maybe_param}\")\n filename = args_to_filename(key, maybe_param)\n FileUtils.mkdir_p(File.dirname(filename))\n IO::write(filename, blob)\n IO::write(\"#{filename}.etag\", etag)\n end", "def write(key, content)\n temp_file = File.join(root, ['tmp', $$, Thread.current.unique_id].join('-'))\n File.open(temp_file, 'wb') do |dest|\n if content.respond_to? :to_str\n dest.write(content.to_str)\n else\n content.each {|s| dest.write(s) }\n end\n end\n\n path = cache_path(key)\n if File.exist?(path)\n File.unlink temp_file\n else\n FileUtils.mkdir_p File.dirname(path), :mode => 0755\n FileUtils.mv temp_file, path\n end\n true\n rescue\n File.unlink temp_file rescue false\n false\n end", "def write(key, value, options = nil)\n super\n method = options && options[:unless_exist] ? :add : :set\n # memcache-client will break the connection if you send it an integer\n # in raw mode, so we convert it to a string to be sure it continues working.\n value = value.to_s if raw?(options)\n response = @data.send(method, key, value, expires_in(options), raw?(options))\n response == Response::STORED\n rescue MemCache::MemCacheError => e\n logger.error(\"MemCacheError (#{e}): #{e.message}\")\n false\n end", "def put(key, value); end", "def cache(uri, obj)\n filename=cacheFileName(uri)\n print(\"Creating #{filename}\\n\")\n File.open(filename, 'w') {|f| f.write(obj) }\nend", "def update_cache(ticket, cache)\n cache[ticket[:spacekey]] = ticket[:id] if seen?(ticket, cache)\n cache\n end", "def _store(*key_elements, value)\n cache.put(_key(*key_elements), value)\n end", "def write_cache(cache, path)\n if @use_cache then\n File.open path, \"wb\" do |cache_file|\n Marshal.dump cache, cache_file\n end\n end\n\n cache\n rescue Errno::EISDIR # HACK toplevel, replace with main\n cache\n end", "def set(key, value)\n @cache[key] = value\n end", "def add(value)\n ensure_cache_path_created\n FileUtils.touch(File.join(cache_path, value))\n end", "def [](entry)\n @cache[key_for(entry)]\n end", "def cache(name, value)\n @cache = {} if @cache.nil?\n @cache[name] = value\n end", "def put(key, value)\n return if @cap <= 0\n fav = @c[key]\n if fav\n return\n end\n \n end", "def cache_set(k, v)\n synchronize{@cache[k] = v}\n end", "def write(key, value)\n perform_update(:write, key, value.to_s)\n end", "def put(cache_method, value)\n cache.send(\"#{cache_method}=\", value)\n end", "def put(key, value)\n node = @cache[key]\n if node.nil?\n if(@size >= @capacity)\n tail = pop_tail()\n @cache.delete(tail.key)\n @size -= 1\n end\n newNode = DLinkedNode.new\n newNode.key = key\n newNode.value = value\n \n @cache[key] = newNode\n add_node(newNode)\n \n @size += 1\n else\n node.value = value\n move_to_head(node)\n end\n end", "def lut_write_to_cache(lut_key)\n if lut_options(lut_key)[:sql_mode]\n count = lut_write_to_cache_sql_mode(lut_key)\n else\n count = lut_write_to_cache_no_sql_mode(lut_key)\n end\n\n # HACK: Writing a \\0 to terminate batch_items\n lut_write_cache_item(lut_key, count, nil)\n end", "def put(key, value)\n \treturn if @capacity.zero?\n if @cache.key?(key) || !@cache.key?(key) && @cache.size < @capacity\n @cache[key] = value\n @frequency[key] += 1\n i = @frequency[key]\n if i == 1 # a new item\n @rentused[1] = { key => nil } if @rentused[1].nil?\n @rentused[1][key] = nil\n else\n @rentused[i - 1].delete(key)\n @rentused[i] = { key => nil } if @rentused[i].nil?\n @rentused[i][key] = nil\n end\n else\n 1.upto(100).each do |i|\n next unless !@rentused[i].nil? && !@rentused[i].empty?\n k = @rentused[i].keys.first\n @cache.delete(k)\n @frequency.delete(k)\n @rentused[i].delete(k)\n break\n end\n @cache[key] = value\n @frequency[key] = 1\n @rentused[1] = { key => nil } if @rentused[1].nil?\n @rentused[1][key] = nil\n # p @cache, @frequency, @rentused\n end\n end", "def cache(named_key, ttl, object)\n @mutex.synchronize {\n self[named_key] = object\n @timestamps[named_key][:ttl] = ttl\n @timestamps[named_key][:expire_type] = :created\n @timestamps[named_key][:is_cache] = true\n } \n end", "def write(name, value, options = nil)\n # check :unless_exist option\n return nil if options && options[:unless_exist] && exist?(name)\n\n # create wrapper with expiry data\n wrapper = if options && options[:expires_in]\n { :value => value, :expires_at => expires_in(options).from_now }\n else\n { :value => value }\n end\n\n # call ActiveSupport::Cache::MemoryStore#write\n super(name, wrapper, options)\n end", "def set_cache\n cache_key = self.class.cache_key(self.key)\n Rails.cache.write(cache_key, self.actual_value)\n end", "def update_cache(type, id, data)\n end", "def update_cache(type, id, data)\n end", "def set(data)\n data = data.to_json\n cache_key = Digest::SHA1.hexdigest(data)\n\n log(\"insert :Cache, #{cache_key} -> {'blob' => #{data.inspect}}\")\n connection.insert(:Cache, cache_key, { \"blob\" => data })\n cache_key\n end", "def update_cache\n Rails.logger.debug \"Updating cache for... #{@@cache_file}\"\n fp = File.new(@@cache_file, 'w')\n if fp\n # acquire an exclusive lock (writer)\n if fp.flock(File::LOCK_EX)\n content = open(@@file_path).read\n \n if content\n #logger.debug \"Generate cache file: #{@@cache_file}\"\n fp.write(content) # writes to the file\n end\n \n fp.flock(File::LOCK_UN) # release a lock\n end\n fp.close\n end\n end", "def write_entry(index_file, entry, journal, data)\n curr = self.size - 1\n \n node_map[entry.last] = curr\n \n link = entry.link_rev\n data_file = index_file[0..-3] + \".d\"\n \n entry = pack_entry entry, link\n \n data_file_handle = open(data_file, \"a\")\n index_file_handle = open(index_file, \"a+\")\n \n journal << {:file => data_file, :offset => offset}\n journal << {:file => index_file, :offset => curr * entry.size}\n \n data_file_handle.write data[:compression] if data[:compression].any?\n data_file_handle.write data[:text]\n \n data_file_handle.flush\n index_file_handle.write entry\n end", "def cache_write(obj)\n # This is just a safety check. It can probably be disabled in the future\n # to increase performance.\n #if obj.respond_to?(:is_poxreference?)\n # # If this condition triggers, we have a bug in the library.\n # PEROBS.log.fatal \"POXReference objects should never be cached\"\n #end\n\n if @transaction_stack.empty?\n # We are not in transaction mode.\n idx = index(obj)\n if (old_obj = @writes[idx]) && old_obj._id != obj._id\n # There is another old object using this cache slot. Before we can\n # re-use the slot, we need to sync it to the permanent storage.\n old_obj._sync\n end\n @writes[idx] = obj\n else\n # When a transaction is active, we don't have a write cache. The read\n # cache is used to speed up access to recently used objects.\n cache_read(obj)\n # Push the reference of the modified object into the write buffer for\n # this transaction level.\n unless @transaction_stack.last.include?(obj._id)\n @transaction_stack.last << obj._id\n @transaction_objects[obj._id] = obj\n end\n end\n end", "def write\n return false unless @path\n\n clean!\n\n @path.open('w') do |file|\n file.puts YAML.dump(@cache)\n end\n\n true\n end", "def put(key, value)\n stored = @node_map[key]\n if stored\n stored.val = value\n #reusing the ips\n get(key)\n nil\n else\n node = CacheListNode.new()\n node.val = value\n node.key = key\n insert_node_at_head(node)\n @list_tail = node unless @list_tail\n @node_map[key] = node\n if @node_map.size > @capacity\n @node_map.delete(@list_tail.key)\n clip_node_from_list(@list_tail)\n end\n nil\n end\n end", "def cache_store(key, value, options = {})\n options[:expires] = options.delete(:ttl) || @options[:expires_in]\n @moneta.store(key, value, options)\n end", "def write(name, value)\n @redis.set(name, Oj.dump(value, mode: :compat, time_format: :ruby))\n end", "def cache_content(type, data)\n return nil unless type.present?\n\n Rails.cache.write(type, data, expires_in: 60.minutes)\n rescue StandardError => e\n logger.error(\"Unable to add #{type} to the Rails cache: #{e}.\")\n end", "def cache_set(ck, obj)\n @cache_store.set(ck, obj, @cache_ttl)\n end", "def update_cache\n return '' if disabled?\n\n key = \"#{identity_cache_key}:#{short_sha1}:#{Time.now.to_f}\"\n ArCache.write(identity_cache_key, key, raw: true, expires_in: 20.years)\n key\n end", "def put(key, value)\n \n end", "def write_mock_response key, value\n @@mutex.synchronize do\n @@mock_caches[key] = [true, value]\n end\n end", "def write_cache!(session)\n FileUtils.mkdir_p(Config.cache_path)\n File.open(cached_file, \"w\") do |cache_file|\n cache_file.write(session.serialize)\n end\n end", "def put(key, value)\n # logger.debug \"put #{key} data\"\n db.put(key, value)\n end", "def set_cache(value); end", "def set_cache(value); end" ]
[ "0.796262", "0.7884245", "0.78670335", "0.7747756", "0.76534295", "0.7595529", "0.7469992", "0.7443536", "0.7425927", "0.7342955", "0.72985774", "0.709497", "0.7039198", "0.70159525", "0.700047", "0.6958491", "0.69418466", "0.6864184", "0.68355346", "0.6819205", "0.6805944", "0.67645836", "0.6745422", "0.6729585", "0.66880924", "0.66829175", "0.664449", "0.6644171", "0.66204417", "0.66177857", "0.66170746", "0.6590852", "0.6577023", "0.65744954", "0.6550918", "0.6544639", "0.6541953", "0.6529119", "0.6529119", "0.65200895", "0.6506332", "0.64603376", "0.64321375", "0.64306504", "0.642265", "0.64118266", "0.64100695", "0.63855475", "0.63853353", "0.636278", "0.6357833", "0.63495123", "0.63379", "0.6316907", "0.63047504", "0.629579", "0.62955016", "0.6291072", "0.62762576", "0.62749094", "0.627174", "0.6261055", "0.6251643", "0.62201816", "0.62123823", "0.62049544", "0.6200997", "0.6200858", "0.6192527", "0.6161799", "0.6160229", "0.6153966", "0.6153356", "0.6144899", "0.6138907", "0.6132303", "0.6123776", "0.612213", "0.609182", "0.6091458", "0.6088973", "0.60542667", "0.60542667", "0.6049384", "0.6047117", "0.6046019", "0.6027933", "0.6017072", "0.60122347", "0.6003083", "0.59902894", "0.5976565", "0.59665024", "0.5965487", "0.59594065", "0.5959007", "0.5945766", "0.59424603", "0.59418976", "0.59418976" ]
0.60887575
81
Deletes an entry from the cache implementation. Subclasses must implement this method.
def delete_entry(key, **_options) failsafe(:delete_entry, returning: false) do res = collection.remove(key) @last_mutation_token = res.mutation_token true end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(entry)\n if index = @cache.delete(entry)\n entries.delete_at(index)\n end\n end", "def delete(entry)\n deleted_index = @cache.delete(key_for(entry))\n if deleted_index\n @cache.each do |key, index|\n @cache[key] -= 1 if index > deleted_index\n end\n end\n deleted_index\n end", "def delete_entry(key, options) # :nodoc:\n response = @data.del(key)\n rescue => e\n logger.error(\"Error deleting cache entry from redis: #{e}\") if logger\n false\n end", "def delete_entry(cache_id:, request:)\n {\n method: \"CacheStorage.deleteEntry\",\n params: { cacheId: cache_id, request: request }.compact\n }\n end", "def cache_delete\n model.send(:cache_delete, cache_key)\n end", "def remove(entry)\n @entry_set.delete(get_entry(entry))\n end", "def cache_delete(key)\n @cache_store.delete(key)\n nil\n end", "def delete(key)\n ref = @cache.delete(key)\n ref.__getobj__ rescue nil\n end", "def delete(key)\n value = self[key]\n\n @memcached.delete key\n\n value\n end", "def delete(key)\n id = @cache[key]\n @cache.delete(key)\n @index.delete(id) if id\n end", "def delete(key)\n raise NotImplementedError.new 'Implement delete(key) in your CacheManager'\n end", "def delete_entry(key, options)\n @hash.delete(key)\n end", "def delete_entry(key, **options)\n failsafe(:delete_entry, returning: false) do\n with { |c| c.del key }\n end\n end", "def delete_entry(key, **options)\n raise NotImplementedError.new\n end", "def delete(instance)\n @cache[mapped_class(instance.class)].delete(instance.key)\n end", "def del(key)\n log(\"remove :Cache, #{key}\")\n connection.remove(:Cache, key)\n end", "def remove(entry); end", "def delete_entry(key, options) # :nodoc:\n @data.remove(key)\n rescue => e\n logger.error(\"KyotoTycoonError (#{e}): #{e.message}\") if logger\n false\n end", "def cache_delete(ck)\n cache_op(:delete, ck)\n nil\n end", "def delete(key)\n File.unlink cache_path(key)\n rescue Errno::ENOENT\n end", "def delete_entry(key, options) # :nodoc:\n @client.delete(key)\n rescue Spymemcached::Error => e\n logger.error(\"Spymemcached::Error (#{e}): #{e.message}\") if logger\n false\n end", "def delete_entry(key, **options)\n rescue_error_with(false) { @data.with { |c| c.delete(key) } }\n end", "def delete( id )\n entry = entries.delete(id)\n if entry\n mark_modified\n Entry.new(self, id, entry)\n end\n end", "def cache_delete\n model.cache_delete_pk(pk)\n end", "def after_destroy(entry)\n expire_cache_for(entry)\n end", "def delete_entry(key, **options); end", "def delete(key, options = {})\n old_key_present = key_exists?(key)\n value = @data[key]\n @data.delete(key)\n @key_access_store.delete(key)\n @cache_size -= compute_value_size(value) if @cache_size > 0 && old_key_present\n end", "def delete(*args)\n args.each do |arg|\n @cache.delete(\"#{@cache_name}:#{arg}\")\n end\n end", "def delete key\n File.delete( cache_file(key) ) if File.exists?( cache_file(key) )\n end", "def delete\n redis.del key\n end", "def delete_entry(key, options)\n dataset.delete Google::Cloud::Datastore::Key.new @datastore_kind_name, key\n end", "def cache_delete_pk(pk)\n cache_delete(cache_key(pk))\n end", "def delete(key)\n @backend.delete(key)\n rescue ::Memcached::Error\n nil\n end", "def delete_entry(key, options) # :nodoc:\n @data.where(key: key).delete\n rescue Sequel::Error => e\n logger.error(\"Sequel::Error (#{e}): #{e.message}\") if logger\n false\n end", "def destroy\n @entry = Entry.find(params[:id])\n expire_page_cache(@entry)\n @tag = @entry.tag\n @entry.destroy\n \n respond_to do |format|\n format.html { redirect_to tag_entries_url(@tag) }\n format.json { head :no_content }\n end\n end", "def delete\n cache_delete\n super\n end", "def delete\n cache_delete\n super\n end", "def delete_entry(key, options) # :nodoc:\n @data.delete(key, options)\n rescue ::Couchbase::Error::Base => e\n logger.error(\"#{e.class}: #{e.message}\") if logger\n raise if @raise_errors\n false\n end", "def delete(resource, key)\n @cache[resource].delete(key)\n end", "def cache_delete(*args)\n super { |key| @store.delete(key) }\n end", "def delete(key)\n if item = super\n lru_delete(item)\n end\n end", "def delete_entry(entry)\n @address_book.entries.delete(entry)\n puts \"#{entry.name} has been deleted\"\n end", "def remove(*key)\n @cache.delete(key)\n end", "def delete_entry(key, options) # :nodoc:\n with { |c| c.delete(key) }\n rescue Dalli::DalliError => e\n log_dalli_error(e)\n instrument_error(e) if instrument_errors?\n raise if raise_errors?\n false\n end", "def delete(key)\n data.delete(key)\n @deleted_hash[key] = nil\n end", "def cache_delete(key: cache_key, **)\n Rails.cache.delete(key, namespace: namespace) if validate_key(key)\n end", "def delete\n bucket.update(:deleted, self)\n freeze\n self.class.delete(key, bucket.name)\n end", "def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n head :no_content\n end", "def delete(key)\n @monitor.synchronize do\n entry = @stash.delete(key)\n if entry\n @expires_at.delete(entry)\n entry.value\n else\n nil\n end\n end\n end", "def remove_entry(path)\n aug.rm(path_to_remove(path))\n end", "def delete(key); end", "def delete(key); end", "def delete(key); end", "def delete(key); end", "def delete(key); end", "def delete(key, options = nil)\n Rails.cache.delete(key, options)\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: delete: K: #{key.inspect}. M: #{exc.message}, I: #{exc.inspect}\" }\n nil\n end", "def delete(key, options = nil)\n Rails.cache.delete(key, options)\n rescue => exc\n Rails.logger.error { \"MEMCACHE-ERROR: delete: K: #{key.inspect}. M: #{exc.message}, I: #{exc.inspect}\" }\n nil\n end", "def remove(key)\n File.unlink cache_path(key)\n rescue Errno::ENOENT\n end", "def test_delete_existing\n @cache.add('Key', 'Data_to_delete', 0, Time.now.to_i + 60)\n result = @cache.delete('Key')\n retrieval = @cache.get('Key')\n\n assert_true result.success\n assert_equal 'SUCCESS', result.message.chomp.split(\"\\s\")[0]\n assert_false retrieval.success\n assert_equal 'NOT_FOUND', retrieval.message.chomp.split(\"\\s\")[0]\n end", "def delete(cache_key)\n @pg.exec_prepared(@delete_statement_name, [object_to_cache_key(cache_key)]).cmd_tuples.eql?(1)\n end", "def destroy\n self.class.remove(key)\n end", "def destroy\n self.class.remove(key)\n end", "def delete_entry(params)\n dd = DBDeleter.new(params)\n dd.delete\n end", "def delete(_url)\n # do nothing since we can't find the key by url\n end", "def delete(entry_id)\n\t\t\tkparams = {}\n\t\t\t# Data entry id to delete\n\t\t\tclient.add_param(kparams, 'entryId', entry_id);\n\t\t\tclient.queue_service_action_call('data', 'delete', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend", "def delete(field)\n redis.hdel @key, field\n end", "def delete(uid)\n @entries.delete_if { |e| e.obj.uid == uid }\n end", "def delete(name, options = nil)\n options ||= {}\n name = expanded_key name\n\n instrument(:delete, name) do\n delete_entry(name, options)\n end\n end", "def delete(key)\n raise \"Method not implemented. Called abstract class.\"\n end", "def delete(key)\n @redis.delete(key)\n end", "def delete key\n rv = self[key]\n self.removeField key\n return rv\n end", "def delete(entry)\n return true if !entry.id\n\n @lock.synchronize do\n with_index_lock do\n return true if !@machines[entry.id]\n\n # If we don't have the lock, then we need to acquire it.\n if !@machine_locks[entry.id]\n raise \"Unlocked delete on machine: #{entry.id}\"\n end\n\n # Reload so we have the latest data, then delete and save\n unlocked_reload\n @machines.delete(entry.id)\n unlocked_save\n\n # Release access on this machine\n unlocked_release(entry.id)\n end\n end\n\n true\n end", "def delete(key)\n hashed_key = key.hash\n bucket_index = hashed_key % num_buckets\n return nil if !@store[bucket_index].include?(key)\n @count -=1\n @store[bucket_index].remove(key)\n end", "def del(key)\n response = db.delete_item(@table_name, {'HashKeyElement' => {'S' => key}})\n true\n end", "def destroy\n begin\n self.class.delete(dn)\n @new_entry = true\n rescue Error\n raise DeleteError.new(_(\"Failed to delete LDAP entry: %s\") % dn)\n end\n end", "def delete(arg_)\n @config.lock\n\n @mutex.synchronize do\n if (objdata_ = _get_objdata(arg_))\n @objects.delete(objdata_[0].object_id)\n objdata_[2].each_key{ |tup_| _remove_tuple(objdata_, tup_) }\n end\n end\n self\n end", "def destroy\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n redirect_to(entries_url)\n end", "def delete(key)\r\n if record = touch(key)\r\n @store.delete(key)\r\n @head = @tail = nil if @store.length.zero?\r\n record[:value]\r\n end\r\n end", "def destroy\n @entry ||= Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to(entries_url) }\n format.xml { head :ok }\n end\n end", "def delete(path)\n path = self.class.path(path).to_s\n zip.fopen(path).delete\n entries.delete(path)\n end", "def delete(key = nil)\n key ? self.data.delete(key) : self.data.clear\n end", "def delete(key = nil)\n key ? self.data.delete(key) : self.data.clear\n end", "def destroy\n debugger\n @entry = Entry.find(params[:id])\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to entries_url }\n format.json { head :ok }\n end\n end", "def delete(o)\n @hash.delete(o)\n self\n end", "def delete(o)\n @hash.delete(o)\n self\n end", "def delete( key )\n fail NotImplementedError\n end", "def del\n delete\n end", "def delete\n CMark.node_unlink(@pointer)\n end", "def delete(key)\n @hash.delete(key.to_s)\n end", "def del(key)\n @first.del(key)\n end", "def rem(key, value)\n log(\"get :Deltas, #{key}, #{cache_name(value)}\")\n timestamp = connection.get(:Deltas, key, cache_name(value))\n\n log(\"remove :Deltas, #{key} -> #{timestamp_name(timestamp)}\")\n connection.remove(:Deltas, key, timestamp_name(timestamp))\n\n log(\"remove :Deltas, #{key} -> #{cache_name(value)}\")\n connection.remove(:Deltas, key, cache_name(value))\n end", "def delete(key)\n pop if change_key(key, nil, true)\n end", "def delete key\n @internal_hash[key].clear\n end", "def delete(key)\n unimplemented\n end", "def delete(key)\n db.delete(key)\n end", "def delete(key)\n @store.delete(key)\n end", "def delete(item, count = 0)\n conn.lrem key, count, item\n end", "def delete(key)\n\n end", "def remove(thing)\n @cache[section(thing)].delete(key(thing))\n end", "def delete!\n clear!\n delete\n end" ]
[ "0.84373236", "0.78725857", "0.76261675", "0.72274303", "0.71454823", "0.7133182", "0.70640075", "0.7055703", "0.70554477", "0.7048757", "0.6982963", "0.69795656", "0.69541943", "0.69132334", "0.69060886", "0.6882095", "0.68051064", "0.6798982", "0.67727005", "0.6738487", "0.6733177", "0.67295194", "0.6693339", "0.66917527", "0.66758126", "0.66730505", "0.6651468", "0.6644156", "0.6618338", "0.66092336", "0.6581619", "0.65751266", "0.6538691", "0.6520813", "0.6518669", "0.6512908", "0.6512908", "0.6500632", "0.6494951", "0.6437171", "0.6428739", "0.64216095", "0.6398716", "0.6390408", "0.63779306", "0.637644", "0.63381726", "0.6323771", "0.630798", "0.63079625", "0.62896395", "0.62896395", "0.62896395", "0.62896395", "0.62896395", "0.6280711", "0.62802273", "0.6279886", "0.6275228", "0.62697405", "0.62588835", "0.62588835", "0.6249329", "0.62392646", "0.62378263", "0.6201455", "0.61871827", "0.61821824", "0.61646575", "0.6139455", "0.61260325", "0.6119297", "0.61034775", "0.6091891", "0.6084343", "0.60755754", "0.6059748", "0.60477126", "0.60419995", "0.60388136", "0.6035355", "0.6035355", "0.60311", "0.60278755", "0.60278755", "0.6026233", "0.60232866", "0.6005519", "0.59946305", "0.5994572", "0.59898376", "0.5986267", "0.5984728", "0.5983641", "0.5983442", "0.5983044", "0.59805113", "0.59758145", "0.59718645", "0.5963575" ]
0.67925274
18
Deletes multiple entries in the cache. Returns the number of entries deleted.
def delete_multi_entries(entries, **_options) return if entries.empty? failsafe(:delete_multi_entries, returning: nil) do successful = collection.remove_multi(entries).select(&:success?) return 0 if successful.empty? @last_mutation_token = successful.max_by { |r| r.mutation_token.sequence_number } successful.count end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_multi_entries(entries, **options)\n entries.count { |key| delete_entry(key, **options) }\n end", "def delete!\n count = 0\n uniq.bulk_job { |e| count += 1; e.delete! }\n count\n end", "def delete_entries(entries)\n delete_all(:id => entries)\n end", "def cache_delete(*keys)\n @client.del(*keys)\n end", "def delete_many(filter = nil, options = nil)\n native.delete_many(filter, options || {}).deleted_count\n end", "def delete(entry)\n deleted_index = @cache.delete(key_for(entry))\n if deleted_index\n @cache.each do |key, index|\n @cache[key] -= 1 if index > deleted_index\n end\n end\n deleted_index\n end", "def call\n return log_info(\"Nothing to delete; exiting.\") if digests.none?\n\n log_info(\"Deleting batch with #{digests.size} digests\")\n return batch_delete(conn) if conn\n\n redis { |rcon| batch_delete(rcon) }\n end", "def delete(*args)\n args.each do |arg|\n @cache.delete(\"#{@cache_name}:#{arg}\")\n end\n end", "def del(*keys)\n keys.each{|key| expunge_if_expired(key)}\n i = 0\n keys.each do |key|\n if self.exists(key)\n self.expunge(key)\n i += 1\n end\n end\n if keys.size > 1\n true\n else\n i\n end\n end", "def delete_entries(entries)\n all(:id => entries.map(&:id)).destroy!\n end", "def delete_entries(entries)\n collection.find(:_id => { '$in' => entries.map(&:id) }).delete_many\n end", "def delete\n count = _redis_lua_run(\n 'batch_delete',\n keys: [_batch_key, _index_key, _batch_ref_key, _batch_gauge_key, _event_gauge_key],\n argv: [@uid, PREFIX_COUNT, subscriber_name])\n _counters.incr('events.removed', queue: subscriber_name, count: count)\n self\n end", "def batch_delete(conn)\n digests.each_slice(BATCH_SIZE) do |chunk|\n conn.pipelined do |pipeline|\n chunk.each do |digest|\n del_digest(pipeline, digest)\n pipeline.zrem(SidekiqUniqueJobs::DIGESTS, digest)\n pipeline.zrem(SidekiqUniqueJobs::EXPIRING_DIGESTS, digest)\n @count += 1\n end\n end\n end\n\n @count\n end", "def cache_delete(*keys)\n keys.each {|key| @moneta.delete(key) }\n end", "def del(*keys)\n keys.flatten!(1)\n return 0 if keys.empty?\n\n send_command([:del] + keys)\n end", "def delete(*args)\n if args.blank?\n raise \"Using delete with no args is not allowed. Please use delete_all to delete all records\"\n end\n keys = find_keys(*args)\n self.store.delete_keys(keys)\n end", "def delete_all(key)\n raise ArgumentError if key.blank?\n\n count = 0\n @redis.keys(\"#{key}*\").each do |k|\n count += @redis.del k\n end\n\n count.positive?\n end", "def delete(entry)\n if index = @cache.delete(entry)\n entries.delete_at(index)\n end\n end", "def delete_multiple(keys = [])\n verify_connection_url\n\n keys.each { |key| delete key }\n end", "def delete!\n uniq.bulk_job { |e| e.delete! }\n end", "def delete_multi(names, options = nil)\n return 0 if names.empty?\n\n options = merged_options(options)\n names.map! { |key| normalize_key(key, options) }\n\n instrument_multi :delete_multi, names do\n delete_multi_entries(names, **options)\n end\n end", "def cache_delete(*keys)\n if keys\n keys.each do |key|\n record = @store[:key => namespaced(key)]\n record.delete if record \n end\n end\n end", "def delete_ids(args)\n while !args[:ids].empty? and ids = args[:ids].shift(500)\n objs = self.list(args[:class], \"id\" => ids)\n self.deletes(objs)\n end\n\n return nil\n end", "def del(pattern = SCAN_PATTERN, count = 0, dry_run = true)\n raise ArgumentError, 'Please provide a number of keys to delete greater than zero' if count.zero?\n pattern = \"#{pattern}:*\" unless pattern.end_with?(':*')\n\n logger.debug { \"Deleting keys by: #{pattern}\" }\n keys, time = timed { keys(pattern, count) }\n logger.debug { \"#{keys.size} matching keys found in #{time} sec.\" }\n keys = dry_run(keys)\n logger.debug { \"#{keys.size} matching keys after post-processing\" }\n unless dry_run\n logger.debug { \"deleting #{keys}...\" }\n _, time = timed { batch_delete(keys) }\n logger.debug { \"Deleted in #{time} sec.\" }\n end\n keys.size\n end", "def delete(*args)\n execute(:delete, *args)\n end", "def deleted_count\n @results[REMOVED_COUNT]\n end", "def delete_all\n sum(&:delete_all)\n end", "def delete(*keys)\n multi do\n keys.each do |k|\n @hash.delete(k)\n @index.delete(k)\n end\n end\n nil\n end", "def process_del(command)\n result = 0\n command.each do |key|\n result += 1 if @connection.delete(as_key(key))\n end\n result\n end", "def cache_delete(key, *keys)\n # Remove a single key\n if keys.empty?\n nkey = namespaced(key)\n result = @dataset.select(:value).filter(:key => nkey).limit(1)\n\n # Ramaze expects nil values\n if result.empty?\n result = nil\n else\n result = deserialize(result.first[:value])\n end\n\n @dataset.filter(:key => nkey).delete\n # Remove multiple keys\n else\n nkeys = [key, keys].flatten.map! { |n| namespaced(n) }\n result = dataset.select(:value).filter(:key => nkeys)\n\n result.map! do |row|\n deserialize(row[:value])\n end\n\n @dataset.filter(:key => nkeys).delete\n end\n\n return result\n end", "def delete_one(filter = nil, options = nil)\n native.delete_many(filter, options || {}).deleted_count\n end", "def delete_from_cache(*keys, **opts)\n base_key = self.base_redis_key opts\n keys.each do |key|\n Cachable::redis.del \"#{base_key}_#{key}\"\n end\n end", "def delete(*args)\n if args.length == 1\n index = *args\n delete_index(index)\n elsif args.length == 2\n start_index, end_index = *args\n delete_range(start_index, end_index)\n elsif args.length > 2 && args.length < @items.length\n indices = *args.each { |arg| arg }\n delete_indices(indices)\n else\n raise UdaciListErrors::ArgumentError, \"Too many arguments\" if args.length\n end\n end", "def cache_delete(key, *keys)\n # Remove a single key\n if keys.empty?\n nkey = namespaced(key)\n result = @dataset.select(:value).filter(:key => nkey).limit(1)\n\n # Ramaze expects nil values\n if result.empty?\n result = nil\n else\n result = deserialize(result.first[:value])\n end\n\n @dataset.filter(:key => nkey).delete\n # Remove multiple keys\n else\n nkeys = [key, keys].flatten.map! { |nkey| namespaced(nkey) }\n result = dataset.select(:value).filter(:key => nkeys)\n\n result.map! do |row|\n deserialize(row[:value])\n end\n\n @dataset.filter(:key => nkeys).delete\n end\n \n return result\n end", "def delete(*key_list)\n first_keys, last_key = split_keys(key_list)\n data = fetch_data(first_keys)\n data.__delete__(last_key) if data.__key__?(last_key)\n end", "def del(*keys)\n keys.each do |key|\n @queries.delete(key)\n end\n\n self\n end", "def del\n redis do |conn|\n conn.multi do |pipeline|\n pipeline.zrem(DIGESTS, key.digest)\n pipeline.del(key.digest, key.queued, key.primed, key.locked, key.info)\n end\n end\n end", "def delete!\n uniq.both_e.uniq.bulk_job { |e| e.delete! }\n uniq.bulk_job { |e| e.delete! }\n end", "def delete(*ids)\n collection.remove(to_criteria(:_id => ids.flatten))\n end", "def delete(item, count = 0)\n conn.lrem key, count, item\n end", "def delete_entry(cache_id:, request:)\n {\n method: \"CacheStorage.deleteEntry\",\n params: { cacheId: cache_id, request: request }.compact\n }\n end", "def bulk_delete(list)\n\t\tputs \"Delete entries to the local host repository from:\\n #{list}\"\n\t\thosts=list\n\t\tchanges=Array.new\n\t\tif hosts.size > 0\n\t\t\thosts.map do |x|\n\t\t\t\thost=delete(x)\n\t\t\t\tchanges.push(host) unless host.nil?\n\t\t\tend\n\t\t\tputs \"Done deleting hosts.\"\n\t\t\treturn changes\n\t\telse\n\t\t\tputs \"Error: empty list - no entry is loaded. Please check your list and try again.\"\n\t\tend\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\"\n\tend", "def bulk_delete(list)\n\t\tputs \"Delete entries to the local site store from list:\\n #{list}\" if @verbose\n\t\tsites=list\n\t\tchanges=Array.new\n\t\tif sites.size > 0\n\t\t\tsites.map do |x|\n\t\t\t\tx=url_2_site(x)\n\t\t\t\tsite=delete(x)\n\t\t\t\tchanges.push(site) unless site.nil?\n\t\t\tend\n\t\t\tputs \"Done deleting sites from the list:\\n #{list}\"\n\t\t\treturn changes\n\t\telse\n\t\t\tputs \"Error: no entry is loaded. Please check your list and try again.\"\n\t\tend\n\trescue => ee\n\t\tputs \"Exception on method #{__method__}: #{ee}\" if @verbose\n\tend", "def _delete_records\n @ids_to_delete.each do |table, ids|\n delete_from_table(table, ids)\n end\n end", "def deleted_entries\n Array.load(self[:@deleted_entries_url])\n end", "def delete_at(index)\n len = count\n values = @@redis.lrange(namespaced_key, 0, len-1)\n @@redis.multi do\n new_values = []\n\n values.each_with_index do |value, i|\n new_values << value unless i == index\n end\n\n @@redis.del(namespaced_key)\n new_values.each do |value|\n @@redis.rpush(namespaced_key, value)\n end\n end\n end", "def batch_delete_rows(rows, per_page=100)\n begin\n batch_modify_rows('delete', rows, per_page)\n rescue VeritableError => e\n if (not e.respond_to?(:http_code)) or (not (e.http_code == \"404 Resource Not Found\"))\n raise e\n end\n end\n end", "def delete\n result, _ = Sidekiq::Batch.redis(bid) do |conn|\n conn.pipelined do\n conn.hsetnx(\"b-#{bid}\", \"deleted\", \"1\")\n conn.del \"b-#{bid}-failinfo\",\n \"b-#{bid}-notify\",\n \"b-#{bid}-cbsucc\",\n \"b-#{bid}-success\",\n \"b-#{bid}-complete\",\n \"b-#{bid}-jids\"\n conn.zrem('batches'.freeze, bid)\n conn.expire \"b-#{bid}\", Sidekiq::Batch::LINGER\n end\n end\n result ? bid : nil\n end", "def deletes(objs)\n if !@args[:datarow]\n objs.each do |obj|\n self.delete(obj)\n end\n else\n tables = {}\n\n begin\n objs.each do |obj|\n next if obj.deleted?\n tablen = obj.table\n\n if !tables.key?(tablen)\n tables[tablen] = []\n end\n\n tables[tablen] << obj.id\n obj.delete if obj.respond_to?(:delete)\n\n #Remove from ID-cache.\n classname = obj.class.classname.to_sym\n @ids_cache[classname].delete(obj.id.to_i) if @ids_cache_should.key?(classname)\n\n #Unset any data on the object, so it seems deleted.\n obj.destroy\n end\n ensure\n #An exception may occur, and we should make sure, that objects that has gotten 'delete' called also are deleted from their tables.\n tables.each do |table, ids|\n ids.each_slice(1000) do |ids_slice|\n @args[:db].delete(table, {:id => ids_slice})\n end\n end\n end\n end\n end", "def delete(*args)\n request(:delete, *args)\n end", "def delete_list(nonce_list)\n _resetCount()\n runMbxTransaction(@hpk, 'delete list') do\n nonce_list.each do |nonce|\n rds.del msg_tag nonce\n rds.hdel hpk_tag, nonce\n logger.info \"#{INFO} deleting #{dumpHex b64dec nonce} in mbx #{dumpHex b64dec @hpk}\"\n end\n end\n end", "def del(*keys); end", "def delete_all_cache(app_id, body, opts = {})\n data, status_code, headers = delete_all_cache_with_http_info(app_id, body, opts)\n return data\n end", "def delete_all\n store.delete(KEY)\n self\n end", "def _delete(i)\n out ={}\n @store.transaction {out = @store.delete(i)}\n out\n end", "def delete_all\n jobs.map(&:delete)\n end", "def multi_zdel(key, members)\n members = Array(members) unless members.is_a?(Array)\n mon_synchronize do\n perform [\"multi_zdel\", key, *members], :proc => T_INT\n end\n end", "def multi_zdel(key, members)\n members = Array(members) unless members.is_a?(Array)\n mon_synchronize do\n perform [\"multi_zdel\", key, *members], proc: T_INT\n end\n end", "def delete(*args)\n dataset.delete(*args)\n self\n end", "def clear\n all_keys = keys\n return 0 if all_keys.empty?\n\n # Delete all keys\n del(*all_keys)\n end", "def delete(*args)\n Request.delete(*args)\n end", "def delete\n self.class.redis_objects.each do |key, obj|\n obj = self.send(key.to_sym)\n if obj.class == Redis::Set || obj.class == Redis::HashKey || obj.class == Redis::List\n delete_key(key)\n else\n obj.delete\n end\n end\n end", "def delete(*ids)\n ids.flatten!\n @write_connection.delete_by_id(ids)\n end", "def process_deletions(deletion_batch)\n return 0 if deletion_batch.empty?\n\n delete_result = delete_message_batch(deletion_batch)\n delete_result.failed.each do |error_entry|\n report_error(\n 'Failed to delete item from queue',\n sqs_delete_error: error_entry.to_h,\n )\n end\n delete_result.successful.size\n rescue StandardError => err\n report_error(err)\n 0\n end", "def test_delete\n ir = ItemRepository.new('./data/items_tiny.csv')\n assert_equal 1367, ir.collection.length\n ir.delete(263396013)\n actual = ir.collection.length\n expected = 1366\n assert_equal expected, actual\n end", "def delete_all!\n delete(query: \"*:*\")\n end", "def delete_all\n self.store.delete_keys(find_keys)\n end", "def entries\n Rails.cache.instance_variable_get(:@data).size\n end", "def delete_host(opts)\n raise ArgumentError.new(\"The following options are required: :ids\") if opts[:ids].nil?\n\n ::ApplicationRecord.connection_pool.with_connection {\n deleted = []\n opts[:ids].each do |host_id|\n host = Mdm::Host.find(host_id)\n begin\n deleted << host.destroy\n rescue # refs suck\n elog(\"Forcibly deleting #{host.address}\")\n deleted << host.delete\n end\n end\n\n return deleted\n }\n end", "def delete\n @@all_items.delete(@id)\n end", "def delete(*args, &block)\n map_method(:delete, args, &block)\n end", "def xdel(key, *ids); end", "def batch_delete(uuids)\n body = uuids.to_json\n request_delete(uri: '/files/storage/', content: body)\n end", "def destroy(ids)\n end", "def destroy(ids)\n end", "def delete\n redis.eval(LUA_SCRIPT_DELETE, :keys => [build_key('*')])\n end", "def deleteItems\n self.items.each do |item|\n item.delete\n end\n end", "def remove_records(messages)\n clause = deleted_query(messages)\n\n clause.delete_all\n end", "def delete(ids, params = {}, body = {})\n delete_docs = ids.map { |id| { delete: { _index: @index, _id: id} } }\n @client.bulk({ body: delete_docs }.merge(params.merge(@params)))\n end", "def deleteAll(xs)\n xs.each do |x|\n x.destroy\n end\n end", "def delete_unmarked_entries(&block)\n deleted_ids = []\n # First remove the entry from the hash table.\n @entries_by_id.delete_if do |id, e|\n if e[MARKED] == 0\n yield(id) if block_given?\n deleted_ids << id\n true\n else\n false\n end\n end\n # Then delete the entry itself.\n @entries.delete_if { |e| e[MARKED] == 0 }\n write_index\n\n deleted_ids\n end", "def delete_entry(key, options) # :nodoc:\n response = @data.del(key)\n rescue => e\n logger.error(\"Error deleting cache entry from redis: #{e}\") if logger\n false\n end", "def bulk_delete\n contact_ids = []\n contact_params[:contact_ids].each do |cid|\n contact_ids << BSON::ObjectId.from_string(cid)\n end\n\n deleted = Contact.where(uid: current_user.id).in(:_id => contact_ids).delete_all\n\n Cashier.expire \"contacts-filter-#{current_user.id}\"\n notice = \"#{deleted} #{(t :contacts_deleted)}\"\n\n respond_to do |format|\n format.html { redirect_to contacts_url, notice: notice }\n format.json { head :no_content }\n end\n end", "def delete(query)\n\n connect if @persevere.nil?\n\n deleted = 0\n\n if ! query.is_a?(DataMapper::Query)\n resources = [query].flatten\n else\n resources = read_many(query)\n end\n\n resources.each do |resource|\n tblname = resource.model.storage_name\n id = resource.attributes(:field)['id']\n \n # Retrieve the ID from persever if the resource doesn't have an ID field\n if id.nil?\n query = Persevere.enhance(resource.query)\n path = \"/#{tblname}/#{query.to_json_query_filter}[={'id':id}]\"\n response = @persevere.retrieve(path, {})\n id = JSON.parse(response.body)[0]['id'].match(/(\\w+\\/)*(\\d+)/)[2]\n end\n \n path = \"/#{tblname}/#{id}\"\n # path = \"/#{tblname}/#{resource.key.first}\"\n \n DataMapper.logger.debug(\"(Delete) PATH/QUERY: #{path}\")\n\n result = @persevere.delete(path)\n\n if result.code == \"204\" # ok\n deleted += 1\n end\n end\n return deleted\n end", "def del(keys)\n keys.each { |key| _data.delete(key) }\n _save\n end", "def services_to_delete\n res = []\n cursor = 0\n\n loop do\n cursor, services = storage.sscan(\n KEY_SERVICES_TO_DELETE, cursor, count: SCAN_SLICE\n )\n\n res += services\n\n break if cursor.to_i == 0\n\n sleep(SLEEP_BETWEEN_SCANS)\n end\n\n res.to_set\n end", "def delete!(keys)\n @pages.pipelined do\n keys.each { |k| @pages.del k }\n end\n return keys\n end", "def delete!(keys)\n @pages.pipelined do\n keys.each { |k| @pages.del k }\n end\n return keys\n end", "def delete_list(params={})\n @obj.delete('delete', @auth.merge(params))\n end", "def remove!( *entries )\n _modify( *entries ) { |a,b| a - b }\n end", "def delete(*args)\n delete!(*args)\n rescue *exceptions\n false\n end", "def delete\n Iterable.request(conf, base_path).delete\n end", "def batch_delete(config, items)\n begin\n subset = items.shift(25)\n sub_batch = write(subset)\n process!(config, sub_batch)\n end until subset.empty?\n end", "def destroy_all\n ids = self.all.map{|item| item.id}\n bulk_update do\n ids.each do |item|\n find_by_id(item).destroy\n end\n end\n # Note collection is not emptied, and next_id is not reset.\n end", "def delete!\n values.delete!\n end", "def destroy_all\n ids = self.all.map{|item| item.id}\n bulk_update do\n ids.each do |item|\n find(item).destroy\n end\n end\n # Note collection is not emptied, and next_id is not reset.\n end", "def delete\n execute_dui(delete_sql){|c| return c.affected_rows}\n end", "def destroy_multiple\n # Remove selected patients from database\n id_list = params[:patient_ids].split(',')\n number_deleted = Patient.where(id: { '$in': id_list }).destroy_all\n redirect_back(fallback_location: root_path)\n # If something can't be deleted, we want to flash that as well as anything that was deleted.\n if number_deleted == id_list.length\n flash[:notice] = \"Deleted #{number_deleted} #{'patient'.pluralize(number_deleted)}.\"\n else\n difference = id_list.length - number_deleted\n flash[:notice] = \"#{difference} #{'patient'.pluralize(difference)} could not be deleted. \\\n Deleted #{number_deleted} #{'patient'.pluralize(number_deleted)}.\"\n end\n end", "def batch_destroy\n params[:device_ids].each do |device_id|\n device = Device.find(device_id)\n device.destroy\n end\n\n respond_with(params[:device_ids], location: devices_path, notice: 'Devices were successfully destroyed.')\n end", "def delete(key)\n raise ArgumentError, \"+key+ is not an Array, but was #{key.class}\" unless Array === key\n\n @second_level_cache.delete(key) if @second_level_cache\n @cache.delete(key)\n end" ]
[ "0.7474177", "0.6824208", "0.6674753", "0.6643579", "0.66373324", "0.66033", "0.65767527", "0.6558294", "0.6550996", "0.6542089", "0.63723123", "0.6368551", "0.6355705", "0.6317323", "0.624858", "0.62176305", "0.61805487", "0.61711884", "0.61625236", "0.6123495", "0.61027884", "0.6036507", "0.59985596", "0.598331", "0.5982922", "0.5976801", "0.5934638", "0.5903094", "0.58766353", "0.58621776", "0.58611155", "0.5858584", "0.58368737", "0.58348006", "0.58322924", "0.57849216", "0.57028824", "0.56956273", "0.5626983", "0.56211704", "0.5598242", "0.55855167", "0.55702543", "0.5565608", "0.5541907", "0.55406964", "0.55347764", "0.5534471", "0.55206513", "0.5515211", "0.5514901", "0.55117726", "0.5496326", "0.5487995", "0.54786295", "0.5472081", "0.5471098", "0.5459862", "0.5431472", "0.54268235", "0.54103523", "0.54060936", "0.5397557", "0.5393069", "0.5371133", "0.5362856", "0.5360399", "0.53554446", "0.53444195", "0.5329507", "0.532844", "0.53192765", "0.5313728", "0.5309743", "0.5309743", "0.5302109", "0.5301842", "0.5293502", "0.52824336", "0.5279145", "0.5273253", "0.52711636", "0.5270601", "0.52605844", "0.5259408", "0.5259166", "0.52560127", "0.52560127", "0.5252202", "0.52501833", "0.52467227", "0.523962", "0.5231543", "0.52294034", "0.52286446", "0.5226718", "0.52247185", "0.5220276", "0.52146465", "0.5207332" ]
0.73292744
1
Truncate keys that exceed 250 characters
def normalize_key(key, options) truncate_key super&.b end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def truncated_key(key)\n digest = digest_class.hexdigest(key)\n \"#{key[0, prefix_length(digest)]}#{TRUNCATED_KEY_SEPARATOR}#{digest}\"\n end", "def max_key_width; end", "def max_key_width=(_arg0); end", "def truncate(length = 30)\n return self if self.length < length\n self[0..length].gsub(/\\s\\w+\\s*$/, '...')\n end", "def shortened_tweet_truncator(tweet_string)\n if tweet_string.length > 140\n tweet_string[0..136] + \"...\"\n else\n tweet_string\n end\nend", "def shortened_tweet_truncator(tweet_one)\n if tweet_one.length > 140\n tweet_one[0..139] \n else\n tweet_one\n end\nend", "def smart_truncate(len = 30, ending = '...')\n len = Math.max(len, 5)\n return self if self.length <= len\n s = self[0...(len-2)].reverse\n bits = s.split(/[\\s\\-,]/,2)\n s = bits.length == 2 ? bits[1] : bits[0]\n s.reverse + ending\n end", "def shortened_tweet_truncator(tweet)\n\n if tweet.length <= 140\n tweet\n else\n word_substituter(tweet)[0..136] + \"...\"\n end\nend", "def xtrim(key, len_or_id, strategy: T.unsafe(nil), approximate: T.unsafe(nil), limit: T.unsafe(nil)); end", "def test_it_can_handle_keys_longer_than_250_characters\n long_key = 'a' * 260\n assert store.write(long_key, 123)\n assert_equal 123, store.read(long_key)\n end", "def shortened_tweet_truncator(tweet)\n selective_tweet_shortener(tweet)\n if tweet.length >= 140\n tweet[0...137].concat(\"...\") #(...) is 3 characters!\n else\n tweet if tweet.length < 140\n end\nend", "def trim_length\n \t400\n end", "def shortened_tweet_truncator(tweet)\n shortened_tweet = selective_tweet_shortener(tweet)\n tweet_w_ellipses = \"\"\n char_array = []\n\n if shortened_tweet.length > 140\n shortened_tweet = shortened_tweet[0..136] + \"...\"\n else\n return shortened_tweet\n end\nend", "def shortened_tweet_truncator(tweet)\n if tweet.length < 140\n tweet\n else\n word_substituter(tweet)[0...140]\n end\nend", "def awesome_truncate(text, length = 30, truncate_string = \"...\")\n return if text.nil?\n l = length - truncate_string.mb_chars.length\n text.mb_chars.length > length ? text[/\\A.{#{l}}\\w*\\;?/m][/.*[\\w\\;]/m] + truncate_string : text\nend", "def shortened_tweet_truncator(tweet)\n if word_substituter(tweet).length <= 140\n word_substituter(tweet)\n else\n word_substituter(tweet)[0..136] << \"...\" \n end\nend", "def rekey_limit; end", "def shortened_tweet_truncator(tweet) \n if word_substitutor(tweet).length > 140 \n word_substitutor(tweet)[0...137] + \"...\"\n else \n tweet\n end \nend", "def shortened_tweet_truncator(tweet)\n shortened_tweet = selective_tweet_shortener(tweet)\n if tweet.length < 140 \n tweet\n elsif\n shortened_tweet.length > 140 \n shortened_tweet[0...140-3] + \"...\" \n else\n shortened_tweet\nend\nend", "def shortened_tweet_truncator(tweet)\n if tweet.length > 140\n temp = word_substituter(tweet)\n temp = temp[0..139] if temp.length >140\n temp\n else\n tweet\n end\nend", "def awesome_truncate(text, length = 30, truncate_string = \"...\")\n return if text.nil?\n l = length - truncate_string.mb_chars.length\n text.mb_chars.length > length ? text[/\\A.{#{l}}\\w*\\;?/m][/.*[\\w\\;]/m] + truncate_string : text\n end", "def awesome_truncate(text, length = 30, truncate_string = \"...\")\n return if text.nil?\n l = length - truncate_string.mb_chars.length\n text.mb_chars.length > length ? text[/\\A.{#{l}}\\w*\\;?/m][/.*[\\w\\;]/m] + truncate_string : text\n end", "def awesome_truncate(text, length = 30, truncate_string = \"...\")\n return if text.nil?\n l = length - truncate_string.mb_chars.length\n text.mb_chars.length > length ? text[/\\A.{#{l}}\\w*\\;?/m][/.*[\\w\\;]/m] + truncate_string : text\n end", "def truncate_message(message, length, ellipsis_string)\n chars = message.scan(/./mu)\n max_length_with_ellipsis = length - ellipsis_string.length - 1\n allowed_chars = chars[0..max_length_with_ellipsis]\n allowed_chars.join.gsub(/ ?\\.?,?$/, '') + ellipsis_string\n end", "def shortened_tweet_truncator(tweet)\n if word_substituter(tweet).length > 140\n word_substituter(tweet)[0..136] + '...'\n else\n tweet\n end\nend", "def shortened_tweet_truncator(tweet)\n short = word_substituter(tweet)\n if short.length > 140\n short[0..139]\n else\n short\n end\nend", "def strlen(key); end", "def strlen(key); end", "def truncate(input, length)\n if input.length > length && input[0..(length - 1)] =~ /(.+)\\b.+$/im\n $1.strip + '...'\n else\n input\n end\n end", "def trunc(len)\n split(/ /).each_with_object('') do |x, ob|\n break ob unless ob.length + ' '.length + x.length <= len\n\n ob << (\" #{x}\")\n end.strip\n end", "def truncate() end", "def format_key(key)\n @string_size = [@string_size.to_i, key.length + 2].max\n key.ljust(@string_size, \" \")\nend", "def truncate(max)\n length = Math.min(max, length)\n self\n end", "def smart_truncate(opts = {})\n opts = {:words => 12}.merge(opts)\n if opts[:sentences]\n return self.split(/\\.(\\s|$)+/).reject{ |s| s.strip.empty? }[0, opts[:sentences]].map{|s| s.strip}.join('. ') + '...'\n end\n a = self.split(/\\s/) # or /[ ]+/ to only split on spaces\n n = opts[:words]\n a[0...n].join(' ') + (a.size > n ? '...' : '')\n end", "def truncated_content\n\t\tid.to_s+\" - \"+content.truncate(50,{omission: '...'})\n end", "def cleanup!(max_len)\n if self.length >= max_len\n self.clear\n end\n end", "def shorten(text, chars=20)\n text.length > chars ? \"#{text[0..chars-3]}...\" : text\n end", "def format_key_string(key, longest_length)\n buffer = longest_length - key.length\n whitespace = ' ' * buffer\n whitespace + key\n end", "def shorten(len=20)\n self[0..len-1]\n end", "def truncate_message(message)\n size = MAX_DATA_LENGTH - 4\n if message.length > size\n message.slice!(size..message.length)\n message << '...'\n else\n message\n end\n end", "def truncated_content\n\t\t\tid.to_s+\" - \"+content.truncate(50,{omission: '...'})\n\t end", "def truncate(v, l = 30)\n s = v.to_s\n s.size > l ? s.first(l) + t('truncation', '...') : s\n end", "def trunc_em\n self.name = self.name.truncate 30 if self.name.present?\n self.twitter_handle = self.twitter_handle.truncate 30 if self.twitter_handle.present?\n self.location = self.location.truncate 40 if self.location.present?\n end", "def key_length(name); end", "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 shortened_tweet_truncator(tweet)\n # puts \"**********************************#{tweet}\"\n tweet = selective_tweet_shortener(tweet)\n # new_tweet = tweeet\n if tweet.length > 140\n #slice!(start, length) → new_ary or nil\n tweet = tweet.slice(0,140)\n end\n tweet\nend", "def limit_text_length (string_to_put_limitation, max_length)\n\n if string_to_put_limitation.length > max_length\n\n limited_string = string_to_put_limitation[0..max_length].gsub(/\\s\\w+\\s*$/,'...')\n\n return limited_string\n\n else\n\n return string_to_put_limitation\n\n end#string size check\n\n end", "def truncate!\n self.name = name[LENGTH_RANGE] if name && name.size > MAX_LENGTH\n self.scope = scope[LENGTH_RANGE] if scope && scope.size > MAX_LENGTH\n end", "def maxStringLength\n\t\tweight = @dictionaries.inject(1) { |x, d| x * d.length }\n\t\tbits = (Math.log(weight)/Math.log(2)).floor\n\t\tchars = bits/4\n\tend", "def limit(length)\n (self.length > length)? self[0...length].gsub(/(?![\\s\\S]+?[,:;)\\/\\\\\\|])([,:;)\\/\\\\\\|].*)/,'') : self\n end", "def prepare_dictionary(dictionary, length)\n result = IO.readlines(dictionary).map(&:chop)\n result.delete_if { |word| word.length > length }\n result.sort_by!(&:length).reverse!\n end", "def desc_char_limit\n 300\n end", "def truncate(max)\n resize([max, self.length].min)\n end", "def test_truncate\n name = \"Broadmark\"\n truncated = truncate name, :length => 5\n assert_equal \"Br...\", truncated, \"truncated Broadmark\"\n\n truncated = truncate name, :length => 9\n assert_equal \"Broadmark\", truncated, \"truncated Broadmark\"\n\n truncated = truncate name, :length => 8\n assert_equal \"Broad...\", truncated, \"truncated Broadmark\"\n end", "def shortened_tweet_truncator(tweet)\n # shortened_tweet stores the new shortened tweet to be returned for this method\n # Instantiated with the shortened tweet using #word_substituter\n shortened_tweet = word_substituter(tweet)\n\n # Checks to see if the length of shortened_tweet is longer than 140 characters\n # If true, truncates the tweet to 140 characters with an ellipsis (...). The ellipsis is included in the count\n if shortened_tweet.length > 140\n shortened_tweet = shortened_tweet[0..136]\n shortened_tweet << \"...\"\n end\n\n # Returns the shortened tweet\n shortened_tweet\nend", "def normalize_key(key, options)\n key = super\n if key\n key = key.dup.force_encoding(Encoding::ASCII_8BIT)\n key = key.gsub(ESCAPE_KEY_CHARS) { |match| \"%#{match.getbyte(0).to_s(16).upcase}\" }\n\n if key.size > KEY_MAX_SIZE\n key_separator = \":hash:\"\n key_hash = ActiveSupport::Digest.hexdigest(key)\n key_trim_size = KEY_MAX_SIZE - key_separator.size - key_hash.size\n key = \"#{key[0, key_trim_size]}#{key_separator}#{key_hash}\"\n end\n end\n key\n end", "def oath_truncate(hash, length = 6)\n\n # Convert to array of decimals\n hmac_result = hash.scan(/../).map { |e| e.hex }\n\n # Find offset\n offset = hmac_result.last & 0xf\n\n v =\n (hmac_result[offset + 0] & 0x7f) << 24 |\n (hmac_result[offset + 1] & 0xff) << 16 |\n (hmac_result[offset + 2] & 0xff) << 8 |\n (hmac_result[offset + 3] & 0xff)\n\n r = v % 10 ** length.to_i\n\n \"%0#{length}d\" % r\n end", "def abbrev_key(key_str)\n key_str[0, 5] + ' ' + key_str[5, 5] + ' ' +key_str[10, 5]\nend", "def truncate(str, width)\n return str if str.bytesize <= width\n\n ellipses = '...'\n truncated_width = width - 3 # leave room for elipses\n\n # Not handling UTF-8 at the moment\n str.slice(0, truncated_width) + ellipses\n end", "def truncate\n end", "def truncate_in_the_middle(max_len)\n r = if(max_len > 0 && length > max_len)\n half_len = max_len/2\n \"#{ self[0..half_len] } [...] #{ self[-half_len..-1] }\"\n else\n self\n end\n r\n end", "def mask(key, from = 4)\n str = key.dup\n if str && str.length > from\n str[from...str.length] = \"X\" * (str[from...str.length].length)\n end\n\n str\n end", "def remove_max_length(table, *arr_cn_len)\n execute sql_remove_max_length(table, *arr_cn_len)\n end", "def ltrunc(max)\n if length > max\n sub(/^.*?(.{#{max - 3}})$/, '...\\1')\n else\n self\n end\n end", "def test_truncate\n name = 'Broadmark'\n truncated = truncate(name, 5)\n assert_equal('Br...', truncated, 'truncated Broadmark')\n\n truncated = truncate(name, 9)\n assert_equal('Broadmark', truncated, 'truncated Broadmark')\n\n truncated = truncate(name, 8)\n assert_equal('Broad...', truncated, 'truncated Broadmark')\n end", "def truncate(length)\n range_stop = -1 - length\n # Get the keys to delete from the hash\n keys = @index.range(0, range_stop)\n # Remove the keys from the index\n @index.delete_by_rank(0, range_stop)\n\n # Remove the values from the hash\n multi do\n keys.each do |key|\n @hash.delete(key)\n end\n end\n self\n end", "def awesome_truncate(text, length = 30, truncate_string = \"&hellip;\")\n return \"\" if text.blank?\n\n l = length - truncate_string.mb_chars.length\n result = text.mb_chars.length > length ? (text[/\\A.{#{l}}\\w*\\;?/m][/.*[\\w\\;]/m] || '') + truncate_string : text\n result.html_safe\n end", "def truncate(input, length = T.unsafe(nil), truncate_string = T.unsafe(nil)); end", "def xtrim(key, len_or_id, strategy: 'MAXLEN', approximate: false, limit: nil)\n strategy = strategy.to_s.upcase\n\n args = [:xtrim, key, strategy]\n args << '~' if approximate\n args << len_or_id\n args.concat(['LIMIT', limit]) if limit\n send_command(args)\n end", "def filter_attempt_hash( hash, threshold = 1 )\n keepers = {}\n hash.each do |k,v|\n keepers[k] = v if v.length >= threshold\n end\n keepers\nend", "def truncate(text, *args)\n options = args.extract_options!\n unless args.empty?\n options[:length] = args[0] || 30\n options[:omission] = args[1] || \"...\"\n end\n options.reverse_merge!(:length => 30, :omission => \"...\")\n\n if text\n l = options[:length] - options[:omission].mb_chars.length\n chars = text.mb_chars\n (chars.length > options[:length] ? chars[0...l] + options[:omission] : text).to_s\n end\n end", "def truncate(max, omission = '...')\n (length > max ? self[0...max] + omission : self)\n end", "def truncate_index(options = {})\n truncate(\n options[:value].join(I18n.t('support.array.words_connector')),\n length: INDEX_TRUNCATION_VALUE,\n omission: I18n.t('meta.search.index.truncated_field'),\n escape: false\n )\n end", "def string_trunc(string, length=30)\n string.length < length ? string : string[0..length] + '...'\n end", "def scrub_dictionary(dictionary)\n dictionary.each do |word|\n word.downcase\n unless word.length >= 5 && word.length <= 12\n dictionary.delete(word)\n end\n end\n end", "def truncate_default(str)\n return str unless str.kind_of? String\n str.sub!(/^'(.*)'$/m,'\\1')\n str = \"#{str[0..10]}...\" if str.size > 10\n str.inspect\n end", "def truncate(length)\n #This is a stub, used for indexing\n end", "def truncate\n @text.truncate_words(@word_num, omission: \"#{@cut_off}\")\n end", "def truncate(string, max)\n return string.size > max ? \"#{string[0...max]}...\" : string\nend", "def chopped_valve_note\n if !self.valve_note.blank? && self.valve_note.length > 200\n return self.valve_note[0..200] + \"...\"\n end\n return self.valve_note\n end", "def user_passion(passion)\n unless passion.blank?\n if passion.size > 17 \n return passion.slice(0,15)+\"...\" \nelse\n return passion\n end \nend\nend", "def truncate( text, num_words = 6, truncate_string = \"...\" )\n if text.nil? then return end\n arr = text.split( ' ' )\n arr.length > num_words ? arr[ 0...num_words ].join( ' ' ) + truncate_string : text\nend", "def rekey_limit=(_arg0); end", "def soft_truncate(string, length, soft_limit=nil)\n return '' unless string\n string.strip!\n return string if string.length <= length\n firstpart = string[0..(length-1)]\n afterpart = string[length..-1]\n does_not_start_with_whitespace = afterpart[/^\\S/]\n afterpart.strip!\n return firstpart if afterpart.empty?\n return firstpart << ' ...' unless soft_limit && does_not_start_with_whitespace\n afterword = afterpart[/(\\S+)/][0..(soft_limit-1)]\n afterword << ' ...' if afterpart.length > afterword.length\n firstpart << afterword\n end", "def max_length=(new_max_length)\n @max_length = new_max_length\n chars = @text.scan(/./m)\n @text = chars[0, @max_length].join if chars.size > @max_length\n self.cursor_move_to_end if @cursor_position > chars.size\n end", "def truncate_index(options = {})\n truncate(\n options[:value].join(I18n.t('support.array.two_words_connector')),\n length: INDEX_TRUNCATION_VALUE,\n omission: I18n.t('search.index.truncated_field')\n )\n end", "def truncate(*fields, length:, strip_whitespaces: true)\n strip(*fields) if strip_whitespaces\n sanitize(*fields) { |value| value[0...length] }\n strip(*fields) if strip_whitespaces\n end", "def truncate(*args)\n i=args[0]\n limit=args[1].to_i\n begin\n if i.split(\"\").size > limit\n k=0\n s=''\n for j in i.split(\"\")\n if k.to_i<limit\n s=s+j\n end\n k+=1\n end\n return s=s+'..'\n else\n return i\n end\n rescue Exception=>e\n puts \"DEBUG :: ERROR :: AdminXMLBuilder Component > truncate Action. Exception is #{e.to_s}\"\n return i\n end\n end", "def truncate(max_length)\n output = deparse(@tree)\n\n # Early exit if we're already below the max length\n return output if output.size <= max_length\n\n truncations = find_possible_truncations\n\n # Truncate the deepest possible truncation that is the longest first\n truncations.sort_by! { |t| [-t.location.size, -t.length] }\n\n tree = deep_dup(@tree)\n truncations.each do |truncation|\n next if truncation.length < 3\n\n find_tree_location(tree, truncation.location) do |expr, k|\n expr[k] = { A_TRUNCATED => nil }\n expr[k] = [expr[k]] if truncation.is_array\n end\n\n output = deparse(tree)\n return output if output.size <= max_length\n end\n\n # We couldn't do a proper smart truncation, so we need a hard cut-off\n output[0..max_length - 4] + '...'\n end", "def restrict_msg_size\n if message.length > restriction\n message = message[0...restriction]\n end\n return message \n end", "def truncate(truncate_at, options = {})\n return dup unless length > truncate_at\n\n options[:omission] ||= '...'\n length_with_room_for_omission = truncate_at - options[:omission].length\n stop = \\\n if options[:separator]\n rindex(options[:separator], length_with_room_for_omission) || length_with_room_for_omission\n else\n length_with_room_for_omission\n end\n\n self[0...stop] + options[:omission]\n end", "def truncate_id(id)\n return id unless id && id.size == 32\n id[16..-1]\n end", "def trim_to_word( max_length )\n string = self\n if string.length > max_length\n string = string[0..max_length-4]\n while string[-1,1] =~ /[\\w]/ && string.length > 1\n string = string[0..string.length-2]\n end\n string += \"...\"\n end\n string\n end", "def truncate(s, truncate_at, options = {})\r\n return s unless s.length > truncate_at\r\n omission = options[:omission] || '...'\r\n with_extra_room = truncate_at - omission.length\r\n stop = \\\r\n if options[:separator]\r\n rindex(options[:separator], with_extra_room) || with_extra_room\r\n else\r\n with_extra_room\r\n end\r\n \"#{s[0, stop]}#{omission}\"\r\n end", "def shortened_string(string)\n string[0, 100] << \"...\" unless string.length < 100\n end", "def truncate(truncate_at, options = {})\n return dup unless length > truncate_at\n\n omission = options[:omission] || '...'\n length_with_room_for_omission = truncate_at - omission.length\n stop = \\\n if options[:separator]\n rindex(options[:separator], length_with_room_for_omission) || length_with_room_for_omission\n else\n length_with_room_for_omission\n end\n\n \"#{self[0, stop]}#{omission}\"\n end", "def truncate(s, truncate_at, options = {})\n return s unless s.length > truncate_at\n omission = options[:omission] || '...'\n with_extra_room = truncate_at - omission.length\n stop = \\\n if options[:separator]\n rindex(options[:separator], with_extra_room) || with_extra_room\n else\n with_extra_room\n end\n \"#{s[0, stop]}#{omission}\"\n end", "def truncate(truncate_at, options = {})\n return dup unless length > truncate_at\n\n omission = options[:omission] || '...'\n length_with_room_for_omission = truncate_at - omission.length\n stop =\n if options[:separator]\n rindex(options[:separator], length_with_room_for_omission) || length_with_room_for_omission\n else\n length_with_room_for_omission\n end\n\n \"#{self[0, stop]}#{omission}\"\n end", "def truncate( text, num_words = 6, truncate_string = \" [...]\" )\n if text.nil? then return end\n arr = text.split( ' ' )\n arr.length > num_words ? arr[ 0...num_words ].join( ' ' ) + truncate_string : text\nend", "def clean!\n if @keys.size > Cache.max_size\n @keys = @keys[(Cache.max_size/2)...@keys.size]\n reject! { |key, value| !@keys.include?(key) }\n end\n end" ]
[ "0.7043864", "0.6650059", "0.66317433", "0.6457402", "0.6442561", "0.63482064", "0.63448626", "0.6339948", "0.6316657", "0.62807345", "0.62536436", "0.6243715", "0.6239133", "0.62176424", "0.6201254", "0.61772496", "0.6173947", "0.6154703", "0.61207646", "0.6118617", "0.6116521", "0.6116521", "0.6116521", "0.61015254", "0.6100463", "0.60967237", "0.60960263", "0.60960263", "0.60603845", "0.6021027", "0.60125774", "0.60036474", "0.60017055", "0.5996114", "0.5992329", "0.59708416", "0.59672165", "0.5959382", "0.59591424", "0.59404266", "0.59348965", "0.592783", "0.59199965", "0.59002584", "0.58777505", "0.5874322", "0.58363265", "0.58202434", "0.58095366", "0.5788706", "0.5781575", "0.5779993", "0.57794064", "0.5767524", "0.5755331", "0.5746879", "0.574488", "0.57430506", "0.5739503", "0.5737961", "0.5728797", "0.572432", "0.5720094", "0.57195884", "0.5715961", "0.5714689", "0.5702268", "0.5701796", "0.5698843", "0.5693206", "0.5690596", "0.56894314", "0.5687011", "0.5683759", "0.5663605", "0.56622803", "0.5659532", "0.5651169", "0.56236684", "0.5613323", "0.5606766", "0.55958676", "0.5594733", "0.55935675", "0.5588853", "0.5582319", "0.5580368", "0.5580096", "0.5576595", "0.5573657", "0.5572604", "0.556614", "0.55569434", "0.55501515", "0.5544615", "0.5526082", "0.5523106", "0.55163413", "0.5515982", "0.5506671" ]
0.6032665
29
Connects to the Couchbase cluster
def build_cluster ::Couchbase::Cluster.connect( @couchbase_options[:connection_string], ::Couchbase::Options::Cluster(authenticator: ::Couchbase::PasswordAuthenticator.new( @couchbase_options[:username], @couchbase_options[:password] )) ) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def connect_cassandra\n @client = Cql::Client.connect(hosts: ['localhost'])\n @client.use('oink')\nend", "def connect\n @cluster.connect\n end", "def connect_to_cassandra\n if @client\n @client.disconnect! rescue nil\n end\n @client = nil\n\n @cassandra_servers.each do |server|\n begin\n c = ::Cassandra.new @keyspace, server\n ring = c.ring\n @client = c\n break\n rescue ThriftClient::NoServersAvailable\n @logger.warn \"Cassandra server #{server} seems to be unavailable.\"\n end\n end\n\n if @client\n @logger.info \"Connected to Cassandra: #{@client.inspect}\"\n else\n raise \"Could not connect to any server in server list: #@cassandra_servers\"\n end\n\n @client\n end", "def connect\n @lock.synchronize do\n return if @started\n @started = true\n @io_reactor.start\n hosts = @host.split(',')\n connection_futures = hosts.map { |host| connect_to_host(host) }\n @connection_ids = Future.combine(*connection_futures).get\n end\n use(@initial_keyspace) if @initial_keyspace\n self\n rescue => e\n close\n if e.is_a?(Cql::QueryError) && e.code == 0x100\n raise AuthenticationError, e.message, e.backtrace\n else\n raise\n end\n end", "def connect\n @client = Redis.new(host: @host, port: @port)\n @logger.info(\"Connecting to database #{@host}:#{@port}\")\n end", "def query_couchbase_servers\n\n couchbase_servers = Hash.new\n \n r=rightscale_server_collection 'couchbase_cluster_nodes' do\n tags [\"couchbase:cluster_ip=#{cluster_ip}\"]\n secondary_tags [\"server:uuid=*\", \"couchbase:listen_ip=*\"]\n action :nothing\n end\n r.run_action(:load)\n \n node[:server_collection]['couchbase_cluster_nodes'].to_hash.values.each do |tags|\n uuid = RightScale::Utils::Helper.get_tag_value('server:uuid', tags)\n ip = RightScale::Utils::Helper.get_tag_value('couchbase:listen_ip', tags)\n couchbase_servers[uuid] = {}\n couchbase_servers[uuid][:ip] = ip\n end\n \n couchbase_servers\n \n end", "def couchdb(options = {})\n # couchbase is available online to download, but not from a debian repository.\n # we'll need us some wget and a place to download it to (/usr/local/src)\n package 'wget', :ensure => :installed\n file '/usr/local/src',\n :ensure => :directory\n \n\n # The couchbase downloads have an architecture in them, but we can rely on Facter for this.\n arch = Facter.architecture\n arch = 'x86_64' if arch == 'amd64'\n deb_filename = \"couchbase-server-community_#{arch}_#{options[:version]}.deb\"\n # Download couchbase, like a bau5.\n exec 'download couchbase',\n :alias => \"/usr/local/src/#{deb_filename}\",\n :creates => \"/usr/local/src/#{deb_filename}\",\n :cwd => '/usr/local/src',\n :require => [package('wget'), file('/usr/local/src')],\n :command => \"wget --quiet http://c3145442.r42.cf0.rackcdn.com/#{deb_filename} --output-document=#{deb_filename}\"\n\n # With couchbase downloaded, we can use the dpkg provider to ensure the couchbase-server is installed\n package 'couchbase-server',\n :ensure => :installed,\n :provider => :dpkg,\n :source => \"/usr/local/src/#{deb_filename}\",\n :require => exec('download couchbase')\n\n # With it installed, make sure it's running.\n service 'couchbase-server',\n :ensure => :running,\n :require => package('couchbase-server')\n\n # couchbase-server works out of the box, but if any other configuration was needed, this would be a good place for it.\n end", "def couchrest_database\n @couchrest_database\n end", "def get_couch_db(creds) \n url = creds['url']\n if !url.end_with?('/')\n url = url + '/'\n end\n url = url + 'bluemix-todo'\n\n puts 'Using URL: ' + url\n #This will create the DB if it does not exist, however it will fail if you do not have permissions\n CouchRest.database!(url)\nend", "def db_connect\n database_connect_options = @options['database']\n db_connector = DatabaseConnector.new(database_connect_options)\n return db_connector.client\n end", "def cass_client\n unless @cass_client\n uri_json = ENV['CASSANDRA_URIS'] || '[\"127.0.0.1:9160\"]'\n @cassandra_uris = MultiJson.load uri_json\n\n @cass_client = ::Cassandra.new(\"Hastur\", @cassandra_uris, THRIFT_OPTIONS)\n\n # for non-production and port-forwarded ssh, there will only be one URI and it\n # should not auto-discover nodes\n if @cassandra_uris.one?\n @cass_client.disable_node_auto_discovery!\n end\n end\n @cass_client\n end", "def conn()\n @@connections ||= {}\n\n config = env_config\n\n thrift_client_options = {:timeout => RightSupport::DB::CassandraModel::DEFAULT_TIMEOUT}\n thrift_client_options.merge!({:protocol => Thrift::BinaryProtocolAccelerated})\\\n if defined? Thrift::BinaryProtocolAccelerated\n\n @@connections[self.keyspace] ||= Cassandra.new(self.keyspace, config[\"server\"], thrift_client_options)\n @@connections[self.keyspace].disable_node_auto_discovery!\n @@connections[self.keyspace]\n end", "def connect_to_database\n config = Rails.configuration.database_configuration\n host = config[Rails.env][\"host\"]\n dbname = config[Rails.env][\"database\"]\n username = config[Rails.env][\"username\"]\n password = config[Rails.env][\"password\"]\n \n client = Mysql2::Client.new(:host => host, :username => username, :password => password, :flags => Mysql2::Client::MULTI_STATEMENTS)\n \n if client.query(\"SHOW DATABASES LIKE '#{dbname}'\").count == 0\n print \"Database '#{dbname}' not found, creating...\"\n client.query(\"CREATE DATABASE #{dbname}\")\n print \"\\n\" + File.open(SETUP_FILE,\"r\").read\n client.select_db(dbname)\n client.query(File.open(SETUP_FILE,\"r\").read)\n end\n \n finalClient = Mysql2::Client.new(:host => host, :username => username, :password => password, :database => dbname)\n \n return finalClient\n \n end", "def connect\n client = Mysql2::Client.new(:host => HOST,\n :username => USERNAME,\n :password => PASSWORD,\n :database => DATABASE)\n end", "def connect\r\n client = Mysql2::Client.new(:host => \"localhost\", \r\n :database => \"school\",\r\n :username => \"root\", \r\n :password => \"password\")\r\n end", "def connect\n \n if !self.connected?\n \n # connect to the MySQL server\n \n @dbh = DBI.connect(\"DBI:Mysql:#{@dataBase}:#{@host}\", \n\t \"#{@user}\", \"#{@password}\")\n \n @connected=true\n \n end\n end", "def connection()\r\n\r\n begin\r\n db_params = {\r\n host: ENV['host'], # AWS link\r\n port: ENV['port'], # AWS port, always 5432\r\n username: ENV['username'],\r\n password: ENV['password'],\r\n database: ENV['database']\r\n }\r\n\r\n client = Mysql2::Client.new(db_params)\r\n\r\n rescue Mysql2::Error => e\r\n puts 'Exception occurred'\r\n puts e.message\r\n end\r\n\r\nend", "def bare_local_couch_database_url\n \"#{local_couch_host_url}/#{config['couchdb']['local']['database']}\"\n end", "def connect\n \n if !self.connected?\n \n # connect to the MySQL server\n @dbh = DBI.connect(\"DBI:Mysql:#{@dataBase}:#{@host}\", \n\t \"#{@user}\", \"#{@password}\")\n @connected=true\n \n end\n end", "def connect\r\n client = Mysql2::Client.new(:host => \"localhost\", \r\n :database => \"space_ship\",\r\n :username => \"root\", \r\n :password => \"password\")\r\n end", "def conn()\n @@connections ||= {}\n\n # TODO remove hidden dependency on ENV['RACK_ENV'] (maybe require config= to accept a sub hash?)\n config = @@config[ENV[\"RACK_ENV\"]]\n raise MissingConfiguration, \"CassandraModel config is missing a '#{ENV['RACK_ENV']}' section\" unless config\n\n thrift_client_options = {:timeout => RightSupport::DB::CassandraModel::DEFAULT_TIMEOUT}\n thrift_client_options.merge!({:protocol => Thrift::BinaryProtocolAccelerated})\\\n if defined? Thrift::BinaryProtocolAccelerated\n\n @@connections[self.keyspace] ||= Cassandra.new(self.keyspace, config[\"server\"], thrift_client_options)\n @@connections[self.keyspace].disable_node_auto_discovery!\n @@connections[self.keyspace]\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 connect\n @connection_manager.connect\n end", "def connect \n\t\t\tfirst_tentative = true\n\t\t\tbegin\n\t\t\t\tdatabase = ActiveOrient.database\n\t\t\t\tlogger.progname = 'OrientDB#Connect'\n\t\t\t\tr = ActiveOrient.db_pool.checkout do | conn |\n\t\t\t\t\tr = conn[\"/connect/#{database}\"].get\n\t\t\t\tend\n\t\t\t\tif r.code == 204\n\t\t\t\t\tlogger.info{\"Connected to database #{database}\"}\n\t\t\t\t\ttrue\n\t\t\t\telse\n\t\t\t\t\tlogger.error{\"Connection to database #{database} could NOT be established\"}\n\t\t\t\t\tnil\n\t\t\t\tend\n\t\t\trescue RestClient::Unauthorized => e\n\t\t\t\tif first_tentative\n\t\t\t\t\tlogger.info{\"Database #{database} NOT present --> creating\"}\n\t\t\t\t\tfirst_tentative = false\n\t\t\t\t\tcreate_database database: database\n\t\t\t\t\tretry\n\t\t\t\telse\n\t\t\t\t\tKernel.exit\n\t\t\t\tend\n\t\t\tend\n\t\tend", "def connect\n first_tentative = true\n begin\n\tdatabase = ActiveOrient.database\n logger.progname = 'OrientDB#Connect'\n r = @res[\"/connect/#{database}\"].get\n if r.code == 204\n \t logger.info{\"Connected to database #{database}\"}\n \t true\n \t else\n \t logger.error{\"Connection to database #{database} could NOT be established\"}\n \t nil\n \t end\n rescue RestClient::Unauthorized => e\n if first_tentative\n \t logger.info{\"Database #{database} NOT present --> creating\"}\n \t first_tentative = false\n \t create_database database: database\n \t retry\n else\n \t Kernel.exit\n end\n end\n end", "def connect_database\n\n\t\t@db = Redis.new\n\n\t\t@db = Redis.connect(\n\t\t\t:db => \"#{Settings.redis.db}\",\n\t\t\t:host => \"#{Settings.redis.host}\",\n\t\t\t:port => Settings.redis.port,\n\t\t\t:password => Settings.redis.password\n\t\t)\n\t\t\n\tend", "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 connect_to_database(validate_schema)\n require 'cloud_crowd/models'\n CloudCrowd.configure_database(\"#{@options[:config_path]}/database.yml\", validate_schema)\n end", "def connect\n connection.connect\n nil\n end", "def connect\n ::Informix.connect(@opts[:database], @opts[:user], @opts[:password])\n end", "def configure(config = {})\n config[:zookeeper_quorum] ||= 'localhost'\n config[:zookeeper_client_port] ||= '2181'\n\n @config = config\n\n init_connection\n end", "def connect\n end", "def connectDB\n \t#config = YAML.load_file( '/home/ubuntu/DB-Performance-Testing/config/db.yml' )['DB2']\n config = YAML.load_file( @@path + '../config/db.yml' )['DB2']\n\t cstring = \"DATABASE=#{config['db']};HOSTNAME=#{config['hostname']};\"\n\t cstring += \"PORT=#{config['port']};PROTOCOL=#{config['protocol']};UID=#{config['uid']};PWD=#{config['pwd']};\"\n\t @conn = IBM_DB.connect(cstring,\"\",\"\")\n end", "def connect\n #@connection = Mongo::Connection.new(, @port, :pool_size => 5)\n @connection = Mongo::Client.new([ \"#{@host}:#{@port}\" ], :database => @dbname)\n @collection = @connection[@collname]\n @collection.drop\n @collection.indexes.create_one({ loc: \"2dsphere\" }, { min: -200, max: 200 })\n end", "def dbCon(host, user, pass, port, database)\n\n\t@host = host\n\t@user = user\n\t@pass = pass\n\t@port = port\n\t@database = database\n\n\tdb = Mysql2::Client.new(\n\t\t:host => @host,\n\t\t:username => @user,\n\t\t:password => @pass,\n\t\t:port => @port,\n\t\t:database => @database\n\t\t)\n\n\tdb\nend", "def connect\n PG::Connection.new(:host => host, :port => port, :user => user, :password => password, :sslmode => sslmode, :dbname => dbname)\n end", "def connect\n @comm.connect(opts.user, opts.password, opts.server)\n end", "def connect\n\tend", "def Connect()\n client = Mongo::Client.new([ \"#{$host}:27017\" ], :database => $database)\n $messages.push(\"Connecting to MongoDB\")\n $db = client.database\n $collection = client[:users] #Selecting users collection\n $messages.push(\"Selecting user collection\")\n end", "def goo_connect\n port ||= @settings.goo_port\n host ||= @settings.goo_host\n\n begin\n Goo.use_cache = @settings.enable_goo_cache\n Goo.configure do |conf|\n conf.queries_debug(@settings.queries_debug)\n conf.add_sparql_backend(:main, query: \"http://#{host}:#{port}/sparql/\",\n data: \"http://#{host}:#{port}/data/\",\n update: \"http://#{host}:#{port}/update/\",\n options: { rules: :NONE })\n\n conf.add_search_backend(:main, service: @settings.search_server_url)\n conf.add_redis_backend(host: @settings.goo_redis_host,\n port: @settings.goo_redis_port)\n end\n rescue Exception => e\n abort(\"EXITING: Cannot connect to triplestore and/or search server:\\n #{e}\\n#{e.backtrace.join(\"\\n\")}\")\n end\n end", "def connect; end", "def connect\n @redis ||= create\n end", "def connect\n @connection.create\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 connect\n change_uris(@seed_uri)\n cache_machines\n change_uris(@machines_cache.first)\n self\n rescue AllNodesDownError => e\n raise ConnectionError, e.message, e.backtrace\n end", "def connect\n @connection_pool.get_connection\n end", "def connect\n PG::Connection.new(:host => host, :port => port, :user => user, :password => password, :dbname => dbname)\n end", "def configure_database\n\tbegin\n\t @client = Mysql2::Client.new(:host => \"localhost\", :username => \"root\", :password => \"qburst\", :database => \"ruby\")\n\trescue Exception=>e\n\t puts e.message\n\tend\n end", "def connect!; end", "def connect!; end", "def connect_for( path, &block )\n zone = zone_for_path( path ) \n info = config[zone]\n raise \"Unable to find zone info in config file for zone `#{zone}\" unless info\n raise \"Check your config. Unable to find `host information\" unless info['host']\n raise \"Check your config. Unable to find `port information\" unless info['port']\n\n con = nil \n begin\n con = Mongo::Connection.new( info['host'], info['port'], { :slave_ok => true } )\n \n if info['user'] and info['password']\n con.db( 'admin' ).authenticate( info['user'], info['password'] )\n end\n rescue => boom\n raise \"MongoDB connection failed for `#{info['host']}:#{info['post']}\"\n end \n \n yield con \n con.close()\n end", "def initialize(host = \"localhost\", port = 1717, username = \"admin\", password = \"admin\", environment = \"\", **kwargs)\n size = kwargs.fetch(:size, @@default_size)\n timeout = kwargs.fetch(:timeout, @@default_timeout)\n super(size:size, timeout:timeout) do\n Concourse.connect(host:host, port:port, username:username, password:password, environment:environment, **kwargs)\n end\n end", "def getCounchDBData \r\n url = URI.parse(\"http://citivan.iriscouch.com/_utils\") \r\n server = Couch::Server.new(url.host, url.port) \r\n res = server.get(\"/sms/currentUsers\") \r\n json = res.body \r\n json = JSON.parse(json) \r\nend", "def connection(host)\n RobotArmy::GateKeeper.shared_instance.connect(host)\n end", "def tend_connection\n if @tend_connection.nil? || @tend_connection.closed?\n @tend_connection = Cluster::CreateConnection.(cluster, host)\n end\n @tend_connection\n end", "def couchdb_get(urn, host = '127.0.0.1', options = @@default_options)\n query_couchdb(urn, 'GET', host, options)\n end", "def get_couch_db(url)\n if !url.end_with?('/')\n url = url + '/'\n end\n url = url + 'mydb'\n\n puts 'Using URL: ' + url\n #This will create the DB if it does not exist, however it will fail if you do not have permissions\n CouchRest.database!(url)\n end", "def mysql_api_connect(environment, rootuser=false)\n db_creds = Hash.new\n # Returns a root only connection if \"root\" string is defined in lieu of environment\n if environment == \"root\"\n chef_api_connect.search.query(:mysql, 'id:mysqlserver').rows.each do |db_item|\n db_creds[:user] = db_item['raw_data']['mysqladminuser']\n db_creds[:pass] = db_item['raw_data']['mysqladminpass']\n # NOTE: Workaround to remove host port concatenation in mysql data bag\n db_creds[:host] = \"#{db_item['raw_data']['mysqlwrite']}\".rpartition(':3306')[0]\n end\n connection = Mysql2::Client.new(:host => db_creds[:host],\n :username => db_creds[:user],\n :password => db_creds[:pass],\n :flags => Mysql2::Client::MULTI_STATEMENTS)\n return connection\n else\n # acquire root user credentials from data bag (if specified)\n if rootuser == true\n chef_api_connect.search.query(:mysql, 'id:mysqlserver').rows.each do |db_item|\n db_creds[:user] = db_item['raw_data']['mysqladminuser']\n db_creds[:pass] = db_item['raw_data']['mysqladminpass']\n end\n end\n chef_api_connect.search.query(:environment, \"name:#{environment}\").rows.each do |envitem|\n # acquire non-root user credentials from environment\n if rootuser == false\n db_creds[:user] = envitem['default_attributes']['af']['activfoundbuser']\n db_creds[:pass] = envitem['default_attributes']['af']['activfoundbpass']\n end\n db_creds[:host] = envitem['default_attributes']['database']['dbservername']\n db_creds[:schema] = envitem['default_attributes']['fconfig']['founconfigdb']\n end\n fconfig = db_creds[:schema]\n connection = Mysql2::Client.new(:host => db_creds[:host],\n :username => db_creds[:user],\n :password => db_creds[:pass],\n :flags => Mysql2::Client::MULTI_STATEMENTS)\n return connection, fconfig\n end\nend", "def connect\r\n db = Sequel.connect(:adapter => 'mysql',\r\n :host => 'localhost', \r\n :user => 'root', \r\n :password => 'password',\r\n :database => 'space_ship')\r\n \r\n \r\n #client = Mysql2::Client.new(:host => \"localhost\", \r\n # :database => \"space_ship\",\r\n # :username => \"root\", \r\n # :password => \"password\")\r\n end", "def db\n return @client if @client\n @client = Mysql2::Client.new(\n host: 'localhost',\n port: nil,\n username: 'root',\n password: nil,\n database: 'isucon5q',\n reconnect: true,\n )\n @client.query_options.merge!(symbolize_keys: true)\n @client\nend", "def connect!\n end", "def run\n connect\n end", "def connect()\n\t\t\t# Check queen(s) for peer list\n\n\t\t\t# Connect to peers\n\t\tend", "def connect_to_database\n # If no input parameters are defined then read the database params\n # from the command line or the default ones\n unless @db_params then self.database_params= DB_PARAMS end\n\n PGconn.connect( @db_params[:host],\n @db_params[:port],\n @db_params[:options],\n @db_params[:tty],\n @db_params[:dbname],\n @db_params[:login],\n @db_params[:password] )\n end", "def connect\n @connection.open\n end", "def connection\n threaded[:connection] || raise('Please authenticate with GoodData.connect first')\n end", "def initialize(keyspace = \"felix\", replication_factor = 1, init_file = \"init\", options={})\n ## Given the options, connect to the Cassandra server\n @client = Cql::Client.connect(options)\n\n ## Check to see if keyspace exists, if it does, drop it and recreate!\n result = @client.execute(\"SELECT * FROM system.schema_keyspaces WHERE keyspace_name='#{keyspace}'\", :all)\n unless result.empty?\n @client.execute(\"DROP KEYSPACE #{keyspace}\")\n end\n\n ## Create keyspace\n @client.execute(\"CREATE KEYSPACE #{keyspace}\n WITH replication = {\n 'class': 'SimpleStrategy',\n 'replication_factor': #{replication_factor}\n }\")\n ## Use it\n @client.use(keyspace)\n\n ## Initialize from file, init, unless overided.\n initialize_schema(init_file)\n\n end", "def connect\n if (@type == \"db2\")\n @config\n Models::Databases::SiteDatabase::Base.setup_connection(@config)\n elsif (@type == \"bops\")\n @config\n Models::Databases::Bops::Base.setup_connection(@config)\n else\n Models::Databases::Dyces::Base.setup_connection(@config)\n end\n\n @connection = @type\n\n Log.instance.debug \"Connected to #@db_url\"\n self\n end", "def connect_to_server\n @service.connect(connect_settings)\n end", "def connect(host, name, user, pass)\n str = sprintf('DBI:Mysql:database=%s;host=%s;flag=%s', \n name, host, 131072)\n begin\n dbh = DBI.connect(str, user, pass)\n rescue => ex\n \n puts sprintf(\"[%s] Failed to connect to '%s' with username '%s'\", Time.new, str, user) + \n \"\\n\\t\" + ex.inspect + \n \"\\n\\t\" + ex.backtrace.join(\"\\n\\t\") \n exit\n \n end\n end", "def connect\n url = ENV['CIDB_DATABASE_URL']\n fatal! 'CIDB_DATABASE_URL not set' if url.nil? || url.empty?\n\n CIDB.connect\n rescue NoMethodError\n fatal! 'CIDB_DATABASE_URL malformed, no adapter name'\n rescue Sequel::Error => err\n fatal! \"Database connection failed (#{err.class}): #{err}\"\n end", "def establish_connection\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 connect\n Drone::Client.connect\n end", "def startup\n Mysql2::Client.new(host: '127.0.0.1', username: 'root', port: '3307', database: 'management_gateway_development')\nend", "def Connect()\n client = Mongo::Client.new([ \"#{$host}:27017\" ], :database => $database)\n $messages.append(\"Connecting to MongoDB\")\n $db = client.database\n $collection = client[:users] #Selecting users collection\n $messages.append(\"Selecting user collection\")\nend", "def query_couchdb(urn, verb, host = '127.0.0.1', options = @@default_options)\n secure = options[:secure] || @@default_options[:secure]\n body = options[:body] || @@default_options[:body]\n\n ## Set scheme\n scheme = secure ? 'https' : 'http'\n ## build uri\n url = \"#{scheme}://#{host}\"\n uri = URI.join(url, urn)\n Chef::Log.debug(\"query_couchdb built uri: #{uri}\")\n\n http = Net::HTTP.new(uri.host, options[:port])\n http.use_ssl = secure\n unless options[:verify_ssl] || @@default_options[:verify_ssl]\n Chef::Log.debug('verify_ssl is false setting verify to none')\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n if body.empty?\n retry_request(http, verb.upcase, uri.request_uri)\n else\n if body.is_a? Hash\n headers = { 'Content-Type' => 'application/json' }\n body = JSON.generate(body)\n else\n body = \"\\\"#{body}\\\"\"\n end\n retry_request(http, verb.upcase, uri.request_uri, body, headers)\n end\n end", "def initialize(opts={})\n @keyspace = opts[:keyspace] || \"Nodule\"\n\n @temp = Nodule::Tempfile.new(:directory => true, :prefix => \"nodule-cassandra\")\n @tmp = @temp.file\n\n @data = File.join(@tmp, 'data')\n @caches = File.join(@tmp, 'caches')\n @commit = File.join(@tmp, 'commitlogs')\n\n @host = \"127.0.0.1\" # will support 127.0.0.2 someday\n @jmx_port = Nodule::Util.random_tcp_port\n @rpc_port = Nodule::Util.random_tcp_port\n @storage_port = Nodule::Util.random_tcp_port\n @ssl_storage_port = Nodule::Util.random_tcp_port\n\n @casshome = \"#{@tmp}/#{CASSANDRA}\"\n @pidfile = \"#{@casshome}/cassandra.pid\"\n @cassbin = \"#{@casshome}/bin\"\n @command = [\"#{@cassbin}/cassandra\", \"-f\", \"-p\", @pidfile]\n @config = \"#{@casshome}/conf/cassandra.yaml\"\n @envfile = \"#{@casshome}/conf/cassandra-env.sh\"\n @log4j = \"#{@casshome}/conf/log4j-server.properties\"\n @logfile = \"#{@tmp}/system.log\"\n\n # This handler reads STDOUT to determine when Cassandra is ready for client\n # access. Coerce the stdout option into an array as necessar so options can\n # still be passed in.\n if opts[:stdout]\n unless opts[:stdout].kind_of? Array\n opts[:stdout] = [ opts.delete(:stdout) ]\n end\n else\n opts[:stdout] = []\n end\n\n # Watch Cassandra's output to be sure when it's available, obviously, it's a bit fragile\n # but (IMO) better than sleeping or poking the TCP port.\n @mutex = Mutex.new\n @cv = ConditionVariable.new\n opts[:stdout] << proc do |item|\n @mutex.synchronize do\n @cv.signal if item =~ /Listening for thrift clients/\n end\n end\n\n super({\"CASSANDRA_HOME\" => @casshome}, *@command, opts)\n end", "def connect(*) end", "def connect\n Connection.new\n end", "def node\n return @node if @node\n Rbeapi::Client.load_config(ENV['RBEAPI_CONF']) if ENV['RBEAPI_CONF']\n connection_name = ENV['RBEAPI_CONNECTION'] || 'localhost'\n @node = Rbeapi::Client.connect_to(connection_name)\n end", "def connection\n @connection.connect\n end", "def connect\n nodes.each do |k,v|\n rs_storage = RSpec.configuration.rs_storage[:nodes][k]\n raise RuntimeError, \"No internal storage for node #{k}\" if rs_storage.nil?\n\n ipaddress = rs_storage[:ipaddress]\n raise RuntimeError, \"No ipaddress provided from launch phase for node #{k}\" if ipaddress.nil?\n\n chan = ssh_connect(:host => k, :user => 'root', :net_ssh_options => {\n :keys => vmconf[:ssh_keys].split(\":\"),\n :host_name => ipaddress,\n })\n RSpec.configuration.rs_storage[:nodes][k][:ssh] = chan\n end\n\n nil\n end", "def connect(options={}, &block)\n case options\n when String\n options = parse_url(options)\n when nil\n options = {}\n end\n options[:host] ||= \"127.0.0.1\"\n options[:port] ||= 6379\n if options[:sentinels].is_a?(Array) && options[:sentinels].length > 0\n connect_via_sentinel(options, &block)\n else\n connect_direct(options, &block)\n end\n end", "def dyna_connect\n puts \"\\n\\n *** CONNECT ** \\n\\n\"\n # TODO Add some checking in here to make sure the given config even exists in the db.yml file.\n # Also make sure its not nil, etc. If validation fails forward to a common error page and\n # throw error.\n if ! session[:cur_company].nil?\n logger.info \"\\n>** Connecting to customer db: #{session[:cur_company].db_config} **<\\n\\n\"\n # for script_console copy this in there: ActiveRecord::Base.establish_connection('klaratee_development_default' )\n return ActiveRecord::Base.establish_connection( session[:cur_company].db_config )\n end\n \n false\n end", "def connect\n @conn = PG.connect(\n :dbname => 'HackerNewsAppDB1',\n :user => 'paul',\n :password => 'password')\n end", "def connect_using conn\n @connection = conn\n end", "def connection\n #@pool ||= {}\n #@pool[Thread.current] ||= Mongoc::Client.new(host, port, :pool_size=>@pool_size)\n #Mongoc::Client.new(host, port, {})\n Thread.current[:_mongo] ||= Mongoc::Client.new(host, port, {})\n end", "def connection; end", "def connection; end", "def connection; end", "def connection; end", "def connection; end", "def connection; end", "def connection; end", "def connection; end", "def connection\n @db = Connection.client\nend", "def chef_api_connect\n # Configured with retries as chef-api occasionally fails on connection\n tries ||= 60\n chefcreds = chef_credentials\n connection = ChefAPI::Connection.new(\n client: chefcreds['c_node'],\n key: chefcreds['c_key'],\n ssl_verify: false,\n endpoint: chefcreds['c_uri']\n )\n return connection\nrescue => e\n puts \"Chef API Timeout, retrying...\"\n retry unless (tries -= 1).zero?\nend", "def connection(environment)\n unless @connection_pool\n pool_config = environment.connection_pool_configuration\n if pool_config.nil?\n pool_config = {\n :size => 1,\n :timeout => 10\n }\n end\n @connection_pool ||= ::ConnectionPool.new(pool_config) do\n environment.create_connection(:connect_to_keyspace => true)\n end\n end\n @connection_pool\n end", "def establish_master_connection\n establish_connection(configuration.merge(\n \"database\" => \"postgres\",\n \"password\" => su_password,\n \"schema_search_path\" => \"public\",\n \"username\" => su_username\n ))\n end" ]
[ "0.69977397", "0.6931105", "0.64401364", "0.6336397", "0.6302618", "0.62917763", "0.62834406", "0.6269196", "0.6245404", "0.61693275", "0.6110907", "0.60501176", "0.59861284", "0.5985573", "0.5923251", "0.59085757", "0.5895992", "0.5877469", "0.5876451", "0.58695453", "0.58463156", "0.58306724", "0.57480204", "0.5747926", "0.57454884", "0.5743601", "0.57105327", "0.5702264", "0.5680586", "0.56732404", "0.5662904", "0.56589097", "0.56486857", "0.5646899", "0.5629743", "0.5627319", "0.56189334", "0.5616443", "0.5610752", "0.5607551", "0.56008804", "0.5578695", "0.5558388", "0.5558086", "0.5544726", "0.5532908", "0.5523211", "0.5520027", "0.5512239", "0.5512239", "0.55032045", "0.5501531", "0.54856104", "0.5461198", "0.54610735", "0.5453483", "0.54507154", "0.5446367", "0.54304326", "0.54281425", "0.541859", "0.54151976", "0.5397078", "0.5393635", "0.5392335", "0.53803223", "0.5378435", "0.537748", "0.537092", "0.5357896", "0.535333", "0.5351176", "0.5344384", "0.53391737", "0.533033", "0.532514", "0.5312097", "0.5304362", "0.5297222", "0.52934396", "0.52934206", "0.528971", "0.5289546", "0.5275409", "0.5274847", "0.52712476", "0.52673405", "0.52603257", "0.52479726", "0.52479726", "0.52479726", "0.52479726", "0.52479726", "0.52479726", "0.52479726", "0.52479726", "0.52477145", "0.52429265", "0.5240627", "0.52351147" ]
0.76647305
0
Connects to the Couchbase cluster, opens specified bucket and returns collection object.
def build_collection bucket = cluster.bucket(@couchbase_options[:bucket]) if @couchbase_options[:scope] && @couchbase_options[:collection] bucket.scope(@couchbase_options[:scope]).collection(@couchbase_options[:collection]) else bucket.default_collection end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_cluster\n ::Couchbase::Cluster.connect(\n @couchbase_options[:connection_string],\n ::Couchbase::Options::Cluster(authenticator: ::Couchbase::PasswordAuthenticator.new(\n @couchbase_options[:username], @couchbase_options[:password]\n ))\n )\n end", "def bucket\n @bucket ||= connection.directories.get(@bucket_name, :prefix => @prefix)\n end", "def get_couch_db(creds) \n url = creds['url']\n if !url.end_with?('/')\n url = url + '/'\n end\n url = url + 'bluemix-todo'\n\n puts 'Using URL: ' + url\n #This will create the DB if it does not exist, however it will fail if you do not have permissions\n CouchRest.database!(url)\nend", "def bucket\n @bucket ||= begin\n bucket = config[:bucket]\n connection.buckets.create(bucket) unless connection.buckets[bucket].exists?\n connection.buckets[bucket]\n end\n end", "def collection(collection_name)\n Collection.new(@backend, @bucket_name, @name, collection_name)\n end", "def initialize(bucket, options = {})\n raise BlankBucketException.new unless bucket\n @options = options\n\n connect!(bucket)\n end", "def bucket(bucket_id)\n @server.bucket(bucket_id)\n end", "def bucket\n begin\n # Find existing bucket:\n bucket = service.buckets.find(s3_bucket)\n rescue ::S3::Error::NoSuchBucket => e\n # Apparently the bucket doesn't exist yet, so create a new one:\n bucket = service.buckets.build(s3_bucket)\n bucket.save\n end\n bucket.retrieve\n end", "def get_bucket(name)\n Bucket.new({:name => name}, @protocol)\n end", "def initialize bucket #:nodoc:\n @bucket = bucket.name\n @connection = bucket.connection\n @owners = nil\n @writers = nil\n @readers = nil\n end", "def initialize bucket #:nodoc:\n @bucket = bucket.name\n @connection = bucket.connection\n @owners = nil\n @writers = nil\n @readers = nil\n end", "def bucket(bucket)\n @buckets[bucket] = RiakOdm::Bucket.new(self, bucket) unless @buckets.has_key? bucket\n @buckets[bucket]\n end", "def bucket bucket_name\n resp = connection.get_bucket bucket_name\n if resp.success?\n Bucket.from_gapi resp.data, connection\n else\n return nil if resp.data[\"error\"][\"code\"] == 404\n fail ApiError.from_response(resp)\n end\n end", "def initialize( connection_string, connection_options = {} )\n\n #Calling super would be inappropriate here \n @connection_string = connection_string\n @connection_options = connection_options\n\n @buckets = { }\n\n end", "def cfcreate(bucket) # s3://BUCKET\n send_command \"cfcreate\", bucket\n end", "def get_collins_client\n user = evie['collins']['user']\n pass = evie['collins']['pass'] \n host = evie['collins']['host']\n \n return Collins::Client.new config = {\n username: user,\n password: pass,\n host: host}\n end", "def establish_s3_connection\n @s3_connection = AWS::S3::Base.establish_connection!(get_keys)\nend", "def []( bucket_name, opts = {} )\n jbucket = @jservice.get_bucket( bucket_name )\n S3Bucket.new( self, jbucket, opts )\n end", "def couchdb_get(urn, host = '127.0.0.1', options = @@default_options)\n query_couchdb(urn, 'GET', host, options)\n end", "def bucket\n @bucket or raise NoBucketSpecified\n end", "def get_couch_db(url)\n if !url.end_with?('/')\n url = url + '/'\n end\n url = url + 'mydb'\n\n puts 'Using URL: ' + url\n #This will create the DB if it does not exist, however it will fail if you do not have permissions\n CouchRest.database!(url)\n end", "def initialize(bucket_name, options={})\n AWS::S3::Base.establish_connection!(options[:s3])\n @bucket_name = bucket_name\n @options = options\n @options[:basedir] ||= 'data'\n load_index\n end", "def newBucket\n innerNewBucket \n end", "def bucket!(bucket)\n request = Riakpb::RpbGetBucketReq.new(:bucket => bucket)\n response = rpc.request(\n Util::MessageCode::GET_BUCKET_REQUEST,\n request\n )\n @bucket_cache[bucket].load(response)\n end", "def couchdb(options = {})\n # couchbase is available online to download, but not from a debian repository.\n # we'll need us some wget and a place to download it to (/usr/local/src)\n package 'wget', :ensure => :installed\n file '/usr/local/src',\n :ensure => :directory\n \n\n # The couchbase downloads have an architecture in them, but we can rely on Facter for this.\n arch = Facter.architecture\n arch = 'x86_64' if arch == 'amd64'\n deb_filename = \"couchbase-server-community_#{arch}_#{options[:version]}.deb\"\n # Download couchbase, like a bau5.\n exec 'download couchbase',\n :alias => \"/usr/local/src/#{deb_filename}\",\n :creates => \"/usr/local/src/#{deb_filename}\",\n :cwd => '/usr/local/src',\n :require => [package('wget'), file('/usr/local/src')],\n :command => \"wget --quiet http://c3145442.r42.cf0.rackcdn.com/#{deb_filename} --output-document=#{deb_filename}\"\n\n # With couchbase downloaded, we can use the dpkg provider to ensure the couchbase-server is installed\n package 'couchbase-server',\n :ensure => :installed,\n :provider => :dpkg,\n :source => \"/usr/local/src/#{deb_filename}\",\n :require => exec('download couchbase')\n\n # With it installed, make sure it's running.\n service 'couchbase-server',\n :ensure => :running,\n :require => package('couchbase-server')\n\n # couchbase-server works out of the box, but if any other configuration was needed, this would be a good place for it.\n end", "def get_bucket!(bucket_name, **opts)\n bucket = gcs_client.bucket(bucket_name, **opts)\n return bucket if bucket\n raise BucketNotFoundError.new(\"Bucket \\\"#{bucket_name}\\\" not found\")\n end", "def bucket(name, options={})\n options.assert_valid_keys(:keys, :props)\n response = http.get(200, prefix, escape(name), {:keys => false}.merge(options), {})\n Bucket.new(self, name).load(response)\n end", "def object!\n connection.get(\"/#{URI.escape(@key)}\", @bucket_name)\n end", "def find_bucket bucket_name\n resp = connection.get_bucket bucket_name\n if resp.success?\n Bucket.from_gapi resp.data, connection\n else\n return nil if resp.data[\"error\"][\"code\"] == 404\n fail ApiError.from_response(resp)\n end\n end", "def find_bucket bucket_name\n resp = connection.get_bucket bucket_name\n if resp.success?\n Bucket.from_gapi resp.data, connection\n else\n return nil if resp.data[\"error\"][\"code\"] == 404\n fail ApiError.from_response(resp)\n end\n end", "def get_bucket(bucket_name, options={})\n resp = get(bucket_name, '/', options)\n resp_obj = Crack::XML.parse(resp.body)\n if resp.code == \"200\"\n resp_obj[:success] = true\n resp_obj[:bucket_name] = bucket_name\n resp_obj[:message] = \"Bucket retrieved successfully\"\n contents = resp_obj[\"ListBucketResult\"][\"Contents\"] ? Array.new : nil\n resp_obj[\"ListBucketResult\"][\"Contents\"].is_a?(Array) ? \\\n (contents = resp_obj[\"ListBucketResult\"][\"Contents\"]) : \\\n (contents[0] = resp_obj[\"ListBucketResult\"][\"Contents\"]) unless contents.nil?\n resp_obj[:contents] = contents\n resp_obj[:raw] = Crack::XML.parse(resp.body)\n resp_obj.each_key {|key| resp_obj.delete(key) unless [:success, :bucket_name, :message, :contents, :raw].include?(key) }\n\n else\n resp_obj[:success] = false\n resp_obj[:bucket_name] = bucket_name\n resp_obj[:message] = resp_obj[\"Error\"][\"Message\"]\n resp_obj[:contents] = nil\n resp_obj[:code] = resp_obj[\"Error\"][\"Code\"]\n resp_obj[:raw] = Crack::XML.parse(resp.body)\n resp_obj.each_key {|key| resp_obj.delete(key) unless [:success, :bucket_name, :message, :contents, :code, :raw].include?(key) }\n\n end\n return resp_obj\n end", "def couchrest_database\n @couchrest_database\n end", "def get_s3_bucket_object(bucket_name)\n resource.bucket(bucket_name)\n end", "def bucket\n @gapi[\"bucket\"]\n end", "def s3_bucket(name)\n s3_client.buckets[name]\n end", "def buckets\n resp = connection.list_buckets\n if resp.success?\n resp.data[\"items\"].map do |gapi_object|\n Bucket.from_gapi gapi_object, connection\n end\n else\n fail ApiError.from_response(resp)\n end\n end", "def client\n key, secret = credentials\n @client ||= Cloudkick::Base.new(key, secret)\n end", "def client\n @client ||= \\\n V2::BigtableClient.new(\n credentials: channel(V2::BigtableClient::SERVICE_ADDRESS),\n timeout: timeout,\n client_config: client_config,\n lib_name: \"gccl\",\n lib_version: Google::Cloud::Bigtable::VERSION\n )\n end", "def bucket; ::AWS::S3.new( { :secure => false } ).buckets[DC::SECRETS['bucket']]; end", "def s3_bucket(bucket_name)\n S3Bucket.new(bucket_name)\n end", "def create_bucket(bucket_name)\n send_request(PUT, bucket_name)\n end", "def bucket=(bucket)\n @bucket = bucket\n self\n end", "def create_bucket bucket_name\n resp = connection.insert_bucket bucket_name\n if resp.success?\n Bucket.from_gapi resp.data, connection\n else\n fail ApiError.from_response(resp)\n end\n end", "def bucket\n Replication::IbmProvider.new(\n region: Settings.zip_endpoints.ibm_us_south.region,\n access_key_id: Settings.zip_endpoints.ibm_us_south.access_key_id,\n secret_access_key: Settings.zip_endpoints.ibm_us_south.secret_access_key\n ).bucket\n end", "def find_bucket(bucket)\n begin\n Bucket.find(bucket) \n rescue NoSuchBucket\n S3.create_bucket(bucket)\n find_bucket(bucket)\n end\n end", "def upload_bucket\n ::AWS::S3.new( { :secure => false } ).buckets['s3.documentcloud.org']\n end", "def connect\n #@connection = Mongo::Connection.new(, @port, :pool_size => 5)\n @connection = Mongo::Client.new([ \"#{@host}:#{@port}\" ], :database => @dbname)\n @collection = @connection[@collname]\n @collection.drop\n @collection.indexes.create_one({ loc: \"2dsphere\" }, { min: -200, max: 200 })\n end", "def initialize(conn = 'mongodb://mongodb.local/')\n @client = Client.new conn\n end", "def [] bucket_name\n bucket_named(bucket_name)\n end", "def get_buckets\n buckets = call(CMD_GET_BUCKETS)[:buckets]\n buckets.map {|bucket| Bucket.new(bucket) }\n end", "def create_bucket( bucket_name, opts = {} )\n jbucket = JS3Bucket.new( bucket_name )\n yield jbucket if block_given?\n jbucket = @jservice.create_bucket( jbucket )\n S3Bucket.new( self, jbucket, opts )\n end", "def index_cloud_buckets_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CloudBucketsApi.index_cloud_buckets ...'\n end\n # resource path\n local_var_path = '/cloud_buckets'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?\n query_params[:'sort_by'] = @api_client.build_collection_param(opts[:'sort_by'], :pipe) if !opts[:'sort_by'].nil?\n query_params[:'id'] = opts[:'id'] if !opts[:'id'].nil?\n query_params[:'cloud_connector_id'] = opts[:'cloud_connector_id'] if !opts[:'cloud_connector_id'].nil?\n query_params[:'pool_id'] = opts[:'pool_id'] if !opts[:'pool_id'].nil?\n query_params[:'name'] = opts[:'name'] if !opts[:'name'].nil?\n query_params[:'location'] = opts[:'location'] if !opts[:'location'].nil?\n query_params[:'price'] = opts[:'price'] if !opts[:'price'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'CloudBucketCollection' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth', 'BearerAuth']\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: CloudBucketsApi#index_cloud_buckets\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def bucket_name\n returning @bucket_name do |name|\n begin\n Bucket.create(name)\n rescue => e\n #puts \"Error creating bucket: #{e}\"\n end\n end\n end", "def get_bucket(bucket_id:)\n path = '/storage/buckets/{bucketId}'\n .gsub('{bucketId}', bucket_id)\n\n if bucket_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"bucketId\"')\n end\n\n params = {\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'GET',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::Bucket\n )\n end", "def checkBucket(bucket, client)\n\tbegin\n\t\tresp = client.list_objects({ bucket: bucket })\n\trescue Aws::S3::Errors::NoSuchBucket => err\n\t\t# Catching errors case name informed is wrong\n\t\tputs \"#{err}!\" \n\t\tresp = client.list_buckets\n\t\t# Informe current buckets\n\t\tputs \"Valid buckets currently are: \"\n\t\tresp.buckets.map(&:name).each do |item|\n\t\t\tputs \"=> #{item}\"\n\t\tend\n\t\texit\n\tend\n\treturn resp\nend", "def default_bucket\n request(method: :get, path: '/v1/buckets')\n end", "def collection(slug, options)\n _get(\"v1/collections/\" + slug, options)\n end", "def run_me\r\n bucket_name = 'doc-example-bucket'\r\n region = 'us-west-2'\r\n s3_client = Aws::S3::Client.new(region: region)\r\n\r\n list_bucket_objects(s3_client, bucket_name)\r\nend", "def bucket; ::AWS::S3.new({ secure: true }).buckets[DC::SECRETS['bucket']]; end", "def find_bucket(name)\n buckets.find(\"#{name}\")\n end", "def s3_connection\n @s3connection ||= connect_to_s3\nend", "def db_connect\n database_connect_options = @options['database']\n db_connector = DatabaseConnector.new(database_connect_options)\n return db_connector.client\n end", "def create_buckets_api\n InfluxDB2::API::BucketsApi.new(@api_client)\n end", "def list_my_buckets(s3)\n resp = s3.list_buckets()\n puts \"My buckets now are:\\n\\n\"\n\n resp.buckets.each do |bucket|\n puts bucket.name\n end\n\nend", "def list_my_buckets(s3)\n resp = s3.list_buckets\n puts \"My buckets now are:\\n\\n\"\n\n resp.buckets.each do |bucket|\n puts bucket.name\n end\n\nend", "def bucket_with_name(bucket_name)\n @buckets[bucket_name.to_sym] if bucket_name\n end", "def open_connection\n AWS::S3::Base.establish_connection!(\n :access_key_id => @reader.access_key_id,\n :secret_access_key => @reader.secret_access_key\n )\n end", "def Connect()\n client = Mongo::Client.new([ \"#{$host}:27017\" ], :database => $database)\n $messages.append(\"Connecting to MongoDB\")\n $db = client.database\n $collection = client[:users] #Selecting users collection\n $messages.append(\"Selecting user collection\")\nend", "def full_bucket(bucket_name)\n @monkey_patched ||= monkey_patch_bucket\n @full_buckets ||= Hash.new\n\n bucket = buckets[bucket_name]\n @full_buckets[bucket_name] ||= Aws::S3::Bucket.new(name: bucket_name, client: client(bucket.location))\n end", "def bucket(bucket)\n return(@bucket_cache[bucket]) if @bucket_cache.has_key?(bucket)\n self.bucket!(bucket)\n end", "def list_buckets(opts = {})\n if @config.cname\n fail ClientError, \"Cannot list buckets for a CNAME endpoint.\"\n end\n\n Iterator::Buckets.new(@protocol, opts).to_enum\n end", "def connection(environment)\n unless @connection_pool\n pool_config = environment.connection_pool_configuration\n if pool_config.nil?\n pool_config = {\n :size => 1,\n :timeout => 10\n }\n end\n @connection_pool ||= ::ConnectionPool.new(pool_config) do\n environment.create_connection(:connect_to_keyspace => true)\n end\n end\n @connection_pool\n end", "def connect_to_s3\n unless AWS::S3::Base.connected?\n AWS::S3::Base.establish_connection!(:access_key_id => AWSCredentials.access_key, :secret_access_key => AWSCredentials.secret_access_key)\n end\n end", "def collections_info(coll_name=nil)\n selector = {}\n selector[:name] = full_collection_name(coll_name) if coll_name\n Cursor.new(Collection.new(SYSTEM_NAMESPACE_COLLECTION, self), :selector => selector)\n end", "def buckets\n body = {\n accountId: Backblaze::B2.account_id\n }\n response = post('/b2_list_buckets', body: body.to_json)\n response['buckets'].map do |bucket|\n params = Hash[bucket.map { |k, v| [Backblaze::Utils.underscore(k).to_sym, v] }]\n new(params)\n end\n end", "def collections_info(coll_name=nil)\n selector = {}\n selector[:name] = full_collection_name(coll_name) if coll_name\n Cursor.new(EM::Mongo::Collection.new(@db_name, SYSTEM_NAMESPACE_COLLECTION, @em_connection), :selector => selector)\n end", "def query_couchbase_servers\n\n couchbase_servers = Hash.new\n \n r=rightscale_server_collection 'couchbase_cluster_nodes' do\n tags [\"couchbase:cluster_ip=#{cluster_ip}\"]\n secondary_tags [\"server:uuid=*\", \"couchbase:listen_ip=*\"]\n action :nothing\n end\n r.run_action(:load)\n \n node[:server_collection]['couchbase_cluster_nodes'].to_hash.values.each do |tags|\n uuid = RightScale::Utils::Helper.get_tag_value('server:uuid', tags)\n ip = RightScale::Utils::Helper.get_tag_value('couchbase:listen_ip', tags)\n couchbase_servers[uuid] = {}\n couchbase_servers[uuid][:ip] = ip\n end\n \n couchbase_servers\n \n end", "def buckets( opts = {} )\n jbuckets = @jservice.list_all_buckets\n jbuckets.map { |jb| S3Bucket.new( self, jb, opts ) }\n end", "def query_couchdb(urn, verb, host = '127.0.0.1', options = @@default_options)\n secure = options[:secure] || @@default_options[:secure]\n body = options[:body] || @@default_options[:body]\n\n ## Set scheme\n scheme = secure ? 'https' : 'http'\n ## build uri\n url = \"#{scheme}://#{host}\"\n uri = URI.join(url, urn)\n Chef::Log.debug(\"query_couchdb built uri: #{uri}\")\n\n http = Net::HTTP.new(uri.host, options[:port])\n http.use_ssl = secure\n unless options[:verify_ssl] || @@default_options[:verify_ssl]\n Chef::Log.debug('verify_ssl is false setting verify to none')\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n if body.empty?\n retry_request(http, verb.upcase, uri.request_uri)\n else\n if body.is_a? Hash\n headers = { 'Content-Type' => 'application/json' }\n body = JSON.generate(body)\n else\n body = \"\\\"#{body}\\\"\"\n end\n retry_request(http, verb.upcase, uri.request_uri, body, headers)\n end\n end", "def apply(bucket = nil)\n bucket ||= export()\n catalog = bucket.to_catalog\n res = catalog.apply\n catalog.clear\n res\n end", "def get_collection(database_id:, collection_id:)\n path = '/databases/{databaseId}/collections/{collectionId}'\n .gsub('{databaseId}', database_id)\n .gsub('{collectionId}', collection_id)\n\n if database_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"databaseId\"')\n end\n\n if collection_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"collectionId\"')\n end\n\n params = {\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'GET',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::Collection\n )\n end", "def retrieve_objects_via_http(bucket)\n _log 'Retrieving objects via unauthenticated method.'\n r = http_request :get, \"https://#{bucket}.s3.amazonaws.com\"\n if r.code != '200'\n _log 'Failed to retrieve any objects using the unauthenticated technique as bucket listing is disabled.'\n return\n end\n\n xml_doc = Nokogiri::XML(r.body)\n xml_doc.remove_namespaces!\n results = xml_doc.xpath('//ListBucketResult//Contents//Key').children.map(&:text)\n results[0...999] # return first 1k results as some buckets may have tons of objects\n\n # format before\n results.reject! { |b| b =~ %r{.+/$} } unless results.nil? # remove folder names if bucket_objs is not nil\n results unless results.empty? \n end", "def database! url\n parsed = parse url\n cr = CouchRest.new(parsed[:host])\n cr.database!(parsed[:database])\n end", "def connect_for( path, &block )\n zone = zone_for_path( path ) \n info = config[zone]\n raise \"Unable to find zone info in config file for zone `#{zone}\" unless info\n raise \"Check your config. Unable to find `host information\" unless info['host']\n raise \"Check your config. Unable to find `port information\" unless info['port']\n\n con = nil \n begin\n con = Mongo::Connection.new( info['host'], info['port'], { :slave_ok => true } )\n \n if info['user'] and info['password']\n con.db( 'admin' ).authenticate( info['user'], info['password'] )\n end\n rescue => boom\n raise \"MongoDB connection failed for `#{info['host']}:#{info['post']}\"\n end \n \n yield con \n con.close()\n end", "def set_bucket\n @bucket = Bucket.find(params[:id])\n has_authority\n end", "def connect\n @lock.synchronize do\n return if @started\n @started = true\n @io_reactor.start\n hosts = @host.split(',')\n connection_futures = hosts.map { |host| connect_to_host(host) }\n @connection_ids = Future.combine(*connection_futures).get\n end\n use(@initial_keyspace) if @initial_keyspace\n self\n rescue => e\n close\n if e.is_a?(Cql::QueryError) && e.code == 0x100\n raise AuthenticationError, e.message, e.backtrace\n else\n raise\n end\n end", "def each &block\n response = client.list_buckets\n response.buckets.each do |b|\n yield(bucket_named(b.name, response.owner))\n end\n nil\n end", "def bucket_field\n 'bucket'\n end", "def open\n conn = connection.protocol::DbOpen.new(params(name: @name, storage: @storage, user: @user, password: @password)).process(connection)\n @session = conn[:session] || OrientdbBinary::OperationTypes::NEW_SESSION\n\n @clusters = conn[:clusters]\n self\n end", "def create_bucket(bucket_name)\n success = false\n bucket_obj = nil\n begin\n bucket_obj = @s3.bucket(bucket_name)\n bucket_obj.create()\n success = true\n rescue Aws::S3::Errors::BucketAlreadyOwnedByYou\n puts \"Bucket already owned - #{bucket_name}\"\n rescue Aws::S3::Errors::InvalidBucketName\n puts \"Bucket name invalid - #{bucket_name}\"\n rescue Aws::S3::Errors::BucketAlreadyExists\n puts \"Bucket name exists - #{bucket_name}\"\n rescue Aws::S3::Errors::InvalidAccessKeyId\n puts \"Invalid AWS Credentials\"\n rescue Aws::S3::Errors::SignatureDoesNotMatch\n puts \"Signature match error - #{bucket_name}\"\n end\n if ! success\n return nil\n end\n return bucket_obj\n end", "def testS3Connection\n begin\n #checks if a query can be sent to the S3 endpoint.\n #Sets the s3connection variable to Established or Error\n s3 = createS3Connection\n test_query = s3.buckets.collect(&:name)\n session[:s3connection] = \"Established\"\n\n #Get the list of buckets if a connection can be Established\n #Return an empty list of buckets if a connection cant be established\n @buckets_array = createEmptyBucketsArray if session[:s3connection] != \"Established\"\n @buckets_array = getBucketsList if session[:s3connection] == \"Established\"\n\n #Get the list of objects for the selected bucket.\n #Returns an empty list of objects if the selected bucket value is None\n @objects_array = createEmptyObjectsArray if session[:s3bucket] == \"No Bucket Selected\"\n @objects_array = getObjectsList if session[:s3bucket] != \"No Bucket Selected\"\n flash.now[:info] = \"<strong>Success!</strong>\".html_safe + \" Account settings refreshed.\"\n rescue Exception => error\n session[:s3connection] = \"Disconnected (Error)\"\n @buckets_array = createEmptyBucketsArray if session[:s3connection] != \"Established\"\n @objects_array = createEmptyObjectsArray if session[:s3bucket] == \"No Bucket Selected\"\n flash.now[:danger] = \"<strong>Error!</strong>\".html_safe + \" Error loading application: #{error}.\"\n end\n end", "def __build_connections\n Connections::Collection.new \\\n :connections => hosts.map { |host|\n host[:protocol] = host[:scheme] || DEFAULT_PROTOCOL\n host[:port] ||= DEFAULT_PORT\n\n client = ::Curl::Easy.new\n client.headers = {'User-Agent' => \"Curb #{Curl::CURB_VERSION}\"}\n client.url = __full_url(host)\n\n if host[:user]\n client.http_auth_types = host[:auth_type] || :basic\n client.username = host[:user]\n client.password = host[:password]\n end\n\n client.instance_eval &@block if @block\n\n Connections::Connection.new :host => host, :connection => client\n },\n :selector_class => options[:selector_class],\n :selector => options[:selector]\n end", "def cname_url\n URI.escape(\"#{protocol}#{name}/#{key}\") if bucket.vhost?\n end", "def list_s3_buckets()\n\n s3 = connect_to_s3()\n response = s3.list_buckets\n\n response.buckets.each do |bucket|\n puts \"#{bucket.creation_date} #{bucket.name}\"\n end\n\nend", "def show_cloud_bucket_by_pool(pool_id, cloud_bucket_id, opts = {})\n data, _status_code, _headers = show_cloud_bucket_by_pool_with_http_info(pool_id, cloud_bucket_id, opts)\n data\n end", "def list_buckets(s3_client)\r\n response = s3_client.list_buckets\r\n if response.buckets.count.zero?\r\n puts 'No buckets.'\r\n else\r\n response.buckets.each do |bucket|\r\n puts bucket.name\r\n end\r\n end\r\nrescue StandardError => e\r\n puts \"Error listing buckets: #{e.message}\"\r\nend", "def process_bucket(&block)\n raise ArgumentError, \"process_bucket requires a block!\" unless block_given?\n raise ArgumentError, \"You must call register_worker before processing!\" unless @memcache_client\n\n begin\n nominate\n if leader?\n # Drb thread handles leader duties\n log.info { \"#{@uri} has been elected leader\" }\n relax until_next_iteration\n initialize_buckets \n else\n # Get a bucket from the leader and process it\n begin\n bucket_process(*leader.bucket_request, &block)\n rescue DRb::DRbError => dre\n log.error { \"Error talking to leader: #{dre.message}\" }\n relax until_next_iteration\n end\n end\n end while loop?\n end", "def bucket_name\n self.class.bucket.name\n end", "def cass_client\n unless @cass_client\n uri_json = ENV['CASSANDRA_URIS'] || '[\"127.0.0.1:9160\"]'\n @cassandra_uris = MultiJson.load uri_json\n\n @cass_client = ::Cassandra.new(\"Hastur\", @cassandra_uris, THRIFT_OPTIONS)\n\n # for non-production and port-forwarded ssh, there will only be one URI and it\n # should not auto-discover nodes\n if @cassandra_uris.one?\n @cass_client.disable_node_auto_discovery!\n end\n end\n @cass_client\n end", "def bucket_from_uri(uri)\n uri.split('/')[2]\n end" ]
[ "0.5900005", "0.5791184", "0.5688879", "0.55614185", "0.5553416", "0.5511002", "0.543184", "0.54155535", "0.53867275", "0.53394616", "0.53394616", "0.5237352", "0.5195417", "0.51768064", "0.5157064", "0.51562643", "0.51496845", "0.5148446", "0.51438856", "0.5143261", "0.51256466", "0.5103966", "0.5086472", "0.5070304", "0.50698996", "0.5067736", "0.50561005", "0.5032854", "0.50232494", "0.50232494", "0.50220895", "0.5011048", "0.50060534", "0.49964935", "0.49718636", "0.4970808", "0.49688557", "0.4966457", "0.49643674", "0.49575943", "0.49528745", "0.4952796", "0.4942287", "0.4933288", "0.49305552", "0.49274194", "0.49260175", "0.4924236", "0.49226397", "0.49212784", "0.49084443", "0.4893973", "0.48850903", "0.48796335", "0.48783484", "0.48646104", "0.4855924", "0.4854589", "0.48426497", "0.48195615", "0.4811939", "0.48118725", "0.4806237", "0.47999743", "0.47822294", "0.4774574", "0.47608623", "0.47434846", "0.4741962", "0.47358093", "0.47240472", "0.471308", "0.47086522", "0.4705357", "0.47019133", "0.4701419", "0.46901643", "0.468364", "0.46815783", "0.4679122", "0.46778032", "0.46775362", "0.46759272", "0.4667141", "0.46642864", "0.46496862", "0.46445274", "0.46313512", "0.4623593", "0.46221912", "0.46219602", "0.4620821", "0.46155322", "0.46079922", "0.45994365", "0.4592598", "0.45866865", "0.45804983", "0.45787483", "0.45773283" ]
0.6535918
0
once fluent v0.14 is released we might be able to use Fluent::Parser::TimeParser, but it doesn't quite do what we want if gives [sec,nsec] where as we want something we can call `strftime` on...
def create_time_parser if @time_key_format begin # Strptime doesn't support all formats, but for those it does it's # blazingly fast. strptime = Strptime.new(@time_key_format) Proc.new { |value| strptime.exec(value).to_datetime } rescue # Can happen if Strptime doesn't recognize the format; or # if strptime couldn't be required (because it's not installed -- it's # ruby 2 only) Proc.new { |value| DateTime.strptime(value, @time_key_format) } end else Proc.new { |value| DateTime.parse(value) } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def time_format(seconds)\nend", "def time_format(seconds)\nend", "def create_time_formatter(expr)\n begin\n f = eval('lambda {|__arg_time__| ' + expr.gsub(\"$time\", \"__arg_time__\") + '}')\n return f\n rescue SyntaxError\n raise Fluent::ConfigError, \"SyntaxError at time_format `#{expr}`\"\n end\n end", "def tt(time, format=:short); '13:37'; end", "def humanize_time(secs)\n [[60, :second], [60, :minute], [24, :hour], [31, :day], [12, :month], [1000, :year]].map{ |count, name|\n if secs > 0\n secs, n = secs.divmod(count)\n next nil if n == 0\n pluralize(name.to_s, n.to_i)\n end\n }.compact.reverse[0..1].join(' ')\n end", "def format_time(seconds)\n if seconds < 60\n sprintf \"%ds\", seconds\n elsif seconds < 60 * 60\n sprintf \"%dm:%02ds\", seconds / 60, seconds % 60\n else\n sprintf \"%dh:%02dm\", seconds / (60 * 60), seconds % (60 * 60) / 60\n end\nend", "def humanize_time(seconds)\n\tminutes = seconds / 60\n \t[[60, :m], [24, :h], [100000, :d]].map{ |count, name|\n if minutes > 0\n minutes, n = minutes.divmod(count)\n \"#{n.to_i}#{name}\"\n end\n }.compact.reverse.join('')\nend", "def strftime(format, time = T.unsafe(nil)); end", "def parse_time\n s0 = @scanner.pos\n if match_str('(') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s3 = parse_ms\n if s3 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n if match_str('/') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n s5 = parse_hms\n s5 = parse_ms(with_hour: true) if s5 == :failed\n if s5 == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n match_spaces\n if match_str(')') == :failed\n @scanner.pos = s0\n s0 = :failed\n else\n @reported_pos = s0\n s0 = { 'now' => s3, 'total' => s5 }\n end\n end\n end\n end\n end\n s0\n end", "def 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 strftime(p0) end", "def humanize secs\n [\t\n \t[60, :seconds], \n \t[60, :minutes], \n \t[24, :hours], \n \t[365, :days], \n \t[100, :years]\n ].map do |count, name|\n if secs > 0\n secs, n = secs.divmod(count)\n \"#{n.to_i} #{name}\"\n end\n end.compact.reverse.join(' ')\nend", "def fmt(cmd); \" %s %s\" % [cmd[:time].strftime(@options[:time_format]), cmd[:cmd]]; end", "def parse_time(time)\n time = \"0#{time}\" if time.match(/^\\d:\\d\\d/)\n time = time.gsub(/u/, '') if utime?\n time = time.gsub(/s/, '') if stime?\n\n time\n end", "def test_format_strftime_record\n d = create_driver %[\n tag #{@tag}\n key #{@key}\n format %d/%b/%Y:%H:%M:%S %z\n source record\n standard localtime\n ]\n\n d.run do\n d.emit({\"a\"=>1}, Time.parse(\"1990-04-14 09:45:15 UTC\").to_i)\n end\n\n record = d.emits.first.last\n assert_equal \"14/Apr/1990:11:45:15 +0200\", record[@key]\n end", "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_str\n Time.at(time[0..-4].to_f + time[-3..-1].to_f / 1000)\n .strftime(\"%M:%S.%L\")\n end", "def parse_timespec_msg_for_action(p, action)\n\n # Optional \"after\" , depending on context\n if p.advance_token == \"after\"\n p.advance_token\n end\n value = nil\n unit = nil\n orig = p.current_token\n if TIMESPEC_MATCH =~ p.current_token\n if $2.nil?\n value = $4.to_i\n unit = :ms\n else\n value = $2.to_f\n unit = :s\n end\n else\n parse_error! p, \"Expected a time interval in the form of X.Ys or XXXms, but got #{p.current_token}\"\n end\n\n msg = p.consume_to_eol\n if msg == :EOL\n parse_error! p, \"Expected a message to follow after #{orig} but got nothing!\"\n end\n action.msg = msg\n action.delay = { value: value, unit: unit }\n action\n end", "def update_time_formats!\n Time::DATE_FORMATS.update(\n :db => '%Y-%m-%d %H:%M:%S',\n :ui => '%d.%m.%Y %H:%M',\n :yaml => '%Y-%m-%d %H:%M:%S %:z', # For DateTimes\n :default => lambda do |time|\n non_zero_time = time.hour != 0 || time.min != 0 || time.sec != 0\n time.strftime(non_zero_time ? '%d.%m.%Y %H:%M' : '%d.%m.%Y')\n end\n )\n end", "def format(precise: false)\n return '-' if @ms.nil?\n\n return Kernel.format('%02d:%02d:%02d.%03d', hours, minutes, seconds, milliseconds) if precise\n Kernel.format('%02d:%02d:%02d', hours, minutes, seconds)\n end", "def create_time_parser\n if @time_key_format\n begin\n # Strptime doesn't support all formats, but for those it does it's\n # blazingly fast.\n strptime = Strptime.new(@time_key_format)\n Proc.new { |value|\n value = convert_numeric_time_into_string(value, @time_key_format) if value.is_a?(Numeric)\n strptime.exec(value).to_datetime\n }\n rescue\n # Can happen if Strptime doesn't recognize the format; or\n # if strptime couldn't be required (because it's not installed -- it's\n # ruby 2 only)\n Proc.new { |value|\n value = convert_numeric_time_into_string(value, @time_key_format) if value.is_a?(Numeric)\n DateTime.strptime(value, @time_key_format)\n }\n end\n else\n Proc.new { |value|\n value = convert_numeric_time_into_string(value) if value.is_a?(Numeric)\n DateTime.parse(value)\n }\n end\n end", "def parse_time(number)\n # Disregard date part\n number -= number.truncate if number.positive?\n\n base = number * 24\n\n hours = base.truncate\n minutes = ((base - hours) * 60).round\n\n # Compensate for rounding errors\n if minutes >= 60\n hours += (minutes / 60)\n minutes = minutes % 60\n end\n\n format(\"%02d:%02d\", hours, minutes)\n end", "def parse_time(time)\n result = Struct.new(:days, :hours, :minutes).new\n time = time.to_i\n result.days = time / 86_400\n time = time % 84_600\n result.hours = time / 3_600\n time %= 3_600\n result.minutes = time / 60\n result\nend", "def format(precise: false, sign: :negatives)\n return '-' if @ms.nil?\n\n format = ['%02d', ':%02d', ':%02d']\n components = [hours, minutes, seconds]\n\n if precise\n format << '.%02d'\n components << (milliseconds / 10)\n end\n\n if sign == :always || (sign == :negatives && negative?)\n format[0] = '%0+2d'\n return Kernel.format(format.join, *components)\n end\n\n Kernel.format(format.join, *components)\n end", "def fmt_time(dt) _format_dt dt, H12_M_PM end", "def sbv_time(t)\r\n i = t.to_i\r\n \"%d:%02d:%02d.%03d\" % [i/3600, i/60%60, i%60, (t*1000).to_i%1000]\r\nend", "def format_duration(secs)\n if !secs\n return ''\n end\n\n [[60, :sec], [60, :min], [24, :hr], [1000, :days]].map{ |count, name|\n if secs > 0\n secs, n = secs.divmod(count)\n \"#{n.to_i} #{name}\"\n end\n }.compact.reverse.join(' ')\n end", "def short_time(fraction_digits=nil, num_elements=nil)\n\t\t\t\telements = [\n\t\t\t\t\tdays.floor,\n\t\t\t\t\thours(:days).floor,\n\t\t\t\t\tminutes(:hours).floor,\n\t\t\t\t\tseconds(:minutes)\n\t\t\t\t]\n\t\t\t\telements.shift while (elements.size > num_elements && elements.first.first.zero?)\n\t\t\t\tdisplay = ShortTime[-elements.size..-1]\n\t\t\t\tdisplay[-1] = \"%#{fraction_digits+3}.#{fraction_digits}f\" if (fraction_digits && fraction_digits > 0)\n\t\t\t\tsprintf(display.join(\":\"), *elements)\n\t\t\tend", "def prep_time_passed\n return \"7:34\"\n end", "def time_as_human\n return Knj::Strings.secs_to_human_time_str(self.time_total, :secs => false)\n end", "def time(value)\n _parse_time(value)\n end", "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 time(text)\n if time?(text)\n Nickel.parse(text).occurrences[0].start_time.to_time\n else\n clean_text = clear_text(text)\n if time?(clean_text)\n Nickel.parse(clean_text).occurrences[0].start_time.to_time\n end\n end\n end", "def agop secs, desc = nil\n return '-' unless secs\n\n [[60, :sec], [60, :min], [24, :hrs], [356, :days], [1000, :years]].map do |count, name|\n if secs > 0\n secs, n = secs.divmod(count)\n \"#{n.to_i}#{name}\"\n end\n end.compact.reverse.slice(0,2).join(' ')\n end", "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 pretty_runtime\n return nil if total_time.nil?\n t = total_time / 1000\n minutes = t / 60\n seconds = t - 60 * minutes\n sprintf '%d:%02d', minutes, seconds\n end", "def humanize(seconds)\n seconds = seconds.to_i\n hours, mins, secs = seconds / 1.hour, (seconds % 1.hour) / 1.minute, seconds%60\n sprintf(\"%3d:%02d:%02d\", hours, mins, secs)\n end", "def nice_time\n Time.at(time).utc.strftime('%-M:%Ss')\n end", "def strftime(*args)\n #This is a stub, used for indexing\n end", "def to_s(*args)\n if args.empty?\n strftime('%H:%M:%S')\n else\n # Superclass may have defined a method that takes a format string,\n # and we shouldn't override in that case.\n super\n end\n end", "def formattime2(unformattedtime)\n unformattedtime.strftime('%H:%M:%S')\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 time\n a=[1, 1000, 60000, 3600000]*2\n ms = duration\n \"%02d\" % (ms / a[3]).to_s << \":\" << \n \"%02d\" % (ms % a[3] / a[2]).to_s << \":\" << \n \"%02d\" % (ms % a[2] / a[1]).to_s #<< \".\" << \n #\"%03d\" % (ms % a[1]).to_s\n end", "def parse_time(string)\n parts = string.split(\":\").map(&:to_f)\n parts = [0] + parts if parts.length == 2\n hours, minutes, seconds = parts\n seconds = hours * 3600 + minutes * 60 + seconds\n seconds.to_i\n end", "def approach_time_format\n \"%b %e, %Y %l:%M%p\"\n end", "def t2f(time) \n time.strftime('%H.%M').to_f\n end", "def elapsed_time_preset preset, show_seconds=TrackingConfig[:show_elapsed_seconds]\n\t\t\tcase preset\n\t\t\twhen :colons\n\t\t\t\tpreset = '%02d:%02d:%02d'\n\t\t\t\tpreset_secs = ':%02d'\n\t\t\twhen :letters\n\t\t\t\tpreset = '%02dd %02dh %02dm'\n\t\t\t\tpreset_secs = ' %02ds'\n\t\t\tend\n\t\t\tpreset += preset_secs if show_seconds\n\t\t\treturn preset\n\t\tend", "def display_time(secs)\n [[60, :s], [60, :m], [9999, :h]].map do |count, name|\n if secs > 0\n secs, n = secs.divmod(count)\n\n \"#{n.to_i}#{name}\" unless n.to_i == 0\n end\n end.compact.reverse.join(' ')\n end", "def normalize_time\n if time.present?\n Time::DATE_FORMATS[:ms] = \"%M:%S\"\n self.time = \"0:#{time.to_formatted_s(:ms)}\".to_time\n end\n end", "def time(text)\n scan(text, TIME, :time)\n end", "def test_time_truncate_usec_on_assigment_precision_3\n time = Time.parse('2018-12-31T23:59:21.341867')\n record = DateAndTimeTypes.new(my_time_one: time)\n\n assert_equal 23, record.my_time_one.hour\n assert_equal 59, record.my_time_one.min\n assert_equal 21, record.my_time_one.sec\n assert_equal 341_000, record.my_time_one.usec\n assert_equal 341_000_000, record.my_time_one.nsec\n end", "def out_of_bounds_time_format; end", "def format_time(time)\n return time.strftime(\"%l:%M%p\")\n end", "def parse_with_fractional_seconds(tc_with_fractions_of_second, fps = DEFAULT_FPS)\n fraction_expr = /\\.(\\d+)$/\n fraction_part = ('.' + tc_with_fractions_of_second.scan(fraction_expr)[0][0]).to_f\n\n seconds_per_frame = 1.0 / fps.to_f\n frame_idx = (fraction_part / seconds_per_frame).floor\n\n tc_with_frameno = tc_with_fractions_of_second.gsub(fraction_expr, \":%02d\" % frame_idx)\n\n parse(tc_with_frameno, fps)\n end", "def parse_with_fractional_seconds(tc_with_fractions_of_second, fps = DEFAULT_FPS)\n fraction_expr = /\\.(\\d+)$/\n fraction_part = ('.' + tc_with_fractions_of_second.scan(fraction_expr)[0][0]).to_f\n\n seconds_per_frame = 1.0 / fps.to_f\n frame_idx = (fraction_part / seconds_per_frame).floor\n\n tc_with_frameno = tc_with_fractions_of_second.gsub(fraction_expr, \":%02d\" % frame_idx)\n\n parse(tc_with_frameno, fps)\n end", "def display_duration(options = {})\n options[:value]&.map { |v| v.scan(/([0-9]{2})/).join(':') }\n end", "def display_duration(options = {})\n options[:value]&.map { |v| v.scan(/([0-9]{2})/).join(':') }\n end", "def parse_seconds(time)\n sounds_for_number(time.strftime(\"%S\"))\n end", "def to_s(pretty=true)\n d, h, m, s, ms = elapsed\n e_t = (d > 0) ? \"#{d.to_s}d \" : ''\n if pretty\n e_t += ('%02u:' % [h]) if (d + h) > 0\n e_t += ('%02u:' % [m]) if (d + h + m) > 0\n e_t += '%02u.%03u' % [s, ms]\n else\n e_t << '%02u:%02u:%02u.%03u' % [h,m,s, ms]\n end\n end", "def test_time_truncate_usec_on_assigment_default_precision\n time = Time.parse('2018-12-31T23:59:21.341867923')\n record = DateAndTimeTypes.new(my_time: time)\n\n assert_equal 23, record.my_time.hour\n assert_equal 59, record.my_time.min\n assert_equal 21, record.my_time.sec\n assert_equal 341_867, record.my_time.usec\n assert_equal 341_867_000, record.my_time.nsec\n end", "def time_convert(num)\n hr, min = num.divmod(60)\n \"#{hr}:#{min}\"\nend", "def custom_time (*arg)\n\tresult = \"\"\n\targ.each do |value|\n\t\tif(value == :day_of_week)\n\t\t\tresult += \"%A, \"\n\t\telsif(value == :month)\n\t\t\tresult += \"%B \"\n\t\telsif(value == :day)\n\t\t\tresult += \"%d, \"\n\t\telsif(value == :year)\n\t\t\tresult += \"%Y \"\n\t\telsif(value == :time)\n\t\t\tresult += \"at %I:%M%p\" \n\t\tend\n\tend\n\tt = Time.now\n\tt.strftime(result)\nend", "def time_parsing str\n Time.parse(str) if str && str != \"<null>\"\n end", "def to_ftime\n mm, ss = divmod(60)\n hh, mm = mm.divmod(60)\n dd, hh = hh.divmod(24)\n format('%d days, %d hours, %d minutes, and %d seconds', dd, hh, mm, ss)\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 parse_time\n time_str = @request[FTIME].sub(REGEX_TIME_FIX) { \"#{$1} #{$2}\" }\n Time.parse(time_str) rescue nil\n end", "def separated_time_string(seconds, separator)\n secs = seconds % 60\n mins = seconds / 60 % 60\n hours = seconds / 60 / 60 \n time_string = sprintf(\"%02d#{separator}%02d#{separator}%02d\", hours, mins, secs)\n end", "def time_transformer(time)\n if time < 10\n \"0\" + time.to_s\n else\n time.to_s\n end\nend", "def pretty_time(num_seconds)\n\ttemp = num_seconds\t\n\n\thours = temp/3600\n\ttemp = temp%3600\n\n\tminutes = temp/60\n\ttemp = temp%60\n\n\tif hours > 0\n\t\treturn \"#{hours} Hours, #{minutes} Minutes, and #{temp} Seconds\"\n\telsif minutes > 0\n\t\treturn \"#{minutes} Minutes and #{temp} Seconds\"\n\telse\n\t\treturn \"#{temp} Seconds\"\n\tend\nend", "def print_time( fmt )\n printf( fmt, utime, stime )\n end", "def fmt_time(t)\n if t.present?\n ApplicationHelper.localtime(t).strftime(ApplicationHelper.gen_time_fmt)\n end\n end", "def as_datetime_in_words\n strftime \"%b %d %I:%M %p\"\n end", "def time_conversion(minutes)\n hours = minutes / 60\n remaining_minutes = minutes % 60\n \"%s:%02d\" % [hours, remaining_minutes]\nend", "def time_string\n hours = @seconds / 3600\n minutes = (@seconds % 3600) / 60\n secs = (@seconds % 3600) % 60\n \n sprintf(\"%02d:%02d:%02d\", hours, minutes, secs)\n end", "def to_dot_time(time)\r\n time = time.to_i\r\n hours = time/3600.to_i\r\n minutes = (time/60 - hours * 60).to_i\r\n seconds = (time - (minutes * 60 + hours * 3600))\r\n # [hours, minutes, seconds].join(\":\")\r\n [format('%02d', hours),format('%02d', minutes) , format('%02d', seconds)].join(\":\")\r\n end", "def fmt_miltime(t)\n if t.present?\n ApplicationHelper.localtime(t).strftime(ApplicationHelper.time_fmt)\n end\n end", "def nltime_duration(duration=nil)\n if duration\n @duration = duration.to_s.capitalize\n else\n @duration || self.to_s.split('::').last\n end\n end", "def formattimeanddate(unformattedtime)\n unformattedtime.strftime('%I:%M:%S %p - %d %m %Y')\n end", "def time_string(secs)\n dhms = ([secs / 86400] + Time.at(secs).utc.strftime('%H|%M|%S').split(\"|\").map(&:to_i)).zip(['day', 'hour', 'minute', 'second'])\n dhms.shift while dhms[0][0] == 0\n dhms.pop while dhms[-1][0] == 0\n dhms.map! { |(v, s)| \"#{v} #{s}#{v == 1 ? nil : 's'}\" }\n return dhms[0] if dhms.size == 1\n \"#{dhms[0..-2].join(', ')} and #{dhms[-1]}\"\n end", "def 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 to_smart_time(form = :utc)\n# 1) Research parsedate to see how it's parsing\n# 2) Refacter the parse to insert the current values from the top down,\n# as they don't exist. Ignore seconds completely unless given by the string.\n ::Time.send(\"#{form}_time\", *ParseDate.parsedate(self)[0..5].map {|arg| arg || 0})\n end", "def time_string()\n #Get numerical representations for each value\n @hours = seconds / 60 / 60\n @minutes = (seconds / 60) % 60\n @seconds = seconds % 60\n\n #Convert the values to properly formatted strings\n @hours = padded(@hours)\n @minutes = padded(@minutes)\n @seconds = padded(@seconds)\n \n #return the string\n @hours + ':' + @minutes + ':' + @seconds\n end", "def timestr(subsec = true)\n if(subsec)\n \"%02d:%02d:%06.3f\" % [ getHour(nil).to_i,\n getMin().to_i,\n getSec().to_f ] ;\n else\n \"%02d:%02d:%02d\" % [ getHour(nil).to_i,\n getMin().to_i,\n getSec().to_i ] ;\n end\n\n end", "def typecast_time(datetime) #:nodoc:\n datetime.sub!(%r|^(\\w{2})/(\\w{3})/(\\w{4})|, '\\2 \\1 \\3')\n datetime.sub!(':', ' ')\n Time.parse(datetime)\n end", "def parse_dcsubtitle_tc_string( tc_string, fps )\n case tc_string\n when /\\d\\d:\\d\\d:\\d\\d:\\d\\d\\d/ # hh:mm:ss:ttt\n Timecode.parse_with_ticks( tc_string, fps )\n when /\\d\\d:\\d\\d:\\d\\d\\.\\d\\d\\d/ # hh:mm:ss.sss\n Timecode.parse( tc_string, fps )\n else\n nil\n end\nend", "def format_time(time)\n format('%02d', time)\nend", "def transform_secs(seconds) \n time = ''\n \n h = (seconds.to_f / 3600.0).floor\n seconds = seconds - (h * 3600)\n time << \"#{h.to_s.rjust(2, '0')}:\" if h > 0\n \n m = (seconds.to_f / 60.0).floor\n seconds = seconds - (m * 60)\n time << \"#{m.to_s.rjust(2, '0')}:\"\n \n time << \"#{seconds.to_s.rjust(2, '0')}\"\n \n time\nend", "def convert_time(string)\n time = Time.parse(string).send(@operation, @time)\n time.strftime('%T,%L') # Formating on 'hh:mm:ss,mls'\n end", "def duration\n duration = @file_metadata.duration.to_s\n\n # in format like: 0:02:43 (approx)\n if duration.match /(\\d{1,2}):(\\d{1,2}):(\\d{1,2})/\n hours = $1.strip.to_i\n minutes = $2.strip.to_i\n seconds = $3.strip.to_i\n\n if hours.to_i == 0\n return sprintf(\"%02d:%02d\", minutes, seconds)\n else\n return sprintf(\"%01s:%02d:%02d\", hours, minutes, seconds)\n end\n elsif duration.match /(\\d{1,2})\\.(\\d{1,2}) s/i\n # in format like: 23.41 s (approx)\n # $1 = 23\n # $2 = 41\n seconds = $1.strip.to_i\n return sprintf(\"%02d:%02d\", 0, seconds)\n end\n end", "def to_label\n \"#{time}\"\n end", "def parse(time_string)\n Time.at(\"#{time_string[0,10]}.#{time_string[10,13]}\".to_f)\n end", "def parse_time\n # add a default time for a task.\n length_of_task = Time.now + 15.minutes\n\n # splits the entered text.\n sentence = body.split ' '\n esc_code = sentence.first\n\n # determines if the word is long enough.\n # if it was long enough, split the word into the necessary code.\n if esc_code.length >= 2\n esc_code_prefix = esc_code[0]\n esc_code_suffix = esc_code[1..-1]\n end\n\n # checks for valid escape sequence to parse.\n if esc_code_prefix == \"+\" and esc_code_suffix.match /\\d/\n # set time specified by user.\n length_of_task = Time.now + (esc_code_suffix.to_i * 60)\n # remove the escape code from the string.\n sentences = body.split ' ', 2\n self.body = sentences[1]\n end\n\n # set the completed at time field.\n self.completed_at = length_of_task\n \n end", "def parse_time(str)\n seconds = 0\n str.scan(/\\d+ *[Dd]/).each { |m| seconds += (m.to_i * 24 * 60 * 60) }\n str.scan(/\\d+ *[Hh]/).each { |m| seconds += (m.to_i * 60 * 60) }\n str.scan(/\\d+ *[Mm]/).each { |m| seconds += (m.to_i * 60) }\n str.scan(/\\d+ *[Ss]/).each { |m| seconds += (m.to_i) }\n seconds\n end", "def time_conversion(mins)\r\n\r\n [mins /60, mins %60].map {|t| t.to_s.rjust(2, '0')}.join(':')\r\nend", "def to_time_string(seconds) \n\tmin = (seconds / 60).floor.to_s\n\tsec = (seconds % 60).round(3).to_s\n\ttime_string = \"#{min}:#{sec.match(/^\\d\\./) == nil ? sec : \"0\" + sec }\"\n\t#conditional string formating to add zero 'padding' if needed\nend", "def timeConvert(num)\n\t\n\treturn \"#{num/60}:#{num%60}\"\nend", "def parse_srt_time(time)\n time =~ /^(\\d+):(\\d+):(\\d+),(\\d{3})$/\n hh, mm, ss, ms = [$1, $2, $3, $4].map(&:to_i)\n hh*3600 + mm*60 + ss + ms/1000.0\n end", "def format_duration(seconds)\n seconds = seconds.to_f\n answer = Array.new\n if seconds == 0\n return \"now\"\n end\n while seconds >= (60*60*24*365) #years\n answer << (seconds / (60*60*24*365).to_f).to_s.split(\".\").first\n answer.last.to_i > 1 ? answer[-1] += \" years\" : answer[-1] += \" year\"\n seconds = (seconds % (60*60*24*365))\n end\n while seconds >= (60*60*24) #days\n answer << (seconds / (60*60*24).to_f).to_s.split(\".\").first\n answer.last.to_i > 1 ? answer[-1] += \" days\" : answer[-1] += \" day\"\n seconds = (seconds % (60*60*24))\n end\n while seconds >= (60*60) #hours\n answer << (seconds / (60*60).to_f).to_s.split(\".\").first\n answer.last.to_i > 1 ? answer[-1] += \" hours\" : answer[-1] += \" hour\"\n seconds = (seconds % (60*60))\n end\n while seconds >= (60) #minutes\n answer << (seconds / (60).to_f).to_s.split(\".\").first\n answer.last.to_i > 1 ? answer[-1] += \" minutes\" : answer[-1] += \" minute\"\n seconds = (seconds % (60))\n end\n if seconds < 60\n answer << seconds.to_i.to_s\n answer.last.to_i > 1 ? answer[-1] += \" seconds\" : answer[-1] += \" second\"\n end\n while answer[-1].split(\" \").first.to_i == 0\n answer.pop\n end\n while answer.length >= 3\n answer[1] = answer[0] + \", \" + answer[1]\n answer.shift\n end\n if answer.length == 2\n answer.join(\" and \")\n else\n answer.first\n end\nend", "def inspect\n \"#{time.strftime(\"%Y-%m-%d %H:%M:%S\")} #{period.abbreviation}\"\n end", "def time_string(seconds)\n Time.at(seconds).utc.strftime(\"%H:%M:%S\")\nend" ]
[ "0.66272694", "0.66272694", "0.6323898", "0.625732", "0.6161273", "0.6096188", "0.60335296", "0.5905873", "0.58548117", "0.58484715", "0.5842492", "0.58343554", "0.58323324", "0.5796436", "0.5791222", "0.5783446", "0.5731633", "0.5722742", "0.5692227", "0.56890213", "0.56539047", "0.56348807", "0.56263906", "0.5621752", "0.55781156", "0.55532193", "0.5540128", "0.55333805", "0.5531652", "0.5529059", "0.5526455", "0.55113375", "0.549909", "0.5497393", "0.54933673", "0.54880166", "0.54876876", "0.54855925", "0.5484708", "0.5482755", "0.54663455", "0.5463477", "0.5461212", "0.544533", "0.54438156", "0.54338616", "0.5432589", "0.5432527", "0.5428988", "0.54250824", "0.54200464", "0.54168355", "0.54129", "0.54119754", "0.54119754", "0.5408558", "0.5408558", "0.53979445", "0.53809404", "0.5378127", "0.53754586", "0.53737533", "0.53722125", "0.53635603", "0.5362836", "0.53586185", "0.53563946", "0.5353731", "0.53535885", "0.5352344", "0.53411096", "0.5338465", "0.5335832", "0.53355086", "0.5332292", "0.5332209", "0.53296196", "0.53276485", "0.53268874", "0.5318599", "0.53168154", "0.53141564", "0.5311944", "0.53115016", "0.5310317", "0.5309409", "0.53042364", "0.52986425", "0.52926487", "0.5292416", "0.52889264", "0.52870935", "0.52797055", "0.5275063", "0.52732164", "0.5273042", "0.526863", "0.5266127", "0.5265489", "0.5265011" ]
0.5671098
20
not complete. currently can only check for the first club does not factor in for if bully stole the money student would no longer meet membership requirements.
def bully if self.name[0,1] == "J" # binding.pry self.budget -= 150 # binding.pry return "The bully stole half of my money!" else return "AHH i'm running away!" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def club_protect\n if session[:club_id]\n @current_membership = Membership.find_by_user_id_and_club_id(session[:user_id], session[:club_id], :conditions => [\"status=?\", \"current\"])\n if session[:user_id] == 6\n @current_membership = true\n end\n \n if !@current_membership \n flash[:notice] = \"Sorry, the page you were trying to access is only for approved \" + Club.find(session[:club_id]).initials + \" members.<BR />Request membership below.\"\n redirect_to club_memberships_path(session[:club_id])\n return false\n end\n end\n \n \n end", "def validate_membership\n errors.add(\"#{self.sadhak_profile.syid}\", \"is not active member to forum #{self.sy_club.name}.\") unless self.sy_club_member.approve?\n errors.empty?\n end", "def club_not_full\n @club = Club.find(self.club_id)\n unless (@club.member_count < @club.capacity)\n errors.add(:member_id, \"Club is full\")\n end\n end", "def check_sadhak_already_joined_to_club?\n errors.add(:sadhak, \"is already member of #{self.transfer_in_club.name.titleize} forum.\") if SyClubMember.where(sy_club_id: self.to_club_id, sadhak_profile_id: self.sadhak_profile_id, status: SyClubMember.statuses['approve']).count > 0\n errors.empty?\n end", "def test_valid_non_member_registering_full_class\n\t\tregistering_non_member = Enrollment.new(:participantID => participants(:non_member_one).participantID, :courseID => \"walk1122\", :startDate =>\"2013-10-18\")\n\t\tassert Participant.find_by(participantID: registering_non_member.participantID), \"Non Member was not found in Participant database\"\n\t\tassert Course.find_by(courseID: registering_non_member.courseID), \"Course is not in Courses database\"\n\t\t\n\t\t# Checking if the member exists by the expiry date to be greater than tomorrow's date, but if nil or expired date, then participant is not a member\n\t\tmember = Participant.find_by(participantID: registering_non_member.participantID)\n\t\tassert_nil member.expirydate, \"Non Member is a member\"\n\n\t\t# Checking the existence of the pair (courseID,startDate) \n\t\tactual = Course.find_by(courseID: registering_non_member.courseID)\n\t\tassert_equal registering_non_member.startDate, actual.startDate, \"Registering Course does not have valid startDate\"\n\n\n\t\t# Checking the capacity of the course\n\t\tcurrent_enrollment = Enrollments.where(courseID: registering_non_member.courseID).count\n\t\tassert_operator current_enrollment, :<, actual.size, \"The size of the course is full\"\n\n\t\t# Adding proper values before saving\n\t\tregistering_non_member.startDate = actual.startDate\n\t\tregistering_non_member.waitlist_status = 1\n\n\t\tassert registering_non_member.save, \"registering a new valid member was not saved\"\n\tend", "def test_valid_non_member_registering_in_class\n\t\tregistering_non_member = Enrollment.new(:participantID => participants(:non_member_one).participantID, :courseID => \"nap12345\", :startDate => '18-10-2013')\n\t\tassert Participant.find_by(participantID: registering_non_member.participantID), \"Non Member was not found in Participant database\"\n\t\tassert Course.find_by(courseID: registering_non_member.courseID), \"Course is not in Courses database\"\n\t\t\n\t\t# Checking if the member exists by the expiry date to be greater than tomorrow's date, but if nil or expired date, then participant is not a member\n\t\tmember = Participant.find_by(participantID: registering_non_member.participantID)\n\t\tassert_nil member.expirydate, \"Non Member is a member\"\n\n\t\t# Checking the existence of the pair (courseID,startDate) \n\t\texpected = registering_non_member.startDate\n\t\tactual = Course.find_by(courseID: registering_non_member.courseID)\n\t\tassert_equal expected, actual.startDate, \"Registering Course does not have valid startDate\"\n\n\t\t# Checking the capacity of the course\n\t\tcurrent_enrollment = Enrollments.where(courseID: registering_non_member.courseID).count\n\t\tassert_operator current_enrollment, :<, actual.size, \"The size of the course is full\"\n\n\t\t# Adding proper values before saving\n\t\tregistering_non_member.waitlist_status = 0\n\n\t\tassert registering_non_member.save, \"registering a new valid non member was not saved\"\n\tend", "def is_request_pending_to_same_club_from_another_club?\n self.class.preloaded_data.where(sadhak_profile_id: self.sadhak_profile_id, to_club_id: self.to_club_id, status: self.class.statuses['requested']).each do |req|\n errors.add(:sadhak, \"Name: #{req.requester_user.name} has already created a request for transfer from #{req.transfer_out_club.name.titleize} forum to #{req.transfer_in_club.name.titleize} froum.\")\n end\n errors.empty?\n end", "def club_invited\n self.errors.add(:team, I18n.t('tournament.team_uninvited')) unless self.tournament.clubs.where(id: team.club.id).any?\n end", "def check_multiple_courses\n \n end", "def check_for_franchise\n if self.is_franchised\n player = Player.find(self.player_id)\n length = self.contract_length\n position = player.position\n averaged_player_salary = 0\n final_salary = 0\n this_salary = 0\n contracted_team_id = self.subcontracts.last.team_id\n top_5_players_of_position = Player.where(\"position = ?\", player.position).sort_by { |player| player.auction_value }.reverse.first(5)\n\n top_5_players_of_position.each do |top_player|\n if top_player.is_contracted?\n this_salary = top_player.this_year.salary_amount\n else\n this_salary = top_player.auction_value\n end\n averaged_player_salary += this_salary\n end\n averaged_player_salary /= 5\n\n salary_progression = SalaryProgression.find_by_auction_value(player.auction_value).attributes.to_a\n\n\n if player.this_year.contract.is_extended\n salary = salary_progression[(length + 2)][1]\n else\n salary = salary_progression[(length + 1)][1] \n end \n if averaged_player_salary >= salary\n final_salary = averaged_player_salary\n else\n final_salary = salary\n end \n\n # create the Subcontract\n sub = Subcontract.new\n if self.is_extended\n sub.contract_year = contract_start_year + length + 1\n else\n sub.contract_year = contract_start_year + length\n end\n sub.salary_amount = final_salary\n sub.contract_id = self.id\n sub.team_id = contracted_team_id\n sub.this_is_a_franchise_tag = true\n sub.save! \n\n # update GM's annual actions to not allow more franchise tags\n actions = AnnualGmAction.find_by_team_id_and_year(contracted_team_id, current_year)\n actions.has_franchised = true\n actions.franchised_player_id = self.player.id\n actions.save!\n end\n end", "def test_valid_member_registering_full_class\n\t\tregistering_member = Enrollment.new(:participantID => participants(:two).participantID, :courseID => \"run12345\", :startDate => '2013-10-18')\n\t\tassert Participant.find_by(participantID: registering_member.participantID), \"Member was not found in Participant database\"\n\t\tassert Course.find_by(courseID: registering_member.courseID), \"Course is not in Courses database\"\n\t\t\n\t\t# Checking if the member exists by the expiry date to be greater than tomorrow's date, but if nil or expired date, then participant is not a member\n\t\tmember = Participant.find_by(participantID: registering_member.participantID)\n\t\tassert_operator Date.today, :<=, member.expirydate, \"Member is not a member\"\n\t\tassert_not_nil member.expirydate, \"Member is not a member\"\n\n\n\t\t# Checking the existence of the pair (courseID,startDate) \n\t\tactual = Course.find_by(courseID: registering_member.courseID)\n\t\tassert_equal registering_member.startDate, actual.startDate, \"Registering Course does not have valid startDate\"\n\n\t\t#TODO: check doctors note, parq, not yet implemented\n\t\t\n\t\t#Checking the capacity of the course\n\t\tcurrent_enrollment = Enrollments.where(courseID: registering_member.courseID).count\n\t\tassert_operator current_enrollment, :<, actual.size, \"The size of the course is full\"\n\n\t\t# Adding proper values before saving\n\t\tregistering_member.startDate = actual.startDate\n\t\tregistering_member.waitlist_status = 1\n\n\t\tassert registering_member.save, \"registering a new valid member was not saved\"\n\tend", "def club?\n !self.club.nil?\n end", "def test_valid_member_registering_class\n\t\tregistering_member = Enrollment.new(:participantID => participants(:two).participantID, :courseID => \"yoga0123\", :startDate => '2013-10-18')\n\t\tassert Participant.find_by(participantID: registering_member.participantID), \"Member was not found in Participant database\"\n\t\tassert Course.find_by(courseID: registering_member.courseID), \"Course is not in Courses database\"\n\t\t\n\t\t# Checking if the member exists by the expiry date to be greater than tomorrow's date, but if nil or expired date, then participant is not a member\n\t\tmember = Participant.find_by(participantID: registering_member.participantID)\n\t\tassert_operator Date.today, :<=, member.expirydate, \"Member is not a member\"\n\t\tassert_not_nil member.expirydate, \"Member is not a member\"\n\n\t\t# Checking the existence of the pair (courseID,startDate) \n\t\tactual = Course.find_by(courseID: registering_member.courseID)\n\t\tassert_equal registering_member.startDate, actual.startDate, \"Registering Course does not have valid startDate\"\n\n\t\t# TODO: check doctors note, parq, not yet implemented\n\t\t\n\t\t# Checking the capacity of the course\n\t\tcurrent_enrollment = Enrollments.where(courseID: registering_member.courseID).count\n\t\tassert_operator current_enrollment, :<, actual.size, \"The size of the course is full\"\n\n\t\t# Adding proper values before saving\n\t\tregistering_member.startDate = actual.startDate\n\t\tregistering_member.waitlist_status = 0\n\n\t\tassert registering_member.save, \"registering a new valid member was not saved\"\n\tend", "def membership(unit)\n unit.membership(self)\n end", "def choose\n other_users = User.all.where.not id: current_user.id\n clubs = Hash.new 0\n other_users.each do |other_user|\n other_user_clubs = Club.left_joins(:club_matches,:users).where(:users=> {id:other_user.id},:club_matches=>{matched:1})\n current_user_clubs = Club.left_joins(:club_matches,:users).where(:users=> {id:current_user.id},:club_matches=>{matched:1})\n\n common_clubs = other_user_clubs & current_user_clubs\n weight = (common_clubs.length.to_f * 100/ other_user_clubs.length)\n other_user_clubs.each do |club|\n if !common_clubs.include?(club)&& !current_user_clubs.include?(club)\n clubs[club] += weight\n end\n end\n end\n\n clubs.each do |club, v|\n common_interest_count = (current_user.interests & club.interests).length\n if clubs[club] >= 1\n clubs[club] = clubs[club] + ((5 * common_interest_count)/clubs[club]) + (rand(-14..14)/7)\n else\n clubs[club] = clubs[club] + (10 * common_interest_count) + (rand(-14..14).to_f/7)\n end\n clubs[club] = clubs[club].round(2)\n end\n @clubs = clubs.sort_by{ |k, v| v }.reverse\n end", "def test_valid_non_member_registered_class\n\t\tregistered_non_member = enrollments(:non_member_one)\n\t\tassert Participant.find_by(participantID: registered_non_member.participantID), \"Non Member was not found in Participant database\"\n\t\tassert Course.find_by(courseID: registered_non_member.courseID), \"Course is not in Courses database\"\n\t\t\n\t\t# Checking if the member exists by the expiry date to be greater than tomorrow's date, but if nil or expired date, then participant is not a member\n\t\tmember = Participant.find_by(participantID: registered_non_member.participantID)\n\t\tassert_nil member.expirydate, \"Non Member is a member\"\n\n\t\t# Checking the existence of the pair (courseID, startDate)\n\t\tactual = Course.find_by(courseID: registered_non_member.courseID)\n\t\tassert_equal registered_non_member.startDate, actual.startDate, \"Registering Course does not have valid startDate\"\n\t\t\n\t\tassert registered_non_member.save, \"valid registered member was not saved\"\n\tend", "def unit_members\n #Academicians & Mgmt staff : \"Teknologi Maklumat\", \"Perpustakaan\", \"Kewangan & Akaun\", \"Sumber Manusia\",\"logistik\", \"perkhidmatan\" ETC.. - by default staff with the same unit in Position will become unit members, whereby Ketua Unit='unit_leader' role & Ketua Program='programme_manager' role.\n #Exceptional for - \"Kejuruteraan\", \"Pentadbiran Am\", \"Perhotelan\", \"Aset & Stor\" (subunit of Pentadbiran), Ketua Unit='unit_leader' with unit in Position=\"Pentadbiran\", Note: whoever within these unit if wrongly assigned as 'unit_leader' will also hv access for all ptdos on these unit staff\n \n exist_unit_of_staff_in_position = Position.find(:all, :conditions =>['unit is not null and staff_id is not null']).map(&:staff_id).uniq\n if exist_unit_of_staff_in_position.include?(Login.current_login.staff_id)\n current_unit = Position.find_by_staff_id(Login.current_login.staff_id).unit\n \n #replace current_unit value if academician also a Unit Leader\n current_roles=Login.current_login.roles.map(&:name)\n current_unit=unit_lead_by_academician if current_roles.include?(\"Unit Leader\") && Programme.roots.map(&:name).include?(current_unit)\n \n if current_unit==\"Pentadbiran\"\n unit_members = Position.find(:all, :conditions=>['unit=? OR unit=? OR unit=? OR unit=?', \"Kejuruteraan\", \"Pentadbiran Am\", \"Perhotelan\", \"Aset & Stor\"]).map(&:staff_id).uniq-[nil]+Position.find(:all, :conditions=>['unit=?', current_unit]).map(&:staff_id).uniq-[nil]\n elsif [\"Teknologi Maklumat\", \"Pusat Sumber\", \"Kewangan & Akaun\", \"Sumber Manusia\"].include?(current_unit) || Programme.roots.map(&:name).include?(current_unit)\n unit_members = Position.find(:all, :conditions=>['unit=?', current_unit]).map(&:staff_id).uniq-[nil]\n else #logistik & perkhidmatan inc. \"Unit Perkhidmatan diswastakan / Logistik\" or other UNIT just in case - change of unit name, eg. Perpustakaan renamed as Pusat Sumber\n unit_members = Position.find(:all, :conditions=>['unit ILIKE(?)', \"%#{current_unit}%\"]).map(&:staff_id).uniq-[nil] \n end\n else\n unit_members = []#Position.find(:all, :conditions=>['unit=?', 'Teknologi Maklumat']).map(&:staff_id).uniq-[nil]\n end\n unit_members #collection of staff_id (member of a unit/dept)\n end", "def unit_members#(current_unit, current_staff, current_roles)\n #Academicians & Mgmt staff : \"Teknologi Maklumat\", \"Perpustakaan\", \"Kewangan & Akaun\", \"Sumber Manusia\",\"logistik\", \"perkhidmatan\" ETC.. - by default staff with the same unit in Position will become unit members, whereby Ketua Unit='unit_leader' role & Ketua Program='programme_manager' role.\n #Exceptional for - \"Kejuruteraan\", \"Pentadbiran Am\", \"Perhotelan\", \"Aset & Stor\" (subunit of Pentadbiran), Ketua Unit='unit_leader' with unit in Position=\"Pentadbiran\" Note: whoever within these unit if wrongly assigned as 'unit_leader' will also hv access for all ptdos on these unit staff\n\n current_staff=staff\n exist_unit_of_staff_in_position = Position.find(:all, :conditions => ['unit is not null and staff_id is not null']).map(&:staff_id).uniq\n if exist_unit_of_staff_in_position.include?(current_staff)\n\n current_unit=staff.position.unit #staff.positions.first.unit\n #replace current_unit value if academician also a Unit Leader (23)\n #current_roles=User.where(userable_id: userable_id).first.roles.map(&:name) ##\"Unit Leader\" #userable.roles.map(&:role_id)\n current_roles=roles.map(&:name)\n current_unit=unit_lead_by_academician if current_roles.include?(\"Unit Leader\") && Programme.roots.map(&:name).include?(current_unit)\n\n if current_unit==\"Pentadbiran\"\n unit_members = Position.find(:all, :conditions => ['unit=? OR unit=? OR unit=? OR unit=?', \"Kejuruteraan\", \"Pentadbiran Am\", \"Perhotelan\", \"Aset & Stor\"]).map(&:staff_id).uniq-[nil]+Position.find(:all, :conditions => ['unit=?', current_unit]).map(&:staff_id).uniq-[nil]\n elsif [\"Teknologi Maklumat\", \"Pusat Sumber\", \"Kewangan & Akaun\", \"Sumber Manusia\"].include?(current_unit) || Programme.roots.map(&:name).include?(current_unit)\n unit_members = Position.find(:all, :conditions => ['unit=?', current_unit]).map(&:staff_id).uniq-[nil]\n else #logistik & perkhidmatan inc.\"Unit Perkhidmatan diswastakan / Logistik\" or other UNIT just in case - change of unit name, eg. Perpustakaan renamed as Pusat Sumber\n unit_members = Position.find(:all, :conditions => ['unit ILIKE(?)', \"%#{current_unit}%\"]).map(&:staff_id).uniq-[nil]\n end\n else\n unit_members = []#Position.find(:all, :conditions=>['unit=?', 'Teknologi Maklumat']).map(&:staff_id).uniq-[nil]\n end\n unit_members #collection of staff_id (member of a unit/dept) - use in model/user.rb (for auth_rules)\n #where('staff_id IN(?)', unit_members) ##use in ptdo.rb (controller - index)\n end", "def test_unexistent_course_registering_non_member\n\t\tregistering_non_member = Enrollment.new(:participantID => participants(:non_member_one).participantID, :courseID => \"nap101\")\n\t\tassert Participant.find_by(participantID: registering_non_member.participantID), \"Non Member was not found in Participant database\"\n \t\tassert !Course.find_by(courseID: registering_non_member.courseID), \"Non existent Course is in Courses database\"\n\tend", "def cancel_pending_requests_if_from_same_club\n self.class.preloaded_data.where(sadhak_profile_id: self.sadhak_profile_id, from_club_id: self.from_club_id, status: self.class.statuses['requested']).each do |sy_club_member_transfer|\n sy_club_member_transfer.responder_user = self.requester_user\n unless sy_club_member_transfer.cancel!\n errors.add(:there, \"is some error while canceling the previous request ##{sy_club_member_transfer.id}. Please contact to board members.\")\n end\n end\n errors.empty?\n end", "def test_unexistent_course_registering_member\n\t\tregistering_member = Enrollment.new(:participantID => participants(:one).participantID, :courseID => \"nap09877\")\n\t\tassert Participant.find_by(participantID: registering_member.participantID), \"Member was not found in Participant database\"\n \t\tassert !Course.find_by(courseID: registering_member.courseID), \"Non existent Course is in Courses database\"\n\tend", "def test_adding_to_waitlist_non_member\n\t\tnon_member = Enrollments.new(:participantID => participants(:non_member_one).participantID,:courseID => \"run12345\", :startDate => '2013-10-18' )\n\t\n\t\t#Checking the capacity of the course\n\t\tactual = Course.find_by(courseID: non_member.courseID)\n\t\tcurrent_enrollment = Enrollments.where(courseID: non_member.courseID).count\n\t\tassert_operator current_enrollment, :<, actual.size, \"The size of the course is full, should fail since we are going to be waitlisting\"\n\n\t\t# Adding proper values before saving\n\t\tnon_member.startDate = actual.startDate\n\t\tnon_member.waitlist_status = 1\n\n\t\tassert non_member.save, \"registering a new valid non_member was not saved\"\n\n\t\twaitlisted_member = Enrollments.find_by(participantID: non_member.participantID)\n\t\texpected = 1\n\t\tassert expected, waitlisted_member.waitlist_status, \"Saved non_member's waitlist_status is false\"\n\tend", "def user_must_own_membership\n # User ID match\n @membership = @user.memberships.find_by(id: params[:id])\n return if @membership && @membership.invite_status != 'left'\n\n alert_and_redirect('Invalid membership or user has left.', login_path, :bad_request)\n end", "def is_request_for_transfer_profile_board_member?\n errors.add(:profile, \"Name: #{self.sadhak_profile.full_name.titleize} SYID: #{self.sadhak_profile_id} is board member of #{self.from_club.name.titleize} forum.\") if self.from_club.is_board_member?(self.sadhak_profile_id)\n errors.empty?\n end", "def checkups\t \n \t\tif Counter.exists?(champ_name: self.champ_name, champ_gegner: self.champ_gegner)\n \tfalse\n # Der selbe Champ ist kein Counter deshalb Rollback \n \telsif self.champ_name == self.champ_gegner\n \t\tfalse\n \telse\n \t\ttrue\t\n\t\t\tend\n\t\tend", "def update_faculty(members)\n self.faculty_was = self.faculty\n self.faculty = []\n return \"\" if members.nil?\n\n msg = \"\"\n members.each do |name|\n person = Person.find_by_human_name(name)\n if person.nil?\n all_valid_names = false\n msg = msg + \"'\" + name + \"' is not in the database. \"\n #This next line doesn't quite seem to work\n self.errors.add(:person_name, \"Person \" + name + \" not found\")\n else\n self.faculty << person\n end\n end\n return msg\n end", "def mark_forum_members_as_expired\n windows = SyClubValidityWindow.includes(:sy_club_sadhak_profile_associations).where('membership_end_date < ?', Date.current)\n clubs = SyClub.all.collect{|c| {id: c.id, name: c.name}}\n windows.count > 0 and windows.each do |validity_win|\n to_be_expired_sadhaks = validity_win.sy_club_sadhak_profile_associations.where(status: SyClubSadhakProfileAssociation.statuses['approve'])\n if to_be_expired_sadhaks.count > 0\n association_ids = to_be_expired_sadhaks.ids\n sadhak_ids = to_be_expired_sadhaks.pluck(:sadhak_profile_id)\n recipients = SadhakProfile.where(id: sadhak_ids).map {|e| {id: e.id, email: e.email}}\n SyClubSadhakProfileAssociation.where(id: association_ids).each do |expired_sadhak|\n expired_sadhak.update_attribute('status', SyClubSadhakProfileAssociation.statuses['expired'])\n club = clubs.find{|c| c[:id] == expired_sadhak.sy_club_id}\n recipient = recipients.find{|r| r[:id] == expired_sadhak.sadhak_profile_id}\n email = recipient.present? ? recipient[:email] : ''\n from = GetSenderEmail.call(club)\n ApplicationMailer.send_email(from: from, recipients: [email], template: 'forum_membership_expired', subject: \"#{club[:name].titleize} - Membership Expired\", club: club, validity_window: validity_win).deliver if club.present? and email.is_valid_email?\n end\n end\n end\n end", "def test_valid_member_registered_class\n\t\tregistered_member = enrollments(:one)\n\t\tassert Participant.find_by(participantID: registered_member.participantID), \"Member was not found in Participant database\"\n\t\tassert Course.find_by(courseID: registered_member.courseID), \"Course is not in Courses database\"\n\t\t\n\t\t# Checking if the member exists by the expiry date to be greater than tomorrow's date, but if nil or expired date, then participant is not a member\n\t\tmember = Participant.find_by(participantID: registered_member.participantID)\n\t\tassert_operator Date.today, :<=, member.expirydate, \"Member is not a member\"\n\t\tassert_not_nil member.expirydate, \"Member is not a member\"\n\n\t\t\n\t\t# Checking the existence of the pair (courseID,startDate) \n\t\texpected = registered_member.startDate\n\t\tactual = Course.find_by(courseID: registered_member.courseID)\n\t\tassert_equal expected, actual.startDate, \"Registering Course does not have valid startDate\"\n\n\t\t# TODO: check doctors note, parq, not yet implemented\n\n\t\tassert registered_member.save, \"valid registered member was not saved\"\n\tend", "def test_member_has_type()\n assert_equal( 'false', @member1.premium_membership() )\n end", "def initialize\n @clubs = {} ## clubs (indexed) by canonical name\n @errors = []\n end", "def student_membership_number\n accepted_students.size + pending_students.size\n end", "def update\n success = false\n \n old_membership = current_user.membership_for(@epicenter)\n new_membership = Membership.find(params[:id])\n upgrade = new_membership.monthly_fee > old_membership.monthly_fee\n\n membershipcard = current_user.get_membershipcard( @epicenter )\n\n # change subscription for \"new circle movement\"\n if @epicenter == @mother \n redirect_path = nil\n\n # subscription is nil if bank member of if we have stripe info but no active subsctiptions\n if membershipcard.payment_id == 'bank'\n subscription = nil\n else\n customer = Stripe::Customer.retrieve( membershipcard.payment_id ) rescue nil\n subscription = customer.subscriptions.first rescue nil\n end\n\n # if we have active subscription we can simply change it\n if subscription\n # change user's subscription\n subscription.plan = new_membership.payment_id.to_s\n \n # if success and upgrade, charge additional payment\n if subscription.save\n success = true\n\n if upgrade\n today = Date.today\n diff_amount = new_membership.monthly_fee - old_membership.monthly_fee\n days_in_month = Time.days_in_month(today.month, today.year)\n days_left_in_month = days_in_month - today.day + 1\n percent_left = days_left_in_month / days_in_month.to_f\n\n # only charge for changes if there are more than 5% of days left in month and user is not in \"trialing\" subscription\n if (percent_left > 0.05 and subscription.status != 'trialing')\n charge_amount = [diff_amount * percent_left, 25].max.round\n payment = Stripe::Charge.create(\n :amount => charge_amount * 100,\n :currency => 'dkk',\n :customer => customer.id,\n :description => \"Membership change from #{old_membership.name} to #{new_membership.name}\"\n )\n end\n end\n\n current_user.membershipcards.each do |card|\n card.update_valid_supply\n end\n else\n no_success_message = \"Der skete desvære en fejl. Betalingen blev ikke gennemført (subs171)\"\n end\n\n # otherwise we need to create a new credit card subscription\n # the user does not have an active subscription but we have stripe info, so we delete it\n else\n if customer\n customer.delete\n end\n if membershipcard.payment_id != 'bank'\n membershipcard.payment_id = 'upgrade'\n end\n membershipcard.save\n\n redirect_path = new_epicenter_subscription_path(@epicenter)\n end\n\n # change subscription to all other epicenters\n else \n success = @epicenter.validate_and_pay_new_membership( current_user, new_membership )\n unless success \n no_success_message = \"Du har ikke nok beholdning og/eller månedlig tilførsel af #{@epicenter.mother.fruittype.name}\"\n end\n end\n\n\n # if we have success we can update the users membershipcard\n if success\n # update membershipcard\n membershipcard.membership_id = new_membership.id\n membershipcard.valid_payment = true\n membershipcard.update_valid_supply\n\n puts \"--------------------------------\"\n puts \"new membership\", membershipcard.membership.monthly_gain\n\n if membershipcard.save\n log_details = { from: old_membership.name, to: new_membership.name }\n EventLog.entry(current_user, @epicenter, MEMBERSHIP_CHANGE, log_details, LOG_COARSE)\n\n # only add fruits if upgrading\n if upgrade\n @epicenter.harvest_time_for(current_user)\n end\n\n flash[:success] = \"Du er nu #{new_membership.name} medlem af #{@epicenter.name}\" \n else \n flash[:error] = \"Der skete desværre en fejl (142). Kontakt venligst NCM\"\n end\n redirect_path = epicenter_path(@epicenter)\n \n # otherwise, if we don't have a redirect already (change from bank to credit card)\n # display error to user\n else\n if not redirect_path\n membershipcard.valid_payment = false\n membershipcard.save\n\n flash[:warning] = no_success_message\n redirect_path = epicenter_subscriptions_path(@epicenter)\n end\n end\n\n redirect_to redirect_path\n end", "def join\n @beer_club = BeerClub.find(params[:id])\n if Membership.where(:beer_club_id => @beer_club.id, :user_id => current_user.id).exists?\n respond_to do |format|\n format.html { redirect_to :back, notice: \"You are already a member of this club!\" }\n end\n else\n @membership = Membership.create\n @membership.beer_club_id = @beer_club.id\n @membership.user_id = current_user.id\n if @beer_club.memberships.count < 1\n @membership.confirmed = true\n else\n @membership.confirmed = false\n end\n respond_to do |format|\n if @membership.save\n format.html { redirect_to :back, notice: \"You joined #{@beer_club.name}\" }\n else\n format.html { redirect_to :back, notice: \"Something went awry! D:\" }\n end\n end\n end\n end", "def check_for_buyout\n if self.is_bought_out\n if self.bought_out_by_team_id\n self.subcontracts.future_years.each do |sub|\n sub.salary_amount *= 0.6\n sub.this_is_a_buyout = true\n sub.save!\n\n # update GM's annual actions to not allow more buyouts\n actions = AnnualGmAction.find_by_team_id_and_year(self.bought_out_by_team_id, current_year)\n actions.has_bought_out = true\n actions.bought_out_player_id = self.player.id\n actions.save!\n end\n end\n end\n end", "def round_actual?\n !self.club.round_actual.nil?\n end", "def update_faculty(members)\n return \"\" if members.nil?\n\n msg = \"\"\n members.each do |name|\n person = Person.find_by_human_name(name)\n if person.nil?\n all_valid_names = false\n msg = msg + \"'\" + name + \"' is not in the database. \"\n #This next line doesn't quite seem to work\n self.errors.add(:person_name, \"Person \" + name + \" not found\")\n else\n self.faculty << person\n end\n end\n return msg\n end", "def is_looser?(club)\n if self.finished?\n if self.local_goals > self.guest_goals\n if club == guest\n return true\n end\n end\n\n if self.guest_goals > self.local_goals\n if club == local\n return true\n end\n end\n end\n\n return false\n end", "def check_membership\n unless @project.member?(current_user.id)\n flash_t_general :error, 'project.not_participating'\n redirect_to panel_projects_path\n return\n end \n end", "def is_request_for_transfer_profile_board_member?\n errors.add(:profile, \"Name: #{self.sadhak_profile.full_name.titleize} SYID: #{self.sadhak_profile_id} is board member of #{self.transfer_out_club.name.titleize} forum.\") if self.transfer_out_club.is_board_member?(self.sadhak_profile_id)\n errors.empty?\n end", "def test\nspongebob = Student.new(\"Spongebob\")\npatrick = Student.new(\"Patrick\")\nplankton = Student.new(\"Plankton\")\n\nmrs_puff = Instructor.new(\"Mrs. Puff\")\nsquidward = Instructor.new(\"Squidward Tentacles\")\n\nspongebob_test1 = spongebob.add_boating_test(\"parking_test\", \"Fail\", mrs_puff)\nspongebob.add_boating_test(\"braking_test\", \"Fail\", mrs_puff)\nspongebob.add_boating_test(\"speeding_test\", \"Pass\", squidward)\n\npatrick.add_boating_test(\"parking_test\", \"Fail\", mrs_puff)\npatrick.add_boating_test(\"speeding_test\", \"Pass\", squidward)\n\nplankton.add_boating_test(\"parking_test\", \"Pass\", squidward)\nplankton.add_boating_test(\"braking_test\", \"Pass\", squidward)\n\nputs \"Student Test\"\nputs \"------------\"\nprint \"Student has first name: \"\nputs spongebob.first_name == \"Spongebob\"\nprint \"Student.all returns all student objects: \"\nputs Student.all == [spongebob, patrick, plankton]\nprint \"#add_boating_test creates a new boating test: \"\nputs spongebob_test1.class == BoatingTest\n\nputs \"------------\"\nputs \"Instructor Test\"\nputs \"------------\"\nprint \"Instructor has name: \"\nputs squidward.name == \"Squidward Tentacles\"\nprint \"Instructor.all returns all instructors: \"\nputs Instructor.all == [mrs_puff, squidward]\nprint \"#pass students: \"\nmrs_puff.pass_student(spongebob, \"parking_test\")\nputs spongebob_test1.status == \"Pass\"\nprint \"#fail_student\"\nmrs_puff.fail_student(spongebob, \"parking_test\")\nputs spongebob_test1.status == \"Fail\"\n\nputs \"------------\"\nputs \"BoatingTest Test\"\nputs \"------------\"\nprint \"has a student: \"\nputs spongebob_test1.student == spongebob\nprint \"has a name: \"\nputs spongebob_test1.test_name == \"parking_test\"\nprint \"has a status: \"\nputs spongebob_test1.status == \"Fail\"\nprint \"has an instructor: \"\nputs spongebob_test1.instructor == mrs_puff\n\nend", "def stupid_way_to_ensure_at_least_one_org_unit(record)\n if !current_user.is_superuser?\n #logger.debug(\"sw #{record.organizational_units.empty?} #{!current_user.organizational_units.empty?} #{current_user.name} #{current_user.organizational_units}\")\n raise \"Organizational units can't be blank\" if record.organizational_units.empty? #&& !current_user.organizational_units.empty? # 2. half is not working because org_unit gets update even before my condition test\n end\n end", "def is_winner?(club)\n if self.finished?\n if self.local_goals > self.guest_goals\n if local == club\n return true\n end\n end\n\n if self.guest_goals > self.local_goals\n if guest == club\n return true\n end\n end\n end\n return false\n end", "def pass_student(student, test_name)\n\n # if BoatingTest.all.select {|bt|bt.test_name == test_name} && BoatingTest.all.select {|bt|bt.student == student}\n # status = \"passed\"\n # else\n # BoatingTest.new(student, test_name, status = \"passed\", instructor = nil)\n # end\n\n arr = BoatingTest.all.select {|bt|bt.student == student}\n\n matched = arr.find {|bt| bt.test_name == test_name}\n\n if matched\n matched.status = 'passed'\n else\n BoatingTest.new(student,test_name,'passed',self) \n end \n\n def fail_student(student, test_name)\n\n # if BoatingTest.all.select {|bt|bt.test_name == test_name} && BoatingTest.all.select {|bt|bt.student == student}\n # status = \"passed\"\n # else\n # BoatingTest.new(student, test_name, status = \"passed\", instructor = nil)\n # end\n \n arr = BoatingTest.all.select {|bt|bt.student == student}\n \n matched = arr.find {|bt| bt.test_name == test_name}\n \n if matched\n matched.status = 'failed'\n else\n BoatingTest.new(student,test_name,'failed',self) \n end\n end\n\n\n\nend", "def checkCredits(newModule)\n newCredits = Subject.find_by(module_code: newModule)\n newCredits = newCredits.credits\n \n #assign userCredits the current users current amount of credits\n userCredits = current_user.credits\n # Check to make sure that the user doesn't add more than 60 credits to their credit count. \n if 60 <= userCredits || userCredits == 60\n flash[:danger] = \"Can't add more than 60 credits!\"\n false\n elsif userCredits + newCredits > 60\n false\n else\n current_user.credits += newCredits \n # Save the user if current_user is valid\n current_user.save\n true\n end \n end", "def test_group\n \n user = @user_1\n group = 'customer-test'\n \n assert (not @crowd.group_member? user.name, group), \"#{user.name} is already a member of group #{group}\"\n\n @crowd.add_user_to_group user.name, group \n assert (@crowd.group_member? user.name, group) \n\n groups = @crowd.find_group_memberships user.name\n assert (groups.length > 0)\n assert (groups.include? group)\n\n @crowd.remove_user_from_group user.name, group \n assert (not @crowd.group_member? user.name, group)\n\n groups_after_remove = @crowd.find_group_memberships user.name\n\n # ensure the user in one less group \n assert_equal groups.length - 1, groups_after_remove.length\n \n end", "def check_user_before_membership\n if current_user\n ncm_membership = current_user.get_membership(@mother)\n epicenter = Epicenter.find_by_slug(params['epicenter_id'])\n\n if epicenter != @mother and not ncm_membership\n session[:new_ncm_membership] = { \n :epicenter_id => params['epicenter_id'], \n :membership_id => params['membership_id'],\n :t => Time.now\n }\n #\n redirect_to new_epicenter_subscription_path(@mother)\n end\n else\n # it's possible that we can put the logic from \"authenticate\" method below here\n redirect_to epicenters_path\n end\n end", "def create\n\n @pending_membership = PendingMembership.new(club_id: params[:user][:pending_membership][:club_id])\n\n params[:user].delete(\"pending_membership\")\n\n @user = User.new(params[:user])\n @possible_memberships = PendingMembership.where(user_email: @user.email)\n\n if @possible_memberships.length > 0 && @user.save\n new_user = User.last\n @membership = Membership.new\n @membership.user_id = new_user.id\n @membership.club_id = @possible_memberships.first.club_id\n @possible_memberships.first.destroy\n @membership.save\n session[:user_id] = @user.id\n redirect_to @user, notice: 'Account and membership successfuly created.'\n elsif @user.save\n @pending_membership.user_id = @user.id \n @pending_membership.user_first_name = @user.first_name\n @pending_membership.user_last_name = @user.last_name\n @pending_membership.user_email = @user.email\n @pending_membership.save\n UserMailer.admin_verification(@pending_membership).deliver\n UserMailer.welcome(@user).deliver\n session[:user_id] = @user.id\n redirect_to @user, notice: 'Account successfuly created.' \n else\n # needed for render 'new' in case of form errors \n @user.pending_memberships.build\n render action: \"new\"\n end\n end", "def prepare_faculty\n unless @user.has_role?('university_secretary')\n @faculty = @user.person.faculty\n end\n end", "def update_sy_club_member\n unless self.sy_club_member.update(transferred_to_club_id: self.to_club_id)\n errors.add(:there, \"is some error while processing your transfer request. Please try again.\")\n logger.info(\"sy_club_member: #{sy_club_member.as_json}\")\n logger.info(\"sy_club_member_transfer: #{self.as_json}\")\n end\n errors.empty?\n end", "def test_adding_to_waitlist_member\n\t\tmember = Enrollments.new(:participantID => participants(:six).participantID,:courseID => \"run12345\", :startDate => '2013-10-18' )\n\t\n\t\t#Checking the capacity of the course\n\t\tactual = Course.find_by(courseID: member.courseID)\n\t\tcurrent_enrollment = Enrollments.where(courseID: member.courseID).count\n\t\tassert_operator current_enrollment, :<, actual.size, \"The size of the course is full, should fail since we are going to be waitlisting\"\n\n\t\t# Adding proper values before saving\n\t\tmember.startDate = actual.startDate\n\t\tmember.waitlist_status = 1\n\n\t\tassert member.save, \"registering a new valid member was not saved\"\n\n\t\twaitlisted_member = Enrollments.find_by(participantID: member.participantID)\n\t\texpected = 1\n\t\tassert expected, waitlisted_member.waitlist_status, \"Saved member's waitlist_status is false\"\n\tend", "def most_expensive_player_on_team \n\n the_club = choose_club #user chooses club they want to see most expensive player for\n my_club = Club.find_by(name: the_club) #use class instance find_by to find the instance of club with the name provided by user (the_club)\n club_players = my_club.players.sort_by do |player| #loops through instance of club and sorts the players by their market value (remember to change market_value from string to integer)\n player.market_value.to_i\n end\n\n most_expensive_player = club_players.last #in ascending order the last item of the sorted array is the player with the highest market value\n puts \"#{the_club}'s most expensive player is #{most_expensive_player.name}. He is worth £#{most_expensive_player.market_value}M\"\n #the_club --> user choice of club name\n #most_expensive_player.name --> use the_club name to find the specific instance of Club class. \n #Use \".players\" method to find all player instances of that specifc club (the instances of players that \n #belong to that instance of club). Use \".name\" method to retrieve attribute \"name\" of player instance. \n #Use \".market_value\" to retrieve attribute \"market_value\" of the player instance. \n\nend", "def show\n @beer_club = BeerClub.find(params[:id])\n if(not current_user.nil?)\n memberships=Membership.where(user_id: current_user.id, beer_club_id: params[:id])\n @membership=(memberships.empty? ? nil : memberships.first)\n else\n @membershi=nil\n end\n end", "def test_waistlisted_nonmember\n\t\tnon_member = enrollments(:non_member_two)\n\t\texpected = 1\n\t\tassert_equal expected, non_member.waitlist_status, \"Supposedly waitlisted non member is not waitlisted\"\n\tend", "def round3_my_party_cand\n Candidate.all.select do |can|\n if can.party == self.party and can.level_of_governments == \"National Election\"\n puts''\n puts\" \"\n puts\" #{can.name} \"\n puts\" \"\n puts\" State: #{can.state} \"\n puts\" Party: #{can.party} \"\n puts\" Age: #{can.age} \"\n puts\" Years of Experience: #{can.years_of_experience} \"\n puts\" Level of Government: #{can.level_of_governments} \"\n puts\" \"\n puts' ==================================================='\n end\n end\n end", "def roster_entries_needed(year: Time.now.year)\n ym = Ygg::Acao::Year.find_by!(year: year)\n\n membership = acao_memberships.find_by(reference_year: ym)\n return nil if !membership\n\n needed = {\n total: 2,\n high_season: 1,\n }\n\n if birth_date && compute_completed_years(birth_date, ym.renew_opening_time) >= 65\n needed[:total] = 0\n needed[:high_season] = 0\n elsif membership.board_member\n needed[:total] = 1\n needed[:high_season] = 0\n elsif membership.tug_pilot\n needed[:total] = 1\n needed[:high_season] = 0\n elsif membership.instructor\n needed[:total] = 0\n needed[:high_season] = 0\n end\n\n needed\n end", "def show\n @membership = if @wine_club.users.include? current_user\n @wine_club.memberships.where(user: current_user).first\n else\n Membership.new wine_club: @wine_club\n end\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 show_players_on_specific_club\n the_club = choose_club #user chooses club they want to see players for\n the_club = Club.find_by(name: the_club) #use class instance find_by to find the instance of club with the name provided by user (the_club)\n the_club.players.each do |player| #loops through instance of club and prints all players \n puts player.name\n end\nend", "def memberships\n @basic_plan = Plan.find(1)\n @pro_plan = Plan.find(2)\n end", "def is_legal?()\n temp_harbors =['brick', 'generic', 'generic', 'generic', 'generic', 'sheep', 'stone', 'wheat', 'wood']\n sorted_harbors = @harbors.sort\n\n #TEST TOTAL ROLLS#\n all_rolls = [6, 6, 8, 8, 2, 3, 3, 4, 4, 5, 5, 9, 9, 10, 10, 11, 11, 12]\n temp_rolls = []\n # extracts the rolls from board\n # -2 because the desert square doesn't have a roll and it is last in the array\n for i in (0..@board.length-2)\n temp_rolls << @board[i][1]\n end\n\n temp_rolls = temp_rolls.sort\n all_rolls = all_rolls.sort\n\n\n\n #TEST RESOURCE AMOUNT#\n all_resources = ['forest', 'forest', 'forest', 'forest', 'brick', 'brick', 'brick', 'wheat', 'wheat', 'wheat', 'wheat', 'sheep', 'sheep', 'sheep', 'sheep', 'stone', 'stone', 'stone']\n temp_resources = []\n # -2 because the desert square isn't a resource and it is last in the array\n for i in (0..@board.length-2) \n temp_resources << @board[i][2]\n end\n\n temp_resources = temp_resources.sort\n all_resources = all_resources.sort\n\n\n #TEST SPECIAL ROLLS#\n # special rolls are in first four locations\n for loc in (0..3)\n for other_loc in (0..3)\n return false if GameControl.neighbors(@board[loc][0]).include?(@board[other_loc][0]) \n end\n end\n\n return false unless temp_rolls == all_rolls\n return false unless temp_harbors == sorted_harbors\n return false unless temp_resources == all_resources\n return true\n end", "def verify_ownership\n set_user_training\n if UserTrainingAccessibility.new( current_user, @user_training ).is_owned\n return\n else\n flash[:error] = I18n.t(:invalid_action_request)\n redirect_to( user_trainings_path() ) and return\n end\n end", "def faculty?\n\t\tmember_of.downcase.include? \"faculty\"\n\tend", "def check_completion(plan)\n\t\tcompletion_hash = Hash.new\n\n\t\t# check the user's major(s), make sure the user has taken all the required courses on that plan\n\t\tcompletion_hash[\"major\"] = Hash.new\n\t\t@current_user.major.each do |major|\n\t\t\tcompletion_hash[\"major\"][major.id] = true\n\t\t\tmajor.course.each do |major_course|\n\t\t\t\tplan_course = PlansCourse.where(plan_id: plan.id, course_id: major_course.id).first\n\t\t\t\tif(!plan_course)\n\t\t\t\t\tcompletion_hash[\"major\"][major.id] = false\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# check the user's minor(s), make sure the user has taken all the required courses\n\t\t# or have completed the minimum hours required for the minor\n\t\tcompletion_hash[\"minor\"] = Hash.new\n\t\t@current_user.minor.each do |minor|\n\t\t\tcompletion_hash[\"minor\"][minor.id] = true\n\t\t\tcourse_hours = 0\n\t\t\tminor.course.each do |minor_course|\n\t\t\t\tplans_course = PlansCourse.where(plan_id: plan.id, course_id: minor_course.id).first\n\t\t\t\tif(!plans_course)\n\t\t\t\t\tcompletion_hash[\"minor\"][minor.id] = false\n\t\t\t\t\tbreak\n\t\t\t\telse\n\t\t\t\t\tcourse_hours += minor_course.hr_low\n\t\t\t\tend\n\t\t\tend\n\t\t\t# if student has fulfilled the required hours for the minor then he/she has completed the minor\n\t\t\tif(course_hours >= minor.total_hours)\n\t\t\t\tcompletion_hash[\"minor\"][minor.id] = true\n\t\t\tend\n\t\tend\n\n\t\t# check the user's concentration(s), make sure the user has taken all the required courses\n\t\tcompletion_hash[\"concentration\"] = Hash.new\n\t\t@current_user.concentration.each do |concentration|\n\t\t\tcompletion_hash[\"concentration\"][concentration.id] = true\n\t\t\tconcentration.course.each do |concentration_course|\n\t\t\t\tplans_course = PlansCourse.where(plan_id: plan.id, course_id: concentration_course.id).first\n\t\t\t\tif(!plans_course)\n\t\t\t\t\tcompletion_hash[\"concentration\"][concentration.id] = false\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# check whether the user has finished all the distributions\n\t\tcompletion_hash[\"distribution\"] = Hash.new\n\t\tDistribution.find_each do |distribution|\n\n\t\t\t# must complete every courses for CORE\n\t\t\tif(distribution.title == \"CORE\")\n\t\t\t\tcompletion_hash[\"distribution\"][distribution.id] = true\n\t\t\t\tdistribution.course.each do |distribution_course|\n\t\t\t\t\tplans_course = PlansCourse.where(plan_id: plan.id, course_id: distribution_course.id).first\n\t\t\t\t\tif(!plans_course)\n\t\t\t\t\t\tcompletion_hash[\"distribution\"][distribution.id] = false\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\telse\n\t\t\t\t# must complete at least one course for other distributions\n\t\t\t\tdistribution.course.each do |distribution_course|\n\t\t\t\t\tcompletion_hash[\"distribution\"][distribution.id] = false\n\t\t\t\t\tplans_course = PlansCourse.where(plan_id: plan.id, course_id: distribution_course.id).first\n\t\t\t\t\tif(plans_course)\n\t\t\t\t\t\tcompletion_hash[\"distribution\"][distribution.id] = true\n\t\t\t\t\t\tbreak\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# returns a hash\n\t\treturn completion_hash\n\tend", "def can_access_club? club_id\n current_user.clubs.find(club_id)\n end", "def create_courts\n futbol = Sport.where(:name => 'futbol').first\n tenis = Sport.where(:name => 'tenis').first\n paddle = Sport.where(:name => 'paddle').first\n\n # court_quantity '*' indicates how many courts already has\n # @*_quantity indicates how many tha user wants\n\n ### Futbol Courts\n diffFutbol = court_quantity('futbol') - @futbol_quantity.to_i \n\n if(diffFutbol > 0)\n diffFutbol.times { self.courts.delete(self.courts.where('sport_id = ?',futbol.id).last)}\n end\n\n if(diffFutbol < 0)\n diffFutbol.abs.times { self.courts.build sport_id: futbol.id }\n end\n\n\n ### Tenis Courts\n\n diffTenis = court_quantity('tenis') - @tenis_quantity.to_i \n\n if(diffTenis > 0)\n diffTenis.times { self.courts.delete(self.courts.where('sport_id = ?',tenis.id).last)}\n end\n\n if(diffTenis < 0)\n diffTenis.abs.times { self.courts.build sport_id: tenis.id }\n end\n\n ### Paddle Courts\n\n diffPaddle = court_quantity('paddle') - @paddle_quantity.to_i \n\n if(diffPaddle > 0)\n diffPaddle.times { self.courts.delete(self.courts.where('sport_id = ?',paddle.id).last)}\n end\n\n if(diffPaddle < 0)\n diffPaddle.abs.times { self.courts.build sport_id: paddle.id }\n end \n end", "def create\n @club = Club.new(params[:club])\n @club.user = current_user\n\n if @club.save\n @club.memberships.create!(couple_id: current_user.activeCouple.id, verified: true)\n redirect_to root_path, notice: t('club.create')\n else\n render :new\n end\n end", "def test_unexistent_member_registering\n\t\tregistering_member = Enrollment.new(:participantID => \"abc12345\", :courseID => \"yoga0123\")\n\t\tassert Course.find_by(courseID: registering_member.courseID), \"Course is not in Courses database\"\n\t\tassert !Participant.find_by(participantID: registering_member.participantID), \"non existent member was found in Participant database\"\n\tend", "def invisible_testSuccess(c, ci, cv, state)\n @state[COMMITMENT].any? {|terms| terms.size == 4 and terms[0] == c and terms[1] == ci}\nend", "def check\n \n end", "def check\n \n end", "def phase_one\n introduction\n title \"Phase One\"\n losers = 0\n immune_members = []\n 8.times do\n losing_tribe = @borneo.tribes.shuffle.first\n puts \"The losing tribe is #{losing_tribe}\".red\n loser = losing_tribe.tribal_council()#no immune members\n puts \" The loser member is #{loser}\"\n losers += 1\n counting = 0\n @borneo.tribes.each{|tribe| counting += tribe.members.length}\n puts \" #{losers} gone!\"\n puts \" #{counting} remaining players\"\n end\nend", "def round2_my_party_cand\n Candidate.all.select do |can|\n if can.party == self.party and can.level_of_governments == \"State Election\"\n puts''\n puts\" \"\n puts\" #{can.name} \"\n puts\" \"\n puts\" State: #{can.state} \"\n puts\" Party: #{can.party} \"\n puts\" Age: #{can.age} \"\n puts\" Years of Experience: #{can.years_of_experience} \"\n puts\" Level of Government: #{can.level_of_governments} \"\n puts\" \"\n puts' ==================================================='\n end\n end\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 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 suction_cup?\n @suction_cup == 1\n end", "def correct_club\n @club = Club.find(params[:id])\n redirect_to(root_url) unless current_club?(@club) || current_club.admin?\n end", "def calc_im_thick_club(user, target)\n THICK_CLUB_POKEMON.include?(user.db_symbol) ? 2 : 1\n end", "def validation_of_user_input(name, cohort, city, hobby)\n\n if !name.empty? && ( !cohort.empty? && @months.include?(\"#{cohort}\")) && !city.empty? && !hobby.empty?\n single_student = {month: \"#{cohort}\", name: name, city: city, hobby: hobby}\n @students << single_student\n list_or_continue_prompt\n elsif !@months.include?(\"#{cohort}\") && !name.empty? && !cohort.empty? && !city.empty? && !hobby.empty?\n puts \"You did´t enter a valid month, please try again!\\n\\n\"\n put_in_user\n#prompt when u haven´t entered all information, calls put_in_user\n else name.empty? && cohort.empty? && city.empty? && hobby.empty?\n puts \"Please fill in all fields\\n!\"\n list_or_continue_prompt\n end\nend", "def credit_unlimited?\n #if prepaid?\n # raise \"Prepaid users do not have credit\"\n credit == -1\n end", "def is_valid?\n instructor_approved || (non_rejected_student_memberships.size >= assignment.group_min)\n end", "def judge\r\n # If all dead determinant is true, or number of members in party is 0\r\n if $game_party.all_dead? or $game_party.actors.size == 0\r\n # If possible to lose\r\n if $game_temp.battle_can_lose\r\n # Return to BGM before battle starts\r\n $game_system.bgm_play($game_temp.map_bgm)\r\n # Battle ends\r\n battle_end(2)\r\n # Return true\r\n return true\r\n end\r\n # Set game over flag\r\n $game_temp.gameover = true\r\n # Return true\r\n return true\r\n end\r\n # Return false if even 1 enemy exists\r\n for enemy in $game_troop.enemies\r\n if enemy.exist?\r\n return false\r\n end\r\n end\r\n # Start after battle phase (win)\r\n start_phase5\r\n # Return true\r\n return true\r\n end", "def fellow_cult_members\n # we want a list of followers, so SELECT is a good tool\n # .any? will return true or false if ANY elements return true for the block\n # .include? will see if an array includes a given element\n Follower.all.select do |follower|\n follower != self && follower.cults.any? do |cult|\n self.cults.include?(cult)\n end\n end\n end", "def place_apprentices_by_requests\n def find_student_by_request(team)\n this_obj = team[:objective_id]\n these_studs = @sem_studs_hash\n .select{|x|\n x[:learn_request] == this_obj &&\n @unplaced_students.include?(x[:user])\n }.map{|x| x[:user]}\n \n this_score = @score_hash.detect{|x|\n x[:obj] == this_obj &&\n these_studs.include?(x[:user]) &&\n x[:total_keys] < 1\n }\n \n if this_score\n this_user = this_score[:user]\n add_to_group(team, this_user)\n adjust_unplaced_students(this_user)\n end\n end\n \n 4.times do\n @teams.each do |team|\n find_student_by_request(team)\n end\n end\\\n end", "def test_non_member_registering_early_bird\n\t\tnon_member = Enrollments.new(:participantID => participants(:non_member_one).participantID,:courseID => \"run12345\", :startDate => '2013-10-18' )\n\t\t\n\t\t# Checking if the member exists by the expiry date to be greater than tomorrow's date, but if nil or expired date, then participant is not a member\n\t\tassert_nil participants(:non_member_one).expirydate, \"Member is not a member\"\n\n\t\tearly_bird_last_date = '2013-11-01'\n\n\t\t#Date.today since creating the enrollment will of today\n\t\tassert_operator Date.today, :<, Date.parse(early_bird_last_date), \"Member registered too late for early bird\"\n\tend", "def main_team_member?(pr, months_back)\n (committer_team(pr, months_back) + merger_team(pr, months_back)).uniq.include? requester(pr)\n end", "def goals_against(club)\n if finished?\n if club == local\n return guest_goals\n end\n\n if club == guest\n return local_goals\n end\n end\n\n 0\n end", "def verify_membership(site, roles, isActive, sections, membership, sourcedid = nil)\n unless membership\n membership = self.memberships.build()\n membership.site_id = site.id\n end\n membership.active = isActive\n\n # Remove any siteroles that aren't in roles param\n membership.siteroles.select { |siterole| !roles.delete(siterole.role.id) }.map { |siterole| membership.siteroles.destroy(siterole) }\n\n # Add any siteroles from roles param that don't exist already\n roles.each do |role_id, role|\n # Admin is not a siterole. This might change in the future?\n continue if role.roleurn =~ /admin/i\n unless siterole = site.siteroles.find_by_role_id(role.id)\n siterole = site.siteroles.build()\n siterole.role_id = role_id\n site.save\n end\n membership.siteroles.push(siterole)\n end\n\n membership.sourcedid = sourcedid || membership.sourcedid\n \n membership.save if membership.changed?\n membership.sections = sections if sections && sections.count > 0 && sections != membership.sections\n\n # Add user to unassigned section if they don't have any sections\n if membership.sections.empty? && record_attendance?(site)\n membership.sections.push(site.default_section)\n end\n\n membership\n end", "def round1_my_party_cand\n Candidate.all.select do |can|\n if can.party == self.party and can.level_of_governments == \"Local Election\"\n puts''\n puts\" \"\n puts\" #{can.name} \"\n puts\" \"\n puts\" State: #{can.state} \"\n puts\" Party: #{can.party} \"\n puts\" Age: #{can.age} \"\n puts\" Years of Experience: #{can.years_of_experience} \"\n puts\" Level of Government: #{can.level_of_governments} \"\n puts\" \"\n puts' ==================================================='\n end\n end\n end", "def pass_student (student_name, test_name)\n test_to_change = BoatingTest.all.select {|test|\n test.name == test_name &&\n test.student.first_name == student_name &&\n test.instructor == self\n }\n\n if test_to_change[0] == nil\n test_to_change << BoatingTest.new(Student.find_student(student_name),test_name, \"passed\", self)\n else\n test_to_change[0].status = \"passed\"\n end\n test_to_change\n end", "def show\n @clubs = Club.where.not(id: @event.club_id)\n @curr_club = Club.where(id: @event.club_id).take\n @unshared_club ||= []\n @shared_club ||= []\n @clubs.each do |club|\n if !SharedEvent.exists?(:eventId => @event.id, :clubId => club.id)\n @unshared_club << club\n elsif SharedEvent.exists?(:eventId => @event.id , :clubId => club.id, :approved => true)\n @shared_club << club\n end\n end\n \n end", "def accountability_groups(students)\n\nthrowaway = []\nunit = []\ngroups = []\n\n3.times do\n\tthrowaway = students.dup\n\ti = 0\n\n\twhile(throwaway.size > 0) do\n\n\t\tunit << throwaway.sample(4) if throwaway.size % 4 == 0 \n\t\tunit << throwaway.sample(5) if throwaway.size % 4 != 0\n\t\tunit[i].each { |student| throwaway.delete(student) }\n\t\ti += 1\n\tend\n\n\tgroups << unit.dup\n\tunit.clear\nend\ngroups\nend", "def add_team_memberships\n this_season_key, school_year_text = TeamMembership.this_season_and_year(time_now: time_now)\n TeamMembership.create!({\n student_id: shs_freshman_mari.id,\n activity_text: 'Competitive Cheerleading Varsity',\n coach_text: 'Fatima Teacher',\n season_key: this_season_key,\n school_year_text: school_year_text\n })\n TeamMembership.create!({\n student_id: shs_senior_kylo.id,\n activity_text: 'Cross Country - Boys Varsity',\n coach_text: 'Jonathan Fishman',\n season_key: this_season_key,\n school_year_text: school_year_text\n })\n end", "def check_team_member\n if owner_team.user.id == guest_team.user.id || owner_team.user.id == guest_team.teammate.id || owner_team.teammate.id == guest_team.user.id || owner_team.teammate.id == guest_team.teammate.id\n errors.add(:game, \"can not have the same member in 2 team\")\n end \n end", "def extra_curriculars(*clubs)\n clubs.each { |club| puts \"After school, I'm involved with #{club}\" }\n end", "def singup (gym, cost)\n new_memebership = Membership.new(cost , self, gym)\n end", "def can_submit?\n # First check the state machine to see if it is Ok to submit based on the\n # current state\n b = super()\n if b\n # Now check that the CP has funding\n b = false unless total_cost > 0\n #b = false unless funding_difference <= 0\n end\n b\n end", "def no_red_numbers\n if self.player.club.cash <= 0\n self.errors[:base] = I18n.t('training.errors.red_numbers')\n end\n end", "def withdraw_using_check(amount)\n\n if checks_used < 3\n if ((balance - (amount)) >= -10) #Allows the account to go into overdraft up to -$10 but not any lower\n @balance = (@balance - (amount))\n printf(\"Balance: $%.2f\\n\", balance) #****test this ******\n @checks_used = checks_used + 1 #when you're changing the value of the instance variable (this wouldnt happen if you werent in the class) so it needs the @ bc it needs to access the method that changes it\n puts \"Checks used: #{@checks_used}\" #but checks_used + 1 doesnt need the @ bc its accessing the value of the instance variable @checks\n else\n puts \"Nope.\"\n printf(\"Balance: $%.2f\\n\", balance)\n end\n\n else\n\n if ((balance - (amount)) >= -10) #Allows the account to go into overdraft up to -$10 but not any lower\n @balance = (@balance - (amount)) - 2 #The user is allowed three free check uses in one month, but any subsequent use adds a $2 transaction fee\n printf(\"Balance: $%.2f\\n\", balance)\n @checks_used = checks_used + 1\n puts \"Checks used: #{@checks_used}\"\n else\n puts \"Nope.\"\n printf(\"Balance: $%.2f\\n\", balance)\n end\n\n end\n\n end", "def metropolitan_club_admin?\n metropolitan_club.leaders.include?(self)\n end", "def valid_card_number\n return if self.number.blank? or not self.member\n return if self.club && self.club.uses_citylife?\n\n # Only check the rules of current cards\n if self.academic_year == Member.current_academic_year\n range = self.member.club.card_range_for self.card_type\n if !range.include?(self.number)\n errors.add(:number, \"valt niet in het toegekende bereik\")\n end\n end\n end", "def test_too_many_guests_in_room__true()\n @room_1.check_in_guest(@guest_1)\n @room_1.check_in_guest(@guest_2)\n @room_1.check_in_guest(@guest_3)\n @room_1.check_in_guest(@guest_4)\n @room_1.check_in_guest(@guest_5)\n @room_1.check_in_guest(@guest_6)\n @room_1.check_in_guest(@guest_7)\n assert_equal(true, @room_1.too_many_guests_in_room)\n # @room_1.check_out_guest(@guest_7)\n # assert_equal(false, @room_1.too_many_guests_in_room)\n end" ]
[ "0.67090636", "0.66647357", "0.64367205", "0.6360402", "0.61423296", "0.61119545", "0.6102576", "0.60052264", "0.59736264", "0.59422004", "0.59222513", "0.5799681", "0.5764733", "0.5761775", "0.5727484", "0.5721266", "0.56899226", "0.5656122", "0.56472737", "0.56111866", "0.56041306", "0.5593696", "0.5584747", "0.5580994", "0.55666345", "0.5552458", "0.55519783", "0.5551788", "0.5548452", "0.5540439", "0.55327463", "0.55218774", "0.5521618", "0.55136806", "0.5505833", "0.55045044", "0.5501729", "0.55005324", "0.54901487", "0.54512435", "0.54482377", "0.54431057", "0.54398996", "0.5429482", "0.5414854", "0.5411373", "0.5407721", "0.5392554", "0.5391494", "0.5385762", "0.53728867", "0.53672063", "0.5358721", "0.53475046", "0.53345746", "0.5331678", "0.53279436", "0.53013754", "0.52889556", "0.52889305", "0.52873874", "0.52869505", "0.5283387", "0.52833265", "0.5282731", "0.5282383", "0.5279702", "0.5273504", "0.52734405", "0.52734405", "0.5272611", "0.5255064", "0.52550375", "0.52547264", "0.5253498", "0.52520597", "0.5244972", "0.5237938", "0.52361524", "0.5236027", "0.5235984", "0.52329993", "0.5230816", "0.5230271", "0.5228059", "0.522472", "0.5224097", "0.5223681", "0.52212495", "0.52199143", "0.5214039", "0.5211914", "0.5207423", "0.5205686", "0.5199972", "0.51994896", "0.51940197", "0.5193548", "0.5188315", "0.5187666", "0.5187192" ]
0.0
-1
Creates a MageeTextEdit param parent, name: The QWidget's parent and name
def initialize(parent = nil, name = nil) super(parent, name) viewport.set_w_flags(Qt::WNoAutoErase | Qt::WStaticContents) set_static_background(true) @invalid_rows = [] @model = TextModel.new() @model.set_first_line_in_view_handler { first_line_in_view } @model.set_last_line_in_view_handler { last_line_in_view } @model.set_changed_handler { |invalid_rows| @invalid_rows = invalid_rows; repaint_contents(false) } set_enabled(true) set_focus_policy(Qt::Widget::StrongFocus) resize(500, 500) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_NewParent(value)\n set_input(\"NewParent\", value)\n end", "def new_parent=(a_parent)\n @new_parent = a_parent\n end", "def t(name, *args)\n field = JTextField.new *args\n field.name = name\n field\n end", "def parent=(_arg0); end", "def parent=(_arg0); end", "def parent=(_arg0); end", "def parent=(_arg0); end", "def parent=(_arg0); end", "def main_window\r\n super\r\n # Make windows\r\n @edit_window = Window_NameEdit.new(@actor, $game_temp.name_max_char)\r\n @input_window = Window_NameInput.new\r\n end", "def quick_editfield(how, what)\n QuickEditField.new(self, how, what, parent_widget, window_id, :editfield)\n end", "def set_Parent(value)\n set_input(\"Parent\", value)\n end", "def textarea(name = \"\", cols = 70, rows = 10) # :yield:\n attributes = if name.kind_of?(String)\n { \"NAME\" => name, \"COLS\" => cols.to_s,\n \"ROWS\" => rows.to_s }\n else\n name\n end\n super(attributes)\n end", "def w(type, params = {})\n puts \"creating #{type.inspect} with #{params.inspect}\"\n klass = eval(camelize(type.to_s))\n widget = klass.new\n\n if (params[:name])\n name = params[:name]\n end\n\n if params[:text]\n widget.text = params[:text]\n end\n\n if (name)\n name_hash[name] = widget\n end\n puts \"returning #{widget.inspect}\"\n widget\n end", "def new_elem\n @type_name = params[:type]\n @name =eval(@type_name).to_p_name\n @parent_id = params[:parent_id]\n end", "def create_name_window\n @edit_window = Window_NameEdit.new(@actor, 10)\n @input_window = Window_NameInput.new(@edit_window)\n @input_window.set_handler(:ok, method(:on_input_ok))\n @edit_window.hide\n @input_window.hide\n @input_window.deactivate\n end", "def builder_args\n [ name ]\n end", "def define_popup_parent(view, component, model, transfer)\n p :define_popup_parent\n view.parent_component = @main_view_component\n end", "def parent_widget\n nil\n end", "def parent_widget\n nil\n end", "def initialize(p_text, p_parent, p_args)\n\t\t\tsuper(p_text, p_parent)\n\t\t\tdo_initialize(p_args)\n\t\tend", "def parent=(p)\n @parent = p\n end", "def set_parent(parent)\n @parent = parent\n end", "def cparent_params\n params.require(:cparent).permit(:name)\n end", "def set_parent(parent)\n @parent = parent\n end", "def set_parent(parent)\n @parent = parent\n end", "def set_parent(parent)\n @parent = parent\n\n self\n end", "def initialize form, config={}, &block\n\n # setting default first or else Widget will place its BW default\n #@color, @bgcolor = ColorMap.get_colors_for_pair $bottomcolor\n super\n @height = 1\n @color_pair = get_color $datacolor, @color, @bgcolor\n @scroll_pair = get_color $bottomcolor, :green, :white\n #@window = form.window\n @editable = false\n # you can set to true upon creation, or use F3 on vimsplit to\n # toggle focusable\n @focusable = false\n @repaint_required = true\n @_events.push(:DRAG_EVENT)\n map_keys\n unless @parent\n raise ArgumentError, \"row col and length should be provided\" if !@row || !@col || !@length\n end\n #if @parent\n #@parent.bind :ENTER_ROW do |p|\n ## parent must implement row_count, and have a @current_index\n #raise StandardError, \"Parent must implement row_count\" unless p.respond_to? :row_count\n #self.current_index = p.current_index\n #@repaint_required = true #requred otherwise at end when same value sent, prop handler\n ## will not be fired (due to optimization).\n #end\n #end\n end", "def initialize(args=nil)\n super(args)\n @field = Box.new(name:'field', parent:self)\n @content = Box.new(name:'content', parent:@field)\n end", "def insert_node(parent, type, text, additional = '', object = nil)\n text = text.to_s\n additional = additional.to_s if additional\n iter = self.model.append(parent)\n iter.set_value(Value::ICON, render_icon(@formats[type][0], Gtk::IconSize::MENU, text))\n iter.set_value(Value::TEXT, text)\n iter.set_value(Value::ADDITIONAL_TEXT, additional) if additional\n iter.set_value(Value::OBJECT, object) if object\n iter\n end", "def parent=(parent)\n @parent = parent\n end", "def parent=(parent)\n @parent = parent\n end", "def initialize(parent); end", "def initialize(p_form, p_parent)\n\n # Call base class constructor\n super(p_parent)\n\n # Initialize form and parent\n @form = p_form\n @parent = p_parent\n\n # Initialize attributes\n @tools = []\n end", "def make_muck_parent_fields(parent)\n return if parent.blank?\n %Q{<input id=\"parent_id\" type=\"hidden\" value=\"#{parent.id}\">\n <input id=\"parent_type\" type=\"hidden\" value=\"#{parent.class.to_s}\">}\n end", "def initialize(parent)\n @parent = parent\n end", "def parent=(parent)\n @parent = parent\n end", "def initialize(*)\n super\n model.plugin :forme\n @params_name = model.new.forme_namespace\n end", "def name\n self.widget.name\n end", "def create_path_edit\n\t\t\n\t\t\t# Create actual Path edit -- LineEditWithHint\n\t\t\t@path_edit = Qt::LineEditWithHint.new(\n\t\t\t\t@form.directoryEditPlaceholder.toolTip, @parent,\n\t\t\t\t{ \n\t\t\t\t\t:validate_callback => lambda { |path| check_path(path) },\n\t\t\t\t\t:done_callback => lambda { set_folder_icon(false) },\n\t\t\t\t :warn_text => @form.directoryEditPlaceholder.statusTip \n\t\t\t\t}\n\t\t\t)\n\t\t\t\t\n\t\t\t# 'Inherit' minimum size\n\t\t\t@path_edit.minimumSize = @form.directoryEditPlaceholder.minimumSize\n\t\t\t@path_edit.prepare_for_immediate_keypress\n\t\t\t\n\t\t\t# Remove placeholder and add actual (extended) widget\n\t\t\tGuiUtils.replace_grid_widget({\n\t\t\t\t:grid => @form.gridLayout, \n\t\t\t\t:old_widget => @form.directoryEditPlaceholder,\n\t\t\t\t:new_widget => @path_edit,\n\t\t\t\t:row => 0, :col => 1,\n\t\t\t\t:col_span => 2\n\t\t\t})\n\t\tend", "def initialize(name)\n @name = name\n @parent = nil\n end", "def add_editor!(name)\n Vedeu::Editor::Document.store(name: name)\n end", "def initialize(parent_element, name, options)\n @parent = parent_element\n @name = name\n @options = options\n end", "def parse_text parent, indent # :nodoc:\n parent << build_paragraph(indent)\n end", "def create_league_champion_text_box\n @league_champ_box = League_Champion_Text_Box.new(@viewport)\n end", "def initialize(name, text, show: true)\n @name = name\n @text = text\n @show = show || false\n end", "def parent=(value)\n @parent = value\n end", "def create\n super\n push_binding(instance_eval(\"#{name.to_s}\"))\n end", "def new_text_input\n end", "def set_ParentID(value)\n set_input(\"ParentID\", value)\n end", "def set_ParentID(value)\n set_input(\"ParentID\", value)\n end", "def set_ParentID(value)\n set_input(\"ParentID\", value)\n end", "def create_trainer_infos_text_box\n @trainer_infos_box = Trainer_Infos_Text_Box.new(@viewport)\n end", "def parent=(instance)\n @controller.instance_variable_set(:\"@#{parent_name}\", instance)\n end", "def initialize(config = {}, parent = nil)\n # @session = Netzke::Base.session\n @passed_config = config # configuration passed at the moment of instantiation\n @parent = parent\n @name = config[:name].nil? ? short_widget_class_name.underscore : config[:name].to_s\n @global_id = parent.nil? ? @name : \"#{parent.global_id}__#{@name}\"\n @flash = []\n end", "def initialize(name = Vedeu.focus)\n @name = present?(name) ? name : Vedeu.focus\n end", "def curatorEditingArea _args\n \"curatorEditingArea _args;\" \n end", "def initialize(parent)\n @parent = parent\n end", "def add_wheel_input(name); end", "def initialize(text = '', **options, &block)\n super(Gtk::Entry.new, **options, &block)\n self.text = text\n end", "def parent=(par)\n if self.parent\n self.parent.children.delete(self) #delete ourselves \n end\n \n @parent = par\n self.parent.children << self unless self.parent.nil?\n end", "def initialize(parent_notebook)\n\t\t@row = 0 # attach widgets top to bottom in grid\n\t\t@obj = nil\n\t\t@parent_notebook = parent_notebook\n\t\t@grid = Gtk::Grid.new\n\t\tsuper(:vertical, 0)\n\t\tself.pack_start(@grid, :expand => false, :fill => false, :padding => 0)\n\t\t@grid.column_spacing = 8\n\tend", "def ctrlParent _args\n \"ctrlParent _args;\" \n end", "def onCmdNew( obj, sig, par )\n\t\t\twin = TicketEditWindow.new( getApp(), @mdimenu, @mdiclient )\n\t\t\twin.create\n\t\t\twin.show\n\t\t\t@mdiclient.setActiveChild( win )\n\t\t\treturn 1\n\t\tend", "def new(name)\n if @data.create(name)\n \"You created widget #{name}\"\n else\n \"#{name} already exists!\"\n end\n end", "def new\n if params[:parent]\n @parent = Source.find(params[:parent])\n @source = Source.new(parent_id: @parent.id, source_type: @parent.source_type, comment: \"Original name was #{@parent.name}, original author was #{@parent.author.name}\")\n else\n @source = Source.new\n end\n\n respond_to do |format|\n format.html { render layout: 'form' }# new.html.erb\n format.json { render json: @source }\n end\n end", "def create_contents\n @shell.layout = GridLayout.new(6, true)\n\n Label.new(@shell, SWT::NONE).text = \"Your name:\"\n\n @name_box = Text.new(@shell, SWT::BORDER)\n layout_data = GridData.new(GridData::FILL_HORIZONTAL)\n layout_data.horizontalSpan = 4\n @name_box.layout_data = layout_data\n\n @status_label = Label.new(@shell, SWT::BORDER)\n layout_data = GridData.new(GridData::FILL_HORIZONTAL)\n layout_data.horizontalSpan = 3\n @status_label.layout_data = layout_data \n\n\n\t\t@button = Button.new(@shell, SWT::PUSH)\n\t\t@button.text = \"Click me!\"\n\t\tlayout_data = GridData.new(GridData::END, GridData::CENTER, false, false)\n\t\tlayout_data.horizontalSpan = 6\n\t\t@button.layout_data = layout_data\n @button.addSelectionListener do\n handle_click\n end\n end", "def new\n @az_tr_text = AzTrText.new\n @az_tr_text.owner_id = params[:owner_id]\n @title = 'Новый шаблон текста технического задания'\n\n prepare_default_data()\n \n #@data_types = AzBaseDataType::DataTypes.collect{|dt| puts dt.inspect}\n #[dt[:name], dt[:id]]\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @az_tr_text }\n end\n end", "def new\n find_name\n find_licenses\n @description = NameDescription.new\n @description.name = @name\n\n # Render a blank form.\n initialize_description_source\n end", "def initialize(name, parent = nil)\n @name = name\n @options = []\n @commands = {}\n @actions = []\n @map = {}\n @parent = parent\n end", "def par_name\n parent.try(:name) || \"\"\n end", "def new\n @parent_id = params[:parent_id] #|| default_parent.id\n @partner = Partner.new\n @partner.parent_id = @parent_id\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @partner }\n format.js\n end\n end", "def initialize(params={})\n @parent ||= params[:parent]\n if params[:model] then\n @entities ||= params[:model].find(:all).entities\n else\n @entities ||= params[:entities]\n @entities ||= @parent.entities if @parent && @parent.respond_to?(:entities)\n end\n params ||= params\n params.delete(:parent)\n params.delete(:entities)\n \n if !params[:options] && !params[:option_values] then\n params[:option_values] ||= [ '' ]\n params[:option_labels] ||= [ tl(:select_option) ]\n @entities.each { |e|\n params[:option_values] << e.pkey\n params[:option_labels] << e.label\n }\n end\n \n if params[:name].empty? then\n params[:name] ||= @entities.first.class.primary_key_name if @entities.first\n end\n if @parent then\n params[:onchange] ||= \"Aurita.Main.selection_list_add({ select_field:'#{params[:id]}', \n name: '#{@parent.options_name}' });\" \n end\n \n super(params)\n end", "def document_window(name)\n Window.new {\n title \"Document: \" + name\n\t\t\n text = TextArea.new {\n ...\n }\n }\nend", "def parent_name\n @parent_name || super\n end", "def parent_name\n @parent_name || super\n end", "def startEdit\n super\n create_text_field unless @text_field\n\n set_text nil\n set_graphic @text_field\n @text_field.select_all\n end", "def initialize(iParent, iSC, iRootTag, iController, iType = nil, iInitialTag = nil)\n if (iSC == nil)\n @Type = iType\n else\n @Type = iSC.Type\n end\n\n super(iParent,\n :title => \"Edit Shortcut (#{@Type.pluginDescription[:PluginName]})\",\n :style => Wx::DEFAULT_DIALOG_STYLE|Wx::RESIZE_BORDER|Wx::MAXIMIZE_BOX\n )\n\n # First create all the panels that will fit in this dialog\n require 'pbs/Windows/ContentMetadataPanel'\n @ContentMetadataPanel = ContentMetadataPanel.new(self, @Type, iController)\n if (iSC == nil)\n lTags = {}\n if (iInitialTag != nil)\n lTags[iInitialTag] = nil\n end\n createTagsPanel(self, iRootTag, lTags)\n @ContentMetadataPanel.setData(iType.createEmptyContent, {'title' => 'New Shortcut', 'icon' => nil})\n else\n createTagsPanel(self, iRootTag, iSC.Tags)\n @ContentMetadataPanel.setData(iSC.Content, iSC.Metadata)\n end\n lButtonsPanel = createButtonsPanel(self)\n # Fit them all now, as we will use their true sizes to determine proportions in the sizers\n @ContentMetadataPanel.fit\n @TagsPanel.fit\n\n # Then put everything in place using sizers\n\n # Create the main sizer\n lMainSizer = Wx::BoxSizer.new(Wx::VERTICAL)\n self.sizer = lMainSizer\n\n # First sizer item is the group of 3 panels (content, metadata and tags)\n l3PanelsSizer = Wx::BoxSizer.new(Wx::HORIZONTAL)\n\n l3PanelsSizer.add_item(@ContentMetadataPanel, :flag => Wx::GROW, :proportion => @ContentMetadataPanel.size.width)\n # A little space\n l3PanelsSizer.add_item([8,0], :proportion => 0)\n # The second part of the 3 Panels sizer is the panel of tags\n l3PanelsSizer.add_item(@TagsPanel, :flag => Wx::GROW, :proportion => @TagsPanel.size.width)\n\n lMainSizer.add_item(l3PanelsSizer, :flag => Wx::GROW|Wx::ALL, :border => 8, :proportion => 1)\n # The second part of the main sizer is the panel containing the buttons\n lMainSizer.add_item(lButtonsPanel, :flag => Wx::GROW|Wx::ALL, :border => 8, :proportion => 0)\n\n self.fit\n\n end", "def set_ParentID(value)\n set_input(\"ParentID\", value)\n end", "def build_widget\r\n Qt::Widget.new do\r\n # Widget Properties\r\n self.window_title = \"QR Generator Qt\"\r\n self.maximum_size = Qt::Size.new(500, 500)\r\n self.minimum_size = Qt::Size.new(300, 400)\r\n\r\n self.resize self.minimum_size\r\n \r\n self.set_window_icon Qt::Icon.new(MAIN_ICON_PATH)\r\n # Widget layout\r\n self.layout = Qt::VBoxLayout.new\r\n end\r\n end", "def parent=(obj); end", "def new\n\t# if :name parameter is present, then pass it in as the cuisine type\n\t\tif !params[:name].nil?\n\t\t\t@name = params[:name]\n\t\tend\n\tend", "def widget_params\n params.require(:widget).permit(:name)\n end", "def setting(name, options = {}, &block)\n settings[name] = InputField.new(name, options, &block)\n end", "def initialize(parent)\n @gtkObject = Gtk::Box.new :vertical\n @gtkObject.set_name 'test'\n\t\t@cb = Gtk::ComboBoxText.new\n @cb.append_text 'Général'\n @cb.append_text 'Contre La Montre'\n @cb.append_text 'Mode Facile'\n @cb.append_text 'Mode Moyen'\n @cb.append_text 'Mode Difficile'\n\t\t@gtkObject.add(@cb)\n\t\tstore = Gtk::ListStore.new(String, Integer)\n\t\ttreeview = Gtk::TreeView.new(store)\n\t\tsetup_tree_view(treeview)\n\t\tdata = desereliseJoueurs\n\n\t\t\tif(data != nil)\n\t\t\t\tdata.each_with_index do |e, i|\n\t\t \t \t\titer = store.append\n\t\t \t\t\tstore.set_value(iter, 0, data[i].donneNom)\n\t\t \t\t\tstore.set_value(iter, 1, data[i].donneScore)\n\t\t\t\tend\n\t\t\tend\n\t\t\t\n\n\t\t\tboxTree = Gtk::Box.new(:vertical, 10)\n\t\t\tboxTree.border_width = 10\n\t\t\t@gtkObject.pack_start(boxTree,:expand => true, :fill => true, :padding => 0)\n\n\t\t\tscrolled_win = Gtk::ScrolledWindow.new\n\t\t\tscrolled_win.add_with_viewport(treeview)\n\t\t\tscrolled_win.set_policy(:automatic,:automatic)\n\t\t\tboxTree.pack_start(scrolled_win,:expand => true, :fill => true, :padding => 0)\n\n\t\t\tseparator = Gtk::Separator.new(:horizontal)\n\t\t\t@gtkObject.pack_start(separator, :expand => false, :fill => true, :padding => 0)\n\t\t\tseparator.show\n\n\n\t\t\tbRetour = MenuItemUi.new(:back,MenuAssets.getInstance())\n\t\t\tbRetour.setOnClickEvent(Proc.new{\n\t\t\t\tparent.changeBackground(\"menuPrincipal\")\n\t\t\t\tparent.display(parent.mainMenu)\n\t\t\t})\n\t\t\t@gtkObject.add(bRetour.gtkObject)\n\t\t\t\n\t\t\tif(data != nil)\n\t\t\t\t@cb.signal_connect \"changed\" do |w, z|\n\t\t \t\t\tselectn(w,z,data,store)\n\t\t\t\tend\n\t\t\tend\n\tend", "def add_node(name, parent, content: nil, attribute: false)\n unless String === name\n name = name.attributes['name'].value\n end\n\n node = BuildNode.new(name, parent: parent, attribute: attribute)\n\n if content\n node.contents << content\n end\n\n parent.children << node\n\n node\n end", "def initialize(main_window)\n\t\tsuper()\n\t\t@main_window = main_window\n\t\t@grid_sensitive_spin_button_list = Array.new\n\t\tself.enable_popup = true\n\t\tself.add(w = Box_Widget.new(self), :tab_label => 'Box')\n\t\tself.set_tab_reorderable(w, true)\n\t\tself.add(w = Net_Widget.new(self), :tab_label => 'Net')\n\t\tself.set_tab_reorderable(w, true)\n\t\tself.add(w = Pin_Widget.new(self), :tab_label => 'Pin')\n\t\tself.set_tab_reorderable(w, true)\n\t\tself.add(w = Path_Widget.new(self), :tab_label => 'Path')\n\t\tself.set_tab_reorderable(w, true)\n\t\tself.add(w = Sym_Widget.new(self), :tab_label => 'Sym')\n\t\tself.set_tab_reorderable(w, true)\n\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 initialize( name, face, type, value, parent )\n @name = name\n @face = face\n @type = type\n @value = value\n @parent = parent\n end", "def initialize name=nil, child=nil\r\n super name\r\n @child = child\r\n end", "def _UNDO_setParent(iParentTag)\n @Parent = iParentTag\n end", "def admin_catalog_params\n params.permit(:parent_id, :name, :position)\n end", "def new\n @widget = Widget.new\n end", "def create_name_text\n Text.new(0, @name_window, 0, -Text::Util::FOY, 0, default_line_height, '')\n end", "def attach_symname_button(name, ivar_name, tooltip_text = nil)\n\t\tself.attach_label('Name', tooltip_text)\n\t\tw = Gtk::Button.new #(:label => 'OpAmp.sym')\n\t\tw.tooltip_text = tooltip_text\n\t\tw.hexpand = true\n\t\t@grid.attach(w, 1, @row, 1, 1)\n\t\t@row += 1\n\t\treturn w\n\tend", "def add_composer( asset, name, parent = nil, options = {} )\n if( options[:type])\n child = options[:type].new(:name => name, :asset => asset)\n else\n child = Composer.new(:name => name, :asset => asset)\n end\n \n child.save\n if parent\n #child = parent.children.create(:asset_id => asset.id, :name => name)\n child.move_to_child_of parent \n end\n \n if( child.errors.size == 0 )\n # Add output view settings\n if( options[:asset_schemas] )\n [*options[:asset_schemas]].each do |sys|\n AssetSchema.create( :system => System.find_by_type(sys.to_s), :viewable => node)\n end\n end\n\n opts = options[:properties]\n\n p = Property.create( opts.merge(:element => node) )\tif( opts )\n\n else\n puts \"ERRORS !!!\"\n node.errors.each_full {|msg| puts msg}\n node.errors.each_full {|msg| logger.error msg}\n logger.error \"Node #{node} - failed to save\"\n end\n\n child\n end", "def parent=(other); end", "def add_widget(name)\n @browser.div(:id=>\"add_goodies_body\").li(:text=>/#{Regexp.escape(name)}/).button.click\n end", "def parent= parent_node\n parent_node.add_child(self)\n parent_node\n end", "def initialize form, config={}, &block\n \n @text = config.fetch(:text, \"NOTFOUND\")\n @editable = false\n @focusable = false\n # we have some processing for when a form is attached, registering a hotkey\n register_events :FORM_ATTACHED\n super\n @justify ||= :left\n @name ||= @text\n @repaint_required = true\n end", "def initialize(composite_parent, opts = {}, &blk)\n @container = Swt::Widgets::Composite.new(composite_parent, Swt::SWT::NONE || Swt::SWT::BORDER)\n\n width, height = opts['width'] || DEFAULT_WIDTH, opts['height'] || DEFAULT_HEIGHT\n\n # RowLayout is horizontal by default, wrapping by default\n @layout = Swt::Layout::RowLayout.new\n\n @layout.type = opts['layout_type'] if opts['layout_type']\n\n # set the margins\n set_layout_margins(opts[:margin]) if opts[:margin]\n\n if width && height\n #@border = Swt::Widgets::Composite.new(composite_parent, Swt::SWT::BORDER)\n #debugger\n @container.setSize(width, height)\n end\n\n @container.setLayout(@layout)\n\n instance_eval &blk if block_given?\n\n @container.pack unless width && height\n\n end" ]
[ "0.5725541", "0.566465", "0.55839866", "0.5578601", "0.5578601", "0.5578601", "0.5578601", "0.5578601", "0.5421841", "0.5369704", "0.5368662", "0.53488046", "0.5293775", "0.52565765", "0.5227468", "0.52261025", "0.52227575", "0.51928705", "0.51928705", "0.51874185", "0.51618785", "0.5148356", "0.51353246", "0.5064778", "0.5064778", "0.5045133", "0.5035974", "0.500906", "0.5003555", "0.50000995", "0.50000995", "0.49730027", "0.49660486", "0.49602407", "0.4959435", "0.49513558", "0.49466667", "0.4945844", "0.49428108", "0.49150324", "0.49142915", "0.48934084", "0.48922482", "0.48738867", "0.48687714", "0.48625103", "0.48552817", "0.48462248", "0.48442703", "0.48442703", "0.48442703", "0.48442653", "0.4840126", "0.4831803", "0.4829632", "0.4816823", "0.48033127", "0.4796023", "0.47951832", "0.47940195", "0.47925273", "0.4785407", "0.47841507", "0.4783501", "0.4778089", "0.4777074", "0.47647873", "0.47518566", "0.47514933", "0.4744806", "0.47411627", "0.4737137", "0.47368896", "0.47297487", "0.47297487", "0.47205877", "0.4719322", "0.47170436", "0.4713514", "0.471182", "0.47037438", "0.46942222", "0.46805966", "0.46768376", "0.4667194", "0.46649247", "0.46614385", "0.4658954", "0.4656599", "0.4653737", "0.4645209", "0.464202", "0.4633988", "0.46302295", "0.46269417", "0.46265903", "0.4625783", "0.4621066", "0.4617483", "0.46146375" ]
0.59607655
0
Returns the display coordinate of line 'n'
def line_num_to_coord(n) (n + 1) * font_metrics.height end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def line(n)\n @lines[n]\n end", "def line_number\n number[6..-1]\n end", "def line_for_position(position); end", "def line_for_position(position); end", "def line_for_position(position); end", "def line(number); end", "def coord_to_line_num(y)\n\t\ty / font_metrics.height - 1\n\tend", "def line(number)\n end", "def line_index()\n end", "def lvl_text_coordinates\n return 121, 5, 35, 16\n end", "def line_n\n [\"Times Square\", \"34th\", \"28th\", \"23rd\", \"Union Square\", \"8th\"]\nend", "def first_line_in_view()\n\t\tcoord_to_line_num(contents_y)\n\tend", "def visible_line_number\r\n return 5\r\n end", "def line\n @line = line_cell.split(' ').last.to_f\n if opponent_cell['@']\n @line *= -1\n end\n @line\n end", "def text_coordinate\n return 39, 5, 222, 16\n end", "def draw_line(number)\n @dim.times do |i|\n if i+1 == number || @dim-i == number\n print draw_x\n else\n print draw_dot\n end\n end\n end", "def last_line_in_view()\n\t\tcoord_to_line_num(contents_y + height)\n\tend", "def line(number)\n lines[number - 1]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line_id\n @line_number - 1\n end", "def visible_line_number\n @ev_height\n end", "def line_and_column(pos); end", "def line_index(num)\n\t\tif num == 0\n\t\t\treturn -1\n\t\telsif num <= @line_indices.length\n\t\t\treturn @line_indices[num - 1]\n\t\telsif num == @line_indices.length + 1\n\t\t\treturn @text.length\n\t\telse\n\t\t\treturn -999 # todo\n\t\tend \n\tend", "def line_number\n\t\t\t@line_index + 1\n\t\tend", "def visible_line_number\n return 4\n end", "def visible_line_number\n return 4\n end", "def line_number\n $curwin.cursor.first\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line\n 1\n end", "def pos_on_line(offset)\n end", "def line_offset\n\t\t\t@offset - @line_range.min\n\t\tend", "def getXYIndex(s)\n return s.y * @width + s.x;\n end", "def visible_line_number\r\n item_max\r\n end", "def visible_line_number\n return 1\n end", "def visible_line_number\n return 1\n end", "def visible_line_number\n item_max\n end", "def visible_line_number\n item_max\n end", "def visible_line_number\n item_max\n end", "def visible_line_number\n item_max\n end", "def line_and_column(position = T.unsafe(nil)); end", "def line(num) lines(num, 1) end", "def from_line_index\n from_line - 1\n end", "def _rl_current_display_line()\r\n # Find out whether or not there might be invisible characters in the\r\n # editing buffer.\r\n if (@rl_display_prompt == @rl_prompt)\r\n nleft = @_rl_last_c_pos - @_rl_screenwidth - @rl_visible_prompt_length\r\n else\r\n nleft = @_rl_last_c_pos - @_rl_screenwidth\r\n end\r\n\r\n if (nleft > 0)\r\n ret = 1 + nleft / @_rl_screenwidth\r\n else\r\n ret = 0\r\n end\r\n\r\n ret\r\n end", "def coordinate\n x = ((position-1) / area.x_max) + 1\n y = position - (x-1) * area.x_max\n \"(#{x}, #{y})\"\n end", "def text_coordinates\n return 28, 5, 152, 16\n end", "def line_number\n @value.line_number if @value.respond_to?(:line_number)\n end", "def get_char_position_in_line\n raise NotImplementedError\n end", "def svg_coord(row, col)\n\t\t[col*10 + 5, row*10 + 5]\n\tend", "def lineno()\n #This is a stub, used for indexing\n end", "def index_of_position(row, col = 0)\n\t\tline_index(row) + col + 1\n\tend", "def line_number(pos=pos())\n line_index(pos) + 1\n end", "def line_before\n line[0..column - 1].to_s\n end", "def incliniation\n (@line2[8...16]).to_f\n end", "def line\n location&.line\n end", "def display(line, column = T.unsafe(nil)); end", "def display(line, column = T.unsafe(nil)); end", "def display(line, column = T.unsafe(nil)); end", "def visible_line_number\n return ROWS_MAX\n end", "def detail\n \"#{line}\\n#{' ' * line_offset}^\"\n end", "def lines_offset\n @starting_line - 1\n end", "def objective_x; line_height / 2; end", "def column\n old_pos - start_of_current_line_pos\n end", "def column\n old_pos - start_of_current_line_pos\n end", "def line_number(pos=pos)\n line_index(pos) + 1\n end", "def findPrincessPosition(n, grid)\n return calculate_position_coordinates(n, grid, 'p')\nend", "def lineno\n @__line\n end", "def current_line_pos\n pos - col\n end", "def getCoords (index)\n return index%10, index/10\n end", "def line\n return 1 unless lexing_context && locator\n locator.line_for_offset(lexing_context[:end_offset])\n end", "def line_num; end", "def line_char_to_offset(text, line, character); end", "def column(n = nil)\n CSI + \"#{n || 1}G\"\n end", "def line_for_offset(offset)\n end", "def row(n = nil)\n CSI + \"#{n || 1}d\"\n end", "def getline_fromcoords(array)\n array.collect {|x,y| @tbls[:notformated][x][y].to_i}\n end", "def propn\n xpos 'NNP'\n end", "def position(index)\n return [-1, -1] unless index < string.length\n\n row_start = @line_starts.select { |line_start| line_start <= index }.last\n row = @line_starts.index(row_start)\n column = index - row_start\n [row, column]\n end", "def line\n buffer[line_number]\n end", "def row\n return nil unless @row\n if @row < 0\n return FFI::NCurses.LINES + @row\n end\n @row\n end", "def col\r\n @lines[@line_num].cursor\r\n end", "def location\n\t\treturn \"line %s, column %s\" % [\n\t\t\tself.linenum || '??',\n\t\t\tself.colnum || '??',\n\t\t]\n\tend", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def get_y_by_line(num_lines)\n if page_count == 1\n return (num_lines*0.16)+0.4\n else\n return ((num_lines - (((page_count-2)*66)+59))*0.16)+0.4\n end\n end", "def line\n lines.line(y)\n end", "def line_offset(line_index)\n return unless line_exists?(line_index)\n line_index == 0 ? 0 : @line_lengths[0..(line_index - 1)].sum\n end", "def find_princess_position\n position_coordinates('p')\n end", "def visible_line_number\n Window_Message.line_number\n end", "def elementnumber\n @line1[64...68].to_i\n end" ]
[ "0.70057374", "0.698374", "0.68126297", "0.68126297", "0.68126297", "0.669584", "0.6666673", "0.6630187", "0.65918994", "0.6552892", "0.654642", "0.65192235", "0.6505281", "0.64988106", "0.64967704", "0.6445515", "0.6402056", "0.63383925", "0.6314022", "0.6314022", "0.6314022", "0.6314022", "0.6314022", "0.6306679", "0.63035166", "0.6299125", "0.6296578", "0.6292961", "0.6290698", "0.6290698", "0.62610614", "0.6251068", "0.6251068", "0.6251068", "0.62356436", "0.62281847", "0.61892486", "0.61850834", "0.61814183", "0.6179273", "0.6179273", "0.6167789", "0.6167789", "0.6167789", "0.6167789", "0.6134031", "0.6123211", "0.607364", "0.6041621", "0.60324264", "0.60305655", "0.60202414", "0.6005577", "0.5992709", "0.5974326", "0.59732455", "0.5968914", "0.59548825", "0.59331465", "0.59314066", "0.59205097", "0.59205097", "0.59205097", "0.59204423", "0.59029996", "0.5892869", "0.5889489", "0.5888383", "0.5888383", "0.588314", "0.5881497", "0.587669", "0.58656985", "0.58606064", "0.58460826", "0.5839605", "0.5832521", "0.5824549", "0.5808353", "0.57909185", "0.5790826", "0.5785984", "0.5777768", "0.5774954", "0.5740896", "0.57357764", "0.57320404", "0.5728272", "0.5728272", "0.5728272", "0.5728272", "0.5728272", "0.5728272", "0.5728272", "0.57255393", "0.5724756", "0.57242936", "0.5723996", "0.5722269", "0.57206273" ]
0.8330883
0
Returns the line number of the display ycoordinate 'y'
def coord_to_line_num(y) y / font_metrics.height - 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gety\n (@lines[0...@str_idx].map(&:ymax).reduce(:+) || 0) + @str_y_idx - @start_y\n end", "def gety\n (@lines[0...@str_idx].map(&:ymax).reduce(:+) || 0) + @str_y_idx - @start_y\n end", "def row_at(y)\n return (((y.to_f - window.container.header_height.to_f) - @view.y_offset.to_f) / @text.height).floor\n end", "def row_of( y )\n @top_line + y\n end", "def row_of( y )\n @top_line + y\n end", "def pixel_y_at(y)\n\t\t(block_size * y) + @y_offset\n\tend", "def last_line_in_view()\n\t\tcoord_to_line_num(contents_y + height)\n\tend", "def y\n OFFSET_FROM_TOP + (coordinates.y * 700).to_i\n end", "def line\n lines.line(y)\n end", "def y\n position.y if position\n end", "def y\n position.y if position\n end", "def get_y_by_line(num_lines)\n if page_count == 1\n return (num_lines*0.16)+0.4\n else\n return ((num_lines - (((page_count-2)*66)+59))*0.16)+0.4\n end\n end", "def y\n @position.y\n end", "def line_num_to_coord(n)\n\t\t(n + 1) * font_metrics.height\n\tend", "def screen_y\n return @sy - ((@index+1)*@speed_y)\n end", "def first_line_in_view()\n\t\tcoord_to_line_num(contents_y)\n\tend", "def top_cell_y_at(y); y / HEIGHT; end", "def horizontal_line y\n line = { x: 0, y: y, w: grid.width, h: 0 }\n line.transform_values { |v| v * grid.cell_size }\n end", "def horizontal_line y\n line = { x: 0, y: y, w: grid.width, h: 0 }\n line.transform_values { |v| v * grid.cell_size }\n end", "def y\n @point[1]\n end", "def screen_y\n return y\n end", "def bottom_cell_y_at(y); (y + HEIGHT - 1) / HEIGHT; end", "def visible_line_number\n @ev_height\n end", "def on_get_line_height(x); (@row_height || -1); end", "def screen_y(y)\n $window.height - ((y.to_f / @scene_height) * $window.height).to_i\n end", "def screen_origin_y\n @cr[1]\n end", "def convert_y_to_row(y)\n\t\treturn (((@width-1)/2) - y).round\n\tend", "def rel_y\n return y - Graphics.height/2\n end", "def rel_y\n return y - Graphics.height/2\n end", "def rel_y\n return y - Graphics.height/2\n end", "def line_number\n $curwin.cursor.first\n end", "def y\n attr('y')\n end", "def screen_y\n if $game_temp.enemies_position[self.index] != nil\n return $game_temp.enemies_position[self.index][1]\n else\n return $data_troops[@troop_id].members[@member_index].y + Enemy_Position_AdjustY\n end\n end", "def screen_y\n unless Layy_Meta.active\n return screen_y_mgc_lm_gtbs\n else\n y = @actor.lm_y_h0\n y -= 40\n if @actor.unit_size > 1\n y += (@actor.unit_size - 1 << 4)\n end\n return y\n end\n end", "def screen_y\n y = (@real_y - $game_map.display_y + 3) / 4 \n return y \n end", "def screen_y\n y = ((@real_y - $game_map.display_y + 3) / 4 ) \n return y \n end", "def screen_y\n y = ((@real_y - $game_map.display_y + 3) / 4 ) \n return y \n end", "def getY() @y end", "def screen_y\n return $data_troops[@troop_id].members[@member_index].y + Enemy_Position_AdjustY\n end", "def screen_y\n y = ((@real_y - $game_map.display_y + 3) / 4 )+16\n return y \n end", "def line_number\n @value.line_number if @value.respond_to?(:line_number)\n end", "def y_offset; end", "def column_at(x, y, y_is_line = false)\n x = @text.x if x < x-@text.x\n line = @newline_data.dig(row_at(y)) unless y_is_line\n line = @newline_data.dig(y) if y_is_line\n column= 0\n return unless line\n\n text = line[:text]\n buffer= \"\"\n local_x=0\n\n text.size.times do |i|\n local_x = @text.font.text_width(buffer)\n\n break if local_x >= x\n column+=1\n buffer+=text.chars[i]\n end\n\n return column\n end", "def get_y\n @piece.color == :white ? @y : 7 - @y\n end", "def y\n rect.y\n end", "def y\n return nil unless @grpc.position\n @grpc.position.y\n end", "def y\n wd.location[1]\n end", "def y\n return @background.y\n end", "def delta_y\n @delta_y ||= (@name_segments.size - 1) * LINE_HEIGHT\n end", "def row_to_y( row )\n return nil if row.nil?\n y = row - @top_line\n y = nil if ( y < 0 ) or ( y > @top_line + @diakonos.main_window_height - 1 )\n y\n end", "def y\n @components[:y]\n end", "def y\n @location.y\n end", "def screen_y\n @page ? super + @page.adjusted_xy[1] : super\n end", "def distance_y_from(y)\n result = @y - y\n if $game_map.loop_vertical? && result.abs > $game_map.height / 2\n if result < 0\n result += $game_map.height\n else\n result -= $game_map.height\n end\n end\n result\n end", "def row_to_y( row )\n return nil if row.nil?\n y = row - @top_line\n y = nil if ( y < 0 ) or ( y > @top_line + $diakonos.main_window_height - 1 )\n y\n end", "def get_y; \t\t@y \t\t\tend", "def adjust_y(y)\n if loop_vertical? and y < @display_y - @margin_y\n return y - @display_y + @map.height * 256\n else\n return y - @display_y\n end\n end", "def shifted_horizontal_line y\n line = { x: grid.width + 1, y: y, w: grid.width, h: 0 }\n line.transform_values { |v| v * grid.cell_size }\n end", "def line_number\n number[6..-1]\n end", "def y_coord(num)\n (num/65536).to_i\nend", "def line_number\n\t\t\t@line_index + 1\n\t\tend", "def line_id\n @line_number - 1\n end", "def line\n @line = line_cell.split(' ').last.to_f\n if opponent_cell['@']\n @line *= -1\n end\n @line\n end", "def lineno\n @__line\n end", "def point_y(index)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.GraphComponentState_point_y(@handle.ptr, index)\n result\n end", "def line\n return 1 unless lexing_context && locator\n locator.line_for_offset(lexing_context[:end_offset])\n end", "def get_y coords\n coords.last\n end", "def y\n @data[:y]\n end", "def y=(y)\n @screen_y = y\n end", "def ui_max_y\n\t\t\t\tCurses.rows\n\t\t\tend", "def delta_y(y_position, y)\n (y - y_position).abs\n end", "def draw_line(y)\n width = @options[:page_layout] == :portrait ? 530 : 770\n @pdf.stroke { @pdf.horizontal_line 0, width, :at => y }\n end", "def height\n return nil unless @height\n if @height < 0\n return ((FFI::NCurses.LINES + @height) - self.row) + 1\n #return (FFI::NCurses.LINES + @height) \n end\n @height\n end", "def height(y = @y)\n height = [y]\n return height unless @page\n @page.size[2].times { |i| height << y - (i + 1) }\n @page.size[3].times { |i| height << y + (i + 1) }\n return height\n end", "def view_y\n return 0 if @viewport.nil? || @view_y.nil?\n return @view_y\n end", "def visible_line_number\r\n return 5\r\n end", "def line\n 1\n end", "def default_line_number\n return current_layout.line_count\n end", "def line_num; end", "def height\n @y1 - @y0\n end", "def y\n object[\"y\"]\n end", "def line_height\n return @common.lineHeight\n end", "def item_y\n contents_height / 2 - line_height * 3 / 2\n end", "def screen_y\n return 464\n end", "def visible_line_number\n return 4\n end", "def visible_line_number\n return 4\n end", "def y_position(as: :units)\n if as == :mm\n ((row.layout.height-1) - row.number) * unit_height\n else\n row.number\n end\n end", "def y_start_for_text(y, text)\n y + padding + (text.blank? ? 0 : char_height) + 2\n end", "def visible_line_number\n return 1\n end", "def visible_line_number\n return 1\n end", "def ay2vy(ay)\n\t\tcheck_integer(ay)\n\t\traise ArgumentError unless ay.between?(0, lines.size-1)\n\t\tvis = visible\n\t\tvis.each_with_index do |y, i|\n\t\t\tfl = @lines[y].folded_lines\n\t\t\treturn i if ay.between?(y, y+fl)\n\t\tend\n\t\traise 'should not happen'\n\tend", "def scene_y(y)\n $window.height - ((y.to_f / $window.height) * @scene_height)\n end", "def line_index()\n end", "def y_label_offset( height )\n 0\n end", "def vertical_line x\n line = { x: x, y: 0, w: 0, h: grid.height }\n line.transform_values { |v| v * grid.cell_size }\n end", "def vertical_line x\n line = { x: x, y: 0, w: 0, h: grid.height }\n line.transform_values { |v| v * grid.cell_size }\n end", "def line_number\n env(:line_number).to_i - 1\n end", "def draw_line; draw_horizontal_line(@draw_y + (line_height / 2) - 1, 2); end", "def maatsf_total_line_width(y = 0)\n contents_width - new_line_x\n end", "def maatsf_total_line_width(y = 0)\n contents_width\n end" ]
[ "0.7560261", "0.7560261", "0.7400839", "0.73583233", "0.73583233", "0.6976197", "0.6957617", "0.6895108", "0.68886316", "0.6864265", "0.6864265", "0.68411833", "0.68350965", "0.67754537", "0.6716687", "0.6647342", "0.66415983", "0.6626125", "0.6626125", "0.65804946", "0.65545034", "0.6534383", "0.6526571", "0.6486752", "0.6456613", "0.6447239", "0.644644", "0.6421556", "0.6421556", "0.6421556", "0.64160526", "0.6413282", "0.6411306", "0.64100605", "0.640919", "0.64057165", "0.64057165", "0.6385977", "0.6383964", "0.6376938", "0.6376726", "0.63548625", "0.6286877", "0.62755364", "0.6275403", "0.62753826", "0.6271009", "0.62661463", "0.6257409", "0.6247584", "0.6231866", "0.6230015", "0.62259394", "0.6220865", "0.6219726", "0.62149644", "0.619612", "0.61854017", "0.6183453", "0.6177525", "0.61692303", "0.61439633", "0.6137538", "0.6128414", "0.6116911", "0.6085939", "0.6085276", "0.607703", "0.60691905", "0.6064786", "0.60505974", "0.6049726", "0.60237914", "0.60089195", "0.6000791", "0.59946257", "0.5993919", "0.5980514", "0.5954137", "0.5951633", "0.5950525", "0.5941584", "0.5939997", "0.5937293", "0.59303546", "0.59303546", "0.59287536", "0.5924944", "0.59210694", "0.59210694", "0.5913099", "0.5900608", "0.5888364", "0.5884042", "0.5858887", "0.5858887", "0.5857926", "0.58547777", "0.5854666", "0.5850487" ]
0.83822256
0
Returns the line number of the first visible line
def first_line_in_view() coord_to_line_num(contents_y) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def visible_line_number\n return 1\n end", "def visible_line_number\n return 1\n end", "def visible_line_number\r\n return 5\r\n end", "def visible_line_number\n return 4\n end", "def visible_line_number\n return 4\n end", "def visible_line_number\n Window_Message.line_number\n end", "def line_number\n $curwin.cursor.first\n end", "def visible_line_number\n return ROWS_MAX\n end", "def visible_line_number\n item_max\n end", "def visible_line_number\n item_max\n end", "def visible_line_number\n item_max\n end", "def visible_line_number\n item_max\n end", "def line_number\n\t\t\t@line_index + 1\n\t\tend", "def visible_line_number\r\n item_max\r\n end", "def visible_line_number\n @ev_height\n end", "def linenumber\n return @cmd.nil? ? 0 : @cmd.linenumber\n end", "def line_number(pos=pos())\n line_index(pos) + 1\n end", "def line\n 1\n end", "def lineno\n @__line\n end", "def line_number\n env(:line_number).to_i - 1\n end", "def line_number(pos=pos)\n line_index(pos) + 1\n end", "def visible_line_number\n [SES::ExternalText::Languages.size, 8].min\n end", "def line\n return 1 unless lexing_context && locator\n locator.line_for_offset(lexing_context[:end_offset])\n end", "def _rl_current_display_line()\r\n # Find out whether or not there might be invisible characters in the\r\n # editing buffer.\r\n if (@rl_display_prompt == @rl_prompt)\r\n nleft = @_rl_last_c_pos - @_rl_screenwidth - @rl_visible_prompt_length\r\n else\r\n nleft = @_rl_last_c_pos - @_rl_screenwidth\r\n end\r\n\r\n if (nleft > 0)\r\n ret = 1 + nleft / @_rl_screenwidth\r\n else\r\n ret = 0\r\n end\r\n\r\n ret\r\n end", "def current_line_number; end", "def from_line_index\n from_line - 1\n end", "def line_id\n @line_number - 1\n end", "def line_index()\n end", "def line_number\n @value.line_number if @value.respond_to?(:line_number)\n end", "def determine_line_number(scanner)\n scanner.string[0, scanner.pos].count(\"\\n\")\n end", "def start_line_number; end", "def start_line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def default_line_number\n return current_layout.line_count\n end", "def start_line_for(code_object)\n if code_object.command? || opts.present?(:'base-one')\n 1\n else\n code_object.source_line.nil? ? 1 :\n (code_object.source_line - code_object.doc.lines.count)\n end\n end", "def get_lineno\n RubyVM::Frame.get(1).source_location[0]\n end", "def lines_offset\n @starting_line - 1\n end", "def line_number\n number[6..-1]\n end", "def last_line_in_view()\n\t\tcoord_to_line_num(contents_y + height)\n\tend", "def line_num; end", "def line_number\n return unless backtrace and backtrace[0]\n\n backtrace[0].split(\":\")[1].to_i\n end", "def start_line_number=(_); end", "def line_offset\n\t\t\t@offset - @line_range.min\n\t\tend", "def line\n @session.request(:vim_get_current_line)\n end", "def lineno()\n #This is a stub, used for indexing\n end", "def line\n lines.first\n end", "def lineNum()\n caller_infos = caller.first.split(\":\")\n # Note caller_infos[0] is file name\n # caller_infos[1]\n return \"Line no. #{caller_infos[1]}\"\nend", "def line_pos(row)\n (row > 0 ? src.split(\"\\n\")[0..(row - 1)].inject(0) { |pos, line| pos + line.length + 1 } : 0)\n end", "def row\n return nil unless @row\n if @row < 0\n return FFI::NCurses.LINES + @row\n end\n @row\n end", "def first_line\n line_from_ip(0)\n end", "def first_line_of_module_definition(file, line)\n searchable_lines = lines_for_file(file)[0..(line - 2)]\n searchable_lines.rindex { |v| module_definition_first_line?(v) } + 1\n end", "def compute_line_index\n scanner = StringScanner.new(@string)\n result = [0] # first line starts at 0\n while scanner.scan_until(/\\n/)\n result << scanner.pos\n end\n @line_index = result\n end", "def current_line_pos\n pos - col\n end", "def current_line\n @lines[@current_index]\n end", "def line_index(num)\n\t\tif num == 0\n\t\t\treturn -1\n\t\telsif num <= @line_indices.length\n\t\t\treturn @line_indices[num - 1]\n\t\telsif num == @line_indices.length + 1\n\t\t\treturn @text.length\n\t\telse\n\t\t\treturn -999 # todo\n\t\tend \n\tend", "def line_number=(_arg0); end", "def line_number=(_arg0); end", "def line_number=(_arg0); end", "def num_lines_in_view()\n\t\tlast_line_in_view() - first_line_in_view() + 1\n\tend", "def lineno\n @source.lineno\n end", "def line_number\n @line_number_overwrite || default_line_number\n end", "def defined_line\n # Detect a -1 ip, which indicates a definition entry.\n return @lines[1] if @lines[0] == -1\n first_line\n end", "def line_number\n lines_read.length\n end", "def lineNum()\n caller_infos = caller.first.split(\":\")\n # Note caller_infos[0] is file name\n caller_infos[1]\nend", "def line\n buffer[line_number]\n end", "def source_line\n @source_location[1]\n end", "def line_for_offset(offset)\n @locator.line_for_offset(offset) + @leading_line_count\n end", "def line\n location&.line\n end", "def lineno\n @lineno || uninitialized!\n end", "def line_number\n raise \"This loader doesn't support line_number\"\n end", "def line(number)\n lines[number - 1]\n end", "def line_before\n line[0..column - 1].to_s\n end", "def lineno\n @_st_lineno\n end", "def line\n\t\t\tself.src.line\n\t\tend", "def line_for_position(position); end", "def line_for_position(position); end", "def line_for_position(position); end", "def current_line_number\n # Not using string[@previous_pos..best_pos].count('\\n') because it is slower\n strscan = ::StringScanner.new(string)\n strscan.pos = @previous_pos\n old_pos = pos + 1\n @previous_line_number += 1 while strscan.skip_until(/\\n/) && strscan.pos <= old_pos\n\n @previous_pos = (eos? ? pos : pos + 1)\n @previous_line_number\n end", "def line\n return 0 unless @method\n\n ip = @ip\n ip -= 1 unless ip_on_current?\n\n return @method.first_line unless ip > 0\n\n @method.line_from_ip(ip)\n end", "def number_of_lines_in_first_chunk\n end_method_line = last_method_source_location.last\n\n end_method_line - line\n end", "def num_lines() @line_indices.length + 1 end", "def jump_to_line l\n l = l.clamp 0, num_lines - 1\n return if @topline == l\n @topline = l\n @botline = [l + buffer.content_height, num_lines].min\n buffer.mark_dirty!\n end", "def line(pos=pos())\n lines[line_index(pos)]\n end", "def lineno\n end", "def lineno\n end", "def line_one\n return @line_one\n end", "def line(num) lines(num, 1) end", "def line_for_offset(offset)\n if line_nbr = line_index.index {|x| x > offset}\n return line_nbr\n end\n # If not found it is after last\n return line_index.size\n end", "def __caller_line_number__(caller_depth=0)\n return if RUBY_ENGINE == 'opal'\n caller[caller_depth] && caller[caller_depth][PutsDebuggerer::STACK_TRACE_CALL_LINE_NUMBER_REGEX, 1].to_i\n end", "def first_visible_component_index\n @widgets.each_with_index do |w, ix|\n return ix if visible?(w) and focusable?(w)\n end\n return -1\n end", "def get_line\n @lines.shift\n end", "def get_line_number(index)\n if @list_of_events.length.zero?\n puts 'list is empty'\n else\n temp_event = @list_of_events[index]\n temp_event.line_number\n end\n end", "def get_line_pos(pos)\n lpos = @line_ends.bsearch_index { |x, _| x >= pos }\n return lpos\n end", "def input_line\n lines - 1\n end" ]
[ "0.84921986", "0.84921986", "0.819771", "0.8082292", "0.8082292", "0.78687614", "0.7747879", "0.7476649", "0.7349445", "0.7349445", "0.7349445", "0.7349445", "0.73332626", "0.7236543", "0.72307825", "0.71180785", "0.7107594", "0.70821154", "0.7026024", "0.7020337", "0.7017442", "0.7015919", "0.70154554", "0.70078796", "0.69735414", "0.69670075", "0.69571406", "0.69367886", "0.6929707", "0.6911359", "0.6881927", "0.6881927", "0.6881545", "0.6881545", "0.6881545", "0.6881545", "0.6881545", "0.6881545", "0.6881545", "0.6844422", "0.6835929", "0.6818646", "0.6811624", "0.6811004", "0.6767797", "0.676491", "0.6747075", "0.6745235", "0.67309546", "0.67067575", "0.6700183", "0.66976184", "0.66959083", "0.66897947", "0.66533226", "0.66390485", "0.66383356", "0.6612626", "0.6610676", "0.65788716", "0.65771425", "0.6573059", "0.6573059", "0.6573059", "0.656553", "0.6560368", "0.65573704", "0.65503925", "0.65320885", "0.6519145", "0.65057224", "0.6478923", "0.64658487", "0.6437944", "0.64348304", "0.643442", "0.64327383", "0.6377537", "0.6374312", "0.6370743", "0.6367083", "0.6367083", "0.6367083", "0.636234", "0.6350348", "0.63182706", "0.63145036", "0.63049096", "0.6293389", "0.6270279", "0.6270279", "0.6260159", "0.6255179", "0.62534827", "0.62528825", "0.6246927", "0.6214986", "0.62130344", "0.6202849", "0.6199303" ]
0.80477166
5
Returns the line number of the last visible line
def last_line_in_view() coord_to_line_num(contents_y + height) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def visible_line_number\n return ROWS_MAX\n end", "def visible_line_number\n return 1\n end", "def visible_line_number\n return 1\n end", "def visible_line_number\r\n return 5\r\n end", "def visible_line_number\n return 4\n end", "def visible_line_number\n return 4\n end", "def visible_line_number\n item_max\n end", "def visible_line_number\n item_max\n end", "def visible_line_number\n item_max\n end", "def visible_line_number\n item_max\n end", "def visible_line_number\r\n item_max\r\n end", "def visible_line_number\n Window_Message.line_number\n end", "def line_number\n $curwin.cursor.first\n end", "def visible_line_number\n @ev_height\n end", "def last_line; end", "def last_line; end", "def last_line; end", "def last_line; end", "def last_line; end", "def last_line; end", "def last_line; end", "def line_number\n env(:line_number).to_i - 1\n end", "def line_number\n\t\t\t@line_index + 1\n\t\tend", "def line_id\n @line_number - 1\n end", "def current_line_number; end", "def nontrivial_end_line\n if successor\n successor.line_numbers.begin - 1\n else\n @document.last_non_empty_line\n end\n end", "def line_number\n number[6..-1]\n end", "def linenumber\n return @cmd.nil? ? 0 : @cmd.linenumber\n end", "def last_instant_text\n return @lines[-1]\n end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def lineno\n @__line\n end", "def line(number)\n lines[number - 1]\n end", "def visible_line_number\n [SES::ExternalText::Languages.size, 8].min\n end", "def line_num; end", "def _rl_current_display_line()\r\n # Find out whether or not there might be invisible characters in the\r\n # editing buffer.\r\n if (@rl_display_prompt == @rl_prompt)\r\n nleft = @_rl_last_c_pos - @_rl_screenwidth - @rl_visible_prompt_length\r\n else\r\n nleft = @_rl_last_c_pos - @_rl_screenwidth\r\n end\r\n\r\n if (nleft > 0)\r\n ret = 1 + nleft / @_rl_screenwidth\r\n else\r\n ret = 0\r\n end\r\n\r\n ret\r\n end", "def from_line_index\n from_line - 1\n end", "def last_line(src)\n if n = src.rindex(\"\\n\")\n src[(n+1) .. -1]\n else\n src\n end\nend", "def last_chat_line\n line = @chat_win.read_text.split(\"\\n\")[-1]\n return @chat_win.strip_timestamp(line)\n end", "def line_number\n @line_number_overwrite || default_line_number\n end", "def num_lines_in_view()\n\t\tlast_line_in_view() - first_line_in_view() + 1\n\tend", "def lines_offset\n @starting_line - 1\n end", "def default_line_number\n return current_layout.line_count\n end", "def line_number\n lines_read.length\n end", "def get_lineno\n RubyVM::Frame.get(1).source_location[0]\n end", "def line_number\n @value.line_number if @value.respond_to?(:line_number)\n end", "def line_index(num)\n\t\tif num == 0\n\t\t\treturn -1\n\t\telsif num <= @line_indices.length\n\t\t\treturn @line_indices[num - 1]\n\t\telsif num == @line_indices.length + 1\n\t\t\treturn @text.length\n\t\telse\n\t\t\treturn -999 # todo\n\t\tend \n\tend", "def line_number(pos=pos())\n line_index(pos) + 1\n end", "def last_line_only(range); end", "def last_line_only(range); end", "def last_line_only(range); end", "def line\n return 1 unless lexing_context && locator\n locator.line_for_offset(lexing_context[:end_offset])\n end", "def current_line_pos\n pos - col\n end", "def line_number\n return unless backtrace and backtrace[0]\n\n backtrace[0].split(\":\")[1].to_i\n end", "def line\n @session.request(:vim_get_current_line)\n end", "def line\n 1\n end", "def input_line\n lines - 1\n end", "def first_line_in_view()\n\t\tcoord_to_line_num(contents_y)\n\tend", "def line_number(pos=pos)\n line_index(pos) + 1\n end", "def line_index()\n end", "def jump_to_line l\n l = l.clamp 0, num_lines - 1\n return if @topline == l\n @topline = l\n @botline = [l + buffer.content_height, num_lines].min\n buffer.mark_dirty!\n end", "def lineno()\n #This is a stub, used for indexing\n end", "def start_line_number; end", "def start_line_number; end", "def line\n location&.line\n end", "def lineNum()\n caller_infos = caller.first.split(\":\")\n # Note caller_infos[0] is file name\n # caller_infos[1]\n return \"Line no. #{caller_infos[1]}\"\nend", "def line_max\n return @line_max if @line_max\n return @line_max = contents_height / line_height\n end", "def last_row\n row( maxrow )\n end", "def get_last_line(file_handle)\n line = nil\n unless @last_line.nil?\n Snoopit.logger.debug \"File point at byte: #{file_handle.tell}\"\n file_handle.seek (-@last_line.bytesize), IO::SEEK_END\n Snoopit.logger.debug \"Seeked to byte: #{file_handle.tell}\"\n line = file_handle.readline\n end\n line\n end", "def line_for_offset(offset)\n if line_nbr = line_index.index {|x| x > offset}\n return line_nbr\n end\n # If not found it is after last\n return line_index.size\n end", "def current_line\n @lines[@current_index]\n end", "def lineno; end", "def lineno; end", "def lineno; end", "def line\n @line = line_cell.split(' ').last.to_f\n if opponent_cell['@']\n @line *= -1\n end\n @line\n end", "def determine_line_number(scanner)\n scanner.string[0, scanner.pos].count(\"\\n\")\n end", "def line_number=(_arg0); end", "def line_number=(_arg0); end", "def line_number=(_arg0); end", "def last_line_only(range)\n if range.line != range.last_line\n range.adjust(begin_pos: range.source =~ /[^\\n]*\\z/)\n else\n range\n end\n end", "def row\n return nil unless @row\n if @row < 0\n return FFI::NCurses.LINES + @row\n end\n @row\n end", "def TreeView_GetLastVisible(hwnd)\r\n TreeView_GetNextItem(hwnd, NULL, TreeViewGetNextItem[:LASTVISIBLE])\r\n end", "def lineno() end", "def lineno() end", "def lineno() end", "def lineNum()\n caller_infos = caller.first.split(\":\")\n # Note caller_infos[0] is file name\n caller_infos[1]\nend", "def lineno\n @lineno || uninitialized!\n end", "def lineno\n end", "def lineno\n end", "def lineno\n @source.lineno\n end", "def line_offset\n\t\t\t@offset - @line_range.min\n\t\tend", "def previous_code_line(line_number); end", "def lineno\n @_st_lineno\n end", "def line_number\n raise \"This loader doesn't support line_number\"\n end", "def line_after\n line[column..-1].to_s\n end" ]
[ "0.8016296", "0.78399557", "0.78399557", "0.78125125", "0.7704984", "0.7704984", "0.7699743", "0.7699743", "0.7699743", "0.7699743", "0.76581144", "0.75609624", "0.74392617", "0.73366356", "0.7335133", "0.7335133", "0.7335133", "0.7335133", "0.7335133", "0.7335133", "0.7335133", "0.731034", "0.7115007", "0.7113364", "0.7104787", "0.70270586", "0.6981171", "0.69801635", "0.69022816", "0.6895973", "0.6895973", "0.6895973", "0.6895973", "0.6895973", "0.6895973", "0.6895973", "0.6856189", "0.68442124", "0.68241864", "0.6814252", "0.6787299", "0.6732906", "0.67093474", "0.67045707", "0.6660321", "0.66552305", "0.66545594", "0.6626579", "0.6623029", "0.66073346", "0.6577306", "0.657597", "0.65753543", "0.656177", "0.656177", "0.656177", "0.65360445", "0.64783233", "0.6465791", "0.64581215", "0.64469177", "0.6419916", "0.64137083", "0.640818", "0.6401022", "0.63877887", "0.6377225", "0.6352105", "0.6352105", "0.6300319", "0.62945026", "0.62897545", "0.6268966", "0.6263293", "0.62621427", "0.6256708", "0.6248512", "0.6248512", "0.6248512", "0.6242654", "0.62179595", "0.6215877", "0.6215877", "0.6215877", "0.6202195", "0.61992407", "0.6196927", "0.6175727", "0.6175727", "0.6175727", "0.61639", "0.6163556", "0.61527485", "0.61527485", "0.6151797", "0.6142357", "0.6139417", "0.612901", "0.6114166", "0.61081034" ]
0.8150478
0
Returns the number of lines that are visible
def num_lines_in_view() last_line_in_view() - first_line_in_view() + 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def num_lines() @line_indices.length + 1 end", "def visible_line_number\n @ev_height\n end", "def line_count\n\t\tlines.size\n\tend", "def line_count\n\t\tlines.size\n\tend", "def visible_line_number\r\n return 5\r\n end", "def visible_line_number\n return 1\n end", "def visible_line_number\n return 1\n end", "def visible_line_number\n return 4\n end", "def visible_line_number\n return 4\n end", "def visible_line_number\n item_max\n end", "def visible_line_number\n item_max\n end", "def visible_line_number\n item_max\n end", "def visible_line_number\n item_max\n end", "def visible_line_number\n return ROWS_MAX\n end", "def visible\n\t\tres = []\n\t\ti = 0\n\t\twhile i < @lines.size\n\t\t\tres << i\n\t\t\ti += @lines[i].folded_lines + 1\n\t\tend\n\t\tres\n\tend", "def visible_line_number\r\n item_max\r\n end", "def num_lines\n load_data unless @num_lines\n @num_lines\n end", "def visible_tabs\n count = 0\n @tab_names.each { |x| count += 1 if x.visible? }\n count\n end", "def count_lines\n linecount = 0\n\n @output_buffer.each do |line|\n linecount += line.scan(/\\n/).count\n end\n\n linecount - 1\n end", "def line_items_count\n self.line_items.size\n end", "def line_items_count\n self.line_items.count\n end", "def getNumLines()\n contents.split(\"\\n\").length - 1\n end", "def count_visible(x, y)\n sum = 0\n h.times do |oy|\n w.times do |ox|\n sum += 1 if visible?(x, y, ox, oy)\n end\n end\n sum\n end", "def TreeView_GetVisibleCount(hwnd) send_treeview_message(hwnd, :GETVISIBLECOUNT) end", "def visible_line_number\n Window_Message.line_number\n end", "def lines_count\n @lines_count ||= lines.count\nend", "def line_number\n lines_read.length\n end", "def visible_line_number\n [SES::ExternalText::Languages.size, 8].min\n end", "def line_items_count\n self.line_items.size\n end", "def line_count\n\t\t\treturn @contents.nil? ? 0 : @contents.count\n\t\tend", "def lines_of_code\n coverage_statistics[:line]&.total\n end", "def visible\n lines.map { |line| line[ox...(ox + bordered_width)] || '' }\n end", "def total_lines\n covered_lines + missed_lines\n end", "def lines_of_code\n covered_lines.size + missed_lines.size\n end", "def window_line_size\n lines - 2\n end", "def lines\n\t\t\t@buffer.data.count(Ruvim::API::CR)\n\t\tend", "def question_lines_count(question_lines)\n question_lines.reduce(0) do |acc, line|\n acc + @prompt.count_screen_lines(line)\n end\n end", "def visible_copies\n copies.count(&:visible?)\n end", "def data_line_count\n 1\n end", "def height\n lines.size\n end", "def height\n lines.size\n end", "def line_count\n entries.inject(0) do |count, entry|\n count + (entry.dir? ? 0 : entry.lines.size)\n end\n end", "def covered_lines\n covered_lines = 0\n @files.select { |f|\n @file_whitelist.include? f.filename\n }.each do |file|\n original_result[file.filename].each do |line_result|\n covered_lines += 1 if line_result and line_result > 0\n end\n end\n covered_lines\n end", "def vertical_grid_lines_len()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.GraphComponentState_vertical_grid_lines_len(@handle.ptr)\n result\n end", "def total_lines(arr)\n return arr.length\nend", "def li_number\n self.lineitems.size\n end", "def lines\n @message.size\n end", "def column_count\n visible_column_names().count\n end", "def _rl_current_display_line()\r\n # Find out whether or not there might be invisible characters in the\r\n # editing buffer.\r\n if (@rl_display_prompt == @rl_prompt)\r\n nleft = @_rl_last_c_pos - @_rl_screenwidth - @rl_visible_prompt_length\r\n else\r\n nleft = @_rl_last_c_pos - @_rl_screenwidth\r\n end\r\n\r\n if (nleft > 0)\r\n ret = 1 + nleft / @_rl_screenwidth\r\n else\r\n ret = 0\r\n end\r\n\r\n ret\r\n end", "def length\n @lines ? @lines.length : 0\n end", "def length\n @lines ? @lines.length : 0\n end", "def find_number_lines(opened_file)\n start_time = Time.now.to_i\n total_file_lines = opened_file.each_line.inject(0) { |total, _amount| total + 1 }\n opened_file.rewind\n if Rails.env.development?\n end_time = Time.now.to_i\n puts(\"1. Lines ==> #{total_file_lines} in #{((end_time - start_time) / 60).round(2)}\")\n end\n total_file_lines\n end", "def covered_lines\n coverage_statistics[:line]&.covered\n end", "def contar_lineas\n line = read_alumnos\n contador = line.count\n contador\nend", "def size_in_lines(filepath)\n f = File.new(filepath)\n f.readlines[-1]\n count = f.lineno.to_s\n puts \"The link check report contains #{count} lines.\".blue\n puts \"To see the report, open the #{filepath} file.\".blue\n end", "def covered_lines; end", "def count_lines_in_class(klass)\n lines = klass.methods.map {|method| method.lines}.inject(:+)\n lines.nil? ? 0 : lines\n end", "def visible_works_count\n self.works.select{|w| w.visible?(User.current_user)}.uniq.size\n end", "def lines?\n @lines\n end", "def horizontal_grid_lines_len()\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.GraphComponentState_horizontal_grid_lines_len(@handle.ptr)\n result\n end", "def width\n theWidth = 0\n @theLines.each { |l| theWidth = l.length if l.length > theWidth }\n theWidth\n end", "def description_lines\n string = @challenge.description\n lines = 0\n string.each_line('|') { |i|\n lines += 1\n }\n return lines+1\n end", "def line_count\n `wc -l public/HelloWorld.txt`.to_i\n end", "def visible_height\n @win.maxy - 2\n end", "def completed_lines\n lines\n end", "def total_data_lines\n @total_data_lines ||= processed_rows.keys.size\n end", "def max_lines\n (contents.width / line_height) - 1\n end", "def lines_counter\n f = File.open('peliculas.txt', 'r')\n print f.readlines.length\n f.close\nend", "def height\n @screenplay.line_height * @lines.size\n end", "def lines\n 2 * @size + 3\n end", "def outline_count\n outlines.count\n end", "def determine_line_number(scanner)\n scanner.string[0, scanner.pos].count(\"\\n\")\n end", "def first_line_in_view()\n\t\tcoord_to_line_num(contents_y)\n\tend", "def internalRepItemCount\n return @delegate.rowCount\n end", "def n_lines(filename); end", "def visible\n return @viewport.visible\n end", "def num_hidden\n @hidden_cards.size\n end", "def number_of_lines_in_first_chunk\n end_method_line = last_method_source_location.last\n\n end_method_line - line\n end", "def last_line_in_view()\n\t\tcoord_to_line_num(contents_y + height)\n\tend", "def visible_scrapers(heights)\n max = 0\n r = 0\n heights.each do |item|\n if item > max\n r += 1\n max = item\n end\n end\n r\nend", "def visible_scrapers(heights)\n max = 0\n r = 0\n heights.each do |item|\n if item > max\n r += 1\n max = item\n end\n end\n r\nend", "def src_lines(pr)\n count_lines(src_files(pr))\n end", "def never_lines\n return 0.0 if empty?\n\n map { |f| f.never_lines.count }.inject(:+)\n end", "def line_num; end", "def total_lines\n hunks.sum(:old_count) + hunks.sum(:new_count)\n end", "def missed_lines\n return 0.0 if empty?\n\n map { |f| f.missed_lines.count }.inject(:+)\n end", "def count_lines(all_lines_from_file)\n all_lines_from_file.lines.count\nend", "def height\n return nil unless @height\n if @height < 0\n return ((FFI::NCurses.LINES + @height) - self.row) + 1\n #return (FFI::NCurses.LINES + @height) \n end\n @height\n end", "def calculate_num_of_lines body\n lines = body.split(\"\\n\")\n lines.each_with_index do |line, index|\n if line.length * 20 > 500\n lines[index] = line.wrap_lines\n end\n end\n reformated_body = lines.join \"\\n\"\n num_lines = reformated_body.split(\"\\n\").size\n return num_lines, reformated_body\n end", "def length\n (lines.map do |line|\n Strings::Align.display_width(line)\n end << 0).max\n end", "def line\n @string[0..@index].split(\"\\n\").count\n end", "def lines\n repository.files.map do |file|\n repository.read(file).to_s.lines.count\n end.sum\n end", "def lines\n @stats ||= stats\n end", "def appearances\n positions.size\n end", "def never_lines\n return 0.0 if empty?\n\n map { |f| f.never_lines.count }.inject(:+)\n end", "def file_line_count(file_name)\n line_count = `wc -l < #{file_name}`.to_i\n LoggerHelper.print_to_log(\"Count of lines in '#{file_name}' is #{line_count}\")\n line_count\n end", "def count_outputs(lines)\n count = 0\n counting = false\n lines.each do |line|\n counting ||= line.include?(\": Outputs:\")\n count += 1 if counting && line.include?(' = ')\n end\n count\n end", "def length\n return nil if self.nil?\n return @theLines.length\n end", "def exhasusted?\n @index >= @lines.count\n end", "def draws()\n\t\tself.as_regular_contestants.select{|c| c.draw()}.size()\n\tend" ]
[ "0.7354008", "0.7268611", "0.7230812", "0.7230812", "0.7180098", "0.7135837", "0.7135837", "0.6989307", "0.6989307", "0.6962526", "0.6962526", "0.6962526", "0.6962526", "0.694949", "0.69361705", "0.69325227", "0.68812764", "0.67878985", "0.67862135", "0.6758374", "0.6754014", "0.67386484", "0.6734715", "0.671245", "0.6661653", "0.6622524", "0.66157496", "0.66129726", "0.66062474", "0.654376", "0.65185905", "0.6471284", "0.64319706", "0.6411549", "0.6404346", "0.637977", "0.63237214", "0.63208956", "0.63161784", "0.6292849", "0.6292849", "0.6202029", "0.6188099", "0.6185834", "0.6168868", "0.6149135", "0.611011", "0.61058426", "0.61052275", "0.6098932", "0.6098932", "0.60587925", "0.6058469", "0.6054829", "0.60541403", "0.6043165", "0.6037515", "0.60364926", "0.60294217", "0.6020668", "0.6002292", "0.60005057", "0.59700674", "0.5950637", "0.59457093", "0.5908417", "0.5888796", "0.5880558", "0.58477616", "0.584095", "0.58216035", "0.57901204", "0.5772941", "0.57688814", "0.5761561", "0.5755332", "0.5754043", "0.57339", "0.57300484", "0.5726266", "0.5726266", "0.5715007", "0.5699041", "0.5696098", "0.5687026", "0.56865644", "0.56853056", "0.568413", "0.5674253", "0.5660061", "0.5658705", "0.56440043", "0.5628096", "0.5619168", "0.55997777", "0.5597135", "0.55884165", "0.558769", "0.55795705", "0.5561684" ]
0.7968226
0
Gets the index of the n'th newline character.
def line_index(num) if num == 0 return -1 elsif num <= @line_indices.length return @line_indices[num - 1] elsif num == @line_indices.length + 1 return @text.length else return -999 # todo end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def line_at(char)\n return nil unless char\n text[0..char].count(\"\\n\") + 1\n end", "def line_index(pos=pos())\n p = n = 0\n string.each_line do |line|\n p += line.length\n return n if p >= pos\n n += 1\n end\n 0\n end", "def line_at(io, char)\n read(io)[0..char].count(\"\\n\") + 1\n end", "def line_index(pos=pos)\n p = n = 0\n string.each_line do |line|\n p += line.length\n return n if p >= pos\n n += 1\n end\n 0\n end", "def line(n)\n @lines[n]\n end", "def line\n @string[0..@index].split(\"\\n\").count\n end", "def line_from_char(index = -1)\n send_message(:LINEFROMCHAR, index.to_i)\n end", "def compute_line_index\n scanner = StringScanner.new(@string)\n result = [0] # first line starts at 0\n while scanner.scan_until(/\\n/)\n result << scanner.pos\n end\n @line_index = result\n end", "def each_reverse_newline_index(chunk)\n while(nl_index = chunk.rindex(\"\\n\", (nl_index||chunk.size)-1))\n yield(nl_index)\n end\n nl_index\nend", "def line_number\n number[6..-1]\n end", "def determine_line_number(scanner)\n scanner.string[0, scanner.pos].count(\"\\n\")\n end", "def line_index()\n end", "def line\n\t return -1 if @inputStack.empty? # only if initialize() arg is bogus\n\n\t input = @inputStack[0] # not @inputStack.last\n\t str = input.string[0 .. input.pos]\n\t return str.count(\"\\n\") + 1\n\tend", "def from_line_index\n from_line - 1\n end", "def line_number\n\t\t\t@line_index + 1\n\t\tend", "def line_space(index=@buffer.line.end)\n\t\t\ts = 0\n\t\t\t@buffer[@buffer.line.start ... index].each_char do |k|\n\t\t\t\ts += char_space(k, s)\n\t\t\tend\n\t\t\t\n\t\t\ts\n\t\tend", "def get_char_position_in_line\n raise NotImplementedError\n end", "def line_number(pos=pos())\n line_index(pos) + 1\n end", "def line_number\n lines_read.length\n end", "def line_number(pos=pos)\n line_index(pos) + 1\n end", "def next_match char\n data = get_content\n row = focussed_index\n currval = data[row].chomp\n row.upto(data.length-1) do |ix|\n val = data[ix].chomp\n if val[0,1] == char and val != currval\n return ix\n end\n end\n 0.upto(row) do |ix|\n val = data[ix].chomp\n if val[0,1] == char and val != currval\n return ix\n end\n end\n return -1\n end", "def nextChar\n if getChar == \"\\n\"\n @line += 1\n @column = @lastLineSize\n end\n @index += 1\n @column += 1\n end", "def find_whitespace_index(characters)\n n = characters.length\n n.times do |i|\n if characters[i] == \" \"\n return i\n end\n end\n return n\nend", "def [](n)\n @chars[n]\n end", "def line_offset(line_index)\n return unless line_exists?(line_index)\n line_index == 0 ? 0 : @line_lengths[0..(line_index - 1)].sum\n end", "def column\n\t return -1 if @inputStack.empty? # only if initialize() arg is bogus\n\n\t input = @inputStack[0] # not @inputStack.last\n\t currLineStart = input.string.rindex(\"\\n\", input.pos)\n\t return input.pos + 1 if currLineStart.nil?\n\t return input.pos - currLineStart + 1\n\tend", "def prevChar\n if getChar == '\\n'\n @line -= 1\n @column = @lastLineSize\n end\n @index -= 1\n @column -= 1\n end", "def input_to_index(position)\nindex = position.strip.to_i - 1\nreturn index\nend", "def skip n=1\r\n\t\tif !@buffer then return nil end\r\n\t\t@buffer= @buffer[n..-1]\r\n\t\tif !@buffer then nl end\r\n\t\tif !@buffer then return nil end\r\n\t\t@buffer.lstrip!\r\n\t\t@col=@max-@buffer.length+1\r\n\t\tif (@buffer.lstrip==\"/n\" || @buffer.lstrip==\"\") then nl end\r\n end", "def line_for_offset(offset)\n if line_nbr = line_index.index {|x| x > offset}\n return line_nbr\n end\n # If not found it is after last\n return line_index.size\n end", "def start_of_word(text,n)\n\treturn text[0,n]\nend", "def character(index = nil)\n return '' if line && line.empty?\n return line[-1] unless index\n\n Vedeu::Editor::Item.by_index(line, index)\n end", "def line(number)\n lines[number - 1]\n end", "def line_number\n $curwin.cursor.first\n end", "def line_num_to_coord(n)\n\t\t(n + 1) * font_metrics.height\n\tend", "def current_line_number\n # Not using string[@previous_pos..best_pos].count('\\n') because it is slower\n strscan = ::StringScanner.new(string)\n strscan.pos = @previous_pos\n old_pos = pos + 1\n @previous_line_number += 1 while strscan.skip_until(/\\n/) && strscan.pos <= old_pos\n\n @previous_pos = (eos? ? pos : pos + 1)\n @previous_line_number\n end", "def nextchars(n)\n raise \"substring bounds error\" if (@index + n > @source.length)\n i = @index\n @index += n\n return(@source[i,n])\n end", "def index_of_position(row, col = 0)\n\t\tline_index(row) + col + 1\n\tend", "def nontrivial_end_line\n if successor\n successor.line_numbers.begin - 1\n else\n @document.last_non_empty_line\n end\n end", "def find_nth_from_end(n)\n list_length = self.length\n return nil if n > list_length - 1 || n < 0\n cursor = @tail\n n.times do\n cursor = cursor.prev\n end\n return cursor.data\n end", "def line_char_to_offset(text, line, character); end", "def line_offset(pos=pos())\n p = 0\n string.each_line do |line|\n len = line.length\n return (pos - p) if p + len >= pos\n p += len\n end\n 0\n end", "def next_match char\n data = get_content\n row = focussed_index + 1\n row.upto(data.length-1) do |ix|\n val = data[ix].chomp rescue return # 2010-01-05 15:28 crashed on trueclass\n #if val[0,1] == char #and val != currval\n if val[0,1].casecmp(char) == 0 #AND VAL != CURRval\n return ix\n end\n end\n row = focussed_index - 1\n 0.upto(row) do |ix|\n val = data[ix].chomp\n #if val[0,1] == char #and val != currval\n if val[0,1].casecmp(char) == 0 #and val != currval\n return ix\n end\n end\n return -1\n end", "def NextChar\r\n\t\t@Line.slice!(0, 1)\r\n\tend", "def find_eow\n\t\t\ti = buffer.index\n\t\t\ti += 1 while ((buffer[i] != nil) && buffer[i].match(/\\w/))\n\t\t\treturn i-1\n\t\tend", "def line_offset(pos=pos)\n p = 0\n string.each_line do |line|\n len = line.length\n return (pos - p) if p + len >= pos\n p += len\n end\n 0\n end", "def line_num; end", "def row(n = nil)\n CSI + \"#{n || 1}d\"\n end", "def nth_ref(n)\n if lm = @last_match\n return lm[n]\n end\n\n return nil\n end", "def prompt_ending_index()\r\n if !@rl_byte_oriented\r\n @prompt_physical_chars\r\n else\r\n (@prompt_last_invisible+1)\r\n end\r\n end", "def nextChar(n, char)\n\tif n > 0\n\t\treturn nextChar(n-1, char.next)\n\telse\n\t\treturn char\n\tend\nend", "def get_current_line(file, index)\n current_line = file[index.value]\n if !current_line.nil?\n current_line.chomp()\n end\n while (!current_line.nil?) && current_line.match(/\\A\\s*\\Z/)\n index.value += 1\n current_line = file[index.value]\n if !current_line.nil?\n current_line.chomp()\n end\n end\n return current_line\nend", "def nth_ref(n)\n if lm = last_match()\n return lm[n]\n end\n\n return nil\n end", "def num_lines() @line_indices.length + 1 end", "def each_reverse_newline_index_with_chunk(chunk_source)\n chunk_source.each_chunk do |chunk|\n while(nl_index = chunk.rindex(\"\\n\", (nl_index||chunk.size)-1))\n yield(nl_index, chunk)\n end\n end\n nl_index\nend", "def line_terminator\n if line_terminator?(@codes[@pos])\n begin\n @pos += 1\n end until !line_terminator?(@codes[@pos])\n return ECMA262::LineTerminator.get\n else\n nil\n end\n end", "def line_number\n env(:line_number).to_i - 1\n end", "def get_line_number(index)\n if @list_of_events.length.zero?\n puts 'list is empty'\n else\n temp_event = @list_of_events[index]\n temp_event.line_number\n end\n end", "def advance_position\n matched_fragment = @str[@pos...@s.pos]\n new_lines = matched_fragment.count(\"\\n\")\n if new_lines > 0\n characters_after_last_newline = matched_fragment.size - matched_fragment.rindex(\"\\n\") - 1\n [@line + new_lines, 1 + characters_after_last_newline]\n else\n [@line, @char + matched_fragment.size]\n end\n end", "def last_index(str, char)\n i = 0\n str.each_char.with_index do |ch,ind|\n if ch == char\n i = ind\n end\n end\n return i\nend", "def linenumber\n return @cmd.nil? ? 0 : @cmd.linenumber\n end", "def find_nth_from_end(n)\r\n list_length = self.length\r\n return nil if n > list_length - 1 || n < 0\r\n index = 1\r\n cursor = @head\r\n until (list_length - index) == n || !cursor.next\r\n index +=1\r\n cursor = cursor.next\r\n end\r\n return cursor.data\r\n end", "def io_buf_line\n index = @io_buf.index \"\\n\"\n return unless index\n\n @io_buf.slice!(0..index)\n end", "def line_pos(row)\n (row > 0 ? src.split(\"\\n\")[0..(row - 1)].inject(0) { |pos, line| pos + line.length + 1 } : 0)\n end", "def position(index)\n return [-1, -1] unless index < string.length\n\n row_start = @line_starts.select { |line_start| line_start <= index }.last\n row = @line_starts.index(row_start)\n column = index - row_start\n [row, column]\n end", "def getc\n # Read c\n c = @input.getc\n\n # Maintain counters\n if c == \"\\n\"\n @line += 1\n @pos = 1\n else\n @pos += 1\n end\n\n # Return char\n return c\n end", "def line_length(line_index)\n @line_lengths[line_index]\n end", "def lineno()\n #This is a stub, used for indexing\n end", "def lineno\n @__line\n end", "def line\n return 1 unless lexing_context && locator\n locator.line_for_offset(lexing_context[:end_offset])\n end", "def row\n return nil unless @row\n if @row < 0\n return FFI::NCurses.LINES + @row\n end\n @row\n end", "def normal_data_start(text)\n text.index(\"\\1\\n\", 2) + 2\n end", "def line_column(string, offset)\n return 1,1 if string.length==0 || offset==0\n lines = (string[0..offset-1] + \" \").split(\"\\n\")\n return lines.length, lines[-1].length\n end", "def start_of_word(word, n)\n\treturn word[0..(n - 1)]\nend", "def get_char at\n index = range_correct_index(at)\n return internal_object_get(index + 1)\n end", "def input_line\n lines - 1\n end", "def nthNumber(s, n)\n pattern = /(?:\\D*\\d+\\D*){#{n-1}}0*(\\d+)/ # https://ruby-doc.org/core-2.5.1/Regexp.html#class-Regexp-label-Grouping\n return pattern.match(s)[1]\nend", "def last_line(src)\n if n = src.rindex(\"\\n\")\n src[(n+1) .. -1]\n else\n src\n end\nend", "def next_char\n temp = @file.eof? ? '^' : @file.getc\n @line += temp;\n @columnCount+=1\n return temp\n end", "def count_trailing_newlines(text)\n if text.end_with? \"\\n\"\n count = 0\n\n text.reverse.chars do |c|\n if c == \"\\n\"\n count += 1\n else\n break\n end\n end\n\n count\n else\n 0\n end\n end", "def get_counterpart(interpreter)\n current_line_index = interpreter.current_line_index\n number = current_line_index.number\n statement_index = current_line_index.statement\n index = current_line_index.index\n other_index = -index\n LineNumberIndex.new(number, statement_index, other_index)\n end", "def line_numbers\n return (line..line) unless @value && text\n\n end_line = if !lines.empty?\n line + lines.count - 1\n elsif children.empty?\n nontrivial_end_line\n else\n line\n end\n\n (line..end_line)\n end", "def character_at(source_position, offset = 0)\n actual_line = source_position.line - 1\n actual_offset = source_position.offset + offset - 1\n\n # Return a newline if offset points at the very end of the line\n return \"\\n\" if actual_offset == engine.lines[actual_line].length\n\n engine.lines[actual_line][actual_offset]\n end", "def getNumLines()\n contents.split(\"\\n\").length - 1\n end", "def peek(n = 0)\n offset = (0..n).inject(0) do |acc, p|\n peek_token(p)&.empty? ? acc + 1 : acc\n end\n peek_token(n + offset)\n end", "def row_seek(n)\n ret = @index\n @index = n\n ret\n end", "def nth_char(arr)\n str = ''\n 0.upto(arr.size - 1) do |idx|\n str += arr[idx][idx]\n end\n str\nend", "def elmt_offset_at token_index\n # Defaults to the character position BEYOND the last text element\n (self[token_index]&.last if token_index) || (last.last + self.last.first.to_s.length)\n end", "def line(num) lines(num, 1) end", "def line\n buffer[line_number]\n end", "def find_line_boundary(text, start_index, rightwards)\n index = start_index\n vector = -1\n vector = 1 if rightwards\n\n loop do\n character = text[index]\n\n if rightwards\n break if index >= text.length\n break if character == \"\\n\"\n else\n break if index <= 0\n break if text[index - 1] == \"\\n\"\n end\n\n index = index + vector\n end\n\n index\n end", "def line_number\n @line_number_overwrite || default_line_number\n end", "def lineno\n @lineno || uninitialized!\n end", "def get_number(lines)\n lines.shift.to_i\n end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end" ]
[ "0.7387125", "0.69991666", "0.6984622", "0.6936094", "0.6918486", "0.6593659", "0.6475847", "0.64593613", "0.6398444", "0.63612634", "0.6360189", "0.63082767", "0.6301517", "0.6263164", "0.6260434", "0.62538785", "0.6223898", "0.62192756", "0.62011427", "0.61791855", "0.6064249", "0.60324055", "0.6023737", "0.600175", "0.6001393", "0.59978867", "0.5970971", "0.5967006", "0.5955089", "0.5947672", "0.59305704", "0.5873146", "0.58690506", "0.58625376", "0.58570457", "0.5852884", "0.5842133", "0.5834743", "0.5834348", "0.5831516", "0.5827794", "0.5821097", "0.5805304", "0.5789528", "0.577849", "0.5766607", "0.57537276", "0.57527936", "0.57447", "0.57437074", "0.5736574", "0.5734887", "0.57343584", "0.57328194", "0.57301724", "0.57216686", "0.57213205", "0.57121646", "0.56731486", "0.56607366", "0.566014", "0.5659895", "0.56454235", "0.5643149", "0.56389457", "0.5605568", "0.5601182", "0.5589052", "0.5588856", "0.5587367", "0.55823123", "0.5572903", "0.55722666", "0.5567914", "0.5566275", "0.5565523", "0.553689", "0.55347055", "0.5524729", "0.5516204", "0.5495787", "0.5493644", "0.5487317", "0.54854035", "0.5462741", "0.545887", "0.54444194", "0.54380417", "0.5435276", "0.54295534", "0.5429059", "0.54228455", "0.54158384", "0.54090023", "0.53994805", "0.53994805", "0.53994805", "0.53994805", "0.53994805", "0.53994805" ]
0.6994547
2
Returns the index of 'row', 'col' in the singledimensional array
def index_of_position(row, col = 0) line_index(row) + col + 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getArrayIndex(row, col)\n index = 0\n case row\n when '1'\n if col == 'A'\n index = 0\n elsif col == 'D'\n index = 1\n else index = 2\n end\n when '2'\n if col == 'B'\n index = 3\n elsif col == 'D'\n index = 4\n else index = 5\n end\n when '3'\n if col == 'C'\n index = 6\n elsif col == 'D'\n index = 7\n else index = 8\n end\n when '4'\n if col == 'A'\n index = 9\n elsif col == 'B'\n index = 10\n elsif col == 'C'\n index = 11\n elsif col == 'E'\n index = 12\n elsif col == 'F'\n index = 13\n else index = 14\n end\n when '5'\n if col == 'C'\n index = 15\n elsif col == 'D'\n index = 16\n else\n index = 17\n end\n when '6'\n if col == 'B'\n index = 18\n elsif col == 'D'\n index = 19\n else\n index = 20\n end\n when '7'\n if col == 'A'\n index = 21\n elsif col == 'D'\n index = 22\n else\n index = 23\n end\n end\n return index\n end", "def get_index(row, col)\n index, row_end = @row_vector[row], @row_vector[row + 1]\n\n while (index < row_end) and (index < nnz) and (col >= @col_vector[index])\n return [index, @data[index]] if @col_vector[index] == col\n index += 1\n end\n [index, nil]\n end", "def [](row,col)\n case col\n when 0...81\n @row_column[row][col]\n when 81...162\n @row_number[row][col - 81]\n when 162...243\n @column_number[row][col - 162]\n when 243...324\n @box_number[row][col - 243]\n else\n nil\n end\n end", "def [](pos) #pos = [1,2]\n # x, y = pos\n x = pos[0]\n y = pos[1]\n @rows[x][y] \n end", "def set_current_row_col(array)\r\n current_s_index = array.locate2d(' ')\r\n @current_row = current_s_index.flatten.first\r\n @current_col = current_s_index.flatten.last\r\n end", "def coord_to_pos(row,col)\n return nil if row.even? && col.even? || row.odd? && col.odd? #these are always empty squares in checkers!\n return row*4+(col/2).floor+1\n end", "def [](row, col)\n @grid[row][col]\n end", "def getCell(row, col)\n # Make sure the row/col combination is within the matrix.\n if row > @rows || col > @cols || row <= 0 || col <= 0\n return 0\n end\n return @info[row][col]\n end", "def find_ones\n ones_locations = []\n # => finding index of ROW and COL for each 1 in grid and storing as row/col array pairs\n @image_array.each_index do |row|\n @image_array[row].each_index do |col|\n if @image_array[row][col] == 1\n puts \"#{row}, #{col}\" # <---this is just to display that it's working, can be removed\n ones_locations << [row, col]\n end\n end\n end\n return ones_locations\n end", "def cellAt(row, col)\n\t\treturn @rows[row][col]\n\tend", "def [](pos)\n row, col = pos\n @rows[row][col]\n end", "def [](pos)\n x, y = pos\n @rows[x][y]\n end", "def get_index_for_pos(prow, pcol)\r\n idx = 0\r\n ct = 0\r\n maxidx = 1e10.to_i\r\n #deblog(\"idx4pos(row:#{prow}, col:#{pcol}) starts; maxidx=#{maxidx}\")\r\n while idx < maxidx\r\n ct += 1\r\n idx += 1\r\n STDERR.print '.' if ct % 1000 == 0\r\n STDERR.puts \">#{idx}: #{get_pos_for_idx(idx)}\" if ct % (1000*100) == 0\r\n aa = get_pos_for_idx(idx)\r\n #deblog(\"aa=#{aa} pos4idx tst #{idx}\")\r\n if aa[0]==prow and aa[1]==pcol\r\n tracelog(\"idx4pos=#{idx} @ [#{prow}, #{pcol}]\")\r\n return idx\r\n end\r\n end\r\n #deblog(\"idx4pos fail=#{idx} @ [#{prow}, #{pcol}]\")\r\n raise \"no pos4idx found\"\r\nend", "def rowcol\n return self.row+@row_offset, self.col+@col_offset\n end", "def get_cell_at_xy(input_array)\n input_array.map do |coord|\n x = coord[0]\n y = coord[1]\n at_coord(x, y)\n end\n end", "def [](pos)\n row, col = pos\n grid[row][col]\n end", "def [](pos)\n row, col = pos\n grid[row][col]\n end", "def [](pos)\n @grid[pos[0]][pos[1]]\n # row,col = pos\n # @grid[row][col]\n end", "def find_ones\n # => Establish an empty array to hold the index positions of all the 1s\n ones_ary = []\n # => Finding the index of ROW and COL for each 1 in the grid and storing\n # => them as row/col array pairs\n\n # => |row| denotes the top-level array (could be named anything)\n @image_array.each_index do |row|\n # => |col| is the chosen variable name for the inner array\n @image_array[row].each_index do |col|\n if @image_array[row][col] == 1\n puts \"#{row}, #{col}\"\n ones_ary << [row, col]\n end\n end\n end \n return ones_ary\n end", "def matrix_find(row, column)\n self[row*9 + column]\n end", "def at(row = @row, col = @col)\n row, col = wrap(row, col)\n return nil unless in_bounds?(row, col)\n\n @cells[row][col]\n end", "def [](row_index, col_index)\n row = data[row_index]\n row && row[col_index]\n end", "def [](pos)\n r, c = pos[0],pos[1]\n grid[r][c]\n end", "def [](pos)\n row = pos.first\n col = pos.last\n @grid[row][col]\n end", "def mineLocation(field)\n row = 0\n column = 0\n field.each_with_index do |array, index|\n row = index if array.include?(1)\n end\n\n field[row].each_with_index do |num, index|\n column = index if num.eql?(1)\n end\n [row, column]\nend", "def [](pos)\n row, col = pos[0], pos[1]\n @rows[row][col]\n end", "def findIndex(a, x)\n\tn = a.length\n\ti = n - 1\n\tj = 0\n\twhile a[i][j] != x do\n\t\tif a[i][j + 1] <= x then\n\t\t\tj += 1\n\t\telse\n\t\t\ti -= 1\n\t\tend\n\tend\n\treturn i, j\nend", "def rowcol #:nodoc:\n return @row+@row_offset, @col+@col_offset\n end", "def position(row, column)\n\t\tcolmn = get_column(column)\n\t\treturn colmn[row] unless colmn.nil?\n\tend", "def [](pos)\n row, col = pos\n @grid[row][col]\n end", "def [](pos)\n row, col = pos\n raise \"Invalid coordinate\" unless (0..7).include?(row) && (0..7).include?(col)\n @board[row][col]\n end", "def [](pos)\n grid[pos[0]][pos[1]]\n end", "def find(num)\n $pre_grid.each_with_index do |row,row_i|\n row.each_with_index do |e,e_i|\n i = [ row_i, e_i ]\n # special case for finding second 1\n if e.to_i == num && i != $first1\n return i\n end\n end\n end\nend", "def row_col\n f = lambda do |board ,mark|\n board.any? { |row| row.all? {|cell| cell == mark } } end\n\n return :X if (f.call(@grid ,:X) || f.call(@grid.transpose,:X))\n return :O if (f.call(@grid ,:O) || f.call(@grid.transpose,:O))\n end", "def [](pos)\n x, y = pos\n grid[x][y]\n end", "def at_index(x,y)\n @board[x][y]\n end", "def get_col(board,col)\n\tboard.map { |row| row[col] }\nend", "def find_position(type, color)\n @grid.each_with_index do |row, ridx|\n row.each_with_index do |square, cidx|\n if square != nil && square.type == type && square.color == color\n return [ridx, cidx]\n end\n end\n end\n nil\n end", "def [](row, column)\n\t\treturn nil unless row.between?(0, @rows-1)\n\t\treturn nil unless column.between?(0, @columns-1)\n\t\t@grid[row][column]\n\tend", "def get_cols_index(col)\n i = @cols.size - 1\n\n @cols.reverse_each do |column|\n if col >= (Integer(column[:attributes][:min])-1)\n if col <= (Integer(column[:attributes][:max])-1)\n break\n end\n end\n i -= 1\n end\n if i < 0\n i = @cols.size #effectively nil\n end\n i\n end", "def cell(row_num, col_num)\n return @puzzle[row_num][col_num]\n end", "def neighbors(row, col, arr)\n height = arr.size\n width = arr[0].size\n neighbors = []\n neighbors << [row, col + 1] if col + 1 < width && arr[row][col + 1] >= 1\n neighbors << [row, col - 1] if col - 1 >= 0 && arr[row][col - 1] >= 1\n neighbors << [row + 1, col] if row + 1 < height && arr[row + 1][col] >= 1\n neighbors << [row - 1, col] if row - 1 >= 0 && arr[row - 1][col] >= 1\n\n neighbors\nend", "def [](pos)\n row, col = pos\n @grid[row][col]\n end", "def cell(col, row)\n return nil if out_of_bound?(row, 0, Grid::MaxRow - 1)\n return nil if out_of_bound?(col, 0, Grid::MaxCol - 1)\n return (Grid::MaxCol * row) + col\n end", "def marker_coords(marker)\n row = @grid.find_index { |x| x.include?(marker) }\n col = @grid[row].index(marker)\n\n [col, row]\n end", "def [](pos)\n x, y = pos.first, pos[1]\n @grid[x][y]\n end", "def [](pos)\n row, col = pos \n @grid[row][col]\n end", "def [](row, column)\n end", "def find_index(column, row)\n\n # Column 0 is for shelf numbers, so no index.\n return nil if column == 0\n\n # Find shelf number.\n shelf = ((row + 1) / 2.0).ceil\n\n # Return index number.\n if (row % 2 != 0)\n return 3 * (shelf - 1) + 2\n else\n return 3 * (shelf - 1) + (column - 1)\n end\n\n end", "def idx(x, y)\n tx = x % @width\n ty = y % @height\n idx = tx + ty * @width\n end", "def [](row, col)\n #convert row values by * by 9\n @grid[row * 9 + col]\n end", "def [](row, column)\n puzzle[row][column]\n end", "def [](pos)\n raise \"pos not on board\" unless on_board?(pos)\n i, j = pos\n @rows[i][j]\n end", "def index_of x, y\n\t\tindex = (y* @width) + x\n\t\treturn index\n\tend", "def row_at(row_idx)\n @grid[row_idx]\n end", "def at(row, column)\n # We have to do three things:\n #\n # 1. Make sure \"row\" is in bounds\n # 2. Make sure \"column\" is in bounds\n # 3. Return the appropriate value on the board (if present)\n @board[row][column]\n end", "def getXYIndex(s)\n return s.y * @width + s.x;\n end", "def [](pos)\n self.grid[pos[1]][pos[0]]\n end", "def [](pos)\n raise 'invalid pos' if !valid_pos?(pos)\n \n row, col = pos\n @rows[row][col]\n end", "def [](pos)\n x, y = pos\n @grid[x][y]\n end", "def [](pos)\n x, y = pos\n @grid[x][y] \n end", "def [](row, column)\n cell(row, column)\n end", "def index_for(x, y, coordinate_system=:row_col)\n case coordinate_system\n when :row_col\n x * 9 + y\n when :col_row\n y * 9 + x\n when :box\n [0,3,6,27,30,33,54,57,60][x] + [0,1,2,9,10,11,18,19,20][y]\n end\n end", "def encontrar\t\n\t\t@fil.to_i.times do |i| \n\t\t\t@col.to_i.times do |j| \t\t\t\t\n\t\t\t\tif yield(mat[i][j]) \n\t\t\t\t\treturn [i,j]\n\t\t\t\tend\t\t\t\t\t\n\t\t\tend\n\t\tend\n\tend", "def get_column_index(line, col_name)\n line_ar = (line.is_a? Array) ? line : line.split\n line_ar.find_index(col_name)\nend", "def get_row(row,board) # row(x,*y)\n\tboard[row]\nend", "def neighbor_cell_coordinates\n NEIGHBOR_OFFSETS.map { |coordinates| [row + coordinates[0], col + coordinates[1]] }\n end", "def get_index_of_position(target_position, ary)\n ary.each_index do |i|\n current_position = ary[i][1]\n if current_position == target_position\n return i\n end\n end\n end", "def element_at(row_idx, column_idx)\n target_row = row_at(row_idx)\n target_row[column_idx]\n end", "def indexes_of_letter(letter, game)\n cells = []\n game.each_with_index do |row, y|\n row.each_with_index do |cell, x|\n cells << [x, y] if cell == letter\n end\n end\n cells\nend", "def get_coordinates(cell)\n row = @cell_coordinates[cell][0]\n col = @cell_coordinates[cell][1]\n [row, col]\n end", "def position\n [row.position, column.position]\n end", "def find_min_elem(matrix)\n min = matrix[1][2]\n indices = [1, 2] \n for i in 1...matrix.length\n for j in i+1...matrix.length\n if ( matrix[i][j] < min )\n min = matrix[i][j]\n indices = [i, j]\n end\n end\n end\n indices\nend", "def coord_to_index(piece, board)\n all_coordinates = board.keys\n index = all_coordinates.index(piece.position.to_sym) \n end", "def squarocol?(arr)\n i = 0\n while i < arr.length\n row_ele = arr[i][0] #x\n col_ele = arr[0][i] #x\n return true if arr[i].all? { |ele| ele == row_ele }\n return true if arr.all? { |subArr| subArr[i] == col_ele }\n i += 1\n end\n false\n\nend", "def [] x, y\r\n @rows[y][x]\r\n end", "def position_coordinates(character)\n which_row = []\n which_cell = []\n (0...@n).each { |i| prepare_set(i, character, which_row, which_cell) }\n [which_row, which_cell]\n end", "def get_row(board, row)\n board[row]\nend", "def get_row(board, row)\n board[row]\nend", "def [](pos)\n @board[pos[0]][pos[1]]\n end", "def [] (row, col)\n _get(gsl, row, col)\n end", "def get_index_from_rowcol(row_col)\n offset = @@row_mappings[row_col[0]].to_i\n multiplier = row_col[1].to_i - 1\n return multiplier * 8 + offset\n end", "def get_row(board, row)\n\tboard[row]\nend", "def pos(a,b)\n\t\t@mat[a][b]\n\tend", "def find_cell(cells, x, y)\n cells.detect{|cell| cell.x == x && cell.y == y }\nend", "def find_all_empty_cells\n @board_array.each_index do |i|\n row = @board_array[i]\n row_index = i\n row.each_index do |i|\n char = row[i]\n column_index = i\n if char == \"-\"\n return [row_index,column_index]\n end\n end\n end\n end", "def get x, y\n if x<0 || x>=size || y<0 || y>=size\n raise ArgumentError, \"Is there a #{x},#{y} cell in a #{size}x#{size} sudoku ?\"\n end\n @grid[x][y]\n end", "def [](x,y)\n @board[x][y]\n end", "def [](pos)\n row,col = pos\n @board[row][col]\n end", "def locate_coordinate(position)\n x = -1\n y = -1\n \n @position_matrix.each_with_index do |array, index| \n if array.include?(position)\n y = index \n x = array.index(position)\n end\n end\n return x, y\n end", "def get_cell(x, y)\n grid[x][y]\n end", "def row_ia(x, y)\n (0...layers).map { |z| xyz_toindex(x, y, z) }\n end", "def next_cell(grid)\n grid.each_with_index do |row, x|\n row.each_with_index do |cell, y|\n return x, y if cell.length > 1\n end\n end\n end", "def indices\n return [\n columns.nil? ? nil : columns.begin,\n rows.nil? ? nil : rows.begin,\n columns.nil? ? nil : columns.end,\n rows.nil? ? nil : rows.end\n ]\n end", "def [](pos)\n if valid_pos?(pos)\n row, col = pos\n @grid[row][col]\n else\n puts \"Invalid position\"\n end\n end", "def get_row(board, row)\n return board[row]\nend", "def getPosIndex(pos)\n (x,y,z) = pos ;\n dx = x + @offset[0] - @origin[0] ;\n dy = y + @offset[1] - @origin[1] ;\n dz = z + @offset[2] - @origin[2] ;\n ix = (dx / @gridSize[0]).floor ;\n iy = (dy / @gridSize[1]).floor ;\n iz = (dz / @gridSize[2]).floor ;\n return [ix, iy, iz] ;\n end", "def get_value(row, col)\n @rectangle[row][col]\n end", "def get_col(board, col)\n board.map {|x| x[col]}\nend", "def is_valid_index?(row, column)\r\n # Check if the specified row is out of bounds\r\n if ( row < 0 ) || ( row >= @image_array.length )\r\n return false\r\n end\r\n\r\n # Check if the specified column is out of bounds\r\n if ( column < 0 ) || ( column >= @image_array[row].length )\r\n return false\r\n end\r\n\r\n return true\r\n end" ]
[ "0.7620627", "0.76191115", "0.7141633", "0.6696994", "0.66085047", "0.6593831", "0.655882", "0.65429103", "0.6529742", "0.65205866", "0.64939433", "0.6442951", "0.6433444", "0.6403113", "0.6400754", "0.63894373", "0.63894373", "0.63887095", "0.63776755", "0.63762736", "0.6360149", "0.63486916", "0.6334588", "0.63249093", "0.6323044", "0.6316219", "0.62968147", "0.62886226", "0.6263487", "0.626279", "0.62491894", "0.62278366", "0.6207806", "0.6202939", "0.6196089", "0.61832476", "0.61803067", "0.61701065", "0.6147276", "0.61458576", "0.6140463", "0.61357003", "0.61351514", "0.6130547", "0.61290216", "0.61077243", "0.6101827", "0.6093033", "0.60900354", "0.60883147", "0.6085144", "0.6062357", "0.60553986", "0.603843", "0.60348314", "0.60335", "0.6031513", "0.6025069", "0.602168", "0.60162604", "0.601263", "0.6004236", "0.6000769", "0.5983882", "0.59794986", "0.59695727", "0.5966514", "0.59657717", "0.59541297", "0.5950349", "0.5946909", "0.5933454", "0.59261626", "0.59243095", "0.59223455", "0.59208304", "0.5917585", "0.59169865", "0.59169865", "0.59092534", "0.5908386", "0.5906748", "0.5903026", "0.589518", "0.5894711", "0.58933115", "0.5887137", "0.5873904", "0.587173", "0.58708006", "0.58694106", "0.5868831", "0.5867106", "0.58670664", "0.5865933", "0.58634335", "0.5861522", "0.58589345", "0.58478135", "0.5836709" ]
0.7217415
2
Given an absolute index returns the line number and index
def index_line_and_col(index) i = 0 i += 1 while index_of_position(i) <= index i -= 1 [i, index - index_of_position(i)] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def from_line_index\n from_line - 1\n end", "def line_index()\n end", "def line_index(num)\n\t\tif num == 0\n\t\t\treturn -1\n\t\telsif num <= @line_indices.length\n\t\t\treturn @line_indices[num - 1]\n\t\telsif num == @line_indices.length + 1\n\t\t\treturn @text.length\n\t\telse\n\t\t\treturn -999 # todo\n\t\tend \n\tend", "def position(index)\n return [-1, -1] unless index < string.length\n\n row_start = @line_starts.select { |line_start| line_start <= index }.last\n row = @line_starts.index(row_start)\n column = index - row_start\n [row, column]\n end", "def line_number(pos=pos())\n line_index(pos) + 1\n end", "def line_number(pos=pos)\n line_index(pos) + 1\n end", "def line_number\n\t\t\t@line_index + 1\n\t\tend", "def line_offset(line_index)\n return unless line_exists?(line_index)\n line_index == 0 ? 0 : @line_lengths[0..(line_index - 1)].sum\n end", "def compute_line_index\n scanner = StringScanner.new(@string)\n result = [0] # first line starts at 0\n while scanner.scan_until(/\\n/)\n result << scanner.pos\n end\n @line_index = result\n end", "def index_for(file, line_number)\n diff_for_file(file).fetch(:diff_chunks).\n reduce(0) do |index, position:, size:, diff:|\n # Unless we are processing the target chunk\n unless line_number.between?(position, position + size)\n next index + 1 + diff.lines.count\n end\n\n position -= 1 # rebase position on first line of chunk\n index_in_chunk = diff.lines.find_index do |line|\n position += 1 unless line.first == '-'\n position == line_number\n end\n\n return index + 1 + index_in_chunk\n end\n\n nil # if this line number is not in diff\n end", "def line_index(pos=pos())\n p = n = 0\n string.each_line do |line|\n p += line.length\n return n if p >= pos\n n += 1\n end\n 0\n end", "def line_number\n number[6..-1]\n end", "def index_of_position(row, col = 0)\n\t\tline_index(row) + col + 1\n\tend", "def line_index(pos=pos)\n p = n = 0\n string.each_line do |line|\n p += line.length\n return n if p >= pos\n n += 1\n end\n 0\n end", "def get_indexfile_with_line number\n IO.readlines(@indexfile)[number]\n end", "def line_number=(_arg0); end", "def line_number=(_arg0); end", "def line_number=(_arg0); end", "def line_for_position(position); end", "def line_for_position(position); end", "def line_for_position(position); end", "def line_number\n return unless backtrace and backtrace[0]\n\n backtrace[0].split(\":\")[1].to_i\n end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def lineno()\n #This is a stub, used for indexing\n end", "def line\n backtrace[0].match(Pattern)[1].to_i + 1\n end", "def current_line_number; end", "def line_pos(row)\n (row > 0 ? src.split(\"\\n\")[0..(row - 1)].inject(0) { |pos, line| pos + line.length + 1 } : 0)\n end", "def get_line_pos(pos)\n lpos = @line_ends.bsearch_index { |x, _| x >= pos }\n return lpos\n end", "def line_id\n @line_number - 1\n end", "def index\n history = File.open(@current)\n line = history.readline.rstrip\n line =~ /(\\d+)$/ # get the index\n $1.to_i\n end", "def line\n return 1 unless lexing_context && locator\n locator.line_for_offset(lexing_context[:end_offset])\n end", "def get_counterpart(interpreter)\n current_line_index = interpreter.current_line_index\n number = current_line_index.number\n statement_index = current_line_index.statement\n index = current_line_index.index\n other_index = -index\n LineNumberIndex.new(number, statement_index, other_index)\n end", "def get_line_number(index)\n if @list_of_events.length.zero?\n puts 'list is empty'\n else\n temp_event = @list_of_events[index]\n temp_event.line_number\n end\n end", "def line(number)\n lines[number - 1]\n end", "def get_pos_for_idx(idx)\r\n idxcount = 0\r\n diag = 0\r\n \r\n diagstart = 0\r\n while( idxcount < idx )\r\n diagstart = idxcount+1\r\n diag += 1\r\n idxcount += diag\r\n #deblog(\" diag #{diag} ends at # #{idxcount}; diagstart @idx #{diagstart}\")\r\n end\r\n diagdiff = idx - diagstart\r\n #deblog(\" idx #{idx} is on diag #{diag}; diagdiff=#{diagdiff}\")\r\n \r\n irow = diag\r\n icol = 1\r\n ipos = [irow-diagdiff, icol+diagdiff]\r\n tracelog(\" pos4idx returns #{ipos}\")\r\n ipos\r\nend", "def line_number\n env(:line_number).to_i - 1\n end", "def position_to_index(position)\n position - 1\n end", "def line_and_column(pos); end", "def start_line_number; end", "def start_line_number; end", "def find_position(path, line_number)\n io = @diff.each_line # maybe redundant?\n\n file_header = \"+++ b/#{path}\\n\" # fixme\n if !io.find_index(file_header)\n @status = :file_not_found\n return\n end\n\n line = io.peek\n if !hunk_header?(line)\n raise StandardError.new(\"Expected hunk header to be after file header, but got '#{line}'\")\n end\n\n pos = 0\n\n while true\n line = io.next\n pos += 1\n\n if file_header?(line)\n @status = :line_not_found\n return\n end\n\n if !hunk_header?(line)\n next\n end\n\n line_numbers = line_numbers_for_destination(line)\n\n if destination_position = line_numbers.find_index(line_number)\n @status = :found_position\n return pos + find_hunk_index(io, destination_position)\n end\n end\n rescue StopIteration\n @status = :line_not_found\n end", "def line_number\n $curwin.cursor.first\n end", "def line_num; end", "def line(number); end", "def get_lineno\n RubyVM::Frame.get(1).source_location[0]\n end", "def line_from_char(index = -1)\n send_message(:LINEFROMCHAR, index.to_i)\n end", "def get_index(position:)\n row = (position - 1) / 3\n col = (position - 1) % 3\n return row, col\n end", "def line_for_offset(offset)\n if line_nbr = line_index.index {|x| x > offset}\n return line_nbr\n end\n # If not found it is after last\n return line_index.size\n end", "def line(number)\n end", "def line_offset(pos=pos())\n p = 0\n string.each_line do |line|\n len = line.length\n return (pos - p) if p + len >= pos\n p += len\n end\n 0\n end", "def line_numbers\n return (line..line) unless @value && text\n\n end_line = if !lines.empty?\n line + lines.count - 1\n elsif children.empty?\n nontrivial_end_line\n else\n line\n end\n\n (line..end_line)\n end", "def extract_line_number(backtrace)\n return unless backtrace\n backtrace = backtrace.to_a\n return unless backtrace.length > 1\n m = backtrace.first.match(/^.+:(\\d+):/)\n return unless m and m.length > 1\n m[1]\n end", "def getParentIdx(idx)\n (idx-1)/2.0.floor if (idx > 0)\n end", "def line_offset(pos=pos)\n p = 0\n string.each_line do |line|\n len = line.length\n return (pos - p) if p + len >= pos\n p += len\n end\n 0\n end", "def linenumber\n return @cmd.nil? ? 0 : @cmd.linenumber\n end", "def input_to_index(position)\nindex = position.strip.to_i - 1\nreturn index\nend", "def line_number\n @value.line_number if @value.respond_to?(:line_number)\n end", "def visible_line_number\r\n return 5\r\n end", "def input_to_index(position)\n index = position.to_i - 1\n end", "def get_index(name_line)\n index_found = -1\n pattern = /\\(TestRail:.*\\:\\s*([0-9]+)\\s*\\)/\n just_cases = pattern.match(name_line)\n if ! just_cases.nil?\n index_found = just_cases[1].to_i\n end\n return index_found\n end", "def position_for_index(index)\n to_move = self.triplocations[index]\n return to_move.position if to_move\n return 1 if self.triplocations.empty?\n self.triplocations.last.position + 1\n end", "def start_line_number=(_); end", "def lineno=(_arg0); end", "def lineNum()\n caller_infos = caller.first.split(\":\")\n # Note caller_infos[0] is file name\n # caller_infos[1]\n return \"Line no. #{caller_infos[1]}\"\nend", "def line_offset\n\t\t\t@offset - @line_range.min\n\t\tend", "def input_to_index(position)\n index = position.to_i - 1\nend", "def lineno= integer\n #This is a stub, used for indexing\n end", "def index_from_start(index); end", "def relative_text_position(index)\n if at_end?(index)\n relative_end_position\n elsif relative_in_first_segment?(index)\n relative_in_first_segment(index)\n else\n relative_in_last_segment(index)\n end\n end", "def at(index); end", "def input_to_index(position)\n position = position .to_i\n index = position-1\nend", "def visible_line_number\n return 1\n end", "def visible_line_number\n return 1\n end", "def each_line_with_index\n c = 0\n each_line do |l|\n yield l, c\n c += 1\n end\n end", "def visible_line_number\n return 4\n end", "def visible_line_number\n return 4\n end", "def line(pos=pos())\n lines[line_index(pos)]\n end", "def line\n buffer[line_number]\n end", "def input_to_index(position)\n position.to_i - 1\nend", "def getCoords (index)\n return index%10, index/10\n end", "def lineno\n @__line\n end", "def line(n)\n @lines[n]\n end", "def lineNum()\n caller_infos = caller.first.split(\":\")\n # Note caller_infos[0] is file name\n caller_infos[1]\nend", "def line_number\n @line_number_overwrite || default_line_number\n end", "def input_to_index(position)\n position = position.to_i - 1\n return position\nend", "def visual_index\n row = @current_index\n row - @prow\n end", "def get_index_for_pos(prow, pcol)\r\n idx = 0\r\n ct = 0\r\n maxidx = 1e10.to_i\r\n #deblog(\"idx4pos(row:#{prow}, col:#{pcol}) starts; maxidx=#{maxidx}\")\r\n while idx < maxidx\r\n ct += 1\r\n idx += 1\r\n STDERR.print '.' if ct % 1000 == 0\r\n STDERR.puts \">#{idx}: #{get_pos_for_idx(idx)}\" if ct % (1000*100) == 0\r\n aa = get_pos_for_idx(idx)\r\n #deblog(\"aa=#{aa} pos4idx tst #{idx}\")\r\n if aa[0]==prow and aa[1]==pcol\r\n tracelog(\"idx4pos=#{idx} @ [#{prow}, #{pcol}]\")\r\n return idx\r\n end\r\n end\r\n #deblog(\"idx4pos fail=#{idx} @ [#{prow}, #{pcol}]\")\r\n raise \"no pos4idx found\"\r\nend", "def count_line_offset(index)\n Array(@spinners[index..-1]).reduce(0) do |acc, spinner|\n if spinner.spinning? || spinner.done?\n acc += 1\n end\n acc\n end\n end", "def line(pos=pos)\n lines[line_index(pos)]\n end", "def get_next_line(file, index)\n index.value += 1\n return get_current_line(file, index)\nend", "def lines_offset\n @starting_line - 1\n end", "def index_offset(io, tag='indexListOffset', bytes_backwards=200)\n tag_re = %r{<#{tag}>([\\-\\d]+)</#{tag}>}\n io.pos = (io.size - 1) - bytes_backwards\n md = io.readlines(\"\\n\").map {|line| line.match(tag_re) }.compact.shift\n md[1].to_i if md\n end", "def row index\n rows[index / 9]\n end", "def get_row_from_index (idx)\n (idx/@cols).floor\n end" ]
[ "0.7658351", "0.76503146", "0.7352164", "0.7191136", "0.71612537", "0.7147532", "0.7088944", "0.7041154", "0.6985347", "0.69707566", "0.69030946", "0.6849574", "0.6845614", "0.6836286", "0.6831197", "0.6813527", "0.6813527", "0.6813527", "0.6787191", "0.6787191", "0.6787191", "0.673855", "0.6678523", "0.6678523", "0.6678523", "0.6678523", "0.6678523", "0.6678523", "0.6678523", "0.6582355", "0.65477026", "0.64948934", "0.64756924", "0.6466031", "0.6457398", "0.64516544", "0.6427595", "0.64219034", "0.640763", "0.6390473", "0.6384233", "0.6363009", "0.6348462", "0.63417006", "0.63351", "0.63351", "0.6326316", "0.6308264", "0.6289168", "0.6282245", "0.6263514", "0.6262652", "0.6250238", "0.6212987", "0.62087077", "0.62031937", "0.619592", "0.61927366", "0.61907256", "0.61846006", "0.6181581", "0.61669713", "0.61659926", "0.6163005", "0.615989", "0.6147499", "0.614258", "0.61414766", "0.6128037", "0.61269563", "0.61264145", "0.6117997", "0.61164355", "0.61153233", "0.6112752", "0.6111375", "0.6109762", "0.60940605", "0.60940605", "0.6093029", "0.60901594", "0.60901594", "0.6074203", "0.60536504", "0.60517675", "0.6003299", "0.59995145", "0.59994286", "0.5991656", "0.59868276", "0.59719753", "0.5966374", "0.5960874", "0.59564793", "0.59550047", "0.5952343", "0.5947427", "0.5943041", "0.59410864", "0.59345466" ]
0.72391075
3
Adds 'amount' to all line indices with a current value greater than or equal to 'threshold'
def adjust_line_indices_after(threshold, amount) @line_indices.map! { |l| l >= threshold ? l + amount : l } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def threshold=(threshold)\n @threshold = threshold\n \n @threshold = 100 if threshold > 100\n @threshold = 1 if threshold < 1\n end", "def relaxed_threshold(threshold)\n\t\tif threshold > @threshold_gap\n\t\t\trelaxed_threshold = threshold - @threshold_gap\n\t\telse\n\t\t\trelaxed_threshold = threshold\n\t\tend\n\t\trelaxed_threshold\n\tend", "def setLineSpacingThreshold(threshold)\n unless /(?i)^0$|^[0-9]+%$/.match(threshold)\n raise Error.new(Pdfcrowd.create_invalid_value_message(threshold, \"setLineSpacingThreshold\", \"pdf-to-text\", \"The value must be a positive integer percentage.\", \"set_line_spacing_threshold\"), 470);\n end\n \n @fields['line_spacing_threshold'] = threshold\n self\n end", "def with_threshold(threshold)\n reconfigure(configuration.with(threshold: threshold))\n end", "def line(options)\n raise \"lines need a caption\" unless options.include?(:caption)\n raise \"lines need a value\" unless options.include?(:value)\n raise \"lines need a color\" unless options.include?(:color)\n\n options[:alias] = options[:caption] unless options[:alias]\n\n args = {:data => \"threshold(#{options[:value]})\", :color => options[:color], :alias => options[:alias]}\n\n args[:dashed] = true if options[:dashed]\n args[:second_y_axis] = true if options[:second_y_axis]\n\n field \"line_#{@linecount}\", args\n\n @linecount += 1\n end", "def set_Threshold(value)\n set_input(\"Threshold\", value)\n end", "def set_spill_threshold(threshold)\n properties['cascading.spill.list.threshold'] = threshold.to_s\n end", "def add_credit(amount)\n raise Transfer::NegativeAmountException if(amount < 0)\n self.lines.create(amount: self.balance + amount)\n self.balance += amount\n end", "def add_changepoints_to_plot(ax, fcst, threshold: 0.01, cp_color: \"r\", cp_linestyle: \"--\", trend: true)\n artists = []\n if trend\n artists << ax.plot(to_pydatetime(fcst[\"ds\"]), fcst[\"trend\"].to_a, c: cp_color)\n end\n signif_changepoints =\n if @changepoints.size > 0\n (@params[\"delta\"].mean(axis: 0, nan: true).abs >= threshold).mask(@changepoints.to_numo)\n else\n []\n end\n to_pydatetime(signif_changepoints).each do |cp|\n artists << ax.axvline(x: cp, c: cp_color, ls: cp_linestyle)\n end\n artists\n end", "def threshold\n @threshold || 95\n end", "def data_threshold=(threshold)\n if (rc = Native.sd_journal_set_data_threshold(@ptr, threshold)) < 0\n raise JournalError, rc\n end\n end", "def set_line(actor)\n for condition in Overdrive_Line_Value.keys\n return [Overdrive_Line_Value[condition] - 1, 0].max if eval(condition)\n end\n return 0\n end", "def threshold_reached_value_type_count_xxx(value_type, threshold_type)\n # Used to prefix sender email to change it\n new_email_prefix = \"new_\"\n # This is ripped from email_bill_entry value_type_value\n sum_thus_far_curr_val = 0\n sum_thus_far_curr_code = nil\n sum_thus_far_str = nil\n email_elem = inbound_emails(:nick_n_xxx_y_yyy_n_tags_y_currency_sender_idable_inbound_email)\n # Set the path so that the \"from:\" email is used\n # otherwise sender is anonymous\n @request.path = Constants::SENDGRID_PARSE_URL\n post :create, :inbound_email => email_elem.attributes\n # Get the new pii\n input_str = email_elem.subject\n input_str ||= email_elem.body_text\n meantItRel_hash = ControllerHelper.parse_meant_it_input(input_str)\n pii_value = meantItRel_hash[ControllerHelper::MEANT_IT_INPUT_RECEIVER_PII]\n hk_pii = Pii.find_by_pii_value(pii_value)\n assert_equal(false, ControllerHelper.sellable_pii(hk_pii), \"newly created pii is not sellable since no pii_property_set\")\n # Now create pii_propery_set and fill in the \n # necessary properties to make pii sellable\n hk_pii.pii_property_set = PiiPropertySet.create\n hk_pii.pii_property_set.currency = nil\n # NOTE: We submit inbound_emails(:nick_n_xxx_y_yyy_n_tags_y_currency_sender_idable_inbound_email_buy) \n # twice with the second time we increase by 1 unit currency\n # so we adjust threshold to the sum so that \n # threshold is exceeded after the 2nd buy\n email_elem = inbound_emails(:nick_n_xxx_y_yyy_n_tags_y_currency_sender_idable_inbound_email_buy)\n input_str = email_elem.subject\n input_str ||= email_elem.body_text\n threshold = ControllerHelper.sum_currency_in_str(input_str)\n threshold_curr_code, threshold_curr_val = ControllerHelper.get_currency_code_and_val(threshold)\n one_unit_currency = \"#{threshold_curr_code}1\"\n threshold = ControllerHelper.sum_currency_in_str(\"#{threshold} #{threshold} #{one_unit_currency}\")\n threshold_curr_code, threshold_curr_val = ControllerHelper.get_currency_code_and_val(threshold)\n hk_pii.pii_property_set.threshold = 2\n hk_pii.pii_property_set.currency = nil\n hk_pii.pii_property_set.status = StatusTypeValidator::STATUS_ACTIVE\n hk_pii.pii_property_set.value_type = value_type\n hk_pii.pii_property_set.threshold_type = threshold_type\n hk_pii.pii_property_set.save\n assert_equal(true, ControllerHelper.sellable_pii(hk_pii), \"pii with appropriate fields filled in is sellable\")\n # Create a new mir by sending another mail\n assert_differences([\n ['InboundEmailLog.count', 0],\n ['InboundEmail.count', 1],\n ['EndPoint.count', 2], # for new sender and the nick for destination\n ['Pii.count', 1], # for new sender\n ['Tag.count', 1], # New tag, i.e., each price is a new tag\n ['EndPointTagRel.count', 1], # New tag to endpoint\n ['MeantItRel.count', 1],\n ['MeantItMoodTagRel.count', 1], # We create a link from MeantItRel to Tag\n ['EmailBillEntry.count', 1]\n ]) do\n # Set the path so that the \"from:\" email is used\n # otherwise sender is anonymous\n @request.path = Constants::SENDGRID_PARSE_URL\n post :create, :inbound_email => email_elem.attributes\n end # end assert_differences\n hk_pii.reload\n # Check the value of email_bill_entry.qty\n hk_pii_email_bill_entries = hk_pii.pii_property_set.email_bill_entries\n assert_equal(1, hk_pii_email_bill_entries.size)\n assert_equal(1, hk_pii_email_bill_entries[0].meant_it_rels.size)\n input_str = email_elem.subject\n input_str ||= email_elem.body_text\n first_email_curr_str = ControllerHelper.sum_currency_in_str(input_str) #AAAAA\n first_email_curr_code, first_email_curr_val = ControllerHelper.get_currency_code_and_val(first_email_curr_str) #AAAAA\n # Assert that we have now one entry\n assert_equal(hk_pii_email_bill_entries.size, hk_pii_email_bill_entries[0].qty)\n assert_equal(nil, hk_pii_email_bill_entries[0].currency)\n # Check threshold\n assert(hk_pii_email_bill_entries[0].qty < hk_pii_email_bill_entries[0].pii_property_set.threshold)\n assert_nil(hk_pii_email_bill_entries[0].ready_date)\n # If a same email is resubmitted, but with different value!\n body_text = email_elem.body_text\n # Get pii and currency\n email_body_hash = ControllerHelper.parse_meant_it_input(body_text)\n pii_str = email_body_hash[ControllerHelper::MEANT_IT_INPUT_RECEIVER_PII]\n curr_arr = ControllerHelper.get_currency_arr_from_str(body_text)\n # Just take one value\n prev_curr_curr_code, prev_curr_curr_val = ControllerHelper.get_currency_code_and_val(curr_arr[0])\n second_email_curr_code = prev_curr_curr_code\n second_email_curr_val = prev_curr_curr_val.to_f + 1.0\n second_email_curr_str = \"#{second_email_curr_code}#{second_email_curr_val}\"\n email_elem.body_text = \":#{pii_str} #{second_email_curr_str}\"\n p \"new email_elem.body_text:#{email_elem.body_text}\"\n assert_differences([\n ['InboundEmailLog.count', 0],\n ['InboundEmail.count', 1],\n ['EndPoint.count', 0], # no new sender and the nick for destination\n ['Pii.count', 0], # no new sender\n ['Tag.count', 1], # One more tag, i.e., the new curr value\n ['EndPointTagRel.count', 1], # One more tag => one more EndPointTagRel\n ['MeantItRel.count', 1],\n ['MeantItMoodTagRel.count', 1], # We create a link from MeantItRel to Tag\n ['EmailBillEntry.count', 0] # No new bill\n ]) do\n # Set the path so that the \"from:\" email is used\n # otherwise sender is anonymous\n @request.path = Constants::SENDGRID_PARSE_URL\n post :create, :inbound_email => email_elem.attributes\n end # end assert_differences\n hk_pii.reload\n hk_pii_email_bill_entries = hk_pii.pii_property_set.email_bill_entries\n assert_equal(1, hk_pii_email_bill_entries.size)\n if value_type == ValueTypeValidator::VALUE_TYPE_COUNT\n # Add one entry even tho' the sender is same \n # since value_type is VALUE_TYPE_VALUE\n assert_equal(2, hk_pii_email_bill_entries[0].meant_it_rels.size)\n src_ep_hash = ControllerHelper.parse_email(email_elem.from)\n src_ep_1 = src_ep_hash[ControllerHelper::EMAIL_STR]\n # The qty should be sum of 1st+2nd email if VALUE_TYPE_VALUE,\n sum_thus_far_curr_val = first_email_curr_val + second_email_curr_val\n else\n # No entry is added\n # since value_type is VALUE_TYPE_VALUE_UNIQ\n assert_equal(1, hk_pii_email_bill_entries[0].meant_it_rels.size)\n # Send another email\n email_addy_hash = ControllerHelper.parse_email(email_elem.from)\n email_addy = email_addy_hash[ControllerHelper::EMAIL_STR]\n email_elem.from = \"#{new_email_prefix}#{email_addy}\"\n src_ep_1 = email_elem.from\np \"!!!!!!!!!!!!!email_elem.attributes.inspect:#{email_elem.attributes.inspect}\"\n assert_differences([\n ['InboundEmailLog.count', 0],\n ['InboundEmail.count', 1],\n ['EndPoint.count', 2], # new sender and the nick for destination\n ['Pii.count', 1], # no new sender\n ['Tag.count', 0], # Zero new tag, since we're using same currency tag\n ['EndPointTagRel.count', 1], # One more tag => one more EndPointTagRel\n ['MeantItRel.count', 1],\n ['MeantItMoodTagRel.count', 1], # We create a link from MeantItRel to Tag\n ['EmailBillEntry.count', 0] # No new bill\n ]) do\n # Set the path so that the \"from:\" email is used\n # otherwise sender is anonymous\n @request.path = Constants::SENDGRID_PARSE_URL\n post :create, :inbound_email => email_elem.attributes\n end # end assert_differences\n hk_pii.reload\n hk_pii_email_bill_entries = hk_pii.pii_property_set.email_bill_entries\n # The qty should be sum of 2nd+3rd if VALUE_TYPE_VALUE_UNIQ\n # NOTE: 3rd email is just 2nd email with from changed\n sum_thus_far_curr_val = second_email_curr_val + second_email_curr_val\n end # end elsif value_type == ValueTypeValidator::VALUE_TYPE_VALUE_UNIQ\n hk_pii_mirs_id_desc = hk_pii_email_bill_entries[0].meant_it_rels.order(\"id desc\")\n mir_src_pii = hk_pii_mirs_id_desc[0].src_endpoint.pii\n assert_equal(src_ep_1, mir_src_pii.pii_value)\n assert_equal(2, hk_pii_email_bill_entries[0].qty)\n # Increase in the number of mirs\n assert_equal(2, hk_pii_email_bill_entries[0].meant_it_rels.size)\n assert_equal(nil, hk_pii_email_bill_entries[0].currency)\n # Check threshold\np \"!!!!!!sum_thus_far_curr_val:#{sum_thus_far_curr_val}\"\np \"!!!!!!hk_pii_email_bill_entries[0].pii_property_set.threshold:#{hk_pii_email_bill_entries[0].pii_property_set.threshold}\"\n assert_equal(hk_pii_email_bill_entries[0].pii_property_set.threshold, hk_pii_email_bill_entries[0].qty)\n assert_not_nil(hk_pii_email_bill_entries[0].ready_date)\n # Check price_final, threshold_final\n if (value_type == ValueTypeValidator::VALUE_TYPE_VALUE or value_type == ValueTypeValidator::VALUE_TYPE_COUNT_UNIQ)\n # For VALUE_TYPE_VALUE_xxx, there is no price_final\n assert_nil(hk_pii_email_bill_entries[0].price_final)\n else\n assert_equal(ControllerHelper.get_price_from_formula(hk_pii.pii_property_set.formula), hk_pii_email_bill_entries[0].price_final)\n end # end if (value_type == ValueTypeValidator::VALUE_TYPE_VALUE or value_type == ValueTypeValidator::VALUE_TYPE_UNIQ)\n assert_equal(hk_pii.pii_property_set.threshold, hk_pii_email_bill_entries[0].threshold_final)\n assert_equal(hk_pii.pii_property_set.currency, hk_pii_email_bill_entries[0].currency)\n if threshold_type == PiiPropertySetThresholdTypeValidator::THRESHOLD_TYPE_ONETIME\n # If threshold_type is onetime then pii becomes inactive\n assert_equal(StatusTypeValidator::STATUS_INACTIVE, hk_pii.pii_property_set.status)\n new_bill_ready_date = hk_pii.pii_property_set.email_bill_entries[0].ready_date\n assert_not_nil(new_bill_ready_date)\n # NOTE: For ONETIME, the active_date is <= ready_date since\n # active_date is set only when the pii is created when active state\n # is re-set\n new_active_date = ControllerHelper.get_bill_dates_by_pii(hk_pii)\n assert_not_nil(new_active_date)\n assert(new_bill_ready_date >= new_active_date)\n assert_in_delta(new_bill_ready_date, new_active_date, 2)\n else\n # If threshold_type is recur then check billing\n # Since this is recur, status should remain active\n assert_equal(StatusTypeValidator::STATUS_ACTIVE, hk_pii.pii_property_set.status)\n new_bill_ready_date = hk_pii.pii_property_set.email_bill_entries[0].ready_date\n assert_not_nil(new_bill_ready_date)\n new_start_bill_date = ControllerHelper.get_bill_dates_by_pii(hk_pii)\n # NOTE: For now new bill dates are created only when billed_date is\n # set, i.e., user contacts their customers through emails\n assert(new_bill_ready_date >= new_start_bill_date)\n assert_in_delta(new_bill_ready_date, new_start_bill_date, 2)\n end # end if threshold_type == PiiPropertySetThresholdTypeValidator::THRESHOLD_TYPE_ONETIME\n end", "def set_threshold\n @threshold = Threshold.find(params[:id])\n end", "def update!(**args)\n @threshold = args[:threshold] if args.key?(:threshold)\n @value = args[:value] if args.key?(:value)\n end", "def track_line_number(line_number)\n @min_line_number = line_number if line_number < min_line_number\n @max_line_number = line_number if line_number > max_line_number\n self\n end", "def threshold\n @threshold ||= Reputation::Threshold.lookup(self.action, self.sender, :tier => self.tier)\n end", "def skip(amount = 1)\n @read_index += amount\n end", "def update_line_numbers!\n each_with_index do |lo, new_line_number|\n lo.line_number = new_line_number\n end\n end", "def lines_to_target\n return if external_target?\n return if target_line_number.nil? || callback_line_number.nil?\n\n (target_line_number - callback_line_number).abs\n end", "def find_lines(options = {})\n default_options = { theta_res: Math::PI / 180, rho_res: 1.0, threshold: 80 }\n options = default_options.merge(options)\n\n @accumulator = Accumulator.new(image, options[:theta_res], options[:rho_res])\n\n image.non_zero_pixels.each do |pixel|\n @accumulator.theta_values.each do |theta|\n rho = pixel[:x] * theta[:cos] + pixel[:y] * theta[:sin]\n @accumulator.write(theta, rho)\n end\n end\n\n @accumulator.intersections(@accumulator.max_value * options[:threshold] / 100.0)\n end", "def threshold_reached_value_type_value_xxx(value_type, threshold_type)\n # Used to prefix sender email to change it\n new_email_prefix = \"new_\"\n # This is ripped from email_bill_entry value_type_value\n sum_thus_far_curr_val = 0\n sum_thus_far_curr_code = nil\n sum_thus_far_str = nil\n email_elem = inbound_emails(:nick_n_xxx_y_yyy_n_tags_y_currency_sender_idable_inbound_email)\n # Set the path so that the \"from:\" email is used\n # otherwise sender is anonymous\n @request.path = Constants::SENDGRID_PARSE_URL\n post :create, :inbound_email => email_elem.attributes\n # Get the new pii\n input_str = email_elem.subject\n input_str ||= email_elem.body_text\n meantItRel_hash = ControllerHelper.parse_meant_it_input(input_str)\n pii_value = meantItRel_hash[ControllerHelper::MEANT_IT_INPUT_RECEIVER_PII]\n hk_pii = Pii.find_by_pii_value(pii_value)\n assert_equal(false, ControllerHelper.sellable_pii(hk_pii), \"newly created pii is not sellable since no pii_property_set\")\n # Now create pii_propery_set and fill in the \n # necessary properties to make pii sellable\n hk_pii.pii_property_set = PiiPropertySet.create\n hk_pii.pii_property_set.currency = \"SGD\"\n # NOTE: We submit inbound_emails(:nick_n_xxx_y_yyy_n_tags_y_currency_sender_idable_inbound_email_buy) \n # twice with the second time we increase by 1 unit currency\n # so we adjust threshold to the sum so that \n # threshold is exceeded after the 2nd buy\n email_elem = inbound_emails(:nick_n_xxx_y_yyy_n_tags_y_currency_sender_idable_inbound_email_buy)\n input_str = email_elem.subject\n input_str ||= email_elem.body_text\n threshold = ControllerHelper.sum_currency_in_str(input_str)\n threshold_curr_code, threshold_curr_val = ControllerHelper.get_currency_code_and_val(threshold)\n one_unit_currency = \"#{threshold_curr_code}1\"\n threshold = ControllerHelper.sum_currency_in_str(\"#{threshold} #{threshold} #{one_unit_currency}\")\n threshold_curr_code, threshold_curr_val = ControllerHelper.get_currency_code_and_val(threshold)\n hk_pii.pii_property_set.threshold = threshold_curr_val\n hk_pii.pii_property_set.currency = threshold_curr_code\n hk_pii.pii_property_set.status = StatusTypeValidator::STATUS_ACTIVE\n hk_pii.pii_property_set.value_type = value_type\n hk_pii.pii_property_set.threshold_type = threshold_type\n hk_pii.pii_property_set.save\n assert_equal(true, ControllerHelper.sellable_pii(hk_pii), \"pii with appropriate fields filled in is sellable\")\n # Create a new mir by sending another mail\n assert_differences([\n ['InboundEmailLog.count', 0],\n ['InboundEmail.count', 1],\n ['EndPoint.count', 2], # for new sender and the nick for destination\n ['Pii.count', 1], # for new sender\n ['Tag.count', 1], # New tag, i.e., each price is a new tag\n ['EndPointTagRel.count', 1], # New tag to endpoint\n ['MeantItRel.count', 1],\n ['MeantItMoodTagRel.count', 1], # We create a link from MeantItRel to Tag\n ['EmailBillEntry.count', 1]\n ]) do\n # Set the path so that the \"from:\" email is used\n # otherwise sender is anonymous\n @request.path = Constants::SENDGRID_PARSE_URL\n post :create, :inbound_email => email_elem.attributes\n end # end assert_differences\n hk_pii.reload\n # Check the value of email_bill_entry.qty\n hk_pii_email_bill_entries = hk_pii.pii_property_set.email_bill_entries\n assert_equal(1, hk_pii_email_bill_entries.size)\n assert_equal(1, hk_pii_email_bill_entries[0].meant_it_rels.size)\n input_str = email_elem.subject\n input_str ||= email_elem.body_text\n#AAAAA sum_thus_far_str = ControllerHelper.sum_currency_in_str(input_str)\n first_email_curr_str = ControllerHelper.sum_currency_in_str(input_str)\n#AAAAA sum_thus_far_curr_code, sum_thus_far_curr_val = ControllerHelper.get_currency_code_and_val(sum_thus_far_str)\n first_email_curr_code, first_email_curr_val = ControllerHelper.get_currency_code_and_val(first_email_curr_str)\n#AAAAA assert_equal(sum_thus_far_curr_val.to_f, hk_pii_email_bill_entries[0].qty)\n assert_equal(first_email_curr_val.to_f, hk_pii_email_bill_entries[0].qty)\n#AAAAA assert_equal(sum_thus_far_curr_code, hk_pii_email_bill_entries[0].currency)\n assert_equal(first_email_curr_code, hk_pii_email_bill_entries[0].currency)\n # Check threshold\n#AAAAA assert(sum_thus_far_curr_val.to_f < hk_pii_email_bill_entries[0].pii_property_set.threshold)\n assert(first_email_curr_val.to_f < hk_pii_email_bill_entries[0].pii_property_set.threshold)\n assert_nil(hk_pii_email_bill_entries[0].ready_date)\n # If a same email is resubmitted, but with different value!\n body_text = email_elem.body_text\n # Get pii and currency\n email_body_hash = ControllerHelper.parse_meant_it_input(body_text)\n pii_str = email_body_hash[ControllerHelper::MEANT_IT_INPUT_RECEIVER_PII]\n curr_arr = ControllerHelper.get_currency_arr_from_str(body_text)\n # Just take one value\n#AAAAA new_curr_curr_code, new_curr_curr_val = ControllerHelper.get_currency_code_and_val(curr_arr[0])\n prev_curr_curr_code, prev_curr_curr_val = ControllerHelper.get_currency_code_and_val(curr_arr[0])\n second_email_curr_code = prev_curr_curr_code\n#AAAAA new_curr_f = new_curr_curr_val.to_f + 1.0\n second_email_curr_val = prev_curr_curr_val.to_f + 1.0\n#AAAAA new_curr_str = \"#{new_curr_curr_code}#{new_curr_f}\"\n second_email_curr_str = \"#{second_email_curr_code}#{second_email_curr_val}\"\n#AAAAA email_elem.body_text = \":#{pii_str} #{new_curr_str}\"\n email_elem.body_text = \":#{pii_str} #{second_email_curr_str}\"\n p \"new email_elem.body_text:#{email_elem.body_text}\"\n assert_differences([\n ['InboundEmailLog.count', 0],\n ['InboundEmail.count', 1],\n ['EndPoint.count', 0], # no new sender and the nick for destination\n ['Pii.count', 0], # no new sender\n ['Tag.count', 1], # One more tag, i.e., the new curr value\n ['EndPointTagRel.count', 1], # One more tag => one more EndPointTagRel\n ['MeantItRel.count', 1],\n ['MeantItMoodTagRel.count', 1], # We create a link from MeantItRel to Tag\n ['EmailBillEntry.count', 0] # No new bill\n ]) do\n # Set the path so that the \"from:\" email is used\n # otherwise sender is anonymous\n @request.path = Constants::SENDGRID_PARSE_URL\n post :create, :inbound_email => email_elem.attributes\n end # end assert_differences\n hk_pii.reload\n hk_pii_email_bill_entries = hk_pii.pii_property_set.email_bill_entries\n assert_equal(1, hk_pii_email_bill_entries.size)\n if value_type == ValueTypeValidator::VALUE_TYPE_VALUE\n # Add one entry even tho' the sender is same \n # since value_type is VALUE_TYPE_VALUE\n assert_equal(2, hk_pii_email_bill_entries[0].meant_it_rels.size)\n src_ep_hash = ControllerHelper.parse_email(email_elem.from)\n src_ep_1 = src_ep_hash[ControllerHelper::EMAIL_STR]\n # The qty should be sum of 1st+2nd email if VALUE_TYPE_VALUE,\n sum_thus_far_curr_val = first_email_curr_val + second_email_curr_val\n else\n # No entry is added\n # since value_type is VALUE_TYPE_VALUE_UNIQ\n assert_equal(1, hk_pii_email_bill_entries[0].meant_it_rels.size)\n # Send another email\n email_addy_hash = ControllerHelper.parse_email(email_elem.from)\n email_addy = email_addy_hash[ControllerHelper::EMAIL_STR]\n email_elem.from = \"#{new_email_prefix}#{email_addy}\"\n src_ep_1 = email_elem.from\np \"!!!!!!!!!!!!!email_elem.attributes.inspect:#{email_elem.attributes.inspect}\"\n assert_differences([\n ['InboundEmailLog.count', 0],\n ['InboundEmail.count', 1],\n ['EndPoint.count', 2], # new sender and the nick for destination\n ['Pii.count', 1], # no new sender\n ['Tag.count', 0], # Zero new tag, since we're using same currency tag\n ['EndPointTagRel.count', 1], # One more tag => one more EndPointTagRel\n ['MeantItRel.count', 1],\n ['MeantItMoodTagRel.count', 1], # We create a link from MeantItRel to Tag\n ['EmailBillEntry.count', 0] # No new bill\n ]) do\n # Set the path so that the \"from:\" email is used\n # otherwise sender is anonymous\n @request.path = Constants::SENDGRID_PARSE_URL\n post :create, :inbound_email => email_elem.attributes\n end # end assert_differences\n hk_pii.reload\n hk_pii_email_bill_entries = hk_pii.pii_property_set.email_bill_entries\n # The qty should be sum of 2nd+3rd if VALUE_TYPE_VALUE_UNIQ\n # NOTE: 3rd email is just 2nd email with from changed\n sum_thus_far_curr_val = second_email_curr_val + second_email_curr_val\n end # end elsif value_type == ValueTypeValidator::VALUE_TYPE_VALUE_UNIQ\n hk_pii_mirs_id_desc = hk_pii_email_bill_entries[0].meant_it_rels.order(\"id desc\")\n#AAAAA mir_src_pii = hk_pii_email_bill_entries[0].meant_it_rels[0].src_endpoint.pii\n mir_src_pii = hk_pii_mirs_id_desc[0].src_endpoint.pii\n assert_equal(src_ep_1, mir_src_pii.pii_value)\n#AAAAA sum_thus_far_curr_val += new_curr_f\n assert_equal(sum_thus_far_curr_val, hk_pii_email_bill_entries[0].qty)\n # Increase in the number of mirs\n assert_equal(2, hk_pii_email_bill_entries[0].meant_it_rels.size)\n # The currency code of first email and second email value are the same\n#AAAAA assert_equal(sum_thus_far_curr_code, new_curr_curr_code)\n assert_equal(first_email_curr_code, second_email_curr_code)\n#AAAAA assert_equal(new_curr_curr_code, hk_pii_email_bill_entries[0].currency)\n assert_equal(second_email_curr_code, hk_pii_email_bill_entries[0].currency)\n # Check threshold\np \"!!!!!!sum_thus_far_curr_val:#{sum_thus_far_curr_val}\"\np \"!!!!!!hk_pii_email_bill_entries[0].pii_property_set.threshold:#{hk_pii_email_bill_entries[0].pii_property_set.threshold}\"\n assert(hk_pii_email_bill_entries[0].pii_property_set.threshold <= sum_thus_far_curr_val)\n assert_not_nil(hk_pii_email_bill_entries[0].ready_date)\n # Check price_final, threshold_final\n if (value_type == ValueTypeValidator::VALUE_TYPE_VALUE or value_type == ValueTypeValidator::VALUE_TYPE_VALUE_UNIQ)\n # For VALUE_TYPE_VALUE_xxx, there is no price_final\n assert_nil(hk_pii_email_bill_entries[0].price_final)\n else\n assert_equal(ControllerHelper.get_price_from_formula(hk_pii.pii_property_set.formula), hk_pii_email_bill_entries[0].price_final)\n end # end if (value_type == ValueTypeValidator::VALUE_TYPE_VALUE or value_type == ValueTypeValidator::VALUE_TYPE_UNIQ)\n assert_equal(hk_pii.pii_property_set.threshold, hk_pii_email_bill_entries[0].threshold_final)\n assert_equal(hk_pii.pii_property_set.currency, hk_pii_email_bill_entries[0].currency)\n if threshold_type == PiiPropertySetThresholdTypeValidator::THRESHOLD_TYPE_ONETIME\n # If threshold_type is onetime then pii becomes inactive\n assert_equal(StatusTypeValidator::STATUS_INACTIVE, hk_pii.pii_property_set.status)\n new_bill_ready_date = hk_pii.pii_property_set.email_bill_entries[0].ready_date\n assert_not_nil(new_bill_ready_date)\n # NOTE: For ONETIME, the active_date is <= ready_date since\n # active_date is set only when the pii is created when active state\n # is re-set\n new_active_date = ControllerHelper.get_bill_dates_by_pii(hk_pii)\n assert_not_nil(new_active_date)\n assert(new_bill_ready_date >= new_active_date)\n assert_in_delta(new_bill_ready_date, new_active_date, 2)\n else\n # If threshold_type is recur then check billing\n # Since this is recur, status should remain active\n assert_equal(StatusTypeValidator::STATUS_ACTIVE, hk_pii.pii_property_set.status)\n new_bill_ready_date = hk_pii.pii_property_set.email_bill_entries[0].ready_date\n assert_not_nil(new_bill_ready_date)\n new_start_bill_date = ControllerHelper.get_bill_dates_by_pii(hk_pii)\n # NOTE: For now new bill dates are created only when billed_date is\n # set, i.e., user contacts their customers through emails\n assert(new_bill_ready_date >= new_start_bill_date)\n assert_in_delta(new_bill_ready_date, new_start_bill_date, 2)\n end # end if threshold_type == PiiPropertySetThresholdTypeValidator::THRESHOLD_TYPE_ONETIME\n end", "def <<(logline)\n compute_timestamp(logline).tap do |ts|\n # First reduce the array size if possible, then add the new\n # entry and perform threshold checks.\n trim ts\n push_line ts, logline\n check_threshold\n end\n end", "def affected_lines_range\n (line_no..line_no + replaced_text.count(\"\\n\"))\n end", "def enable_threshold\n @enable_threshold = true\n end", "def threshold_alert(actual, threshold)\n\t\t\tif actual > threshold\n\t\t\t\tputs \"#{actual - threshold}% above threshold set @ #{threshold}%\".color(:red)\n\t\t\t\tputs \"pixels changed (%): \t\t#{@compare.percentage_changed}%\"\n\t\t\t\tputs \"pixels changed/total:\t#{@compare.changed_px}/#{@compare.total_px}\"\n\t\t\telse\n\t\t\t\tputs \"pixels changed/total:\t#{@compare.changed_px}/#{@compare.total_px}\"\n\t\t\tend\n\t\tend", "def calculate_level\n # Increase level for every 10 lines cleared\n @level = @start_level + (@lines_cleared / 10).floor\n end", "def lines_to_conditional_target\n return if conditional_target_symbol.nil? || external_conditional_target?\n\n (conditional_target_line_number - callback_line_number).abs\n end", "def threshold(x)\n\t\tx > 0 ? 1.0 : 0.0\n\tend", "def array_add(latest, original)\n if Coverband.configuration.use_oneshot_lines_coverage\n latest.map!.with_index { |v, i| (v + original[i] >= 1 ? 1 : 0) if v && original[i] }\n elsif Coverband.configuration.simulate_oneshot_lines_coverage\n latest.map.with_index { |v, i| (v + original[i] >= 1 ? 1 : 0) if v && original[i] }\n else\n latest.map.with_index { |v, i| v && original[i] ? v + original[i] : nil }\n end\n end", "def add_severity(severity, count)\n @count += count\n @severities[severity] = count\n end", "def add_severity(severity, count)\n @count += count\n @severities[severity] = count\n end", "def critical(options)\n raise \"critical lines need a value\" unless options[:value]\n\n @critical_threshold = [options[:value]].flatten\n\n options[:color] ||= \"red\"\n\n unless options[:hide]\n @critical_threshold.each_with_index do |crit, index|\n line :caption => \"crit_#{index}\", :value => crit, :color => options[:color], :dashed => true\n end\n end\n end", "def blur!(blur_distance)\r\n ones = get_ones\r\n\r\n @icon.each_with_index do |row, row_index|\r\n row.each_with_index do |item, col_index|\r\n ones.each do |found_row_index, found_col_index|\r\n if manhattan_distance(col_index, row_index, found_col_index, found_row_index) <= blur_distance\r\n @icon[row_index][col_index] = 1\r\n end\r\n end\r\n end\r\n end\r\n end", "def threshold=(threshold_severity)\n\n\t\traise TypeError, \"threshold_severity must be a #{::Symbol}\" unless ::Symbol === threshold_severity\n\n\t\t@threshold_v = @value_lookup_map[threshold_severity] if @relativity_lookup_map[threshold_severity] or raise ArgumentError, \"unknown threshold severity level '#{threshold_severity}' (#{threshold_severity.class})\"\n\t\t@threshold = threshold_severity\n\n\t\tnil\n\tend", "def around(line_num, lines=1)\n return self unless line_num\n\n select do |l, ln|\n ln >= line_num - lines && ln <= line_num + lines\n end\n end", "def calculate(threshold: 0.001, safety_net: false)\n dinv, b, l, u = @dinv, @b, @l, @u\n c = dinv * b\n t = -1 * dinv * (l + u)\n x_n = Matrix.column_vector(Array.new(@a.column_count, 0))\n counter = 0\n loop do \n x_n_plus_1 = c + t * x_n\n x_difference = (x_n_plus_1 - x_n).map{ |el| el.abs }\n # puts x_n_plus_1\n should_break = !x_difference.find{ |el| el > threshold }\n x_n = x_n_plus_1 \n break if should_break\n counter += 1\n if counter > 10000000 and safety_net \n return (@a.inv * b).map{ |el| el.to_f}\n end\n end \n return (safety_net and x_n.find{ |el| el.to_f.nan? }) ? (@a.inv * b).map{ |el| el.to_f} : x_n\n end", "def add_line_to_file(filename, new_value, line_number = nil)\n File.open(filename, 'r+') do |file|\n lines = file.each_line.to_a\n if line_number\n lines[line_number] = new_value + \"\\n\"\n else\n lines.push(new_value + \"\\n\")\n end\n file.rewind\n file.write(lines.join)\n file.close\n end\n end", "def add_total_discount(name, discount, threshold)\n total_discounts << TotalDiscount.new(name, discount, threshold)\n end", "def cover_line(segment)\n l = segment.l\n r = segment.r\n l = 0 if l < 0\n r -= 1\n r = @line.length-1 if r > @line.length-1\n\n for i in l..r\n @line[i] = true\n end\n end", "def take_lines(start_line, num_lines)\n if start_line >= 0\n start_idx = @lines.index { |l| l.last >= start_line } || @lines.length\n else\n start_idx = @lines.length + start_line\n end\n\n alter do\n @lines = @lines.slice(start_idx, num_lines)\n end\n end", "def set_notification_threshold(th,th_plus=th,i=0,asd=Hash.new,percent=th*0.25)\n asd[i] = {min: th_plus-percent,max: (th_plus+th)-percent}\n i == 3 ? (return asd) : (set_notification_threshold(th,th_plus*=2,i+=1,asd))\n end", "def change_thresholds *thresholds\n unless thresholds.first.is_a? Hash\n return change_thresholds LEVELS[0, thresholds.size].zip(thresholds).to_h\n end\n thresholds.first.each do |k, new_threshold|\n next unless (badge = @badge[k])\n @badge.delete badge.threshold\n badge.threshold = new_threshold\n @badge[new_threshold] = badge\n end\n end", "def xxx_find_templates_on_img_with_dynamic_threshold(template_path, image_path, output_path = '')\n logc(\"method: #{__method__}, params: '#{template_path}', #{image_path}, #{output_path}\")\n\n ts = Time.now\n\n calculated_threshold = nil\n current_density = nil\n\n min_threshold = 0.6\n max_threshold = 0.8\n threshold_with_no_results = max_threshold\n threshold_step = 0.02\n accepted_density = 80.0\n\n\n res = find_templates_on_img(template_path, image_path, output_path)\n\n # case of 'not found'\n # decrease threshold to ensure that image does not contains templates or find templates\n if res[\"found\"] == 0\n logc(\"Enter to cycle of decreasing threshold to ensure that image does not contains templates or find templates\")\n while true\n logc(\"Cycle of decreasing threshold\")\n\n threshold_with_no_results = res[\"threshold\"]\n previous_threshold = res[\"threshold\"]\n next_threshold = previous_threshold - threshold_step\n\n logc(\"Can't find templates on the screen with threshold '#{threshold_with_no_results}'.\" +\n \" Decreasing threshold to '#{next_threshold}'\")\n\n if next_threshold <= min_threshold\n calculated_threshold = previous_threshold\n logc(\"Next threshold value '#{next_threshold}' smaller or equal than min threshold '#{min_threshold}'.\" +\n \" End calculation with threshold value '#{calculated_threshold}'.\")\n break\n end\n\n res = find_templates_on_img(template_path, image_path, nil, next_threshold)\n if res[\"found\"] != 0\n logc(\"Found '#{res[\"found\"]}' templates on the screen with threshold '#{next_threshold}'\" +\n \" Exit from 'decreasing threshold' cycle to function to find accepted level of density\")\n break\n end\n end\n end\n\n # case of 'found' or 'calculated_threshold' is still 'nil'\n # increase threshold to reach 'accepted_density' or 'max_threshold' or 'threshold_with_no_results'\n if calculated_threshold.nil? && !res[\"point_clouds\"].to_s.empty?\n logc(\"Enter to cycle of increasing threshold to\" +\n \" reach 'accepted_density' or 'max_threshold' or 'threshold_with_no_results'\")\n while true\n logc(\"Cycle of increasing threshold\")\n\n previous_threshold = res[\"threshold\"]\n current_density = res[\"found\"].to_f / res[\"point_clouds\"].to_f\n next_threshold = previous_threshold + threshold_step\n\n logc(\"Found '#{res[\"point_clouds\"]}' point clouds.\" +\n \" Increasing threshold to '#{next_threshold}'\")\n\n if current_density <= accepted_density\n calculated_threshold = previous_threshold\n logc(\"Accepted density '#{accepted_density}' reached with value '#{current_density}'.\" +\n \" End calculation with threshold value '#{calculated_threshold}'.\")\n break\n end\n\n if next_threshold >= threshold_with_no_results\n calculated_threshold = previous_threshold\n logc(\"Next threshold value '#{next_threshold}' greater or equal\" +\n \" than threshold with no results '#{threshold_with_no_results}'.\" +\n \" End calculation with threshold value '#{calculated_threshold}'.\")\n break\n end\n\n if next_threshold >= max_threshold\n calculated_threshold = previous_threshold\n logc(\"Next threshold value '#{next_threshold}' greater or equal than max threshold '#{max_threshold}'.\" +\n \" End calculation with threshold value '#{calculated_threshold}'.\")\n break\n end\n\n res = find_templates_on_img(template_path, image_path, nil, next_threshold)\n\n if res[\"point_clouds\"].to_s.empty?\n calculated_threshold = previous_threshold\n\n logc(\"Next threshold value '#{next_threshold}' cause 'not found' result.\" +\n \"Exit from 'increasing threshold' cycle with threshold value '#{calculated_threshold}'.\")\n break\n end\n end\n end\n\n assert_false_custom(calculated_threshold.nil?,\n \"Function logic fail. After set of conditions threshold value must be found.\")\n\n\n logc(\"Threshold for template '#{File.basename(template_path)}' calculated.\" +\n \"\\n Accepted threshold value: '#{calculated_threshold}'.\" +\n \"\\n Calculated density: '#{current_density}'.\" +\n \"\\n Time spent for threshold calculating: #{(Time.now - ts)}s\" +\n \"\\n In the end - Finding template with calculated threshold to return it\")\n\n if !res.nil? && (res[\"threshold\"] == calculated_threshold)\n # result with calculated threshold is already exist and saved in res variable\n logc(\"Template with calculated threshold is already found and saved in 'res' variable. Return it\")\n else\n # get result with calculated threshold\n res = find_templates_on_img(template_path, image_path, output_path, calculated_threshold)\n end\n\n return res\nend", "def add_blur_to_image\n r = 0\n c = 0\n rc = 0\n n = 1\n z = []\n u = @y.size.to_i\n while n <= u\n @ary.each_index do |r|\n @ary[r].each_index do |c|\n if ((c.to_i - y[rc][1].to_i).abs + (r.to_i - y[rc][0].to_i).abs).between?(1, @distance.to_i);\n z << [r.to_i, c.to_i]\n end\n end\n end\n r = 0\n c = 0\n rc += 1\n n += 1\n end\n zz=[]\n r1 = 0\n c1 = 0\n z.each do |r|\n r1 = r[0].to_i\n c1 = r[1].to_i\n @ary[r1][c1] = 1\n end\n end", "def heal(_amount)\n\t\t@current_hp += _amount\n\t\t@current_hp = @hit_points if @current_hp > @hit_points\n\tend", "def remove_visibilities_below_threshold\n Visibility.\n active.\n where(created_by: nil, person_id: people_ids_under_threshold).\n each do |visibility|\n visibility.update!(\n removed_by: nil,\n removal_notes: crossed_threshold_message,\n removed_at: Time.current,\n )\n end\n end", "def line_numbers=(line_numbers)\n filter_run_including :line_numbers => line_numbers.map{|l| l.to_i}\n end", "def add_trivia(amount)\n if amount < 10\n @credits = @credits + amount * 2\n else\n @credits = @credits + 20\n end\n end", "def <=>(line)\n if self.slope > line.slope\n 1\n elsif self.slope < line.slope\n -1\n else\n if self.intercept > line.intercept\n 1\n elsif self.intercept < line.intercept\n -1\n else\n 0\n end\n end\n end", "def increase_consumed_lines_to(value)\n while @consumed_lines < value\n STDOUT.print \"\\n\"\n @consumed_lines += 1\n end\n end", "def feature_adjustment\n total = 0\n self.contract_features.each do |f|\n if f.feature.amount\n total += f.feature.amount\n end\n end\n return total\n end", "def my_array_modification_method(source, thing_to_modify)\n source.each_with_index do |element, i|\n source[i] += thing_to_modify if element.is_a?(Numeric)\n end\n source\n end", "def defender_goal_reached(threshold = 5)\n dist = calc_dist(@tank, @goal)\n #puts \"#{@tank.index} Distance to goal = #{dist}\"\n return dist < threshold\n end", "def inversion(amount)\n fail ArgumentError, 'Inversion amount must be greater than or equal to 1' if amount < 1\n fail ArgumentError, 'Not enough notes in chord for inversion' if amount >= @notes.size\n\n note_array = @notes.to_a.sort\n notes = (0...amount).collect { note_array.shift.adjust_by_semitones(12) }\n Chord.new(notes + note_array)\n end", "def after(line_num, lines=1)\n return self unless line_num\n\n select do |l, ln|\n ln > line_num && ln <= line_num + lines\n end\n end", "def scan_data_for_increase\n flag_collection = []\n dataset = get_firebase_data\n dataset.each_with_index do |datapoint, index|\n if (datapoint[1]['humidity'].to_f - dataset[index-1][1]['humidity'].to_f) > 3\n flag_collection << index\n end\n end\n flag_collection\n end", "def check_threshold\n rate = lines.length.to_f / expiry\n if rate > threshold\n alert_status\n elsif rate < threshold\n normal_status\n end\n end", "def take_lines(start_line, num_lines)\n start_idx =\n if start_line >= 0\n @lines.index { |loc| loc.lineno >= start_line } || @lines.length\n else\n [@lines.length + start_line, 0].max\n end\n\n alter do\n @lines = @lines.slice(start_idx, num_lines)\n end\n end", "def shard_block(threshold, &block)\n yield block if block_given? && in_shard?(threshold)\n end", "def make_change_for_amount(amount, check = false)\n remaining_returns = amount\n\n change = []\n\n @coins.each do |coin, count|\n num_coins = count\n\n while num_coins > 0 && ((remaining_returns - @@coin_value_by_details[coin]) >= 0)\n # remove amount we need less\n remaining_returns -= @@coin_value_by_details[coin]\n change << @@coin_value_by_details[coin]\n\n num_coins -= 1\n end\n\n @coins[coin] = num_coins unless check\n\n break if remaining_returns == 0\n end\n\n change\n end", "def test_it_can_find_golden_items_from_threshold\n threshold = 605_1\n assert_equal 5, @sa.find_golden_items(@se.items.all, threshold).count\n end", "def below_threshold?\n coverage < threshold\n end", "def insert_text_at_line_number(source, target_file, line_number)\n if line_number > 0\n line_number -= 1\n file = IO.readlines(target_file)\n file.insert((line_number), check_source_type(source))\n File.open(target_file, \"w\") do |x|\n x.puts file\n end\n else\n raise ArgumentError, \"Line number must be 1 or higher.\".red\n end\n end", "def collect( amount, resource = :deuterium )\n\t\tbefore_amount = amount_of( resource )\n\t\t@resources[ resource ][ :value ] = [ amount_of( resource ) + amount, capacity( resource ) ].min\n\t\treturn amount_of( resource ) - before_amount\n\tend", "def my_array_modification_method(source, thing_to_find)\n source.each_with_index {|elem, index|\n if elem.is_a?(Integer)\n source[index] = (elem + thing_to_find)\n end\n }\nend", "def add_water(amount)\n end", "def add_water(amount)\n end", "def add_segment(position, segment)\n @min_count += 1\n @min_solution[position] = true\n cover_line(segment)\n end", "def set_verification_threshhold(lvl = 1)\n @@verification_threshhold = lvl\n end", "def increment_positions_between(low, high)\n acts_as_list_class.update_all(\n \"#{position_column} = (#{position_column} + 1)\", [\"#{scope_condition} AND #{position_column} >= ? AND #{position_column} <= ?\", low, high]\n )\n end", "def adjust!(adjustment)\n updated_quantities = {}\n item_validator = Errors::InsufficientAllotment.new(\"Adjustment exceeds the available inventory\")\n\n adjustment.line_items.each do |line_item|\n\n inventory_item = self.inventory_items.find_by(item: line_item.item)\n next if inventory_item.nil? || inventory_item.quantity == 0\n\n if ((inventory_item.quantity + line_item.quantity) >= 0)\n updated_quantities[inventory_item.id] = (updated_quantities[inventory_item.id] || inventory_item.quantity) + line_item.quantity\n else\n item_validator.add_insufficiency(line_item.item, inventory_item.quantity, line_item.quantity)\n end\n\n end\n\n raise item_validator unless item_validator.satisfied?\n\n update_inventory_inventory_items(updated_quantities)\n end", "def distance_to_line(line)\n end", "def paths_above_threshold\n path_complexity_change.select do |_, (complexity_increase)|\n complexity_increase >= @change_threshold\n end\n end", "def add(num)\n i = @array.bsearch_index { |ele| ele >= num } || @array.size\n @array.insert(i, num)\n end", "def add_amount(amount)\n @balance += amount\n end", "def create_adjustment(order,line_item)\n amount = self.compute_amount(line_item)\n return false if amount == 0\n self.adjustments.create!(\n amount: amount,\n adjustable: line_item,\n order: order,\n label: \"#{Spree.t(:ink_deal)} - #{ink_button.variant.ink_name}\",\n )\n true\n end", "def line_numbering(value)\n @document_builder.line_numbering = value\n end", "def on_position_change(threshold = 0, &block)\n\t\t\t@position_change_threshold = threshold\n\t\t\t@on_position_change = block\n\t\tend", "def shift_output_lines(delta)\n return if delta == 0\n @data.each do |m|\n m.output.start_pos.line += delta\n m.output.end_pos.line += delta\n end\n end", "def test_get_line_number_03\n old_positions = OriginalFile.get_line_number(1)\n old_array_line_number=[1, 2, 3, 4, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52]\n assert_equal old_array_line_number,old_positions.values_at(0..50)\n\n new_positions = OriginalFile.get_line_number(2)\n new_array_line_number=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51]\n assert_equal new_array_line_number,new_positions.values_at(0..50)\n end", "def withdraw_using_check(amount)\n @limit = -10\n\n if @checks < 3\n @fee = 0\n withdraw(amount)\n else\n @fee = 2\n withdraw(amount)\n end\n\n @checks += 1\n\n #Resets fee & limit to initialized values\n @fee = 1\n @limit = 0\n return balance\n end", "def seek(amount, whence=SEEK_SET)\n #This is a stub, used for indexing\n end", "def blur!(distance = 1) #needs the !, is a bang, syntax is telling that is going to change the state of what we are operating on.\r\n distance.times do #looping for distance\r\n\r\n blur_pixels = coords # accessing array from previous method\r\n @array.each_with_index do |row, row_int|\r\n row.each_with_index do |int, col_index|\r\n blur_pixels.each do |row_int_coord, col_index_coord|\r\n\r\n if row_int == row_int_coord && col_index == col_index_coord\r\n # left of 1\r\n @array[row_int][col_index -1] = 1 unless col_index == 0\r\n # right of 1\r\n @array[row_int][col_index +1] = 1 unless col_index >= @col_length-1\r\n # above 1\r\n @array[row_int -1][col_index] = 1 unless row_int == 0\r\n # below 1\r\n @array[row_int +1][col_index] = 1 unless row_int >= @row_length-1\r\n end\r\n end\r\n end\r\n end\r\n end\r\n end", "def affected(text)\n occurrences = lines.each_index.select do |i|\n lines[i].start_with?(\"+\") && text.any? { |t| lines[i].include? t }\n end\n occurrences.map do |occ|\n lines[2..occ].reverse.find { |l| l.start_with? \"Index: \" }[7..]\n end\n end", "def add_value value\n @mutex.synchronize do\n index = @items += 1\n\n delta = value - @mean\n @mean += delta / index\n @M_2 += delta * (value - @mean)\n\n index\n end\n end", "def depositProfit(deposit, rate, threshold)\n count = 0\n profit = deposit\n \n while profit < threshold do\n count += 1\n profit += ((profit*rate)/100).to_f\n end\n \n if rate == 1\n threshold - deposit\n else\n count\n end\nend", "def store_excess(frame, amount)\n amount = @input_capacity if amount > @input_capacity\n converted = amount * @input_efficiency[frame]\n\n added = @reserve.add(frame, converted)\n @input_curve[frame] += added\n\n added / @input_efficiency[frame]\n end", "def change(amount, arr)\n changes = [[]] + Array.new(amount, Array.new(amount))\n\n 1.upto(amount) do |i|\n arr.each do |coin|\n next if coin > i\n\n changes[i] = changes[i - coin] + [coin] if changes[i].size > (changes[i - coin] + [coin]).size\n end\n end\n\n changes[amount]\nend", "def my_array_modification_method(source, thing_to_modify)\n source.each_with_index do |value, index|\n if value.is_a? Integer\n source[index] += thing_to_modify\n end\n end\nend", "def split_number_in_sets_one_below_500_and_ones_above(array)\n\tarray.partition{|x| x < 500}\nend", "def next_lines(lines, number)\n lines.slice!(0, number)\n end", "def increment(who, amount = 1)\n stat(key(who)).record_data_point(amount)\n end", "def adjust!\n raise \"Adjustment is already created\" if adjustment\n\n amount = compute_amount(inventory_unit.line_item)\n\n self.adjustment = inventory_unit.line_item.adjustments.create!(\n source: self,\n amount: amount,\n order: inventory_unit.order,\n label: \"#{I18n.t('spree.cancellation')} - #{reason}\",\n eligible: true,\n finalized: true\n )\n end", "def my_drop(cutoff)\n result = []\n i = 0\n each do | value |\n result.push value if i >= cutoff\n i += 1\n end\n result\n end", "def affected_lines_after\n affected_lines = String.new(affected_lines_before)\n affected_lines[column..(column + length - 1)] = replacement\n affected_lines\n end", "def take_damage(_amount)\n\t\t@temp_hp -= _amount\n\t\tif (temp_hp < 0)\n\t\t\t@current_hp += @temp_hp\n\t\t\t@temp_hp = 0\n\t\tend\n\t\tleftover = @current_hp\n\t\t@current_hp = 0 if @current_hp < 0\n\t\tleftover\n\tend", "def threshold_spy\n puts \"Ergebnis:\"\n puts (@spy_level_defender - @spy_level_attacker)*0.05+0.5 \n return (@spy_level_defender - @spy_level_attacker)*0.05+0.5 \n end", "def lower(amount)\n return Temperature.new(@value - amount, scale)\n end", "def increment_positions_on_lower_items(position)\n conditions = scope_condition\n conditions.merge!( { position_key.gte => position } )\n\n increase_all! in_collection.where(conditions)\n end" ]
[ "0.5497338", "0.51628816", "0.49867752", "0.4970769", "0.4927415", "0.47238207", "0.4689792", "0.46662536", "0.4647617", "0.46465495", "0.46371502", "0.46313834", "0.46305835", "0.46239343", "0.46220207", "0.46083945", "0.46038696", "0.45898765", "0.45389003", "0.45345128", "0.4525133", "0.4513466", "0.4490016", "0.44751337", "0.44714826", "0.44504368", "0.44454032", "0.44418895", "0.44320098", "0.44189474", "0.44127524", "0.44127524", "0.4406081", "0.440208", "0.43972188", "0.4387769", "0.43801907", "0.43739066", "0.4370884", "0.43168616", "0.43042988", "0.42726645", "0.42721945", "0.42707926", "0.4269073", "0.4266237", "0.4251581", "0.4241191", "0.42391688", "0.42370987", "0.4227482", "0.42194796", "0.42191678", "0.4211275", "0.42085302", "0.42043352", "0.4201026", "0.41994676", "0.41972613", "0.41893297", "0.41883275", "0.41793784", "0.4177762", "0.4172941", "0.41703862", "0.41633236", "0.41557384", "0.41557384", "0.4148938", "0.41436365", "0.41375196", "0.41301444", "0.41275257", "0.412436", "0.41205946", "0.4116987", "0.41167063", "0.41109985", "0.41080305", "0.4099191", "0.40891707", "0.4088546", "0.408799", "0.40861565", "0.40815896", "0.4080351", "0.4077639", "0.40734833", "0.40712175", "0.40693387", "0.40684825", "0.40664616", "0.40630862", "0.40626687", "0.40616077", "0.4060609", "0.40577245", "0.40548354", "0.40490094", "0.40451306" ]
0.85977507
0
Removes the line numbered 'line_num'
def remove_line(line_num) if @line_indices == [] @text = "" else length = line_index(line_num + 1) - line_index(line_num) @text[line_index(line_num) + 1 .. line_index(line_num + 1)] = "" @line_indices.delete_at(line_num) (line_num...@line_indices.length).each { |i| @line_indices[i] -= length } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_at(line_number)\n self[line_number].delete\n super(line_number)\n update_line_numbers!\n end", "def noteboard_delete(line_number)\n \n\n end", "def remove_line(line)\n\t\t@lines.delete(line)\n\tend", "def removeLine(lineNumber)\n \n\n\tlineNumber = lineNumber - 1\n\tnewQuestions = \"\"\n\n\tquestions = File.open(\"/Users/Wipf/questions.txt\", \"r+\")\n\n\t\tquestions.readlines.each_with_index do |eachLine, idx|\n\n\t\t\tif idx != lineNumber && eachLine.delete(\"#{idx}\\n\") != \"\" #each line has an index and /n ; .delete(\"#{idx}\\n\")removes it\n\t\t\t\t\t\t\t\t\t\t\t\t \t\t \n\t\t\t \tnewQuestions += eachLine\n\n\t\t\tend\n \t end\n\n questions.close\n\n \tquestions = File.open(\"/Users/Wipf/questions.txt\", \"w\")\n \tquestions.puts newQuestions\n\n\tquestions.close\n\n\tprint \"Question #{lineNumber + 1} has been removed\"\n\n\tputs \n\tputs\n\tputs \"Updated questions are:\"\n\tprint_questions\n\nend", "def strip_line_numbers(str_with_ruby_code)\n str_with_ruby_code.gsub(/ *\\d+: ? ?/, \"\")\n end", "def remove_data_line(which = 1)\n remove_line(\"data_line_#{which}\")\n end", "def back_to(line_number)\n while @lines.size > line_number\n @lines.pop\n end\n refresh\n end", "def line_number\n number[6..-1]\n end", "def normalized_line_number(line_number, total_lines)\n line_number < 0 ? line_number + total_lines : line_number\n end", "def line(number)\n lines[number - 1]\n end", "def line_id\n @line_number - 1\n end", "def read_specific_line(file_name, line_number)\n line = `sed '#{line_number + 1}!d' #{file_name}`\n line.chop! if line.last == \"\\n\"\n LoggerHelper.print_to_log(\"Lines in '#{file_name}' by number is '#{line}'\")\n line\n end", "def remove_line_from_file(path, line)\n run \"#{sudo} sed -i '/#{escape_sed(line)}/d' #{path}\", options\n end", "def line_number\n @line_number_overwrite || default_line_number\n end", "def line(number); end", "def remove_range(line_from, index_from, line_to, index_to) \n\t\tix1 = index_of_position(line_from, index_from)\n\t\tix2 = index_of_position(line_to, index_to)\n\t\t@text[ix1 ... ix2] = \"\"\n\t\t@line_indices.delete_if { |i| i.between?(ix1, ix2) }\n\t\tadjust_line_indices_after(ix2, -(ix2 - ix1))\n\tend", "def remove_line(instance_name)\n raise StandardError, \"Line object does not exist. (#{instance_name})\" unless self.instance_variables.include?(\"@#{instance_name}\".to_sym)\n remove_instance_variable(\"@#{instance_name}\".to_sym)\n unmake_attr(instance_name.to_sym)\n end", "def line(number)\n end", "def possibly_add_line_number_comment(line)\n if @state[:ll_end]\n return line + \" # WPLINE_#{@state[:line_number]}\"\n else\n return line\n end\n end", "def drop_from_each_line(n)\n self.lines.map do |line|\n k = 0\n line.chars.drop_while do |x|\n k += 1\n k <= n && x != \"\\n\"\n end.join(\"\")\n end.join(\"\")\n end", "def remove_line_references(name, file)\n source = IO.readlines name\n source.reject! { |line| line =~ /^#line\\s(\\d+)\\s\"[^\"]+\"/ }\n File.open(name, \"w\") { |f| f.puts source }\nend", "def rl_unix_line_discard(count, key)\r\n if (@rl_point == 0)\r\n rl_ding()\r\n else\r\n rl_kill_text(@rl_point, 0)\r\n @rl_point = 0\r\n if (@rl_editing_mode == @emacs_mode)\r\n @rl_mark = @rl_point\r\n end\r\n end\r\n 0\r\n end", "def new_line!(number)\n if @preprocessor.line_first\n @packet.send_packet\n @packet.add_line(number.to_i)\n else\n @packet.add_line(number.to_i)\n @packet.send_packet\n end\nend", "def delete_line(line)\n raise \"Can't find line item to delete\" unless @lines.delete(line)\n @deleted_lines << line\n end", "def set_line(line_number)\n @line_number = line_number\n end", "def update_line_numbers!\n each_with_index do |lo, new_line_number|\n lo.line_number = new_line_number\n end\n end", "def line_num; end", "def line(num) lines(num, 1) end", "def change_line(line_num, text) \n\t\traise \"no newlines here yet please\" if text =~ /\\n/\n\t\n\t\tix1, ix2 = line_index(line_num) + 1, line_index(line_num + 1)\n\t\t@text[ix1...ix2] = text\n\t\t(line_num...@line_indices.length).each { |i| @line_indices[i] += text.length - (ix2 - ix1) }\n\tend", "def read_line_number(filename, number)\n return nil if number < 1\n line = File.readlines(filename)[number-1]\n line ? line.chomp : nil\n end", "def from_line_index\n from_line - 1\n end", "def ti_delete_line\n\ttictl(\"dl\")\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def original_line_number(new_line)\n # First of all, convert the line number to an integer\n new_line = new_line.to_i\n\n if @phase == :execute\n # It's the execute phase, so we have more to do\n if @augmented_code.nil?\n # We haven't augmented the code with line numbers or anything\n number_of_prepended_lines = make_runnable(\"\").count(\"\\n\")\n return new_line - number_of_prepended_lines\n\n else\n # Pull the offending line out of the augmented code\n augmented_code_lines = @augmented_code.lines\n if new_line > augmented_code_lines.length\n # We were not able to find the line the error message refers to. Shouldn't happen.\n return \"<unbekannt>\"\n else\n # Check if the line has a line number comment\n ln = PythonCodeAugmenter.extract_line_number(augmented_code_lines[new_line - 1])\n if ln.nil?\n return \"<unbekannt>\"\n else\n return ln\n end\n end\n end\n\n else\n # It's not the execute phase, so we can simply return the line number\n return new_line\n end\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def remove_lines(target_file, args)\n new_file = []\n original_lines = IO.readlines(target_file)\n if args[:line] != nil && args[:lines] == nil\n args[:line] -= 1\n original_lines.slice!(args[:line])\n elsif args[:lines] != nil && args[:line] == nil\n args[:lines].map! {|x| x -= 1}\n args[:lines].each do |y|\n original_lines[y] = nil\n end\n elsif args[:lines] != nil && args[:line] != nil\n puts\n puts \"You have used an incorrect syntax for the FileUtils.remove_lines method.\".red\n puts \"You have specified a\" + \" :line\".red_bold + \" argument at the same time as a \" + \":lines\".red_bold + \" argument, only one can be used at a time.\"\n raise ArgumentError\n end\n if args[:pattern] != nil then\n original_lines.each do |line|\n if line =~ /#{args[:pattern]}/\n original_lines[original_lines.find_index(line)] = nil\n end\n end\n end\n original_lines.compact!\n new_file += original_lines\n File.open(target_file, \"w\") do |x|\n x.puts new_file\n end\n end", "def remove_line(match)\n func = nil\n\n if match.is_a?(Regexp)\n func = Proc.new { |x| x =~ match }\n else\n func = Proc.new { |x| x.index(match) }\n end\n\n lines = []\n modified = false\n\n open do |f|\n all_lines = f.readlines\n\n for line in all_lines\n unless func.call(line)\n lines << line\n end\n end\n\n if all_lines.size != lines.size\n modified = true\n end\n end\n\n if modified\n # TODO copy original file to backup store\n\n write do |f|\n f.write lines.join\n end\n end\n\n modified\n end", "def start_line_number=(_); end", "def remove(n = 1)\n left(n)\n @text.slice!(@cursor, n)\n end", "def line_at(filename, line_number) # :nodoc:\n line = LineCache::getline(filename, line_number, @reload_on_change)\n return \"\\n\" unless line\n return line.gsub(/^\\s+/, '').chomp\n end", "def delete_content_line(cl)\n lines.delete_if { |line| line.object_id == cl.object_id }\n end", "def nontrivial_end_line\n if successor\n successor.line_numbers.begin - 1\n else\n @document.last_non_empty_line\n end\n end", "def clear_line\n CLEAR_LINE\n end", "def original_line; end", "def remove_lines!\n self << \"for(var i = 0; i < map_lines.length; i++){\"\n self.remove_overlay 'map_lines[i]'\n self << \"}\"\n end", "def next_skip_line_number\n first = self.next\n first.type == :integer ? self.next : first\n end", "def remove_line_item(line_item)\n unless self.ordered?\n line_item.destroy\n end\n end", "def line_index(num)\n\t\tif num == 0\n\t\t\treturn -1\n\t\telsif num <= @line_indices.length\n\t\t\treturn @line_indices[num - 1]\n\t\telsif num == @line_indices.length + 1\n\t\t\treturn @text.length\n\t\telse\n\t\t\treturn -999 # todo\n\t\tend \n\tend", "def remove_line(options)\n line = Google::OptionsHelper.to_line(options)\n\n self.remove_overlay line\n line.removed_from_map self \n end", "def erase_line\n # highline does not expose the output stream\n HighLine.default_instance.instance_variable_get('@output').print \"\\r\\e[K\"\n end", "def line_number\n raise \"This loader doesn't support line_number\"\n end", "def irrelevant_line(source_line); end", "def line_number\n\t\t\t@line_index + 1\n\t\tend", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def clear_line\n CSI + '2K' + column(1)\n end", "def fixed_line_number\n FFaker.numerify('6### ####')\n end", "def rl_revert_line(count, key)\r\n if @rl_undo_list.nil?\r\n rl_ding()\r\n else\r\n while (@rl_undo_list)\r\n rl_do_undo()\r\n end\r\n if (@rl_editing_mode == @vi_mode)\r\n @rl_point = @rl_mark = 0 # rl_end should be set correctly\r\n end\r\n end\r\n 0\r\n end", "def clean_line(line)\n line.strip\n end", "def strip_comments(line)\n if line.include?('#')\n line.split(\"#\", 2)[0]\n else\n line\n end\n end", "def track_line_number(line_number)\n @min_line_number = line_number if line_number < min_line_number\n @max_line_number = line_number if line_number > max_line_number\n self\n end", "def destroy\n @line = Line.find_by_no(params[:id])\n @line.destroy\n\n respond_to do |format|\n format.html { redirect_to lines_url }\n format.json { head :no_content }\n end\n end", "def strip_diff_syntax(line)\n line[2..-1]\n end", "def line_at(filename, line_number)\n source_reload\n\n return \"\\n\" unless File.exist?(filename)\n line = Tracer::Single.get_line(filename, line_number)\n\n return \"#{line.gsub(/^\\s+/, '').chomp}\"\n end", "def rm_leader\n gsub(/^\\[\\d+\\] /,'')\n end", "def line\n buffer[line_number]\n end", "def unindent line\n if @options[:unindent] and\n @program.new_line? and\n margin = @margins.last and\n crown = @crowns.first\n then\n line.gsub(/^#{margin}/, crown)\n else\n line\n end\n end", "def editor_delete_line!\n Vedeu.bind(:_editor_delete_line_) do |name|\n Vedeu.documents.by_name(name).delete_line\n end\n end", "def kill_line(*)\n if current_buffer[current_buffer.point] == \"\\n\"\n current_buffer.slice!(current_buffer.point)\n return true\n end\n\n line_end = current_buffer.index(/$/, current_buffer.point)\n current_buffer.slice!(current_buffer.point, line_end - current_buffer.point)\n true\nend", "def strip_comments(line)\n\t\tline.strip!\n\t\t\n\t\tif line.start_with?(COMMENTS[0]) or line.start_with?(COMMENTS[1])\n\t\t\treturn ''\n\t\tend\n\t\t\n\t\tcomment_exists = (0 ... line.length).find_all {|i| line[i, 1] == COMMENTS[0] or line[i, 1] == COMMENTS[1]}\n\t\t\n\t\tif comment_exists.empty?\n\t\t\treturn line\n\t\tend\n\t\t\n\t\tif comment_exists\n\t\t\tline1 = String.new(line)\n\t\t\t#ignore delimiters within the text in the line itself.\n\t\t\t#replace quoted string with ' ' for the length and then remove comments.\n\t\t\t#return original line with the newly calculated index values.\n\t\t\t#asked question in forum and got this idea.\n\t\t\tline.scan(REGEX_STRING).each do |item|\n\t\t\t\tline1.sub!(item,' ' * item.length)\n\t\t\tend\n\n\t\t\tcomment_start = line1.index(COMMENTS[0])\n\t\t\t\n\t\t\tunless comment_start\n\t\t\t\tcomment_start = line1.index(COMMENTS[1])\n\t\t\t\t\tunless comment_start\n\t\t\t\t\t\treturn line\n\t\t\t\t\tend\n\t\t\tend\n\t\t\t\n\t\t\toutput = line[0..comment_start - 1]\n\t\t\t#strip again for whitespace before comment \n\t\t\toutput.strip!\n\t\t\treturn output\n\t\tend\n\t\t#if comment doesn't exist, return the line\n\t\tline\n\tend", "def remove\n\t\t\tback if (@buffer.at_end?)\n\t\t\tch = @buffer.char\n\t\t\t@buffer.remove\n\t\t\tredraw_line((ch == Ruvim::API::CR) ? (@cursor.y ... @height) : @cursor.y) \n\t\t\tself\n\t\tend", "def visible_line_number\r\n return 5\r\n end", "def line_number\n env(:line_number).to_i - 1\n end", "def delete_element(lines_number)\n\t\tdeleted_element_hash = {modify_nodes: [], add_nodes: [], remove_nodes: [], modify_edges: [], remove_edges: [], add_edges: []}\n\n\t\tlines_number.reverse.each do |number|\n\t\t\tdeleted_element_hash = merge_two_hashes(deleted_element_hash , remove_element(number))\n\t\tend\n\t\treturn uniqify_arrays_in_hash(deleted_element_hash, :id)\n\tend", "def visible_line_number\n return 4\n end", "def visible_line_number\n return 4\n end", "def next_lines(lines, number)\n lines.slice!(0, number)\n end", "def search_file_delete_line(regex)\n search_match(regex, \" \", 'd', 1)\n end", "def skip_lines(num=0) \n num.times do \n puts \" \"\n end\n end", "def parse_debug_line_number(number_as_string)\n # Deduct 1 because kakoune always maintains an extra empty line at the end of the debug buffer.\n number_as_string.to_i - 1\nend", "def remove_whitespace_before(index, buffer, rewriter, remove_preceeding_newline)\n end_pos = index\n begin_pos = end_pos - 1\n begin_pos -= 1 while code[begin_pos] =~ /\\s/ && code[begin_pos] != \"\\n\"\n begin_pos -= 1 if code[begin_pos] == \"\\n\"\n begin_pos -= 1 if code[begin_pos] == \"\\n\" && remove_preceeding_newline\n return if begin_pos.next == end_pos\n rewriter.remove Parser::Source::Range.new(buffer, begin_pos.next, end_pos)\n end", "def remove_lines\n @deleted_indexes = []\n\n # Loop though each line of the board array\n @object_array.each_with_index do |line, i|\n # if the line has a 0 in it, its not solid and should be ignored\n next if line.include?(0)\n\n # Add 0.5 to the lines_cleared tally (one line is two array rows thick)\n @lines_cleared += 0.5\n\n # Add the index of the solid line to the deleted_indexes array\n @deleted_indexes << i\n end\n\n # Delete rows from the board array at the index values in the deleted_indexes array\n @deleted_indexes.reverse.each { |i| @object_array.delete_at(i) }\n\n # Add rows of zeros to the top of the board array to replace the deleted lines\n @object_array = Array.new(@deleted_indexes.length) { [0] * @game_board_width } + @object_array\n\n @deleted_indexes\n end", "def previous_code_line(line_number); end", "def lineno=(num)\n num = Maglev::Type.coerce_to(num, Fixnum, :to_int)\n @_st_lineno = num\n $. = num\n num\n end", "def start_line_number; end", "def start_line_number; end", "def skip(a_line)\n @line_cnt ||= 0\n @line_cnt += 1\n 1 == @line_cnt ||\n a_line.empty? ||\n a_line.strip.start_with?('#')\n end", "def remove_unwanted_lines\n return unless @remove_lines.is_a?(Hash)\n @non_tabular_lines.each_with_index do |_line, i|\n @remove_lines.each do |_key, lines_to_remove|\n comparable_lines = @non_tabular_lines[i, lines_to_remove.length]\n next unless lines_equal(comparable_lines, lines_to_remove)\n # All lines are equal, so flag them as removed\n comparable_lines.each { |line| line.removed = true }\n end\n end\n end", "def line_numbering(value)\n @document_builder.line_numbering = value\n end" ]
[ "0.75238675", "0.72559553", "0.71756136", "0.6893151", "0.68463844", "0.6694514", "0.6635316", "0.6474661", "0.6412143", "0.637273", "0.6341321", "0.63086516", "0.6296507", "0.62349516", "0.6228228", "0.6216985", "0.61865336", "0.61761105", "0.6110079", "0.60851204", "0.60775286", "0.60641384", "0.60444343", "0.60423684", "0.60068655", "0.6003551", "0.59967744", "0.59526706", "0.59296256", "0.59144413", "0.58810234", "0.58777726", "0.5875098", "0.5875098", "0.5875098", "0.5875098", "0.5875098", "0.58667904", "0.5846788", "0.5846788", "0.5846788", "0.58458906", "0.58453804", "0.58403915", "0.5838129", "0.5805338", "0.57927203", "0.578867", "0.57693076", "0.5742386", "0.5727546", "0.57252365", "0.571176", "0.5707971", "0.57074016", "0.56851697", "0.56804127", "0.5678976", "0.56716913", "0.5671405", "0.5671405", "0.5671405", "0.5671405", "0.5671405", "0.5671405", "0.5671405", "0.56658924", "0.5662762", "0.5661361", "0.5658005", "0.563974", "0.56351036", "0.562834", "0.56116754", "0.5608638", "0.56020206", "0.560116", "0.5590301", "0.5585434", "0.55820876", "0.55736756", "0.55692625", "0.55386573", "0.5533878", "0.55330014", "0.55327743", "0.55327743", "0.5528657", "0.55280966", "0.5515229", "0.5513325", "0.5494589", "0.54921556", "0.5478698", "0.54749215", "0.5469583", "0.5469583", "0.54589635", "0.5451649", "0.54486316" ]
0.8547995
0
Removes from 'line_from', 'index_from' up to but not including 'line_to', 'index_to'
def remove_range(line_from, index_from, line_to, index_to) ix1 = index_of_position(line_from, index_from) ix2 = index_of_position(line_to, index_to) @text[ix1 ... ix2] = "" @line_indices.delete_if { |i| i.between?(ix1, ix2) } adjust_line_indices_after(ix2, -(ix2 - ix1)) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_preceding(node_or_range, size); end", "def remove_line(line_num)\n\t\tif @line_indices == []\n\t\t\t@text = \"\"\n\t\telse\n\t\t\tlength = line_index(line_num + 1) - line_index(line_num)\n\t\t\t@text[line_index(line_num) + 1 .. line_index(line_num + 1)] = \"\"\n\t\t\t@line_indices.delete_at(line_num)\n\t\t\t(line_num...@line_indices.length).each { |i| @line_indices[i] -= length }\n\t\tend\n\tend", "def remove_edge_by_indexes(start_vertex_index, end_vertex_index)\n\n @vertices[start_vertex_index].neighbours[end_vertex_index] = nil\n @vertices[end_vertex_index].neighbours[start_vertex_index] = nil\n\n self\n end", "def remove(range); end", "def remove(range); end", "def remove(range); end", "def remove(range); end", "def remove(range); end", "def remove(range); end", "def remove(range); end", "def remove(range); end", "def remove_range(from = '-inf', to = '+inf')\n connection.zremrangebyscore(key_label, from, to)\n end", "def strip_blank_lines!\n\t\t# algorithm: figure out what lines to remove - mark and execute\n\t\t# (flag undesirables, then remove them all in one pass)\n\t\t\n\t\t\n\t\t# work inwards from the outside until you fine lines that are not empty\n\t\tmin_i = self.index{ |line| line != \"\" }\n\t\tmax_i = self.rindex{ |line| line != \"\" }\n\t\t\n\t\t\n\t\t\n\t\t\n\t\t# need to keep everything in this range\n\t\t# and discard everything else\n\t\t# (min_i..max_i)\n\t\t# \n\t\t# \n\t\t# need to remove all things in these two ranges\n\t\t# (0..min_i) + (max_i..-1)\n\t\t# well, except the limits need to be moved outwards by one position,\n\t\t# because the initial search find the first non-empty lines\n\t\t# \n\t\t# but, there might only be empty lines on one side or the other\n\t\t\n\t\t\n\t\t# --- figure out what to get rid of\n\t\tlower_range = (0..(min_i-1))\n\t\tupper_range = ((max_i+1)..(self.size-1))\n\t\t\n\t\t\n\t\t# delete ranges if malformed\n\t\tlower_range = nil unless lower_range.max\n\t\tupper_range = nil unless upper_range.max\n\t\t\n\t\t# delete lower range if it is the same as the upper one\n\t\t# (Don't want to try to delete things twice. That could get messy)\n\t\tupper_range = nil if upper_range == lower_range\n\t\t\n\t\t\n\t\t# --- mark and execute\n\t\t# flag unnecessary elements\n\t\tself[lower_range] = nil if lower_range\n\t\tself[upper_range] = nil if upper_range\n\t\t\n\t\t# condense array so only desirables remain\n\t\tself.compact!\n\t\t\n\t\t\n\t\treturn self\n\tend", "def remove_leading(node_or_range, size); end", "def delete_at(line_number)\n self[line_number].delete\n super(line_number)\n update_line_numbers!\n end", "def remove_lines(target_file, args)\n new_file = []\n original_lines = IO.readlines(target_file)\n if args[:line] != nil && args[:lines] == nil\n args[:line] -= 1\n original_lines.slice!(args[:line])\n elsif args[:lines] != nil && args[:line] == nil\n args[:lines].map! {|x| x -= 1}\n args[:lines].each do |y|\n original_lines[y] = nil\n end\n elsif args[:lines] != nil && args[:line] != nil\n puts\n puts \"You have used an incorrect syntax for the FileUtils.remove_lines method.\".red\n puts \"You have specified a\" + \" :line\".red_bold + \" argument at the same time as a \" + \":lines\".red_bold + \" argument, only one can be used at a time.\"\n raise ArgumentError\n end\n if args[:pattern] != nil then\n original_lines.each do |line|\n if line =~ /#{args[:pattern]}/\n original_lines[original_lines.find_index(line)] = nil\n end\n end\n end\n original_lines.compact!\n new_file += original_lines\n File.open(target_file, \"w\") do |x|\n x.puts new_file\n end\n end", "def same_line(line, start_index, end_index)\n if (start_index > end_index)\n start_index = reverse_direction(line, start_index)\n end_index = reverse_direction(line, end_index)\n line.reverse!\n line[start_index..end_index]\n elsif start_index == end_index\n \"\\nBuddy, have a look around, you are already there...\\n\"\n else\n line[start_index..end_index]\n end\nend", "def strip_index(input); end", "def remove_trailing(node_or_range, size); end", "def remove_whitespace_before(index, buffer, rewriter, remove_preceeding_newline)\n end_pos = index\n begin_pos = end_pos - 1\n begin_pos -= 1 while code[begin_pos] =~ /\\s/ && code[begin_pos] != \"\\n\"\n begin_pos -= 1 if code[begin_pos] == \"\\n\"\n begin_pos -= 1 if code[begin_pos] == \"\\n\" && remove_preceeding_newline\n return if begin_pos.next == end_pos\n rewriter.remove Parser::Source::Range.new(buffer, begin_pos.next, end_pos)\n end", "def remove_range(left, right)\n \n end", "def remove_range(left, right)\n \n end", "def from_line_index\n from_line - 1\n end", "def strip_blank_lines\n\t\t# algorithm: keep only the non-blank lines\n\t\t\n\t\t\n\t\t# work inwards from the outside until you fine lines that are not empty\n\t\tmin_i = self.index{ |line| line != \"\" }\n\t\tmax_i = self.rindex{ |line| line != \"\" }\n\t\t\n\t\t\n\t\t# keep only the things inside the range\n\t\trange = (min_i..max_i)\n\t\t\n\t\t\n\t\tunless range.max < range.min # only on ascending\n\t\t\treturn self.each_index.select {|i| range.include? i }\n\t\telse\n\t\t\treturn self.clone\n\t\tend\n\tend", "def remove_preceding(node_or_range, size)\n range = to_range(node_or_range)\n to_remove = Parser::Source::Range.new(range.source_buffer,\n range.begin_pos - size,\n range.begin_pos)\n @source_rewriter.remove(to_remove)\n end", "def remove_lines\n @deleted_indexes = []\n\n # Loop though each line of the board array\n @object_array.each_with_index do |line, i|\n # if the line has a 0 in it, its not solid and should be ignored\n next if line.include?(0)\n\n # Add 0.5 to the lines_cleared tally (one line is two array rows thick)\n @lines_cleared += 0.5\n\n # Add the index of the solid line to the deleted_indexes array\n @deleted_indexes << i\n end\n\n # Delete rows from the board array at the index values in the deleted_indexes array\n @deleted_indexes.reverse.each { |i| @object_array.delete_at(i) }\n\n # Add rows of zeros to the top of the board array to replace the deleted lines\n @object_array = Array.new(@deleted_indexes.length) { [0] * @game_board_width } + @object_array\n\n @deleted_indexes\n end", "def remove(x)\n if include?(x)\n ind = @indices[x]\n ind2 = @content.size - 1\n swap(ind,ind2) # do this to ensure constant time\n removeEnd\n end\n end", "def remove(range)\n @source_rewriter.remove(range)\n end", "def remove(range)\n @source_rewriter.remove(range)\n end", "def remove_leading(node_or_range, size)\n range = to_range(node_or_range)\n to_remove = Parser::Source::Range.new(range.source_buffer,\n range.begin_pos,\n range.begin_pos + size)\n @source_rewriter.remove(to_remove)\n end", "def rl_delete_text(from, to)\r\n\r\n # Fix it if the caller is confused.\r\n if (from > to)\r\n from,to = to,from\r\n end\r\n\r\n # fix boundaries\r\n if (to > @rl_end)\r\n to = @rl_end\r\n if (from > to)\r\n from = to\r\n end\r\n end\r\n if (from < 0)\r\n from = 0\r\n end\r\n text = rl_copy_text(from, to)\r\n diff = to - from\r\n @rl_line_buffer[from...to] = ''\r\n @rl_line_buffer << 0.chr * diff\r\n # Remember how to undo this delete.\r\n if (!@_rl_doing_an_undo)\r\n rl_add_undo(UNDO_DELETE, from, to, text)\r\n else\r\n text = nil\r\n end\r\n @rl_end -= diff\r\n @rl_line_buffer[@rl_end,1] = 0.chr\r\n return (diff)\r\n end", "def remove_captured(pos1,pos2)\n row = (pos1[0]+pos2[0]) / 2\n col = (pos1[1] + pos2[1]) / 2\n self[[row,col]] = nil\n end", "def remove_at(index)\n removed_node = at_no_data(index)\n prev_node = at_no_data(index - 1)\n next_node = at_no_data(index + 1)\n prev_node.next_node = next_node\n puts \"#{removed_node.data} has left the group\"\n removed_node\n end", "def removeEnd\n @indices.delete(@content[-1])\n @content.pop\n end", "def remove_at(index)\n if index == 0\n @home = get_index(index+1)\n @home.next_node = get_index(index+2)\n elsif get_index(index) == @tail\n @tail = get_index(index-1)\n @tail.next_node = nil\n else\n prev = get_index(index-1)\n post = get_index(index+1)\n prev.next_node = post\n end\n end", "def remove(from, to)\n time_range_to_remove = @with_time ? Range.create_time_range(from, to) : from..to\n\n # Check and Delete if there is an exact match of the (time) range and an existing (time) range within the day.\n unless @day.delete?(time_range_to_remove)\n\n # looking at each (time) range of the day\n @day.each do |time_range|\n\n # Check if the (time) range to remove overlaps the current (time) range\n if time_range_to_remove.overlaps?(time_range)\n\n # Delete the (time) range\n @day.delete time_range\n\n # Merge the difference between the (time) range and the (time) range to remove.\n @day.merge(time_range - time_range_to_remove)\n\n end\n\n end\n\n end\n\n day\n end", "def remove_unwanted_lines\n return unless @remove_lines.is_a?(Hash)\n @non_tabular_lines.each_with_index do |_line, i|\n @remove_lines.each do |_key, lines_to_remove|\n comparable_lines = @non_tabular_lines[i, lines_to_remove.length]\n next unless lines_equal(comparable_lines, lines_to_remove)\n # All lines are equal, so flag them as removed\n comparable_lines.each { |line| line.removed = true }\n end\n end\n end", "def delete_at(p0) end", "def get_range(line_from, index_from, line_to, index_to) \n\t\tix1 = index_of_position(line_from, index_from)\n\t\tix2 = index_of_position(line_to, index_to)\n\t\t@text[ix1 ... ix2]\n\tend", "def remove_at(index)\n raise(StandardError, 'IndexError') if invalid_index?(index)\n return remove_uniq_element if size == 1\n\n index = normalize_index(index)\n\n if index.zero?\n remove_header\n elsif (index + 1) == size\n remove_trailer\n else\n remove_node(find_node_by_index(index))\n end\n end", "def drop_row(pos)\n start = pos[:at].to_i\n count = pos[:count].to_i\n stop = start + count - 1\n rows.where(position: start..stop).destroy_all\n rows.each_with_index do |row,i|\n row.position = i\n row.save\n end\n end", "def back_to(line_number)\n while @lines.size > line_number\n @lines.pop\n end\n refresh\n end", "def remove_row_selection_interval ix0, ix1\n @anchor_selection_index = ix0\n @lead_selection_index = ix1\n arr = @selected_indices.dup # to un highlight\n @selected_indices.delete_if {|x| x >= ix0 and x <= ix1 }\n arr.each {|i| @obj.fire_row_changed(i) }\n lse = ListSelectionEvent.new(ix0, ix1, @obj, :DELETE)\n @obj.fire_handler :LIST_SELECTION_EVENT, lse\n end", "def trip(line, from, to)\n line = @subway[line]\n from_index = line.index(from)\n to_index = line.index(to)\n\n if from_index < to_index\n line[from_index..to_index]\n else # opposite direction\n line[to_index..from_index].reverse\n end\nend", "def noteboard_delete(line_number)\n \n\n end", "def skippast(to)\n @index = @source.index(to, @index)\n @index = (@index.nil?) ? @source.length : @index + to.length\n end", "def remove_by_range(start=nil, stop=nil)\n if !start and !stop\n throw \"Must specify either start or stop\"\n end\n\n start = start ? \"(#{start}\" : '-inf'\n stop = stop ? \"#{stop}\" : \"+inf\"\n\n # Get the keys to delete from the hash\n keys = @index.range_by_score(start, stop)\n # Remove the keys from the index\n @index.delete_by_score(start, stop)\n # Remove the values from the hash\n multi do\n keys.each do |key|\n @hash.delete(key)\n end\n end\n\n self\n end", "def remove_at(index)\n at(index+1)\n temp = @current_node\n at(index-1)\n @current_node.next = temp\n end", "def delrows(row1,row2)\n\t\t@text[row1..row2] = []\n\tend", "def adjust_line_indices_after(threshold, amount) \n\t\t@line_indices.map! { |l| l >= threshold ? l + amount : l }\n\tend", "def strip_diff_syntax(line)\n line[2..-1]\n end", "def removeLine(lineNumber)\n \n\n\tlineNumber = lineNumber - 1\n\tnewQuestions = \"\"\n\n\tquestions = File.open(\"/Users/Wipf/questions.txt\", \"r+\")\n\n\t\tquestions.readlines.each_with_index do |eachLine, idx|\n\n\t\t\tif idx != lineNumber && eachLine.delete(\"#{idx}\\n\") != \"\" #each line has an index and /n ; .delete(\"#{idx}\\n\")removes it\n\t\t\t\t\t\t\t\t\t\t\t\t \t\t \n\t\t\t \tnewQuestions += eachLine\n\n\t\t\tend\n \t end\n\n questions.close\n\n \tquestions = File.open(\"/Users/Wipf/questions.txt\", \"w\")\n \tquestions.puts newQuestions\n\n\tquestions.close\n\n\tprint \"Question #{lineNumber + 1} has been removed\"\n\n\tputs \n\tputs\n\tputs \"Updated questions are:\"\n\tprint_questions\n\nend", "def remove_at(index)\n self.at(index - 1).next_node = self.at(index + 1)\n self.at(index).next_node = nil\n end", "def drop_from_each_line(n)\n self.lines.map do |line|\n k = 0\n line.chars.drop_while do |x|\n k += 1\n k <= n && x != \"\\n\"\n end.join(\"\")\n end.join(\"\")\n end", "def black_move(from_pos, to_pos)\n real_move!(from_pos, to_pos)\n @last_move = self[to_pos].line_key\n end", "def ltrim(key, start, stop); end", "def ltrim(key, start, stop); end", "def exclude_ends input\n\n input[1..-2]\n\n end", "def move_subway start_stop, end_stop, line\n if start_stop > end_stop\n subway_stops = line[end_stop..start_stop - 1].reverse\n else\n subway_stops = line[start_stop + 1..end_stop]\n end\nend", "def remove(a, b)\n puts \"Removing between #{a} and #{b}\"\n (a..b).each { |i| @counts[i] = 0 }\n (1..@k).each { |i| @counts[i] += @counts[i - 1] }\n end", "def filter_off(ip, line, input, vp_hash)\n\tprocess_line(ip, find_elem(line, 3), find_elem(line, 2), vp_hash)\n # while there is still data, and while the IP of next\n # is the same as this IP, yield statement\n while nex = input.gets and find_elem(nex).eql?(ip)\n #yield the VP (index 3) and IP (index 1)\n\t\tprocess_line(ip, find_elem(nex, 3), find_elem(nex, 2), vp_hash)\n end\n #return the line that contains the first different prefix\n nex\nend", "def remove_at(index)\n counter = 0\n current_node = @head\n until counter == index\n previous_node = current_node\n current_node = current_node.next_node\n counter += 1\n end\n previous_node.next_node = current_node.next_node\n end", "def remove_trailing(node_or_range, size)\n range = to_range(node_or_range)\n to_remove = Parser::Source::Range.new(range.source_buffer,\n range.end_pos - size,\n range.end_pos)\n @source_rewriter.remove(to_remove)\n end", "def remove_at(index)\n\t\t@current_node = at(index)\n\n\t\tif @current_node != @head\n\t\t\t@previous_node = at(index - 1)\n\n\t\t\tif @current_node != @tail\n\t\t\t\t@previous_node.next_node = at(index + 1)\n\t\t\telse\n\t\t\t\t@previous_node.next_node = nil\n\t\t\t\t@previous_node = @tail\n\t\t\tend\n\t\t\t@current_node = nil\n\t\telse\n\t\t\t@head = at(index + 1)\n\t\t\t@current_node = nil\n\t\tend\n\tend", "def exclude_ends potato\n potato [1..-2]\nend", "def remove_index_on(node, old_props)\n @config.fields.each { |field| rm_index(node, field, old_props[field]) if old_props[field] }\n end", "def remove_line(line)\n\t\t@lines.delete(line)\n\tend", "def remove(n = 1)\n left(n)\n @text.slice!(@cursor, n)\n end", "def remove_from_list\n # if in_list?\n # decrement_positions_on_lower_items\n # update_attribute position_column, nil\n # end \n return unless in_list?\n decrement_positions_on_lower_items\n update_attribute position_column, nil \n end", "def remove_included_ip_range(from, to)\n from_ip = IPAddr.new(from)\n to_ip = IPAddr.new(to)\n (from_ip..to_ip)\n raise 'Invalid IP range specified' if (from_ip..to_ip).to_a.size.zero?\n @included_scan_targets[:addresses].reject! { |t| t.eql? IPRange.new(from, to) }\n rescue ArgumentError => e\n raise \"#{e.message} in given IP range\"\n end", "def remove_inserts\n\n currseq = \"\"\n currname = \"\"\n # TODO: extract this from all methods to a helper class \n @content.each do |line|\n # if name anchor is found start a new bin\n if (line =~ /^>(.*)/)\n # check if we found next bin\n if (currseq.length > 0)\n # push name and sequence to containers\n @names << currname\n @seqs << currseq\n end\n # name is found next to anchor\n currname = $1\n # no sequence data yet\n currseq = \"\"\n else\n # append sequence data\n currseq += line\n end \n end \n # collect the data from the last bin\n if (currseq.length > 0)\n @names << currname\n @seqs << currseq\n end\n \n match_cols = []\n \n # Determine which columns have a gap in first sequence (match_cols = false)\n residues = @seqs[0].unpack(\"C*\")\n residues.each_index do |num|\n if (residues[num] == 45 || residues[num] == 46)\n match_cols[num] = false\n else\n match_cols[num] = true\n end\n end\n \n # Delete insert columns\n @names.each_index do |i|\n # Unpack C : 8-bit unsigned integer , push -> Array\n residues = @seqs[i].unpack(\"C*\")\n seq = \"\"\n # traverse over Integer Representation\n residues.each_index do |num|\n # If the base Sequence has no gap then check current sequence \n if (match_cols[num])\n if (residues[num] == 45 || residues[num] == 46)\n # Add gap to Sequence\n seq += \"-\"\n else\n # Add the Residue to Sequence\n seq += residues[num].chr\n end \n end \n end\n # Remove anchoring String Characters\n seq.tr!('^a-zA-Z-','')\n # Push an Upper Case representation to the @seqs array\n @seqs[i] = seq.upcase\n # Check whether all sequences have same length as parent\n if (@seqs[i].length != @seqs[0].length)\n logger.debug \"ERROR! Sequences in alignment do not all have equal length!\"\n end\n end\n end", "def remove_header_and_footer_rows(results_rows)\n results_rows[2..-4]\n end", "def remove_before(stop)\n remove_by_range(nil, stop)\n end", "def complement\n l = self.clone\n l.from = to\n l.from_orient = (to_orient == :+ ? :- : :+)\n l.to = from\n l.to_orient = (from_orient == :+ ? :- : :+)\n l.overlap = complement_overlap\n l\n end", "def start_nodes(rows)\n rows.reject do |row|\n rows.any? do |other_row|\n other_row.to == row.from\n end\n end\nend", "def trim_results(results, line_prefix)\n return results unless line_prefix\n\n results.each_with_index do |row, i|\n return results.drop(i + 1) if row.start_with? line_prefix\n end\n\n results\n end", "def affected_lines_range\n (line_no..line_no + replaced_text.count(\"\\n\"))\n end", "def get_users_stops_by_line(line,origin_stop,destination_stop)\n # stop_list is an array which is line details\n stop_list = get_stop_details(line)\n origin_stop_index = stop_list.index(origin_stop)\n destination_stop_index = stop_list.index(destination_stop)\n\n if origin_stop_index < destination_stop_index\n stop_list[origin_stop_index + 1..destination_stop_index]\n\n else\n stop_list[destination_stop_index..origin_stop_index - 1].reverse()\n end\n end", "def delete_at_index(index)\n \n end", "def trim(start_nt, end_nt, ref_option = :HXB2, path_to_muscle = false)\n seq_hash = self.dna_hash.dup\n seq_hash_unique = seq_hash.uniq_hash\n trimmed_seq_hash = {}\n seq_hash_unique.each do |seq, names|\n trimmed_seq = ViralSeq::Sequence.new('', seq).sequence_clip(start_nt, end_nt, ref_option, path_to_muscle).dna\n names.each do |name|\n trimmed_seq_hash[name] = trimmed_seq\n end\n end\n return_seq_hash = self.dup\n return_seq_hash.dna_hash = trimmed_seq_hash\n return return_seq_hash\n end", "def rm_index\n\tarray = [0, 2, 4, 6, 8]\n\twhile array.length > 2\n\t\tputs array.pop\n\tend\nend", "def rm_block(start_id, end_id, path)\n puts \"Removing string block from #{start_id} to #{end_id} #{path}\".colorize(:light_red)\n\t\tstart_regexp = Regexp.new(Regexp.escape(start_id))\n\t\tend_regexp = Regexp.new(Regexp.escape(end_id))\n\t\tlines, new_lines, result = [], [], true\n\t\tFile.open(path, 'r'){|f| lines = f.readlines }\n\t\tlines.chunk { |line|\n\t\t\tif line =~ start_regexp\n\t\t\t\tresult = false\n\t\t\telsif line =~ end_regexp\n\t\t\t\tresult = true\n\t\t\tend\n\t\t\tresult\n\t\t}.each{ |result, arr| \n\t\t\tif result\n\t\t\t\tarr[0] =~ end_regexp ? arr.shift : arr\n\t\t\t\tnew_lines << arr\n\t\t\tend\n\t\t}\n\t\tFile.open(path, 'w+'){|f| f.write(new_lines.join)}\n\tend", "def remove_at(index)\n current = @head\n (index - 1).times do\n current = current.next_node\n end\n\n current.next_node = current.next_node.next_node\n end", "def delete_before\r\n return nil if @cursor == 0\r\n result = @buffer.delete_at(@cursor - 1)\r\n @buffer.compact! #needed?\r\n @cursor = @cursor - 1 if result != nil\r\n result\r\n end", "def remove_line(match)\n func = nil\n\n if match.is_a?(Regexp)\n func = Proc.new { |x| x =~ match }\n else\n func = Proc.new { |x| x.index(match) }\n end\n\n lines = []\n modified = false\n\n open do |f|\n all_lines = f.readlines\n\n for line in all_lines\n unless func.call(line)\n lines << line\n end\n end\n\n if all_lines.size != lines.size\n modified = true\n end\n end\n\n if modified\n # TODO copy original file to backup store\n\n write do |f|\n f.write lines.join\n end\n end\n\n modified\n end", "def each_line_with_index(io)\n offset = format.skip\n io.each_line.with_index do |line, index|\n yield(line, index) unless index < offset\n end\n end", "def delete_edge!(from, to)\n protected_delete_edge!(from, to)\n protected_delete_edge!(to, from)\n @edge_number -= 1\n end", "def irrelevant_line(source_line); end", "def revert_pos(data)\n self.pos = data[0]\n @previous_pos, @previous_line_number = data[1], data[2]\n end", "def rstrip_buffer!(index = -1)\n last = @to_merge[index]\n if last.nil?\n push_silent(\"_hamlout.rstrip!\", false)\n @dont_tab_up_next_text = true\n return\n end\n\n case last.first\n when :text\n last[1].rstrip!\n if last[1].empty?\n @to_merge.slice! index\n rstrip_buffer! index\n end\n when :script\n last[1].gsub!(/\\(haml_temp, (.*?)\\);$/, '(haml_temp.rstrip, \\1);')\n rstrip_buffer! index - 1\n else\n raise SyntaxError.new(\"[HAML BUG] Undefined entry in Haml::Precompiler@to_merge.\")\n end\n end", "def erase_line(direction = :both)\n options = [:both, :beginning, :end]\n target = \"erase_line_to_#{direction}\"\n return(self.send(target)) if options.grep(direction).any?\n\n raise(ArgumentError,\n \"Expected :both, :end, or :beginning, got #{direction}.\")\n end", "def removing(range, &block)\n return if range.count == 0\n\n @access.begin_remove(range.min, range.max)\n ret = yield\n @access.end_remove\n ret\n end", "def rstrip_buffer!(index = -1)\n last = @to_merge[index]\n if last.nil?\n push_silent(\"_hamlout.rstrip!\", false)\n @dont_tab_up_next_text = true\n return\n end\n\n case last.first\n when :text\n last[1].rstrip!\n if last[1].empty?\n @to_merge.slice! index\n rstrip_buffer! index\n end\n when :script\n last[1].gsub!(/\\(haml_temp, (.*?)\\);$/, '(haml_temp.rstrip, \\1);')\n rstrip_buffer! index - 1\n else\n raise SyntaxError.new(\"[HAML BUG] Undefined entry in Haml::Compiler@to_merge.\")\n end\n end", "def remove_lines!\n self << \"for(var i = 0; i < map_lines.length; i++){\"\n self.remove_overlay 'map_lines[i]'\n self << \"}\"\n end", "def delete_edge!(from, to)\n protected_delete_edge!(from, to)\n @edge_number -= 1\n end", "def remove(index)\n assert_in_range index\n \n current, previous = get_node(index)\n previous.successor = current.successor if previous\n \n @head = current.successor if current == @head\n @tail = previous if current == @tail\n \n @size -= 1\n end", "def decrement_positions_between(low, high)\n acts_as_list_class.update_all(\n \"#{position_column} = (#{position_column} - 1)\", [\"#{scope_condition} AND #{position_column} >= ? AND #{position_column} <= ?\", low, high]\n )\n end", "def clean_overlap_yard_log(exclude_log)\n BoatYardLog.ransack(\n id_not_eq: exclude_log.id,\n boat_id_eq: @boat.id,\n g: [{\n start_date_or_end_date_in: @current_date..@current_date,\n end_date_present: 0,\n m: \"or\"\n }]\n ).result.destroy_all\n end", "def revert_pos(data); end", "def remove_edge(from, to)\n\t\t\t@size -= 1 if disconnect(from, to)\n\t\t\tself\n\t\tend" ]
[ "0.62792844", "0.6189214", "0.6107818", "0.61052537", "0.61052537", "0.61052537", "0.61052537", "0.61052537", "0.61052537", "0.61052537", "0.61052537", "0.6097464", "0.6032891", "0.59996", "0.59461457", "0.5907957", "0.5883209", "0.58761173", "0.5823448", "0.58043784", "0.5786225", "0.5786225", "0.5763849", "0.574641", "0.57340497", "0.56827784", "0.561632", "0.56135815", "0.56135815", "0.5602747", "0.5557981", "0.5544634", "0.55339533", "0.5530794", "0.55105156", "0.5493234", "0.5473234", "0.5454437", "0.54526216", "0.5451358", "0.54349494", "0.5430591", "0.5428179", "0.5423829", "0.5411635", "0.5402496", "0.5386105", "0.53785175", "0.5354402", "0.5338087", "0.5328879", "0.5325955", "0.53094476", "0.5289463", "0.52659404", "0.5264748", "0.5264748", "0.52600104", "0.5259122", "0.52556604", "0.52396244", "0.5237426", "0.5212196", "0.5199418", "0.51937747", "0.51864344", "0.5175098", "0.5173938", "0.51701206", "0.5156324", "0.5147807", "0.51388353", "0.51282305", "0.5122405", "0.511748", "0.5113863", "0.5100374", "0.5093531", "0.50597507", "0.50526845", "0.5051122", "0.50505173", "0.5042427", "0.5040413", "0.50397617", "0.5035029", "0.5032339", "0.502747", "0.5026305", "0.5018435", "0.5011864", "0.5009475", "0.5005349", "0.4999377", "0.49815607", "0.49699003", "0.49596238", "0.4945919", "0.49420846", "0.49389058" ]
0.82596976
0
Gets text from 'line_from', 'index_from' up to but not including 'line_to', 'index_to'
def get_range(line_from, index_from, line_to, index_to) ix1 = index_of_position(line_from, index_from) ix2 = index_of_position(line_to, index_to) @text[ix1 ... ix2] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def remove_range(line_from, index_from, line_to, index_to) \n\t\tix1 = index_of_position(line_from, index_from)\n\t\tix2 = index_of_position(line_to, index_to)\n\t\t@text[ix1 ... ix2] = \"\"\n\t\t@line_indices.delete_if { |i| i.between?(ix1, ix2) }\n\t\tadjust_line_indices_after(ix2, -(ix2 - ix1))\n\tend", "def from_line_index\n from_line - 1\n end", "def slice(text)\n text[from...to]\n end", "def lines(start, num) \n\t\t@text[index_of_position(start)...index_of_position(start + num) - 1]\n\tend", "def offset_range\n return nil unless original_text\n start_pos.offset...(start_pos.offset + original_text.bytesize)\n end", "def text_range\n body = get.gsub!(/\\s*/,'')\n pattern = /#{@before_element}.*#{@after_element}/\n results = pattern.match(body)\n return results[0] if results\n end", "def line_for_position(position); end", "def line_for_position(position); end", "def line_for_position(position); end", "def from_first_line_matching(regex_from)\n arr_lines = self.split(\"\\n\")\n ix1 = arr_lines.index_regex(regex_from) || 0\n if ! ix1\n throw \"Cattivo Indice per arr_lines. Non greppa una fava con: #{regex_from}\"\n ix1 = 0\n end\n ix2 = arr_lines.length\n deb \"#{ix1}..#{ix2}\"\n joint = arr_lines[ix1..ix2].join(\"\\n\") #rescue ''\n return joint \n end", "def affected(text)\n occurrences = lines.each_index.select do |i|\n lines[i].start_with?(\"+\") && text.any? { |t| lines[i].include? t }\n end\n occurrences.map do |occ|\n lines[2..occ].reverse.find { |l| l.start_with? \"Index: \" }[7..]\n end\n end", "def affected_lines_range\n (line_no..line_no + replaced_text.count(\"\\n\"))\n end", "def singleLine(line, from, to)\n ans = ''\n \n reapet = line.index(from) - line.index(to)\n if reapet > 0 \n steps = reapet\n\n i = line.index(from)\n reapet.times{\n i += 1\n ans += \"#{line[i]}, \"\n }\n else\n\n reapet = line.index(to) - line.index(from)\n steps = reapet\n i = line.index(to)\n reapet.times{\n i -= 1\n ans += \"#{line[i]}, \"\n }\n\n end\n\n return [ans, steps]\n\n end", "def line_index()\n end", "def extract_text(offset, length)\n end", "def line_range\n max_lines = source_file.content.lines.size - 1\n context_lines = 3\n first_line = [0, location_line - context_lines - 1].max\n last_line = [max_lines, location_line + context_lines - 1].min\n first_line..last_line\n end", "def text\n @text[range]\n end", "def to_offset(text, position); end", "def find_line_boundary(text, start_index, rightwards)\n index = start_index\n vector = -1\n vector = 1 if rightwards\n\n loop do\n character = text[index]\n\n if rightwards\n break if index >= text.length\n break if character == \"\\n\"\n else\n break if index <= 0\n break if text[index - 1] == \"\\n\"\n end\n\n index = index + vector\n end\n\n index\n end", "def line_numbers\n return (line..line) unless @value && text\n\n end_line = if !lines.empty?\n line + lines.count - 1\n elsif children.empty?\n nontrivial_end_line\n else\n line\n end\n\n (line..end_line)\n end", "def first_line_only(range); end", "def first_line_only(range); end", "def first_line_only(range); end", "def index_line_and_col(index) \n\t\ti = 0\n\t\ti += 1 while index_of_position(i) <= index\n\t\ti -= 1\n\t\t[i, index - index_of_position(i)]\n\tend", "def read_between_the_lines(file_name, start_line, end_line)\n content = File.read(File.expand_path(file_name))\n lines_array = content.each_line.to_a\n\n [lines_array[start_line..end_line].join, normalized_line_number(start_line, lines_array.size),\n normalized_line_number(end_line, lines_array.size)]\n end", "def rl_delete_text(from, to)\r\n\r\n # Fix it if the caller is confused.\r\n if (from > to)\r\n from,to = to,from\r\n end\r\n\r\n # fix boundaries\r\n if (to > @rl_end)\r\n to = @rl_end\r\n if (from > to)\r\n from = to\r\n end\r\n end\r\n if (from < 0)\r\n from = 0\r\n end\r\n text = rl_copy_text(from, to)\r\n diff = to - from\r\n @rl_line_buffer[from...to] = ''\r\n @rl_line_buffer << 0.chr * diff\r\n # Remember how to undo this delete.\r\n if (!@_rl_doing_an_undo)\r\n rl_add_undo(UNDO_DELETE, from, to, text)\r\n else\r\n text = nil\r\n end\r\n @rl_end -= diff\r\n @rl_line_buffer[@rl_end,1] = 0.chr\r\n return (diff)\r\n end", "def relative_text_position(index)\n if at_end?(index)\n relative_end_position\n elsif relative_in_first_segment?(index)\n relative_in_first_segment(index)\n else\n relative_in_last_segment(index)\n end\n end", "def same_line(line, start_index, end_index)\n if (start_index > end_index)\n start_index = reverse_direction(line, start_index)\n end_index = reverse_direction(line, end_index)\n line.reverse!\n line[start_index..end_index]\n elsif start_index == end_index\n \"\\nBuddy, have a look around, you are already there...\\n\"\n else\n line[start_index..end_index]\n end\nend", "def source_from_range(source_range) # rubocop:disable Metrics/AbcSize\n current_line = source_range.start_pos.line - 1\n last_line = source_range.end_pos.line - 1\n start_pos = source_range.start_pos.offset - 1\n\n source =\n if current_line == last_line\n engine.lines[current_line][start_pos..(source_range.end_pos.offset - 1)]\n else\n engine.lines[current_line][start_pos..-1]\n end\n\n current_line += 1\n while current_line < last_line\n source += engine.lines[current_line].to_s\n current_line += 1\n end\n\n if source_range.start_pos.line != source_range.end_pos.line\n source += ((engine.lines[current_line] || '')[0...source_range.end_pos.offset]).to_s\n end\n\n source\n end", "def line_and_column(pos); end", "def range_encompassing first_text_element, last_text_element\n first_pos = last_pos = last_limit = nil\n each_with_index do |pair, index|\n if !first_pos && pair.first == first_text_element\n first_pos = pair.last\n end\n if !last_pos && pair.first == last_text_element\n last_pos = pair.last\n last_limit = elmt_offset_at(index+1)\n break\n end\n end\n [first_pos, last_limit]\n end", "def line_range(lineno); end", "def index_from_start(index); end", "def search_text_main(clipped = false)\n text = ''\n if self.event_type == 'sent' \n text = text + self.outgoing_message.get_text_for_indexing + \"\\n\\n\"\n elsif self.event_type == 'followup_sent'\n text = text + self.outgoing_message.get_text_for_indexing + \"\\n\\n\"\n elsif self.event_type == 'response'\n if clipped\n text = text + self.incoming_message.get_text_for_indexing_clipped + \"\\n\\n\"\n else\n text = text + self.incoming_message.get_text_for_indexing_full + \"\\n\\n\"\n end\n elsif self.event_type == 'comment'\n text = text + self.comment.body + \"\\n\\n\"\n else\n # nothing\n end\n return text\n end", "def each_with_depth(from: nil, to: nil, &block)\n Array(lines).each_with_index do |line, index|\n next if index < (from || 0)\n\n depth = line.length - line.lstrip.length\n block.call(line.strip, depth, index)\n\n break if to == index\n end\n\n nil\n end", "def line_index(num)\n\t\tif num == 0\n\t\t\treturn -1\n\t\telsif num <= @line_indices.length\n\t\t\treturn @line_indices[num - 1]\n\t\telsif num == @line_indices.length + 1\n\t\t\treturn @text.length\n\t\telse\n\t\t\treturn -999 # todo\n\t\tend \n\tend", "def text_at(location, offset, length)\n line = lines[location[0] - 1]\n line[location[1] + offset, length]\n end", "def remove_line(line_num)\n\t\tif @line_indices == []\n\t\t\t@text = \"\"\n\t\telse\n\t\t\tlength = line_index(line_num + 1) - line_index(line_num)\n\t\t\t@text[line_index(line_num) + 1 .. line_index(line_num + 1)] = \"\"\n\t\t\t@line_indices.delete_at(line_num)\n\t\t\t(line_num...@line_indices.length).each { |i| @line_indices[i] -= length }\n\t\tend\n\tend", "def get_text_for_indexing_clipped\n return get_body_for_quoting + \"\\n\\n\" + get_attachment_text_clipped\n end", "def index(from: nil, to: nil, &block)\n each_with_depth(from: from, to: to) do |line, depth, index|\n return index if block.call(line, depth, index)\n end\n end", "def position(index)\n return [-1, -1] unless index < string.length\n\n row_start = @line_starts.select { |line_start| line_start <= index }.last\n row = @line_starts.index(row_start)\n column = index - row_start\n [row, column]\n end", "def line_before\n line[0..column - 1].to_s\n end", "def slice_text str, active = nil\n if (active || (active.nil? && (option? :slice))) && (str.include? ' ')\n (str.split SliceHintRx).map {|line| %(<span class=\"line\">#{line}</span>) }.join EOL\n else\n str\n end\n end", "def from_line\n position.new_line\n end", "def select(from: nil, to: nil, &block)\n retval = []\n\n each_with_depth(from: from, to: to) do |line, depth, index|\n retval << line if (block_given? == false || block.call(line, depth, index))\n end\n\n retval\n end", "def last_line_only(range); end", "def last_line_only(range); end", "def last_line_only(range); end", "def line_char_to_offset(text, line, character); end", "def Text2Words(txt, len, where, offset)\n txt.each do |words|\n print \" { { \" \n words.each do |word|\n if word==\"ET\" then\n pos = where.index(\"TERTAUQ\")\n else\n pos = where.index(word.reverse) || where.index(word) \n end\n print \" { %3d, %2d }, \" % [pos+offset, word.length ]\n end\n (len - words.length).times do\n print \" { %3d, %2d }, \" % [0, 0 ]\n end\n puts \" } }, // \" + words.join(\" \")\n end\nend", "def extract_text(offset, length)\n string.slice(offset, length)\n end", "def start_of_word(text,n)\n\treturn text[0,n]\nend", "def line2offsets(line_number)\n offsetlines.select do |offset, lines| \n lines.member?(line_number) \n end.keys\n end", "def replaced_text\n affected_lines_before[column..(column + length - 1)]\n end", "def line_range=(_arg0); end", "def newline_has_from_to(from_to)\n insert_into_transcript if @line_temp[:reading]\n start_reading(from_to[1], from_to[2])\n end", "def each_reverse_newline_index_with_chunk(chunk_source)\n chunk_source.each_chunk do |chunk|\n while(nl_index = chunk.rindex(\"\\n\", (nl_index||chunk.size)-1))\n yield(nl_index, chunk)\n end\n end\n nl_index\nend", "def strip_index(input); end", "def range_by_lines(range); end", "def remove(n = 1)\n left(n)\n @text.slice!(@cursor, n)\n end", "def each_line_with_index(io)\n offset = format.skip\n io.each_line.with_index do |line, index|\n yield(line, index) unless index < offset\n end\n end", "def line_for_offset(offset)\n end", "def trip(line, from, to)\n line = @subway[line]\n from_index = line.index(from)\n to_index = line.index(to)\n\n if from_index < to_index\n line[from_index..to_index]\n else # opposite direction\n line[to_index..from_index].reverse\n end\nend", "def matching_lines(text)\n if @lines.is_a?(RegexpRange)\n @lines.to_range(text)\n else\n @lines\n end\n end", "def source_from_range(source_range)\n current_line = source_range.start_pos.line - 1\n last_line = source_range.end_pos.line - 1\n\n source = engine.lines[current_line][(source_range.start_pos.offset - 1)..-1]\n\n current_line += 1\n while current_line < last_line\n source += \"#{engine.lines[current_line]}\\n\"\n current_line += 1\n end\n\n if source_range.start_pos.line != source_range.end_pos.line &&\n # Sometimes the parser reports ranges ending on the first column of the\n # line after the last line; don't include the last line in this case.\n engine.lines.count == current_line - 1\n source += \"#{engine.lines[current_line][0...source_range.end_pos.offset]}\\n\"\n end\n\n source\n end", "def extract_string(range, strscan); end", "def method_source_lines(file, line_num, context=5)\n # Yeah, we're not memory efficient here.\n lines = Array(File.open(file))\n result = []\n\n min_index = line_num - context - 1\n max_index = line_num + context\n\n max_width = (max_index + 1).to_s.length\n\n (min_index...max_index).each do |index|\n result << [(index + 1).to_s.rjust(max_width), lines[index].rstrip, index == line_num - 1]\n end\n\n result\n end", "def from(index)\n index = 0 if index == :begin\n fail ArgumentError unless (0..@to).include? index\n @from = index\n self\n end", "def pos_on_line(offset)\n end", "def with_around(current_str, i, text, around_quantity)\n prev = (i >= around_quantity) ? # chek count lines previous line with search string\n (i - around_quantity ... i) : (0 ... i)\n after = (i + around_quantity <= text.size) ? # chek count lines after line with search string\n (i + 1 .. i + around_quantity) : (i + 1 .. text.size)\n\n [text[prev],\n red_str(current_str),\n text[after],\n '---'.red_on_green].\n flatten\n end", "def text\n return unless reader\n\n xmin = if right_of\n if [Integer,Float].include?(right_of.class)\n right_of\n elsif xy = reader.text_position(right_of,page)\n xy[:x]\n end\n else\n 0\n end\n xmax = if left_of\n if [Integer,Float].include?(left_of.class)\n left_of\n elsif xy = reader.text_position(left_of,page)\n xy[:x]\n end\n else\n 99999 # TODO: figure out the actual limit?\n end\n\n ymin = if above\n if [Integer,Float].include?(above.class)\n above\n elsif xy = reader.text_position(above,page)\n xy[:y]\n end\n else\n 0\n end\n ymax = if below\n if [Integer,Float].include?(below.class)\n below\n elsif xy = reader.text_position(below,page)\n xy[:y]\n end\n else\n 99999 # TODO: figure out the actual limit?\n end\n\n reader.text_in_region(xmin,xmax,ymin,ymax,page,inclusive)\n end", "def skippast(to)\n @index = @source.index(to, @index)\n @index = (@index.nil?) ? @source.length : @index + to.length\n end", "def task_2(str)\n r = []\n str.each_line do |x|\n ip = x[/^.* - -/]\n d = x[/[\\[].*[\\]]/]\n a = x[/T .* H/]\n if ip && d && a\n r << d[1..-2] + ' FROM: ' + ip[0..-4] + 'TO:' + a[1..-3].upcase\n end\n end\n r\nend", "def drop_from_each_line(n)\n self.lines.map do |line|\n k = 0\n line.chars.drop_while do |x|\n k += 1\n k <= n && x != \"\\n\"\n end.join(\"\")\n end.join(\"\")\n end", "def paragraph_under_cursor\n ( first, _ ), ( last, _ ) = paragraph_under_cursor_pos\n @lines[ first..last ]\n end", "def scrolling_text(text)\n # Good luck\n results = []\n counter = text.length\n new_text = text.upcase \n\n counter.times do \n results << new_text\n head = new_text[0]\n tail = new_text[1..-1]\n new_text = tail + head\n \n end\n results\nend", "def line_offset\n\t\t\t@offset - @line_range.min\n\t\tend", "def lines_of(range)\n min_words = range.first\n max_words = range.last\n words_left = 0\n line = []\n\n @sentences.inject([]) do |result, sentence|\n too_few_words = proc { line.size < min_words || words_left < min_words }\n too_many_words = proc { line.size >= max_words ||\n line.size + words_left > max_words && words_left <= min_words }\n end_line = proc { result << line.join(\" \") and line.clear }\n words = sentence.split\n word_count = words.size\n\n next result << sentence if word_count < min_words * 2\n\n line.clear\n words.each_with_index do |word, i|\n words_left = word_count - i\n if too_few_words[]\n line << word\n end_line.call if word =~ /[,;]$/ && !too_few_words[]\n elsif too_many_words[] || word =~ /^['\"]|^(and|that|or|for|nor|if)$/\n end_line.call\n line << word\n elsif word =~ /[,;]$/\n line << word\n end_line.call\n else\n line << word\n end\n end\n result << line.join(\" \")\n end\n end", "def lines_offset\n @starting_line - 1\n end", "def getLine(theLines, theIndex)\n\n\treturn theLines.fetch(theIndex, EMPTY_LINE);\n\nend", "def get_line_pos(pos)\n lpos = @line_ends.bsearch_index { |x, _| x >= pos }\n return lpos\n end", "def scan_for_index_start_and_end(code, regex)\n res = []\n code.scan(regex) do\n res << {starts: Regexp.last_match.offset(0).first,\n ends: Regexp.last_match.offset(0).last}\n end\n res\nend", "def line_offset(pos=pos())\n p = 0\n string.each_line do |line|\n len = line.length\n return (pos - p) if p + len >= pos\n p += len\n end\n 0\n end", "def line_offset(pos=pos)\n p = 0\n string.each_line do |line|\n len = line.length\n return (pos - p) if p + len >= pos\n p += len\n end\n 0\n end", "def get_line_render_instructions(line_num)\n\t\tstart_line_index = index_of_position(line_num)\n\t\tline = line(line_num)\n\n\t\tinstructions = []\n\n\t\thighlight_index = @highlights.length - 1\n\t\thighlight_index -= 1 while highlight_index > 0 and @highlights[highlight_index][0] > start_line_index\n\t\thighlight = @highlights[highlight_index][1]\n\t\thighlight_index += 1\n\t\tpart_start_index = 0\n\n\t\t(0..line.length).each do |c|\n\t\t\tif c == line.length or (highlight_index < @highlights.length and @highlights[highlight_index][0] == c + start_line_index)\n\t\t\t\tinstructions << [highlight, line[part_start_index ... c]]\n\t\t\t\tbreak if c == line.length\n\t\t\t\thighlight = @highlights[highlight_index][1]\n\t\t\t\thighlight_num += 1\n\t\t\tend\n\t\tend\n\n\t\tinstructions\n\tend", "def around_lines(needle)\n\n file = @file\n pos = file.pos\n result = \"\"\n\n # scan min\n file.seek(pos)\n min = seek_contiguous_min(needle) || pos\n\n # scan max\n file.seek(pos)\n max = seek_contiguous_max(needle) || pos\n\n # for debug\n # p [\n # pos: pos,\n # min: min,\n # max: max\n # ].to_s\n # sleep 0.05\n\n # read\n # - require succeed scan processes\n if max > min\n file.seek(min)\n result = file.read(max - min)\n end\n\n result\n end", "def get_text_for_indexing\n text = self.body.strip\n text.sub!(/Dear .+,/, \"\")\n text.sub!(/[^\\n]+1049\\/2001[^:\\n]+:? ?/, \"\") # XXX: can't be more specific without locale\n self.remove_privacy_sensitive_things!(text)\n return text\n end", "def diff(text)\n @diff ||= begin\n files = affected(text).uniq\n @raw.split(\"Index: \")\n .select { |i| files.any? { |f| i.start_with? f } }\n .map { |i| i.split \"\\n\" }\n .flatten\n end\n end", "def function(str,start_position, end_position) #the method of return substring\n\tstr1=str.split(\"\")\n\tstr2=[]\n\tj=0\n\tfor i in start_position-1...end_position\n\t\tstr2[j]=str1[i]\n\t\tj+=1\n\tend\n\treturn str2\nend", "def trip(line, start_stop, end_stop)\n trip_line = s_line(line)\n p trip_line\n start_index = trip_line.index(start_stop)\n end_index = trip_line.index(end_stop)\n stops = \"\"\n\n if start_index < end_index\n until start_index == end_index\n stops += trip_line[start_index]\n start_index += 1\n end\n else\n until start_index == end_index\n stops += trip_line[start_index]\n start_index -= 1\n end\n end\n return stops\nend", "def get_word_start_marks(startpos, endpos)\n startpos = 0 if startpos < 0\n endpos = self.size if endpos > self.size\n search_str = self[(startpos)..(endpos)]\n return if search_str == nil\n wsmarks = scan_indexes(search_str, /(?<=[^\\p{Word}])\\p{Word}/)\n wsmarks = wsmarks.collect { |x| x + startpos }\n return wsmarks\n end", "def from(position)\n self[position..-1]\n end", "def stopGetter(stop_1, stop_2, line)\n if stop_1 > stop_2\n return line[stop_2..stop_1].reverse!\n else\n return line[stop_1..stop_2]\n end\nend", "def get_index(node_1, node_2, num_nodes)\n if node_1 < node_2 and node_1 < num_nodes and node_2 <= num_nodes\n line = 1\n (1...node_1).each {|i| line += num_nodes - i}\n line += node_2 - node_1 - 1\n puts line\n end\nend", "def line_from_char(index = -1)\n send_message(:LINEFROMCHAR, index.to_i)\n end", "def start_line_number; end", "def start_line_number; end", "def strip_blank_lines\n\t\t# algorithm: keep only the non-blank lines\n\t\t\n\t\t\n\t\t# work inwards from the outside until you fine lines that are not empty\n\t\tmin_i = self.index{ |line| line != \"\" }\n\t\tmax_i = self.rindex{ |line| line != \"\" }\n\t\t\n\t\t\n\t\t# keep only the things inside the range\n\t\trange = (min_i..max_i)\n\t\t\n\t\t\n\t\tunless range.max < range.min # only on ascending\n\t\t\treturn self.each_index.select {|i| range.include? i }\n\t\telse\n\t\t\treturn self.clone\n\t\tend\n\tend", "def substrings_starting_at(string, index)\n substrings_at = []\n string = string[index...string.size]\n (0...string.size).each do |index|\n substrings_at << string[0..index]\n end\n substrings_at\nend", "def paragraph_under_cursor_pos\n if @lines[ @last_row ] =~ /^\\s*$/\n return [\n [ @last_row, 0 ],\n [ @last_row, @lines[ @last_row ].length - 1 ]\n ]\n end\n\n upper_boundary = 0\n lower_boundary = @lines.size - 1\n\n @last_row.downto( 0 ) do |i|\n line = @lines[ i ]\n if line =~ /^\\s*$/\n upper_boundary = i + 1\n break\n end\n end\n\n @last_row.upto( @lines.size - 1 ) do |i|\n line = @lines[ i ]\n if line =~ /^\\s*$/\n lower_boundary = i - 1\n break\n end\n end\n\n [\n [ upper_boundary, 0 ],\n [ lower_boundary, @lines[ lower_boundary ].length - 1 ]\n ]\n end" ]
[ "0.74373615", "0.69180185", "0.68700963", "0.66062117", "0.6275667", "0.6266768", "0.61057496", "0.61057496", "0.61057496", "0.6042144", "0.5999725", "0.59089905", "0.58547854", "0.5843117", "0.5837925", "0.582337", "0.58171666", "0.5802001", "0.57992876", "0.57536846", "0.5752156", "0.5752156", "0.5752156", "0.57515734", "0.56467414", "0.5646116", "0.5617739", "0.56075495", "0.5588407", "0.557525", "0.5541672", "0.55186844", "0.5516715", "0.5513033", "0.5505822", "0.5492313", "0.54866445", "0.54682964", "0.5466249", "0.5455103", "0.5439528", "0.54373825", "0.54178095", "0.53994805", "0.53925955", "0.5392286", "0.5392286", "0.5392286", "0.5382168", "0.5374243", "0.5367923", "0.53561276", "0.53504807", "0.5344513", "0.53274256", "0.5300219", "0.5293013", "0.5290452", "0.5273653", "0.5249906", "0.52483666", "0.5238782", "0.5235403", "0.52330863", "0.5210724", "0.5210263", "0.52098405", "0.51943535", "0.5189632", "0.5188768", "0.5182859", "0.51755655", "0.5168664", "0.51650226", "0.51522374", "0.5150084", "0.5146837", "0.5146285", "0.51436293", "0.51398", "0.51295483", "0.51264405", "0.5121", "0.51014227", "0.5087477", "0.50835466", "0.50789875", "0.5073395", "0.5070539", "0.5067155", "0.5058216", "0.5054176", "0.5053117", "0.5050552", "0.5041271", "0.5040856", "0.5040856", "0.50340533", "0.5032584", "0.50290936" ]
0.8064715
0
Inserts text 'text' at line 'line', before column 'col'
def insert_text(line, col, text) index = index_of_position(line, col) @text.insert(index, text) i = 0 i += 1 while i < @line_indices.length and @line_indices[i] < index (0...text.length).each do |c| if text[c,1] == "\n" @line_indices.insert(i, index + c) i += 1 end end (i ... @line_indices.length).each { |i| @line_indices[i] += text.length } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def insert_text_at_cursor(text) \n\t\tinsert_text(@cursor_row, @cursor_col, text)\n\t\n\t\tif text.include?(\"\\n\")\n\t\t\t#todo what about multiple \\n's\n\t\t\t@cursor_row += 1\n\t\t\t@cursor_col = 0\n\t\t\t#resize_contents(500, line_num_to_coord(@text.num_lines + 1))\n\t\t\temit_changed(@cursor_row - 1)\n\t\telse\n\t\t\t@cursor_col += text.length\n\t\t\temit_changed(@cursor_row)\n\t\tend\n\tend", "def insert_after\r\n @lines.insert(@line_num, TextLineBuffer.new(\"\"))\r\n @line_num = @line_num + 1\r\n end", "def insert_row filename, lineno, text\n d = _read filename\n d.insert(lineno, text)\n _write filename, d\n 0\n end", "def insert_text(row, column, text, style = CharacterStyle.default)\n text.each_char do |char|\n self[row][column] = Character.new(char, style)\n column += 1\n end\n self\n end", "def insert_text_before(text)\r\n text_run = get_run_before\r\n text_run.text = \"#{text_run.text}#{text}\"\r\n end", "def splitrow(row,col)\n\t\ttext = @text[row].dup\n\t\t@text[row] = text[(col)..-1]\n\t\tinsertrow(row,text[0..(col-1)])\n\tend", "def write_str(line,column,text)\n\t\tif text == nil\n\t\t\treturn\n\t\tend\n\t\tCurses.setpos(line,column)\n\t\tCurses.addstr(text)\n\tend", "def overwrite c, text\n pos = text =~ /\\n/\n unless pos\n if text.size > @fileContent[c.line][c.column, @fileContent[c.line].size].size\n @fileContent[c.line] = @fileContent[c.line][0, c.column] + text\n else\n @fileContent[c.line] = @fileContent[c.line][0, c.column] +\n text + @fileContent[c.line][c.column + text.size,\n @fileContent[c.line].size]\n end\n c.moveToColumn c.column + text.size\n else\n if @fileContent[c.line][c.column, @fileContent[c.line].size].size > pos\n nbToDelete = text[pos, text.size].count \"^\\n\"\n insertText c, text\n deleteTextDelete c, nbToDelete\n else\n @fileContent[c.line] = @fileContent[c.line][0, c.column] + text[0, pos]\n c.moveToColumn c.column + pos\n insertText c, text[pos, text.size]\n end\n end\n end", "def replace_line(line)\n cursor = text_cursor\n\n cursor.position = document.character_count - 1\n cursor.set_position(@min_position, Qt::TextCursor::KeepAnchor)\n\n cursor.insert_text line\n\n change_cursor { |c| c.position = document.character_count - 1 }\n\n highlight\n end", "def insert(pos,content)\n content=rowify(content)\n \n enforce_valid(pos)\n\n if pos.is_a? BufferRegion\n unless pos.empty?\n delete(pos)\n end\n cursor=pos.start_pos.to_mutable\n end\n cursor ||= pos.to_mutable\n hanging_line=nil\n row=nil\n content.each do |new_line|\n\n\n row=@rows[cursor.row]\n row = row.clone if row\n\n if hanging_line!=nil\n #this is a wholly new line\n row=new_line.clone\n add_row(cursor.row,row)\n\n else\n\n hanging_line = row.slice!(cursor.column..-1)\n row << new_line\n modify_row(cursor.row,row)\n end\n\n if row.chomp!\n row=\"\"\n add_row(cursor.row+1,row)\n\n\n cursor.next_row!\n end\n cursor.next_row! unless new_line==content.last\n end\n\n\n if hanging_line\n cursor.column=row.length\n row << hanging_line\n modify_row(cursor.row,row)\n\n end\n\n invalidate \n cursor.to_immutable\n end", "def change_line(line_num, text) \n\t\traise \"no newlines here yet please\" if text =~ /\\n/\n\t\n\t\tix1, ix2 = line_index(line_num) + 1, line_index(line_num + 1)\n\t\t@text[ix1...ix2] = text\n\t\t(line_num...@line_indices.length).each { |i| @line_indices[i] += text.length - (ix2 - ix1) }\n\tend", "def insertTextEmptyFile cursor, text\n puts \"\\t\\t#{text.inspect}\"\n @fileContent[cursor.line].replace splitText text\n text\n end", "def handle_text_insertion pos, text\n add_command InsertionCommand.new(pos, text)\n end", "def wrap_text(txt, col)\n txt.gsub(/(.{1,#{col}})( +|$)\\n?|(.{#{col}})/,\"\\\\1\\\\3\\n\")\n end", "def insert_text_after(text)\r\n text_run = get_run_after\r\n text_run.text = \"#{text}#{text_run.text}\"\r\n end", "def insert_line\n down\n\n @lines = lines.insert_line(Vedeu::Editor::Line.new, y)\n\n bol\n\n refresh\n end", "def insert_line lineno=@current_index\n prompt = \"Insert: \"\n maxlen = 80\n #config={}; \n #config[:default] = line\n #ret, str = rb_getstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config)\n ret, str = input_string prompt\n #ret, str = rb_getstr(@form.window, @row+@height-1, @col+1, prompt, maxlen, config)\n $log.debug \" rb_getstr returned #{ret} , #{str} \"\n return if ret != 0\n\n # pad based expect @content not list\n # remove list after a while FIXME\n @list ||= @content\n @list.insert lineno, str\n ## added handler on 2010-05-23 11:46 - undo works - tested in testlistbox.rb\n fire_handler :CHANGE, InputDataEvent.new(0,str.length, self, :INSERT_LINE, lineno, str)\n fire_dimension_changed\n end", "def normal_line(text)\n end", "def put_to_new_next_line(txt)\n l = current_line_range()\n insert_txt_at(txt, l.end + 1)\n set_pos(l.end + 1)\n end", "def replaced_text\n affected_lines_before[column..(column + length - 1)]\n end", "def maatsf_set_next_line(text, pos)\n text.gsub!(/^[ \\t\\r\\f]*/, \"\")\n max_width = maatsf_total_line_width(pos[:y])\n # Create a Dummy Contents\n real_contents = contents # Preserve Real Contents\n self.contents = Bitmap.new(24, 24)\n self.contents.font = real_contents.font.dup\n @atsf_testing = true\n # Do everything\n oline, nline, tw = mapf_format_by_line(text.clone, max_width)\n # Replace old line with the new one\n text.sub!(/#{Regexp.escape(oline)}/m, nline)\n contents.dispose # Dispose dummy contents\n self.contents = real_contents # Restore real contents\n @atsf_testing = false\n return tw\n end", "def setrow(row,text)\n\t\told = @text[row]\n\t\t@text[row] = text\n\tend", "def insert_text(text)\n # Create the mark tag if not exist\n @buffer.insert(@buffer.end_iter, text)\n if (not @buffer.get_mark('end_mark'))\n @buffer.create_mark('end_mark', @buffer.end_iter, false)\n end\n\n # Save our offset\n @@offset = @buffer.end_iter.offset\n\n # Scrolled the view until the end of the buffer\n @textview.scroll_mark_onscreen(@buffer.get_mark('end_mark'))\n end", "def add_line(line)\n @text_lines << line.upcase_trim\n end", "def insert(text)\n normal \"i#{text}\"\n end", "def move(line, column = T.unsafe(nil)); end", "def move(line, column = T.unsafe(nil)); end", "def insert_after_line(file, insert, regex = /^## Next/)\n tempfile = File.open(\"#{file}.tmp\", \"w\")\n f = File.new(file)\n f.each do |line|\n tempfile << line\n next unless line =~ regex\n\n tempfile << \"\\n\"\n tempfile << insert\n tempfile << \"\\n\"\n end\n f.close\n tempfile.close\n\n FileUtils.mv(\"#{file}.tmp\", file)\nend", "def insert(text, at: caret)\n editable? and @native.insert_text(at.to_i, text.to_s, text.to_s.length)\n end", "def insert_text(position, pattern, new_text)\n index = case pattern\n when Regexp\n if match = @body.match(pattern)\n match.offset(0)[position == :before ? 0 : 1]\n else\n @body.size\n end\n else\n pattern\n end\n @body.insert index, new_text\n end", "def insertText cursor, text\n if @fileContent.size == 1 and @fileContent[0] == \"\"\n dataStr = insertTextEmptyFile cursor, text\n else\n dataStr = insertTextFilledFile cursor, text\n end\n splitSize = insertTextSplitFlatten cursor\n insertTextCursorReplacement text, cursor, splitSize, dataStr\n end", "def append(row,text)\n\t\t@text[row] = @text[row].dup\n\t\t@text[row] += text\n\tend", "def line_before\n line[0..column - 1].to_s\n end", "def highlight(row,scol,ecol)\n\t\t# only do rows that are on the screen\n\t\tif row < @linefeed then return end\n\t\tif row > (@linefeed + $screen.rows - 2) then return end\n\n\t\tif @text[row].length < 1 then return end\n\n\t\t# convert pos in text to pos on screen\n\t\tsc = bc2sc(row,scol)\n\t\tec = bc2sc(row,ecol)\n\n\t\t# replace tabs with spaces\n\t\tsline = tabs2spaces(@text[row])\n\t\t# get just string of interest\n\t\tif sc < @colfeed then sc = @colfeed end\n\t\tif ec < @colfeed then return end\n\t\tstr = sline[sc..ec]\n\t\tif ec == sline.length then str += \" \" end\n\t\tssc = sc - @colfeed\n\t\tsec = ec - @colfeed\n\n\t\tif (str.length+ssc) >= $screen.cols\n\t\t\tstr = str[0,($screen.cols-ssc)]\n\t\tend\n\n\t\t$screen.text_reverse(true)\n\t\t$screen.write_str((row-@linefeed+1),ssc,str)\n\t\t$screen.text_reverse(false)\n\tend", "def wrap_text(txt, col = 80)\n txt.gsub(/(.{1,#{col}})( +|$\\n?)|(.{1,#{col}})/,\n \"\\\\1\\\\3\\n\")\n end", "def insert_text_at_line_number(source, target_file, line_number)\n if line_number > 0\n line_number -= 1\n file = IO.readlines(target_file)\n file.insert((line_number), check_source_type(source))\n File.open(target_file, \"w\") do |x|\n x.puts file\n end\n else\n raise ArgumentError, \"Line number must be 1 or higher.\".red\n end\n end", "def write_line(row,colfeed,line)\n\n\t\tif line == nil || line == \"\"\n\t\t\treturn\n\t\tend\n\n\t\twrite_str(row,0,\" \"*@cols) # clear row\n\n\t\tsubstrings = line.split($color) # split at color escape\n\n\t\t# Write from colfeed to first color escape.\n\t\t# If colfeed is larger than the first substring,\n\t\t# this will naturally write nothing.\n\t\twrite_str(row,0,substrings[0][colfeed,@cols])\n\t\tpos = substrings[0].length\n\t\tsubstrings = substrings[1..-1]\n\t\treturn if substrings == nil\n\n\t\t# loop over remaining parts of the line\n\t\tsubstrings.each{|substring|\n\t\t\tcolorcode = substring[0].chr\n\t\t\tsubstring = substring[1..-1]\n\t\t\tnext if substring == nil\n\t\t\tcase colorcode\n\t\t\t\twhen $color_white then set_color(Curses::COLOR_WHITE)\n\t\t\t\twhen $color_red then set_color(Curses::COLOR_RED)\n\t\t\t\twhen $color_green then set_color(Curses::COLOR_GREEN)\n\t\t\t\twhen $color_yellow then set_color(Curses::COLOR_YELLOW)\n\t\t\t\twhen $color_blue then set_color(Curses::COLOR_BLUE)\n\t\t\t\twhen $color_magenta then set_color(Curses::COLOR_MAGENTA)\n\t\t\t\twhen $color_cyan then set_color(Curses::COLOR_CYAN)\n\t\t\t\twhen $color_reverse then @screen.attron(Curses::A_REVERSE)\n\t\t\t\twhen $color_normal then @screen.attroff(Curses::A_REVERSE)\n\t\t\tend\n\t\t\t# pos is position in the line.\n\t\t\tif pos < colfeed\n\t\t\t\t# We must chop off first part of the substring,\n\t\t\t\t# because we are writing off the left edge of the screen.\n\t\t\t\tstr_start = colfeed - pos\n\t\t\t\tcol = 0\n\t\t\telse\n\t\t\t\t# We write the entire string, but starting some number of\n\t\t\t\t# spaces in from the edge.\n\t\t\t\tcol = pos - colfeed\n\t\t\t\tstr_start = 0\n\t\t\tend\n\t\t\twrite_str(row,col,substring[str_start,(@cols-col)])\n\t\t\tpos += substring.length\n\t\t}\n\tend", "def pre_process(text_line)\n text_line\n end", "def add_instant_text(text)\n @lines.push(text)\n refresh\n end", "def sub(text, regexp, with)\n linestart = text.index('insert linestart')\n lineend = linestart.lineend\n line = text.get(linestart, lineend)\n\n text.replace(linestart, lineend, line) if line.sub!(regexp, with)\n end", "def line_and_column(pos); end", "def add_line(line)\n @tip.string_content += line.slice(@offset, line.length) + '\\n'\n end", "def addchar(c)\n\t\tif @marked == false\n\t\t\tinsertchar(@row,@col,c.chr)\n\t\telse\n\t\t\tmark_row,row = ordered_mark_rows\n\t\t\tfor r in mark_row..row\n\t\t\t\tif (@text[r].length==0)&&((c==?\\s)||(c==?\\t)||(c==$ctrl_i)||(c==$space))\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tif @colmode\n\t\t\t\t\tsc = bc2sc(@row,@col)\n\t\t\t\t\tcc = sc2bc(r,sc)\n\t\t\t\t\tif(cc>@text[r].length) then next end\n\t\t\t\t\tinsertchar(r,cc,c.chr)\n\t\t\t\telse\n\t\t\t\t\tinsertchar(r,0,c.chr)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tcursor_right\n\t\tif @linewrap\n\t\t\tjustify(true)\n\t\tend\n\tend", "def wrap_text(txt, col = 80)\n txt.gsub(/(.{1,#{col}})( +|$\\n?)|(.{1,#{col}})/, \"\\\\1\\\\3\\n\") \nend", "def insert_word(word, x, y)\n for i in 0...word.length\n @grid[x][y+i] = word[i]\n end\n end", "def initialize(text, line, column)\n @text = text\n @line = line\n @column = column\n end", "def add_location(path, line); end", "def initialize(text, line, column)\n @text = text\n @line = line\n @column = column\n end", "def _patch_part(text_part, text_orig, sline, eline)\n lines = text_orig.split(\"\\n\", -1)\n lines[(sline -1) ..(eline-1)] = text_part.split(\"\\n\", -1)\n lines.join(\"\\n\")\n end", "def insert(cursor, string)\n string.split(Pattern).each_with_index do |str, i|\n if i.even?\n cursor.insert_text str\n else\n enable_ansi_code(cursor, str)\n end\n end\n end", "def update_line(y,line=nil)\n if !line\n line = AnsiTerm::String.new(buffer.lines(y))\n end\n if !line.is_a?(AnsiTerm::String)\n line = AnsiTerm::String.new(line)\n end\n\n if line.index(\"\\t\").nil?\n return line\n end\n \n pos = 0\n max = line.length\n col = 0\n nline = AnsiTerm::String.new\n first = true\n while (pos < max)\n ch = line.char_at(pos)\n if ch == \"\\t\"\n t = 4-(col%4)\n nline << TABS[4-t]\n col += t\n else\n nline << line[pos]\n col+= 1\n end\n pos+= 1\n end\n\n nline\n end", "def maatsf_paragraph_new_line(orig_method, text, pos, *args, &block)\n tw = nil\n tw = maatsf_set_next_line(text, pos) if $game_message.paragraph_format && !text.nil? && !text.empty?\n orig_method.call(text, pos, *args, &block) # Call original Method\n # Alignment\n next_line = text[/^[^\\n\\f]*/]\n align = maatsf_line_alignment(next_line)\n if align != 0 # If not left aligned\n if tw.nil?\n @atsf_testing = true\n tw = mapf_calc_line_width(next_line)\n @atsf_testing = false\n end\n space = maatsf_total_line_width(pos[:y]) - tw\n pos[:x] = [pos[:x] + (space / (align == 1 ? 2 : 1)), pos[:x]].max\n end\n end", "def insert_text(text:)\n {\n method: \"Input.insertText\",\n params: { text: text }.compact\n }\n end", "def line(pos = T.unsafe(nil)); end", "def insert_text(position, pattern, new_text, indentation = 4)\n index = case pattern\n when Regexp\n if match = @body.match(pattern)\n match.offset(0)[position == :before ? 0 : 1]\n else\n @body.size\n end\n else\n pattern\n end\n @body.insert index, indent(indentation, new_text)\n end", "def rl_insert_text(string)\r\n string.delete!(0.chr)\r\n l = string.length\r\n return 0 if (l == 0)\r\n\r\n if (@rl_end + l >= @rl_line_buffer.length)\r\n rl_extend_line_buffer(@rl_end + l)\r\n end\r\n @rl_line_buffer[@rl_point,0] = string\r\n\r\n # Remember how to undo this if we aren't undoing something.\r\n if (!@_rl_doing_an_undo)\r\n # If possible and desirable, concatenate the undos.\r\n if ((l == 1) &&\r\n @rl_undo_list &&\r\n (@rl_undo_list.what == UNDO_INSERT) &&\r\n (@rl_undo_list.end == @rl_point) &&\r\n (@rl_undo_list.end - @rl_undo_list.start < 20))\r\n @rl_undo_list.end+=1\r\n else\r\n rl_add_undo(UNDO_INSERT, @rl_point, @rl_point + l, nil)\r\n end\r\n end\r\n @rl_point += l\r\n @rl_end += l\r\n if @rl_line_buffer.length <= @rl_end\r\n @rl_line_buffer << 0.chr * (@rl_end - @rl_line_buffer.length + 1)\r\n else\r\n @rl_line_buffer[@rl_end] = \"\\0\"\r\n end\r\n l\r\n end", "def line_for_position(position); end", "def line_for_position(position); end", "def line_for_position(position); end", "def insert(text)\n chars = @text.scan(/./m)\n return if chars.size >= @max_length\n # limiting characters\n new_chars = text.scan(/./m)\n if chars.size + new_chars.size > @max_length\n new_chars = new_chars[0, @max_length - chars.size]\n end\n # it's possible that text contains tab characters which are forbidden\n while new_chars.include?(\"\\t\")\n new_chars.delete(\"\\t\")\n end\n return if new_chars.size == 0\n # split text at cursor position\n left = (@cursor_position > 0 ? chars[0, @cursor_position] : [])\n if @cursor_position < chars.size\n right = chars[@cursor_position, chars.size - @cursor_position]\n else\n right = []\n end\n # move cursor\n @cursor_position += new_chars.size\n # put together the split halves with the new text inbetween\n self.text = (left + new_chars + right).join\n self.reset_cursor_blinking\n end", "def rl_replace_line(text, clear_undo)\r\n len = text.delete(0.chr).length\r\n @rl_line_buffer = text.dup + 0.chr\r\n @rl_end = len\r\n if (clear_undo)\r\n rl_free_undo_list()\r\n end\r\n _rl_fix_point(true)\r\n end", "def insert_into_transcript\n @transcript_lines << {\n transcript_id: @transcript_id,\n start_time: @line_temp[:from],\n end_time: @line_temp[:to],\n original_text: @line_temp[:lines].join(' '),\n sequence: (@line_number - 1)\n }\n @line_number += 1\n end", "def move(line, column=0)\n \"\\e[#{line.to_i};#{column.to_i}H\"\n end", "def pos_on_line(offset)\n end", "def before_record(text_line)\n new_line = before_process(text_line)\n return new_line.nil? ? '' : pad_record(new_line)\n end", "def draw(text)\n printf \"%s %-#{(columns / 3) - 5}s \" % [V_SEP, text]\n end", "def insert_from_line( line )\n begin\n row = line.chomp.parse_csv\n @cached << record( row )\n rescue\n print '#'\n end\n\n flush_inserts if @cached.size >= CACHE_SIZE\n end", "def tree_at(line, column); end", "def display(line, column = T.unsafe(nil)); end", "def display(line, column = T.unsafe(nil)); end", "def display(line, column = T.unsafe(nil)); end", "def insert buffer, text\n @frames[buffer].fillBuffer buffer, text\n end", "def replace_instant_text(text)\n @lines.pop\n @lines.push(text)\n refresh\n end", "def offset_on_line(offset)\n end", "def set_cursor_position(row, col)\n\t\tinvalid_rows = [@cursor_row, row]\n\t\t@cursor_row, @cursor_col = row, col\n\t\tif @cursor_row < first_line_in_view\n\t\t\tset_contents_pos(0, line_num_to_coord(@cursor_row))\n\t\t\temit_changed(nil)\n\t\telsif @cursor_row > last_line_in_view\n\t\t\tset_contents_pos(0, line_num_to_coord(@cursor_row - num_lines_in_view))\n\t\t\temit_changed(nil)\n\t\tend\n\tend", "def cmd_after_replace(file, lineno, content, cmd)\n change_line(file, lineno, content)\n cmd\n end", "def write text\n\t\t@search_text = @line.text = text\n\tend", "def write(x,y,text)\n Curses.setpos(x,y)\n text.each_line do |line|\n break if x == Curses.lines-1\n Curses.addstr(line) \n x += 1\n end\n for x in 1..Curses.lines\n Curses.deleteln\n end\n Curses.setpos(text.lines.count-1,0)\n Curses.addstr(text.lines.take(3)[2]) unless text.lines.take(3)[2].nil?\n Curses.setpos(text.lines.count-1,0)\n end", "def node_at(line, column); end", "def replace(line)\n # get the actual offset\n start = @buffer.get_iter_at_offset(@@offset)\n\n # Delete all\n @buffer.delete(start, @buffer.end_iter)\n\n # Save the new offset\n @@offset = @buffer.end_iter.offset\n\n # insert the old command\n @buffer.insert(@buffer.end_iter, line)\n end", "def insert_before(range, content); end", "def insert_before(range, content); end", "def insert_before(range, content); end", "def insert_before(range, content); end", "def insert_before(range, content); end", "def insert_before(range, content); end", "def insert_before(range, content); end", "def insert_before(range, content); end", "def addtext(url)\n img = MiniMagick::Image.open(IMAGE_FILE)\n rows = split_text_into_rows(text)\n addrow(img, rows[0], POSITION_1)\n addrow(img, rows[1], POSITION_2)\n addrow(img, rows[2], POSITION_3)\n addrow(img, rows[3], POSITION_4)\n addrow(img, rows[4], POSITION_5)\n addrow(img, rows[5], POSITION_6)\n save_to_file(img, url)\n end", "def line_after\n line[column..-1].to_s\n end", "def line_char_to_offset(text, line, character); end", "def place_marker(marker, column)\n column -= 1 #index 0\n z = @board.length - 1\n until @board[z][column] == \"_\"\n z -= 1\n end\n @board[x][column] = marker\n end", "def insert_line_after_match(regex, newline)\n search_match(regex, newline, 'i', 1)\n end", "def update_line(line_text)\n updated_line_text = line_text\n # replace outlook list format with textile list format:\n updated_line_text.gsub!(/^[\\u00b7]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /,\"* \") # middot - middle dot\n updated_line_text.gsub!(/^[\\u2022]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /,\"* \") # bull - bullet\n updated_line_text.gsub!(/^o&nbsp;&nbsp; /,\"** \") # second level bullet\n updated_line_text.gsub!(/^[\\u00A7]&nbsp; /,\"*** \") # 3rd level bullet (section entity)\n \n updated_line_text.gsub!(/^[0-9]+\\.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /, \"# \")\n \n updated_line_text\n end", "def draw_text_indent(line, string, additional=0)\n return if line <= 0\n y = 32 * line - 32\n self.contents.draw_text(35+additional, y, @width, 32, string)\n end", "def line_at(start_x, str)\n x = start_x\n move_to_x(start_x) if start_x > 1\n str.length.times do |i|\n $stdout.putc str[i] if x > 0 && x < @width\n x += 1\n end\n $stdout.putc \"\\n\"\n end", "def editor_insert_line!\n Vedeu.bind(:_editor_insert_line_) do |name|\n Vedeu.documents.by_name(name).insert_line\n end\n end", "def text_file_scan_and_rewrite(my_file_name)\n\n textfile = File.open(my_file_name, 'r+') #open file for read/write\n\n all_lines_from_file = textfile.read #read all the records in the file\n\n if word_position = all_lines_from_file =~ /word/ #check for \"word\" and if found note position in string\n all_lines_from_file.insert(word_position, 'inserted ') #put \"inserted \" in front of \"word\"\n textfile.rewind #reset to beginning of file\n textfile.puts all_lines_from_file #write new data to file\n end\n textfile.close\nend", "def write_line(line)\n text = line\n text.gsub!('~~~~{.cpp}', '```cpp')\n text.gsub!(\"~~~~\",\"```\")\n\n if text.include? \"![\"\n puts \"Image found in #{@current_content_block}.\\n...please fix #{text}\\n\"\n end\n\n @content << text\nend", "def overwriteText cursor, text\n if cursor.isAtEOL? or cursor.isAtEOF?\n insertText cursor, text\n else\n overwrite cursor, text\n end\n end" ]
[ "0.7264024", "0.6832584", "0.6745029", "0.66017145", "0.6530093", "0.63915396", "0.6282005", "0.6271797", "0.62317735", "0.61838007", "0.6153853", "0.614321", "0.6102728", "0.6093982", "0.606195", "0.60552585", "0.60202473", "0.600556", "0.5996389", "0.598623", "0.59469384", "0.5918847", "0.59099597", "0.58943224", "0.58576894", "0.5840166", "0.5840166", "0.58320683", "0.581154", "0.5809705", "0.58094054", "0.5794915", "0.57947594", "0.5791906", "0.5774971", "0.5770358", "0.5743389", "0.57405126", "0.5727988", "0.5698793", "0.56925076", "0.5679499", "0.567905", "0.56780016", "0.5674401", "0.56713265", "0.5651082", "0.56508833", "0.56357217", "0.5635277", "0.5634979", "0.5626136", "0.560777", "0.55952424", "0.5588289", "0.558233", "0.5565619", "0.5565619", "0.5565619", "0.55537933", "0.55430764", "0.5541908", "0.55348897", "0.5525106", "0.55197066", "0.551616", "0.5512204", "0.55009145", "0.5499827", "0.5499827", "0.5499827", "0.54996145", "0.54868114", "0.54734033", "0.54682755", "0.5457072", "0.5456489", "0.5449441", "0.54354763", "0.54318637", "0.5429661", "0.5429661", "0.5429661", "0.5429661", "0.5429661", "0.5429661", "0.5429661", "0.5429661", "0.5419558", "0.5409813", "0.54069257", "0.5381374", "0.5375974", "0.5364822", "0.5364089", "0.5343108", "0.5342106", "0.53388435", "0.53364843", "0.5335357" ]
0.84449697
0
Changes the text of line 'line_num' to 'text
def change_line(line_num, text) raise "no newlines here yet please" if text =~ /\n/ ix1, ix2 = line_index(line_num) + 1, line_index(line_num + 1) @text[ix1...ix2] = text (line_num...@line_indices.length).each { |i| @line_indices[i] += text.length - (ix2 - ix1) } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def normal_line(text)\n end", "def remove_line(line_num)\n\t\tif @line_indices == []\n\t\t\t@text = \"\"\n\t\telse\n\t\t\tlength = line_index(line_num + 1) - line_index(line_num)\n\t\t\t@text[line_index(line_num) + 1 .. line_index(line_num + 1)] = \"\"\n\t\t\t@line_indices.delete_at(line_num)\n\t\t\t(line_num...@line_indices.length).each { |i| @line_indices[i] -= length }\n\t\tend\n\tend", "def original_text\n @line\n end", "def set_line(line_number)\n @line_number = line_number\n end", "def insert_text(line, col, text) \n\t\tindex = index_of_position(line, col)\n\t\t@text.insert(index, text)\n\t\ti = 0\n\t\ti += 1 while i < @line_indices.length and @line_indices[i] < index\n\t\t(0...text.length).each do |c|\n\t\t\tif text[c,1] == \"\\n\"\n\t\t\t\t@line_indices.insert(i, index + c)\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\t\t(i ... @line_indices.length).each { |i| @line_indices[i] += text.length }\n\tend", "def write text\n\t\t@search_text = @line.text = text\n\tend", "def update_line(line_text)\n updated_line_text = line_text\n # replace outlook list format with textile list format:\n updated_line_text.gsub!(/^[\\u00b7]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /,\"* \") # middot - middle dot\n updated_line_text.gsub!(/^[\\u2022]&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /,\"* \") # bull - bullet\n updated_line_text.gsub!(/^o&nbsp;&nbsp; /,\"** \") # second level bullet\n updated_line_text.gsub!(/^[\\u00A7]&nbsp; /,\"*** \") # 3rd level bullet (section entity)\n \n updated_line_text.gsub!(/^[0-9]+\\.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /, \"# \")\n \n updated_line_text\n end", "def line(number); end", "def set_textline\n @textline = Textline.find(params[:id])\n end", "def pre_process(text_line)\n text_line\n end", "def draw_line(index)\n rect = Rect.new(0, 0, 0, 0)\n rect.x += 4\n rect.y += index * WLH\n rect.width = contents.width - 8\n rect.height = WLH\n self.contents.clear_rect(rect)\n self.contents.font.color = normal_color\n self.contents.draw_text(rect, @lines[index])\n end", "def line(number)\n end", "def update_line_numbers!\n each_with_index do |lo, new_line_number|\n lo.line_number = new_line_number\n end\n end", "def text=(text); end", "def update_counter(text)\n number_of_newlines = text.count(\"\\n\")\n\n if number_of_newlines > 0\n @line += text.count(\"\\n\")\n @column = text.length - text.rindex(\"\\n\")\n else\n @column += text.length\n end\n end", "def set_text(text); end", "def replaced_text\n affected_lines_before[column..(column + length - 1)]\n end", "def insert_text_at_line_number(source, target_file, line_number)\n if line_number > 0\n line_number -= 1\n file = IO.readlines(target_file)\n file.insert((line_number), check_source_type(source))\n File.open(target_file, \"w\") do |x|\n x.puts file\n end\n else\n raise ArgumentError, \"Line number must be 1 or higher.\".red\n end\n end", "def setrow(row,text)\n\t\told = @text[row]\n\t\t@text[row] = text\n\tend", "def replace_text(text)\n @txt .set_editable(true) # .freeze\n @txt .buffer .set_text(\"\")\n# hdr, value = text .split(\"\\n\\n\", 2)\n# hdr .to_s .each_line{|line|\n# case line\n# when /^Subject:/ ;color = BLUE\n# when /^X-SC-Subject:/ ;color = BLUE\n# when /^From:/ ;color = PURPLE\n# #when /^To:|Cc:/ ;color = ORANGE\n# #when /^Date:/ ;color = GREEN\n# when /^X-SC-(Time|Day):/ ;color = RED\n# else ;color = BLACK\n# end\n# @txt .insert(nil, color, nil, line) if line != ''\n# }\n# @txt .insert(nil, RED, WHITE, hdr .to_s)\n# @txt .insert(nil, BLACK, nil, \"\\n\\n\" + value .to_s)\n\n @txt .buffer .insert(@txt.buffer.start_iter, MhcKconv::todisp(text))\n @txt .set_editable(@text_editable) #.thaw\n end", "def setLine (line)\n @line = line\n end", "def edit_line lineno=@current_index\n line = self[lineno]\n prompt = \"Edit: \"\n maxlen = 80\n config={}; \n oldline = line.dup\n config[:default] = line\n ret, str = rb_getstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config)\n $log.debug \" rb_getstr returned #{ret} , #{str} \"\n return if ret != 0\n # we possibly cou;d have done []= but maybe in textpad or something that would replace a row pointer ??\n self[lineno].replace(str)\n fire_handler :CHANGE, InputDataEvent.new(0,oldline.length, self, :DELETE_LINE, lineno, oldline) # 2008-12-24 18:34 \n fire_handler :CHANGE, InputDataEvent.new(0,str.length, self, :INSERT_LINE, lineno, str)\n fire_row_changed lineno\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line_for_position(position); end", "def line_for_position(position); end", "def line_for_position(position); end", "def maatsf_set_next_line(text, pos)\n text.gsub!(/^[ \\t\\r\\f]*/, \"\")\n max_width = maatsf_total_line_width(pos[:y])\n # Create a Dummy Contents\n real_contents = contents # Preserve Real Contents\n self.contents = Bitmap.new(24, 24)\n self.contents.font = real_contents.font.dup\n @atsf_testing = true\n # Do everything\n oline, nline, tw = mapf_format_by_line(text.clone, max_width)\n # Replace old line with the new one\n text.sub!(/#{Regexp.escape(oline)}/m, nline)\n contents.dispose # Dispose dummy contents\n self.contents = real_contents # Restore real contents\n @atsf_testing = false\n return tw\n end", "def line_index(num)\n\t\tif num == 0\n\t\t\treturn -1\n\t\telsif num <= @line_indices.length\n\t\t\treturn @line_indices[num - 1]\n\t\telsif num == @line_indices.length + 1\n\t\t\treturn @text.length\n\t\telse\n\t\t\treturn -999 # todo\n\t\tend \n\tend", "def change_line(file, lineno, new_line)\n lines = File.readlines(file).tap { |c| c[lineno - 1] = \"#{new_line}\\n\" }\n\n File.open(file, \"w\") { |f| f.write(lines.join) }\n end", "def replace_instant_text(text)\n @lines.pop\n @lines.push(text)\n refresh\n end", "def _patch_part(text_part, text_orig, sline, eline)\n lines = text_orig.split(\"\\n\", -1)\n lines[(sline -1) ..(eline-1)] = text_part.split(\"\\n\", -1)\n lines.join(\"\\n\")\n end", "def text=(new_text)\n @text = new_text\n refresh\n update_cursor\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def notify_line(lineno, count, text)\n unless @path_notified\n Concov.error(\"path of original source code is not found\") \n end\n\n @blk.call(:line, lineno, count, text)\n end", "def line_numbering(value)\n @document_builder.line_numbering = value\n end", "def add_line(line)\n @text_lines << line.upcase_trim\n end", "def draw_text(line, string, even_text = false, width = nil)\n return if line <= 0\n y = 32 * line - 32\n if even_text\n if width != nil\n draw_even_text(0, y, width, 32, string)\n else\n draw_even_text(0, y, @width, 32, string)\n end\n else\n self.contents.draw_text(0, y, @width, 32, string)\n end\n end", "def line_at(filename, line_number)\n source_reload\n\n return \"\\n\" unless File.exist?(filename)\n line = Tracer::Single.get_line(filename, line_number)\n\n return \"#{line.gsub(/^\\s+/, '').chomp}\"\n end", "def new_text=(value)\n @new_text = value\n end", "def modline(line)\n %Q{<tr class=\"changes line\">} +\n render_comment_count(line) +\n %Q{<td class=\"line-numbers commentable\">#{line.old_number}</td>} +\n %Q{<td class=\"line-numbers commentable\">#{line.new_number}</td>} +\n %Q{<td class=\"code unchanged mod\">#{render_line(line)}</td></tr>}\n end", "def update_line(y,line=nil)\n if !line\n line = AnsiTerm::String.new(buffer.lines(y))\n end\n if !line.is_a?(AnsiTerm::String)\n line = AnsiTerm::String.new(line)\n end\n\n if line.index(\"\\t\").nil?\n return line\n end\n \n pos = 0\n max = line.length\n col = 0\n nline = AnsiTerm::String.new\n first = true\n while (pos < max)\n ch = line.char_at(pos)\n if ch == \"\\t\"\n t = 4-(col%4)\n nline << TABS[4-t]\n col += t\n else\n nline << line[pos]\n col+= 1\n end\n pos+= 1\n end\n\n nline\n end", "def convert_line(line_num)\n return '' unless @callouts.key? line_num\n\n @callouts[line_num]\n .map { |num| convert_callout(num) }\n .join(' ')\n end", "def update_raw_text(item); end", "def update_raw_text(item); end", "def write_str(line,column,text)\n\t\tif text == nil\n\t\t\treturn\n\t\tend\n\t\tCurses.setpos(line,column)\n\t\tCurses.addstr(text)\n\tend", "def line_at(filename, line_number) # :nodoc:\n line = LineCache::getline(filename, line_number, @reload_on_change)\n return \"\\n\" unless line\n return line.gsub(/^\\s+/, '').chomp\n end", "def original_line; end", "def parse_line(lineno)\n @native_text[lineno] = @content_type_handler.parse_line( @list[lineno]) \n end", "def original_line_text(line)\n \n #if line.print_change == true\n rev_line_class = 'rev_row' \n #else\n # rev_line_class = 'rev_row_strike'\n #end\n \n last_clause_change = Change.where(:specline_id => line.specline_id).last\n if line[:id] == last_clause_change[:id] \n \"<table width='100%' class='rev_table'><tr id='#{line.id.to_s}' class='#{rev_line_class}'><td class='rev_row_padding'>#{line_content(line)}</td><td class='rev_line_menu_mob'>#{rev_mob_menu(line)}</td><td class='rev_line_menu'>#{reinstate_original_line(line)}#{change_info(line)}</td></tr><tr class='rev_mob_menu_popup'><td class='mob_rev_menu' colspan=3 >#{reinstate_original_line(line)}#{change_info(line)}</td></tr></table>\".html_safe \n else\n \"<table width='100%' class='rev_table'><tr id='#{line.id.to_s}' class='#{rev_line_class}'><td class='rev_row_padding'>#{line_content(line)}</td><td class='rev_line_menu_mob'>#{rev_mob_menu(line)}</td><td class='rev_line_menu'>#{change_info(line)}</td></tr><tr class='rev_mob_menu_popup'><td class='mob_rev_menu' colspan=3 >#{change_info(line)}</td></tr></table>\".html_safe \n end \n end", "def move increment\n\t\tnew_text = Array.new\n\t\tif increment > 0\n\t\t\t@text_spacer += \" \" * increment\n\t\telse\n\t\t\t@text_spacer = @text_spacer[1..increment]\n\t\tend\n\t\t@text.split(\"\\n\").each do |line|\n if increment > 0 \n line = (\" \" * increment) + line\n\t\t\telsif increment < 0 \n\t\t\t line = line[increment.abs..line.size]\n\t\t\tend\n\t\t\tnew_text << line\n\t end\n\t\t@text = new_text.join \"\\n\"\n\tend", "def update(text); end", "def replace_line(line)\n cursor = text_cursor\n\n cursor.position = document.character_count - 1\n cursor.set_position(@min_position, Qt::TextCursor::KeepAnchor)\n\n cursor.insert_text line\n\n change_cursor { |c| c.position = document.character_count - 1 }\n\n highlight\n end", "def line_one=(line_one)\n @line_one = line_one\n end", "def text_at(location, offset, length)\n line = lines[location[0] - 1]\n line[location[1] + offset, length]\n end", "def rl_replace_line(text, clear_undo)\r\n len = text.delete(0.chr).length\r\n @rl_line_buffer = text.dup + 0.chr\r\n @rl_end = len\r\n if (clear_undo)\r\n rl_free_undo_list()\r\n end\r\n _rl_fix_point(true)\r\n end", "def initialize(path, line_number, line)\r\n @path = path\r\n @line_number = line_number\r\n @line = line\r\n @colorize_line = @line.gsub('<', '&lt;')\r\n @colorize_line = @colorize_line.gsub('>', '&gt;')\r\n end", "def update(text)\n text\n end", "def line=(_); end", "def line=(_); end", "def line=(line)\n @session.request(:vim_set_current_line, line)\n end", "def update_text_field(new_value)\n self.row.text_field.text = row_value\n end", "def line\n\t\t\t@line.set(buffer.line.start, buffer.line.end)\n\t\tend", "def current_line_of_text\n @file_text.split(\"\\n\").at(lineno - 1) || ''\n end", "def add_instant_text(text)\n @lines.push(text)\n refresh\n end", "def update_text_field(new_value)\n self.row.text_field.text = row_value.to_s\n end", "def insert_text_at_cursor(text) \n\t\tinsert_text(@cursor_row, @cursor_col, text)\n\t\n\t\tif text.include?(\"\\n\")\n\t\t\t#todo what about multiple \\n's\n\t\t\t@cursor_row += 1\n\t\t\t@cursor_col = 0\n\t\t\t#resize_contents(500, line_num_to_coord(@text.num_lines + 1))\n\t\t\temit_changed(@cursor_row - 1)\n\t\telse\n\t\t\t@cursor_col += text.length\n\t\t\temit_changed(@cursor_row)\n\t\tend\n\tend", "def line(num) lines(num, 1) end", "def transaction_set_line_number(index)\n ['LX', index.to_s.rjust(4, '0')].join(@element_seperator)\n end", "def new_line!(number)\n if @preprocessor.line_first\n @packet.send_packet\n @packet.add_line(number.to_i)\n else\n @packet.add_line(number.to_i)\n @packet.send_packet\n end\nend", "def line_num; end", "def cmd_after_replace(file, lineno, content, cmd)\n change_line(file, lineno, content)\n cmd\n end", "def update( text )\n text\n end", "def after_process(text_line)\n nil\n end", "def add_text(text); end", "def text_position=(pos)\n end", "def project_to_line\n end", "def lines(start, num) \n\t\t@text[index_of_position(start)...index_of_position(start + num) - 1]\n\tend", "def render_line(line)\n raise NotImplementedError\n end", "def set_original_text(text, lang_code)\n text_record.set_original_text(text, lang_code)\n end", "def set_text(text)\n @text = text\n end", "def lineno=(num)\n num = Maglev::Type.coerce_to(num, Fixnum, :to_int)\n @_st_lineno = num\n $. = num\n num\n end", "def line\n buffer[line_number]\n end", "def old_text=(value)\n @old_text = value\n end", "def add_line(line)\n @tip.string_content += line.slice(@offset, line.length) + '\\n'\n end", "def send_line (line)\n send_data line.to_s\n end", "def source_line(lineno); end", "def initialize(text, line, column)\n @text = text\n @line = line\n @column = column\n end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end" ]
[ "0.6719064", "0.66787726", "0.6625625", "0.6545188", "0.6476965", "0.64592564", "0.64402807", "0.6407536", "0.6332513", "0.6291928", "0.62585914", "0.6197664", "0.6172941", "0.61715883", "0.6155007", "0.6151595", "0.61308306", "0.6128319", "0.60884655", "0.60676867", "0.6027283", "0.6011889", "0.5941986", "0.5941986", "0.5941986", "0.5941986", "0.5941986", "0.5908133", "0.5908133", "0.5908133", "0.5898476", "0.5893127", "0.5891638", "0.58887523", "0.588826", "0.588627", "0.5874877", "0.5874877", "0.5874877", "0.5859481", "0.5855136", "0.58331215", "0.5809626", "0.58031046", "0.58029324", "0.5795443", "0.579339", "0.5752126", "0.5748843", "0.5748843", "0.5741777", "0.5741496", "0.5740554", "0.5726297", "0.5703901", "0.56553864", "0.56516284", "0.5626216", "0.56195974", "0.56162053", "0.5610643", "0.5608209", "0.55978996", "0.5597362", "0.5597362", "0.5591892", "0.5587472", "0.558049", "0.5577246", "0.5572014", "0.55687284", "0.5562924", "0.5557936", "0.5552646", "0.5550267", "0.55416095", "0.5531427", "0.5525669", "0.55214727", "0.55125666", "0.5511563", "0.5511237", "0.55071", "0.55064034", "0.55051327", "0.55022633", "0.5500619", "0.5499929", "0.5494621", "0.5487134", "0.5480791", "0.5473505", "0.5437983", "0.5431458", "0.5431458", "0.5431458", "0.5431458", "0.5431458", "0.5431458", "0.5431458" ]
0.8175392
0
Returns the line numbered 'num' (first line is 0)
def line(num) lines(num, 1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def line_index(num)\n\t\tif num == 0\n\t\t\treturn -1\n\t\telsif num <= @line_indices.length\n\t\t\treturn @line_indices[num - 1]\n\t\telsif num == @line_indices.length + 1\n\t\t\treturn @text.length\n\t\telse\n\t\t\treturn -999 # todo\n\t\tend \n\tend", "def line_number\n number[6..-1]\n end", "def line_number\n\t\t\t@line_index + 1\n\t\tend", "def line(number)\n lines[number - 1]\n end", "def line(number); end", "def line_number(pos=pos)\n line_index(pos) + 1\n end", "def line_number(pos=pos())\n line_index(pos) + 1\n end", "def line(number)\n end", "def line_num; end", "def get_number(lines)\n lines.shift.to_i\n end", "def line_number\n raise \"This loader doesn't support line_number\"\n end", "def read_line_number(filename, number)\n return nil if number < 1\n line = File.readlines(filename)[number-1]\n line ? line.chomp : nil\n end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_id\n @line_number - 1\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line_number\n @line_number_overwrite || default_line_number\n end", "def line(n)\n @lines[n]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line(line_no)\n @line[line_no]\n end", "def line_number\n @value.line_number if @value.respond_to?(:line_number)\n end", "def current_line_number; end", "def line_number\n env(:line_number).to_i - 1\n end", "def from_line_index\n from_line - 1\n end", "def line_number\n $curwin.cursor.first\n end", "def linenumber\n return @cmd.nil? ? 0 : @cmd.linenumber\n end", "def line\n 1\n end", "def lineno\n @__line\n end", "def visible_line_number\r\n return 5\r\n end", "def lineno=(num)\n num = Maglev::Type.coerce_to(num, Fixnum, :to_int)\n @_st_lineno = num\n $. = num\n num\n end", "def line_number=(_arg0); end", "def line_number=(_arg0); end", "def line_number=(_arg0); end", "def line_number\n lines_read.length\n end", "def line_index()\n end", "def start_line_number=(_); end", "def start_line_number; end", "def start_line_number; end", "def visible_line_number\n return 1\n end", "def visible_line_number\n return 1\n end", "def default_line_number\n return current_layout.line_count\n end", "def lineno= integer\n #This is a stub, used for indexing\n end", "def lineNum()\n caller_infos = caller.first.split(\":\")\n # Note caller_infos[0] is file name\n # caller_infos[1]\n return \"Line no. #{caller_infos[1]}\"\nend", "def determine_line_number(scanner)\n scanner.string[0, scanner.pos].count(\"\\n\")\n end", "def lineno()\n #This is a stub, used for indexing\n end", "def line\n buffer[line_number]\n end", "def lineno() end", "def lineno() end", "def lineno() end", "def visible_line_number\n return 4\n end", "def visible_line_number\n return 4\n end", "def number lines\n lines.each_with_index.map { |x,i| \"#{i + 1}: #{x}\" }\nend", "def lineno\n @lineno || uninitialized!\n end", "def line_for_position(position); end", "def line_for_position(position); end", "def line_for_position(position); end", "def lineno\n end", "def lineno\n end", "def lineno; end", "def lineno; end", "def lineno; end", "def line_index(pos=pos())\n p = n = 0\n string.each_line do |line|\n p += line.length\n return n if p >= pos\n n += 1\n end\n 0\n end", "def line_num_to_coord(n)\n\t\t(n + 1) * font_metrics.height\n\tend", "def line_index(pos=pos)\n p = n = 0\n string.each_line do |line|\n p += line.length\n return n if p >= pos\n n += 1\n end\n 0\n end", "def assign_line_numbers\n line_num = 1;\n\n @line_num = [ ]\n @tokens.each do |token|\n @line_num << line_num\n line_num += token.count \"\\n\"\n end\n end", "def line\n return 1 unless lexing_context && locator\n locator.line_for_offset(lexing_context[:end_offset])\n end", "def original_line_number(new_line)\n # First of all, convert the line number to an integer\n new_line = new_line.to_i\n\n if @phase == :execute\n # It's the execute phase, so we have more to do\n if @augmented_code.nil?\n # We haven't augmented the code with line numbers or anything\n number_of_prepended_lines = make_runnable(\"\").count(\"\\n\")\n return new_line - number_of_prepended_lines\n\n else\n # Pull the offending line out of the augmented code\n augmented_code_lines = @augmented_code.lines\n if new_line > augmented_code_lines.length\n # We were not able to find the line the error message refers to. Shouldn't happen.\n return \"<unbekannt>\"\n else\n # Check if the line has a line number comment\n ln = PythonCodeAugmenter.extract_line_number(augmented_code_lines[new_line - 1])\n if ln.nil?\n return \"<unbekannt>\"\n else\n return ln\n end\n end\n end\n\n else\n # It's not the execute phase, so we can simply return the line number\n return new_line\n end\n end", "def elementnumber\n @line1[64...68].to_i\n end", "def line_number\n return unless backtrace and backtrace[0]\n\n backtrace[0].split(\":\")[1].to_i\n end", "def compute_line_index\n scanner = StringScanner.new(@string)\n result = [0] # first line starts at 0\n while scanner.scan_until(/\\n/)\n result << scanner.pos\n end\n @line_index = result\n end", "def lineno=(p0) end", "def lineno=(p0) end", "def lineno=(p0) end", "def line_at(filename, line_number)\n source_reload\n\n return \"\\n\" unless File.exist?(filename)\n line = Tracer::Single.get_line(filename, line_number)\n\n return \"#{line.gsub(/^\\s+/, '').chomp}\"\n end", "def lineNum()\n caller_infos = caller.first.split(\":\")\n # Note caller_infos[0] is file name\n caller_infos[1]\nend", "def read_specific_line(file_name, line_number)\n line = `sed '#{line_number + 1}!d' #{file_name}`\n line.chop! if line.last == \"\\n\"\n LoggerHelper.print_to_log(\"Lines in '#{file_name}' by number is '#{line}'\")\n line\n end", "def lines(start, num) \n\t\t@text[index_of_position(start)...index_of_position(start + num) - 1]\n\tend", "def readline(file, line_number)\n current_line = 0\n File.open(file).each do |line_text|\n current_line += 1\n return line_text.strip if current_line == line_number\n end\n end", "def readline(file, line_number)\n current_line = 0\n File.open(file).each do |line_text|\n current_line += 1\n return line_text.strip if current_line == line_number\n end\n end", "def line_numbers\n return (line..line) unless @value && text\n\n end_line = if !lines.empty?\n line + lines.count - 1\n elsif children.empty?\n nontrivial_end_line\n else\n line\n end\n\n (line..end_line)\n end", "def lineno\n @_st_lineno\n end", "def normalized_line_number(line_number, total_lines)\n line_number < 0 ? line_number + total_lines : line_number\n end", "def coord_to_line_num(y)\n\t\ty / font_metrics.height - 1\n\tend", "def index_for(file, line_number)\n diff_for_file(file).fetch(:diff_chunks).\n reduce(0) do |index, position:, size:, diff:|\n # Unless we are processing the target chunk\n unless line_number.between?(position, position + size)\n next index + 1 + diff.lines.count\n end\n\n position -= 1 # rebase position on first line of chunk\n index_in_chunk = diff.lines.find_index do |line|\n position += 1 unless line.first == '-'\n position == line_number\n end\n\n return index + 1 + index_in_chunk\n end\n\n nil # if this line number is not in diff\n end", "def parse_debug_line_number(number_as_string)\n # Deduct 1 because kakoune always maintains an extra empty line at the end of the debug buffer.\n number_as_string.to_i - 1\nend", "def line_for_offset(offset)\n @locator.line_for_offset(offset) + @leading_line_count\n end", "def line_for_offset(offset)\n if line_nbr = line_index.index {|x| x > offset}\n return line_nbr\n end\n # If not found it is after last\n return line_index.size\n end", "def line_pos(row)\n (row > 0 ? src.split(\"\\n\")[0..(row - 1)].inject(0) { |pos, line| pos + line.length + 1 } : 0)\n end", "def lineno=\n end", "def first_line_in_view()\n\t\tcoord_to_line_num(contents_y)\n\tend" ]
[ "0.84106016", "0.79114735", "0.77193195", "0.77130175", "0.76239145", "0.75851053", "0.75791425", "0.7510495", "0.7502307", "0.7428788", "0.71273696", "0.7097533", "0.704864", "0.704864", "0.704864", "0.704864", "0.704864", "0.704864", "0.704864", "0.7036752", "0.70050186", "0.70050186", "0.70050186", "0.70050186", "0.70050186", "0.6991041", "0.69857967", "0.696587", "0.696587", "0.696587", "0.6962946", "0.6950832", "0.6939438", "0.6915875", "0.6911555", "0.6904586", "0.68850446", "0.6846638", "0.6829943", "0.68274176", "0.68017554", "0.68017554", "0.68017554", "0.6796677", "0.6775142", "0.6775103", "0.6754095", "0.6754095", "0.6750431", "0.6750431", "0.67294806", "0.6726214", "0.6717363", "0.66982645", "0.6692369", "0.6680807", "0.66804516", "0.66804516", "0.66804516", "0.6674273", "0.6674273", "0.66559666", "0.6655837", "0.660694", "0.660694", "0.660694", "0.6604977", "0.6604977", "0.6546174", "0.6546174", "0.6546174", "0.65439373", "0.6526374", "0.6519106", "0.64558756", "0.6424118", "0.64154375", "0.64015895", "0.6387782", "0.6385105", "0.6367225", "0.6367225", "0.63662887", "0.63662887", "0.6330793", "0.6323237", "0.632218", "0.6319448", "0.6319448", "0.63163555", "0.63109833", "0.62936884", "0.6290366", "0.62871706", "0.6284117", "0.6215656", "0.6215231", "0.62101305", "0.61909634", "0.61857784" ]
0.79931754
1
Returns 'num' lines starting from line 'start'
def lines(start, num) @text[index_of_position(start)...index_of_position(start + num) - 1] end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def take_lines(start_line, num_lines)\n start_idx =\n if start_line >= 0\n @lines.index { |loc| loc.lineno >= start_line } || @lines.length\n else\n [@lines.length + start_line, 0].max\n end\n\n alter do\n @lines = @lines.slice(start_idx, num_lines)\n end\n end", "def take_lines(start_line, num_lines)\n if start_line >= 0\n start_idx = @lines.index { |l| l.last >= start_line } || @lines.length\n else\n start_idx = @lines.length + start_line\n end\n\n alter do\n @lines = @lines.slice(start_idx, num_lines)\n end\n end", "def start_line_number; end", "def start_line_number; end", "def start_line_number=(_); end", "def lines_offset\n @starting_line - 1\n end", "def line_range(lineno); end", "def next_lines(lines, number)\n lines.slice!(0, number)\n end", "def line(num) lines(num, 1) end", "def line_range\n max_lines = source_file.content.lines.size - 1\n context_lines = 3\n first_line = [0, location_line - context_lines - 1].max\n last_line = [max_lines, location_line + context_lines - 1].min\n first_line..last_line\n end", "def read(start: 0, num: 10)\n f = open(@filename, 'r')\n # Iterate to start line\n start.times { f.gets }\n \n # Read lines start to last\n data = ''\n num.times {\n chunk = f.gets\n data << chunk unless chunk.nil?\n }\n \n f.close()\n return data\n end", "def num_lines() @line_indices.length + 1 end", "def line_index(num)\n\t\tif num == 0\n\t\t\treturn -1\n\t\telsif num <= @line_indices.length\n\t\t\treturn @line_indices[num - 1]\n\t\telsif num == @line_indices.length + 1\n\t\t\treturn @text.length\n\t\telse\n\t\t\treturn -999 # todo\n\t\tend \n\tend", "def start_line_for(code_object)\n if code_object.command? || opts.present?(:'base-one')\n 1\n else\n code_object.source_line.nil? ? 1 :\n (code_object.source_line - code_object.doc.lines.count)\n end\n end", "def index_from_start(index); end", "def range_by_lines(range); end", "def number_of_lines_in_first_chunk\n end_method_line = last_method_source_location.last\n\n end_method_line - line\n end", "def sub_horizontal_line(start, length)\n offset = byte_offset start\n data[offset .. (offset + (length*pixel_byte_size)-1)]\n end", "def from_line_index\n from_line - 1\n end", "def start_num\n return @start_num\n end", "def assert_lines_starting_with(text, number, start_with)\n\tnumber = number.to_i if number.is_a? String\n\tcount = text.split(\"\\n\").count { |line| line.start_with? start_with }\n\texpect(count).to eq number\nend", "def line_number\n lines_read.length\n end", "def goto_line pos\n pos = pos.to_i\n pages = ((pos * 1.00)/$pagesize).ceil\n pages -= 1\n $sta = pages * $pagesize + 1\n $cursor = pos\nend", "def read_between_the_lines(file_name, start_line, end_line)\n content = File.read(File.expand_path(file_name))\n lines_array = content.each_line.to_a\n\n [lines_array[start_line..end_line].join, normalized_line_number(start_line, lines_array.size),\n normalized_line_number(end_line, lines_array.size)]\n end", "def line_numbers\n return (line..line) unless @value && text\n\n end_line = if !lines.empty?\n line + lines.count - 1\n elsif children.empty?\n nontrivial_end_line\n else\n line\n end\n\n (line..end_line)\n end", "def rl_beg_of_line(count, key)\r\n @rl_point = 0\r\n 0\r\n end", "def affected_lines_range\n (line_no..line_no + replaced_text.count(\"\\n\"))\n end", "def line(number); end", "def line_number(pos=pos)\n line_index(pos) + 1\n end", "def num_lines\n load_data unless @num_lines\n @num_lines\n end", "def line_offset\n\t\t\t@offset - @line_range.min\n\t\tend", "def line_for_position(position); end", "def line_for_position(position); end", "def line_for_position(position); end", "def line_number(pos=pos())\n line_index(pos) + 1\n end", "def line_number\n number[6..-1]\n end", "def line_for_offset(offset)\n if line_nbr = line_index.index {|x| x > offset}\n return line_nbr\n end\n # If not found it is after last\n return line_index.size\n end", "def line_num; end", "def lines\n 2 * @size + 3\n end", "def line_number\n\t\t\t@line_index + 1\n\t\tend", "def line_index(pos=pos())\n p = n = 0\n string.each_line do |line|\n p += line.length\n return n if p >= pos\n n += 1\n end\n 0\n end", "def line_index(pos=pos)\n p = n = 0\n string.each_line do |line|\n p += line.length\n return n if p >= pos\n n += 1\n end\n 0\n end", "def goto_line pos\n pages = ((pos * 1.00) / @pagesize).ceil\n pages -= 1\n @sta = pages * @pagesize + 1\n @cursor = pos\nend", "def lines\n total = 0\n chunk { |measurement|\n total += measurement.length + DELIMITER.length * 2\n total / max\n }.map { |_, line|\n [source, line].join(DELIMITER)\n }\n end", "def assign_line_numbers\n line_num = 1;\n\n @line_num = [ ]\n @tokens.each do |token|\n @line_num << line_num\n line_num += token.count \"\\n\"\n end\n end", "def headlines_count(start = @start, per_page = @per_page, topic = @custom_topic)\r\n page = per_page + 1\r\n headlines = @newsapi.get_top_headlines(category: \"#{topic}\", language: \"en\", country: \"us\")[start...start + page]\r\n\r\n is_remaining = headings.size\r\n\r\n is_remaining\r\n end", "def n_lines(filename); end", "def first_line_only(range); end", "def first_line_only(range); end", "def first_line_only(range); end", "def get_number(lines)\n lines.shift.to_i\n end", "def print_from(start)\n\twhile start < RC_C.num_rows\n\t\tputs RC_C.rows[start][1]\n\t\tstart += 1\n\tend\nend", "def line_for_offset(offset)\n @locator.line_for_offset(offset) + @leading_line_count\n end", "def before(line_num, lines=1)\n return self unless line_num\n\n select do |l, ln|\n ln >= line_num - lines && ln < line_num\n end\n end", "def initial_load_range( line_a=1, line_b=-1 )\n\t\t@lines = []\n\t\tline_number = 0\n\t\tf = @data_source\n\t\tf.each do |line|\n\t\t\tline_number += 1\n\t\t\tnext unless line_number >= line_a\n\t\t\t@lines << Line.new(line_number, line.chomp )\n\t\t\tbreak if line_b != -1 && line_number >= line_b\n\t\tend\n\t\tf.close if f.is_a? File\n\t\t@lines\n\tend", "def number lines\n lines.each_with_index.map { |x,i| \"#{i + 1}: #{x}\" }\nend", "def find_number_lines(opened_file)\n start_time = Time.now.to_i\n total_file_lines = opened_file.each_line.inject(0) { |total, _amount| total + 1 }\n opened_file.rewind\n if Rails.env.development?\n end_time = Time.now.to_i\n puts(\"1. Lines ==> #{total_file_lines} in #{((end_time - start_time) / 60).round(2)}\")\n end\n total_file_lines\n end", "def lines\n @document.lines @line_numbers\n end", "def __beg_len(len)\n beg = Maglev::Type.coerce_to(@_st_from, Fixnum, :to_int)\n the_end = Maglev::Type.coerce_to(@_st_to, Fixnum, :to_int)\n\n if (beg < 0)\n beg += len\n return nil if (beg < 0)\n end\n\n return nil if (beg > len)\n the_end = len if (the_end > len)\n\n the_end += len if (the_end < 0)\n the_end += 1 unless @_st_excludeEnd\n len = the_end - beg\n len = 0 if (len < 0)\n return [beg, len]\n end", "def line_at(start_x, str)\n x = start_x\n move_to_x(start_x) if start_x > 1\n str.length.times do |i|\n $stdout.putc str[i] if x > 0 && x < @width\n x += 1\n end\n $stdout.putc \"\\n\"\n end", "def line(number)\n end", "def compute_line_index\n scanner = StringScanner.new(@string)\n result = [0] # first line starts at 0\n while scanner.scan_until(/\\n/)\n result << scanner.pos\n end\n @line_index = result\n end", "def between(start_line, end_line=nil)\n return self unless start_line\n\n if start_line.is_a? Range\n end_line = start_line.last\n end_line -= 1 if start_line.exclude_end?\n\n start_line = start_line.first\n else\n end_line ||= start_line\n end\n\n if start_line > 0\n start_idx = @lines.index { |l| l.last >= start_line } || @lines.length\n else\n start_idx = start_line\n end\n\n if end_line > 0\n end_idx = (@lines.index { |l| l.last > end_line } || 0) - 1\n else\n end_idx = end_line\n end\n\n alter do\n @lines = @lines[start_idx..end_idx] || []\n end\n end", "def get_line_pos(pos)\n lpos = @line_ends.bsearch_index { |x, _| x >= pos }\n return lpos\n end", "def lines_of(range)\n min_words = range.first\n max_words = range.last\n words_left = 0\n line = []\n\n @sentences.inject([]) do |result, sentence|\n too_few_words = proc { line.size < min_words || words_left < min_words }\n too_many_words = proc { line.size >= max_words ||\n line.size + words_left > max_words && words_left <= min_words }\n end_line = proc { result << line.join(\" \") and line.clear }\n words = sentence.split\n word_count = words.size\n\n next result << sentence if word_count < min_words * 2\n\n line.clear\n words.each_with_index do |word, i|\n words_left = word_count - i\n if too_few_words[]\n line << word\n end_line.call if word =~ /[,;]$/ && !too_few_words[]\n elsif too_many_words[] || word =~ /^['\"]|^(and|that|or|for|nor|if)$/\n end_line.call\n line << word\n elsif word =~ /[,;]$/\n line << word\n end_line.call\n else\n line << word\n end\n end\n result << line.join(\" \")\n end\n end", "def line_for_offset(offset)\n if @prev_offset == offset\n # use cache\n return @prev_line\n end\n line_nbr = ary_bsearch_i(line_index, offset)\n if line_nbr\n # cache\n @prev_offset = offset\n @prev_line = line_nbr\n return line_nbr\n end\n # If not found it is after last\n # clear cache\n @prev_offset = @prev_line = nil\n return line_index.size\n end", "def line(number)\n lines[number - 1]\n end", "def lex_start line\n starts << line.strip\n end", "def page_start_for(page_num)\n page_size * (page_num - 1) + 1\n end", "def seek_contiguous_min(needle, step_lines = 10)\n\n file = @file\n min = nil\n\n # move to head of line\n seek_line_head\n\n loop do\n\n lines = backward_lines(step_lines)\n lines_pos = str_byte_index(lines, needle)\n file_pos = file.pos\n\n # for debug\n # p [\n # lines: lines,\n # lines_pos: lines_pos,\n # file_pos: file_pos\n # ].to_s\n # sleep 0.05\n\n if lines_pos.nil?\n break\n else\n\n min = file_pos + lines_pos\n\n # if not first line, add 1 to result\n min += 1 if file_pos > 0\n\n break if lines_pos > 0 || file_pos < 1\n end\n end\n\n file.seek(min) unless min.nil?\n min\n end", "def start_index(page)\n (page - 1) * @count + 1\n end", "def num_lines_in_view()\n\t\tlast_line_in_view() - first_line_in_view() + 1\n\tend", "def method_source_lines(file, line_num, context=5)\n # Yeah, we're not memory efficient here.\n lines = Array(File.open(file))\n result = []\n\n min_index = line_num - context - 1\n max_index = line_num + context\n\n max_width = (max_index + 1).to_s.length\n\n (min_index...max_index).each do |index|\n result << [(index + 1).to_s.rjust(max_width), lines[index].rstrip, index == line_num - 1]\n end\n\n result\n end", "def goto_line pos\n pages = ((pos * 1.00)/$pagesize).ceil\n pages -= 1\n #$sta = pages * $pagesize + 1\n $sta = pages * $pagesize + 0\n $cursor = pos\n #$log.debug \"XXX: GOTO_LINE #{$sta} :: #{$cursor}\"\nend", "def line_for_offset(offset)\n end", "def lines(source); end", "def range_by_lines(range)\n begin_of_first_line = range.begin_pos - range.column\n\n last_line = range.source_buffer.source_line(range.last_line)\n last_line_offset = last_line.length - range.last_column\n end_of_last_line = range.end_pos + last_line_offset\n\n Parser::Source::Range.new(range.source_buffer,\n begin_of_first_line,\n end_of_last_line)\n end", "def count_lines\n linecount = 0\n\n @output_buffer.each do |line|\n linecount += line.scan(/\\n/).count\n end\n\n linecount - 1\n end", "def set_line_range(listsize, maxline)\n if !@match || !(@match[1] || @match[2])\n b = if @state.previous_line\n @state.previous_line + listsize\n else\n @state.line - (listsize / 2)\n end\n elsif @match[1] == '-'\n b = if @state.previous_line\n if @state.previous_line > 0\n @state.previous_line - listsize\n else\n @state.previous_line\n end\n else\n @state.line - (listsize / 2)\n end\n elsif @match[1] == '='\n @state.previous_line = nil\n b = @state.line - (listsize / 2)\n else\n b, e = @match[2].split(/[-,]/)\n if e\n b = b.to_i\n e = e.to_i\n else\n b = b.to_i - (listsize / 2)\n end\n end\n\n if b > maxline\n errmsg 'Invalid line range'\n return [-1, -1]\n end\n\n b = [1, b].max\n e ||= b + listsize - 1\n\n if e > maxline\n e = maxline\n b = e - listsize + 1\n b = [1, b].max\n end\n\n [b, e]\n end", "def increase_consumed_lines_to(value)\n while @consumed_lines < value\n STDOUT.print \"\\n\"\n @consumed_lines += 1\n end\n end", "def line\n return 1 unless lexing_context && locator\n locator.line_for_offset(lexing_context[:end_offset])\n end", "def line_count\n\t\tlines.size\n\tend", "def line_count\n\t\tlines.size\n\tend", "def line_offset(pos=pos())\n p = 0\n string.each_line do |line|\n len = line.length\n return (pos - p) if p + len >= pos\n p += len\n end\n 0\n end", "def around(line_num, lines=1)\n return self unless line_num\n\n select do |l, ln|\n ln >= line_num - lines && ln <= line_num + lines\n end\n end", "def line_offset(pos=pos)\n p = 0\n string.each_line do |line|\n len = line.length\n return (pos - p) if p + len >= pos\n p += len\n end\n 0\n end", "def first_ip_on_line(line, start=nil)\n i = 1\n total = @lines.size\n\n while i < total\n cur_line = @lines.at(i)\n if cur_line >= line\n ip = @lines.at(i-1)\n\n if !start or ip > start\n # matched the definition line, return 0\n return 0 if ip == -1\n return ip\n end\n end\n\n i += 2\n end\n\n nil\n end", "def src_lines(pr)\n count_lines(src_files(pr))\n end", "def get_lines\n lines = []\n read_file.each_line{|l| lines << l.chomp }\n @total_lines = lines.shift.to_i\n lines\n end", "def find_file_lines(file)\n file.open { |f| find_number_lines(f) }\n end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def begin_pos; end", "def begin_line(kind); end", "def begin_line(kind); end" ]
[ "0.72183967", "0.71518797", "0.6923758", "0.6923758", "0.67764974", "0.6596829", "0.6540667", "0.6475989", "0.64405864", "0.6342851", "0.6335547", "0.6253575", "0.62462795", "0.62190163", "0.620429", "0.61829734", "0.6128401", "0.60797524", "0.6043772", "0.6015493", "0.5971664", "0.5971598", "0.5930554", "0.59021413", "0.5891418", "0.589059", "0.5889393", "0.58719015", "0.58655715", "0.5852742", "0.5843578", "0.58342886", "0.58342886", "0.58342886", "0.5821081", "0.58141494", "0.581196", "0.5801202", "0.58006734", "0.58005494", "0.5793268", "0.5785864", "0.57657737", "0.5747824", "0.5741107", "0.57258666", "0.5718305", "0.5710659", "0.5710659", "0.5710659", "0.5677387", "0.56767654", "0.56666607", "0.5659794", "0.56332386", "0.56272346", "0.56242955", "0.56093276", "0.55931115", "0.5575627", "0.5570218", "0.55647993", "0.55619085", "0.55564165", "0.5545913", "0.5524847", "0.55189276", "0.55100375", "0.550867", "0.5503867", "0.5502509", "0.5496422", "0.54903644", "0.54850876", "0.54538816", "0.54509497", "0.54467493", "0.54466724", "0.5443881", "0.54424536", "0.5441799", "0.543761", "0.543761", "0.54245406", "0.54244095", "0.5403125", "0.54010695", "0.54007035", "0.5379205", "0.53679395", "0.53634334", "0.53634334", "0.53634334", "0.53634334", "0.53634334", "0.53634334", "0.53634334", "0.5357915", "0.53570944", "0.53570944" ]
0.79685843
0
Returns the number of lines
def num_lines() @line_indices.length + 1 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def line_count\n\t\tlines.size\n\tend", "def line_count\n\t\tlines.size\n\tend", "def getNumLines()\n contents.split(\"\\n\").length - 1\n end", "def line_count\n\t\t\treturn @contents.nil? ? 0 : @contents.count\n\t\tend", "def count_lines\n linecount = 0\n\n @output_buffer.each do |line|\n linecount += line.scan(/\\n/).count\n end\n\n linecount - 1\n end", "def line_number\n lines_read.length\n end", "def num_lines\n load_data unless @num_lines\n @num_lines\n end", "def lines_count\n @lines_count ||= lines.count\nend", "def line_count\n `wc -l public/HelloWorld.txt`.to_i\n end", "def line_count\n entries.inject(0) do |count, entry|\n count + (entry.dir? ? 0 : entry.lines.size)\n end\n end", "def n_lines(filename); end", "def num_lines_in_view()\n\t\tlast_line_in_view() - first_line_in_view() + 1\n\tend", "def length\n @lines ? @lines.length : 0\n end", "def length\n @lines ? @lines.length : 0\n end", "def lines_count(str)\n i = 0\n str.each_line { i += 1 }\n i\n end", "def lines_counter\n f = File.open('peliculas.txt', 'r')\n print f.readlines.length\n f.close\nend", "def line_items_count\n self.line_items.size\n end", "def line_items_count\n self.line_items.size\n end", "def number_of_lines_in_first_chunk\n end_method_line = last_method_source_location.last\n\n end_method_line - line\n end", "def line_items_count\n self.line_items.count\n end", "def linecount(fname)\n File.open(fname, \"r\") do |f|\n f.readlines.length\n end\nend", "def data_line_count\n 1\n end", "def count_lines(all_lines_from_file)\n all_lines_from_file.lines.count\nend", "def file_line_count(file_name)\n line_count = `wc -l < #{file_name}`.to_i\n LoggerHelper.print_to_log(\"Count of lines in '#{file_name}' is #{line_count}\")\n line_count\n end", "def count_lines(file)\n n = 0\n while file.gets\n n += 1\n end\n n\n end", "def calculate_num_of_lines body\n lines = body.split(\"\\n\")\n lines.each_with_index do |line, index|\n if line.length * 20 > 500\n lines[index] = line.wrap_lines\n end\n end\n reformated_body = lines.join \"\\n\"\n num_lines = reformated_body.split(\"\\n\").size\n return num_lines, reformated_body\n end", "def line_length(line)\n line.chomp.gsub(/\\e\\[[\\d;]*m/, '').length\n end", "def line_num; end", "def line\n @string[0..@index].split(\"\\n\").count\n end", "def paragraph_count(all_lines_from_file)\n all_lines_from_file.split(/\\n\\n/).length\nend", "def length\n @line.length\n end", "def line_length(line)\n line.chomp.gsub(/\\e\\[[\\d;]*m/, '').length\n end", "def size_in_lines(filepath)\n f = File.new(filepath)\n f.readlines[-1]\n count = f.lineno.to_s\n puts \"The link check report contains #{count} lines.\".blue\n puts \"To see the report, open the #{filepath} file.\".blue\n end", "def line_count(file)\n\t\tf = File.new(file)\n\t\tnum_newlines = 0\n\t\twhile (c = f.getc) != nil\n\t\t\tnum_newlines += 1 if c == $/\n\t\tend\n\t\tnum_newlines\n\tend", "def line_count(file_list)\n file_list.empty? ?\n nil :\n %x{wc -l #{file_list.join(' ')} | awk 'END {print $1}'}.to_i\n end", "def total_lines(arr)\n return arr.length\nend", "def lines\n @message.size\n end", "def countlines\n file = File.open('peliculas.txt', 'r')\n data = file.readlines\n file.close\n puts data.length\nend", "def count_lines_in_class(klass)\n lines = klass.methods.map {|method| method.lines}.inject(:+)\n lines.nil? ? 0 : lines\n end", "def size\n line.size\n end", "def height\n lines.size\n end", "def height\n lines.size\n end", "def n_lines(filename)\n File.foreach(filename).reduce(0) { |acc, _elem| acc + 1 }\n end", "def line\n\t return -1 if @inputStack.empty? # only if initialize() arg is bogus\n\n\t input = @inputStack[0] # not @inputStack.last\n\t str = input.string[0 .. input.pos]\n\t return str.count(\"\\n\") + 1\n\tend", "def description_lines\n string = @challenge.description\n lines = 0\n string.each_line('|') { |i|\n lines += 1\n }\n return lines+1\n end", "def lines_of_code\n covered_lines.size + missed_lines.size\n end", "def lines\n repository.files.map do |file|\n repository.read(file).to_s.lines.count\n end.sum\n end", "def test_lines(pr)\n count_lines(test_files(pr))\n end", "def length\n (lines.max_by(&:length) || '').size\n end", "def determine_line_number(scanner)\n scanner.string[0, scanner.pos].count(\"\\n\")\n end", "def line_length(line_index)\n @line_lengths[line_index]\n end", "def lines\n\t\t\t@buffer.data.count(Ruvim::API::CR)\n\t\tend", "def line_length(line = -1)\n send_message(:LINELENGTH, line.to_i)\n end", "def src_lines(pr)\n count_lines(src_files(pr))\n end", "def line_length_for(line_number)\n line_lengths[line_number]\n end", "def total_data_lines\n @total_data_lines ||= processed_rows.keys.size\n end", "def length\n return nil if self.nil?\n return @theLines.length\n end", "def count_lines()\n start_time = Time.now\n @file_lines = 0 \n last_block_position = 0\n prev_block_position = -1\n Rula.log(Logger::DEBUG,\"Reading file #{@filename} lines count\",self)\n file_handle = File.open(@filename,'rb')\n while data = file_handle.read(@@BLOCK_SIZE)\n original_size = data.length\n last_occurence = data.rindex(Rula.options[:line_separator])\n difference_in_size = original_size - last_occurence\n\n if data.length==1 then\n break\n end\n\n if !last_occurence.nil? then\n data = data[0..last_occurence]\n file_handle.pos -= difference_in_size\n end\n @file_lines += data.scan(/([^|#{Rula.options[:line_separator]}].*)#{Rula.options[:line_separator]}/).length\n \n (0...@@BUFFERS).each {|i| \n @buffers[i].add_hash(last_block_position, prev_block_position, file_handle.pos, @file_lines)\n }\n prev_block_position = last_block_position \n last_block_position = file_handle.pos\n end\n Rula.log(Logger::DEBUG,\"Counted #{@file_lines} lines for file #{@filename}\",self)\n ensure\n Rula.log(Logger::DEBUG,\"Counting lines ran #{(Time.now - start_time) * 1000} ms\",self)\n file_handle.close()\n load_buffer_data(0)\n end", "def count\n Jhead.call(\"-c\", @match, @pattern).split(\"\\n\").size\n end", "def question_lines_count(question_lines)\n question_lines.reduce(0) do |acc, line|\n acc + @prompt.count_screen_lines(line)\n end\n end", "def contar_lineas\n line = read_alumnos\n contador = line.count\n contador\nend", "def count\n `wc -l < #{filepath}`.to_i - 1\n end", "def find_number_lines(opened_file)\n start_time = Time.now.to_i\n total_file_lines = opened_file.each_line.inject(0) { |total, _amount| total + 1 }\n opened_file.rewind\n if Rails.env.development?\n end_time = Time.now.to_i\n puts(\"1. Lines ==> #{total_file_lines} in #{((end_time - start_time) / 60).round(2)}\")\n end\n total_file_lines\n end", "def length\n (lines.map do |line|\n Strings::Align.display_width(line)\n end << 0).max\n end", "def lines\n 2 * @size + 3\n end", "def li_number\n self.lineitems.size\n end", "def count_paragraphs(some_file)\n file_content = open(some_file).read()\n count = 0\n file_content_split = file_content.split('')\n\n file_content_split.each_index do |index|\n count += 1 if file_content_split[index] == \"\\n\" && file_content_split[index + 1] == \"\\n\"\n end\n return count\nend", "def total_lines\n covered_lines + missed_lines\n end", "def width\n theWidth = 0\n @theLines.each { |l| theWidth = l.length if l.length > theWidth }\n theWidth\n end", "def count_rows(s)\n return nil if s.nil?\n\n col = 1\n row = 1\n\n s.each_char do |c|\n if c == \"\\n\" or col > TA_COLS then\n col = 1\n row += 1\n next\n end\n\n col += 1\n end\n\n row\n end", "def line_number\n\t\t\t@line_index + 1\n\t\tend", "def word_count(all_lines_from_file)\n all_lines_from_file.split.length\nend", "def get_file_lines_of_code!(f)\n count = 0;\n File.foreach(f) {count+=1}\n #print(\"#{count}\")\n count\n end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def line_number; end", "def lines_of_code\n coverage_statistics[:line]&.total\n end", "def rows_count\n @rows.size\n end", "def count_total_lines files\n files.each do |f, k|\n lines_output = `wc -l #{f.to_s}`\n if $? != 0 then\n raise 'Error in counting total lines.'\n end\n lines_count = lines_output.strip.split(' ')[0].to_i\n k['total_lines'] = lines_count\n end\n return files\n end", "def line_number(pos=pos())\n line_index(pos) + 1\n end", "def line_number(pos=pos)\n line_index(pos) + 1\n end", "def num_commits(lines)\n numCommits = 0\n lines.each{ |line| numCommits += 1 if line.start_with?(\"commit \") }\n return numCommits\nend", "def total_lines\n hunks.sum(:old_count) + hunks.sum(:new_count)\n end", "def count_characters(all_lines_from_file)\n all_lines_from_file.gsub(/\\n+/,\"\").length\nend", "def line_level line\n line.match(/^[ \\t]*/)[0].gsub(\"\\t\", \" \").split('').length\n end", "def number_of_rows(matrix)\n counter = 1\n matrix.each_char { |symb|\n counter += 1 if symb == \"\\n\"\n }\n counter\nend", "def num_commits(lines)\n i = 0\n\tlines.each{|line| \n\t\tif line.include? \"commit\"\n\t\t\ti += 1\n\t\tend\n\t}\n\treturn i\nend", "def count_trailing_newlines(text)\n if text.end_with? \"\\n\"\n count = 0\n\n text.reverse.chars do |c|\n if c == \"\\n\"\n count += 1\n else\n break\n end\n end\n\n count\n else\n 0\n end\n end", "def total_lines(csv_file_name,rb='rb',options={})\n\t\tf = CSV.open(csv_file_name, rb, {}.merge(options))\n\t\ttotal_lines = f.readlines.size # includes header, but so does f.lineno\n\t\tf.close\n\t\ttotal_lines\n\tend", "def line_index(pos=pos())\n p = n = 0\n string.each_line do |line|\n p += line.length\n return n if p >= pos\n n += 1\n end\n 0\n end", "def row_count\n @rows.length;\n end", "def sentence_count(all_lines_from_file)\n all_lines_from_file.split(/\\.|\\?|\\!/).length\nend", "def max_lines\n (contents.width / line_height) - 1\n end", "def maatsf_total_line_width(y = 0)\n contents_width\n end", "def get_lines\n lines = []\n read_file.each_line{|l| lines << l.chomp }\n @total_lines = lines.shift.to_i\n lines\n end", "def line_index(pos=pos)\n p = n = 0\n string.each_line do |line|\n p += line.length\n return n if p >= pos\n n += 1\n end\n 0\n end" ]
[ "0.9101023", "0.9101023", "0.87184674", "0.8558411", "0.8494818", "0.844529", "0.8258071", "0.8162386", "0.7946143", "0.7926586", "0.7897918", "0.7733357", "0.772134", "0.772134", "0.76482654", "0.76154155", "0.759892", "0.75958043", "0.7586319", "0.75692225", "0.7563106", "0.7540833", "0.75308865", "0.7504927", "0.74965084", "0.746408", "0.74588317", "0.74569076", "0.74527574", "0.7446508", "0.744344", "0.7426771", "0.7393519", "0.73919004", "0.73705256", "0.73158133", "0.73054224", "0.7282583", "0.72156113", "0.7198764", "0.71896476", "0.71896476", "0.7187713", "0.71819466", "0.7136439", "0.71157086", "0.70549315", "0.7054636", "0.70468295", "0.70447594", "0.70260864", "0.7025107", "0.70090216", "0.7003281", "0.69559795", "0.6942323", "0.6936666", "0.69307154", "0.6924483", "0.6922092", "0.6905574", "0.687948", "0.6807397", "0.6790181", "0.67760515", "0.67641443", "0.6721424", "0.67167807", "0.66945666", "0.6661369", "0.6660447", "0.66570556", "0.66515046", "0.6633117", "0.6633117", "0.6633117", "0.6633117", "0.6633117", "0.6633117", "0.6633117", "0.6630951", "0.6627778", "0.66262734", "0.6624785", "0.66182405", "0.66153437", "0.6612024", "0.6604533", "0.660167", "0.65852433", "0.6577243", "0.65645546", "0.65519786", "0.6546932", "0.6520624", "0.65140253", "0.65064615", "0.65001404", "0.6497226", "0.6471945" ]
0.8742464
2
stuff can be various things (document this)
def emit_changed(stuff) if stuff == nil @changed_handler.call(RangeList.new((0...num_lines))) else @changed_handler.call(RangeList.new(stuff)) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stuff\n end", "def writethis; end", "def doc; end", "def doc; end", "def doc; end", "def doc; end", "def extra; end", "def base_docstring; end", "def weber; end", "def doc=(_arg0); end", "def doc=(_arg0); end", "def doc=(_arg0); end", "def docstring; end", "def docstring; end", "def parts; end", "def parts; end", "def parts; end", "def parslet; end", "def parslet; end", "def parslet; end", "def parslet; end", "def buzzword; end", "def buzzword; end", "def custom; end", "def custom; end", "def docs=(_arg0); end", "def content=(_); end", "def specie; end", "def specie; end", "def specie; end", "def specie; end", "def who_we_are\r\n end", "def probers; end", "def document?; end", "def document?; end", "def docs; end", "def anatomy; end", "def method_that_says(stuff)\n\tputs (stuff)\nend", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def content; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document; end", "def document=(_arg0); end", "def document=(_arg0); end", "def document=(_arg0); end", "def document=(_arg0); end", "def document=(_arg0); end", "def document=(_arg0); end", "def document=(_arg0); end", "def document=(_arg0); end", "def document=(_arg0); end", "def parslets; end", "def section; end", "def under; end", "def headline; end", "def look_at(thing) # object\n case thing\n when Location\n puts \"You stand in a #{thing.descriptor}, #{thing.description}\"\n when Entity\n puts \"You see #{thing.full_name}. They're a #{thing.type}!\"\n else\n puts \"You can't see that thing.\"\n end\n puts ''\n end", "def specialty; end", "def usage; end", "def usage; end", "def how_it_works\r\n end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end", "def comment; end" ]
[ "0.6749312", "0.601931", "0.5891246", "0.5891246", "0.5891246", "0.5891246", "0.5870815", "0.57917994", "0.571982", "0.57120335", "0.57120335", "0.57120335", "0.56779754", "0.56779754", "0.56731564", "0.56731564", "0.56731564", "0.562318", "0.562318", "0.562318", "0.562318", "0.55924046", "0.55924046", "0.55922115", "0.55922115", "0.5575235", "0.55455804", "0.55410594", "0.55410594", "0.55410594", "0.55410594", "0.55348694", "0.5519125", "0.55182284", "0.55182284", "0.5506653", "0.54952055", "0.5446184", "0.54355246", "0.54355246", "0.54355246", "0.54355246", "0.54355246", "0.54355246", "0.54355246", "0.54355246", "0.54355246", "0.54355246", "0.54355246", "0.54355246", "0.54355246", "0.54355246", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.5433271", "0.54310054", "0.54310054", "0.54310054", "0.54310054", "0.54310054", "0.54310054", "0.54310054", "0.54310054", "0.54310054", "0.54287493", "0.5412084", "0.53960156", "0.53784466", "0.53778684", "0.53503203", "0.5349828", "0.5349828", "0.5338451", "0.53325033", "0.53325033", "0.53325033", "0.53325033", "0.53325033", "0.53325033", "0.53325033", "0.53325033", "0.53325033", "0.53325033" ]
0.0
-1
Sets the cursor's position to 'row', 'col'
def set_cursor_position(row, col) invalid_rows = [@cursor_row, row] @cursor_row, @cursor_col = row, col if @cursor_row < first_line_in_view set_contents_pos(0, line_num_to_coord(@cursor_row)) emit_changed(nil) elsif @cursor_row > last_line_in_view set_contents_pos(0, line_num_to_coord(@cursor_row - num_lines_in_view)) emit_changed(nil) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def restore_cursor_position() set_cursor_position(@event[\"line\"], @event[\"column\"]) end", "def set_position(row, col)\n if row.between?(0, 7) && col.between?(0, 7)\n @position[:row] = row\n\t @position[:col] = col\n\tend\n end", "def cursor_home\n @curpos = 0\n @pcol = 0\n set_col_offset 0\n end", "def pos=(val)\n #setter method for position \n row, col = val\n @pos = val\n\n end", "def ensure_cursor_visible\r\n self.top_col = index if index < top_col\r\n self.bottom_col = index if index > bottom_col\r\n end", "def setpos r=@row, c=@col\n #$log.debug \"setpos : (#{self.name}) #{r} #{c} XXX\"\n ## adding just in case things are going out of bounds of a parent and no cursor to be shown\n return if r.nil? or c.nil? # added 2009-12-29 23:28 BUFFERED\n return if r<0 or c<0 # added 2010-01-02 18:49 stack too deep coming if goes above screen\n @window.wmove r,c\n end", "def ensure_cursor_visible\n self.top_col = index if index < top_col\n self.bottom_col = index if index > bottom_col\n end", "def ensure_cursor_visible\n self.top_col = index if index < top_col\n self.bottom_col = index if index > bottom_col\n end", "def ensure_cursor_visible\n self.top_col = index if index < top_col\n self.bottom_col = index if index > bottom_col\n end", "def cur_pos=(idx)\n @cursor_moved=true\n @cursor.pos=idx\n end", "def cursor_at(row, col)\n \"\\e[#{row};#{col}H\"\nend", "def move row, col\n @row = row\n @col = col\n end", "def cursor_home\n @curpos = 0\n @pcol = 0\n set_form_col 0\n end", "def set_cursor(position)\r\n print locate((@disks*2+2)*@column+4, @disks+4-position)\r\n end", "def set_cursor_position locator, position\r\n command 'setCursorPosition', locator, position\r\n end", "def set_cursor_position(x, y)\n if stdout && x && y\n coord = Coord.new(x, y)\n self.set_console_cursor_position(stdout, coord)\n end\n end", "def cursor\n @cursor ||= Vedeu::Editor::Cursor.new(y: 0,\n x: 0,\n by: by,\n bx: bx,\n byn: byn,\n bxn: bxn)\n end", "def cursor_to( row, col, do_display = DONT_DISPLAY, stopped_typing = STOPPED_TYPING, adjust_row = ADJUST_ROW )\n old_last_row = @last_row\n old_last_col = @last_col\n\n row = row.fit( 0, @lines.length - 1 )\n\n if col < 0\n if adjust_row\n if row > 0\n row = row - 1\n col = @lines[ row ].length\n else\n col = 0\n end\n else\n col = 0\n end\n elsif col > @lines[ row ].length\n if adjust_row\n if row < @lines.length - 1\n row = row + 1\n col = 0\n else\n col = @lines[ row ].length\n end\n else\n col = @lines[ row ].length\n end\n end\n\n if adjust_row\n @desired_column = col\n else\n goto_col = [ @desired_column, @lines[ row ].length ].min\n if col < goto_col\n col = goto_col\n end\n end\n\n new_col = tab_expanded_column( col, row )\n view_changed = show_character( row, new_col )\n @last_screen_y = row - @top_line\n @last_screen_x = new_col - @left_column\n\n @typing = false if stopped_typing\n @last_row = row\n @last_col = col\n @last_screen_col = new_col\n changed = ( @last_row != old_last_row or @last_col != old_last_col )\n if changed\n record_mark_start_and_end\n\n removed = false\n if not @changing_selection and selecting?\n remove_selection( DONT_DISPLAY )\n removed = true\n end\n if removed or ( do_display and ( selecting? or view_changed ) )\n display\n else\n @diakonos.display_mutex.synchronize do\n @win_main.setpos( @last_screen_y, @last_screen_x )\n end\n end\n @diakonos.update_status_line\n @diakonos.update_context_line\n\n @diakonos.remember_buffer self\n end\n\n changed\n end", "def mvtb_cursor(x,y)\n (p=$game_player).x = x; p.y = y\n end", "def define_cursor_rect\n cursor_rect.set(-4, @index * default_line_height, cursorskin.width, cursorskin.height)\n end", "def cursor_bol\n # copy of C-a - start of line\n @repaint_required = true if @pcol > 0\n @pcol = 0\n @curpos = 0\n end", "def position\n [ @row_offset, @col_offset ]\n end", "def c_topleft\n print cursor.column(0)\n print cursor.row(0)\n end", "def cursor(*options)\n options = combine_options(*options)\n apply_offset(options)\n @cursor_loc ||= {}\n @cursor_loc[:x] = options[:to][:left]\n @cursor_loc[:y] = options[:to][:top]\n \n compatible_call :cursor, @cursor_loc\n end", "def update_cursor\n cursor_rect.set((@index % 2) * DELTA_X, (@index / 2) * DELTA_Y)\n $game_system.se_play($data_system.cursor_se)\n end", "def move_to(row, col)\n @row, @col = wrap(row, col)\n end", "def home()\n\t\t@cursor_y = 0\n\t\t@cursor_x = 0\n\tend", "def cursor_reposition!\n Vedeu.bind(:_cursor_reposition_) do |name, y, x|\n Vedeu.cursors.by_name(name).reposition(y, x)\n\n Vedeu.trigger(:_clear_, name)\n Vedeu.trigger(:_refresh_, name)\n Vedeu.trigger(:_refresh_cursor_, name)\n end\n end", "def move\n @cursor.x = wrap(@cursor.x + @delta.x, @code.width)\n @cursor.y = wrap(@cursor.y + @delta.y, @code.height)\n end", "def set_Cursor(value)\n set_input(\"Cursor\", value)\n end", "def set_Cursor(value)\n set_input(\"Cursor\", value)\n end", "def set_Cursor(value)\n set_input(\"Cursor\", value)\n end", "def set_Cursor(value)\n set_input(\"Cursor\", value)\n end", "def set_Cursor(value)\n set_input(\"Cursor\", value)\n end", "def set_Cursor(value)\n set_input(\"Cursor\", value)\n end", "def set_Cursor(value)\n set_input(\"Cursor\", value)\n end", "def set_Cursor(value)\n set_input(\"Cursor\", value)\n end", "def set_Cursor(value)\n set_input(\"Cursor\", value)\n end", "def set_Cursor(value)\n set_input(\"Cursor\", value)\n end", "def set_Cursor(value)\n set_input(\"Cursor\", value)\n end", "def set_Cursor(value)\n set_input(\"Cursor\", value)\n end", "def set_Cursor(value)\n set_input(\"Cursor\", value)\n end", "def set_Cursor(value)\n set_input(\"Cursor\", value)\n end", "def update_cursor_pos\n @cursor_timer = 0\n pos = @text.virtual_position\n if pos == 0\n @cursor.x = 1\n else\n @cursor.x = @sprite.bitmap.text_size(value[0...pos]).width\n end\n end", "def set_mouse_position(x, y); end", "def cursor_end\n blen = @buffer.rstrip.length\n if blen < @width\n set_col_offset blen\n else\n @pcol = blen-@width\n #set_form_col @width-1\n set_col_offset blen\n end\n @curpos = blen # this is position in array where editing or motion is to happen regardless of what you see\n # regardless of pcol (panning)\n end", "def OLDsetrowcol r, c\n $log.debug \" SCROLL setrowcol #{r}, #{c} + #{@cols_panned}\"\n # aha ! here's where i can check whether the cursor is falling off the viewable area\n cc = nil\n rr = nil\n if c\n cc = c #+ @cols_panned\n if c+@cols_panned < @orig_left\n # this essentially means this widget (button) is not in view, its off to the left\n $log.debug \" setrowcol OVERRIDE #{c} #{@cols_panned} < #{@orig_left} \"\n $log.debug \" aborting settrow col for now\"\n return\n end\n if c+@cols_panned > @orig_left + @display_w\n # this essentially means this button is not in view, its off to the right\n $log.debug \" setrowcol OVERRIDE #{c} #{@cols_panned} > #{@orig_left} + #{@display_w} \"\n $log.debug \" aborting settrow col for now\"\n return\n end\n end\n if r\n rr = r+@rows_panned\n end\n super rr, cc\n end", "def cur_pos\n @cursor.pos\n end", "def coord(col, row = 0)\n coordinates = parse_coord_args(col, row)\n self.col = coordinates[0]\n self.row = coordinates[1]\n end", "def cursor_x\n contents_width - cursor_width - 4\n end", "def cursor_x\n contents_width - cursor_width - 4\n end", "def cursor_x\n contents_width - cursor_width - 4\n end", "def cursor_forward\n $multiplier = 1 if $multiplier == 0\n if @curpos < @cols\n @curpos += $multiplier\n if @curpos > @cols\n @curpos = @cols\n end\n @repaint_required = true\n end\n $multiplier = 0\n end", "def set_form_col col1=@curpos\n @curpos = col1 || 0 # NOTE we set the index of cursor here\n c = @col + @col_offset + @curpos - @pcol\n min = @col + @col_offset\n max = min + @width\n c = min if c < min\n c = max if c > max\n #$log.debug \" #{@name} FIELD set_form_col #{c}, curpos #{@curpos} , #{@col} + #{@col_offset} pcol:#{@pcol} \"\n setrowcol nil, c\n end", "def cursor_position!\n Vedeu.bind(:_cursor_position_) do |name|\n Vedeu.cursors.by_name(name).position\n end\n end", "def setxy(x, y)\n setpos y, x\n end", "def set_mouse_pos _x, _y\n send_cmd(\"set_mouse_pos #{_x} #{_y}\")\n end", "def setrowcol r, c\n # aha ! here's where i can check whether the cursor is falling off the viewable area\n if c+@cols_panned < @orig_left\n # this essentially means this widget (button) is not in view, its off to the left\n $log.debug \" setrowcol OVERRIDE #{c} #{@cols_panned} < #{@orig_left} \"\n $log.debug \" aborting settrow col for now\"\n return\n end\n if c+@cols_panned > @orig_left + @display_w\n # this essentially means this button is not in view, its off to the right\n $log.debug \" setrowcol OVERRIDE #{c} #{@cols_panned} > #{@orig_left} + #{@display_w} \"\n $log.debug \" aborting settrow col for now\"\n return\n end\n super r+@rows_panned, c+@cols_panned\n end", "def set_loc(x, y)\n @curr_x = x\n @curr_y = y\n end", "def cursor_origin!\n Vedeu.bind(:_cursor_origin_) do |name|\n Vedeu.cursors.by_name(name).move_origin\n end\n\n Vedeu.bind_alias(:_cursor_reset_, :_cursor_origin_)\n end", "def move_cursor(input)\n\n if input == 'w'\n dx,dy = [-1,0]\n elsif input == 's'\n dx,dy = [1,0]\n elsif input == 'a'\n dx,dy = [0,-1]\n elsif input == 'd'\n dx,dy = [0,1]\n elsif input == 'q'\n exit\n end\n\n\n x, y = [cursor[0] + dx, cursor[1] + dy]\n #returns cursor position, doesn't return a new cursor UNLESS x, and y are between 0 and 7, valid board spaces\n self.cursor = ([x, y].all? { |i| i.between?(0, 7) } ? [x, y] : self.cursor)\n end", "def update_position\r\n # update selection for grid[col][row]\r\n #puts \"#{@grid[2][0]}\"\r\n \r\n puts \"Enter the row, column and value for your selection.\"\r\n print \"row: \"\r\n row = gets.chomp.to_i\r\n print \"column: \"\r\n col = gets.chomp.to_i\r\n print \"value: \"\r\n val = gets.chomp.to_s\r\n puts\r\n\r\n @grid[row][col] = val\r\n\r\n end", "def setposition(x,y)\n\t\t@x = x\n\t\t@y = y\n\tend", "def go_to(rows,cols,face=nil)\n \tface = 'north' if (rows == 0 && cols == 0)\n @position.change ({:x => rows, :y => cols, :face => face.to_sym}) if face\n end", "def []=(pos, figure)\n x, y = pos\n @rows[x][y] = figure\n end", "def []=(pos, val)\n x,y = pos\n @rows[x][y] = val\n end", "def move_cursor(row = nil)\n if row\n if (prev_item = items[current_row])\n main.draw_item prev_item\n end\n page = row / max_items\n switch_page page if page != current_page\n main.activate_pane row / maxy\n @current_row = row\n else\n @current_row = 0\n end\n\n item = items[current_row]\n main.draw_item item, current: true\n main.display current_page\n\n header_l.draw_current_file_info item\n @current_row\n end", "def position\n [row.position, column.position]\n end", "def store_cursor_position locator, variable_name\r\n command 'storeCursorPosition', locator, variable_name\r\n end", "def lastcurpos r,c\n @lastrow = r\n @lastcol = c\n end", "def step_cursor()\r\n unless @@busy_cursors \r\n self.class.send(:get_cursors)\r\n end\r\n \r\n @cursor_index = (@cursor_index + 1) % 8\r\n UI.set_cursor(@@busy_cursors[@cursor_index]) if @mouse_in_viewport\r\n end", "def cursor_dn\n @cursor_movement = :down\n @old_cursor = @cursor\n move_to(pos + 1)\nend", "def moveto(point={})\n set RGhost::Cursor.moveto(point)\n end", "def change_cursor\n cursor = text_cursor\n yield cursor\n self.text_cursor = cursor\n end", "def c_bottomleft\n print cursor.column(0)\n print cursor.row(height)\n end", "def move_by(row_delta, col_delta)\n @row, @col = wrap(@row + row_delta, @col + col_delta)\n end", "def col\r\n @lines[@line_num].cursor\r\n end", "def set_screen_row_col top, left=-1\n @top = top\n @left = left unless left < 0\n end", "def set(max, position)\n @max = max\n @number = 1\n @cursor_y = position\n refresh\n end", "def set_cell_coordinates\n x = 0\n while x < 6\n y = 0\n while y < 7\n grid[x][y].co_ord = [x + 1, y + 1]\n y += 1\n end\n x += 1\n end\n end", "def setrowcol r, c\n @row = r unless r.nil?\n @col = c unless c.nil?\n end", "def set_selection_for_char char\n @oldrow = @current_index\n ix = next_match char\n @current_index = ix if ix && ix != -1\n bounds_check\n return ix\n end", "def setup!\n cursor_origin!\n cursor_position!\n cursor_reposition!\n directional!\n end", "def set_current_row_col(array)\r\n current_s_index = array.locate2d(' ')\r\n @current_row = current_s_index.flatten.first\r\n @current_col = current_s_index.flatten.last\r\n end", "def cursor(value)\n attributes[:cursor] = value\n end", "def move_cursor(index)\n cursor = $arrows.index(\"^\")\n $arrows[index], $arrows[cursor] = $arrows[cursor], $arrows[index]\nend", "def cursor\n y - bounds.absolute_bottom\n end", "def north(i=@cursor) i-width end", "def set_current_cell\n @current_cell = @map.cells_at[@x][@y]\n end", "def update start_row, start_col, end_row, end_col\n temp = @board[start_row][start_col]\n @board[start_row][start_col] = \"[ ]\"\n @board[end_row][end_col] = temp\n end", "def cursor_y\n return 2\n end", "def cursor(*options)\n options = combine_options(*options)\n\n apply_offset(options)\n @cursor_loc ||= {}\n @cursor_loc[:x] = options[:to][:left]\n @cursor_loc[:y] = options[:to][:top]\n\n options[:speed] ||= 1\n\n automatically \"mousemove #{@cursor_loc[:x]} #{@cursor_loc[:y]} #{options[:speed]}\"\n end", "def cursor=(cur)\n\t\t\tLcdProto.lcdPosition(@fd, cur[1], cur[0])\n\t\t\t@cursor = cur\n\t\tend", "def rmoveto(point={})\n set RGhost::Cursor.rmoveto(point)\n end", "def set_form_row\n r,c = rowcol\n @rows_panned ||= 0\n \n #win_row=@form.window.top\n win_row=@win_top # 2010-02-11 15:12 RFED16\n win_row = 0 # 2010-02-07 21:44 now ext offset added by widget\n #win_row = 0 # new approach, we have it \n #win_col=@form.window.left\n # added 1 ?? in copywin too 2010-02-11 18:51 RFED16 this results in extra in normal situations.\n row = win_row + r + (@current_index-@toprow) + @rows_panned \n $log.debug \" #{@name} LIST set_form_row #{row} = ci #{@current_index} + r #{r} + winrow: #{win_row} - tr:#{@toprow} #{@toprow} + rowsp #{@rows_panned} \"\n $log.debug \" - LIST set_form_row row_offset: #{@row_offset} + r #{r} + ci - topr + rowsp: #{@rows_panned}. c= #{c} \"\n\n ## 2009-12-28 23:05 TRYING OUT but i really can't do this everywhere. BUFFERED\n ## this needs to percolate up a heirarchy.\n ## 2010-01-05 21:09 changed c to nil, since c is not cursor col pos but where printing starts, i think\n #@form.setrowcol row, nil\n #setformrowcol row, nil\n setrowcol row, nil\n show_caret_func\n end", "def[]=(pos, value)\n row = pos.first\n col = pos.last\n @grid[row][col] = value\n end", "def move_to position\n orig = @cursor\n place_cursor(CLEAR) if @highlight_row_flag\n @cursor = position\n @cursor = [@cursor, @view.size - 1].min\n @cursor = [@cursor, 0].max\n\n # try to stop it from landing on separator\n if current_file == SEPARATOR\n @cursor += 1 if @cursor_movement == :down\n @cursor -= 1 if @cursor_movement == :up\n # 2019-06-01 - remove return in case scrolling happens here\n # return\n end\n\n # 2019-03-18 - adding sta\n # @sta = position - only when page flips and file not visible\n # FIXME not correct, it must stop at end or correctly cycle\n # sta goes to 0 but cursor remains at 70\n # viewport.size may be wrong here, maybe should be pagesize only\n oldsta = @sta\n if @cursor - @sta >= @pagesize\n @sta += @pagesize\n # elsif @sta - @cursor >= @vps\n end\n if @sta > @cursor\n @sta -= @pagesize\n # @sta = @cursor\n end\n\n @cursor_movement = nil if oldsta != @sta # we need to redraw\n\n # -------- return here --- only visual mode continues ---------------------#\n return unless @visual_mode\n\n star = [orig, @cursor].min\n fin = [orig, @cursor].max\n @cursor_movement = nil # visual mode needs to redraw page\n\n # PWD has to be there in selction\n # FIXME with visited_files\n if selected? File.join(@current_dir, current_file)\n # this depends on the direction\n # @selected_files = @selected_files - @view[star..fin]\n remove_from_selection @view[star..fin]\n ## current row remains in selection always.\n add_to_selection current_file\n else\n # @selected_files.concat @view[star..fin]\n add_to_selection @view[star..fin]\n end\n message \"#{@selected_files.count} files selected. \"\nend", "def set_position(x, y)\n @pos_x = x\n @pos_y = y\n end", "def moveto *args\n row,col = *({ :row => nil, :col => nil}.merge(args.first).values rescue args)\n cmd = (col and row) ? :cup : (col ? :hpa : (row ? :vpa : :home))\n __send__(cmd, [row, col].compact)\n end", "def set_mark(pos, mark)\n\t row, col = to_row_col(pos)\n\t return if row.nil? || col.nil?\n\t @grid[row][col] = mark\n\tend" ]
[ "0.76773417", "0.7410794", "0.7367086", "0.72834444", "0.7256796", "0.723927", "0.72136575", "0.72136575", "0.72136575", "0.7210068", "0.7180605", "0.7059563", "0.70543504", "0.6995929", "0.69584244", "0.68167746", "0.6764925", "0.6745875", "0.67443615", "0.6712027", "0.6711861", "0.6705176", "0.66460335", "0.6610974", "0.6607707", "0.66037476", "0.6577945", "0.65031785", "0.6491792", "0.6476543", "0.6476543", "0.6476543", "0.6476543", "0.6476543", "0.6476543", "0.6476543", "0.6476543", "0.6476543", "0.6476543", "0.6476027", "0.6476027", "0.6475508", "0.6475508", "0.6472233", "0.6413282", "0.6385583", "0.63372386", "0.63333845", "0.63321483", "0.6327621", "0.63274413", "0.63274413", "0.6321513", "0.632113", "0.6317642", "0.6302311", "0.6290471", "0.6277772", "0.6270556", "0.6222898", "0.6213962", "0.6213648", "0.6205689", "0.6186408", "0.61813545", "0.616122", "0.61534905", "0.61337185", "0.6126018", "0.612363", "0.61200243", "0.60986143", "0.60971755", "0.6084713", "0.60828835", "0.6074501", "0.60564095", "0.6048972", "0.60007423", "0.59948653", "0.5984081", "0.5976265", "0.5964614", "0.59499425", "0.59401244", "0.5938713", "0.59218925", "0.5909779", "0.59087425", "0.5904395", "0.5895958", "0.587816", "0.5857878", "0.58576006", "0.5856672", "0.5856092", "0.5852144", "0.58472925", "0.5837831", "0.5836958" ]
0.83647645
0
Inserts text at the cursor's current position and updates cursor
def insert_text_at_cursor(text) insert_text(@cursor_row, @cursor_col, text) if text.include?("\n") #todo what about multiple \n's @cursor_row += 1 @cursor_col = 0 #resize_contents(500, line_num_to_coord(@text.num_lines + 1)) emit_changed(@cursor_row - 1) else @cursor_col += text.length emit_changed(@cursor_row) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def handle_text_insertion pos, text\n add_command InsertionCommand.new(pos, text)\n end", "def insert(text, at: caret)\n editable? and @native.insert_text(at.to_i, text.to_s, text.to_s.length)\n end", "def insertText cursor, text\n if @fileContent.size == 1 and @fileContent[0] == \"\"\n dataStr = insertTextEmptyFile cursor, text\n else\n dataStr = insertTextFilledFile cursor, text\n end\n splitSize = insertTextSplitFlatten cursor\n insertTextCursorReplacement text, cursor, splitSize, dataStr\n end", "def insert_text(text)\n # Create the mark tag if not exist\n @buffer.insert(@buffer.end_iter, text)\n if (not @buffer.get_mark('end_mark'))\n @buffer.create_mark('end_mark', @buffer.end_iter, false)\n end\n\n # Save our offset\n @@offset = @buffer.end_iter.offset\n\n # Scrolled the view until the end of the buffer\n @textview.scroll_mark_onscreen(@buffer.get_mark('end_mark'))\n end", "def insert_selection\n insert(cursor, Tk::Selection.get(type: 'UTF8_STRING'))\n end", "def insert(chars)\n self[@cursor] = chars\n end", "def insert(chars)\n self[@cursor] = chars\n end", "def insert(text)\n chars = @text.scan(/./m)\n return if chars.size >= @max_length\n # limiting characters\n new_chars = text.scan(/./m)\n if chars.size + new_chars.size > @max_length\n new_chars = new_chars[0, @max_length - chars.size]\n end\n # it's possible that text contains tab characters which are forbidden\n while new_chars.include?(\"\\t\")\n new_chars.delete(\"\\t\")\n end\n return if new_chars.size == 0\n # split text at cursor position\n left = (@cursor_position > 0 ? chars[0, @cursor_position] : [])\n if @cursor_position < chars.size\n right = chars[@cursor_position, chars.size - @cursor_position]\n else\n right = []\n end\n # move cursor\n @cursor_position += new_chars.size\n # put together the split halves with the new text inbetween\n self.text = (left + new_chars + right).join\n self.reset_cursor_blinking\n end", "def insert(text)\n normal \"i#{text}\"\n end", "def insert_text(text:)\n {\n method: \"Input.insertText\",\n params: { text: text }.compact\n }\n end", "def insert(cursor, string)\n string.split(Pattern).each_with_index do |str, i|\n if i.even?\n cursor.insert_text str\n else\n enable_ansi_code(cursor, str)\n end\n end\n end", "def entering text, options = {}\n widget = find_widget options[:into]\n widget.insert_text text, widget.position\n process_events\nend", "def overwriteText cursor, text\n if cursor.isAtEOL? or cursor.isAtEOF?\n insertText cursor, text\n else\n overwrite cursor, text\n end\n end", "def insert_text(line, col, text) \n\t\tindex = index_of_position(line, col)\n\t\t@text.insert(index, text)\n\t\ti = 0\n\t\ti += 1 while i < @line_indices.length and @line_indices[i] < index\n\t\t(0...text.length).each do |c|\n\t\t\tif text[c,1] == \"\\n\"\n\t\t\t\t@line_indices.insert(i, index + c)\n\t\t\t\ti += 1\n\t\t\tend\n\t\tend\n\t\t(i ... @line_indices.length).each { |i| @line_indices[i] += text.length }\n\tend", "def insert_completion(completion)\n cursor = text_cursor\n size = completion.size - @completer.completion_prefix.size\n\n cursor.move_position Qt::TextCursor::Left\n cursor.move_position Qt::TextCursor::EndOfWord\n\n return unless can_write_from? cursor.position\n\n cursor.insert_text completion[-size..-1]\n self.text_cursor = text_cursor\n\n highlight\n end", "def insertTextEmptyFile cursor, text\n puts \"\\t\\t#{text.inspect}\"\n @fileContent[cursor.line].replace splitText text\n text\n end", "def insert_text_after(text)\r\n text_run = get_run_after\r\n text_run.text = \"#{text}#{text_run.text}\"\r\n end", "def put_text_node_at(position)\n clear_insert_toolbar_before(@current_edited_node_position)\n @current_edited_node_position = position\n nodes.insert(position + 1, PostNode.new(node: PostText.new, node_type: 'PostText'))\n set_state post: state.post\n end", "def insert(text)\n raise \"must be passed string\" unless text.is_a?(String)\n\n snippet = Snippet.new_text(core, text)\n snippet.snippet_tags.each do |tag_info|\n visit tag_info[:tag]\n end\n\n context = Context.new(nil)\n insert_func(snippet, context).join($/)\n end", "def replace(text)\n @text = text\n @cursor = @text.length # put cursor outside of text\n end", "def insert_text(position, pattern, new_text)\n index = case pattern\n when Regexp\n if match = @body.match(pattern)\n match.offset(0)[position == :before ? 0 : 1]\n else\n @body.size\n end\n else\n pattern\n end\n @body.insert index, new_text\n end", "def editor_insert_character!\n Vedeu.bind(:_editor_insert_character_) do |name, character|\n Vedeu.documents.by_name(name).insert_character(character)\n end\n end", "def insert_after\r\n @lines.insert(@line_num, TextLineBuffer.new(\"\"))\r\n @line_num = @line_num + 1\r\n end", "def insert(pos,content)\n content=rowify(content)\n \n enforce_valid(pos)\n\n if pos.is_a? BufferRegion\n unless pos.empty?\n delete(pos)\n end\n cursor=pos.start_pos.to_mutable\n end\n cursor ||= pos.to_mutable\n hanging_line=nil\n row=nil\n content.each do |new_line|\n\n\n row=@rows[cursor.row]\n row = row.clone if row\n\n if hanging_line!=nil\n #this is a wholly new line\n row=new_line.clone\n add_row(cursor.row,row)\n\n else\n\n hanging_line = row.slice!(cursor.column..-1)\n row << new_line\n modify_row(cursor.row,row)\n end\n\n if row.chomp!\n row=\"\"\n add_row(cursor.row+1,row)\n\n\n cursor.next_row!\n end\n cursor.next_row! unless new_line==content.last\n end\n\n\n if hanging_line\n cursor.column=row.length\n row << hanging_line\n modify_row(cursor.row,row)\n\n end\n\n invalidate \n cursor.to_immutable\n end", "def insert_text_before(text)\r\n text_run = get_run_before\r\n text_run.text = \"#{text_run.text}#{text}\"\r\n end", "def insert_text(row, column, text, style = CharacterStyle.default)\n text.each_char do |char|\n self[row][column] = Character.new(char, style)\n column += 1\n end\n self\n end", "def text=(new_text)\n @text = new_text\n refresh\n update_cursor\n end", "def rl_insert_text(string)\r\n string.delete!(0.chr)\r\n l = string.length\r\n return 0 if (l == 0)\r\n\r\n if (@rl_end + l >= @rl_line_buffer.length)\r\n rl_extend_line_buffer(@rl_end + l)\r\n end\r\n @rl_line_buffer[@rl_point,0] = string\r\n\r\n # Remember how to undo this if we aren't undoing something.\r\n if (!@_rl_doing_an_undo)\r\n # If possible and desirable, concatenate the undos.\r\n if ((l == 1) &&\r\n @rl_undo_list &&\r\n (@rl_undo_list.what == UNDO_INSERT) &&\r\n (@rl_undo_list.end == @rl_point) &&\r\n (@rl_undo_list.end - @rl_undo_list.start < 20))\r\n @rl_undo_list.end+=1\r\n else\r\n rl_add_undo(UNDO_INSERT, @rl_point, @rl_point + l, nil)\r\n end\r\n end\r\n @rl_point += l\r\n @rl_end += l\r\n if @rl_line_buffer.length <= @rl_end\r\n @rl_line_buffer << 0.chr * (@rl_end - @rl_line_buffer.length + 1)\r\n else\r\n @rl_line_buffer[@rl_end] = \"\\0\"\r\n end\r\n l\r\n end", "def put_to_new_next_line(txt)\n l = current_line_range()\n insert_txt_at(txt, l.end + 1)\n set_pos(l.end + 1)\n end", "def insert_text(position, pattern, new_text, indentation = 4)\n index = case pattern\n when Regexp\n if match = @body.match(pattern)\n match.offset(0)[position == :before ? 0 : 1]\n else\n @body.size\n end\n else\n pattern\n end\n @body.insert index, indent(indentation, new_text)\n end", "def move_to_end\n @cursor = @text.length # put cursor outside of text\n end", "def move_to_end\n @cursor = @text.length # put cursor outside of text\n end", "def _rl_replace_text(text, start, _end)\r\n rl_begin_undo_group()\r\n rl_delete_text(start, _end + 1)\r\n @rl_point = start\r\n n = rl_insert_text(text)\r\n rl_end_undo_group()\r\n n\r\n end", "def paste(text)\n can_refresh = false\n # Attempt to insert every character individually\n text.split(\"\").each do |ch|\n break unless @helper.insert(ch)\n can_refresh = true\n end\n # Only refresh if characters were inserted\n self.refresh if can_refresh\n end", "def update_cursor_pos\n @cursor_timer = 0\n pos = @text.virtual_position\n if pos == 0\n @cursor.x = 1\n else\n @cursor.x = @sprite.bitmap.text_size(value[0...pos]).width\n end\n end", "def winsertln\n Ncurses.winsertln(pointer)\n end", "def replace(text)\n @text = text\n @cursor = @text.length # put cursor outside of text\n replace_mode\n end", "def insert buffer, text\n @frames[buffer].fillBuffer buffer, text\n end", "def insert_string(str, pos)\n StringInserter.new(self, str, pos).insert_string\n end", "def position_inserted(position)\n end", "def add_instant_text(text)\n @lines.push(text)\n refresh\n end", "def insert_line lineno=@current_index\n prompt = \"Insert: \"\n maxlen = 80\n #config={}; \n #config[:default] = line\n #ret, str = rb_getstr(@form.window, $error_message_row, $error_message_col, prompt, maxlen, config)\n ret, str = input_string prompt\n #ret, str = rb_getstr(@form.window, @row+@height-1, @col+1, prompt, maxlen, config)\n $log.debug \" rb_getstr returned #{ret} , #{str} \"\n return if ret != 0\n\n # pad based expect @content not list\n # remove list after a while FIXME\n @list ||= @content\n @list.insert lineno, str\n ## added handler on 2010-05-23 11:46 - undo works - tested in testlistbox.rb\n fire_handler :CHANGE, InputDataEvent.new(0,str.length, self, :INSERT_LINE, lineno, str)\n fire_dimension_changed\n end", "def insert_character(character, index = nil)\n return self unless character\n\n Vedeu::Editor::Line.coerce(Vedeu::Editor::Insert\n .into(line, character, index, size))\n end", "def insert_after(range, content); end", "def insert_after(range, content); end", "def insert_after(range, content); end", "def insert_after(range, content); end", "def insert_after(range, content); end", "def insert_after(range, content); end", "def insert_after(range, content); end", "def insert_after(range, content); end", "def move\n @cursor.x = wrap(@cursor.x + @delta.x, @code.width)\n @cursor.y = wrap(@cursor.y + @delta.y, @code.height)\n end", "def insert_text\n attributes.fetch(:insertText)\n end", "def handle_insert\n return unless previous_edited?\n snippet = @snippet_loader.current_snippets.find { |snip| snip.pressed? }\n if snippet\n snippet.insert_snippet \n @history.clear\n end\n end", "def insert_character(character, index = nil)\n return self unless character\n\n Vedeu::Editor::Line.coerce(Vedeu::Editor::Insert\n .into(collection, character, index, size))\n end", "def editor_insert_line!\n Vedeu.bind(:_editor_insert_line_) do |name|\n Vedeu.documents.by_name(name).insert_line\n end\n end", "def <<(char)\n @text << char\n @cursor += 1\n end", "def <<(char)\n @text << char\n @cursor += 1\n end", "def insert_line\n down\n\n @lines = lines.insert_line(Vedeu::Editor::Line.new, y)\n\n bol\n\n refresh\n end", "def insert(k)\n\t\t\tif k == Ruvim::API::CR then\n\t\t\t\tcr\n\t\t\telse\n\t\t\t\t@buffer.insert k\n\t\t\t\tforward\n\t\t\t\tredraw_line\n\t\t\tend\n\t\t\tself\n\t\tend", "def insert_tab\n insert(cursor, \"\\t\")\n end", "def []=(i, chars)\n edit_mode\n\n if i.is_a?(Range)\n @text[i] = chars\n @cursor += chars.length\n return\n end\n\n if i <= 0\n before_text = \"\"\n after_text = @text.dup\n elsif i > @text.length - 1 # insert outside of line input\n before_text = @text.dup\n after_text = ?\\s * (i - @text.length)\n @cursor += after_text.length\n else\n before_text = @text[0..i-1].dup\n after_text = @text[i..-1].dup\n end\n\n if i > @text.length - 1\n @text = before_text + after_text + chars\n else\n @text = before_text + chars + after_text\n end\n\n @cursor = i + chars.length\n end", "def change_cursor\n cursor = text_cursor\n yield cursor\n self.text_cursor = cursor\n end", "def insert_some_chars(string, count, col)\r\n if @hConsoleHandle\r\n _rl_output_some_chars(string,0,count)\r\n else\r\n # DEBUGGING\r\n if (@rl_byte_oriented)\r\n if (count != col)\r\n $stderr.write(\"readline: debug: insert_some_chars: count (#{count}) != col (#{col})\\n\");\r\n end\r\n end\r\n # If IC is defined, then we do not have to \"enter\" insert mode.\r\n #if (@_rl_term_IC)\r\n # buffer = tgoto(@_rl_term_IC, 0, col)\r\n # @_rl_out_stream.write(buffer)\r\n # _rl_output_some_chars(string,0,count)\r\n #else\r\n # If we have to turn on insert-mode, then do so.\r\n if (@_rl_term_im)\r\n @_rl_out_stream.write(@_rl_term_im)\r\n end\r\n # If there is a special command for inserting characters, then\r\n # use that first to open up the space.\r\n if (@_rl_term_ic)\r\n @_rl_out_stream.write(@_rl_term_ic * count)\r\n end\r\n\r\n # Print the text.\r\n _rl_output_some_chars(string,0, count)\r\n\r\n # If there is a string to turn off insert mode, we had best use\r\n # it now.\r\n if (@_rl_term_ei)\r\n @_rl_out_stream.write(@_rl_term_ei)\r\n end\r\n #end\r\n end\r\n end", "def insert_character(character)\n return self if character.is_a?(Symbol)\n\n @lines = lines.insert_character(character, y, x)\n\n right\n\n refresh\n end", "def insert_text(out = nil)\n print out if out\n exit 203\n end", "def insertCompletion(word, forPartialWordRange:range, movement:movement, isFinal:flag)\n\n # If we're inserting the word and it starts at the beginning, append a colon\n if flag == true and range.location == 0\n word = word + \":\"\n end\n \n super word, range, movement, flag\n end", "def insert_character(char)\n @background_grid[@state.row][@state.column] = Character.new(char, @state.style.dup)\n @state.column += 1\n end", "def render_cursor\n # This is necessary to handle characters that render\n # as more or less than 1 character, such as e.g. tabs.\n y = cursor.row\n x = editor.model.cursor_x(y, cursor.col-@xoff)+text_xoff\n\n # Make cursor visible even if currently no character\n # FIXME: Update AnsiTerm w/function to allow forcing a space\n # w/out this\n l = @out.lines[cursor.row-@top]\n if !l || !l[x]\n @out.move_cursor(x,cursor.row-@top)\n @out.print(\" \")\n end\n l = @out.lines[cursor.row-@top]\n l.set_attr(x..x, @cursor_attr)\n end", "def insert_before(range, content); end", "def insert_before(range, content); end", "def insert_before(range, content); end", "def insert_before(range, content); end", "def insert_before(range, content); end", "def insert_before(range, content); end", "def insert_before(range, content); end", "def insert_before(range, content); end", "def insert_word(word, x, y)\n for i in 0...word.length\n @grid[x][y+i] = word[i]\n end\n end", "def go_caret_word(newtab=false)\n go_word('insert', newtab)\n end", "def insert(pos, subwindow, options = {})\n execute_only(:insert, pos, subwindow, options.to_tcl_options)\n end", "def add(text)\n @text << text\n end", "def init_post_text_addition(position)\n clear_insert_toolbar_before(@current_edited_node_position)\n @current_edited_node_position = position\n\n modal_open(\n nil,\n t(Components::PostTexts::New, \n {\n on_done: ->(post_node){insert_node(post_node)},\n on_collect: ->(post_text, component){generic_create_node(post_text, component)}\n }\n )\n )\n end", "def add_text(text); end", "def cursor_move_to_end\n @cursor_position = @text.scan(/./m).size\n self.reset_cursor_blinking\n end", "def add(character)\n if @total_width + @char_widths[character] <= MAX_WIDTH and\n @text.size < @chars_max\n if $input_text_sound_mode == 1\n $game_system.se_play($data_system.cursor_se)\n end\n @text.size.downto(@index+1) do |i|\n @text[i] = @text[i-1]\n end\n @text[@index] = character\n @index += 1\n @cursor_x += @char_widths[character]\n else\n $game_system.se_play($data_system.cancel_se)\n end\n end", "def replace_instant_text(text)\n @lines.pop\n @lines.push(text)\n refresh\n end", "def set_cursor(position)\r\n print locate((@disks*2+2)*@column+4, @disks+4-position)\r\n end", "def enter_insert_mode\n\nend", "def add_result(res)\n change_cursor { |c|\n saved_format = c.char_format # moving changes char format\n c.move_position document.character_count - 1\n c.char_format = saved_format\n\n ANSIToQt.insert(c, res)\n }\n end", "def insert(name, tag, value)\n set_text_content(name, tag, @klass, value)\n end", "def insert_at(position = acts_as_list_top)\n insert_at_position(position)\n end", "def insert_row filename, lineno, text\n d = _read filename\n d.insert(lineno, text)\n _write filename, d\n 0\n end", "def replace_line(line)\n cursor = text_cursor\n\n cursor.position = document.character_count - 1\n cursor.set_position(@min_position, Qt::TextCursor::KeepAnchor)\n\n cursor.insert_text line\n\n change_cursor { |c| c.position = document.character_count - 1 }\n\n highlight\n end", "def insert_into_transcript\n @transcript_lines << {\n transcript_id: @transcript_id,\n start_time: @line_temp[:from],\n end_time: @line_temp[:to],\n original_text: @line_temp[:lines].join(' '),\n sequence: (@line_number - 1)\n }\n @line_number += 1\n end", "def update_cursor\n cursor_rect.set((@index % 2) * DELTA_X, (@index / 2) * DELTA_Y)\n $game_system.se_play($data_system.cursor_se)\n end", "def cursor(position)\n new_cursor = @undo_page.cursor(position)\n if @undo_log\n new_cursor.push_name(\"undo_log[#{@undo_log.position}]\")\n end\n new_cursor.push_name(\"undo_record[#{@position}]\")\n new_cursor\n end", "def set_left(text)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n Native.TextComponent_set_left(@handle.ptr, text)\n end", "def addchar(c)\n\t\tif @marked == false\n\t\t\tinsertchar(@row,@col,c.chr)\n\t\telse\n\t\t\tmark_row,row = ordered_mark_rows\n\t\t\tfor r in mark_row..row\n\t\t\t\tif (@text[r].length==0)&&((c==?\\s)||(c==?\\t)||(c==$ctrl_i)||(c==$space))\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tif @colmode\n\t\t\t\t\tsc = bc2sc(@row,@col)\n\t\t\t\t\tcc = sc2bc(r,sc)\n\t\t\t\t\tif(cc>@text[r].length) then next end\n\t\t\t\t\tinsertchar(r,cc,c.chr)\n\t\t\t\telse\n\t\t\t\t\tinsertchar(r,0,c.chr)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tcursor_right\n\t\tif @linewrap\n\t\t\tjustify(true)\n\t\tend\n\tend", "def write_str(line,column,text)\n\t\tif text == nil\n\t\t\treturn\n\t\tend\n\t\tCurses.setpos(line,column)\n\t\tCurses.addstr(text)\n\tend", "def catch_text\n # get the actual offset\n start = @buffer.get_iter_at_offset(@@offset)\n\n # get the command\n cmd = @buffer.get_text(start, @buffer.end_iter)\n\n # Save the command to the history object\n @historic.append(cmd)\n\n # Write the command to our pipe\n send_cmd(cmd)\n\n # Add a return line to our buffer\n insert_text(\"\\n\")\n\n # Call the prompt\n prompt()\n\n # Create the mark tag if not exist\n if (not @buffer.get_mark('end_mark'))\n @buffer.create_mark('end_mark', @buffer.end_iter, false)\n end\n\n # Save our offset\n @@offset = @buffer.end_iter.offset\n end" ]
[ "0.78739834", "0.7795639", "0.7627861", "0.75727004", "0.72709006", "0.72687006", "0.72687006", "0.72526455", "0.7165091", "0.7125943", "0.70980746", "0.70634115", "0.70015275", "0.6886459", "0.6852852", "0.6845627", "0.6751516", "0.6738957", "0.67093945", "0.66722345", "0.66448617", "0.66429436", "0.66069233", "0.65336806", "0.6531892", "0.6528975", "0.6480059", "0.6399373", "0.6392969", "0.6358853", "0.6329094", "0.6329094", "0.6313103", "0.6290292", "0.62824273", "0.6274391", "0.62659085", "0.62022996", "0.6164851", "0.6128675", "0.6126112", "0.61007637", "0.609148", "0.60851586", "0.60851586", "0.60851586", "0.60851586", "0.60851586", "0.60851586", "0.60851586", "0.60851586", "0.60848254", "0.60678387", "0.60603034", "0.6056592", "0.60524637", "0.60202634", "0.60202634", "0.6019392", "0.59962714", "0.5969798", "0.5964934", "0.59615546", "0.5878434", "0.5875999", "0.5872954", "0.58689547", "0.5858923", "0.57857263", "0.57527107", "0.57527107", "0.57527107", "0.57527107", "0.57527107", "0.57527107", "0.57527107", "0.57527107", "0.57487917", "0.57360995", "0.5731591", "0.5724557", "0.57131106", "0.5673975", "0.56611776", "0.56569165", "0.56510794", "0.564386", "0.56295323", "0.5628657", "0.5618576", "0.5613919", "0.5605146", "0.5593138", "0.5546284", "0.5544237", "0.55439186", "0.5538188", "0.55294836", "0.55201614", "0.5498508" ]
0.8378789
0
Deletes the character before the cursor (like pressing backspace)
def backspace() #todo if @cursor_col > 0 line = line(@cursor_row) line[@cursor_col - 1.. @cursor_col - 1] = "" change_line(@cursor_row, line) @cursor_col -= 1 emit_changed(@cursor_row) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_current_character() \n\t\tif @selection_start != -1\n\t\t\tl1, i1 = index_line_and_col(@selection_start)\n\t\t\tl2, i2 = index_line_and_col(@selection_end)\n\t\t\tremove_range(l1, i1, l2, i2)\n\t\t\tclear_selection\n\t\t\temit_changed((l1...num_lines)) #todo\n\t\telse\n\t\t\tline = line(@cursor_row)\n\t\t\tline[@cursor_col.. @cursor_col] = \"\"\n\t\t\tchange_line(@cursor_row, line)\n\t\t\temit_changed(@cursor_row)\n\t\tend\n\tend", "def delete_prev_char\n return -1 if !@editable \n return if @curpos <= 0\n # if we've panned, then unpan, and don't move cursor back\n # Otherwise, adjust cursor (move cursor back as we delete)\n adjust = true\n if @pcol > 0\n @pcol -= 1\n adjust = false\n end\n @curpos -= 1 if @curpos > 0\n delete_at\n addcol -1 if adjust # move visual cursor back\n @modified = true\n end", "def delete_character\n @lines = lines.delete_character(y, x - 1)\n\n left\n\n refresh\n end", "def prev_char\n self.cursor -= 1\n end", "def clear_to_cursor; print \"\\e[1K\" end", "def clear_up_to_cursor; puts \"\\e[1J\" end", "def clear_line_before\n CSI + '1K'\n end", "def delete\n @text.slice!(@cursor, 1)\n end", "def remove\n left\n @text.slice!(@cursor, 1)\n end", "def erase_line_to_beginning\n ConsoleGlitter.escape('1K')\n end", "def delete_left_word\n chars = @text.scan(/./m)\n position = @cursor_position\n # skip all whitespaces first\n while position > 0 && chars[position - 1] == ' '\n position -= 1\n end\n # skip all non-whitespaces\n while position > 0 && chars[position - 1] != ' '\n position -= 1\n end\n delete_left(@cursor_position - position) if @cursor_position > position\n self.reset_cursor_blinking\n end", "def minibuffer_delete()\n $minibuffer.delete(BACKWARD_CHAR)\nend", "def delete_before\r\n return nil if @cursor == 0\r\n result = @buffer.delete_at(@cursor - 1)\r\n @buffer.compact! #needed?\r\n @cursor = @cursor - 1 if result != nil\r\n result\r\n end", "def clear_line_after\n CSI + '0K'\n end", "def restore_cursor; puts \"\\e[u\" end", "def apply_backspace\n end", "def remove\n\t\t\tback if (@buffer.at_end?)\n\t\t\tch = @buffer.char\n\t\t\t@buffer.remove\n\t\t\tredraw_line((ch == Ruvim::API::CR) ? (@cursor.y ... @height) : @cursor.y) \n\t\t\tself\n\t\tend", "def undo_delete_eol\n return if @delete_buffer.nil?\n #oldvalue = @buffer\n @buffer.insert @curpos, @delete_buffer \n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos+@delete_buffer.length, self, :INSERT, 0, @delete_buffer) \n end", "def backspace\n\t\tif @marked\n\t\t\tmark_row,row = ordered_mark_rows\n\t\t\tif @colmode\n\t\t\t\tcolumn_backspace(mark_row,row,@col)\n\t\t\telse\n\t\t\t\tcolumn_backspace(mark_row,row,1)\n\t\t\tend\n\t\telse\n\t\t\tif (@col+@row)==0\n\t\t\t\treturn\n\t\t\tend\n\t\t\tif @col == 0\n\t\t\t\tcursor_left\n\t\t\t\tmergerows(@row,@row+1)\n\t\t\t\treturn\n\t\t\tend\n\t\t\tcursor_left\n\t\t\tdelchar(@row,@col)\n\t\tend\n\tend", "def delete_character(index = nil)\n Vedeu::Editor::Line.coerce(Vedeu::Editor::Delete\n .from(line, index, size))\n end", "def delete_character(index = nil)\n Vedeu::Editor::Line.coerce(Vedeu::Editor::Delete\n .from(line, index, size))\n end", "def delete_left(count = 1)\n if self.cursor_can_move_left?\n # limiting character count\n count = @cursor_position if count > @cursor_position\n # split text at cursor with one character removed left from the cursor\n chars = @text.scan(/./m)\n left = (@cursor_position > count ? chars[0, @cursor_position - count] : [])\n if @cursor_position < chars.size\n right = chars[@cursor_position, chars.size - @cursor_position]\n else\n right = []\n end\n # set cursor at right position\n @cursor_position -= count\n # put together the split halves\n self.text = (left + right).join\n self.reset_cursor_blinking\n end\n end", "def editor_delete_character!\n Vedeu.bind(:_editor_delete_character_) do |name|\n Vedeu.documents.by_name(name).delete_character\n end\n end", "def on_key_delete(evt)\n @hexbyte_started=false\n if not @selection.nil?\n idx=gui_set_value(nil, '')\n move_to_idx(idx)\n elsif @data[self.cur_pos]\n gui_set_value(self.cur_pos, '')\n refresh\n end\n end", "def delete_after\r\n result = @buffer.delete_at(@cursor)\r\n @buffer.compact! #needed?\r\n result\r\n end", "def erase_line_to_end\n ConsoleGlitter.escape('0K')\n end", "def undo_delete_eol\n return if @delete_buffer.nil?\n #oldvalue = @buffer\n @buffer.insert @curpos, @delete_buffer \n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos+@delete_buffer.length, self, :INSERT, 0, @delete_buffer) # 2010-09-11 13:01 \n end", "def wdelch\n Ncurses.wdelch(pointer)\n end", "def delchar(row,col)\n\t\tif col == @text[row].length\n\t\t\tmergerows(row,row+1)\n\t\telse\n\t\t\t@text[row] = @text[row].dup\n\t\t\t@text[row][col] = \"\"\n\t\tend\n\tend", "def clear_line\n CSI + '2K' + column(1)\n end", "def map_backspace\n Vim.command('imap <BS> <C-R>=DeliminatorBackspace()<CR>')\n end", "def deleteTextBackspace cursor, overwrite, nbToDelete = 1\n nbToDelete = deleteTextBackspaceTooBig cursor, nbToDelete\n while cursor.column < nbToDelete\n nbToDelete = deleteTextBackspaceConcatLine cursor, nbToDelete, overwrite\n end\n deleteTextBackspaceSameLine cursor, nbToDelete, overwrite\n nil\n end", "def cut_word_forward()\n select_word_forward_including_whitespace(@number_prefix) + [\"copySelection\", \"deleteBackward:\"] +\n restore_cursor_position()\n end", "def clear_to_beginning\n ConsoleGlitter.escape('1J')\n end", "def delete_at index=@curpos\n return -1 if !@editable \n char = @buffer.slice!(index,1)\n #$log.debug \" delete at #{index}: #{@buffer.length}: #{@buffer}\"\n @modified = true\n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos, self, :DELETE, 0, char) # 2010-09-11 13:01 \n end", "def string_deleter(string)\n string.chars.each do |_x|\n print TTY::Cursor.backward(1)\n print TTY::Cursor.clear_char(1)\n sleep(0.03)\n end\n end", "def delete_right_word\n chars = @text.scan(/./m)\n position = @cursor_position\n # skip all non-whitespaces first\n while position < chars.size && chars[position] != ' '\n position += 1\n end\n # skip all whitespaces\n while position < chars.size && chars[position] == ' '\n position += 1\n end\n delete_right(position - @cursor_position) if position > @cursor_position\n self.reset_cursor_blinking\n end", "def on_key_back(evt)\n @hexbyte_started=false\n if not @selection.nil?\n idx=gui_set_value(nil, '')\n move_to_idx(idx)\n elsif (didx=self.cur_pos-1) >= 0\n gui_set_value(didx, '')\n move_cursor_left()\n end\n end", "def clear_line; print \"\\e[2K\" end", "def cursor_bol\n # copy of C-a - start of line\n @repaint_required = true if @pcol > 0\n @pcol = 0\n @curpos = 0\n end", "def reset_cursor\n c = get_cursor_pos\n print_area_to_buffer(@main_buffer, c[0], c[1], @last_chars)\n @last_chars = cache_area(@main_buffer,\n c[0], 1,\n c[1], 1)\n @cursor = [\"\\u2588\"]\n print_area_to_buffer(@main_buffer, c[0], c[1], @cursor)\n\n return\n end", "def clear_selection()\n @last_pos = nil\n @selection = nil\n end", "def werase\n Ncurses.werase(pointer)\n end", "def process_key_press( typed_line )\n # retrieve typed character\n typed_character = get_character.chr\n # process backspace\n if typed_character == \"\\177\"\n putc \"\\b \\b\"\n typed_line.chop!\n return typed_line\n # ignore return\n elsif typed_character == \"\\r\"\n return typed_line\n end\n # append typed to current line character and write it out\n typed_line = typed_line + typed_character\n putc typed_character\n typed_line\n end", "def undo_move(move)\n self.cells[move.to_i - 1] = \" \"\n end", "def erase_line_to_both\n ConsoleGlitter.escape('2K')\n end", "def clear_char(n = nil)\n CSI + \"#{n}X\"\n end", "def handle_special_character(byte)\n if byte == 0x39\n # Transparent space: Move cursor after deleting the current column to open up a hole\n @background_grid[@state.row][@state.column] = nil\n @state.column += 1\n else\n char = SPECIAL_CHARACTER_MAP[byte.chr]\n insert_character(char)\n end\n end", "def move_for_keypress(keypress); nil; end", "def clear\n puts \"\\n\" # pour certaines méthodes\n puts \"\\033c\"\nend", "def delete_chars(count)\r\n return if (count > @_rl_screenwidth) # XXX\r\n\r\n if @hConsoleHandle.nil?\r\n #if (@_rl_term_DC)\r\n # buffer = tgoto(_rl_term_DC, count, count);\r\n # @_rl_out_stream.write(buffer * count)\r\n #else\r\n if (@_rl_term_dc)\r\n @_rl_out_stream.write(@_rl_term_dc * count)\r\n end\r\n #end\r\n end\r\n end", "def do_clear\n @editor.value = ''\n @editor.focus\n end", "def prevChar\n if getChar == '\\n'\n @line -= 1\n @column = @lastLineSize\n end\n @index -= 1\n @column -= 1\n end", "def kill_word(*)\n first_non_letter = current_buffer.index(/\\P{L}/, current_buffer.point) || current_buffer.length\n word_beginning = current_buffer.index(/\\p{L}/, first_non_letter) || current_buffer.length\n current_buffer.slice!(current_buffer.point, word_beginning - current_buffer.point)\n true\nend", "def clear_line\n puts \"\\e[0A\\e[0G\"\n end", "def clear_to_end\n ConsoleGlitter.escape('0J')\n end", "def _rl_unget_char(key)\r\n if (ibuffer_space()!=0)\r\n @pop_index-=1\r\n if (@pop_index < 0)\r\n @pop_index = @ibuffer_len - 1\r\n end\r\n @ibuffer[@pop_index] = key\r\n return (1)\r\n end\r\n return (0)\r\n end", "def clear_line!\n print \"\\r\\e[2K\"\n end", "def erase!(chars)\n return if chars == 0\n str = @result.slice!(-chars..-1)\n newlines = str.count(\"\\n\")\n if newlines > 0\n @line -= newlines\n @offset = @result[@result.rindex(\"\\n\") || 0..-1].size\n else\n @offset -= chars\n end\n end", "def delete_last_n_characters_in_word(word,n)\r\n start = word.Selection.Start\r\n word.Selection.Start = start - n\r\n word.Selection.End = start\r\n word.Selection.Delete\r\nend", "def prev_char(options = {})\n ix = column - 1\n ix = skip_space(ix, :left) if options[:skip_space]\n char_at(ix) || ''\n end", "def undo\n if done\n @text = text.sub(DONE_REGEX, '').strip\n @done = false\n end\n end", "def cursor_move_left_word\n chars = @text.scan(/./m)\n # skip all whitespaces first\n while @cursor_position > 0 && chars[@cursor_position - 1] == ' '\n @cursor_position -= 1\n end\n # skip all non-whitespaces\n while @cursor_position > 0 && chars[@cursor_position - 1] != ' '\n @cursor_position -= 1\n end\n self.reset_cursor_blinking\n end", "def cursor_move_to_end\n @cursor_position = @text.scan(/./m).size\n self.reset_cursor_blinking\n end", "def _rl_erase_at_end_of_line(l)\r\n _rl_backspace(l)\r\n @rl_outstream.write(' '*l)\r\n _rl_backspace(l)\r\n @_rl_last_c_pos -= l\r\n @visible_line[@_rl_last_c_pos,l] = 0.chr * l\r\n @rl_display_fixed = true if !@rl_display_fixed\r\n end", "def cursor_move_to_beginning\n @cursor_position = 0\n self.reset_cursor_blinking\n end", "def clear\n \"\\e[2J\\e[H\"\nend", "def rl_delete(count, key)\r\n if (count < 0)\r\n return (_rl_rubout_char(-count, key))\r\n end\r\n if (@rl_point == @rl_end)\r\n rl_ding()\r\n return -1\r\n end\r\n\r\n if (count > 1 || @rl_explicit_arg)\r\n xpoint = @rl_point\r\n rl_forward_byte(count, key)\r\n\r\n rl_kill_text(xpoint, @rl_point)\r\n @rl_point = xpoint\r\n else\r\n if !@rl_byte_oriented\r\n xpoint =_rl_find_next_mbchar(@rl_line_buffer, @rl_point, 1, MB_FIND_NONZERO)\r\n else\r\n xpoint = @rl_point + 1\r\n end\r\n\r\n rl_delete_text(@rl_point, xpoint)\r\n end\r\n 0\r\n end", "def delete_right(count = 1)\n if self.cursor_can_move_right?\n # limiting character count\n chars = @text.scan(/./m)\n if count > chars.size - @cursor_position\n count = chars.size - @cursor_position\n end\n # moving cursor to the right\n @cursor_position += count\n # deleting everything left from cursor\n self.delete_left(count)\n self.reset_cursor_blinking\n end\n end", "def type_and_delete(string)\n string.chars.each do |x|\n print x.colorize(selector(@@colours))\n sleep(0.02)\n end\n sleep(1.5)\n string.chars.each do |_x|\n print TTY::Cursor.backward(1)\n print TTY::Cursor.clear_char(1)\n sleep(0.03)\n end\n end", "def backward_kill_word(*)\n first_letter_backward = current_buffer.rindex(/\\p{L}/, current_buffer.point) || 0\n first_non_letter_before_word = current_buffer.rindex(/\\P{L}/, first_letter_backward) || -1\n current_buffer.slice!(first_non_letter_before_word + 1..current_buffer.point)\n true\nend", "def killtoeol\n char = @text[@cursor, 1]\n if char == \"\\n\"\n killto :killtoeol do movetoright end\n else\n killto :killtoeol do movetoeol end\n end\n end", "def move_to_end\n @cursor = @text.length # put cursor outside of text\n end", "def move_to_end\n @cursor = @text.length # put cursor outside of text\n end", "def clear\n puts \"\\e[2J\\e[f\"\nend", "def restore_cursor_position() set_cursor_position(@event[\"line\"], @event[\"column\"]) end", "def render_cursor\n # This is necessary to handle characters that render\n # as more or less than 1 character, such as e.g. tabs.\n y = cursor.row\n x = editor.model.cursor_x(y, cursor.col-@xoff)+text_xoff\n\n # Make cursor visible even if currently no character\n # FIXME: Update AnsiTerm w/function to allow forcing a space\n # w/out this\n l = @out.lines[cursor.row-@top]\n if !l || !l[x]\n @out.move_cursor(x,cursor.row-@top)\n @out.print(\" \")\n end\n l = @out.lines[cursor.row-@top]\n l.set_attr(x..x, @cursor_attr)\n end", "def check_key_delete\n return unless open?\n return if @closing\n if Input.legacy_press?(:B)\n @esc_counter += 1\n if @esc_counter >= 50\n @esc_counter = 0\n selection_ok(nil)\n end\n else\n @esc_counter = 0\n end\n end", "def cursor_left(wrap = false)\n process_cursor_cancel\n end", "def backspace buffer, nb\n @frames[buffer].backspaceBuffer buffer, nb\n end", "def cursor_to_input_line\n setpos(input_line, 0)\n end", "def cursor_home\n @curpos = 0\n @pcol = 0\n set_form_col 0\n end", "def clear_eol\n print \"\\e[0K\"\n end", "def ti_delete_line\n\ttictl(\"dl\")\n end", "def next_char\n self.cursor += 1\n end", "def delete_illegal_chars\n self.title.delete!(\"~\")\n end", "def deleteTextBackspaceTooBig cursor, nbToDelete\n nb = nbToDelete - cursor.column\n line = cursor.line - 1\n while nb > 0 && line >= 0\n nb -= @fileContent[line].size + 1\n line -= 1\n end\n if nb <= 0\n return nbToDelete\n else \n return nbToDelete - nb\n end\n end", "def move_foward(n); print \"\\e[#{n}C\" end", "def clear_line\n CLEAR_LINE\n end", "def cut\n\n # FIXME\n if OperaWatir::Platform.os == :macosx\n keys.send [:command, 'x']\n else\n keys.send [:control, 'x']\n end\n end", "def NextChar\r\n\t\t@Line.slice!(0, 1)\r\n\tend", "def move_caret_to_mouse\n # Test character by character\n 1.upto(self.text.length) do |i|\n if @window.mouse_x < x + FONT.text_width(text[0...i])\n self.caret_pos = self.selection_start = i - 1;\n return\n end\n end\n # Default case: user must have clicked the right edge\n self.caret_pos = self.selection_start = self.text.length\n end", "def cursor_move_right_word\n chars = @text.scan(/./m)\n # skip all non-whitespaces first\n while @cursor_position < chars.size && chars[@cursor_position] != ' '\n @cursor_position += 1\n end\n # skip all whitespaces\n while @cursor_position < chars.size && chars[@cursor_position] == ' '\n @cursor_position += 1\n end\n self.reset_cursor_blinking\n end", "def clear\n VIM::command(\"%d\")\n end", "def move_to_x(x)\n $stdout.write \"\\033[#{x}C\"\n end", "def remove_char(s)\n s[1...-1]\nend", "def remove_char(s)\n s[1..-2]\nend", "def rl_delete_horizontal_space(count, ignore)\r\n start = @rl_point\r\n\r\n while (@rl_point!=0 && whitespace(@rl_line_buffer[@rl_point - 1]))\r\n @rl_point-=1\r\n end\r\n start = @rl_point\r\n while (@rl_point < @rl_end && whitespace(@rl_line_buffer[@rl_point]))\r\n @rl_point+=1\r\n end\r\n if (start != @rl_point)\r\n rl_delete_text(start, @rl_point)\r\n @rl_point = start\r\n end\r\n if (@rl_point < 0)\r\n @rl_point = 0\r\n end\r\n 0\r\n end", "def delete\n\t\t\tresult = @editor.buffer.data.slice!(range)\n\t\t\t@editor.goto(@start).redraw\n\t\t\t@editor.buffer.touch\n\n\t\t\treturn result\n\t\tend", "def clear; puts \"\\e[2J\" end" ]
[ "0.7839138", "0.76375204", "0.7370505", "0.7297016", "0.72069186", "0.7041504", "0.6990519", "0.69695044", "0.69440466", "0.6920794", "0.68249846", "0.6771089", "0.6688815", "0.6669755", "0.6600718", "0.6580403", "0.6573684", "0.65690404", "0.6564683", "0.6563899", "0.6563899", "0.6536511", "0.65326786", "0.6521935", "0.6521854", "0.64620024", "0.64274985", "0.6404715", "0.64001364", "0.6362207", "0.6349537", "0.6348499", "0.63125145", "0.6305249", "0.6256606", "0.62315917", "0.62167513", "0.6165821", "0.6155178", "0.61202127", "0.6109778", "0.61022735", "0.6097193", "0.60911846", "0.60465354", "0.6039953", "0.603479", "0.60015047", "0.5989383", "0.5977599", "0.59772813", "0.5974499", "0.5927045", "0.5908699", "0.5888272", "0.5887396", "0.58814764", "0.5877493", "0.5868094", "0.58495593", "0.58358073", "0.5833581", "0.5815818", "0.58071065", "0.5800141", "0.57875377", "0.57812375", "0.5763836", "0.5760231", "0.5752855", "0.5698881", "0.5696233", "0.5683729", "0.5683729", "0.567326", "0.56706977", "0.5650268", "0.5645704", "0.56219375", "0.56111443", "0.55969083", "0.5596204", "0.5582485", "0.5581463", "0.55709356", "0.5559541", "0.5558865", "0.5557492", "0.55451465", "0.5541097", "0.55361766", "0.55347544", "0.55264103", "0.5524711", "0.55219567", "0.5520686", "0.550986", "0.5509266", "0.55005854", "0.5493004" ]
0.7675729
1
Deletes the character at the cursor (like pressing delete)
def delete_current_character() if @selection_start != -1 l1, i1 = index_line_and_col(@selection_start) l2, i2 = index_line_and_col(@selection_end) remove_range(l1, i1, l2, i2) clear_selection emit_changed((l1...num_lines)) #todo else line = line(@cursor_row) line[@cursor_col.. @cursor_col] = "" change_line(@cursor_row, line) emit_changed(@cursor_row) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_character\n @lines = lines.delete_character(y, x - 1)\n\n left\n\n refresh\n end", "def editor_delete_character!\n Vedeu.bind(:_editor_delete_character_) do |name|\n Vedeu.documents.by_name(name).delete_character\n end\n end", "def delete_character(index = nil)\n Vedeu::Editor::Line.coerce(Vedeu::Editor::Delete\n .from(line, index, size))\n end", "def delete_character(index = nil)\n Vedeu::Editor::Line.coerce(Vedeu::Editor::Delete\n .from(line, index, size))\n end", "def delete\n @text.slice!(@cursor, 1)\n end", "def delete_prev_char\n return -1 if !@editable \n return if @curpos <= 0\n # if we've panned, then unpan, and don't move cursor back\n # Otherwise, adjust cursor (move cursor back as we delete)\n adjust = true\n if @pcol > 0\n @pcol -= 1\n adjust = false\n end\n @curpos -= 1 if @curpos > 0\n delete_at\n addcol -1 if adjust # move visual cursor back\n @modified = true\n end", "def wdelch\n Ncurses.wdelch(pointer)\n end", "def delete_at index=@curpos\n return -1 if !@editable \n char = @buffer.slice!(index,1)\n #$log.debug \" delete at #{index}: #{@buffer.length}: #{@buffer}\"\n @modified = true\n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos, self, :DELETE, 0, char) # 2010-09-11 13:01 \n end", "def on_key_delete(evt)\n @hexbyte_started=false\n if not @selection.nil?\n idx=gui_set_value(nil, '')\n move_to_idx(idx)\n elsif @data[self.cur_pos]\n gui_set_value(self.cur_pos, '')\n refresh\n end\n end", "def delchar(row,col)\n\t\tif col == @text[row].length\n\t\t\tmergerows(row,row+1)\n\t\telse\n\t\t\t@text[row] = @text[row].dup\n\t\t\t@text[row][col] = \"\"\n\t\tend\n\tend", "def clear_to_cursor; print \"\\e[1K\" end", "def backspace() \n\t\t#todo\n\t\tif @cursor_col > 0\n\t\t\tline = line(@cursor_row)\n\t\t\tline[@cursor_col - 1.. @cursor_col - 1] = \"\"\n\t\t\tchange_line(@cursor_row, line)\n\t\t\t@cursor_col -= 1\n\t\t\temit_changed(@cursor_row)\n\t\tend\n\tend", "def remove\n\t\t\tback if (@buffer.at_end?)\n\t\t\tch = @buffer.char\n\t\t\t@buffer.remove\n\t\t\tredraw_line((ch == Ruvim::API::CR) ? (@cursor.y ... @height) : @cursor.y) \n\t\t\tself\n\t\tend", "def remove\n left\n @text.slice!(@cursor, 1)\n end", "def clear_up_to_cursor; puts \"\\e[1J\" end", "def minibuffer_delete()\n $minibuffer.delete(BACKWARD_CHAR)\nend", "def prev_char\n self.cursor -= 1\n end", "def string_deleter(string)\n string.chars.each do |_x|\n print TTY::Cursor.backward(1)\n print TTY::Cursor.clear_char(1)\n sleep(0.03)\n end\n end", "def clear_char(n = nil)\n CSI + \"#{n}X\"\n end", "def undo_delete_eol\n return if @delete_buffer.nil?\n #oldvalue = @buffer\n @buffer.insert @curpos, @delete_buffer \n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos+@delete_buffer.length, self, :INSERT, 0, @delete_buffer) \n end", "def delete_after\r\n result = @buffer.delete_at(@cursor)\r\n @buffer.compact! #needed?\r\n result\r\n end", "def werase\n Ncurses.werase(pointer)\n end", "def delete_chars(count)\r\n return if (count > @_rl_screenwidth) # XXX\r\n\r\n if @hConsoleHandle.nil?\r\n #if (@_rl_term_DC)\r\n # buffer = tgoto(_rl_term_DC, count, count);\r\n # @_rl_out_stream.write(buffer * count)\r\n #else\r\n if (@_rl_term_dc)\r\n @_rl_out_stream.write(@_rl_term_dc * count)\r\n end\r\n #end\r\n end\r\n end", "def rl_delete(count, key)\r\n if (count < 0)\r\n return (_rl_rubout_char(-count, key))\r\n end\r\n if (@rl_point == @rl_end)\r\n rl_ding()\r\n return -1\r\n end\r\n\r\n if (count > 1 || @rl_explicit_arg)\r\n xpoint = @rl_point\r\n rl_forward_byte(count, key)\r\n\r\n rl_kill_text(xpoint, @rl_point)\r\n @rl_point = xpoint\r\n else\r\n if !@rl_byte_oriented\r\n xpoint =_rl_find_next_mbchar(@rl_line_buffer, @rl_point, 1, MB_FIND_NONZERO)\r\n else\r\n xpoint = @rl_point + 1\r\n end\r\n\r\n rl_delete_text(@rl_point, xpoint)\r\n end\r\n 0\r\n end", "def clear_line\n CSI + '2K' + column(1)\n end", "def restore_cursor; puts \"\\e[u\" end", "def check_key_delete\n return unless open?\n return if @closing\n if Input.legacy_press?(:B)\n @esc_counter += 1\n if @esc_counter >= 50\n @esc_counter = 0\n selection_ok(nil)\n end\n else\n @esc_counter = 0\n end\n end", "def undo_delete_eol\n return if @delete_buffer.nil?\n #oldvalue = @buffer\n @buffer.insert @curpos, @delete_buffer \n fire_handler :CHANGE, InputDataEvent.new(@curpos,@curpos+@delete_buffer.length, self, :INSERT, 0, @delete_buffer) # 2010-09-11 13:01 \n end", "def clear_selection()\n @last_pos = nil\n @selection = nil\n end", "def erase_line_to_end\n ConsoleGlitter.escape('0K')\n end", "def delete\n\t\t\tresult = @editor.buffer.data.slice!(range)\n\t\t\t@editor.goto(@start).redraw\n\t\t\t@editor.buffer.touch\n\n\t\t\treturn result\n\t\tend", "def type_and_delete(string)\n string.chars.each do |x|\n print x.colorize(selector(@@colours))\n sleep(0.02)\n end\n sleep(1.5)\n string.chars.each do |_x|\n print TTY::Cursor.backward(1)\n print TTY::Cursor.clear_char(1)\n sleep(0.03)\n end\n end", "def clear_line_after\n CSI + '0K'\n end", "def delete_left(count = 1)\n if self.cursor_can_move_left?\n # limiting character count\n count = @cursor_position if count > @cursor_position\n # split text at cursor with one character removed left from the cursor\n chars = @text.scan(/./m)\n left = (@cursor_position > count ? chars[0, @cursor_position - count] : [])\n if @cursor_position < chars.size\n right = chars[@cursor_position, chars.size - @cursor_position]\n else\n right = []\n end\n # set cursor at right position\n @cursor_position -= count\n # put together the split halves\n self.text = (left + right).join\n self.reset_cursor_blinking\n end\n end", "def clear\n puts \"\\n\" # pour certaines méthodes\n puts \"\\033c\"\nend", "def clear_line_before\n CSI + '1K'\n end", "def handle_special_character(byte)\n if byte == 0x39\n # Transparent space: Move cursor after deleting the current column to open up a hole\n @background_grid[@state.row][@state.column] = nil\n @state.column += 1\n else\n char = SPECIAL_CHARACTER_MAP[byte.chr]\n insert_character(char)\n end\n end", "def delete_right(count = 1)\n if self.cursor_can_move_right?\n # limiting character count\n chars = @text.scan(/./m)\n if count > chars.size - @cursor_position\n count = chars.size - @cursor_position\n end\n # moving cursor to the right\n @cursor_position += count\n # deleting everything left from cursor\n self.delete_left(count)\n self.reset_cursor_blinking\n end\n end", "def process_key_press( typed_line )\n # retrieve typed character\n typed_character = get_character.chr\n # process backspace\n if typed_character == \"\\177\"\n putc \"\\b \\b\"\n typed_line.chop!\n return typed_line\n # ignore return\n elsif typed_character == \"\\r\"\n return typed_line\n end\n # append typed to current line character and write it out\n typed_line = typed_line + typed_character\n putc typed_character\n typed_line\n end", "def delete(n = 1)\n @text.slice!(@cursor, n)\n end", "def do_clear\n @editor.value = ''\n @editor.focus\n end", "def putch char\n return -1 if !@editable \n return -1 if !@overwrite_mode && (@buffer.length >= @maxlen)\n blen = @buffer.length\n if @chars_allowed != nil\n return if char.match(@chars_allowed).nil?\n end\n # added insert or overwrite mode 2010-03-17 20:11 \n oldchar = nil\n if @overwrite_mode\n oldchar = @buffer[@curpos] \n @buffer[@curpos] = char\n else\n @buffer.insert(@curpos, char)\n end\n oldcurpos = @curpos\n #$log.warn \"XXX: FIELD CURPOS #{@curpos} blen #{@buffer.length} \" #if @curpos > blen\n @curpos += 1 if @curpos < @maxlen\n @modified = true\n #$log.debug \" FIELD FIRING CHANGE: #{char} at new #{@curpos}: bl:#{@buffer.length} buff:[#{@buffer}]\"\n if @overwrite_mode\n fire_handler :CHANGE, InputDataEvent.new(oldcurpos,@curpos, self, :DELETE, 0, oldchar) # 2010-09-11 12:43 \n end\n fire_handler :CHANGE, InputDataEvent.new(oldcurpos,@curpos, self, :INSERT, 0, char) # 2010-09-11 12:43 \n 0\n end", "def ungetch(ch)\n Ncurses.ungetch(ch)\n end", "def clear_line; print \"\\e[2K\" end", "def editor_delete_line!\n Vedeu.bind(:_editor_delete_line_) do |name|\n Vedeu.documents.by_name(name).delete_line\n end\n end", "def ti_delete_line\n\ttictl(\"dl\")\n end", "def putch char\n return -1 if !@editable \n return -1 if !@overwrite_mode && (@buffer.length >= @maxlen)\n blen = @buffer.length\n if @chars_allowed != nil\n return if char.match(@chars_allowed).nil?\n end\n # added insert or overwrite mode 2010-03-17 20:11 \n oldchar = nil\n if @overwrite_mode\n oldchar = @buffer[@curpos] \n @buffer[@curpos] = char\n else\n @buffer.insert(@curpos, char)\n end\n oldcurpos = @curpos\n #$log.warn \"XXX: FIELD CURPOS #{@curpos} blen #{@buffer.length} \" #if @curpos > blen\n @curpos += 1 if @curpos < @maxlen\n @modified = true\n #$log.debug \" FIELD FIRING CHANGE: #{char} at new #{@curpos}: bl:#{@buffer.length} buff:[#{@buffer}]\"\n # i have no way of knowing what change happened and what char was added deleted or changed\n #fire_handler :CHANGE, self # 2008-12-09 14:51 \n if @overwrite_mode\n fire_handler :CHANGE, InputDataEvent.new(oldcurpos,@curpos, self, :DELETE, 0, oldchar) # 2010-09-11 12:43 \n end\n fire_handler :CHANGE, InputDataEvent.new(oldcurpos,@curpos, self, :INSERT, 0, char) # 2010-09-11 12:43 \n 0\n end", "def delete_right_word\n chars = @text.scan(/./m)\n position = @cursor_position\n # skip all non-whitespaces first\n while position < chars.size && chars[position] != ' '\n position += 1\n end\n # skip all whitespaces\n while position < chars.size && chars[position] == ' '\n position += 1\n end\n delete_right(position - @cursor_position) if position > @cursor_position\n self.reset_cursor_blinking\n end", "def delete(from: 0, to: length)\n editable? and @native.delete_text(from.to_i, to.to_i)\n end", "def delete_last_n_characters_in_word(word,n)\r\n start = word.Selection.Start\r\n word.Selection.Start = start - n\r\n word.Selection.End = start\r\n word.Selection.Delete\r\nend", "def putch char\n @current_index ||= 0\n if @editable \n raise \"how is it editable here in combo\"\n super\n return 0\n else\n match = next_match(char)\n text match unless match.nil?\n fire_handler :ENTER_ROW, self\n end\n @modified = true\n fire_handler :CHANGE, self # 2008-12-09 14:51 ???\n 0\n end", "def erase_line_to_beginning\n ConsoleGlitter.escape('1K')\n end", "def delete_left_word\n chars = @text.scan(/./m)\n position = @cursor_position\n # skip all whitespaces first\n while position > 0 && chars[position - 1] == ' '\n position -= 1\n end\n # skip all non-whitespaces\n while position > 0 && chars[position - 1] != ' '\n position -= 1\n end\n delete_left(@cursor_position - position) if @cursor_position > position\n self.reset_cursor_blinking\n end", "def deleteTextBackspace cursor, overwrite, nbToDelete = 1\n nbToDelete = deleteTextBackspaceTooBig cursor, nbToDelete\n while cursor.column < nbToDelete\n nbToDelete = deleteTextBackspaceConcatLine cursor, nbToDelete, overwrite\n end\n deleteTextBackspaceSameLine cursor, nbToDelete, overwrite\n nil\n end", "def move_for_keypress(keypress); nil; end", "def _rl_unget_char(key)\r\n if (ibuffer_space()!=0)\r\n @pop_index-=1\r\n if (@pop_index < 0)\r\n @pop_index = @ibuffer_len - 1\r\n end\r\n @ibuffer[@pop_index] = key\r\n return (1)\r\n end\r\n return (0)\r\n end", "def clear_line!\n print \"\\r\\e[2K\"\n end", "def delete\n \ttemp = @cbuf.delete_at(@s)\n \t@s += 1\n \ttemp\n end", "def delete_before\r\n return nil if @cursor == 0\r\n result = @buffer.delete_at(@cursor - 1)\r\n @buffer.compact! #needed?\r\n @cursor = @cursor - 1 if result != nil\r\n result\r\n end", "def handle_character\n char = characters.get_next\n return interupt if char.is?(:ctrl_c)\n return cancel if char.is?(:escape)\n return go_up if char.is?(:up)\n return go_down if char.is?(:down)\n return enter if char.is?(:enter)\n return right if char.is?(:right)\n return left if char.is?(:left)\n return right if char.is?(:option_right)\n return left if char.is?(:option_left)\n\n\n if editor\n editor.auto_complete_input = char\n cancel\n end\n end", "def delete_characters\n @db.execute(\"DROP TABLE Characters\")\n end", "def clear\n \"\\e[2J\\e[H\"\nend", "def putch char\n @current_index ||= 0\n if @editable \n super\n return 0\n else\n match = next_match(char)\n set_buffer match unless match.nil?\n fire_handler :ENTER_ROW, self\n end\n @modified = true\n fire_handler :CHANGE, self # 2008-12-09 14:51 ???\n 0\n end", "def destroy\n @character.destroy\n end", "def undo_move(move)\n self.cells[move.to_i - 1] = \" \"\n end", "def erase!(chars)\n return if chars == 0\n str = @result.slice!(-chars..-1)\n newlines = str.count(\"\\n\")\n if newlines > 0\n @line -= newlines\n @offset = @result[@result.rindex(\"\\n\") || 0..-1].size\n else\n @offset -= chars\n end\n end", "def erase_line_to_both\n ConsoleGlitter.escape('2K')\n end", "def clear_line\n puts \"\\e[0A\\e[0G\"\n end", "def cut\n\n # FIXME\n if OperaWatir::Platform.os == :macosx\n keys.send [:command, 'x']\n else\n keys.send [:control, 'x']\n end\n end", "def reset_character\n Vedeu::Cells::Escape.new(value: Vedeu.esc.reset)\n end", "def _rl_erase_at_end_of_line(l)\r\n _rl_backspace(l)\r\n @rl_outstream.write(' '*l)\r\n _rl_backspace(l)\r\n @_rl_last_c_pos -= l\r\n @visible_line[@_rl_last_c_pos,l] = 0.chr * l\r\n @rl_display_fixed = true if !@rl_display_fixed\r\n end", "def clear\n puts \"\\e[2J\\e[f\"\nend", "def remove_selection\n buffer_current.remove_selection\n update_status_line\n end", "def backspace\n\t\tif @marked\n\t\t\tmark_row,row = ordered_mark_rows\n\t\t\tif @colmode\n\t\t\t\tcolumn_backspace(mark_row,row,@col)\n\t\t\telse\n\t\t\t\tcolumn_backspace(mark_row,row,1)\n\t\t\tend\n\t\telse\n\t\t\tif (@col+@row)==0\n\t\t\t\treturn\n\t\t\tend\n\t\t\tif @col == 0\n\t\t\t\tcursor_left\n\t\t\t\tmergerows(@row,@row+1)\n\t\t\t\treturn\n\t\t\tend\n\t\t\tcursor_left\n\t\t\tdelchar(@row,@col)\n\t\tend\n\tend", "def erase\n runcmd 'erase'\n end", "def deleteTextDelete c, nbToDelete = 1\n nbToDelete = deleteTextDeleteTooBig c, nbToDelete\n while @fileContent[c.line].size - c.column < nbToDelete\n nbToDelete = deleteTextDeleteConcatLine c, nbToDelete\n end\n deleteTextDeleteSameLine c, nbToDelete\n nil\n end", "def clear\n VIM::command(\"%d\")\n end", "def move_to_x(x)\n $stdout.write \"\\033[#{x}C\"\n end", "def show_single_key\n c = read_char\n \n case c\n when \" \"\n puts \"SPACE\"\n when \"\\t\"\n puts \"TAB\"\n when \"\\r\"\n puts @cursor_pos\n when \"\\n\"\n puts \"LINE FEED\"\n when \"\\e\"\n puts \"ESCAPE\"\n \n\n when \"\\e[A\" ##up\n print \"\\033[1A\\033\"\n @cursor_pos[1] -= 1\n when \"\\e[B\" ##down\n print \"\\033[1B\\033\"\n @cursor_pos[1] += 1\n when \"\\e[C\" ##right\n print \"\\033[1C\\033\"\n @cursor_pos[0] += 1\n when \"\\e[D\" ##left\n print \"\\033[1D\\033\"\n @cursor_pos[0] -= 1\n \n\n when \"\\177\"\n puts \"BACKSPACE\"\n when \"\\004\"\n puts \"DELETE\"\n when \"\\e[3~\"\n puts \"ALTERNATE DELETE\"\n when \"\\u0003\"\n puts \"CONTROL-C\"\n exit 0\n when \"f\"\n puts \"flag\"\n puts \"SINGLE CHAR HIT: #{c.inspect}\"\n else\n puts \"SOMETHING ELSE: #{c.inspect}\"\n end\n\n #p @cursor_pos\nend", "def apply_backspace\n end", "def <<(char)\n @text << char\n @cursor += 1\n end", "def <<(char)\n @text << char\n @cursor += 1\n end", "def clear_clicked(txtvu)\n s, e = txtvu.buffer.selection_bounds\n txtvu.buffer.remove_all_tags(s, e)\nend", "def cursor_bol\n # copy of C-a - start of line\n @repaint_required = true if @pcol > 0\n @pcol = 0\n @curpos = 0\n end", "def next_char\n self.cursor += 1\n end", "def clear_to_end\n ConsoleGlitter.escape('0J')\n end", "def on_char_ascii(evt)\n @hexbyte_started=false\n ch = evt.get_key_code\n pos = self.cur_pos\n\n return if (pos > @data.size)\n\n if (idx = gui_set_value(pos, ch.chr)) != pos\n move_to_idx(idx, 1)\n else\n move_cursor_right()\n end\n @selection=nil\n end", "def render_cursor\n # This is necessary to handle characters that render\n # as more or less than 1 character, such as e.g. tabs.\n y = cursor.row\n x = editor.model.cursor_x(y, cursor.col-@xoff)+text_xoff\n\n # Make cursor visible even if currently no character\n # FIXME: Update AnsiTerm w/function to allow forcing a space\n # w/out this\n l = @out.lines[cursor.row-@top]\n if !l || !l[x]\n @out.move_cursor(x,cursor.row-@top)\n @out.print(\" \")\n end\n l = @out.lines[cursor.row-@top]\n l.set_attr(x..x, @cursor_attr)\n end", "def rl_rubout_or_delete(count, key)\r\n if (@rl_end != 0 && @rl_point == @rl_end)\r\n return (_rl_rubout_char(count, key))\r\n else\r\n return (rl_delete(count, key))\r\n end\r\n end", "def reset_cursor\n c = get_cursor_pos\n print_area_to_buffer(@main_buffer, c[0], c[1], @last_chars)\n @last_chars = cache_area(@main_buffer,\n c[0], 1,\n c[1], 1)\n @cursor = [\"\\u2588\"]\n print_area_to_buffer(@main_buffer, c[0], c[1], @cursor)\n\n return\n end", "def custom_delete(string, delete_characters)\n output = \"\"\n string.each_char { |char| output << char unless delete_characters.include?(char) }\n output\nend", "def close\n @graphic.ungetch(?q.ord)\n end", "def custom_delete(string,delete_characters)\nnew_string = \"\"\nstring.each_char {|char| new_string << char unless delete_characters.include?(char)}\nnew_string\nend", "def cursor_at(row, col)\n \"\\e[#{row};#{col}H\"\nend", "def handle_control_character(search, key)\n case key\n\n when KEY_CTRL_N then search.down\n when KEY_CTRL_P then search.up\n\n when KEY_CTRL_U then search.clear_query\n when KEY_CTRL_W then search.delete_word\n when KEY_CTRL_H, KEY_DELETE then search.backspace\n\n when ?\\r, KEY_CTRL_J, KEY_CTRL_M then search.done\n\n when KEY_CTRL_C then raise Abort\n\n else search\n end\n end", "def custom_delete(string, chars)\n new_string = \"\"\n string.each_char do |letter|\n new_string << letter unless chars.include?(letter)\n end\n new_string\nend", "def killtoeol\n char = @text[@cursor, 1]\n if char == \"\\n\"\n killto :killtoeol do movetoright end\n else\n killto :killtoeol do movetoeol end\n end\n end", "def on_key_back(evt)\n @hexbyte_started=false\n if not @selection.nil?\n idx=gui_set_value(nil, '')\n move_to_idx(idx)\n elsif (didx=self.cur_pos-1) >= 0\n gui_set_value(didx, '')\n move_cursor_left()\n end\n end", "def rl_delete_text(from, to)\r\n\r\n # Fix it if the caller is confused.\r\n if (from > to)\r\n from,to = to,from\r\n end\r\n\r\n # fix boundaries\r\n if (to > @rl_end)\r\n to = @rl_end\r\n if (from > to)\r\n from = to\r\n end\r\n end\r\n if (from < 0)\r\n from = 0\r\n end\r\n text = rl_copy_text(from, to)\r\n diff = to - from\r\n @rl_line_buffer[from...to] = ''\r\n @rl_line_buffer << 0.chr * diff\r\n # Remember how to undo this delete.\r\n if (!@_rl_doing_an_undo)\r\n rl_add_undo(UNDO_DELETE, from, to, text)\r\n else\r\n text = nil\r\n end\r\n @rl_end -= diff\r\n @rl_line_buffer[@rl_end,1] = 0.chr\r\n return (diff)\r\n end", "def move_foward(n); print \"\\e[#{n}C\" end" ]
[ "0.80851126", "0.77552146", "0.74847394", "0.74847394", "0.7448047", "0.7275868", "0.7258426", "0.69643384", "0.69332397", "0.6917795", "0.68581516", "0.67701685", "0.65531725", "0.6525773", "0.6491013", "0.64766586", "0.64537454", "0.6432829", "0.62588584", "0.6229734", "0.6223935", "0.6192196", "0.6141451", "0.6139603", "0.61203414", "0.6073604", "0.6052403", "0.60160565", "0.6007876", "0.5988301", "0.5980519", "0.5971172", "0.59704864", "0.5964947", "0.59576225", "0.59281224", "0.59134316", "0.5906335", "0.588838", "0.5877179", "0.58445346", "0.58387107", "0.5825027", "0.5823234", "0.5822464", "0.58191615", "0.5812797", "0.5796136", "0.5792212", "0.5788977", "0.57822883", "0.57755905", "0.5759093", "0.57314557", "0.5710778", "0.56905633", "0.56848854", "0.5676697", "0.5672303", "0.566665", "0.56556505", "0.56515193", "0.5648436", "0.5639297", "0.5615183", "0.5612943", "0.5606393", "0.560362", "0.56007975", "0.5596487", "0.55907094", "0.5583133", "0.5568222", "0.55635756", "0.5549016", "0.5530572", "0.55247724", "0.55154073", "0.55147344", "0.5513445", "0.55082643", "0.55082643", "0.5505724", "0.5505319", "0.5451238", "0.5450746", "0.5449682", "0.54468954", "0.5438818", "0.5428827", "0.5420775", "0.54116017", "0.539594", "0.5393338", "0.5387313", "0.5386223", "0.538385", "0.5375098", "0.5366341", "0.5362252" ]
0.82607466
0
Highlights all instances of 'pattern' in the text
def highlight(pattern) pattern = Regexp.new(pattern) if pattern.is_a?(String) @highlights = [[0, Qt::black]] # todo factor this invalid_rows = [] (0...num_lines).each do |index| line = line(index) if line =~ pattern #todo #@highlights << HighlightData.new(index, $~.begin(0), index, $~.end(0), Qt::yellow, Qt::black) #invalid_rows << index end end ##repaint_rows(invalid_rows) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def highlight(keywords, replacement_pattern)\n s = self.clone\n keywords.each do|kw|\n r = replacement_pattern.is_a?(Array) ? \"#{replacement_pattern.first}\\\\1#{replacement_pattern}\" : replacement_pattern\n s.gsub!(/(#{kw})/i, replacement_pattern)\n end\n s\n end", "def highlight(keyword)\n Rainbow.enabled = true\n regexp = Regexp.new(keyword,@options['ignore-case'] ? Regexp::IGNORECASE : nil)\n ARGF.each_line do |line|\n puts highlight_matches(regexp,line)\n end\n end", "def highlight(search_str, text)\n text.gsub!(search_str, \"<strong>#{search_str}</strong>\")\n end", "def highlight text\n color_code = 7\n \"\\e[#{color_code}m#{text}\\e[0m\"\nend", "def match(pattern); end", "def seeded_pattern( search_term )\n randomish_color = \"%06x\" % (rand * 0xffffff)\n return GeoPattern.generate(search_term, color: randomish_color )\n end", "def word_pattern(pattern, input)\n \nend", "def highlights; end", "def highlights; end", "def highlights; end", "def highlight_line(string)\n\t$targets.each do |t|\n\t\n\t\t# match case insensitive if asked nicely\n\t\tif $options.match(/i/)\n\t\t\tre = Regexp.compile(t, true)\n\t\telse\n\t\t\tre = Regexp.compile(t, false)\n\t\tend\n\n\t\t# surround each match with terminal color control chars\n\t\tstring.gsub!(re) do |s|\n\t\t\t\"%s%s%s\" % [get_color(t), $&, $Normal]\n\t\tend\n\tend\n\n\tstring\nend", "def replace_text_nodes_matching(pattern)\n return doc if project.nil?\n\n search_text_nodes(doc).each do |node|\n content = node.to_html\n\n next unless content.match(pattern)\n next if ignored_ancestry?(node)\n\n html = yield content\n\n next if html == content\n\n node.replace(html)\n end\n\n doc\n end", "def Pattern(*pattern)\n (self.class)::B._clear_bindings!(caller_locations(1,1)[0].label)\n ::PatternMatching::PatternMatch.new(*pattern)\n end", "def fullmatch(re)\n format(:color => false).match(re)\n end", "def word_pattern\n @emphasis[:word_pattern]\n end", "def apply_to(pattern)\n @pattern = pattern\n end", "def highlight(string)\n string.gsub @terms, \"<b>#{@terms}</b>\"\n end", "def on_match_pattern_p(node); end", "def highlight(text,relations,places)\n highlight = String.new(text)\n relations.each do |relation|\n highlight.gsub!(/(#{relation[\"name\"]})/) {\"\\033[7m#{$1}\\033[0m\"}\n end\n places.each do |place|\n highlight.gsub!(/(#{place})/) {\"\\033[4m#{$1}\\033[0m\"}\n end\n\n highlight\nend", "def apply_pattern(pattern)\n raise \"Not a pattern\" unless pattern.instance_of?(Pattern)\n if self.matches?(pattern.regexp)\n self.assign_tag(pattern.tag_id, 2, pattern.id)\n true\n else\n false\n end\n end", "def knump (pattern, text, start, endpos, debug_trigger)\n\n debug = \"none\"\n\n if debug_trigger == true then\n debug = \"debug\"\n end\n\n if (!pattern) || (!text) then\n log(\"No pattern input or no string/file input.\", \"error\")\n return []\n end\n\n if pattern.length == 0 || text.length == 0 then\n log(\"Pattern or text of length zero.\", \"error\")\n return []\n end\n\n if pattern.length == 1 then\n log(\"Pattern is a single character. Using ordinary naive search.\", debug)\n return findchar(pattern, text, start, endpos)\n end\n\n if start >= endpos then\n if (pattern.length == 1) && (start == endpos) then\n if text[start] == pattern[0] then\n return [0]\n else\n log(\"Char in text differs from pattern char.\", debug)\n return []\n end\n end\n log(\"Start position is after end position. Seriously?\", debug)\n return []\n end\n\n if start < 0 || endpos >= text.length then\n log(\"Start position is less than zero or end position after last\\n\" +\n \"position in text (y u do dis... dolan pls)\", \"error\")\n return []\n end\n\n prefix = createPrefixTable(pattern)\n\n log(\"Prefix table created: [#{prefix}].\", debug)\n\n results = Array.new(0,0)\n\n iRes = 0\n iPat = 0 # position in pattern\n iPtx = 0 # position of pattern check in text\n iTex = start # position in text\n\n while true\n\n if iTex > endpos then\n log(\"Main loop reached end position: #{endpos}.\", debug)\n break\n end\n\n if text[iTex] != pattern[0] then\n iTex = iTex + 1\n else\n log(\"Partial match at: #{iTex}. Enter secondary loop.\", debug)\n iPtx = iTex\n iPat = 0\n\n while true\n\n if iPtx > endpos then\n log(\"Reached end at: #{endpos} during partial match.\", debug)\n return\n end\n\n if text[iPtx] == pattern[iPat] then\n iPtx = iPtx + 1\n iPat = iPat + 1\n else\n iPtx = iPtx + prefix[iPat]\n iPat = prefix[iPat]\n end\n\n if iPat >= pattern.length then\n results[iRes] = iTex\n iRes = iRes + 1\n iTex = iTex + prefix[iPat - 1] + 1\n log(\"We've got a match! Advance by #{iTex} and continue.\", debug)\n break\n end\n\n if iPat == 0 then\n log(\"We have reached root of pattern. Advance by 1.\", debug)\n iTex = iTex + 1\n break\n end\n\n end\n\n end\n end\n return results\nend", "def highlight(text, options = {})\n options = translate(DEFAULT.merge(options))\n args = options.values_at(:output, :syntax, :line_numbers, :style, :headers)\n \n Uv.parse(text, *args)\n rescue => ex\n \"<pre>#{Rack::Utils.escape(text)}</pre>\"\n end", "def pattern2regex(pattern); end", "def start_word_pattern; end", "def scan(pattern); end", "def highlight_codes\n #@content.gsub!(/%(.*?){(.*?)}%/m) do # %{ some code }%\n @content.gsub!(/^```(.*?)\\n(.*?)\\n```/m) do # github like: http://github.github.com/github-flavored-markdown/\n lang = :text\n lang = $1 if $1 != \"\"\n Albino.colorize($2, lang)\n end\n end", "def generate_pattern(pattern)\n plist.dict do\n append_single('begin', pattern.begin)\n append_dictionary('beginCaptures', pattern.begin_captures)\n append_dictionary('captures', pattern.captures)\n append_single('comment', pattern.comment)\n append_single('contentName', pattern.content_name)\n append_single('disabled', 1) if pattern.disabled\n append_single('end', pattern.end)\n append_dictionary('endCaptures', pattern.end_captures)\n append_single('include', pattern.include)\n append_single('match', pattern.match)\n append_single('name', pattern.name)\n append_array('patterns', pattern.patterns)\n end\n end", "def highlight_by_language(text, language)\n ::CodeRay.scan(text, language).html(:line_numbers => :inline, :wrap => :span)\n end", "def process_text text, color = \"#000000\"\n end", "def on_match_pattern(node); end", "def scan(pattern)\n do_scan pattern, true, true, true\n end", "def highlight(text, phrases, *args)\n options = extract_options_from_args!(args) || {}\n unless args.empty?\n options[:highlighter] = args[0] || '<strong class=\"highlight\">\\1</strong>'\n end\n options.reverse_merge!(:highlighter => '<strong class=\"highlight\">\\1</strong>')\n\n if text.blank? || phrases.blank?\n text\n else\n match = Array(phrases).map { |p| Regexp.escape(p) }.join('|')\n text.gsub(/(#{match})/i, options[:highlighter])\n end\n end", "def pattern_matching(pattern, genome)\n # Pattern Matching Problem: Find all occurrences of a pattern in a string.\n # Input: Two strings, Pattern and Genome.\n # Output: All starting positions where Pattern appears as a substring of Genome.\n\n # Sample Input:\n # ATAT\n # GATATATGCATATACTT\n\n # Sample Output:\n # 1 3 9\n\n match_indexes = []\n search_start_pos = 0\n while index = genome.index(pattern, search_start_pos)\n match_indexes << index\n # puts index\n search_start_pos = index + 1\n end\n return match_indexes\n end", "def pattern=(pattern)\n @pattern = pattern\n substitute_variables! # TODO: Remove this call\n end", "def matching_lines(regex); end", "def pattern\n Regexp.union(pattern_classifiers.map(&:pattern))\n end", "def pattern_matcher *pattern\n lambda do |string, index = 0, counts:|\n original_counts = counts.dup\n\n pattern.inject([]) do |memo, part|\n found = part.call(string, index, counts: counts)\n\n if match? found\n index += found.size\n memo.push(*found)\n else\n counts.replace(original_counts)\n return found\n end\n end\n end\n end", "def try_regexp( str, re )\n\tif str =~ re\n\t\tputs \" #$PREMATCH\",\n\t\t \" \" + colorize( 'bold', 'green' ) { $MATCH },\n\t\t \" #$POSTMATCH\"\n\telse\n\t\tputs colorize( \"Nope.\", 'red' )\n\tend\nend", "def colorize txt, fg, bg, flags\n txt\n end", "def highlight_problems( line, re )\n\t\tline \\\n\t\t\t.gsub( re ) { color $&, :on_red } \\\n\t\t\t.gsub( /\\t+/ ) { color \"\\u{21e5} \" * $&.length, :dark, :white }\n\tend", "def highlight_blacklisted_words\n params[:comment_text]&.gsub(/(#{Regexp.union(BLACKLISTED_WORDS).source})/i) { |s| \"<<#{s}>>\" }\n end", "def pattern\n @pattern\n end", "def end_word_pattern; end", "def patterns(workbook, center, heading, _colors)\n worksheet = workbook.add_worksheet('Patterns')\n\n worksheet.set_column(0, 4, 10)\n worksheet.set_column(5, 5, 50)\n\n worksheet.write(0, 0, \"Index\", heading)\n worksheet.write(0, 1, \"Index\", heading)\n worksheet.write(0, 3, \"Pattern\", heading)\n\n worksheet.write(0, 5, \"The background colour has been set to silver.\",\n heading)\n worksheet.write(1, 5, \"The foreground colour has been set to green.\",\n heading)\n\n 19.times do |i|\n format = workbook.add_format\n\n format.set_pattern(i)\n format.set_bg_color('silver')\n format.set_fg_color('green')\n format.set_align('center')\n\n worksheet.write((2 * (i + 1)), 0, i, center)\n worksheet.write((2 * (i + 1)),\n 1, sprintf(\"0x%02X\", i), center)\n\n worksheet.write((2 * (i + 1)), 3, \"Pattern\", format)\n\n if i == 1\n worksheet.write((2 * (i + 1)),\n 5, \"This is solid colour, the most useful pattern.\", heading)\n end\n end\n end", "def highlighter; end", "def highlighter; end", "def pattern; end", "def pattern; end", "def pattern; end", "def do_parse text, pattern\n data = pattern[:blk].call(text.scan(pattern[:exp]))\n\n puts data.inspect\n end", "def patterns; end", "def expect_pattern(state)\n case state\n when :outer then %r{(?:^\\s*|<)%[~=!_#%]?|<l10n>}\n when /\\Acode_line/ then %r{\\n|\\Z}\n when /\\Acode_(?:span|print|template|visitor|comment)/ then %r{[-%]?%>}\n when :l10n then %r{<\\/l10n>}\n end\n end", "def fill(pattern)\n @style[:fill] = pattern(pattern)\n end", "def pattern(name, x, y, width, height)\n push('defs')\n push(\"pattern #{name} \" + sprintf('%g %g %g %g', x, y, width, height))\n push('graphic-context')\n yield\n ensure\n pop('graphic-context')\n pop('pattern')\n pop('defs')\n end", "def gsub(pattern, replace)\n lambda do |rec, acc|\n acc.collect! { |v| v.gsub(pattern, replace) }\n end\n end", "def grep(pattern)\n return self unless pattern\n\n pattern = Regexp.new(pattern)\n\n select do |loc|\n loc.line =~ pattern\n end\n end", "def hit_highlight(text, hits = [])\n if hits.empty?\n return text\n end\n \n chunks = text.split(\"<\").map do |item|\n item.blank? ? item : item.split(\">\")\n end.flatten\n\n tags = [\"<\" + DEFAULT_HIGHLIGHT_TAG + \">\", \"</\" + DEFAULT_HIGHLIGHT_TAG + \">\"]\n \n result = \"\"\n chunk_index, chunk = 0, chunks[0]\n prev_chunks_len = 0\n chunk_cursor = 0\n start_in_chunk = false\n for hit, index in hits.flatten.each_with_index do\n tag = tags[index % 2]\n \n placed = false\n until chunk.nil? || hit < prev_chunks_len + chunk.length do\n result << chunk[chunk_cursor..-1] \n if start_in_chunk && hit == prev_chunks_len + chunk.length\n result << tag\n placed = true\n end\n result << \"<#{chunks[chunk_index+1]}>\"\n prev_chunks_len += chunk.length\n chunk_cursor = 0\n chunk_index += 2\n chunk = chunks[chunk_index]\n start_in_chunk = false\n end\n \n if !placed && !chunk.nil?\n hit_spot = hit - prev_chunks_len\n result << chunk[chunk_cursor...hit_spot] + tag\n chunk_cursor = hit_spot\n if index % 2 == 0\n start_in_chunk = true\n end\n end\n end\n \n if !chunk.nil?\n result << chunk[chunk_cursor..-1]\n for index in chunk_index+1..chunks.length-1\n result << (index.even? ? chunks[index] : \"<#{chunks[index]}>\")\n end\n end\n \n result\n end", "def search(pattern)\n\t\tmatching_lines = lines.select { |line| line.match(pattern) }\n\t\tmatching_lines.size == 0 ? nil : matching_lines\n\tend", "def search(pattern)\n\t\tmatching_lines = lines.select { |line| line.match(pattern) }\n\t\tmatching_lines.size == 0 ? nil : matching_lines\n\tend", "def grep(pattern)\n return self unless pattern\n pattern = Regexp.new(pattern)\n\n select do |l, ln|\n l =~ pattern\n end\n end", "def add_pattern(pattern)\n @patterns << pattern\n end", "def highlight_text(text, terms, start_tag)\r\n\t\t\tquery_params = %(text=#{text}&highlight_expression=#{terms}&start_tag=#{start_tag}).tr(\" \", \"+\")\r\n\t\t\turl = construct_target_url(:highlighttext, query_params)\r\n\t\t\t\r\n\t\t\tURI.parse(url).read\r\n\t\tend", "def beautify(txt)\n #txt.gsub!(/\\*(.*)\\*/, \"<span style=\\\"font-weight: bold;\\\">\\\\1</span>\")\n #txt.gsub!(/\\/(.*)\\//, \"<em>\\\\1</em>\") # Italic\n #txt.gsub!(/\\_(.*)\\_/, \"<span style=\\\"font-decoration: underline;\\\">\\\\1</span>\")\n #txt.gsub!(/\\-(.*)\\-/, \"<span style=\\\"font-decoration: line-through;\\\">\\\\1</span>\")\n # <span style=\"font-size: large;\">ok?</span>\n # <span style=\"color: #FF0000;\">ok?</span>\n txt\n end", "def highlight_gap_marks_in_red!(lb)\n # gap_marks: Skip certain characters and find characters to highlight in red\n gap_mark_complete_regex = Regexp.new(Regexp.escape(tmp_gap_mark_complete))\n l_ch = @options[:language].chars\n chars_to_skip = [\n l_ch[:d_quote_open],\n l_ch[:em_dash],\n l_ch[:s_quote_open],\n ' ',\n '(',\n '[',\n '\"',\n \"'\",\n '}',\n '*',\n '[', # chinese bracket\n '(', # chinese parens\n '一', # chinese dash\n '《', # chinese left double angle bracket\n ].join\n lb.gsub!(\n /\n #{ gap_mark_complete_regex } # find tmp gap mark number and text\n ( # capturing group for first group of characters to be colored red\n (?: # non capturing group\n #{ l_ch[:elipsis] } # elipsis\n (?!#{ l_ch[:elipsis] }) # not followed by another elipsis so we exclude chinese double elipsis\n )? # optional\n )\n ( # capturing group for characters that are not to be colored red\n (?: # find one of the following, use non-capturing group for grouping only\n [#{ Regexp.escape(chars_to_skip) }]+ # special chars or delimiters\n | # or\n …… # chinese double elipsis\n | # or\n \\\\[[:alnum:]]+\\{ # latex command with opening {\n | # or\n \\s+ # eagle followed by whitespace\n )* # any of these zero or more times to match nested latex commands\n )\n ( # capturing group for second group of characters to be colored red\n #{ l_ch[:elipsis] }? # optional elipsis\n [[:alpha:][:digit:]#{ l_ch[:apostrophe] }\\-\\?,]* # words and some punctuation\n )\n /x,\n # we move the tmp_gap_mark_number to the very beginning so that if we\n # have an ellipsis before a latex command, the gap_mark_number will be\n # in front of the entire section that is colored red.\n # \\1: an optional ellipsis (colored red)\n # \\2: an optional latex command or characters not to be colored red\n # \\3: the text to be colored red\n # OPTIMIZATION: We could skip the first \\RtGapMarkText if \\1 is blank\n tmp_gap_mark_number + \"\\\\RtGapMarkText\" + '{\\1}' + '\\2' + \"\\\\RtGapMarkText\" + '{\\3}'\n )\n # If in the gap_mark processing above regex ref \\1 is empty, we end up\n # with empty `\\RtGapMarkText{}` fragments. We remove them in this step:\n lb.gsub!(\"\\\\RtGapMarkText{}\", '')\n # Move tmp_gap_mark_number to outside of quotes, parentheses and brackets\n if !['', nil].include?(tmp_gap_mark_number)\n gap_mark_number_regex = Regexp.new(Regexp.escape(tmp_gap_mark_number))\n chars_to_move_outside_of = [\n l_ch[:apostrophe],\n l_ch[:d_quote_open],\n l_ch[:s_quote_open],\n '(',\n '[',\n ].join\n lb.gsub!(\n /\n ( # capturing group for characters to move outside of\n [#{ Regexp.escape(chars_to_move_outside_of) }]*\n )\n #{ gap_mark_number_regex } # find tmp gap mark number\n /x,\n tmp_gap_mark_number + '\\1' # Reverse order\n )\n # Move tmp_gap_mark_number to after leading eagle\n lb.gsub!(\n /\n (#{ gap_mark_number_regex }) # capture group for tmp gap mark number\n \\s? # followed by eagle and optional space\n /x,\n '\\1' # Reverse order\n )\n # Convert tmp_gap_mark_number to latex command\n lb.gsub!(gap_mark_number_regex, \"\\\\RtGapMarkNumber{}\")\n end\n # Make sure no tmp_gap_marks are left\n if(ltgm = lb.match(/.{0,20}#{ Regexp.escape(tmp_gap_mark_text) }.{0,20}/))\n raise(LeftoverTempGapMarkError.new(\"Leftover temp gap mark: #{ ltgm.to_s.inspect }\"))\n end\n if !['', nil].include?(tmp_gap_mark_number)\n if(ltgmn = lb.match(/.{0,10}#{ Regexp.escape(tmp_gap_mark_number) }.{0,10}/))\n raise(LeftoverTempGapMarkNumberError.new(\"Leftover temp gap mark number: #{ ltgmn.to_s.inspect }\"))\n end\n end\n end", "def each_match_range(range, regex); end", "def highlight_words(t, words, html = true)\n if html\n t = h(t)\n end\n if html\n t = highlight(t, words, '<span class=\"highlight\">\\1</span>')\n else\n t = highlight(t, words, '*\\1*')\n end\n return t\n end", "def link_regex(regex, &url_proc)\n highlighted_lines.map!.with_index do |rich_line, i|\n marker = StringRegexMarker.new(plain_lines[i].chomp, rich_line.html_safe)\n\n marker.mark(regex, group: :name) do |text, left:, right:|\n url = yield(text)\n url ? link_tag(text, url) : text\n end\n end\n end", "def occurGrep(pattern, filename)\n\tregexp = Regexp.new(pattern)\n\tFile.foreach(filename).with_index { |line, line_num| \n\t\tputs \"#{line_num}: #{line}\" if regexp =~ line }\nend", "def extract(pattern); end", "def initialize(pattern)\n @pattern = pattern\n end", "def scan(text, pattern, &block)\n # convert tabs to spaces\n text.gsub!(/^(\\t+)/) {|tabs| ' ' * (8 * tabs.length)}\n\n text.scan(pattern).each do |matches|\n hash = Hash[pattern.names.zip(matches)]\n yield hash if block\n\n section = hash.delete('section')\n section ||= hash.delete('attach')\n\n if section\n hash['approved'] &&= hash['approved'].strip.split(/[ ,]+/)\n\n @sections[section] ||= {}\n next if hash['text'] and @sections[section]['text']\n @sections[section].merge!(hash)\n end\n end\n end", "def min_distance_pattern_text(pattern, text)\n pattern.upcase!\n text.upcase!\n # d(Pattern,Text)= min of all k-mers Pattern' in Text calculate the HammingDistance(Pattern,Pattern′)\n min_dist = hamming_distance(pattern, text.slice(0,pattern.length))\n (1..(text.length-pattern.length)).each do |i|\n kmer = text.slice(i,pattern.length)\n min_dist = hamming_distance(pattern, kmer) if min_dist > hamming_distance(pattern, kmer)\n end\n return min_dist\n end", "def scan(pattern, &blk)\n @string.scan(pattern, &blk)\n end", "def scan(pattern, &blk)\n @string.scan(pattern, &blk)\n end", "def fetch_pattern(type, indentation); end", "def search(ent, txtvu)\n start = txtvu.buffer.start_iter\n first, last = start.forward_search(ent.text, Gtk::TextIter::SEARCH_TEXT_ONLY, nil)\n count = 0\n while (first)\n start.forward_char\n first, last = start.forward_search(ent.text, Gtk::TextIter::SEARCH_TEXT_ONLY, nil)\n start = first\n txtvu.buffer.apply_tag(\"highlight\", first, last)\n count += 1\n end\nend", "def highlight_search_res(sentence, word)\n count = sentence.split.count{ |matched| matched.downcase.include?('can') }\n capital_word = word.dup.capitialize()\n s = \"\"\n s += sentence.gsub(\"#{word}\", \"(#{word})\").gsub(\"#{capital_word}\", \"(#{capital_word})\")\n s += \"\\n\"\n s += \"Total occurence found : #{count}\"\nend", "def =~(pattern)\n if pattern.is_a? Symbol\n @name == pattern\n elsif pattern.is_a? Regexp\n rv = text =~ pattern\n else # Hash, Pattern_any, Pattern_all\n pattern === self\n end\n end", "def get_matching_indices pattern\n matches = []\n @obj.content.each_with_index { |e,i| \n # convert to string for tables\n e = e.to_s unless e.is_a? String\n if e =~ /#{pattern}/\n matches << i\n end\n }\n return matches\n end", "def pattern\n segs = @tags.map { |tagged_segment| build_segment(tagged_segment) }\n segs.last.gsub!(/\\.$/, '')\n segs.unshift \"^\"\n segs.push \"\\\\.?$\"\n Regexp.new(segs.join)\n end", "def regex(pattern)\n Regexp.new pattern.regex\n end", "def show_regexp(string, pattern)\n match = pattern.match(string)\n if match\n \"#{match.pre_match}->#{match[0]}<-#{match.post_match}\"\n else\n \"no match\"\n end\nend", "def simplified_pattern\n pattern\n end", "def simplified_pattern\n pattern\n end", "def matches_pattern?(text)\n text.split('|').count == 3\n end", "def each(&block)\n @patterns.each(&block)\n end", "def egrep(pattern)\n each do |fn|\n open(fn) do |inf|\n count = 0\n\n inf.each do |line|\n count += 1\n if pattern.match(line)\n if block_given?\n yield fn, count, line\n else\n puts \"#{fn}:#{count}:#{line}\"\n end\n end\n end\n \n end\n end\n end", "def pattern_candidates(pattern,representative)\n candidate_set_for_syntax_trees(representative.head_trees,@category_filters,pattern)\n end", "def rabinKarpStringSearch(text, pattern)\n return nil if pattern.nil? or text.nil?\n n = text.length\n m = pattern.length\n\n patternHash = hash_of(pattern)\n textHash = hash_of(text[0,m]) \n\n 0.upto(n-m) do |i|\n if textHash == patternHash\n if text[i..i+m-1] == pattern\n return i\n end\n end\n \n textHash = hash_of(text[i+1..i+m])\n end\n \n nil\nend", "def find_by_pattern(pattern)\n pattern = decode_pattern(pattern)\n rotation { |offset| match?(offset, pattern) }\n end", "def pattern\n pattern = params[:pattern].to_s\n if pattern.match(/^\\d+$/) &&\n (@project = Project.safe_find(pattern))\n # redirect_to(action: :show, id: project.id)\n set_ivars_for_show\n render(\"show\", location: project_path(@project.id))\n else\n query = create_query(:Project, :pattern_search, pattern: pattern)\n show_selected_projects(query)\n end\n end", "def goHighlight (h, s)\n # if (!h) return\n # hLen = h.size\n #\n # for (var i=0; i<hLen; i++) {\n # var para = this.paragraphList().list[h[i]-1] || false;\n # if (para) {\n # var sntns = s[h[i].toString()] || false;\n # var multi = !sntns || sntns.length==0; #// Individual sentences, or whole paragraphy?\n # var lines = this.getSentences(para);\n # var jLen = lines.length;\n #\n # /* First pass. Add SPAN tags to all lines. */\n # for (var j=0; j<jLen; j++) {\n # var k = (multi) ? j : sntns[j]-1;\n # lines[j] = \"<span data-num='\" + (j+1) + \"'>\" + lines[j] + \"</span>\";\n # # // lines[j] = \"<a name='\" + (j+1) + \"' /><span data-num='\" + (j+1) + \"'>\" + lines[j] + \"</span>\";\n # }\n #\n # /* Second pass, update span to Highlight selected lines */\n # for (var j=0; j<jLen; j++) {\n # var k = (multi) ? j : sntns[j]-1;\n # var line = lines[k] || false;\n # if (line) {\n # lines[k] = lines[k].replace(\"<span\", \"<span class='\" + this.classHighlight + \"'\");\n # # // trying to create absolute links for sentences here\n # # // lines[k] = lines[k].replace(\"<span\", \"<a name='\" + + \"'><span class='\" + this.classHighlight + \"'\");\n # }\n # }\n #\n # para.setAttribute(\"data-sentences\", jLen);\n # para.innerHTML = lines.join('. ').replace(/__DOT__/g, \".\").replace(/<\\/span>\\./g, \".<\\/span>\");\n # para.addClassName('emReady'); /* Mark the paragraph as having SPANs */\n # }\n # }\n end", "def c(text, colors)\n text = \"%{B#{colors[:bg]}}#{text}%{B-}\" if colors[:bg]\n text = \"%{F#{colors[:fg]}}#{text}%{F-}\" if colors[:fg]\n text\nend", "def escape_text\n color.strip text.dup\n end", "def cmd_list pattern = '.'\n puts \"Following mnemo's #{pattern && \"matching regexp /#{pattern}/\"} are present\"\n puts\n references_by_pattern(pattern).each do |reference|\n puts (\" \" * 4) + reference\n end\n\n puts\n puts \"Done ..\"\n end", "def insert_text(position, pattern, new_text, indentation = 4)\n index = case pattern\n when Regexp\n if match = @body.match(pattern)\n match.offset(0)[position == :before ? 0 : 1]\n else\n @body.size\n end\n else\n pattern\n end\n @body.insert index, indent(indentation, new_text)\n end", "def add_regexp_handling pattern, name, exclusive = false\n bitmap = @attributes.bitmap_for(name)\n @regexp_handlings << [pattern, bitmap]\n @exclusive_bitmap |= bitmap if exclusive\n end", "def pattern\n @pattern ||= Pattern.patterns[pattern_name]\n end", "def matches?(pattern); end", "def highlight\n return unless Config.live_highlight\n\n code = CodeRay.scan(line, :ruby).html\n\n cursor = text_cursor\n\n pos = cursor.position\n cursor.move_position Qt::TextCursor::End\n cursor.set_position @min_position, Qt::TextCursor::KeepAnchor\n cursor.remove_selected_text\n\n cursor.insert_html \"<code>#{code}</code>\"\n cursor.position = pos\n\n self.text_cursor = cursor\n end" ]
[ "0.7007881", "0.6570006", "0.6157934", "0.61531353", "0.61190563", "0.6077356", "0.60678107", "0.601119", "0.601119", "0.601119", "0.5939517", "0.5928957", "0.5888052", "0.58456266", "0.584248", "0.58179927", "0.57969415", "0.5784149", "0.57815874", "0.5753481", "0.57060385", "0.5689268", "0.56687176", "0.56596047", "0.564978", "0.5646188", "0.56450784", "0.56445897", "0.56398535", "0.5629519", "0.56261444", "0.5625687", "0.56229836", "0.5572615", "0.5570199", "0.5561977", "0.5551529", "0.5547816", "0.5542234", "0.55248296", "0.55215675", "0.55192286", "0.55095977", "0.55042386", "0.54925346", "0.54925346", "0.5473931", "0.5473931", "0.5473931", "0.5461868", "0.5461067", "0.54294956", "0.54253966", "0.5424634", "0.5424081", "0.5423017", "0.5421029", "0.54089785", "0.54089785", "0.54076415", "0.54023707", "0.5399238", "0.538938", "0.53777564", "0.5376027", "0.53543794", "0.5347326", "0.53460264", "0.53453004", "0.534029", "0.5338343", "0.5333364", "0.5331052", "0.5331052", "0.5331025", "0.5329885", "0.53258944", "0.53198355", "0.53129977", "0.53004867", "0.52737844", "0.5272845", "0.52646434", "0.52646434", "0.52568454", "0.5250526", "0.52443874", "0.52435523", "0.523386", "0.52294", "0.5228608", "0.52285624", "0.5227", "0.5226813", "0.52236605", "0.521953", "0.52176195", "0.52147686", "0.52069026", "0.52054" ]
0.7619761
0
Returns a 2D array [[render1, text1], [render2, text2], ..., [rendern, textn]]
def get_line_render_instructions(line_num) start_line_index = index_of_position(line_num) line = line(line_num) instructions = [] highlight_index = @highlights.length - 1 highlight_index -= 1 while highlight_index > 0 and @highlights[highlight_index][0] > start_line_index highlight = @highlights[highlight_index][1] highlight_index += 1 part_start_index = 0 (0..line.length).each do |c| if c == line.length or (highlight_index < @highlights.length and @highlights[highlight_index][0] == c + start_line_index) instructions << [highlight, line[part_start_index ... c]] break if c == line.length highlight = @highlights[highlight_index][1] highlight_num += 1 end end instructions end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def matrix(text)\n row1, row2, row3 = rows_as_char_arrays(text)\n row1.zip(row2, row3)\n end", "def characters_array # That's a terrible name.\n convert_to_chars\n highlight_squares\n self.rows\n end", "def create\n\t\t\tobj = []\n\t\t\t@@fonts[@font]['n'].size.times do\n\t\t\t\tobj << []\n\t\t\tend\n\t\t\tcurrent = 0\n\n\t\t\tcount = 0\n\t\t\t@text.each_byte do |c|\n\t\t\t\tif @@chars.include? c.chr\n\t\t\t\t\t@@fonts[@font][c.chr].each_with_index do |fr,ri|\n\t\t\t\t\t\tfr.each do |fc|\n\t\t\t\t\t\t\tif @rainbow\n\t\t\t\t\t\t\t\tobj[ri] << Pixel.new(@@rainbow[current], @colors[0].bg,fc)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tobj[ri] << Pixel.new(@colors[current].fg,@colors[current].bg,fc)\n\t\t\t\t\t\t\tend\n\n\t\t\t\t\t\t\tif @rainbow != true\n\t\t\t\t\t\t\t\tcurrent += 1 if @colors.size > 1\n\t\t\t\t\t\t\t\tcurrent = 0 if current > @colors.size\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\n\t\t\t\t\tif @rainbow\n\t\t\t\t\t\tcurrent += 1\n\t\t\t\t\t\tcurrent = 0 if current >= @@rainbow.size\n\t\t\t\t\tend\n\n\t\t\t\t\tif count < @text.size-1\n\t\t\t\t\t\t@@fonts[@font]['n'].size.times do |ri|\n\t\t\t\t\t\t\t@space.times do\n\t\t\t\t\t\t\t\tif @rainbow\n\t\t\t\t\t\t\t\t\tobj[ri] << Pixel.new(@@rainbow[current], @colors[0].bg,Theme.get(:background).symbol)\n\t\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\t\tobj[ri] << Pixel.new(@colors[current].fg,@colors[current].bg,Theme.get(:background).symbol)\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t# SPace\n\t\t\t\telse\n\t\t\t\t\t@@fonts[@font]['n'].size.times do |ri|\n\t\t\t\t\t\t3.times do\n\t\t\t\t\t\t\tif @rainbow\n\t\t\t\t\t\t\t\tobj[ri] << Pixel.new(@@rainbow[current], @colors[0].bg, Theme.get(:background).symbol)\n\t\t\t\t\t\t\telse\n\t\t\t\t\t\t\t\tobj[ri] << Pixel.new(@colors[current].fg,@colors[current].bg, Theme.get(:background).symbol)\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tcount += 1\n\t\t\tend\n\t\t\t@obj = obj\n\t\tend", "def render\n arr = Array.new(4) { Array.new(4) }\n # arr1 = Array.new(4) { Array.new(4) }\n # @grid.each_with_index do |row, i|\n # row.each_with_index do |card, j|\n # #arr[i][j] = card.face_up ? card.face_value : 0\n # arr1[i][j] = card.face_value\n # end\n # p arr1[i]\n # end\n\n @grid.each_with_index do |row, i|\n row.each_with_index do |card, j|\n arr[i][j] = card.face_up ? card.face_value : 0\n end\n p arr[i]\n end\n arr\n end", "def render\n render = Array.new(@towers)\n \n @board.each_with_index do |tower, i|\n render[i] = [\" \"] * (@towers - tower.length) + tower\n end\n \n puts \"__________\"\n puts \"\\nTOWERS OF HANOI\\n\"\n \n render.transpose.each do |row|\n puts \" \" + row.join(\" \")\n end\n \n puts \"--- \" * @towers \n puts \" \" + (1..@towers).to_a.join(\" \")\n puts \"\\n\\n\"\n end", "def to_a(newlines: false, phrases: true)\n grid[:rows]\n .reverse\n .map { |row|\n grid[:columns].map do |column|\n render(\n phrases ? words_inside(column, row) : chars_inside(column, row),\n newlines: newlines\n )\n end\n }\n end", "def to_a(newlines: false, phrases: true)\n grid[:rows]\n .reverse\n .map { |row|\n grid[:columns].map do |column|\n render(\n phrases ? words_inside(column, row) : chars_inside(column, row),\n newlines: newlines\n )\n end\n }\n end", "def represent\n # grid_array will be an array of strings that represent our grid in NxN format\n grid_array=[]\n @h.times{|r| grid_array<<@grid[r*@w,@w].split('')*' '}\n grid_array\n end", "def draw_string_array(instructions, start_x, start_y, max_width)\n draw_string_y = start_y\n string_height = 20\n instructions_font = Gosu::Font.new(string_height)\n instructions.each do |instruction|\n wrapped_instruction = wrap_string(instruction, instructions_font, max_width)\n instructions_font.draw_text(wrapped_instruction[0],\n start_x,\n draw_string_y,\n 1)\n draw_string_y += string_height * (wrapped_instruction[1] + 1)\n end\nend", "def build_ocr_arr\n # puts\n ocr_arr = []\n ocr_lines = @text.split(\"\\n\\n\") # lines of OCR chars are sep'd by a blank line\n ocr_lines.each do |line|\n # puts \"line ==\\n#{line}\"\n\n rows = line.split(\"\\n\") # each line of OCR chars is made up of multiple rows of text\n # puts \"rows ==\\n#{rows}\"\n\n # map the arr of cols into each row\n ocr_size = 0\n rows.map! do |row|\n ocr_cols = row.scan(/.{1,3}/) # each OCR char is made up of 1 to 3 cols of text\n\n # ocr_size is the num of ocr_cols (thus a rep of the num of OCR chars) in each row\n ocr_cols = [\"\"] if ocr_cols == []\n\n # puts \"ocr_cols == #{ocr_cols}\"\n ocr_size += ocr_cols.size\n ocr_cols\n end\n # puts \"rows2 ==\\n#{rows}\"\n ocr_size /= 3 # 3 rows for each OCR char\n # p \"ocr_size == #{ocr_size}\"\n\n # build a str rep of each OCR char that's in the current line of OCR\n # chars and copy that str to the ocr_arr\n (0...ocr_size).each do |ocr_digit|\n ocr_str = ''\n rows.each do |row|\n # puts \"row == #{row}\"\n\n # chop off any trailing blanks;\n # if the row has trailing spaces (padding for the next OCR char),\n # strip off the padding\n str = row[ocr_digit]\n ocr_str += str.sub(/( )+$/, '') + \"\\n\"\n end\n # p \"ocr_str == '#{ocr_str}'\"\n ocr_arr << ocr_str\n end\n ocr_arr << ',' unless line == ocr_lines.last # put a comma btwn lines of OCR chars\n end\n ocr_arr\n end", "def time_to_font(time,font)\n output = []\n for i in 0...time.length()\n converted_font = convert_1_number_to_1_font(time[i],font)\n output.append(converted_font)\n end\n return output\nend", "def rows_as_char_arrays(text)\n rows = text.split(\"\\n\")\n\n max_length = rows.map(&:length).max\n\n rows.map do |row|\n # add padding to fix row length if necessary\n row += ' ' * (max_length - row.length)\n row.chars\n end\n end", "def as_two_dimensional_array\n @as_two_dimensional_array ||= grid.as_two_dimensional_array.each_with_index.map do |row, y|\n row.each_with_index.map do |letter, x|\n Letter.new(\n letter: letter,\n x: x,\n y: y,\n letter_multiplier: multipliers.letter.indices(x,y).first&.value,\n word_multiplier: multipliers.word.indices(x,y).first&.value\n )\n end\n end\n end", "def render_matrix\n Matrix.rows render_rows\n end", "def print\n grid_array = []\n @height.times do |r|\n grid_array << @grid[r * @width, @width].split('') * ' '\n end\n grid_array\n end", "def draw_entry_array(x, y, w, array)\n draw_icon(array[0].to_i, x, y + (line_height - 24) / 2)\n change_color(text_color(MARW_CONFIGURATION[:colour_name]))\n tw_r = array[2] ? text_size(array[2].to_s).width + 4 : 0\n draw_text(x + 24, y, w - 24 - tw_r, line_height, array[1].to_s)\n change_color(text_color(MARW_CONFIGURATION[:colour_amount]))\n draw_text(x + 24, y, w - 24, line_height, array[2].to_s, 2) if array[2]\n end", "def render_all pad, arr\n pre_render\n @content_cols = @source.pad_cols\n @clearstring = \" \" * @content_cols\n @list = arr\n\n att = @attr || NORMAL\n FFI::NCurses.wattron(pad, @cp | att)\n\n arr.each_with_index { |line, ix|\n render pad, ix, line\n }\n FFI::NCurses.wattroff(pad, @cp | att)\n end", "def create_texts\n add_text(TEXT_OX, 0, DELTA_X - TEXT_OX, DELTA_Y, text_get(32, 0)) # Attack !\n add_text(TEXT_OX + DELTA_X, 0, DELTA_X - TEXT_OX, DELTA_Y, text_get(32, 1)) # Bag\n add_text(TEXT_OX, DELTA_Y, DELTA_X - TEXT_OX, DELTA_Y, text_get(32, 2)) # Pokemon\n add_text(TEXT_OX + DELTA_X, DELTA_Y, DELTA_X - TEXT_OX, DELTA_Y, text_get(32, 3)) # Flee\n end", "def test_cmds(cmds)\n max_x = 7\n max_y = 3\n cmds.push(\"rect 3x2\")\n cmds.push(\"rotate column x=1 by 1\")\n cmds.push(\"rotate row y=0 by 4\")\n cmds.push(\"rotate column x=1 by 1\")\n screen = Array.new(max_x) { |i| Array.new(max_y) { |i| \".\" }}\nend", "def render\n # Clear the console\n puts \"\\e[H\\e[2J\"\n (1..DEFAULT_WIDTH).each do |y|\n row = []\n\n (1..DEFAULT_WIDTH).each do |x|\n row << cell(x, y).render\n end\n puts row.join(\" \")\n puts \"\\n\"\n end\n end", "def text_rendering_matrix\n @text_rendering_matrix ||= begin\n state_matrix = TransformationMatrix.new(\n state[:text_font_size] * state[:h_scaling], 0,\n 0, state[:text_font_size],\n 0, state[:text_rise]\n )\n state_matrix.multiply!(\n @text_matrix.a, @text_matrix.b,\n @text_matrix.c, @text_matrix.d,\n @text_matrix.e, @text_matrix.f\n )\n state_matrix.multiply!(\n ctm.a, ctm.b,\n ctm.c, ctm.d,\n ctm.e, ctm.f\n )\n end\n end", "def to_s\n Array(render).map(&:to_s).join(\"\\n\")\n end", "def graphics\n board_graphics = []\n board.each do |row|\n symbolic_row = []\n row.each {|ele| symbolic_row << ele.to_s }\n board_graphics << symbolic_row\n end\n board_graphics\n end", "def create\n for i in 1 .. (@canvas_height - 1) do\n @buffer.append(i, \" \" * (@canvas_width - 1))\n end\n end", "def array_of_row_arrays(text)\n c = 0\n arr = []\n arr_of_arrys = []\n # add \"\\n\" to last row of string to make symmetric with previous rows\n # creating an array every 51 chars, and push such array into container array\n text.split('').push('\\n').each_with_index do |value, i| \n c += 1\n arr << value\n if c == 51\n c = 0\n arr_of_arrys << arr\n arr = []\n end\n end\n return arr_of_arrys\nend", "def merge_arr(arr)\n merged_arr = [\"\",\"\",\"\",\"\",\"\",\"\"]\n for i in 0...arr[0].length() \n for j in 0...arr.length() \n font_character = arr [j]\n merged_arr[i] += font_character[i]\n end\n end \n return merged_arr\nend", "def make_grid()\n grid = Array.new(GRID_SIZE) { Array.new(GRID_SIZE) }\n ## Build init grid\n x = 1\n y = 1\n File.readlines(FILENAME).each do |line|\n x = 1\n line.chars.each do |char|\n grid[y][x] = char\n x += 1\n end\n y += 1\n end\n grid\nend", "def another_print_fonts\n for index in 0..@fonts.size do\n puts \"#{index} -> #{@fonts[index]}\" # use of templating\n end\nend", "def make_matrixarray\n\t\tmatrix = []\n\t\t@speakers.each do |this_speaker|\n\t\t\tmatrix << row(this_speaker)\n\t\tend\n\t\t#return matrix array\n\t\treturn matrix\n\tend", "def layout\n return @layout if @layout\n\n bad_tiles = [] # The set of tile names that didn't work!\n @layout = [] # The 2D array of tiles\n for row in layout_text\n @layout.push(r = [])\n for tile_name in row\n tile = Tile.find_by_name(tile_name)\n r.push(tile)\n # Handle an error by remembering the tile name\n unless tile\n bad_tiles.push(tile_name) unless bad_tiles.include?(tile_name)\n end\n end\n end\n\n # If there was a problem raise the Error.\n unless bad_tiles.empty?\n @layout = nil\n raise Error(\"Bad tiles: %s\" % bad_tiles.join(\", \"))\n end\n @layout\n end", "def layout\n return @layout if @layout\n\n bad_tiles = [] # The set of tile names that didn't work!\n @layout = [] # The 2D array of tiles\n for row in layout_text\n @layout.push(r = [])\n for tile_name in row\n tile = Tile.find_by_name(tile_name)\n r.push(tile)\n # Handle an error by remembering the tile name\n unless tile\n bad_tiles.push(tile_name) unless bad_tiles.include?(tile_name)\n end\n end\n end\n\n # If there was a problem raise the Error.\n unless bad_tiles.empty?\n @layout = nil\n raise Error(\"Bad tiles: %s\" % bad_tiles.join(\", \"))\n end\n @layout\n end", "def create_inputs\n @inputs = Array.new(@max_size) do |i|\n add_text(base_x + i * delta_x, base_y + delta_y, delta_x, delta_y, NO_CHAR, 1)\n end\n end", "def render\n \"\".tap do |output|\n (1..height).each do |y|\n (1..width).each do |x|\n object = objects_at(Locatable::Point.new(x: x, y: y)).first\n\n output << (object.nil? ? \" \" : object.sprite)\n end\n\n output << \"\\n\"\n end\n end\n end", "def button_texts\n return [[nil, nil, nil, ext_text(9000, 9)]] * 3 if @page_id\n\n return [\n [ext_text(9000, 6), ext_text(9000, 7), ext_text(9000, 8), ext_text(9000, 9)],\n [ext_text(9000, 10), ext_text(9000, 11), ext_text(9000, 12), ext_text(9000, 13)],\n [ext_text(9000, 6), ext_text(9000, 7), ext_text(9000, 8), ext_text(9000, 9)]\n ]\n end", "def display_plate(outname, ops, stamp_columns=false)\n plate = Array.new(8) { Array.new(12, \"-\") }\n if stamp_columns\n ops.each do |op|\n col = op.output(outname).column\n background = BACKGROUND_COLORS[col]\n content = \"#{(\"A\".ord.to_i).chr}#{col+1}\"\n plate[0][col] = {content: content, style: {background: background} }\n (1..stamp_columns - 1).each do |row|\n plate[row][col] = { content: \" \", style: { background: background } }\n end\n end\n else\n ops.each do |op|\n row = op.output(outname).row\n col = op.output(outname).column\n plate[row][col] = {content: \"#{(row + \"A\".ord.to_i).chr}#{col+1}\", style: {background: BACKGROUND_COLORS[0] } }\n end\n end\n\n return plate\n end", "def to_array str\n array = []\n str.split().each do |i|\n entry = i.split(\",\")\n\n width = entry[0].to_i\n height = entry[1].to_i\n\n if entry.length == 2\n array << [width, height]\n else\n ALL_MACROS[entry[2]].call(width, height, array)\n end\n end\n\n array\nend", "def parse_text_with_render_state(str, rs = nil)\n\t\t\trs ||= RenderState.new\n \t\t\thtml = parse_text(str, rs)\n\n\t\t\treturn [html, rs]\n\t\tend", "def createTextOutput(tree, width, height, divisions)\n\tareaMap = [ ]\n\ttextOutput = [ ]\n\tfor x in 0..width \n\t\tareaMap[x] = [ ]\n\t\tfor y in 0..height \n\t\t\tareaMap[x][y] = '#'\n\t\tend\n\tend\n\tareaMap = tree.displayTree(areaMap)\n\tsaveTextOutput(1, areaMap, width, height, divisions)\nend", "def convert(data_array, format)\n formated_text_and_coordinates=[]\n for i in 0 ... format.items.size\n formated_text_current = format.items[i][2].clone\n for j in 0 ... data_array.size\n if formated_text_current =~ /__#{j}__/\n if ! data_array[j] then data_array[j]=\"\" end\n eval \"formated_text_current.gsub!(/__#{j}__/,data_array[j])\"\n end\n end\n formated_text_and_coordinates.push([format.items[i][0], format.items[i][1], formated_text_current])\n end\n return formated_text_and_coordinates\nend", "def convert(data_array, format)\n formated_text_and_coordinates=[]\n for i in 0 ... format.items.size\n formated_text_current = format.items[i][2].clone\n for j in 0 ... data_array.size\n if formated_text_current =~ /__#{j}__/\n if ! data_array[j] then data_array[j]=\"\" end\n eval \"formated_text_current.gsub!(/__#{j}__/,data_array[j])\"\n end\n end\n formated_text_and_coordinates.push([format.items[i][0], format.items[i][1], formated_text_current])\n end\n return formated_text_and_coordinates\nend", "def row_cells\n rowdata = []\n print_layout.each do |section|\n rowdata += row_cell_items(section[:row_cells])\n end\n rowdata\n end", "def yale_nd_row_as_array i\n yale_nd_row(i, :array)\n end", "def get_text\n outarr = Array.new\n @data.each do |item|\n paths = item[\"path\"]\n item[\"text\"] = \"\"\n \n # OCR all files and save\n paths.each { |path| item[\"text\"] += ocr_file(\"../docs/\"+path)} if paths\n outarr.push(item)\n end\n @data = outarr\n end", "def draw_multi(text, x, y, width, lines = -1, base_color = Color.new(255,255,255), shadow_color = nil,\n outline = false, y_line_diff = 24, allow_split_in_words = false)\n self.bmp.draw_multi(text, x, y, width, lines, base_color, shadow_color,\n outline, y_line_diff, allow_split_in_words)\n end", "def make_list(text)\n\traw_text_array = text.split(\" \")\n\treturn raw_text_array\nend", "def create_position_array()\n array_2D = []\n array_1D = []\n\n (0...@row).each_with_index do |value, row_index|\n (0...@col).each_with_index { |value, col_index| array_1D.append(value+(row_index*@col)) }\n array_2D.append(array_1D)\n array_1D = []\n end\n\n return array_2D\n end", "def print *textarray\n create_window unless @win\n show unless @visible\n c = 1\n textarray.each_with_index { |s, i| \n @win.printstring i+@row_offset, c+@col_offset, \"%-*s\" % [@w-(@col_offset*2)-c, s], @color_pair\n }\n @win.wrefresh\n end", "def render\n puts \" #{(0..8).to_a.join(\" \")}\"\n grid.each_with_index do |row, i|\n arr = []\n row.each do |tile|\n if tile.revealed == true\n arr << tile.display_value\n elsif tile.flagged == true\n arr << \"F\"\n else\n arr << \"*\"\n end\n end\n\n puts \"#{i} #{arr.join(\" \")}\"\n end\n end", "def render\n index\n grid.each_with_index do |row, i|\n join(row, i)\n end\n index\n end", "def generate_grid(board_string) current_grid = Array.new(3, Array.new(3) {\n[\"-\", \"X\"].sample })\n\n parse_char = board_string.split('')\n parse_count = 0\n\n test = current_grid.length\n\n 3.times do |row|\n 3.times do |idx|\n current_grid[row][idx] = parse_char[parse_count]\n parse_count += 1\n end\n end\n\n return current_grid\nend", "def break_text_with_image(width, textarray, draw)\n tokens = textarray.flat_map{ |x| x.respond_to?(:split) ? x.split(/ /) : x }\n tokens = tokens.flat_map{ |x| x.respond_to?(:split) ? x.split(/(?<=\\n)/) : x }\n\n result = []\n line = []\n linelength = 0\n\n tokens.each_with_index do |item, i|\n itemlength = item.class == Image ?\n item.columns : draw.get_type_metrics(item + ' ').width\n\n if (line.empty?)\n line << item\n else\n if (width != 0 && itemlength + linelength > width)\n result << line\n line = [item]\n linelength = 0\n else\n t = line.pop\n\n if (t.class != Image)\n t += ' '\n elsif (item.class != Image)\n item = ' ' + item\n end\n\n if (t.class == Image or item.class == Image)\n line << t << item\n else\n line << t + item\n end\n end\n end\n\n if (item.class != Image and item.include?(\"\\n\"))\n line[0].sub!(\"\\n\", '')\n result << line\n line = []\n linelength = 0\n next\n end\n\n linelength += itemlength\n end\n\n unless (line.empty?)\n result << line\n end\n\n return result\n end", "def to_boxes\n boxes = []\n @contents.each do |c|\n if @type == VERTICAL\n boxes << Box.new(c[0], 0, c[1], c[2])\n else\n boxes << Box.new(0, c[0], c[2], c[1])\n end\n end\n boxes\n end", "def render\n buffer = []\n _guess_col_widths\n rows = @list.size.to_s.length\n @rows = rows\n _prepare_format\n \n str = \"\"\n if @numbering\n str = \" \"*(rows+1)+@y\n end\n str << @fmstr % @columns\n buffer << str\n #puts \"-\" * str.length\n buffer << separator\n if @list\n if @numbering\n @fmstr = \"%#{rows}d \"+ @y + @fmstr\n end\n #@list.each { |e| puts e.join(@y) }\n count = 0\n @list.each_with_index { |r,i| \n value = convert_value_to_text r, count\n buffer << value\n count += 1\n }\n end\n buffer\n end", "def create_congratulation_text_boxes\n @congrats_text_boxes = []\n $actors.each do |pkm|\n @congrats_text_boxes << Congratulation_Text_Box.new(@viewport, pkm)\n end\n end", "def rect(a, b, screen)\n screen[0...b].each do |row|\n row[0...a] = (\"#\"*a).split(\"\")\n end\n\n screen\nend", "def characters_in_split_arrays\n array_of_lines = recieve_and_read_file.split(\"\\n\")\n row_one = array_of_lines[0].scan(/../).to_a\n row_two = array_of_lines[1].scan(/../).to_a\n row_three = array_of_lines[2].scan(/../).to_a\n row_one.zip(row_two, row_three)\n end", "def render()\n # Display text \n puts \"Current Board: \"\n\n # array of blank strings, initialized before adding content\n render_rows = [\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\",\"\"]\n\n # Loop through to build the rows to render\n # Display number of rows corresponding to tower height\n # Display a column for each tower (split into rows for rendering)\n 0.upto(@no_of_discs) do |row|\n 1.upto(3) do |column|\n # Display a blank area for \"nil\" \"tower spots\"\n if @towers[column].tower_size <= row\n # Shovel a blank piece into the render row\n render_rows[row] << tower_piece(0,no_of_discs)\n else\n # Set piece size to the corresponding board value\n piece_size = @towers[column].tower[row].size\n # Shovel the corresponding piece into the render row\n render_rows[row] << tower_piece(piece_size,no_of_discs)\n end\n end\n end\n\n #Render in reverse order (top to bottom) so it appears correctly\n render_rows.reverse_each do |row|\n puts row\n end\n\n #Label line - Display a row with column labels on it under the towers\n puts \"[[[[[[[ 1 ]]]]]]][[[[[[[ 2 ]]]]]]][[[[[[[ 3 ]]]]]]]\"\n end", "def render\n parts.map(&:content)\n end", "def render\n puts \"-------------------------------------\"\n @grid.each do |row| \n puts \"| \" + row.map(&:to_s).join(\" | \") + \" |\"\n puts \"-------------------------------------\"\n end\n end", "def array\n \t(1..size).map{ |i| \"#{fill}\" }\n end", "def render(image)\n i = 0\n len = @drawingArray.length()\n begin\n @drawingArray[i].render(image)\n i += 1\n end while i < len\n end", "def render(text, emojis)\n emoji_index_cycle = (0...emojis.size).cycle\n\n char_maps = text.split('')\n .map { |char|\n downcase_char_map(char)\n # char_map(char)\n }.compact # get the map for each letter\n .map { |cm| cm.join(\"\\n\").gsub(/[^ \\n]/, emoji_index_cycle.next.to_s).split(\"\\n\") } # 'o' -> (0..N)\n\n asciiart = concat_letters_with_kerning(char_maps).join(\"\\n\")\n # puts asciiart\n\n emojis.each_with_index do |em, i|\n asciiart.gsub!(i.to_s, \":#{emojis[i]}:\")\n end\n\n asciiart.gsub(' ', ':transparent:')\nend", "def print_2d_array(a)\r\n\r\n max_word_length = 0 # keeps track of the longest string in layout\r\n flattened = a.flatten\r\n flattened.each{|x| if x.length > max_word_length\r\n max_word_length = x.length \r\n end}\r\n max_word_length += 1 # we want a space in front when printing\r\n \r\n # insert a row of numbers into layout for printing\r\n max_no_columns = 0\r\n a.each{|x| if x.length > max_no_columns\r\n max_no_columns = x.length\r\n end}\r\n counter_array = [*0...max_no_columns] # [0, 1, 2, 3....max_no_columns]\r\n \r\n # clone, insert numbers into array, then print\r\n temp = Marshal.load(Marshal.dump(a))\r\n temp.unshift(counter_array) # insert in front\r\n print_array(temp, max_word_length) \r\nend", "def create_sample_text\n Text.new(0, viewport, 0, 0, 0, 0, ' ')\n end", "def test_array\n # PdfColoredPages.stubs(:get_ghostscript_output).returns(MOCKED_GS_OUTPUT)\n assert_equal [1,3,4], PdfColoredPages.as_array(TEST_PDF)\n end", "def render\n system(\"clear\")\n puts \" #{(0...size).to_a.join(\" \")}\"\n @grid.each_with_index do |row, i|\n puts \"#{i} #{row.join(\" \")}\"\n end\n end", "def return_string_by_index(index_array)\n string_array = []\n index_array.each do |index|\n string_array.push(COLORS[index])\n end\n string_array\n end", "def render\n draw\n (@shape.size).times {|c| puts @shape[c]}\n end", "def render outputs\n\n # Work through each brick in the current brick orientation\n @bricks[@rotation].each do |brick|\n\n outputs.primitives << {\n x: @board_origin_x + ( ( @grid_col + brick[1] ) * 32 ),\n y: @board_origin_y + ( ( @grid_row + brick[0] ) * 32 ),\n w: 32,\n h: 32,\n path: \"sprites/brick_#{@type.to_s}.png\"\n }.sprite\n\n end\n\n end", "def show\n (lines[rows] || []).map { |line| (line.chars[columns] || []) }\n end", "def tablerow_array(objects)\n tablerow = []\n objects.each do |object|\n tablerow << RowData.new(object.row_cells)\n end\n tablerow\n end", "def createMatrix\n jsonArray = Array.new(@matrixRow)\n #Tenim un array vertical de n files, en cada casella es crea un altre\n #vector horitzontal amb tantes posicions com \"tags\" té aquest tipus de taula\n\t\tfor i in 0..@matrixRow-1\n\t\t\tjsonArrayColumns = Array.new(@matrixColumn)\n\t\t\tfor j in 0..@matrixColumn-1\n if i==0 #Quan es la primera fila s'afegeixen els tags a la matriu\n jsonArrayColumns[j] = @firstRow[j]\n else\n\t\t\t\t jsonArrayColumns[j] = @jsonObject[i-1][@firstRow[j]]\n end\n\t\t\tend\n\t\t\tjsonArray[i] = jsonArrayColumns\n\t\tend\n return jsonArray\n end", "def haiku(text)\n text_array = text.split(\" \")\n line_1 = make_line(text_array, 5)\n line_2 = make_line(text_array, 7)\n line_3 = make_line(text_array, 5)\n [line_1,line_2,line_3]\n end", "def repeat(text, n=2)\n\treturn Array.new(n, text).join(\" \")\nend", "def render(io)\n io.cmd :celld\n io.cmd :clbrdrt\n io.cmd :brdrs\n io.cmd :brdrw10\n io.cmd :clbrdrl\n io.cmd :brdrs\n io.cmd :brdrw10\n io.cmd :clbrdrb\n io.cmd :brdrs\n io.cmd :brdrw10\n io.cmd :clbrdrr\n io.cmd :brdrs\n io.cmd :brdrw10\n io.cmd v_merge if v_merge\n io.cmd :cellx, right_width\n contents = [@content] unless @content.is_a?(Array)\n contents.each do |c|\n if c.respond_to?(:render)\n c.render(io)\n else\n io.txt c\n end\n end\n io.cmd :cell\n end", "def init_texts\n texts = text_file_get(27)\n with_surface(114, 19, 95) do\n add_line(0, texts[3]) # Type\n add_line(1, texts[36]) # Category\n add_line(0, texts[37], dx: 1) # Power\n add_line(1, texts[39], dx: 1) # Accuracy\n end\n @move_info = SpriteStack.new(@viewport)\n @move_info.with_surface(114, 19, 95) do\n @move_info.add_line(0, :power_text, 2, type: SymText, color: 1, dx: 1)\n @move_info.add_line(1, :accuracy_text, 2, type: SymText, color: 1, dx: 1)\n @move_info.add_line(2, :description, type: SymMultilineText, color: 1).width = 195\n end\n @move_info.push(175, 21, nil, type: TypeSprite)\n @move_info.push(175, 21 + 16, nil, type: CategorySprite)\n end", "def rpsArr\n [\"✊\",\"✌️\",\"👋\"]\n end", "def rows(parts=@parts)\n \n @renderer.rows(parts)\n \n end", "def generate_controls(text)\n contents_text = \"\"\n loop do\n c = text.slice!(/./m)\n case c\n when nil\n break\n #--------------------------\n # DEFAULT FEATURES\n #-----------------------\n when \"\\x01\"\n text.sub!(/\\[([0-9]+)\\]/, \"\")\n @last_color = $1.to_i\n contents.font.color = text_color($1.to_i)\n \n #--------------------------\n # * NMS FEATURES!!\n #-----------------------\n when \"\\x83\"\n text.sub!(/\\[([0-9]+)\\]/, \"\")\n\n new_line if (@contents_x + 24 > contents.width)\n\n # Draw ICON\n ucIcon = UCIcon.new(self, Rect.new(@contents_x, @contents_y, 24, 24), $1.to_i)\n @cControlsList.push(ucIcon)\n @contents_x += 24\n when \"\\x84\"\n text.sub!(/\\[(.*?)\\]/, \"\")\n contents.font.name = $1.to_s\n when \"\\x85\"\n text.sub!(/\\[([0-9]+)\\]/, \"\")\n contents.font.size = $1.to_i\n when \"\\x86\"\n contents.font.name = Font.default_name \n when \"\\x87\"\n contents.font.size = Font.default_size\n when \"\\x88\"\n contents.font.bold = contents.font.bold == true ? false : true\n when \"\\x89\"\n contents.font.italic = contents.font.italic == true ? false : true\n when \"\\x93\"\n contents.font.shadow = contents.font.shadow == true ? false : true\n when \"\\x11\"\n text.sub!(/\\[(.*?)\\]/, \"\")\n a = $1.to_s.split(',')\n bitmap = Cache.picture(a[0])\n\n new_line if (@contents_x + bitmap.width > contents.width)\n \n # Size\n if !a[1].nil? && !a[1].empty?\n width = a[1].to_i\n else\n width = bitmap.width\n end\n if !a[2].nil? && !a[2].empty?\n height = a[2].to_i\n else\n height = bitmap.height\n end\n \n # Border\n if !a[3].nil? && !a[3].empty?\n border = a[3].to_i \n else\n border = 0\n end\n if !a[4].nil? && !a[4].empty?\n border_color = text_color(a[4].to_i)\n else\n border_color = nil\n end\n\n # Draw Image\n ucImageBorder = UCImageBorder.new(self, Rect.new(@contents_x, @contents_y, width, height),\n bitmap, Rect.new(0,0, width-border*2, height-border*2),\n 0, 255, 0, border, border_color)\n @cControlsList.push(ucImageBorder)\n \n @contents_x += width\n @biggest_text_height = height if height > @biggest_text_height\n #bitmap.dispose\n when \"\\x12\"\n text.sub!(/\\[([0-9]+)\\]/, \"\")\n\n new_line if (@contents_x + 96 > contents.width)\n\n # Draw Face\n actor = Game_Actor.new($1.to_i)\n ucCharFace = UCCharacterFace.new(self, Rect.new(@contents_x, @contents_y, 96, 96), actor)\n @cControlsList.push(ucCharFace)\n \n @biggest_text_height = 96 if 96 > @biggest_text_height\n else\n # Draw Text\n next_char = text.slice(/./m)\n contents_text += c\n if next_char == nil || next_char.match(/[\\x01-\\x12\\x80-\\xff]/) != nil\n text_height = contents.get_text_height(contents_text)\n if text_height < WLH\n text_height = WLH\n end\n @biggest_text_height = text_height if text_height > @biggest_text_height\n\n rect = Rect.new(@contents_x, @contents_y, contents.width, @biggest_text_height)\n cLabel = CLabel.new(self, rect, contents_text, 0, contents.font.clone, \n true, false, 3)\n @cControlsList.push(cLabel)\n \n lines = contents.split_multiline(rect, contents_text, 3)\n if lines.size > 1\n text_height = contents.get_text_height(contents_text)\n if text_height < WLH\n text_height = WLH\n end\n text_height = @biggest_text_height + text_height * (lines.size-2)\n @biggest_text_height = text_height if text_height > @biggest_text_height\n new_line\n end\n\n contents_text = \"\"\n @contents_x += contents.get_text_width(lines[lines.size-1])\n end\n \n end\n end\n\n end", "def build_canvas(lines_of_text_blocks)\n # Grab the greatest values for each line\n line_baseline = []\n line_height = []\n line_width = []\n lines_of_text_blocks.each_index do |i|\n baselines = (lines_of_text_blocks[i].sort { |a,b| a.baseline <=> b.baseline })\n heights = (lines_of_text_blocks[i].sort { |a,b| a.height <=> b.height })\n line_baseline << baselines.last.baseline\n line_height << heights.last.height - heights.last.line_spacing\n width = 0\n lines_of_text_blocks[i].each { |l| width += l.width }\n line_width << width\n end\n \n # set up canvas height and width\n @width = line_width.sort.last\n height = 0\n line_spacing_height = 0\n line_height.each { |h| height += h ; line_spacing_height += (h * (@options[:line_spacing] || 0)) }\n line_spacing_height -= (line_height.last * (@options[:line_spacing] || 0))\n @height = height + line_spacing_height\n \n options = nil\n if @options[:matte]\n options = @options.dup\n options[:bgcolor] = 'transparent'\n else\n options = @options\n end\n \n @canvas = IQ::Image::Canvas.new(@width, @height, options)\n \n # actually go through the lines and do stuff with them to make the canvas\n # for each line align each text block with the baseline\n top = 0\n lines_of_text_blocks.each_index do |i|\n left = 0\n lines_of_text_blocks[i].each do |text_block|\n offset = (line_baseline[i] - text_block.baseline)\n @canvas.overlay!(text_block.to_canvas, :dest_x => left, :dest_y => top + offset)\n left += text_block.width\n end\n top += line_height[i] + ((@options[:line_spacing] || 0) * line_height[i])\n end\n @canvas\n end", "def get_words_with_repeats\n rep_words =[]\n self.each do |x|\n chars = x.get_repeater_chars\n if chars != []\n rep_words << x\n end\n end\n return rep_words\n end", "def render\n\t\tputs `clear` #this clears the terminal to keep the playing space clean\n\t\tfor i in 0...@@board.length\n\t\t\tmapping_array = @@board[i].map { |e| renderHelper(e) }\n\t\t\tputs mapping_array.join('|')\n\t\tend\n\tend", "def render\n # need to return the following like this\n # 1) font_size as font-size \n # 2) dot_size as dot-size\n # 3) outline_colour as outline-colour\n # 4) halo_size as halo-size\n # 5) start_angle as start-angle\n # 6) tick_height as tick-height\n # 7) grid_colour as grid-colour\n # 8) threed as 3d\n # 9) tick_length as tick-length\n # 10) visible_steps as visible-steps\n # 11) key_on_click as key-on-click\n returning self.to_json2 do |output|\n output.gsub!(\"threed\",\"3d\")\n %w(font_size dot_size outline_colour halo_size start_angle tick_height grid_colour tick_length no_labels label_colour gradient_fill fill_alpha on_click spoke_labels visible_steps key_on_click).each do |replace|\n output.gsub!(replace, replace.gsub(\"_\", \"-\"))\n end\n end\n end", "def create_work_matrix(array)\n array[1..-2].each_with_object([]) do |line, arr|\n line.gsub!(/\\s/, '0')\n arr << line[1..-2].chars\n end.to_a\n end", "def outputArray(word)\n Array.new(word.length, \"_\")\nend", "def generate_matrix\n [].tap { |a| 25.times { a << 'X' } }.each_slice(5).to_a\n end", "def get_world_array\n world_array = Array.new(@total_length){ [] }\n\n @all_strawberries.each do |strawberry|\n world_array[Matrix.two_to_one(strawberry.get_x_location, strawberry.get_y_location, @x_size)].push(strawberry)\n end\n @all_mushrooms.each do |mushroom|\n world_array[Matrix.two_to_one(mushroom.get_x_location, mushroom.get_y_location, @x_size)].push(mushroom)\n end\n @all_persons.each do |person|\n world_array[Matrix.two_to_one(person.get_x_location, person.get_y_location, @x_size)].push(person)\n end\n @all_monsters.each do |monster|\n world_array[Matrix.two_to_one(monster.get_x_location, monster.get_y_location, @x_size)].push(monster)\n end\n world_array\n end", "def splitText text\n res = Array.new(text.count(\"\\n\") + 1) {LockString.new}\n i = 0\n text.each_char do |c|\n if c == \"\\n\"\n i += 1\n else\n res[i] << c\n end\n end\n puts res.inspect\n res\n end", "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 header_init(width)\r\n display_arr = Array.new(width)\r\n count = width -1\r\n display_arr.each_with_index do\r\n |x, y|\r\n display_arr[y] = count\r\n count = count - 1\r\n end\r\n return display_arr\r\nend", "def proptextarray(name) #:nodoc:\n @properties.select{ |f| f.name? name }.map{ |p| p.to_text }\n end", "def render\n bari, tenor, alto, soprano = '', '', '', ''\n instrument_strings = [bari, tenor, alto, soprano]\n @notes.each_with_index {|note, index| \n duration_string = '1'\n duration_string = '2' if index == deltas_max_index\n instrument_string = instrument_strings[index]\n note_string = midi_to_lily(note) + duration_string\n instrument_string << note_string\n instrument_string << ' r2' if index == deltas_max_index\n }\n instrument_strings\n end", "def render pad, lineno, text\n @renderer.render pad, lineno, text\n end", "def frame(text, char)\n\n longest_word_length = (text.map { |w| w.length }.max)\n frame_width = longest_word_length + 4\n\n frame_top_bottom = char*(frame_width)\n frame_arr = []\n\n #top of frame\n frame_arr.push(\"#{frame_top_bottom}\\n\")\n\n #middle of frame (content and the sides of the frame)\n text.each do |word|\n diff = longest_word_length - word.length\n spaces = ' '*diff\n frame_arr.push(\"#{char} #{word} #{spaces}#{char}\\n\")\n end\n\n #bottom of frame\n frame_arr.push(\"#{frame_top_bottom}\")\n frame_arr.join\nend", "def color_matrix(txt = \"[X]\")\n size = String.colors.length\n String.colors.each do |color|\n String.colors.each do |back|\n print txt.colorize(color: color, background: back)\n end\n puts \" < #{color}\"\n end\n String.colors.reverse.each_with_index do |back, index|\n puts \"#{\"|\".rjust(txt.length) * (size - index)} < #{back}\"\n end\n \"\"\n end", "def text_blocks\n pdf.each_object\n .select {|o| o.instance_of? Origami::ContentStream}\n .flat_map(&:instructions)\n .select {|i| i.operator == \"Tj\"}\n .map(&:operands)\n .map { |operands| operands.join(\" \") }\n end", "def build_search_results_array(doc)\n names = return_names_array(doc)\n descrs = return_descriptions_array(doc)\n durs = return_durations_array(doc)\n diffs = return_difficulties_array(doc)\n links = return_links_array(doc)\n\n search_results = []\n\n names.each_with_index do |_name, i|\n search_results << { name: names[i], descr: descrs[i], dur: durs[i], diff: diffs[i], link: links[i] }\n end\n\n return search_results\n end", "def initiate_nested_array(n)\n nested_array = []\n n.times do\n nested_array << (' ' * n).split('')\n end\n\n nested_array\nend", "def render\n\t\tprint \"cl1 cl2 cl3 cl4 cl5 cl6 cl7 cl8 cl9 c10\\n\"\n\t\t(0..9).each do |row|\n\t\t\t(0..9).each do |col|\n\t\t\t\tif @grid[row][col].is_flagged\n\t\t\t\t\tprint \"FLG\"\n\t\t\t\telsif @grid[row][col].is_hidden\n\t\t\t\t\tprint \" \"\n\t\t\t\telsif @grid[row][col].surrounding_bombs > 0\n\t\t\t\t\tprint \" #{@grid[row][col].surrounding_bombs} \"\n\t\t\t\telsif @grid[row][col].has_bomb\n\t\t\t\t\tprint \"POW\"\t\t\t\t\t\n\t\t\t\telse print \"xxx\"\n\t\t\t\tend\n\t\t\t\tprint \"|\" unless col == 9\n\t\t\t\tprint \"row#{row + 1}\\n\" if col == 9\n\t\t\tend\n\t\tend\n\tend", "def color_matrix( txt = \"[X]\" )\n size = String.colors.length\n String.colors.each do | color |\n String.colors.each do | back |\n print txt.colorize( :color => color, :background => back )\n end\n puts \" < #{color}\"\n end\n String.colors.reverse.each_with_index do | back, index |\n puts \"#{\"|\".rjust(txt.length)*(size-index)} < #{back}\"\n end\n \"\"\n end", "def render\n @board.height.times do |x|\n @board.width.times do |y|\n cell = @board.read_cell(x, y)\n print @piece_renderer.render(cell)\n end\n puts\n end\n end" ]
[ "0.645829", "0.5959358", "0.5882848", "0.58606184", "0.5860072", "0.5827875", "0.5827059", "0.57310015", "0.57167274", "0.56647253", "0.5659097", "0.55576104", "0.55306387", "0.55274045", "0.5516862", "0.55161095", "0.550755", "0.55003744", "0.54650366", "0.5388109", "0.538138", "0.53792065", "0.5377506", "0.53349966", "0.53341913", "0.52698666", "0.52628523", "0.5243447", "0.5241158", "0.52038246", "0.52038246", "0.51867014", "0.51858187", "0.5166333", "0.51602733", "0.51313496", "0.5105539", "0.50982124", "0.5090198", "0.50896597", "0.50846654", "0.5082668", "0.5080604", "0.5064608", "0.5059023", "0.50505227", "0.5040401", "0.503398", "0.5026554", "0.5021579", "0.5007265", "0.50019276", "0.49923563", "0.49883115", "0.4985661", "0.49802768", "0.49801645", "0.49560314", "0.49455407", "0.49449185", "0.4936216", "0.49313563", "0.4888549", "0.48865318", "0.48830417", "0.48717505", "0.48627177", "0.48582885", "0.48511922", "0.48454553", "0.48423302", "0.48413616", "0.48413387", "0.4826527", "0.48227906", "0.48160127", "0.48032165", "0.4795001", "0.47948545", "0.47924128", "0.47913185", "0.47882837", "0.47787482", "0.47746554", "0.4758069", "0.475748", "0.47531715", "0.47412303", "0.47412032", "0.47407293", "0.47369498", "0.47361866", "0.47346562", "0.47258556", "0.47221896", "0.47209445", "0.47197735", "0.47169286", "0.4716018", "0.47135186", "0.47129792" ]
0.0
-1
Write a function sum_to(n) that uses recursion to calculate the sum from 1 to n (inclusive of n).
def sum_to(n) if n == 1 return 1 elsif n < 1 return nil end n + sum_to(n - 1) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def sum_to(n)\n return nil if n < 0\n return 0 if n == 0\n \n n += sum_to(n-1)\n end", "def sum_to(n)\n return nil if n <= 0 #negatives and 0\n return 1 if n == 1 #base step\n #inclusive step 1 + sum_to(n)\n n + sum_to(n - 1)\nend", "def sum_to(n)\n return n if n == 1\n n + sum_to(n-1)\nend", "def sum_to(n)\n return nil if n<0\n return 1 if n==1\n sum_to(n-1) + n\nend", "def sum_to(n)\n\n if n < 1\n return nil\n elsif n == 1\n return 1\n end\n\n n + sum_to(n - 1)\nend", "def sum_to(n)\n n > 1 ? n + sum_to(n - 1) : n < 1 ? [].first : 1\n end", "def sum_to(n)\n return nil if n < 1\n return 1 if n == 1\n sum_to(n - 1) + n\nend", "def sum_to(n)\n return nil if n < 0\n return 0 if n == 0\n n + sum_to(n-1)\nend", "def sum_to(n)\n return 1 if n == 1\n return nil if n<1\n n + sum_to(n-1)\nend", "def sum_to(n)\n return n if n == 1 || n == 0\n return nil if n < 0\n n + sum_to(n - 1)\nend", "def sum_to(n)\n return nil if n < 1\n return n if n == 1\n n + sum_to(n - 1)\nend", "def sum_to(n)\n return nil if n < 1\n return 1 if n == 1\n\n n + sum_to(n - 1) \nend", "def sum_to(n)\n return 1 if n == 1\n return nil if n <= 0\n n + sum_to(n-1)\nend", "def sum_to(n)\n return nil if n < 0\n return n if n == 1\n\n n + sum_to(n - 1)\nend", "def sum_to(n)\n return 1 if n == 1\n return nil if n < 1\n n += sum_to(n - 1)\nend", "def sum_to(n)\n return nil if n < 1\n return n if n == 1\n \n n + sum_to(n - 1)\nend", "def sum_to(n)\n return nil if n < 0\n return n if n == 0\n n += sum_to(n - 1)\nend", "def sum_to(n)\n return n if n == 0\n return nil if n < 0\n n + sum_to(n - 1)\nend", "def sum_to(n)\n # if n < 2\n # 1\n # else\n # n + sum_to(n-1)\n # end\n return 1 if n < 2\n n + sum_to(n - 1)\nend", "def sum_to(n)\n return nil if n < 0\n return n if n <= 1\n n + sum_to(n - 1) #if n > 0\nend", "def sum_to(min=1, n)\n if n > 0\n return min if min == n \n min + sum_to(min + 1, n)\n end\nend", "def sum_to(n)\n (1..n).reduce(0) do |sum, value|\n sum + value\n end\nend", "def sum(n)\n return 1 if n == 1\n\n n + sum(n - 1)\nend", "def sum_to(to)\n\treturn nil if to < 0\n\n\treturn 1 if to == 1\n\n\treturn to + sum_to(to - 1)\nend", "def sum_to_n(n)\n # Your Code Here!\nend", "def sum(n)\n end", "def rec_sum(n)\n if n == 0\n return 0\n else\n return n + rec_sum(n-1)\n end\nend", "def sum_integers_up_to(n)\n sum = 0\n for i in 1..n\n sum += i\n end\n sum\nend", "def sum_integers_up_to(n)\n (n * ( n + 1 ) ) / 2\nend", "def sum_recursive(num)\n # can also compute sum with symbol (1..5).inject(:+)\n (1..num).inject { |sum, n| sum + n }\nend", "def sum_to(num)\n if num == 0\n return num\n elsif num < -1\n return nil\n end\n num + sum_to(num - 1)\nend", "def sum(n)\n result = 0\n n.each do |number|\n result = result + number\n end\n return result\n end", "def summation(n)\n #iterate through numbers less than or equal to n and add them up\n sum = 0\n\n (1..n).each { |num| sum += num }\n return sum\nend", "def sum_of_n(n)\n # your code here\n # result = []\n # if n >= 0\n # ary = (0..n).to_a\n # else\n # ary = (n..0).to_a.reverse\n # end\n # ary.each_with_index do |_numb, index|\n # somme = 0\n # result << somme += ary[0..index].sum + somme\n # end\n # result\n sum = 0\n (n.negative? ? 0.downto(n) : 0.upto(n)).map do |number|\n sum += number\n end\nend", "def sum(n=16) end", "def square_sum_up_to n=100\r\n (n * (n + 1) / 2)**2\r\nend", "def summation(n)\n sum = 0\n (1..n).each { |num| sum += num }\n return sum\nend", "def tail_sum(n, total = 0)\n return total if n == 0\n\n tail_sum(n - 1, total + n)\nend", "def summation(n)\n sum = 0\n (1..n).each { |num| sum += num }\n return sum\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n - 1) + fibs_sum(n - 2) + 1\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2) + 1\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2) + 1\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2) + 1\nend", "def fibs_sum(n)\n return 0 if n == 0\n return 1 if n == 1\n\n fibs_sum(n-1) + fibs_sum(n-2) + 1\nend", "def sum(n, m)\n if n > m\n return 0\n else\n return sum(n+1, m) + n\n end\nend", "def compute_sum(number)\n (1..number).inject(:+)\nend", "def compute_sum(number)\n (1..number).reduce(:+)\nend", "def sum_recursively(num)\n return num if num == 0\n sum_recursively(num-1) + num\nend", "def sum_multiples(multiple, to)\n n = (to-1) / multiple\n n * (n+1) / 2 * multiple\nend", "def sum_range(num)\n if num == 1\n 1\n else\n num + sum_range(num - 1)\n end\nend", "def fibs_sum(n)\n return 1 if n == 1 || n == 2\n sum = 0\n sum += (fibs_sum(n - 1) + fibs_sum(n - 2))\n \n \nend", "def fib_sum(n)\n return n if ( 0..1 ).include? n\n ( fib_sum( n - 1 ) + fib_sum( n - 2 ) )\nend", "def sum_func(n)\n if n / 10 == 0\n return n\n else\n return n % 10 + sum_func(n/10)\n end\nend", "def fibs_sum(n) # my version\n return 1 if n == 1\n return 2 if n == 2\n\n current = single_fib(n)\n current += fibs_sum(n - 1)\nend", "def f(n)\n return n if n.zero? || n == 1\n f(n - 1) + f(n - 2)\nend", "def sum_digits(n)\n return n if n <= 9\n n % 10 + sum_digits(n / 10)\nend", "def sum_to(number)\n sum = 0\n i = 1\n while i <= number\n sum += i\n i += 1\n end\n return sum\nend", "def sum_of_n(n)\n key = 0\n answer = (0..n.abs).to_a.map { |num| key += num }\n n < 0 ? (answer.map { |n| n * (-1) }) : answer\nend", "def rec_sum(num)\n return num if num <= 1\n num + rec_sum(num - 1)\nend", "def compute_sum(number)\n total = 0\n 1.upto(number) { |value| total += value }\n total\nend", "def sumn(n)\n result = 0\n 1.upto(n) { |e| result += e }\n puts \"Sum of #{n} numbers is #{result}\"\nend", "def sum_rec(numbers)\n # base case\n return 0 if numbers.empty?\n # inductive step\n numbers[0] + sum_rec(numbers[1..-1])\nend", "def summation(num)\n sum = (0..num).inject(:+)\n return sum\nend", "def summation(num)\n (1..num).reduce(:+)\nend", "def sum(n)\n s = BigDecimal.new(\"1\")\n sig = 1\n\n 1.upto(n) do |i|\n sig *= -1\n s += (1.0 / (2*i + 1)) * sig\n end\n\n 4 * s\nend", "def compute_sum(int)\n sum = 0\n int.downto(1) {|n| sum += n}\n sum\nend", "def sum_to(num)\n i = 0\n sum = 0\n while i < num\n i += 1\n sum += i\n end\n return sum\nend", "def fib_sum(n)\n #generate up to n recursive\n fib = [0, 1]\n i = 2\n while i < n\n fib << fib[i - 2] + fib[i - 1]\n i += 1\n end\n p fib\n # sum = 0\n accumulator = fib.first\n while !fib.empty?\n accumulator += fib.pop\n end\n #iterate and sum through the stack\n return accumulator\nend", "def sum_to(num)\n sum = 0\n i = 0\n while i <= num\n sum += i\n i += 1\n end\n return sum\nend", "def sum(number)\n total = 0\n 1.upto(number) {|v| total += v }\n total\nend", "def sum_of_products_of n, sum_up_to=999\r\n p = sum_up_to / n\r\n n * (p *(p + 1)) / 2\r\nend", "def sum_to(number)\n i = 0\n output = 0\n while i < number\n i +=1\n output += i\n end\n return output\nend", "def sum_to(number)\n i = number\n output = number\n while i > 0\n output += number-1\n number-=1\n i-=1\n end\n return output\nend", "def compute_sum(n)\n i = 1\n num = 0\n\n loop do\n num += i\n i += 1\n break if i > n\n end\n num\nend", "def sum_to(int)\n if !int.is_a?(Integer) || int < 0\n return nil\n else \n sum = 0\n for i in 0..int\n sum += i\n end\n end\n return sum\nend", "def sum_multiples(multiple, upto)\n n = (upto-1) / multiple\n n * (n+1) / 2 * multiple\nend", "def sum_of_all_integers(num)\n (0..num).sum\nend", "def sum(number)\n a = (1..number).to_a\n puts a.inject(:+)\nend", "def square_of_sum(n)\n sum = 0\n (1..n).each {|i| sum = sum + i}\n sum * sum\n end", "def sum(n)\n n.digits.sum\nend", "def sum_recurse(num)\n return 0 if num == 0\n num[0] + sum_recurse(num.delete(1))\nend", "def fibonacci_recursive n\n return n if n < 2\n fibonacci_recursive(n-1) + fibonacci_recursive(n-2)\nend", "def GetSum(num, sum)\n if num == 0\n return sum\n else\n return GetSum((num - 1), (sum + num))\n end\nend", "def sum_to(num)\n i = num\n output = 0\n while i > 0\n output += i\n i -= 1\n end\n return output\nend", "def first_even_numbers_sum(n)\n return 2 if n == 1\n 2 * n + first_even_numbers_sum(n-1)\nend", "def get(n=0)\n sum = 0\n (0...n).each do |i|\n sum += i\n end\n return sum\n end", "def sum_nums(num)\n (1..num).inject(&:+)\nend", "def first_even_numbers_sum(n)\n return 2 if n == 1\n 2 * n + first_even_numbers_sum(n-1)\n end", "def compute_sum(int)\n sum = 0\n 1.upto(int) { |i| sum += i }\n sum\nend", "def sequence_sum(begin_number, end_number, step)\n return 0 if begin_number > end_number\n sum = 0\n until begin_number > end_number\n \tsum += step\n end\nend", "def sum(num)\n num.zero? ? num : num + sum(num - 1)\nend", "def super_digit(n, sum=0) \n return sum + n if n / 10 == 0\n return super_digit(super_digit(n/10, sum+(n%10)))\nend", "def compute_sums(n)\n return compute1_sum if n == 1\n pivot_index = n/2-1\n target_value = total_value/3\n num_souvenirs = souvenirs.size\n\n indexes = []\n skip = false\n while indexes = next_indexes(indexes, n, skip)\n skip = false\n val = nil\n sum(*indexes) do |arr, i|\n val = sum(*indexes[0..pivot_index]) + sum(*indexes[pivot_index+1..-1])\n arr[i] = val\n print \"indexes: #{indexes}, val=#{val}, sum(#{indexes[0..pivot_index].inspect})=#{sum(*indexes[0..pivot_index])}, sum(#{indexes[pivot_index+1..-1]})=#{sum(*indexes[pivot_index+1..-1])}\"\n print \"good indexes found=#{indexes}, pivot=#{pivot_index}\" if val == target_value\n @good_sums << i+1 if val == target_value\n skip = val > target_value\n end\n end\n end", "def fibsum(n)\n\tsum = 0\n\tfib = [1,2]\n\ttest = fib[-1]\n\twhile test <= n:\n\t\tsum += test if test % 2 == 0\n\t\tfib << test + fib[-2]\n\t\tfib.shift\n\t\ttest = fib[-1]\n\tend\n\tp sum\nend", "def sum_numbers(arr, n)\n sum = 0\n index = 0\n\n arr.each do |i|\n if index != n \n sum += i\n else\n return sum\n end\n\n index += 1\n end\nend", "def fibonacciRecursive(n)\n\tif n <= 1\n\t\treturn n\n\telse\n\t\treturn fibonacciRecursive(n - 1) + fibonacciRecursive(n - 2)\n\tend\nend", "def sum_to(num)\n if num<0\n return \"number is negative, wont work!\"\n end\n\n i=0\n sum = 0\n while i <= num\n sum += i\n i += 1\n end\n return sum\nend", "def factorial_recursive(n)\n\tif (n==0)\n\t\treturn 1\n\telse\n\t\t\treturn n*factorial_recursive(n-1)\n\tend\nend", "def factorial_recursive n\n return 1 if n == 0\n n * factorial_recursive(n-1)\nend", "def sumdig_r(n)\n return n if n < 10\n (n%10) + sumdig_r(n/10)\nend" ]
[ "0.8673652", "0.86240727", "0.86119795", "0.8595396", "0.8589504", "0.8567511", "0.85596436", "0.8507498", "0.8500545", "0.84943825", "0.84879327", "0.8453495", "0.84448504", "0.8416314", "0.8341449", "0.8336774", "0.8321511", "0.82756466", "0.82407045", "0.82068515", "0.81902844", "0.80702174", "0.7780393", "0.77719384", "0.7728699", "0.7619338", "0.7547985", "0.7533648", "0.75234205", "0.7459839", "0.7306436", "0.7227603", "0.71655107", "0.7161792", "0.7157396", "0.7097803", "0.70930785", "0.7076542", "0.70550805", "0.70024425", "0.69888574", "0.69888574", "0.69888574", "0.69888574", "0.6985284", "0.6971866", "0.69535786", "0.6944378", "0.69303495", "0.69117767", "0.6895021", "0.686825", "0.68676925", "0.6852347", "0.6778443", "0.6756382", "0.6749883", "0.673848", "0.6727255", "0.6725632", "0.67149454", "0.669162", "0.6683351", "0.6674993", "0.66652256", "0.6619515", "0.661922", "0.6603836", "0.6581024", "0.65715533", "0.65340585", "0.6519069", "0.6488519", "0.6483095", "0.64819616", "0.64734954", "0.6472861", "0.6447427", "0.64437217", "0.64338946", "0.64249474", "0.6419482", "0.6412004", "0.64004695", "0.63974994", "0.63959664", "0.6387925", "0.6383085", "0.6378564", "0.63739085", "0.63722605", "0.6369691", "0.6363738", "0.63607156", "0.63526225", "0.6350611", "0.6345063", "0.6335295", "0.6328858", "0.63286215" ]
0.83986896
14
=> returns nil Exercise 2 add_numbers Write a function add_numbers(nums_array) that takes in an array of Fixnums and returns the sum of those numbers. Write this method recursively.
def add_numbers(nums_array) if nums_array.length == 1 return nums_array.last elsif nums_array.empty? return nil end nums_array.pop + add_numbers(nums_array) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_numbers(nums_array)\n return nums_array.first if nums_array.length == 1 #=> base case if the array is length 1 then just return the first element\n return nil if nums_array.length < 1 #=> return nil if the array length is less than 1\n \n nums_array.pop + add_numbers(nums_array) #=> inductive/recursive case taking the sum of the array and #pop the the last ele each time\nend", "def add_numbers(num_array)\n return num_array[0] if num_array.length <= 1\n sum = num_array[0]\n sum += add_numbers(num_array[1..-1])\nend", "def add_numbers(nums_array)\n if nums_array.empty? \n 0\n else \n n = nums_array.pop\n return n + add_numbers(nums_array)\n end \nend", "def add_numbers(nums_array)\n return nil if nums_array.empty?\n return nums_array.pop if nums_array.length == 1\n return nums_array.pop + add_numbers(nums_array)\nend", "def add_numbers(nums_array)\n return nums_array[0] if nums_array.size ==1\n return nil if nums_array.empty?\n\n nums_array[0] + add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array)\n return nums_array[0] if nums_array.length <= 1\n nums_array[0] +add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array)\n return nil if nums_array.empty?\n return nums_array[0] if nums_array.length == 1\n nums_array[0] + add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array)\n return 0 if nums_array.length == 0\n\n first = nums_array.shift\n\n first + add_numbers(nums_array)\nend", "def add_numbers(nums_array)\n return nil if nums_array.empty?\n return nums_array.pop if nums_array.length == 1\n return nums_array.pop + add_numbers(nums_array)\nend", "def add_numbers(nums_array)\n return nums_array[0] if nums_array.length <= 1\n n = nums_array[0] + add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array = nil)\r\n return nil if nums_array.nil?\r\n return nums_array[0] if nums_array.length == 1\r\n nums_array[0] + add_numbers(nums_array[1..-1])\r\n end", "def add_numbers(nums_array)\n return nil if nums_array.length == 0\n\n return nums_array.first if nums_array.length == 1\n\n nums_array.first + add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array)\n return nil if nums_array.empty?\n first_elem = nums_array.first\n return first_elem if nums_array.length == 1\n first_elem + add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array)\n return nil if nums_array.empty?\n return nums_array.pop if nums_array.length == 1\n\n nums_array.pop + add_numbers(nums_array)\nend", "def RecursiveSum(arrayofNumbers) \n \n # Base Case: If the array is empty, return 0. \n \n if arrayofNumbers? \n return 0\n \n # Recursive code: Adding each element to the variable by calling the method. \n \n else\n Sum = arrayofNumbers.pop \n return Sum + RecursiveSum(arrayofNumbers) \n end\nend", "def add_numbers(nums_array)\n return nil if nums_array.length < 1\n return nums_array.first if nums_array.length == 1\n nums_array[0] + add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array)\n return nums_array[0] if nums_array.length < 2\n nums_array[0] + add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array)\n return nums_array[0] if nums_array.length < 2\n nums_array[0] + add_numbers(nums_array[1..-1])\nend", "def add_numbers(nums_array)\n\treturn nil if nums_array.length == 0\n\n\treturn nums_array.first if nums_array.length == 1\n\n\treturn nums_array.shift + add_numbers(nums_array)\nend", "def add_numbers(num_array = nil)\n return nil if num_array.nil?\n return num_array[0] if num_array.length == 1\n num_array[0] + add_numbers(num_array[1..-1])\nend", "def add_numbers(nums_array)\n return nil if nums_array.empty?\n return nums_array[0] if nums_array.length == 1\n add_numbers(nums_array[1..-1]) + nums_array[0]\nend", "def add_numbers(nums_array)\n return nums_array[0] if nums_array.length <= 1\n nums_array.pop + add_numbers(nums_array)\nend", "def add_numbers(nums_array)\n return nums_array.first if nums_array.length <= 1\n\n nums_array.pop + add_numbers(nums_array)\nend", "def add_numbers(nums_array)\n # Base Case: Is the array empty?\n return nums_array[0] if nums_array.length <= 1\n nums_array.shift + add_numbers(nums_array)\nend", "def add_numbers(nums_array)\n return nums_array.first if nums_array.length == 1 || nums_array.empty?\n nums_array.last + add_numbers(nums_array[0...-1])\n end", "def add_numbers(nums_array)\n return nums_array.first if nums_array.length <= 1\n nums_array.shift + add_numbers(nums_array)\nend", "def add_numbers(nums_array)\n return nums_array.first if nums_array.length <= 1\n last = nums_array.pop\n last + add_numbers(nums_array)\nend", "def add_numbers(arr)\n return arr[0] if arr.length <= 1\n arr[0] + add_numbers(arr[1..-1])\nend", "def add_numbers(arr)\n if arr == []\n return nil\n elsif arr[0] == arr[-1]\n return arr[0]\n end\n arr[-1] + add_numbers(arr[0...-1])\nend", "def add_nums(arr)\n return nil if arr.length == 0\n return arr[0] if arr.length == 1\n arr[0] + add_nums(arr[1..-1])\nend", "def add_numbers(arr)\n return arr[0] if arr.length == 1\n return nil if arr.length == 0\n tot = arr.pop + add_numbers(arr)\nend", "def add_numbers(arr)\n return nil if arr.length < 1\n return arr[0] if arr.length == 1\n arr[0] += add_numbers(arr[1..-1])\n end", "def rec_sum(nums)\n\nend", "def rec_sum(nums)\n\nend", "def add_numbers(arr_of_ints)\n return arr_of_ints[0] if arr_of_ints.length <= 1\n arr_of_ints[0] + add_numbers(arr_of_ints[1..-1])\nend", "def add_numbers(nums_array)\n #if array has >1 element, then take first element and then ...\n return nums_array.first if nums_array.length <= 1\n nums_array.first + add_numbers(nums_array[1..-1])\nend", "def sum(nums)\n return 0 if nums.empty?\n nums[0] + sum_rec(nums[1..-1])\nend", "def add_numbers(num_array)\n num_array.count > 1 ? num_array.first + add_numbers(num_array.drop(1)) : num_array.first\n end", "def add_numbers(arr)\n return arr.first if arr.length <= 1\n\n arr.pop + add_numbers(arr)\nend", "def sum_numbers(numbers)\r\n # Your code here\r\n #initalize the sum\r\n sum = 0\r\n #iterate through every element of a given array\r\n numbers.each do |number|\r\n #add the previous sum and next number in the array\r\n sum += number\r\n end\r\n \r\n return sum\r\nend", "def recursive_sum(nums)\n return 0 if nums.empty?\n\n return nums.pop + recursive_sum(nums)\nend", "def add_nums_iterative(arr)\n return nil if arr.length == 0\n total = 0\n arr.each do |num|\n total += num\n end\n total\nend", "def add_numbers(array)\n#add first in array to next in array. replace next in array\n#until array.length < 1\n return array[0] if array.length <= 1\n num1, num2 = array.pop, array.pop\n sum = num1.to_i + num2.to_i\n array.unshift(sum)\n add_numbers(array)\nend", "def sum_rec(nums)\n return 0 if nums.empty?\n nums[0] + sum_rec(nums[1..-1])\nend", "def add_numbers(nums_array)\n nums_array.inject { |sum, el| sum + el }\nend", "def sum_rec(numbers)\n return 0 if numbers.empty?\n num = numbers.pop\n num + sum_rec(numbers)\nend", "def sum_rec(numbers)\n # base case\n return 0 if numbers.empty?\n # inductive step\n numbers[0] + sum_rec(numbers[1..-1])\nend", "def add_numbers(arr)\n return nil if arr.empty?\n return arr[0] if arr.length == 1\n arr.shift + add_numbers(arr)\nend", "def sum_nums(num)\n\t\n\tnumbers = []\n\tnum_sum = num\n\t\nuntil numbers.length == num_sum\n\tnumbers.push(num)\n\tnum = num - 1\nend\n return\tnumbers.inject(:+)\nend", "def recursive_sum(array)\n return array[0] if array.length == 1\n\n array[0] + recursive_sum(array[1..-1])\nend", "def sum_rec(num_array)\n return 0 if num_array.empty?\n\n num[0] + sum_rec(num_array.drop(1))\nend", "def add_all_numbers(array)\n array.inject(:+)\nend", "def sum_recur(array)\n#for array = []\n return 0 if array == []\n\n first_el = array.shift\n recursive_call = sum_recur(array)\n first_el + recursive_call\n\nend", "def sum_recur(array)\n #base case\n return 0 if array.empty?\n #iterative step\n array.first + sum_recur(array[1..-1])\nend", "def sum_numbers(numbers) # new method that takes 1 parameter\r\n array_total = 0 #beginning the sum at clean 0\r\n if numbers == [] # when provided an empty array default return is 0\r\n return nil #changed return value to nil\r\n else\r\n for number in numbers #iterating through array\r\n array_total += number #then adding that number to the total\r\n end\r\n return array_total\r\n end\r\nrescue Exception => e\r\n puts e.class, \"Invalid Input\"\r\nend", "def recursive_sum(array)\n if array.length == 0\n return 0\n end\n recursive_sum(array[1..-1]) + array.first\nend", "def add_numbers(n)\n return nil if n.length == 0\n return n[0] if n.length == 1\n adder = n.pop\n adder + add_numbers(n)\n\nend", "def sum_rec(nums)\n return 0 if nums.length == 0\n sum_rec(nums[0...-1]) + nums[-1]\nend", "def sum_recurse(num)\n return 0 if num == 0\n num[0] + sum_recurse(num.delete(1))\nend", "def sum_recur(array)\n return 0 if array.empty?\n array.pop + sum_recur(array)\nend", "def sum(array) \n if array == []\n 0\n else\n array[0] + sum(array[1..-1])\n end\nend", "def sum_recur(array)\n return 0 if array.empty?\n \n array[0] + sum_recur(array[1..-1])\nend", "def sum_rec(nums)\nreturn nums[0] if nums.size == 1\nreturn 0 if nums.size == 0\n nums[0] + sum_rec(nums[1..-1])\nend", "def rec_sum(nums)\n return 0 if nums.empty?\n \n nums[0] + rec_sum(nums.drop(1))\nend", "def sum_recur(array)\n return 0 if array.length <= 0\n array[0] + sum_recur(array[1..-1])\nend", "def sum_recursion(arr)\n return 0 if arr.empty?\n sum = arr.shift\n sum += sum_of_array(arr)\n # 2 + sum_of_array([3])\n #3 + sum_of_array([])\n\n\nend", "def sum_array(numbers)\n return numbers.sum()\nend", "def sum_nums(num)\n (1..num).inject(&:+)\nend", "def sum_rec(nums)\n return 0 if nums.empty?\n nums[0] + sum_rec(nums.drop(1))\nend", "def sum_numbers(numbers)\r\n # Your code here\r\n sum = 0\r\n # If numbers is not an array will return true and ask for a user for\r\n # valid input\r\n if !numbers.is_a?(Array)\r\n # Needs to be assigned to sum to still print and return nil\r\n # as would be expected of puts, otherwise return sum will evaluate\r\n # to 0 instead, which wouldn't allow distinction from an sum of\r\n # numbers that was equal to zero, and an invalid input\r\n sum = puts \"Please give me a set of numbers.\"\r\n else numbers.each do |num|\r\n sum += num\r\n end\r\n puts \"The sum of #{numbers} is #{sum}\"\r\n end\r\n return sum\r\nend", "def sum(nums)\n\treturn 0 if nums == []\n\tnums.reduce(:+)\nend", "def sum_array_rec(array_to_sum)\n if(array_to_sum.length > 0)\n sum = array_to_sum[0]\n sum += sum_array_rec(array_to_sum[1..-1])\n else\n 0\n end\nend", "def sum_array( numbers )\r\n numbers.inject(0, :+)\r\nend", "def sum_array(array_num)\n\nend", "def sum(array)\n return 0 if array.empty?\n array.first + sum(array[1..-1])\nend", "def sum(nums)\n nums.reduce(&:+)\nend", "def sum_recur(array)\n return array.first if array.length == 1\n array[0] + sum_recur(array[1..-1])\nend", "def total(array_of_numbers)\n sum = 0\n array_of_numbers.each do |num|\n sum += num\n end\n return sum\nend", "def sum_recur(array)\n return 0 if array.empty?\n array.first + sum_recur(array.drop(1))\nend", "def sum(numbers)\n numbers.reduce(&:+)\n end", "def sum(nums)\n total = 0\n nums.each do |n|\n total+= n\n end\n return total\nend", "def sum_recur(array)\n return 0 if array.empty?\n array.first + sum_recur(array.drop(1))\nend", "def sum_recur(array)\n sum = 0\n if array.empty?\n 0\n else\n sum = array.first\n sum += sum_recur(array.drop(1))\n sum\n end\nend", "def sum_array_recur(array)\n return nil if array.empty?\n return array[0] if array.length == 1\n\n array[0] + sum_array_recur(array[1..-1])\nend", "def sum(array)\n sum = 0\n\n array.each { |number|\n sum += number\n }\n\n return sum\nend", "def sum_recursive(num)\n # can also compute sum with symbol (1..5).inject(:+)\n (1..num).inject { |sum, n| sum + n }\nend", "def sum_only_numbers(an_array)\n if an_array.length == 0\n \treturn 0\n end\n if an_array[0].is_a?(Numeric)\n \tan_array[0] + sum_only_numbers(an_array.drop(1))\n else\n \tsum_only_numbers(an_array.drop(1))\n end\n\nend", "def sum arr\n return 0 if arr.empty?\n arr.inject(:+)\nend", "def sum_array(array)\n sum = 0\n array.each do |number|\n sum += number\n end\n sum\nend", "def sum_of_array(array)\n if array.empty?\n return 0\n else\n item = array.shift\n if item.is_a?(String)\n puts item = num_value(item)\n end\n \n item = item + sum_of_array(array)\n end\nend", "def sum_array(array)\n sum = 0\n array.each do |num|\n sum = sum + num\n end\n sum\nend", "def rec_sum(num)\n return num if num <= 1\n num + rec_sum(num - 1)\nend", "def sum_recur(array)\n return 0 if array.empty?\n dup = array.dup\n return dup[0] if dup.length == 1\n sum = dup.pop + sum_recur(dup)\n\nend", "def sum_numbers3(list)\n return 0 if list.empty?\n\n list[0] + sum_numbers3(list[1..-1])\nend", "def total(array_of_numbers)\n return array_of_numbers.reduce(:+)\nend", "def sum_array(numbers)\n total = 0\n for number in numbers\n total = total + number\n end\n return total\nend", "def sum(array)\n return 0 if array.empty?\n array.inject(:+)\nend", "def sum1(array)\r\n sum = 0\r\n array.each do |number|\r\n sum += number\r\n end\r\n sum\r\nend", "def total(nums)\n nums.inject(:+)\nend", "def arr_sum(array)\n sum = 0 # Declares initial value for variable 'sum' as 0\n array.each do |i| # Begin iterating each item of arr\n sum += i # add each number in array to the next item, continue until items exhausted\n end\n return sum # Returns new sum value\nend" ]
[ "0.8449055", "0.8392316", "0.83362216", "0.8239925", "0.8232353", "0.82213223", "0.82135147", "0.81997126", "0.81960714", "0.818539", "0.81810707", "0.8166863", "0.81329715", "0.812441", "0.81220436", "0.8096984", "0.8064034", "0.8064034", "0.80628866", "0.8047653", "0.8032085", "0.8020136", "0.80041915", "0.79917145", "0.7966944", "0.7961135", "0.7912331", "0.781462", "0.7809672", "0.77836204", "0.77511126", "0.77224994", "0.77044004", "0.77044004", "0.7685516", "0.7649482", "0.76443297", "0.7626987", "0.75975394", "0.75701237", "0.75667", "0.7562103", "0.75581867", "0.75571424", "0.75565886", "0.75525826", "0.75509274", "0.75184715", "0.74270695", "0.73938733", "0.73915005", "0.7387245", "0.7384548", "0.735115", "0.7344237", "0.73408926", "0.73008347", "0.7299481", "0.7298078", "0.72766525", "0.7268147", "0.72548777", "0.7253235", "0.72327614", "0.7221269", "0.72092116", "0.7202871", "0.7198791", "0.71654785", "0.71582633", "0.71407634", "0.712374", "0.70772463", "0.70721114", "0.70600575", "0.705952", "0.7056687", "0.7054109", "0.7050974", "0.7039673", "0.70367426", "0.70365006", "0.7028928", "0.7025232", "0.70242995", "0.69972783", "0.69905347", "0.6979962", "0.69738024", "0.6972509", "0.6969674", "0.69667894", "0.69666445", "0.69645554", "0.6962248", "0.696208", "0.6961677", "0.69603807", "0.69463617", "0.6939847" ]
0.8054679
19
=> returns 5040 Exercise 4 Ice Cream Shop Write a function ice_cream_shop(flavors, favorite) that takes in an array of ice cream flavors available at the ice cream shop, as well as the user's favorite ice cream flavor. Recursively find out whether or not the shop offers their favorite flavor.
def ice_cream_shop(flavors, favorite) if flavors.empty? return false end return true if favorite == flavors.pop ice_cream_shop(flavors, favorite) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ice_cream_shop(flavors, favorite)\n # Base step\n return false if flavors.empty?\n return true if flavors[0] == favorite\n # Recursive Step\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors == []\n return true if flavors[0] == favorite\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite) \n offers = flavors[0] == favorite \n return offers if offers == true\n return offers if flavors.length <= 1\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return true if favorite == flavors[0]\n return false if flavors.length <= 1\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors,favorite)\n return true if flavors[0] == favorite\n return false if flavors.length < 1\n ice_cream_shop(flavors[1..-1],favorite)\nend", "def ice_cream_shop(flavors,favorite)\r\n return false if flavors.length == 0\r\n return true if flavors[0] == favorite\r\n ice_cream_shop(flavors[1..-1],favorite)\r\nend", "def ice_cream_shop(flavors, favorite)\n return true if flavors[0] == favorite\n return false if flavors.length < 1\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors.empty?\n return true if flavors[0] == favorite\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return true if flavors[0] == favorite\n return false if flavors.length <= 1\n\n ice_cream_shop(flavors[1..-1],favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors.length == 0\n\n flavors[0] == favorite ? true : ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors.length == 0 #=> returns false if flavors arrray is empty\n last_flavor = flavors.pop #=> #pop the last flavor from the array \n return true if last_flavor == favorite #=> checking if the last flavor equals the favorite flavor is so return true\n # above is base case\n\n ice_cream_shop(flavors, favorite) #=> recusive case check the flavors array again with one less flavor now that since #pop was called\nend", "def ice_cream_shop(flavors, favorite)\n return true if flavors[-1] == favorite\n return false if flavors.empty?\n\n ice_cream_shop(flavors[0...-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors.empty?\n return true if flavors.first == favorite\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return true if flavors.first == favorite\n return false if flavors.empty?\n\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors.length.zero?\n\n return flavors.first == favorite if flavors.length == 1\n\n flavors.first == favorite || ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors.empty?\n return true if flavors.pop == favorite\n ice_cream_shop(flavors[0...-1],favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return true if flavors.last == favorite\n return false if flavors.length == 1 || flavors.empty?\n ice_cream_shop(flavors[0...-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return favorite == flavors[0] if flavors.length <= 1\n flavors[0] == favorite || ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n checker = flavors.pop\n return true if checker == favorite\n return false if flavors.length == 0\n ice_cream_shop(flavors, favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors.empty?\n return true if flavors.pop == favorite\n return ice_cream_shop(flavors, favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return true if flavors.first == favorite\n ice_cream_shop(flavors[1..-1],favorite) until flavors.first == nil\nend", "def ice_cream_shop(flavors, favorite)\n return true if flavors.pop == favorite\n return false if flavors.length == 1 || flavors.empty?\n ice_cream_shop(flavors, favorite)\nend", "def ice_cream_shop(flavor, favorite)\n return false if flavor.empty?\n return flavor[0] == favorite if flavor.length == 1\n return flavor[0] == favorite || ice_cream_shop(flavor[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors.empty?\n # favorite == flavors[0] if flavors.length == 1 #错的\n return true if favorite == flavors[0]\n ice_cream_shop(flavors[1..-1], favorite)\nend", "def ice_cream_shop(flavors, favorite)\n\treturn false if flavors.empty?\n\n\treturn true if flavors.first == favorite\n\n\t_, *remaining = flavors\n\n\treturn ice_cream_shop(remaining, favorite)\nend", "def ice_cream_shop(arr, favorite)\n\n return false if arr.length == 0 \n\n if favorite == arr.pop \n return true\n else\n ice_cream_shop(arr, favorite)\n end\nend", "def ice_cream_shop(flavors, favorite)\n return false if flavors.empty?\n if flavors[0] == favorite && flavors.length == 1\n return true\n else\n pick_one_flavors = flavors.sample\n flavors.delete(pick_one_flavors) unless pick_one_flavors == favorite\n ice_cream_shop(flavors, favorite)\n end\nend", "def ice_cream_shop(flavors, favorite)\n flavors.select{|word| word == favorite }.empty? == false \nend", "def ice_cream_shop(flavors, favorite)\n flavors.empty? ? false : flavors.first == favorite ? true : ice_cream_shop(flavors.drop(1), favorite)\n end", "def ice_cream_shop(arr,flav)\n return true if arr[-1] == flav\n return false if arr.length == 0\n arr.pop\n ice_cream_shop(arr,flav)\nend", "def is_fav_food(person, test_food)\n fav_snacks = person[:favourites][:snacks]\n for snack in fav_snacks\n if snack == test_food\n return true\n end\n end\n return false\nend", "def describe_favorites(games)\n for game in games\n puts \"Favorite Game: #{game}\"\n end\nend", "def food_tastes(person, food)\n return person[:favourites][:things_to_eat].include?(food)\nend", "def likes_to_eat(person, food)\n\n for x in person[:favourites][:snacks]\n if x == food\n return true\n end\n end\n return false\nend", "def every_favourite_food(people)\n #Create a empty array to save all the strings\n all_food = \"\"\n #For loop to iterate person in the array people\n for person in people\n #For loop to iterate in snacks in person\n for snacks in person[:favourites][:snacks]\n #adds new items to the array\n p snacks\n all_food += snacks += \" \"\n end\n end\n all_food.chop!\n return all_food\nend", "def favourite_foods(person, food)\n return person[:favourites][:things_to_eat].include?(food)\nend", "def favorite_beverage_list(name, favorite_beverage)\n puts \"#{name}'s favorite beverage is #{favorite_beverage}!\"\nend", "def likes_to_eat(person, food)\nreturn person[:favourites][:snacks].include?(food)\nend", "def bakery_num( num_of_people, fav_food ) # defines a method called bakery_num that takes two parameters, num_of_peope, fav_food\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} # Hash of avaialble foods and associated counts\n \n pie_qty = 0\n cake_qty = 0 # quantity of the foods equals to 0 \n cookie_qty = 0\n \n has_fave = false # Initializes our has_fave tood to false\n\n my_list.each_key do |key| # iterating over my_list keys to do a comparison \n if key == fav_food # Favorite food comparison\n has_fave = true # confirms fav_food is in the list \n end\n # has_fave = true if key == fav_food\n end\n \n if has_fave == false # my_list does not contain fav_food \n raise ArgumentError.new(\"You can't make that food\") # Raise error if fav_food was not found\n else # Fav_food was in the list\n fav_food_qty = my_list[fav_food] #.values_at(fav_food)[0] # if in the list, return the quantity on hand *** refactor\n if num_of_people % fav_food_qty == 0 # Checks if num_of_people is evenly divisable by the fav_food_qty\n num_of_food = num_of_people / fav_food_qty # returns num_of_food eq to number of people / fav foods \n return \"You need to make #{num_of_food} #{fav_food}(s).\" # Return favorite food along with quantity\n else #num_of_people % fav_food_qty != 0 # num_of_people was not evenly divisable by fav_food_qty\n while num_of_people > 0 # while num_of_people is greater than zero \n if num_of_people / my_list[\"pie\"] > 0 # At least more people than the quantity of pie will feed \n pie_qty = num_of_people / my_list[\"pie\"] # quantity of pie is equal the number of people divided by my_list of pie \n num_of_people = num_of_people % my_list[\"pie\"] # number of people ramaining after distributing pies\n elsif num_of_people / my_list[\"cake\"] > 0 # At least more people than the quantity of cake \n cake_qty = num_of_people / my_list[\"cake\"] # quantity of cake is equal to the number of people divided by qty of people cake will feed\n num_of_people = num_of_people % my_list[\"cake\"] # number of people remaining after distributing cakes \n else # num_of_people is less than both qty that pie and cake will feed\n cookie_qty = num_of_people # cookie quantity is equal to the number of people \n num_of_people = 0 # Set num_of_people to 0 in order to end the loop\n end # Ending if-else conditions\n end\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\n end\n end\nend", "def likes_to_eat(person, food)\n food_array = person[:favourites][:snacks]\nreturn food_array.include?food\nend", "def describe_favorites(*games)\n for game in games\n puts \"Favorite Game: #{game}\"\n end\nend", "def find_the_cheese(snacks)\n cheeses = %w(gouda cheddar camembert)\n snacks.find do |maybe_cheese|\n cheeses.include?(maybe_cheese)\n end\nend", "def grill_cheese(bread, cheese, cheese_num, melt)\n # If cheese_num is greater than 3 cheese slices you want it extra cheesy.\n if cheese_num > 3\n # Patty melt instead of grilled cheese sando.\n if melt == true\n puts \"We got one extra cheesy #{cheese} patty melt on #{bread}, coming right up!\"\n else\n puts \"We got one extra cheesy #{cheese} grilled cheese on #{bread}, coming right up!\"\n end\n # For less cheesey sandwich\n else\n # Patty melt instead of grilled cheese sando.\n if melt == true\n puts \"We got one cheesy #{cheese} patty melt on #{bread}, coming right up!\"\n else\n puts \"We got one cheesy #{cheese} grilled cheese on #{bread}, coming right up!\"\n end\n end\nend", "def find_the_cheese(food)# code an argument here\n # the array below is here to help\n # check if elements in food are included in cheese_types\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n food.find do |i|\n if !cheese_types.include?(i)\n nil\n else\n true\n end\n end\nend", "def bakery_num( num_of_people, fav_food ) # defines a method called bakery_num that takes two parameters, num_of_peope, fav_food\n serving_sizes = { \"pie\" => 8, \"cake\" => 6, \"cookie\" => 1 } # Hash of available foods and associated counts\n food_quantities = { \"fav_food\" => 0, \"pie\" => 0, \"cake\" => 0, \"cookie\" => 0 } # Hash of food quantities\n\n # Raise error if serving sizes doesn't contain food\n raise ArgumentError.new(\"You can't make that food\") if !serving_sizes.has_key? (fav_food)\n\n # Returns the necessary number of food items needed to satisfy each serving if the \n # number of people attending is evenly divisible by the quantity of the passed favorite food.\n return \"You need to make #{num_of_people / serving_sizes[fav_food]} #{fav_food}(s).\" if num_of_people % serving_sizes[fav_food] == 0\n\n # Loop through each key in food_quantities to determine how many of each food item is needed.\n food_quantities.each do |key, value|\n if key == \"fav_food\" \n food_quantities[key] = num_of_people / serving_sizes[fav_food] # Setting \"fav_food\" property for future use in food_quantities\n food_quantities[fav_food] = food_quantities[key]\n num_of_people = num_of_people % serving_sizes[fav_food] # Setting remaining amount of people left after fav_food is determined.\n elsif num_of_people / serving_sizes[key] > 0 # key is not fav_food and number of remaining people divided by the next food item serving size is greater than zero\n food_quantities[key] = num_of_people / serving_sizes[key] # Setting count for additional food items needed for remaining people\n num_of_people = num_of_people % serving_sizes[key] # Setting number of remaining people after the additional food item\n end # Ending conditional\n end # Ending .each loop\n\n return \"You need to make #{food_quantities[\"pie\"]} pie(s), #{food_quantities[\"cake\"]} cake(s), and #{food_quantities[\"cookie\"]} cookie(s).\"\nend", "def check_fav\n print \"Are they a favorite? (y/n): \"\n user_fav = gets.strip\n if user_fav == \"y\"\n return true\n elsif user_fav == \"n\"\n return false \n else\n puts \"not vaild input\"\n check_fav\n end\nend", "def favorite_brewery\n favorite :brewery\n end", "def any_apples?\n # code to check if tree has any oranges goes here\n @apples.length > 0\n end", "def favorite_brewery\n favorite :brewery\n end", "def bakery_num(num_of_people, fav_food) #defining method bakery_num, which takes 2 arguments\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1, \"pudding\" => 2, \"bunt cake\" => 4, \"mega-cupcakes\" => 3} #creates hash my_list, key is food, value is number\n pie_qty = cake_qty = cookie_qty = has_fave = 0 \n \n\n my_list.each_key do |k| #iterating through array my_list\n if k == fav_food #tests if each item in array my_list = fav_food\n has_fave = 1 #if test above passes, set has_fave to true\n # fav_food = k #if test above passes, set fav_food to k\n end\n end\n \n if has_fave == 0 #if fav_food is not a key, end program\n raise ArgumentError.new(\"You can't make that food\")\n else #if fav_food is a key\n fav_food_qty = my_list.values_at(fav_food)[0] #set fav_food_qty equal to the value of fav_food\n if num_of_people % fav_food_qty == 0 \n num_of_food = num_of_people / fav_food_qty #if num_of_people is evenly divisible by fav_food_qty\n return \"You need to make #{num_of_food} #{fav_food}(s).\"\n \n #num_of_food = num_of_people / fav_food_qty #then perform division by integer\n #return \"You need to make #{num_of_food} #{fav_food}(s).\" #return \"You need to make (num_of_food) (fav_food)s\"\n else num_of_people % fav_food_qty != 0 #redundant else\n while num_of_people > 0 #while num_of_people is greater than 0\n if num_of_people / my_list[\"pie\"] > 0 #if num_of_people divided by value of pie is greater than 0\n pie_qty = num_of_people / my_list[\"pie\"] #set pie_qty equal to num_of_people divided by value of pie in hash\n num_of_people = num_of_people % my_list[\"pie\"] #set num_of_people equal to the remainder of num_of_people divided by value of pie in hash\n elsif num_of_people / my_list[\"cake\"] > 0 #if num_of_people divided by hash value of cake is greater than 0\n cake_qty = num_of_people / my_list[\"cake\"] #set cake_qty equal to num_of_people divided by hash value of cake\n num_of_people = num_of_people % my_list[\"cake\"] #set num_of_people equal to the remainder of num_of_people divided by value of cake in hash\n else\n cookie_qty = num_of_people #set cookie_qty equal to num_of_people\n num_of_people = 0 #set num_of_people equal to 0\n end\n end\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\" #print out\n end\n end\n \nend", "def find_the_cheese(ingredients)\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n ingredients.detect {|item| cheese_types.include?(item)}\n #ingredients.find {|item| cheese_types.include?(item)}\n #ingredients.each {|item| return item if cheese_types.include?(item)}\n #else\n #return nil\nend", "def ice_cream_shop(arr, str)\n return false if arr.empty?\n if arr[0] != str \n ice_cream_shop(arr[1..-1], str)\n else \n true\n end \n end", "def true_for_food(hash, item)\n food= hash[:favourites][:things_to_eat]\n\n for i in hash\n if i == food\n\n return \"Yes I like this food\"\n end\n end\n return \"No I don't like this\"\n end", "def like_food?(food, person)\n person[:favourites][:things_to_eat].include?(food)\nend", "def find_the_cheese(foods) # code an argument here\n # the array below is here to help\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n\n cheese_types.find do |cheese|\n foods.include?(cheese)\n end\n\nend", "def bakery_num(num_of_people, fav_food) #Defining a function that takes two parameters\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} #Declaring a my_list hash\n pie_qty = 0 # Assigning three other variables \n cake_qty = 0\n cookie_qty = 0\n \n has_fave = false #setting a default value of false \n\n my_list.each_key do |k| #looping through the keys of my_list\n if k == fav_food #An if statement, where the condition is comapred to one of the parameters\n has_fave = true #If true, declaring a has_fave to true \n fav_food = k #Assigning fav_food to that key\n end\n end\n if has_fave == false #If no matec ==> error\n raise ArgumentError.new(\"You can't make that food\")\n else\n fav_food_qty = my_list.values_at(fav_food)[0] #If match ==> find value from Hash \n if num_of_people % fav_food_qty == 0 #Module of the first function parameter, number of people by fav food quantity\n num_of_food = num_of_people / fav_food_qty #If true, get portions \n return \"You need to make #{num_of_food} #{fav_food}(s).\" #return an order \n else num_of_people % fav_food_qty != 0 #redundant but if not \n while num_of_people > 0 \n if num_of_people / my_list[\"pie\"] > 0 #if there are more people than pies\n pie_qty = num_of_people / my_list[\"pie\"] #This gets portions\n num_of_people = num_of_people % my_list[\"pie\"] #this gets amount of people for leftovers \n elsif num_of_people / my_list[\"cake\"] > 0 #If the number of people is not rgeater than pies, we go into cakes\n cake_qty = num_of_people / my_list[\"cake\"]\n num_of_people = num_of_people % my_list[\"cake\"]\n else\n cookie_qty = num_of_people\n num_of_people = 0\n end\n end\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\n end\n end\nend", "def favorite_recipes\n favorites.each do |f|\n f.recipe\n end\n end", "def should_eat(food, season)\n if food == \"hot chocolate\" && season == \"summer\"\n return \"False\"\n elsif food == \"ice cream\" && season == \"winter\"\n return \"False\"\n else return \"true\"\n end\nend", "def person_cheers_song(pl, favourite_song)\n \n for tune in pl\n if tune == favourite_song\n return \"yaaay!\"\n else \n return \"didn't find my favourite\" \n end \n end \n end", "def fruit([])\n\nend", "def super_fizzbuzz(array)\n\n\nend", "def find_the_cheese(food)\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n food.find do |item|\n cheese_types.find do |cheese|\n item == cheese\n end\n end\nend", "def fizzbuzz(n)\n if n == 100\n false\n else\n if n % 3 == 0 && n % 5 == 0\n puts \"FizzBuzz\"\n elsif n % 3 == 0\n puts \"Fizz\"\n elsif n % 5 == 0\n puts \"Buzz\"\n else\n puts n\n end\n fizzbuzz(n += 1)\n end\nend", "def find_the_cheese(foods)\n foods.find{ |cheese| cheese == \"cheddar\" || cheese == \"gouda\" || cheese ==\n \"camembert\"}\nend", "def favorite\n puts FAVE\n end", "def favourite_food name\r\n\tif name == \"Lister\"\r\n\t\treturn \"vindaloo\"\r\n\tend\r\n\r\n\tif name == \"Rimmer\"\r\n\t\treturn \"mashed potatoes\"\r\n\tend\r\n\r\n\t\"hard to say...maybe fired plantain?\"\r\nend", "def find_the_cheese(potentially_cheesy_items)\n cheeses = %w(gouda cheddar camembert)\n\n potentially_cheesy_items.find do |maybe_cheese|\n cheeses.include?(maybe_cheese)\n end\nend", "def bake_cake servings\n\t#in the beginning the oven is off, and the bowl is empty\n\toven_on = false\n\tbowl = \"\"\n\t#Step 1: turn on the oven\n\n\tputs \"Is the oven on? \" + oven_on.to_s\n\n\t#Step 2: add flour, add eggs, add sugar\n\n\tputs \"The bowl currently has: \" + bowl #should have all ingredients listed with the right quantities!\n\t\nend", "def bottles(n, total = n)\n\n puts english_number(n).capitalize + \" bottles of beer on the wall, \" +\n english_number(n) + \" bottles of beer.\"\n puts \"Take one down and pass it around, \" + english_number(n-1) +\n \" bottle#{n-1==1 ? '' : 's'} of beer on the wall.\"\n puts\n\n # recursion\n if n > 2\n bottles(n-1, total)\n else\n puts \"1 bottle of beer on the wall. 1 bottle of beer.\"\n puts \"Take one down and pass it around, no more bottles of beer on the wall.\"\n puts\n puts \"No more bottles of beer on the wall. No more bottles of beer.\"\n puts \"Go to the store and buy some more, \" + english_number(total) +\n \" bottles of beer on the wall.\"\n puts\n end\nend", "def dominant(fish)\n \nend", "def select_by_flavors \n\n selections = @@prompt.multi_select(\"Select flavors. Returns a list of all dishes that include those flavors.\", Flavor.active_flavor_names, cycle: true)\n # if dish's flavors - selections == 0, then that dish should be included! \n # iterate through all the dishes \n dishes_to_return = []\n # push that dish to dishes_to_return if that dish's flavors match our selections array \n Dish.all.select{ |dish| \n dish_flavor_array = dish.flavors.map{|flavor|flavor.name} \n if selections - dish_flavor_array == [] && selections != []\n dishes_to_return << dish \n # binding.pry\n end \n if selections == []\n system 'clear'\n puts \"Please select at least one flavor\"\n select_by_flavors\n end\n }\n # print each dish that matches \n if dishes_to_return.length == 0 \n puts \"There are no dishes matching those flavors\"\n if @@prompt.yes?(\"Would you like to search again?\")\n system 'clear'\n select_by_flavors\n else\n main_menu\n end \n else \n puts \"These dishes match those flavors: \"\n dishes_to_return.map{|dish| dish.print_dish}\n if @@prompt.yes?(\"Would you like to search again?\")\n system 'clear'\n select_by_flavors\n else\n main_menu\n end\n end \n end", "def bakery_num(num_of_people, fav_food) #defines the method and accepts arguments num_of_people and fav_food\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} \n pie_qty = 0 #declaring variables at 0\n cake_qty = 0 #declaring variables at 0\n cookie_qty = 0 #declaring variables at 0\n \n has_fave = false\n\n my_list.each_key do |k| #iterates through the keys in my_list\n if k == fav_food #checks if passed argument fav_food is in the hash as a key\n has_fave = true #sets boolean has_fave to true\n fav_food = k #re-assigns fav_food to the key in the hash\n end\n end\n \n if has_fave == false #if fav_food is not found in the list\n raise ArgumentError.new(\"You can't make that food\") #raise an error\n else\n fav_food_qty = my_list.values_at(fav_food)[0] #declares a variable that is the quantity of fav food argument and sets it equal to first element in the value\n \n if num_of_people % fav_food_qty == 0 #if number of people is divisable by quantity of fav food\n num_of_food = num_of_people / fav_food_qty #number of food is set to number of people divided by fav food quantity\n return \"You need to make #{num_of_food} #{fav_food}(s).\" #returns string concatenated declaring how much of the food to make\n \n else num_of_people % fav_food_qty != 0 #if num of people is not divisable by fav food qty\n while num_of_people > 0 \n if num_of_people / my_list[\"pie\"] > 0 #if number of people divided by number of pies floor is greater than 0 \n pie_qty = num_of_people / my_list[\"pie\"] #sets pie quantity to multiples of number of servings\n num_of_people = num_of_people % my_list[\"pie\"] #num of people reassigned to remainder \n elsif num_of_people / my_list[\"cake\"] > 0 #if number of people divided by number of cakes floor is greater than 0\n cake_qty = num_of_people / my_list[\"cake\"] #sets cake quantity to multiples of number of servings\n num_of_people = num_of_people % my_list[\"cake\"] #num of people reassigned to remainder \n else\n cookie_qty = num_of_people #sets cookie qty to number of people remaining\n num_of_people = 0 #ends the loop if \"cookie else\" is reached\n end\n end\n \n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\" #returns the string, whole combination\n end\n end\nend", "def super_fizzbuzz(array)\n fizzy=[]\n\tarray.each do |x| \n\t if x%3==0 && x%5==0\n\t\t fizzy << \"FizzBuzz\"\n\t elsif x%5==0\n\t\t fizzy << \"Buzz\"\n\t elsif x%3==0\n\t\t fizzy << \"Fizz\"\n\t else\n\t\t fizzy << x\n\t end\n\tend\nreturn fizzy\nend", "def search_array(favorite_nums,num)\n # loop containing a conditional statement\n iteration = 0\n while iteration < favorite_nums.length\n if num == favorite_nums[iteration]\n return iteration\n end\n iteration += 1\n end\nend", "def say_fav_food(food)\n puts \"One of your favorite foods is #{food}\"\n menu_favorite_foods\nend", "def super_fizzbuzz(array)\n buzz_array = []\n array.each do |x|\n if x % 3 == 0 && x % 5 != 0\n buzz_array.push(\"Fizz\")\n elsif x % 3 != 0 && x % 5 == 0\n buzz_array.push(\"Buzz\")\n elsif x % 3 == 0 && x % 5 == 0\n buzz_array.push(\"FizzBuzz\")\n else\n buzz_array.push(x)\n end\n end\n p buzz_array\nend", "def find_the_cheese(food)\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n food.find do |item|\n cheese_types.include?(item)\n end\n end", "def bakery_num(num_of_people, fav_food) #defining a method bakery_number. Takes number of people and favorite food as parameters \n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} #hash- my_list that has type of food as a key and amount of food as a value\n pie_qty = 0 # set default quantity to zero \n cake_qty = 0 # set default quantity to zero \n cookie_qty = 0 # set default quantity to zero \n \n ##has_fave = false # setting has_fave to false ##\n\n #my_list.each_key do |k| # we are iterating over my_list key values \n #if k == fav_food # if one of the keys matches fav_food, then...\n #has_fave = true # has_fave is set to true \n ##fav_food = k ##not necessary \n #closed out if statement \n if my_list.has_key?(fav_food) \n fav_food_qty = my_list.values_at(fav_food)[0] \n if num_of_people % fav_food_qty == 0 \n num_of_food = num_of_people / fav_food_qty \n return \"You need to make #{num_of_food} #{fav_food}(s).\" \n else \n case fav_food\n when \"pie\"\n if num_of_people / my_list[\"pie\"] > 0 \n pie_qty = num_of_people / my_list[\"pie\"] \n num_of_people = num_of_people % my_list[\"pie\"] \n elsif num_of_people / my_list[\"cake\"] > 0 \n cake_qty = num_of_people / my_list[\"cake\"] \n num_of_people = num_of_people % my_list[\"cake\"]\n else\n cookie_qty = num_of_people\n num_of_people = 0\n when \"cake\"\n if num_of_people / my_list[\"cake\"] > 0 \n cake_qty = num_of_people / my_list[\"cake\"] \n num_of_people = num_of_people % my_list[\"cake\"]\n else\n cookie_qty = num_of_people\n num_of_people = 0\n when \"cookie\"\n cookie_qty = num_of_people\n num_of_people = 0\n else\n \"You need to pick pie, cake, or cookie\"\n end \n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\n end \n end \n else \n raise ArgumentError.new(\"You can't make that food\") # raise argument using a string \n end", "def bakery_num(num_of_people, fav_food) # this is defining bakery_num and takes 2 inputs\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} # creates hash, keys are baked goods, values are how many you can feed\n pie_qty = 0 # sets pie_qty to zero\n cake_qty = 0\n cookie_qty = 0\n \n has_fav = false # rename?\n\n my_list.each_key do |k| # iterates through each key in my_list\n if k == fav_food # if they key matches fav_food input\n has_fav = true # change has_fav to true\n end\n end\n \n if has_fav == false # If food isn't in stock/ isn't found\n raise ArgumentError.new(\"You can't make that food\")\n \n else\n fav_food_qty = my_list.values_at(fav_food)[0] # quantity of people favorite food can feed\n \n if num_of_people % fav_food_qty == 0 # if num_of_people can be divided evenly by fav_food_qty\n num_of_food = num_of_people / fav_food_qty\n return \"You need to make #{num_of_food} #{fav_food}(s).\"\n \n else\n num_of_fav_food = num_of_people / fav_food_qty\n num_of_people = num_of_people % fav_food_qty\n \n while num_of_people > 0\n cake_qty = num_of_people / my_list[\"cake\"]\n if num_of_people % my_list[\"cake\"] > 0\n cookie_qty = num_of_people\n num_of_people = 0\n end \n end\n \n if fav_food == \"pie\"\n pie_qty = num_of_fav_food\n elsif fav_food == \"cake\"\n cake_qty = num_of_fav_food\n else\n cookie_qty = num_of_fav_food\n end\n\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\n \n \n end \n end\nend", "def find_the_cheese(array)\n cheeses = %w[gouda cheddar camembert]\n\n array.find do |cheese_flavor|\n cheeses.include?(cheese_flavor)\n end\nend", "def ask_for_winner(flavors)\n if flavors.length > 2\n puts \"0. \"+flavors[0]\n puts \"1. \"+flavors[1]\n puts \"2. \"+flavors[2]\n puts \"3. \"+flavors[3]\n puts \"4. \"+flavors[4]\n while true\n answer = gets.chomp.downcase\n if (answer == \"0\" || answer == \"1\" || answer == \"2\" || answer == \"3\" || answer == \"4\")\n return flavors[answer.to_i]\n else\n puts \"Please answer '0' - '4'.\"\n end\n end\n else\n puts \"0. \"+flavors[0]\n puts \"1. \"+flavors[1]\n while true\n answer = gets.chomp.downcase\n if (answer == \"0\" || answer == \"1\")\n return flavors[answer.to_i]\n else\n puts \"Please answer '0' or '2'.\"\n end\n end\n end\nend", "def find_the_cheese(array)\n # the array below is here to help\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n if array.include?(\"cheddar\")\n return \"cheddar\"\n elsif array.include?(\"gouda\")\n return \"gouda\"\n elsif array.include?(\"camambert\")\n end\nend", "def bakery_num(num_of_people, fav_food)\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1}\n food_array = []\n has_fave = false\n\n my_list.each_key do |k|\n if k == fav_food\n has_fave = true\n end\n end\n raise ArgumentError.new(\"You can't make that food\") if has_fave == false\n fav_food_qty = my_list[fav_food]\n if num_of_people % fav_food_qty == 0\n num_of_food = num_of_people / fav_food_qty\n return \"You need to make #{num_of_food} #{fav_food}(s).\"\n else num_of_people % fav_food_qty != 0\n while num_of_people > 0\n my_list.each do |k, v|\n food_qty = num_of_people / v\n num_of_people = num_of_people % v\n food_array << food_qty\n end\n end\n return \"You need to make #{food_array[0]} pie(s), #{food_array[1]} cake(s), and #{food_array[2]} cookie(s).\"\n end\nend", "def baskets_full(apple_count)\n puts \"All baskets are full. We couldn't find the place for #{apple_count} apples\"\nend", "def bakery_num(num_of_people, fav_food)\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1}\n pie_qty = 0\n cake_qty = 0\n cookie_qty = 0\n \n has_fave = false\n\n my_list.each_key do |k|\n if k == fav_food\n has_fave = true\n fav_food = k\n end\n end\n if has_fave == false\n raise ArgumentError.new(\"You can't make that food\")\n else\n fav_food_qty = my_list.values_at(fav_food)[0]\n if num_of_people % fav_food_qty == 0\n num_of_food = num_of_people / fav_food_qty\n return \"You need to make #{num_of_food} #{fav_food}(s).\"\n else num_of_people % fav_food_qty != 0\n while num_of_people > 0\n if num_of_people / my_list[\"pie\"] > 0\n pie_qty = num_of_people / my_list[\"pie\"]\n num_of_people = num_of_people % my_list[\"pie\"]\n elsif num_of_people / my_list[\"cake\"] > 0\n cake_qty = num_of_people / my_list[\"cake\"]\n num_of_people = num_of_people % my_list[\"cake\"]\n else\n cookie_qty = num_of_people\n num_of_people = 0\n end\n end\n return \"You need to make #{pie_qty} pie(s), #{cake_qty} cake(s), and #{cookie_qty} cookie(s).\"\n end\n end\nend", "def find_people_around_football_pitch_around_jindigeling\n find_shops\nend", "def is_favorite?\n\t favorite?\n\tend", "def search_by_meat\n choice_of_meat = display_choices('What meat would you like?',($default_recipe.recipe_name_and_meats.values.uniq << 'Previous Page'))\n return level_2_option_1 if choice_of_meat == 'Previous Page'\n choices = $default_recipe.recipe_name_and_meats.filter{|k,v|v == choice_of_meat}.keys << 'Previous Page'\n recipe_choice = display_choices(\"List of Dish that can be made from #{choice_of_meat} meat : \",choices)\n return search_by_meat if recipe_choice == 'Previous Page'\n display_ing_and_method(recipe_choice)\nend", "def fizzbuzz (i)\n if i % 3 == 0 && i % 5 == 0\n return \"FizzBuzz\"\nend\n if i % 3 == 0 \n return \"Fizz\"\nend\n if i % 5 == 0 \n return \"Buzz\"\nend \nend", "def dominant_octopus(array)\n fish_food = octopus_army(array)\n fish_food.first\nend", "def find_the_cheese(food) #method and argument\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"] #array\n food.find do |i|\n if cheese_types.include?(i)\n return i\n else\n end\n nil\n end\nend", "def simple_fizzy(start_num, end_num)\n (start_num..end_num).each do |number|\n puts \"Fizz: \" + number.to_s if fizzbuzz(number) == \"Fizz\"\n if number == end_num\n (start_num..end_num).each do |number|\n puts \"Buzz: \" + number.to_s if fizzbuzz(number) == \"Buzz\"\n if number == end_num\n (start_num..end_num).each do |number|\n puts \"FizzBuzz: \" + number.to_s if fizzbuzz(number) == \"FizzBuzz\"\n end\n end\n end\n end\n end\nend", "def bakery_num(num_of_people, fav_food) \n \n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} \n \n has_fave = false \n\n my_list.each_key do |k| \n if k == fav_food\n has_fave = true\n end\n end\n \n if has_fave == false\n raise ArgumentError.new(\"You can't make that food\")#raise error if has_fave is #false will catch items that are not included in program\n \n else fav_food_qty = my_list[fav_food] #setting fav_food_qty equal to value in my_list\n \n if num_of_people % fav_food_qty == 0 #if perfectly divisible...\n num_of_food = num_of_people / fav_food_qty\n return \"You need to make #{num_of_food} #{fav_food}(s).\"\n \n else #the scenario where the favorite food is not perfectly divisible\n final_hash = my_list \n my_list.each do |k, v|\n final_hash[k] = num_of_people / v\n num_of_people %= v\n end\n\n stringOut = \"You need to make \"\n stringMod = \"\"\n stringEnd = \"\"\n mod_hash = final_hash.dup.delete_if {|k, v| k == \"cookie\" } #Assumes that cookies always feeds one \n last_hash = final_hash.dup.delete_if {|k, v|k != \"cookie\" } #See above\n\n mod_hash.each do |k,v| \n stringMod += \"#{v}\" + \" \" + \"#{k}(s)\" + \",\" + \" \"\n end\n\n last_hash.each do |k,v|\n stringEnd += \"and #{v}\" + \" \" + \"#{k}(s)\" + \".\"\n end\n end\n end\n return stringOut + stringMod + stringEnd #purpose of this is to return as String\nend", "def bakery_num(num_of_people, fav_food)\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1}\n food_quantity = {\"pie\" => 0, \"cake\" => 0, \"cookie\" => 0}\n \n#Determine whether fav_food is a key in my_list\n# if you type in a food that isn't on the list, it raises an argument error\n\nunless my_list.has_key?(fav_food)\n raise ArgumentError.new(\"You can't make that food\")\nend\n\n# takes the value of the favorite food\n fav_food_qty = my_list[fav_food]\n#checks whether the number of people is divisible by that value \n if num_of_people % fav_food_qty == 0\n \n num_of_food = num_of_people / fav_food_qty\n return \"You need to make #{num_of_food} #{fav_food}(s).\"\n#if there is a remainder...\n else num_of_people % fav_food_qty != 0\n food_quantity[fav_food] = num_of_people / fav_food_qty\n remaining_people=num_of_people%fav_food_qty\n my_list.each do |k,v|\n if remaining_people / my_list[k] > 0\n food_quantity[k] += remaining_people / my_list[k]\n remaining_people = remaining_people % my_list[k]\n end\n end\n # returns the number of pies, cakes, and cookie that can be made\n return \"You need to make #{food_quantity['pie']} pie(s), #{food_quantity['cake']} cake(s), and #{food_quantity['cookie']} cookie(s).\"\n end\n end", "def adopted_cats(dumb_friends_league, from_friend, stray_cat)\n puts \"I have adopted #{dumb_friends_league} cat(s) from Dumb Friends League.\"\n puts \"I have adopted #{from_friend} cat(s) from a friend.\"\n puts \"I have adopted #{stray_cat} stray cat(s).\"\nend", "def get_info_on_club(fixture)\n puts \"See when your favourites are playing:(enter favourite club name)\"\n fav_club = gets.chomp\n all_fav_matches = fixture.map do |game|\n if game[:home_team].downcase.include?(fav_club) || game[:away_team].downcase.include?(fav_club)\n game\n end\n end.compact\n\n if all_fav_matches.empty?\n puts \"Did not match the database!\"\n else\n puts all_fav_matches\n end\nend", "def questionOne(frustration)\n if frustration == \"Yes\"\n return 3\n end \n \n if frustration == \"Not at all\"\n return 1\n end \n \n if frustration == \"I can't tell\"\n return 2\n end\nend", "def find_the_cheese(ingredients)\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n #I originally did it this way, but the instructions said to use \"include?\"\n #ingredients.detect { |ingredient| ingredient == cheese_types[0] || ingredient == cheese_types[1] || ingredient == cheese_types[2]}\n ingredients.find do |ingredient|\n cheese_types.include?(ingredient)\n end\nend", "def bakery_num(num_of_people, fav_food) # creating method bakery_num\n my_list = {\"pie\" => 8, \"cake\" => 6, \"cookie\" => 1} #creating hash. value of keys equals servings per person\n pie_qty = 0\n cake_qty = 0\n cookie_qty = 0\n dessert_array = Array.new\n has_fave = false \n\n my_list.each_key do |k| #iterates each key in the hash my_list\n if k == fav_food # making a comparison of each key in hash\n has_fave = true # gives a true value to fave_food\n #fav_food = k #fav_food is set to the value of the key ***** Redundant assignment, line deleted.\n end\n end\n\n if has_fave == false #if has_fave is false\n raise ArgumentError.new(\"You can't make that food\") #makes a new error to say that we cannot make that food because we have the incorrect arguements\n else\n fav_food_qty = my_list[fav_food] #creating a variable that, through the values method, returns an array made up by the value of the key established at fav_food \n if num_of_people % fav_food_qty == 0 #if theres no remainder in num_of_people divided fav_food_quantity\n num_of_food = num_of_people / fav_food_qty #creating num_of_food variable that gives us how many food items we should make\n return \"You need to make #{num_of_food} #{fav_food}(s).\" # returns string \n else #if there is a remainder \n while num_of_people > 0\n #\n my_list.each do |k,v|\n dessert_qty = num_of_people / v\n num_of_people = num_of_people % v\n dessert_array << dessert_qty \n end\n \n #\n # if num_of_people / my_list[\"pie\"] > 0 # if num_of_people divided by number of servings of pie is greather than zero\n # pie_qty = num_of_people / my_list[\"pie\"] # pie_qty equals num_of_people divided by servings of pie\n # num_of_people = num_of_people % my_list[\"pie\"] # num_of_people equals the remainder of num_of_people and servings of pie\n # elsif num_of_people / my_list[\"cake\"] > 0 #repetition of first set of conditions of pie\n # cake_qty = num_of_people / my_list[\"cake\"]\n # num_of_people = num_of_people % my_list[\"cake\"]\n # else\n # cookie_qty = num_of_people / my_list[\"cookie\"] \n # num_of_people = num_of_people % my_list[\"cookie\"] # so we don't have an infinite loop\n # end\n end\n return \"You need to make #{dessert_array[0]} pie(s), #{dessert_array[1]} cake(s), and #{dessert_array[2]} cookie(s).\"\n end\n end\nend", "def find_the_cheese(array)\n cheese_types = [\"cheddar\", \"gouda\", \"camembert\"]\n if array.include?(cheese_types[0])\n return cheese_types[0]\n elsif\n array.include?(cheese_types[1])\n return cheese_types[1]\n elsif array.include?(cheese_types[2])\n return cheese_types[2]\n else\n return nil\n end\nend" ]
[ "0.8377418", "0.7770475", "0.7662393", "0.7660354", "0.76519716", "0.7648953", "0.7648287", "0.7633423", "0.7615455", "0.760103", "0.75485975", "0.75462985", "0.7533894", "0.7522362", "0.7493256", "0.74747753", "0.74473643", "0.73858213", "0.73810697", "0.7343126", "0.7335998", "0.7323468", "0.73147815", "0.7238434", "0.6969449", "0.69239324", "0.6833885", "0.6811388", "0.6694026", "0.63510865", "0.5979739", "0.5765818", "0.5725217", "0.5707125", "0.5705454", "0.57046604", "0.5702016", "0.56201154", "0.5606061", "0.5594378", "0.5547612", "0.55036855", "0.550214", "0.5484034", "0.5465006", "0.5462319", "0.5441141", "0.5436252", "0.53902715", "0.53819096", "0.5376507", "0.5373855", "0.5369747", "0.536876", "0.53481126", "0.5339617", "0.5329378", "0.5322994", "0.5311314", "0.530113", "0.52939874", "0.52928364", "0.5285577", "0.52485245", "0.52416116", "0.5236174", "0.5226987", "0.52240086", "0.5215498", "0.5196837", "0.5182657", "0.5175341", "0.5169002", "0.51670444", "0.51668817", "0.51624936", "0.5160322", "0.51552975", "0.51535386", "0.51508427", "0.51300925", "0.5128971", "0.5125962", "0.512303", "0.5115903", "0.5110558", "0.5105671", "0.51020044", "0.50916153", "0.5079729", "0.50778306", "0.5077664", "0.506628", "0.5056928", "0.5054121", "0.5052298", "0.505031", "0.50466615", "0.5041237", "0.5029047" ]
0.7464782
16
=> returns false Exercise 5 Reverse Write a function reverse(string) that takes in a string and returns it reversed.
def reverse(string) if string == '' return '' end string.chars.pop + reverse((string.chars - [string.chars.pop]).join) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reverse(string)\nend", "def reverse(str)\n return str.reverse()\nend", "def reverse(str)\n return str.reverse()\nend", "def reverse_string(string)\n answer = string.reverse\n return answer\nend", "def Reverse(str)\n return str.reverse! # Okay, completely useless\nend", "def reverse(s)\nend", "def reverse(s)\n return s.reverse\nend", "def solution(str)\n str.reverse\nend", "def reverse (string)\n # Your code here\nend", "def solution(str)\n str.reverse\nend", "def palindrome (input_string)\n input_string == input_string.reverse\nend", "def isPalindrome(string)\n return string.reverse == string\nend", "def isPalindrome(string)\n string == string.reverse\nend", "def reverse(string)\n \n string.reverse!\nend", "def palindrome_tester(s)\n if s == s.reverse\n puts \"It's a palindrome!\"\n else\n puts \"It's not a palindrome.\"\n end\nend", "def palindrome('')\n if string == string.reverse\n return true\n else\n puts \"String is not a palindrome\"\n end\nend", "def reverse(string)\n string.reverse\nend", "def reverse(string)\n string.reverse\nend", "def palindrome (string)\n\n if string.reverse == string\n return true\n else\n return false\n end\n \nend", "def test(string)\n reverse_string = string.reverse\n if string == reverse_string\n puts \"#{string} is a palindrome\"\n else\n puts \"#{string} is not a palindrome\"\n end\nend", "def reverse_string(string)\n reverse = string.reverse\n return reverse\nend", "def reverse_string(s)\n s.reverse!\nend", "def reverse_string(string)\r\n return string.reverse\r\nend", "def palindrome string\n if string == string.reverse\n \"#{string} is a palindrome!\"\n else \n \"#{string} is not a palindrome\"\n end \nend", "def reverse_string(string)\nreturn string.reverse\nend", "def reverse(s)\n s.reverse\nend", "def reverse(string)\n\tstring.reverse\nend", "def reverse(string)\n\tstring.reverse\nend", "def reverse(string)\n\tstring.reverse\nend", "def palindrome(str)\n str == str.reverse\nend", "def reverse(str)\n str.reverse\nend", "def reverseString(string)\n\nend", "def palindrome(str)\n if str.reverse == str\n puts true\n else\n puts 'not palindrome'\n end\nend", "def is_palindrome(str)\n return str == str.reverse\nend", "def reverse(input); end", "def palindrome?(string)\r\n string.reverse == string\r\nend", "def palindrome?(string)\r\n string.reverse == string\r\nend", "def palindrome?(string)\r\n string.reverse == string\r\nend", "def reverse_string input\n input.reverse\nend", "def q8_palindrome?(str)\n str == str.reverse\nend", "def palindrome?(string)\n string == string.reverse\n\nend", "def reverse(string)\n return \"\" if string == \"\"\n return string if string.length == 1\n return string[-1] + reverse(string[0..-2])\nend", "def palindrome?(string)\n string.reverse == string\nend", "def palindrome?(string)\n string.reverse == string\nend", "def palindrome?(string)\n string.reverse == string\nend", "def palinodrome?(string)\n string == my_reverse(string)\nend", "def reverse(s)\n # raise NotImplementedError, \"Method not implemented\"\n if s.length <= 1 # will stop once string is equal to 1 or less\n return s\n else\n return s[-1] + reverse(s[0..-2])\n end\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def palindrome?(string)\n string == string.reverse\nend", "def reverse(string)\n return string if string.length <= 1\n string[-1] + reverse.string[0...-1]\nend", "def reverse (string_to_check)\n\n\tif string_to_check.bytes.last == 0\n\t\tputs \"yup\"\n\t\treturn string_to_check.reverse\n\tend\n\n\tnil\n\nend", "def palindrome?(string)\n string == string.reverse\nend", "def reverse(string)\n return \"\" if string.length == 0\n\n string[-1] + reverse(string[0...-1])\nend", "def palindrome?(string)\n if string == string.reverse\n return true\n else \n return false\n end\nend", "def reverse(string)\n return string if string.length < 2\n reverse(string[1..-1]) + string[0]\nend", "def reverse(string)\n return \"\" if string.length == 0\n return string if string.length == 1\n return string[-1] + reverse(string[0..-2])\nend", "def reverse(string)\n return string if string.empty?\n\n reverse(string[1..-1]) + string[0]\nend", "def reverse(string)\n return string if string.length <= 1\n return string[-1] + reverse(string[0...-1])\nend", "def reverse_string(some_string)\r\n reversed_string = some_string.reverse\r\n return reversed_string #usually it is the last statement in a method\r\nend", "def reverse(string)\n return string if string.length == 0\n reverse(string[1..-1]) + string[0]\nend", "def reverse(string)\n return string if string.length <= 1\n\n string.slice!(-1) + reverse(string)\nend", "def reverse_s(string)\r\n puts string.reverse\r\nend", "def reverse(s)\n return '' if s == nil || s == ''\n\n i = 0\n puts \"#{s} #{s[i]}\"\n return reverse(s[i + 1..-1]) + s[i]\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def palindrome?(str)\n str == str.reverse\nend", "def reverse(string)\n reversed = \"\"\n return string if string.length <= 1\n reversed += string[-1] + reverse(string[0..-2])\n reversed\nend", "def palindrome?(str)\n str == str.reverse \nend", "def palindrome?(string)\n return true if string == string.reverse\n false\nend", "def reverse(string)\n return string if string.length < 2\n \n reversed = reverse(string[1, string.length]) # <-- top bottom\n reversed + string[0] # <-- bottom up\nend", "def palindrome?(str)\r\n str == str.reverse\r\nend", "def palindrome?(str)\n str.reverse == str\nend", "def palindrome?(str)\n str.reverse == str\nend", "def palindrome?(str)\n str.reverse == str\nend", "def palindrome?(str)\n str.reverse == str\nend", "def reverse(string)\n return string if string.length <= 1\n string[-1] + reverse(string[0..-2])\nend", "def reverse(string)\n return string if string.length <= 1\n string[-1] + reverse(string[0..-2])\nend", "def reverse(string)\n return string if string.length <= 1\n string[-1] + reverse(string[0..-2])\nend", "def reverse(string)\n return string if string.length <= 1\n string[-1] + reverse(string[0..-2])\nend", "def reverse_string(string)\n\treturn string.reverse\nend", "def reverse(string)\n return string if string.empty?\n string[-1] + reverse(string[0..-2])\nend", "def is_a_palindrome?(string)\n if string == string.reverse\n return true #can be also return string, in that case we will get the string printed\n else\n p \"This string is not a palindrome.\"\n end\nend", "def reverse(string)\n return string if string.length <= 1\n reverse(string[1..-1]) + string[0]\nend" ]
[ "0.8209055", "0.81811655", "0.81701505", "0.811757", "0.807593", "0.8058038", "0.8052876", "0.8037358", "0.8034767", "0.80033046", "0.8000448", "0.7986728", "0.79866797", "0.7985523", "0.7975693", "0.79712987", "0.79675597", "0.79675597", "0.7942086", "0.79223895", "0.79215336", "0.79104596", "0.7904689", "0.78753483", "0.7857531", "0.7852962", "0.7844012", "0.7844012", "0.7844012", "0.7837984", "0.7811289", "0.7809835", "0.7802347", "0.77964455", "0.7791866", "0.7762687", "0.7762687", "0.7762687", "0.7759663", "0.775144", "0.77412254", "0.7739982", "0.7733125", "0.7733125", "0.7733125", "0.7730396", "0.77294475", "0.77283746", "0.77283746", "0.77283746", "0.77283746", "0.77283746", "0.77283746", "0.77283746", "0.77283746", "0.77283746", "0.77283746", "0.77283746", "0.7724346", "0.77207416", "0.77171135", "0.7716616", "0.77164114", "0.7709953", "0.7698633", "0.76873684", "0.7683239", "0.7672686", "0.76704615", "0.76649386", "0.76616657", "0.76496816", "0.76465374", "0.76465374", "0.76465374", "0.76465374", "0.76465374", "0.76465374", "0.76465374", "0.76465374", "0.76465374", "0.76465374", "0.76465374", "0.76465374", "0.764592", "0.7645058", "0.76450574", "0.7643289", "0.7639438", "0.76377827", "0.76377827", "0.76377827", "0.76377827", "0.76275027", "0.76275027", "0.76275027", "0.76275027", "0.76241094", "0.7622643", "0.7622595", "0.76169515" ]
0.0
-1
GET /api/v1/poll_responses GET /api/v1/poll_responses.json
def index @api_v1_poll_responses = Api::V1::PollResponse.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_api_v1_poll_response\n @api_v1_poll_response = Api::V1::PollResponse.find(params[:id])\n end", "def api_v1_poll_response_params\n params.fetch(:api_v1_poll_response, {})\n end", "def respond\n\t\t@poll = Poll.find(params[:id])\n\t\t@expert_user = @poll.expert_user\n\t\t@participants = @poll.participants\n\t\t@questions = @poll.questions\n\tend", "def responses\n question=Question.find(params[:questionId])\n render :json=> question.response\n end", "def responses\n @responses\n end", "def index\n @poll_answers = PollAnswer.all\n end", "def getChoices(token, pollnum)\n\t\turl = \"/polls/#{pollnum}\"\n\t\theaders = { 'Content-Type' => 'application/json',\n\t\t\t'Authorization' => 'Bearer #{token}'}\n\t\tresponse = HTTParty.get(url, :headers => headers)\n\t\tresult = response['choices']\n\t\treturn result\n\tend", "def index\n @api_v1_groups_polls = Api::V1::GroupsPoll.all\n end", "def list_poll_choices_in_poll(poll_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"poll_id is required\" if poll_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :poll_id => poll_id\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{poll_id}/poll_choices\",\n :poll_id => poll_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response\n \n end", "def index\n @polls = Poll.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @polls }\n end\n end", "def index\n @pollanswers = Pollanswer.all\n end", "def create\n @api_v1_poll_response = Api::V1::PollResponse.new(api_v1_poll_response_params)\n\n respond_to do |format|\n if @api_v1_poll_response.save\n format.html { redirect_to @api_v1_poll_response, notice: 'Poll response was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_poll_response }\n else\n format.html { render :new }\n format.json { render json: @api_v1_poll_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @responses = Response.all\n end", "def index\n @responses = Response.all\n end", "def index\n @responses = Response.all\n end", "def index\n @responses = Response.all\n end", "def index\n @responses = Response.all\n end", "def index\n \t @responses = Response.all\n end", "def index\n @question_polls = QuestionPoll.all\n end", "def get_polls_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.get_polls ...\"\n end\n # resource path\n local_var_path = \"/media/polls\"\n\n # query parameters\n query_params = {}\n query_params[:'filter_category'] = opts[:'filter_category'] if !opts[:'filter_category'].nil?\n query_params[:'filter_tagset'] = opts[:'filter_tagset'] if !opts[:'filter_tagset'].nil?\n query_params[:'filter_text'] = opts[:'filter_text'] if !opts[:'filter_text'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageResourcePollResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaPollsApi#get_polls\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @poll = Poll.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @poll }\n end\n end", "def index\n @pending_polls = Poll.where(id: current_user.user_poll.where(answered: nil).pluck(:poll_id))\n @done_polls = Poll.where(id: current_user.user_poll.where(answered: true).pluck(:poll_id))\n end", "def get_single_poll(id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"id is required\" if id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :id => id\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{id}\",\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response\n \n end", "def answer_poll_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.answer_poll ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling MediaPollsApi.answer_poll\"\n end\n # resource path\n local_var_path = \"/media/polls/{id}/response\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'answer_key'])\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\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 => 'PollResponseResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaPollsApi#answer_poll\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def completed_polls\n Poll.find_by_sql([<<-SQL, self.id])\n SELECT\n polls.*\n FROM\n responses\n JOIN\n answer_choices ON responses.answer_choice_id = answer_choices.id\n RIGHT JOIN\n questions ON answer_choices.question_id = questions.id\n JOIN\n polls ON questions.poll_id = polls.id\n WHERE\n responses.user_id = ? OR responses.user_id IS NULL\n GROUP BY\n polls.id\n HAVING\n COUNT(*) = COUNT(answer_choices.id)\n SQL\n end", "def index\n @poll_questions = PollQuestion.all\n end", "def set_responses\n\t\t@responses = Response.where(question_id: params[:id] ) rescue nil\n\tend", "def update\n respond_to do |format|\n if @api_v1_poll_response.update(api_v1_poll_response_params)\n format.html { redirect_to @api_v1_poll_response, notice: 'Poll response was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_poll_response }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_poll_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_poll_answer_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.get_poll_answer ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling MediaPollsApi.get_poll_answer\"\n end\n # resource path\n local_var_path = \"/media/polls/{id}/response\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PollResponseResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaPollsApi#get_poll_answer\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @polls = Poll.all\n end", "def index\n @polls = Poll.all\n end", "def index\n @polls = Poll.all\n end", "def index\n @polls = Poll.all\n end", "def index\n @polls = Poll.all\n end", "def responses\n {\n 'multiple_choice_answers' => self.multiple_choice_answers,\n 'open_response_answers' => self.open_response_answers,\n 'image_question_answers' => self.image_question_answers,\n 'external_links' => self.interactive_run_states\n }\n end", "def show\n @participation_urls = participation_urls(@poll)\n @answers = @poll.number_histogram\n end", "def show\n @poll_question = PollQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @poll_question }\n end\n end", "def destroy\n @api_v1_poll_response.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_poll_responses_url, notice: 'Poll response was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def responses\n @proposal = current_user.proposals.find(params[:id])\n @responses = @proposal.responses\n\n respond_to do |format|\n format.html # responses.html.erb\n format.xml { render :xml => @responses }\n end\n end", "def index\n @pollitems = Pollitem.all\n end", "def index\n @listings_polls = ListingsPoll.all\n end", "def getResponses(surveyId)\n return survey_responses.where({:survey_id => surveyId})\n end", "def show\n @poll_options_set = PollOptionsSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @poll_options_set }\n end\n end", "def get_polls_and_answers(polls)\n pollArray = []\n if polls.length > 0\n polls.each {|poll|\n pollArray.push({\n id: poll.id,\n title: poll.title,\n question: poll.question,\n answers: poll.answers\n })\n }\n end\n puts pollArray\n pollArray\n end", "def get_poll_templates_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.get_poll_templates ...\"\n end\n # resource path\n local_var_path = \"/media/polls/templates\"\n\n # query parameters\n query_params = {}\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageResourceTemplateResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaPollsApi#get_poll_templates\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_single_poll_choice(poll_id,id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"poll_id is required\" if poll_id.nil?\n raise \"id is required\" if id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :poll_id => poll_id,\n :id => id\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{poll_id}/poll_choices/{id}\",\n :poll_id => poll_id,\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response\n \n end", "def poll_response\n begin\n r = JSON.parse(content.gsub('\\\"', '\\'')).to_hash\n puts r\n return r\n rescue JSON::ParserError\n return content\n end\n end", "def get_responses(entries)\n responses = entries.map do |entry|\n entry.responses\n end\n responses.flatten.compact\n end", "def index\n \t@polls = Poll.paginate :order => \"polls.created_at DESC\", :conditions => @conditions, :include => :answers, :page => params[:page]\n end", "def get_poll_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.get_poll ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling MediaPollsApi.get_poll\"\n end\n # resource path\n local_var_path = \"/media/polls/{id}\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PollResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaPollsApi#get_poll\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @report = Report.find(params[:id])\n correct_questions = Array.new\n question_labels = Array.new\n answers_picked = Array.new\n # get the correct questions into the array\n if(@report.participants.count == 0)\n correct_questions << -1\n else\n sorted = @report.poll.pollquestions.sort { |a, b| a.weight <=> b.weight }\n sorted.each do |q|\n correct_questions << AnsweredQuestion.num_correct(q.question, @report)\n question_labels << q.question.body\n end\n end\n @report.poll.pollquestions.sort { | a, b | a.weight <=> b.weight } .each do |q|\n q.question.answers.each do |a|\n answers_picked << a.picked(@report)\n end \n end\n data = [{ \n :p_count => @report.participants.count,\n :q_count => @report.poll.questions.count,\n :correct_questions => correct_questions,\n :q_labels => question_labels,\n :answers_picked => answers_picked\n }];\n respond_with data.to_json\n end", "def index\n @survey_question_responses = SurveyQuestionResponse.all\n end", "def show\n @survey_response = SurveyResponse.find(params[:id])\n \n convert_responses([@survey_response])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @survey_response }\n end\n end", "def poll\n @statistics[:total_calls] += 1\n\n response = @connection.post(request_parameters)\n handle_connection_response(response) unless self.class.long_polling\n end", "def index\n @survey_responses = SurveyResponse.all\n end", "def create_poll_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.create_poll ...\"\n end\n # resource path\n local_var_path = \"/media/polls\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'poll_resource'])\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\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 => 'PollResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaPollsApi#create_poll\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @responses = Response.all\n @response = Response.new\n end", "def show\n id = params[:id]\n unless is_number? id\n token = id\n decode_t = decode_link token\n id = decode_t[0]['id']\n end\n\n @opinion_poll = OpinionPoll.find(id)\n\n return ok_request @opinion_poll, %w(user time_slots answers.time_slots)\n rescue ActiveRecord::RecordNotFound\n r = {opinion_poll: 'Record Not Found'}\n return not_found r\n end", "def send_poll_results vote\n tweeter = Tweeter.default\n _winners = winners\n if _winners.length > 1\n status = \"@#{vote.voter_name} The current winners in the #{name} poll are #{winners_as_text}. #{fq_url} #{poll_tag}\"\n else\n status = \"@#{vote.voter_name} The current winner in the #{name} poll is #{winners_as_text}. #{fq_url} #{poll_tag}\"\n end\n tweeter.status_update( status, vote.tweet_id )\n logger.info(\"POLL RESULTS SENT\")\n end", "def index\n @user_responses = UserResponse.all\n end", "def get_questionnaire_responses\n @get_questionnaire_responses ||=\n questionnaire_response_service.search(\n source: user.icn,\n authored: [date_ge_one_month_ago, date_le_two_weeks_from_now],\n _count: '100'\n )\n end", "def index\n @responses = Response.all\n puts \"\\n\\n\\n\\nyo dude I think its working \\n\\n\\n\\n\"\n end", "def list_answer_responses\n article = find_entity # questionnaire article\n receive_and_set_background_params\n @display_mode = params[:display_mode]\n @is_answer_response = true # choose only answer response article to questionnaire article\n @question_entities = article.questionnaires\n find_detail_of_thread(article.a_thread)\n render :partial => \"detail_with_answer_responses\", :layout => \"base_layout\"\n end", "def responses\n participants.flat_map(&:responses)\n end", "def index\n @responses = @survey.responses.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @responses }\n end\n end", "def answers\n request('answers')\n end", "def create\n result = Userpoll::CreateUserpoll.perform(userpoll_context)\n\n respond_to do |format|\n if result.success?\n @userpoll = result.userpoll\n format.json { render action: 'show', status: :created }\n else\n format.json { render json: { :errors => result.errors.full_messages }, status: :unprocessable_entity }\n end\n end\n end", "def index\n\n if params[:id].present?\n @poll_options = PollOption\n .paginate(:page => params[:page], :per_page => 10)\n .where(poll_id: params[:id])\n .order('id DESC').accessible_by(current_ability)\n else\n redirect_to admin_polls_path\n end\n end", "def new\n @poll = Poll.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poll }\n end\n end", "def new\n @poll = Poll.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poll }\n end\n end", "def poll_params\n params.require(:poll).permit(:name, :description, :instant_result, :public_result, :open, :answer_type, :participants)\n end", "def pings\n response[\"pings\"]\n end", "def show\n @responses = Response.find(params[:id])\n respond_with @response\n end", "def create_single_poll(polls__question__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :polls__question__,\n :polls__description__,\n \n ]\n\n # verify existence of params\n raise \"polls__question__ is required\" if polls__question__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :polls__question__ => polls__question__\n )\n\n # resource path\n path = path_replace(\"/v1/polls\",\n )\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:post, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:post, path, query_params, form_params, headers)\n page_params_store(:post, path)\n response\n \n end", "def polls(options = {})\n options[:filter] ||= []\n options[:filter] << { :field => 'subtype', :operator => '=', :value => 'Poll' }\n surveys(options)\n end", "def all\n raw_response = get_request('webhooks')\n parse_response(raw_response, :webhooks)\n end", "def long_poll_result\n response = async_response(api_url)\n return response[:body]\n end", "def do_poll\n\t\tstatus_lamp\n\t\tstatus_input\n\t\tprojector_information\n\t\tstatus_error\n\tend", "def new\n @poll_question = PollQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poll_question }\n end\n end", "def list\n get(uri: '/webhooks/')\n end", "def get_results_for_single_poll_session(poll_id,id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"poll_id is required\" if poll_id.nil?\n raise \"id is required\" if id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :poll_id => poll_id,\n :id => id\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{poll_id}/poll_sessions/{id}\",\n :poll_id => poll_id,\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response\n \n end", "def set_listings_poll\n @listings_poll = ListingsPoll.find(params[:id])\n end", "def handle_connection_response(response)\n handle_response(response.body)\n light_sleep(self.class.poll_interval)\n end", "def set_poll\r\n @poll = Poll.find(params[:id])\r\n end", "def index\n @prompts = Prompt.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @prompts }\n end\n end", "def new\n @poll_options_set = PollOptionsSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poll_options_set }\n end\n end", "def show\n if(@poll.has_been_voted_on_by current_user)\n render action: 'show_results' \n end\n end", "def create\n @poll = Poll.new(poll_params)\n @poll.owner_id = current_user.id\n @poll.answer_count = 0\n @poll.status = \"pending\"\n @client = GooglePlaces::Client.new(\"AIzaSyBewVg-2JE4BAunjrxdhKU8ao8qnOLvuAc\")\n params[:poll][:respondees].tr(' ', '').split(\",\").each do |email|\n user = User.find_by(email: email)\n if user\n @poll.users << user\n end\n end\n options = @client.spots_by_query(@poll.address, types: ['restaurant', 'food']).slice(0, 10)\n respond_to do |format|\n if @poll.save\n options.each do |option|\n @poll.options.create(name: option.name, positive_votes: 0, negative_votes: 0, place_id: option.reference)\n end\n format.html { redirect_to root_path, notice: 'Poll was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end", "def index\n @responses = @survey.responses\n @questions = Question.all\n end", "def index\n @answer_respondents = AnswerRespondent.all\n end", "def index\n @whos_home_responses = WhosHomeResponse.all\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def list_poll_sessions_for_poll(poll_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"poll_id is required\" if poll_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :poll_id => poll_id\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{poll_id}/poll_sessions\",\n :poll_id => poll_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response\n \n end" ]
[ "0.6578214", "0.6476995", "0.6418129", "0.6399645", "0.6371288", "0.6334123", "0.62478423", "0.623384", "0.6232368", "0.61980903", "0.6183851", "0.61230755", "0.60523313", "0.60523313", "0.60523313", "0.60523313", "0.60523313", "0.6037501", "0.600481", "0.5996631", "0.5953638", "0.5953579", "0.5943944", "0.5914853", "0.5885841", "0.587326", "0.58646685", "0.58408827", "0.58254933", "0.5791838", "0.5791838", "0.5791838", "0.5791838", "0.5791838", "0.57616544", "0.57440424", "0.5726359", "0.5720691", "0.57066655", "0.56805205", "0.56760305", "0.5646882", "0.5623043", "0.56167966", "0.56114244", "0.56058615", "0.5604048", "0.56015617", "0.55960715", "0.55929494", "0.5587637", "0.55864465", "0.5574771", "0.55599785", "0.55447483", "0.55420935", "0.553699", "0.55297816", "0.5527088", "0.55183804", "0.55074996", "0.5504278", "0.5504086", "0.5497762", "0.5497744", "0.54793113", "0.54774654", "0.547439", "0.54710597", "0.54710597", "0.5462499", "0.54569596", "0.5447534", "0.54331976", "0.54075706", "0.5403993", "0.5402297", "0.5397424", "0.5381064", "0.53760403", "0.53742576", "0.53693247", "0.53651655", "0.5355878", "0.5350391", "0.53480875", "0.5345603", "0.5344928", "0.53446597", "0.53443384", "0.5331284", "0.53306115", "0.53306115", "0.53306115", "0.53306115", "0.53306115", "0.53306115", "0.53306115", "0.53306115", "0.53304654" ]
0.7910411
0
GET /api/v1/poll_responses/1 GET /api/v1/poll_responses/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @api_v1_poll_responses = Api::V1::PollResponse.all\n end", "def set_api_v1_poll_response\n @api_v1_poll_response = Api::V1::PollResponse.find(params[:id])\n end", "def api_v1_poll_response_params\n params.fetch(:api_v1_poll_response, {})\n end", "def get_single_poll(id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"id is required\" if id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :id => id\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{id}\",\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response\n \n end", "def create\n @api_v1_poll_response = Api::V1::PollResponse.new(api_v1_poll_response_params)\n\n respond_to do |format|\n if @api_v1_poll_response.save\n format.html { redirect_to @api_v1_poll_response, notice: 'Poll response was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_poll_response }\n else\n format.html { render :new }\n format.json { render json: @api_v1_poll_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def respond\n\t\t@poll = Poll.find(params[:id])\n\t\t@expert_user = @poll.expert_user\n\t\t@participants = @poll.participants\n\t\t@questions = @poll.questions\n\tend", "def responses\n question=Question.find(params[:questionId])\n render :json=> question.response\n end", "def show\n @poll = Poll.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @poll }\n end\n end", "def update\n respond_to do |format|\n if @api_v1_poll_response.update(api_v1_poll_response_params)\n format.html { redirect_to @api_v1_poll_response, notice: 'Poll response was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_poll_response }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_poll_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def getChoices(token, pollnum)\n\t\turl = \"/polls/#{pollnum}\"\n\t\theaders = { 'Content-Type' => 'application/json',\n\t\t\t'Authorization' => 'Bearer #{token}'}\n\t\tresponse = HTTParty.get(url, :headers => headers)\n\t\tresult = response['choices']\n\t\treturn result\n\tend", "def index\n @api_v1_groups_polls = Api::V1::GroupsPoll.all\n end", "def get_single_poll_choice(poll_id,id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"poll_id is required\" if poll_id.nil?\n raise \"id is required\" if id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :poll_id => poll_id,\n :id => id\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{poll_id}/poll_choices/{id}\",\n :poll_id => poll_id,\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response\n \n end", "def index\n @poll_answers = PollAnswer.all\n end", "def index\n @polls = Poll.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @polls }\n end\n end", "def answer_poll_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.answer_poll ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling MediaPollsApi.answer_poll\"\n end\n # resource path\n local_var_path = \"/media/polls/{id}/response\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'answer_key'])\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\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 => 'PollResponseResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaPollsApi#answer_poll\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @poll_question = PollQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @poll_question }\n end\n end", "def index\n @pollanswers = Pollanswer.all\n end", "def destroy\n @api_v1_poll_response.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_poll_responses_url, notice: 'Poll response was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def poll_response\n begin\n r = JSON.parse(content.gsub('\\\"', '\\'')).to_hash\n puts r\n return r\n rescue JSON::ParserError\n return content\n end\n end", "def list_poll_choices_in_poll(poll_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"poll_id is required\" if poll_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :poll_id => poll_id\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{poll_id}/poll_choices\",\n :poll_id => poll_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response\n \n end", "def get_poll_answer_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.get_poll_answer ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling MediaPollsApi.get_poll_answer\"\n end\n # resource path\n local_var_path = \"/media/polls/{id}/response\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PollResponseResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaPollsApi#get_poll_answer\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n id = params[:id]\n unless is_number? id\n token = id\n decode_t = decode_link token\n id = decode_t[0]['id']\n end\n\n @opinion_poll = OpinionPoll.find(id)\n\n return ok_request @opinion_poll, %w(user time_slots answers.time_slots)\n rescue ActiveRecord::RecordNotFound\n r = {opinion_poll: 'Record Not Found'}\n return not_found r\n end", "def create_single_poll(polls__question__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :polls__question__,\n :polls__description__,\n \n ]\n\n # verify existence of params\n raise \"polls__question__ is required\" if polls__question__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :polls__question__ => polls__question__\n )\n\n # resource path\n path = path_replace(\"/v1/polls\",\n )\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:post, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:post, path, query_params, form_params, headers)\n page_params_store(:post, path)\n response\n \n end", "def show\n @poll_options_set = PollOptionsSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @poll_options_set }\n end\n end", "def new\n @poll = Poll.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poll }\n end\n end", "def new\n @poll = Poll.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poll }\n end\n end", "def responses\n @responses\n end", "def index\n @responses = Response.all\n end", "def index\n @responses = Response.all\n end", "def index\n @responses = Response.all\n end", "def index\n @responses = Response.all\n end", "def index\n @responses = Response.all\n end", "def index\n \t @responses = Response.all\n end", "def index\n @question_polls = QuestionPoll.all\n end", "def get_poll_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.get_poll ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling MediaPollsApi.get_poll\"\n end\n # resource path\n local_var_path = \"/media/polls/{id}\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PollResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaPollsApi#get_poll\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def index\n @pending_polls = Poll.where(id: current_user.user_poll.where(answered: nil).pluck(:poll_id))\n @done_polls = Poll.where(id: current_user.user_poll.where(answered: true).pluck(:poll_id))\n end", "def get_polls_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.get_polls ...\"\n end\n # resource path\n local_var_path = \"/media/polls\"\n\n # query parameters\n query_params = {}\n query_params[:'filter_category'] = opts[:'filter_category'] if !opts[:'filter_category'].nil?\n query_params[:'filter_tagset'] = opts[:'filter_tagset'] if !opts[:'filter_tagset'].nil?\n query_params[:'filter_text'] = opts[:'filter_text'] if !opts[:'filter_text'].nil?\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageResourcePollResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaPollsApi#get_polls\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def show\n @survey_response = SurveyResponse.find(params[:id])\n \n convert_responses([@survey_response])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @survey_response }\n end\n end", "def create\n result = Userpoll::CreateUserpoll.perform(userpoll_context)\n\n respond_to do |format|\n if result.success?\n @userpoll = result.userpoll\n format.json { render action: 'show', status: :created }\n else\n format.json { render json: { :errors => result.errors.full_messages }, status: :unprocessable_entity }\n end\n end\n end", "def set_poll\r\n @poll = Poll.find(params[:id])\r\n end", "def index\n @poll_questions = PollQuestion.all\n end", "def new\n @poll_question = PollQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poll_question }\n end\n end", "def set_poll\n @poll = Poll.includes(:poll_options).where(id: params[:id]).take\n end", "def show\n @report = Report.find(params[:id])\n correct_questions = Array.new\n question_labels = Array.new\n answers_picked = Array.new\n # get the correct questions into the array\n if(@report.participants.count == 0)\n correct_questions << -1\n else\n sorted = @report.poll.pollquestions.sort { |a, b| a.weight <=> b.weight }\n sorted.each do |q|\n correct_questions << AnsweredQuestion.num_correct(q.question, @report)\n question_labels << q.question.body\n end\n end\n @report.poll.pollquestions.sort { | a, b | a.weight <=> b.weight } .each do |q|\n q.question.answers.each do |a|\n answers_picked << a.picked(@report)\n end \n end\n data = [{ \n :p_count => @report.participants.count,\n :q_count => @report.poll.questions.count,\n :correct_questions => correct_questions,\n :q_labels => question_labels,\n :answers_picked => answers_picked\n }];\n respond_with data.to_json\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def create_poll_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.create_poll ...\"\n end\n # resource path\n local_var_path = \"/media/polls\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'poll_resource'])\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\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 => 'PollResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaPollsApi#create_poll\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def poll\n @statistics[:total_calls] += 1\n\n response = @connection.post(request_parameters)\n handle_connection_response(response) unless self.class.long_polling\n end", "def show\n @participation_urls = participation_urls(@poll)\n @answers = @poll.number_histogram\n end", "def get_results_for_single_poll_session(poll_id,id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"poll_id is required\" if poll_id.nil?\n raise \"id is required\" if id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :poll_id => poll_id,\n :id => id\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{poll_id}/poll_sessions/{id}\",\n :poll_id => poll_id,\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response\n \n end", "def index\n @pollitems = Pollitem.all\n end", "def get_single_poll_submission(poll_id,poll_session_id,id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"poll_id is required\" if poll_id.nil?\n raise \"poll_session_id is required\" if poll_session_id.nil?\n raise \"id is required\" if id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :poll_id => poll_id,\n :poll_session_id => poll_session_id,\n :id => id\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{poll_id}/poll_sessions/{poll_session_id}/poll_submissions/{id}\",\n :poll_id => poll_id,\n :poll_session_id => poll_session_id,\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response\n \n end", "def index\n @polls = Poll.all\n end", "def index\n @polls = Poll.all\n end", "def index\n @polls = Poll.all\n end", "def index\n @polls = Poll.all\n end", "def index\n @polls = Poll.all\n end", "def poll name\n poll = @watch.objects.find { |obj| obj.name == \"poll#{name}\" }\n\n poll.invoke.objects.find do |object|\n object.name == \"values\"\n end.objects\n end", "def pings\n response[\"pings\"]\n end", "def poll\n options['poll'] || 10\n end", "def set_poll\n @poll = current_user.created_polls.find(params[:id])\n end", "def set_responses\n\t\t@responses = Response.where(question_id: params[:id] ) rescue nil\n\tend", "def new\n @poll_options_set = PollOptionsSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poll_options_set }\n end\n end", "def set_mypoll\n @mypoll = Mypoll.find(params[:id])\n end", "def get_poll_templates_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.get_poll_templates ...\"\n end\n # resource path\n local_var_path = \"/media/polls/templates\"\n\n # query parameters\n query_params = {}\n query_params[:'size'] = opts[:'size'] if !opts[:'size'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PageResourceTemplateResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaPollsApi#get_poll_templates\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n respond_to do |format|\n if @api_v1_groups_poll.update(api_v1_groups_poll_params)\n format.html { redirect_to @api_v1_groups_poll, notice: 'Groups poll was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_groups_poll }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_groups_poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def responses\n @proposal = current_user.proposals.find(params[:id])\n @responses = @proposal.responses\n\n respond_to do |format|\n format.html # responses.html.erb\n format.xml { render :xml => @responses }\n end\n end", "def long_poll_result\n response = async_response(api_url)\n return response[:body]\n end", "def create\n @api_v1_groups_poll = Api::V1::GroupsPoll.new(api_v1_groups_poll_params)\n\n respond_to do |format|\n if @api_v1_groups_poll.save\n format.html { redirect_to @api_v1_groups_poll, notice: 'Groups poll was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_groups_poll }\n else\n format.html { render :new }\n format.json { render json: @api_v1_groups_poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_listings_poll\n @listings_poll = ListingsPoll.find(params[:id])\n end", "def index\n @responses = Response.all\n @response = Response.new\n end", "def index\n @listings_polls = ListingsPoll.all\n end", "def getResponses(surveyId)\n return survey_responses.where({:survey_id => surveyId})\n end", "def api_response\n @response\n end", "def set_api_v1_groups_poll\n @api_v1_groups_poll = Api::V1::GroupsPoll.find(params[:id])\n end", "def poll_params\n params.require(:poll).permit(:name, :description, :instant_result, :public_result, :open, :answer_type, :participants)\n end", "def create\n @poll = Poll.new(poll_params)\n @poll.owner_id = current_user.id\n @poll.answer_count = 0\n @poll.status = \"pending\"\n @client = GooglePlaces::Client.new(\"AIzaSyBewVg-2JE4BAunjrxdhKU8ao8qnOLvuAc\")\n params[:poll][:respondees].tr(' ', '').split(\",\").each do |email|\n user = User.find_by(email: email)\n if user\n @poll.users << user\n end\n end\n options = @client.spots_by_query(@poll.address, types: ['restaurant', 'food']).slice(0, 10)\n respond_to do |format|\n if @poll.save\n options.each do |option|\n @poll.options.create(name: option.name, positive_votes: 0, negative_votes: 0, place_id: option.reference)\n end\n format.html { redirect_to root_path, notice: 'Poll was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end", "def set_poll_answer\n @poll_answer = PollAnswer.find(params[:id])\n end", "def send_poll_results vote\n tweeter = Tweeter.default\n _winners = winners\n if _winners.length > 1\n status = \"@#{vote.voter_name} The current winners in the #{name} poll are #{winners_as_text}. #{fq_url} #{poll_tag}\"\n else\n status = \"@#{vote.voter_name} The current winner in the #{name} poll is #{winners_as_text}. #{fq_url} #{poll_tag}\"\n end\n tweeter.status_update( status, vote.tweet_id )\n logger.info(\"POLL RESULTS SENT\")\n end", "def set_question_poll\n @question_poll = QuestionPoll.find(params[:id])\n end", "def completed_polls\n Poll.find_by_sql([<<-SQL, self.id])\n SELECT\n polls.*\n FROM\n responses\n JOIN\n answer_choices ON responses.answer_choice_id = answer_choices.id\n RIGHT JOIN\n questions ON answer_choices.question_id = questions.id\n JOIN\n polls ON questions.poll_id = polls.id\n WHERE\n responses.user_id = ? OR responses.user_id IS NULL\n GROUP BY\n polls.id\n HAVING\n COUNT(*) = COUNT(answer_choices.id)\n SQL\n end", "def getResponse(surveyId, questionId)\n return survey_responses.where({:survey_id => surveyId, :survey_question_id => questionId}).first\n end", "def show\n @responses = Response.find(params[:id])\n respond_with @response\n end", "def do_poll\n\t\tstatus_lamp\n\t\tstatus_input\n\t\tprojector_information\n\t\tstatus_error\n\tend", "def show\n @poll = Poll.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @poll }\n end\n end", "def respond(message)\n RESPONSES.sample\n end", "def index\n\n if params[:id].present?\n @poll_options = PollOption\n .paginate(:page => params[:page], :per_page => 10)\n .where(poll_id: params[:id])\n .order('id DESC').accessible_by(current_ability)\n else\n redirect_to admin_polls_path\n end\n end", "def create\n @question_poll = QuestionPoll.new(question_poll_params)\n\n respond_to do |format|\n if @question_poll.save\n format.html { redirect_to @question_poll}\n format.json { render action: 'show', status: :created, location: @question_poll }\n else\n flash[:success] = \"Welcome to the Sample App!\"\n format.html { redirect_to @question_poll }\n format.json { render json: @question_poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_polls_and_answers(polls)\n pollArray = []\n if polls.length > 0\n polls.each {|poll|\n pollArray.push({\n id: poll.id,\n title: poll.title,\n question: poll.question,\n answers: poll.answers\n })\n }\n end\n puts pollArray\n pollArray\n end", "def fetch\n response = RestClient.get \"http://pokeapi.co/#{resource_uri}\"\n update(resource_data: JSON.parse(response))\n end", "def single_response_summary(id)\n get(\"/response/#{id}\")\n end", "def handle_connection_response(response)\n handle_response(response.body)\n light_sleep(self.class.poll_interval)\n end", "def latest_response\n return nil if self.invite_responses.empty?\n self.invite_responses.first\n end", "def index\n @survey_question_responses = SurveyQuestionResponse.all\n end", "def find_response(answer_id)\n self.responses.find_by_answer_id(answer_id)\n end" ]
[ "0.7743532", "0.7208182", "0.6721901", "0.6448035", "0.6436729", "0.6434451", "0.6422756", "0.6202063", "0.61444414", "0.6068865", "0.60517454", "0.6040167", "0.6028721", "0.60113466", "0.5997825", "0.5996945", "0.5901361", "0.59002596", "0.5892823", "0.58864284", "0.5871122", "0.584798", "0.5843895", "0.5767979", "0.5765789", "0.5765789", "0.5751023", "0.574733", "0.574733", "0.574733", "0.574733", "0.574733", "0.5745298", "0.574404", "0.5733275", "0.571475", "0.5702572", "0.568416", "0.56799364", "0.5654677", "0.5647874", "0.5636996", "0.56336343", "0.56259733", "0.5621412", "0.5621412", "0.5621412", "0.5621412", "0.5621412", "0.5621412", "0.5621412", "0.5621412", "0.5620921", "0.56178075", "0.56060714", "0.56025517", "0.5565832", "0.55654866", "0.5558202", "0.5558202", "0.5558202", "0.5558202", "0.5558202", "0.5553936", "0.55441576", "0.55433494", "0.5539623", "0.55375516", "0.5533326", "0.5521451", "0.550893", "0.5498681", "0.5479354", "0.547643", "0.546939", "0.5463834", "0.5463678", "0.54609597", "0.5437088", "0.5424701", "0.54231966", "0.54193103", "0.5411715", "0.54108036", "0.5401178", "0.5397216", "0.5390245", "0.5375527", "0.5374859", "0.53690255", "0.5367649", "0.5358923", "0.5355715", "0.5353473", "0.5348355", "0.5346721", "0.5345455", "0.5344055", "0.5342981", "0.5329261", "0.53246605" ]
0.0
-1
POST /api/v1/poll_responses POST /api/v1/poll_responses.json
def create @api_v1_poll_response = Api::V1::PollResponse.new(api_v1_poll_response_params) respond_to do |format| if @api_v1_poll_response.save format.html { redirect_to @api_v1_poll_response, notice: 'Poll response was successfully created.' } format.json { render :show, status: :created, location: @api_v1_poll_response } else format.html { render :new } format.json { render json: @api_v1_poll_response.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @api_v1_poll_responses = Api::V1::PollResponse.all\n end", "def create_single_poll(polls__question__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :polls__question__,\n :polls__description__,\n \n ]\n\n # verify existence of params\n raise \"polls__question__ is required\" if polls__question__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :polls__question__ => polls__question__\n )\n\n # resource path\n path = path_replace(\"/v1/polls\",\n )\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:post, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:post, path, query_params, form_params, headers)\n page_params_store(:post, path)\n response\n \n end", "def create\n result = Userpoll::CreateUserpoll.perform(userpoll_context)\n\n respond_to do |format|\n if result.success?\n @userpoll = result.userpoll\n format.json { render action: 'show', status: :created }\n else\n format.json { render json: { :errors => result.errors.full_messages }, status: :unprocessable_entity }\n end\n end\n end", "def create\n @poll = Poll.new(poll_params)\n @poll.owner_id = current_user.id\n @poll.answer_count = 0\n @poll.status = \"pending\"\n @client = GooglePlaces::Client.new(\"AIzaSyBewVg-2JE4BAunjrxdhKU8ao8qnOLvuAc\")\n params[:poll][:respondees].tr(' ', '').split(\",\").each do |email|\n user = User.find_by(email: email)\n if user\n @poll.users << user\n end\n end\n options = @client.spots_by_query(@poll.address, types: ['restaurant', 'food']).slice(0, 10)\n respond_to do |format|\n if @poll.save\n options.each do |option|\n @poll.options.create(name: option.name, positive_votes: 0, negative_votes: 0, place_id: option.reference)\n end\n format.html { redirect_to root_path, notice: 'Poll was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end", "def api_v1_poll_response_params\n params.fetch(:api_v1_poll_response, {})\n end", "def create\n @api_v1_groups_poll = Api::V1::GroupsPoll.new(api_v1_groups_poll_params)\n\n respond_to do |format|\n if @api_v1_groups_poll.save\n format.html { redirect_to @api_v1_groups_poll, notice: 'Groups poll was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_groups_poll }\n else\n format.html { render :new }\n format.json { render json: @api_v1_groups_poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @pollanswer = Pollanswer.new(pollanswer_params)\n\n respond_to do |format|\n if @pollanswer.save\n format.html { redirect_to @pollanswer, notice: 'Pollanswer was successfully created.' }\n format.json { render :show, status: :created, location: @pollanswer }\n else\n format.html { render :new }\n format.json { render json: @pollanswer.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_api_v1_poll_response\n @api_v1_poll_response = Api::V1::PollResponse.find(params[:id])\n end", "def create\n @question_poll = QuestionPoll.new(question_poll_params)\n\n respond_to do |format|\n if @question_poll.save\n format.html { redirect_to @question_poll}\n format.json { render action: 'show', status: :created, location: @question_poll }\n else\n flash[:success] = \"Welcome to the Sample App!\"\n format.html { redirect_to @question_poll }\n format.json { render json: @question_poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @poll = Poll.new(poll_params)\n @poll.ip = request.remote_ip\n # @poll.answers.build(params[:poll][:answers])\n respond_to do |format|\n if @poll.save && @poll.answers.build(params[:poll][:answers])\n format.html { redirect_to polls_url, notice: 'Poll was successfully created.' }\n format.json { render 'show', status: :created, location: @poll }\n else\n format.html { render 'new' }\n format.json { render json: @poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @api_v1_poll_response.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_poll_responses_url, notice: 'Poll response was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def respond_save\n\t\t@poll = Poll.find(params[:id])\n\t\tif current_user.save_answers_and_respond_to!(@poll, params)\n\t\t\tredirect_to @poll, notice: \"Successfully responded to this poll.\"\n\t\telse\n\t\t\tredirect_to respond_poll_path(@poll), notice: \"Something went wrong: please try again.\"\n\t\tend\n\tend", "def create\n @response = Response.new(params[:response])\n @response.ip_address = request.remote_ip\n @response.survey_id = @survey.id\n @response.user_id = current_user\n \n for param in params do\n if param[0] =~ /^question_id_/\n # handle all question parameters\n # $' represents the value of the question_id\n if param[1].is_a? Hash\n # Valid keys include country, option, year, month, day and numeric option_id\n if param[1].has_key? \"year\" && \"month\" && \"day\"\n # concat year, month and day into one answer\n @response.answers.build(:question_id => $', :answer => Date.new(param[1][\"year\"].to_i, param[1][\"month\"].to_i, param[1][\"day\"].to_i) )\n elsif param[1].has_key? \"option\"\n # look up option id for radio & select questions and build answer\n option_id = Option.find_by_label_and_question_id(param[1][\"option\"], $').id\n @response.answers.build(:question_id => $', :answer => param[1][\"option\"], :option_id => option_id)\n elsif param[1].has_key? \"country\"\n # build country answer\n @response.answers.build(:question_id => $', :answer => param[1][\"country\"])\n else\n # build checkbox and likert answers\n param[1].each do |key, value|\n @response.answers.build(:question_id => $', :answer => value, :option_id => key) unless value == \"0\"\n end\n end\n else\n # build answer without option ie text, textarea\n @response.answers.build(:question_id => $', :answer => param[1] ) #unless param[1].blank?\n end \n end\n if param[0] == 'token'\n @response.survey.update_invitation(param[1])\n end\n end\n\n respond_to do |format|\n if @response.save!\n flash[:notice] = 'Response was successfully created.'\n format.html { redirect_to([@survey, @response]) }\n format.xml { render :xml => @response, :status => :created, :location => @response }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @response.errors, :status => :unprocessable_entity }\n end\n end\n rescue ActiveRecord::RecordInvalid => invalid\n render :action => \"new\"\n end", "def create\n @poll = Poll.new(poll_params)\n\n respond_to do |format|\n if @poll.save\n format.html { redirect_to @poll, notice: 'Poll was successfully created.' }\n format.json { render :show, status: :created, location: @poll }\n else\n format.html { render :new }\n format.json { render json: @poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @poll = Poll.new(poll_params)\n\n respond_to do |format|\n if @poll.save\n format.html { redirect_to @poll, notice: 'Poll was successfully created.' }\n format.json { render :show, status: :created, location: @poll }\n else\n format.html { render :new }\n format.json { render json: @poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def pollanswer_params\n params.require(:pollanswer).permit(:pollquestion_id, :option, :status)\n end", "def create\n \n respond_to do |format|\n \n if !params[:questions].nil? \n params[:questions].each {\n |q| \n type = Question.find_by_id(q[0]).question_type\n answer = (type == 2 ? Answer.find_by_id(q[1]).correct : nil)\n Response.new( \n {\n \"question_id\" => q[0],\n \"answer_id\" => type == 2 ? q[1] : nil,\n \"text\" => type == 1 ? q[1] : nil,\n \"user_id\" => current_user.id,\n \"question_group_id\" => params[:response][:question_group_id],\n \"correct\" => answer\n }\n ).save\n }\n format.html { redirect_to '/responses', notice: 'Your responses were successfully saved.' }\n else\n @response = Response.new(params[:response])\n if @response.save\n format.html { redirect_to @response, notice: 'Response was successfully created.' }\n format.json { render json: @response, status: :created, location: @response }\n end\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_poll_response.update(api_v1_poll_response_params)\n format.html { redirect_to @api_v1_poll_response, notice: 'Poll response was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_poll_response }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_poll_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @listings_poll = ListingsPoll.new(listings_poll_params)\n\n respond_to do |format|\n if @listings_poll.save\n format.html { redirect_to @listings_poll, notice: 'Listings poll was successfully created.' }\n format.json { render :show, status: :created, location: @listings_poll }\n else\n format.html { render :new }\n format.json { render json: @listings_poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def load_responses(parameters, survey_id)\n Question.all.each do |question|\n response = Response.new(survey_id: survey_id, question_id: question.id, choice_id: parameters[:\"#{question.id}\"])\n response.save\n end\n end", "def create\n @poll = Poll.new(poll_params)\n @poll.type_poll_id = params[:type_poll_id].to_i\n @questions= params[:questions]\n\n respond_to do |format|\n if @poll.save\n @questions.each do |question_id|\n QuestionPoll.create(poll_id: @poll.id, question_id: question_id)\n end\n if TypePollRole.where(:type_poll_id => @poll.type_poll).count > 0\n TypePollRole.where(:type_poll_id => @poll.type_poll).each do |tpr|\n if User.where(:role_id => tpr.role_id).count > 0\n User.where(:role_id => tpr.role_id).each do |u|\n NewPollMailer.sample_email(@poll,u).deliver_now\n end\n end\n end\n end\n\n\n format.html { redirect_to '/polls' , notice:\"Encuesta creada exitosamente\" }\n format.json { render action: 'show', status: :created, location: @poll }\n else\n format.html { render action: 'new' }\n format.json { render json: @poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def answer_poll_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.answer_poll ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling MediaPollsApi.answer_poll\"\n end\n # resource path\n local_var_path = \"/media/polls/{id}/response\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'answer_key'])\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\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 => 'PollResponseResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaPollsApi#answer_poll\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def responses\n question=Question.find(params[:questionId])\n render :json=> question.response\n end", "def create\n @poll = current_user.polls.new(poll_params)\n\n respond_to do |format|\n if @poll.save\n format.html { redirect_to polls_url, notice: 'Poll was successfully created.' }\n format.json { render :show, status: :created, location: @poll }\n else\n format.html { render :new }\n format.json { render json: @poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def respond\n\t\t@poll = Poll.find(params[:id])\n\t\t@expert_user = @poll.expert_user\n\t\t@participants = @poll.participants\n\t\t@questions = @poll.questions\n\tend", "def create_poll_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.create_poll ...\"\n end\n # resource path\n local_var_path = \"/media/polls\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'poll_resource'])\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\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 => 'PollResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaPollsApi#create_poll\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def poll_params\n params.require(:poll).permit(:name, :description, :instant_result, :public_result, :open, :answer_type, :participants)\n end", "def create\n @s = []\n params.each do |name, value|\n if name =~ /vertical_(.+)$/\n if value =~ /radio(.+)$/\n @s << $1.to_i\n end\n end\n end\n @poll = Poll.find(Pollitem.find(@s[0].to_i).poll_id)\n for s in @s\n @survey = Survey.create(pollitem_id: s.to_i, user_id: current_user.id, poll_id: @poll.id)\n end\n\n\n respond_to do |format|\n if @survey.save\n format.html { redirect_to @survey, notice: 'Survey was successfully created.' }\n format.json { render :show, status: :created, location: @survey }\n format.js\n else\n format.html { render :new }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @poll_question = PollQuestion.new(params[:poll_question])\n\n respond_to do |format|\n if @poll_question.save\n format.html { redirect_to @poll_question, notice: 'Poll question was successfully created.' }\n format.json { render json: @poll_question, status: :created, location: @poll_question }\n else\n format.html { render action: \"new\" }\n format.json { render json: @poll_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def vote(token, pollnum, choices)\n\t\turl = \"/polls/#{pollnum}/vote\"\n\t\theaders = { 'Content-Type' => 'application/json',\n\t\t\t'Authorization' => 'Bearer #{token}'}\n\t\tarray = Array.new\n\t\tchoices.each do |key, value| \n\t\t\tentry = Hash.new\n\t\t\tentry['choice'] = key\n\t\t\tentry['kind'] = value\n\t\t\tarray.push(entry)\n\t\tend\n\t\tresult = HTTParty.post(url, {:headers => headers, :body => array.to_json})\n\t\treturn result\n\tend", "def create\n @poll_question = PollQuestion.new(poll_question_params)\n\n respond_to do |format|\n if @poll_question.save\n format.html { redirect_to @poll_question, notice: 'Poll question was successfully created.' }\n format.json { render :show, status: :created, location: @poll_question }\n else\n format.html { render :new }\n format.json { render json: @poll_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_responses\n\t\t@responses = Response.where(question_id: params[:id] ) rescue nil\n\tend", "def send_poll_results vote\n tweeter = Tweeter.default\n _winners = winners\n if _winners.length > 1\n status = \"@#{vote.voter_name} The current winners in the #{name} poll are #{winners_as_text}. #{fq_url} #{poll_tag}\"\n else\n status = \"@#{vote.voter_name} The current winner in the #{name} poll is #{winners_as_text}. #{fq_url} #{poll_tag}\"\n end\n tweeter.status_update( status, vote.tweet_id )\n logger.info(\"POLL RESULTS SENT\")\n end", "def create\n @poll = Poll.new(poll_params)\n respond_to do |format|\n if @poll.save\n format.html { redirect_to admin_path(@poll), notice: 'Poll was successfully created.' }\n format.json { render :show, status: :created, location: admin_path(@poll) }\n else\n format.html { render :new }\n format.json { render json: @poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def poll_params\n params[:poll].permit(:question, answers_attributes: [:name, :id] )\n end", "def create\n @poll = Poll.new(params[:poll])\n @poll.poll_options ||= PollOptions.new\n @poll.poll_options.enable_captcha = params[:enable_captcha]\n\n @poll.candidates = posted_candidates\n\n\n @poll.initialize_keys\n\n respond_to do |format|\n if @poll.save\n flash[:notice] = 'Poll was successfully created.'\n format.html { redirect_to :action => :admin, :key => @poll.admin_key }\n format.xml { render :xml => @poll, :status => :created, :location => @poll }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @poll.errors, :status => :unprocessable_entity }\n end\n end\n end", "def poll_params\n params.require(:poll).permit(:question, answers_attributes: [:id, :poll_id, :content, :_destroy])\n end", "def save(user)\n Rails.logger.debug \"Call to polls.save\"\n self.answers=Util.arraystring_to_csv(self.answers)\n if self.valid? #Validate if the Poll object is valid\n Rails.logger.debug \"The poll question is valid!\"\n #Create a raw poll object\n poll_req = { 'question'=>self.question,\n 'answers'=>Util.arraystring_to_csv(self.answers),#Turn the answers array in string form to a comma separated string\n 'start'=> Util.date_to_epoch(self.start_date), #Turn the start_date to epoch\n 'duration'=> self.duration.to_i*60000, #Turn minutes to milliseconds\n 'ownerId'=> self.owner_id,\n 'creatorId'=> self.creator_id\n }\n reqUrl = \"/api/poll/\" #Set the request url\n rest_response = MwHttpRequest.http_post_request(reqUrl,poll_req,user['email'],user['password']) #Make the POST call to the server with the required parameters\n Rails.logger.debug \"Response from server: #{rest_response.code} #{rest_response.message}: #{rest_response.body}\"\n if rest_response.code == \"200\" || rest_response.code == \"201\" || rest_response.code == \"202\" #Validate if the response from the server is satisfactory\n poll = Poll.rest_to_poll(rest_response.body) #Turn the response object to a Poll object\n return true, poll #Return success\n else\n return false, \"#{rest_response.code}\", \"#{rest_response.message}\" #Return error\n end\n else\n Rails.logger.debug self.errors.full_messages\n return false, self.errors.full_messages #Return invalid object error\n end\n end", "def create\n @response = @bbs_thread.responses.build(response_params)\n\n respond_to do |format|\n if @response.save\n write_session\n\n format.html { redirect_to bbs_thread_path(@bbs_thread.id), notice: t('notice.response.create') }\n format.json { render :show, status: :created, location: @bbs_response }\n else\n format.html { redirect_to bbs_thread_path(@bbs_thread.id), alert: @response.errors.full_messages }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n question_response = QuestionResponse.build_response_essay(current_user, params)\n\n if question_response.try :save\n render json: { message: \"answer saved\" }\n else\n render json: { message: \"error\" }, status: :unprocessable_entity\n end\n end", "def create_questionnaire_response(data)\n attrs = data.to_h.with_indifferent_access\n response = questionnaire_response_service.create(attrs)\n\n response.tap do |resp|\n if resp.response[:code] == SUCCESS_STATUS\n questionnaire_response.tap do |qr|\n qr.user_uuid = user.uuid\n qr.user_account = user.user_account\n qr.appointment_id = attrs.dig(:appointment, :id)\n qr.questionnaire_response_id = resp.resource.id\n qr.user = user\n qr.questionnaire_response_data = data\n\n qr.save\n end\n end\n end\n end", "def poll_answer_params\n params.require(:poll_answer).permit(:poll_id, :title, :voteCount)\n end", "def create\n @poll = Poll.new(poll_params)\n\n if @poll.save\n flash[:success] = t(:poll_created_successfully)\n redirect_to @poll\n else\n render 'new'\n end\n end", "def create\n poll = Poll.find(params[:poll_id])\n @poll_answer = poll.poll_answers.build poll_answer_params\n @poll_answer.update_attribute(:voteCount, 0 )\n @poll_answer.save\n @poll = Poll.find(params[:poll_id])\n end", "def create_single_poll_choice(poll_id,poll_choices__text__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :poll_choices__text__,\n :poll_choices__is_correct__,\n :poll_choices__position__,\n \n ]\n\n # verify existence of params\n raise \"poll_id is required\" if poll_id.nil?\n raise \"poll_choices__text__ is required\" if poll_choices__text__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :poll_id => poll_id,\n :poll_choices__text__ => poll_choices__text__\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{poll_id}/poll_choices\",\n :poll_id => poll_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:post, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:post, path, query_params, form_params, headers)\n page_params_store(:post, path)\n response\n \n end", "def index\n @poll_answers = PollAnswer.all\n end", "def subscribe_response_hook(name = SecureRandom.hex.to_sym, &block)\n EasyPost::Hooks.subscribe(:response, name, block)\n end", "def create_poll(opts = {})\n data, _status_code, _headers = create_poll_with_http_info(opts)\n return data\n end", "def poll_params\n params.require(:poll).permit(:name, :description, :status, :started_at, :concluded_at)\n end", "def create\n @poll = Poll.new(params[:poll])\n @poll.option_a_score = 0\n @poll.option_b_score = 0\n @poll.option_c_score = 0\n @poll.option_d_score = 0\n\n respond_to do |format|\n if @poll.save\n format.html { redirect_to @poll, notice: 'Poll was successfully created.' }\n format.json { render json: @poll, status: :created, location: @poll }\n else\n format.html { render action: \"new\" }\n format.json { render json: @poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_single_poll_submission(poll_id,poll_session_id,poll_submissions__poll_choice_id__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :poll_submissions__poll_choice_id__,\n \n ]\n\n # verify existence of params\n raise \"poll_id is required\" if poll_id.nil?\n raise \"poll_session_id is required\" if poll_session_id.nil?\n raise \"poll_submissions__poll_choice_id__ is required\" if poll_submissions__poll_choice_id__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :poll_id => poll_id,\n :poll_session_id => poll_session_id,\n :poll_submissions__poll_choice_id__ => poll_submissions__poll_choice_id__\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{poll_id}/poll_sessions/{poll_session_id}/poll_submissions\",\n :poll_id => poll_id,\n :poll_session_id => poll_session_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:post, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:post, path, query_params, form_params, headers)\n page_params_store(:post, path)\n response\n \n end", "def list_poll_choices_in_poll(poll_id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"poll_id is required\" if poll_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :poll_id => poll_id\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{poll_id}/poll_choices\",\n :poll_id => poll_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response\n \n end", "def create\n @poll = Poll.new(params[:poll])\n\n respond_to do |format|\n if @poll.save\n format.html { redirect_to([:admin, @poll], :notice => 'Poll was successfully created.') }\n format.xml { render :xml => @poll, :status => :created, :location => @poll }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @poll.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update_responses(responses)\n\n ui_hash = []\n\n responses.each do |key, value|\n question = survey.question(key)\n response = response(key)\n\n next if value.nil? || question.nil?\n\n if question.type == :none || question.type == :repeater\n answer = question.answers.first\n ui_hash.push(HashWithIndifferentAccess.new(\n question_id: question.id.to_s,\n api_id: response ? response.api_id : Surveyor::Common.generate_api_id,\n answer_id: answer.id.to_s,\n answer.value_key => value.to_s,\n autocompleted: true\n ))\n end\n\n if question.type == :one\n ui_hash.push(HashWithIndifferentAccess.new(\n question_id: question.id.to_s,\n api_id: response ? response.api_id : Surveyor::Common.generate_api_id,\n answer_id: question.answer(value).id.to_s,\n autocompleted: true\n ))\n end\n\n if question.type == :any\n value.each do |item|\n ui_hash.push(HashWithIndifferentAccess.new(\n question_id: question.id.to_s,\n api_id: response ? response.api_id : Surveyor::Common.generate_api_id,\n answer_id: question.answer(item).id.to_s,\n autocompleted: true\n ))\n end\n end\n end\n\n update_from_ui_hash(Hash[ui_hash.map.with_index { |value, i| [i.to_s, value] }])\n end", "def index\n @pollanswers = Pollanswer.all\n end", "def create\n @response = Response.new(response_params)\n\n respond_to do |format|\n if @response.save\n format.html { redirect_to survey_responses_path(@survey), notice: 'Thanks for your response!' }\n format.json { render :show, status: :created, location: @response }\n else\n format.html { render :new }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n end\n end", "def poll\n @statistics[:total_calls] += 1\n\n response = @connection.post(request_parameters)\n handle_connection_response(response) unless self.class.long_polling\n end", "def create\n @survey_response = SurveyResponse.new(params[:survey_response])\n\n respond_to do |format|\n if @survey_response.save\n format.html { redirect_to survey_survey_responses_path(params[:survey_id]), notice: 'Survey response was successfully created.' }\n format.json { render json: @survey_response, status: :created, location: @survey_response }\n else\n format.html { render action: \"new\" }\n format.json { render json: @survey_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n\n @survey_response = SurveyResponse.new(survey_response_params)\n\n respond_to do |format|\n if @survey_response.save\n format.html { redirect_to survey_responses_path, notice: 'Survey response was successfully created.' }\n format.json { render :index, status: :created, location: @survey_response }\n else\n format.html { render :new }\n format.json { render json: @survey_response.errors, status: :unprocessable_entity }\n end\n end\n \n end", "def handle_connection_response(response)\n handle_response(response.body)\n light_sleep(self.class.poll_interval)\n end", "def create\n\n @poll_option = PollOption.new(poll_option_params)\n\n respond_to do |format|\n if @poll_option.save\n format.html { redirect_to [:admin, @poll_option], notice: 'Poll option was successfully created.' }\n format.json { render action: 'show', status: :created, location: @poll_option }\n else\n format.html { render action: 'new' }\n format.json { render json: @poll_option.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @response = Response.new\n \n reason = Reason.new\n reason.why = params[:response][:reason][:why]\n reason.critique = params[:response][:reason][:critique]\n @response.reasons = [reason]\n\n @response.who = params[:response][:who]\n @response.ip_address = request.remote_ip\n @response.user_agent = request.env['HTTP_USER_AGENT']\n\n respond_to do |format|\n if @response.save\n format.html { redirect_to root_url, notice: 'Your response was successfully submitted! Thanks for taking the time to affect change in our government.' }\n format.json { render json: @response, status: :created, location: @response }\n else\n format.html { render action: \"new\" }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @poll = Poll.create(params[:poll])\n if @poll.valid?\n redirect_to @poll\n else\n render action: :new\n end\n end", "def create\n authorize! :create_response, @survey\n @response_survey = @survey.responses.new(response_survey_params)\n @auto_vote = (params[:auto_vote] ? true : false)\n @response_survey.vote(current_user) if @auto_vote\n\n respond_to do |format|\n if @response_survey.save\n @reload = true if current_user && !@survey.can_vote?(current_user)\n format.html { redirect_to :back }\n format.js\n format.json { render action: 'show', status: :created, location: @survey }\n else\n format.js\n format.html { render action: 'new' }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_question_responses\n 10.times do\n response = Response.create(content: \"that sucks\", response_context_type: \"Question\", response_context_id: rand(1..12))\n User.find(rand(3)+1).responses << response\n end\nend", "def poll_question_params\n params.require(:poll_question).permit(:text, :question_type, :poll_ids => [])\n end", "def question_poll_params\n params.require(:question_poll).permit(:question_id, :poll_id)\n end", "def new\n @poll_question = PollQuestion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poll_question }\n end\n end", "def completed_polls\n Poll.find_by_sql([<<-SQL, self.id])\n SELECT\n polls.*\n FROM\n responses\n JOIN\n answer_choices ON responses.answer_choice_id = answer_choices.id\n RIGHT JOIN\n questions ON answer_choices.question_id = questions.id\n JOIN\n polls ON questions.poll_id = polls.id\n WHERE\n responses.user_id = ? OR responses.user_id IS NULL\n GROUP BY\n polls.id\n HAVING\n COUNT(*) = COUNT(answer_choices.id)\n SQL\n end", "def set_poll_answer\n @poll_answer = PollAnswer.find(params[:id])\n end", "def response_params\n params.require(:response).permit(\n :ip, \n :survey_id, \n :answers_attributes => [\n :id, \n :answer, \n {:resp => []}, \n :survey_id, \n :question_id, \n :response_id, \n :user_id \n ])\n end", "def poll_params\n params.require(:poll).permit(:user_id, :question, :token, :multi, :public, \n options_attributes: [:id, :name, :_destroy])\n end", "def create\n @survey_question_response = SurveyQuestionResponse.new(survey_question_response_params)\n respond_to do |format|\n if @survey_question_response.save\n format.html { redirect_to @survey_question_response, notice: 'Survey question response was successfully created.' }\n format.json { render :show, status: :created, location: @survey_question_response }\n else\n format.html { render :new }\n format.json { render json: @survey_question_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def response_params\n params.require(:response).permit(:user_id, :issue_id, :answer, :timestamp)\n end", "def create\n @question_response = QuestionResponse.new(params[:question_response])\n\n respond_to do |format|\n if @question_response.save\n format.html { redirect_to @question_response, notice: 'Question response was successfully created.' }\n format.json { render json: @question_response, status: :created, location: @question_response }\n else\n format.html { render action: \"new\" }\n format.json { render json: @question_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def webhook_response\n # if get request, checks if it is the subscription call\n # if it is, echoes back the hub.challenge token\n if request.get?\n params = request.query_parameters\n\n if params['hub.mode'] == 'subscribe' && params['hub.verify_token'] == ENV['VERIFICATION_TOKEN']\n render json: { 'hub.challenge': params['hub.challenge'] }, status: :ok\n else\n raise 'Bad Request'\n end\n\n # if post request, checks if it is an activity creation post\n elsif request.post?\n params = request.request_parameters\n\n if params['object_type'] == 'activity' && params['aspect_type'] == 'create'\n # potentially should make it only change if the name is one of the default ones, so custom names won't be overriden\n this_user = User.find(params['owner_id'])\n this_user.update_user_token!(@client)\n\n user_client = this_user.generate_user_client\n\n updated_activity = user_client.update_activity(\n id: params['object_id'],\n name: Quote.order(\"RANDOM()\").first.format_quote\n )\n render json: {}, status: :ok\n else\n render json: {}, status: :ok\n end\n else\n raise 'Bad Request'\n end\n end", "def new\n @poll = Poll.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poll }\n end\n end", "def new\n @poll = Poll.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poll }\n end\n end", "def responses\n {\n 'multiple_choice_answers' => self.multiple_choice_answers,\n 'open_response_answers' => self.open_response_answers,\n 'image_question_answers' => self.image_question_answers,\n 'external_links' => self.interactive_run_states\n }\n end", "def destroy\n @question_poll.destroy\n respond_to do |format|\n format.html { redirect_to question_polls_url }\n format.json { head :no_content }\n end\n end", "def answer_poll(id, opts = {})\n data, _status_code, _headers = answer_poll_with_http_info(id, opts)\n return data\n end", "def add_response(json_response)\n\t\tself.responses << json_response\n\t\tyield if block_given?\n\tend", "def create\n @survey_response = SurveyResponse.new(survey_response_params)\n\n respond_to do |format|\n if @survey_response.save\n format.html { redirect_to @survey_response, notice: 'Survey response was successfully created.' }\n format.json { render :show, status: :created, location: @survey_response }\n else\n format.html { render :new }\n format.json { render json: @survey_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @survey_response = SurveyResponse.new(params[:survey_response])\r\n\r\n respond_to do |format|\r\n if @survey_response.save\r\n format.html { redirect_to @survey_response, notice: 'Survey response was successfully created.' }\r\n format.json { render json: @survey_response, status: :created, location: @survey_response }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @survey_response.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def _poll_server\n server_uri = @config.get(PROVISIONER_SERVER_URI)\n poll_error_interval = @config.get(PROVISIONER_WORKER_POLL_ERROR_INTERVAL).to_i || 10\n postdata = { 'provisionerId' => @provisioner_id, 'workerId' => @worker_id, 'tenantId' => @tenant }.to_json\n loop do\n begin\n response = Coopr::RestHelper.post \"#{server_uri}/v2/tasks/take\", postdata\n break response\n rescue StandardError => e\n log.error \"Unable to connect to Coopr Server #{server_uri}/v2/tasks/take: #{e}\"\n sleep poll_error_interval\n end\n end\n end", "def submit\n self.http_get(self.poll_url)#.tap{|t| STDERR.puts \"Trace: #{caller[1]}: returning #{t}\"}\n end", "def process_response(new_response)\n responses.push(new_response)\n responses.shift if responses.size > 5\n responses\n end", "def create\n @user = User.find_or_create_by_id(params[:participant_id], group: params[:group])\n @response = @user.responses.find_or_create_by_error_and_round_number(params[:response][:id], params[:response][:round_number])\n @response.update_attributes(params[:response])\n\n respond_to do |format|\n if @response.save\n format.js\n format.html { redirect_to(@response, notice: 'Response was successfully created.') }\n format.xml { render xml: @response, status: :created, location: @response }\n\n else\n format.js { render js: \"#{ @response.errors}\" }\n format.html { render action: 'new' }\n format.xml { render xml: @response.errors, status: :unprocessable_entity }\n\n end\n end\n end", "def poll_params\n params.require(:poll).permit(:name, :email, :sexo, :edad, :question1, :question2,:question3, \n :question4,\n :question5,\n :question6,\n :question7,\n :question8,\n :question9,\n :question10,\n :question11,\n :question12,\n :question13,\n :question14,\n :question15,\n :question16,\n :question17,\n :question18,\n :question19,\n :question20,\n :question21,\n :question22,\n :question23,\n :question24,\n :question25,\n :question26,\n :question27,\n :question28,\n :question29,\n :question30,\n :question31,\n :question32,\n :question33,\n :question34,\n :question35,\n :question36,\n :question37,\n :question38\n )\n end", "def create \n\t\tquestionId = params[:questionId]\n\t\tanswerId = params[:answerId]\n\t\tanswer = params[:answer]\n\t\tnumAnswers = params[:numAnswers].to_i\n\n\t\tbegin\n\t\t\tsuccess = ParseManager.createUserAnswer(answer, answerId, questionId)\n\t\t\tnumAnswers -= 1\n\t\tend until numAnswers == 0\n\n\t\trender json:success\n\tend", "def create_response\n\t\t@response = Response.create(player_id: current_player.id, option_id: params[:option])\n\t\t@question = @response.option.question\n\t\t@total_questions = @question.artist.questions.count\n\t\t@answered = params[:correct].to_i\n\t\tif (@response.option.correct) && (@answered < @total_questions) \n\t\t\t@answered += 1\n\t\t\tredirect_to category_artist_path(last_question: @question.id, correct: @answered,\n\t\t\tcategory_id: @question.artist.category.id, id: @question.artist.id)\n\t\telsif @response.option.correct\n\t\t\tredirect_to category_path(@question.artist.category)\n\t\telse\n\t\t\tartist = @response.option.question.artist\n\t\t\tredirect_to category_path(artist.category), notice: \"Sorry try again!\"\n\t\tend\n\tend", "def set_pollanswer\n @pollanswer = Pollanswer.find(params[:id])\n end", "def userpoll_params\n params.require(:userpoll).permit(:poll_id, {:answers_attributes => [:slider, :question_id]})\n end", "def create\n @poll_option = PollOption.new(params[:poll_option])\n @poll_option.votes = 0\n\n respond_to do |format|\n if @poll_option.save\n format.html { redirect_back_or_default :controller => \"polls\", :action => :vote_first, :id => params[:poll_option][:poll_id]}\n format.xml { render :xml => @poll_option, :status => :created, :location => @poll_option }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @poll_option.errors, :status => :unprocessable_entity }\n end\n end\n end", "def save_user_responses(resp)\n @response = Response.find(resp[:id])\n @question = @response.question\n resp_val_string = Response::EMPTY_RESPONSE_VALUE\n if (@question.question_type == Question::TYPES['short_answer'])\n resp_val_string = resp[:response_value]\n elsif (@question.question_type == Question::TYPES['multiple_choice'] || @question.question_type == Question::TYPES['scale'])\n # look through the multiple choice options and see which one is selected\n # note: for now these are implemented in the same way. in the future, scale may be a slider.\n resp_val_string = resp[:response_value]\n elsif (@question.question_type == Question::TYPES['multiple_select'])\n # look through the multiple select options and see which one(s) are selected\n\t @option_count = 0\n\t @option_arr = []\n\t while(@option_count < @response.question.question_options.length)\n\t\tputs \"** OPTION \" + @option_count.to_s + \" ***\"\n\t\t@index = @option_count.to_s\n\t\tif(resp[\"response_values\"][@index] != \"\")\n\t\t\t@option_arr << resp[\"response_values\"][@index]\n\t\tend\n\t\t@option_count += 1\n\t end\n resp_val_string = @option_arr.join(\",\")\n end\n \n puts \"RESPONSE VALUE STRING: #{resp_val_string}\"\n \n if (resp_val_string == \"\")\n return false\n else\n # update the stuff here\n @response.response_value = resp_val_string\n @response.save!\n return true\n end\n end", "def update\n respond_to do |format|\n if @api_v1_groups_poll.update(api_v1_groups_poll_params)\n format.html { redirect_to @api_v1_groups_poll, notice: 'Groups poll was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_groups_poll }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_groups_poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n passed = true\n count = 0\n if params[:status] == \"listOfAnswers\"\n params[:answers].each do |ans|\n @answer = Answer.new(answers_params(ans))\n if @answer.save\n if @answer.correct\n count = count + 1\n # update_result ans[:user_id], ans[:quiz_id]\n end\n else\n passed = false\n end\n end\n if passed\n create_result params[:answers].first[:user_id], params[:answers].first[:quiz_id], count\n render json: @answer, status: :created, location: @answer\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n else\n @answer = Answer.new(answer_params)\n if @answer.save\n if @answer.correct\n update_result\n end\n render json: @answer, status: :created, location: @answer\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n end\n end", "def do_poll\n\t\tstatus_lamp\n\t\tstatus_input\n\t\tprojector_information\n\t\tstatus_error\n\tend", "def handle_post(body)\n make_response(200, validate_questions(body))\nend", "def parse_response(body)\n # Handling first response\n if INITIAL_FEELINGS.include? body\n @answers.push(body)\n create_response(create_second_text_message(body))\n # Handling second response\n elsif FOLLOWUP_FEELINGS.include? body\n @answers.push(body)\n if (@answers.length >= 1)\n create_response(\"Feel #{@answers[0]} and #{@answers[1]} throughout the day!\")\n else\n create_response(\"Empower youself with these feelings throughout the day. You can do it.\")\n end\n else\n create_response(\"We're not sure how to reply, please follow up with a valid feeling.\")\n end\n end" ]
[ "0.65801", "0.62844723", "0.60589164", "0.6054359", "0.6022208", "0.59708434", "0.59641784", "0.5954258", "0.5930939", "0.5907393", "0.59044474", "0.5894023", "0.5887609", "0.58723444", "0.58723444", "0.580967", "0.5809335", "0.5786081", "0.5779321", "0.57725215", "0.5757535", "0.574749", "0.57246685", "0.57104576", "0.570801", "0.57038563", "0.5699843", "0.56693965", "0.5666832", "0.5665566", "0.56634194", "0.5636723", "0.56012154", "0.5587708", "0.5539853", "0.5538899", "0.553835", "0.55282056", "0.5523412", "0.5511941", "0.5494664", "0.5494028", "0.5493813", "0.54781336", "0.5460353", "0.5447852", "0.54363704", "0.5428082", "0.5393886", "0.5379642", "0.5376777", "0.537023", "0.5362132", "0.5357598", "0.53348905", "0.5333539", "0.5304624", "0.5302584", "0.5297251", "0.5271612", "0.5264891", "0.5262466", "0.52483773", "0.523561", "0.5229842", "0.5223492", "0.52169764", "0.5201168", "0.5200761", "0.51907784", "0.51871055", "0.51818985", "0.51799226", "0.5175029", "0.5175014", "0.5165455", "0.51614296", "0.51614296", "0.5159271", "0.5131352", "0.512739", "0.5124072", "0.5121003", "0.5120838", "0.51187044", "0.511443", "0.5105146", "0.5100591", "0.5099033", "0.5095725", "0.50955826", "0.5095234", "0.5093925", "0.50922525", "0.5087405", "0.5086531", "0.50793266", "0.5076518", "0.50688624", "0.5065776" ]
0.70459193
0
PATCH/PUT /api/v1/poll_responses/1 PATCH/PUT /api/v1/poll_responses/1.json
def update respond_to do |format| if @api_v1_poll_response.update(api_v1_poll_response_params) format.html { redirect_to @api_v1_poll_response, notice: 'Poll response was successfully updated.' } format.json { render :show, status: :ok, location: @api_v1_poll_response } else format.html { render :edit } format.json { render json: @api_v1_poll_response.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_single_poll(id,polls__question__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :polls__question__,\n :polls__description__,\n \n ]\n\n # verify existence of params\n raise \"id is required\" if id.nil?\n raise \"polls__question__ is required\" if polls__question__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :id => id,\n :polls__question__ => polls__question__\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{id}\",\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end", "def update\n respond_to do |format|\n if @api_v1_groups_poll.update(api_v1_groups_poll_params)\n format.html { redirect_to @api_v1_groups_poll, notice: 'Groups poll was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_groups_poll }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_groups_poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question_poll.update(question_poll_params)\n format.html { redirect_to @question_poll}\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question_poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n \n if @poll.update(poll_params)\n format.html { redirect_to polls_url, notice: 'Poll was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render 'edit' }\n format.json { render json: @poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @mypoll.update(mypoll_params)\n format.html { redirect_to @mypoll, notice: 'Mypoll was successfully updated.' }\n format.json { render :show, status: :ok, location: @mypoll }\n else\n format.html { render :edit }\n format.json { render json: @mypoll.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @poll = Poll.find(params[:id])\n\n respond_to do |format|\n if @poll.update_attributes(params[:poll])\n format.html { redirect_to @poll, notice: 'Poll was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @poll = Poll.find(params[:id])\n\n respond_to do |format|\n if @poll.update_attributes(params[:poll])\n format.html { redirect_to @poll, notice: 'Poll was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @poll.update(poll_params)\n format.html { redirect_to @poll, notice: 'Poll was successfully updated.' }\n format.json { render :show, status: :ok, location: @poll }\n else\n format.html { render :edit }\n format.json { render json: @poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @poll.update(poll_params)\n format.html { redirect_to @poll, notice: 'Poll was successfully updated.' }\n format.json { render :show, status: :ok, location: @poll }\n else\n format.html { render :edit }\n format.json { render json: @poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @poll.update(poll_params)\n format.html { redirect_to @poll, notice: 'Poll was successfully updated.' }\n format.json { render :show, status: :ok, location: @poll }\n else\n format.html { render :edit }\n format.json { render json: @poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @poll.update(poll_params)\n format.html { redirect_to polls_url, notice: 'Poll was successfully updated.' }\n format.json { render :show, status: :ok, location: @poll }\n else\n format.html { render :edit }\n format.json { render json: @poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n # {:name => poll_params[:name]}\n if @poll.update(poll_params)\n format.html { redirect_to admin_path(@poll), notice: 'Poll was successfully updated.' }\n format.json { render :show, status: :ok, location: admin_path(@poll) }\n else\n format.html { render :edit }\n format.json { render json: @poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @poll_question.update(poll_question_params)\n format.html { redirect_to @poll_question, notice: 'Poll question was successfully updated.' }\n format.json { render :show, status: :ok, location: @poll_question }\n else\n @polls = Poll.all\n format.html { render :edit }\n format.json { render json: @poll_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_api_v1_poll_response\n @api_v1_poll_response = Api::V1::PollResponse.find(params[:id])\n end", "def update\n respond_to do |format|\n if @poll_option.update(poll_option_params)\n format.html { redirect_to [:admin, @poll_option], notice: 'Poll option was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @poll_option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @simple_responses = args[:simple_responses] if args.key?(:simple_responses)\n end", "def update!(**args)\n @simple_responses = args[:simple_responses] if args.key?(:simple_responses)\n end", "def update\n @poll_options_set = PollOptionsSet.find(params[:id])\n\n respond_to do |format|\n if @poll_options_set.update_attributes(params[:poll_options_set])\n format.html { redirect_to @poll_options_set, notice: 'Poll options set was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @poll_options_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @poll.type_poll_id = params[:type_poll_id]\n respond_to do |format|\n\n if @poll.update(descripcion: poll_params[:descripcion], type_poll_id: params[:type_poll_id])\n @questions= params[:questions]\n if (@questions)\n @question_polls = QuestionPoll.where(poll_id: @poll.id)\n @question_polls.each do |question_poll|\n question_poll.destroy\n end\n @questions.each do |question_id|\n QuestionPoll.create(poll_id: @poll.id, question_id: question_id)\n end\n else\n @collections = Collection.all\n format.html { render '/postulates/chequeo', notice: 'Debe seleccionar por lo menos un recaudo' }\n end\n format.html { redirect_to '/polls' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n\n end\n\n end", "def update\n @poll_question = PollQuestion.find(params[:id])\n\n respond_to do |format|\n if @poll_question.update_attributes(params[:poll_question])\n format.html { redirect_to @poll_question, notice: 'Poll question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @poll_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @vote_poll.update(vote_poll_params)\n format.html { redirect_to define_admin_routes({resourceName: 'VotePoll', objectId: @vote_poll.id}), notice: 'PollVote was successfully updated.' }\n # format.html { redirect_to @vote_poll, notice: 'Vote poll was successfully updated.' }\n format.json { render :show, status: :ok, location: @vote_poll }\n else\n format.html { render :edit }\n format.json { render json: @vote_poll.errors, status: :unprocessable_entity }\n end\n\n end\n end", "def update_poll_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.update_poll ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling MediaPollsApi.update_poll\"\n end\n # resource path\n local_var_path = \"/media/polls/{id}\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'poll_resource'])\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'PollResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaPollsApi#update_poll\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n respond_to do |format|\n if @pollanswer.update(pollanswer_params)\n format.html { redirect_to @pollanswer, notice: 'Pollanswer was successfully updated.' }\n format.json { render :show, status: :ok, location: @pollanswer }\n else\n format.html { render :edit }\n format.json { render json: @pollanswer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @poll_answer = Poll.find(params[:id])\n @poll_answer.update_attributes(poll_answer_params)\n @poll = @poll_answer.poll\n end", "def update\n respond_to do |format|\n if @listings_poll.update(listings_poll_params)\n format.html { redirect_to @listings_poll, notice: 'Listings poll was successfully updated.' }\n format.json { render :show, status: :ok, location: @listings_poll }\n else\n format.html { render :edit }\n format.json { render json: @listings_poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @user_poll.update(user_poll_params)\n format.html { redirect_to @user_poll, notice: 'User poll was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_poll }\n else\n format.html { render :edit }\n format.json { render json: @user_poll.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_single_poll_choice(poll_id,id,poll_choices__text__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :poll_choices__text__,\n :poll_choices__is_correct__,\n :poll_choices__position__,\n \n ]\n\n # verify existence of params\n raise \"poll_id is required\" if poll_id.nil?\n raise \"id is required\" if id.nil?\n raise \"poll_choices__text__ is required\" if poll_choices__text__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :poll_id => poll_id,\n :id => id,\n :poll_choices__text__ => poll_choices__text__\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{poll_id}/poll_choices/{id}\",\n :poll_id => poll_id,\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end", "def update\n @poll = Poll.find(params[:id])\n\n respond_to do |format|\n if @poll.update_attributes(params[:poll])\n format.html { redirect_to([:admin, @poll], :notice => 'Poll was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @poll.errors, :status => :unprocessable_entity }\n end\n end\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def update\n params[:poll_question][:active] = params[:poll_question][:active].present?\n params[:poll_question][:existing_poll_option_attributes] ||= {}\n\n @poll_question.attributes = params[:poll_question]\n\n respond_to do |format|\n if @commit_type == 'preview' && @poll_question.valid?\n format.html { render template: 'admin/shared/update_preview', locals: { record: @poll_question }, layout: 'admin/admin_preview' }\n format.xml { render xml: @poll_question, status: :created, location: @poll_question }\n elsif @commit_type == 'save' && @poll_question.save(user: current_user)\n format.html do\n @refresh = true\n render 'admin/shared/update'\n end\n format.xml { head :ok }\n else\n format.html { render action: :edit }\n format.xml { render xml: @poll_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def update\n @poll = Poll.find_by_admin_key(params[:key])\n @poll.poll_options ||= PollOptions.new\n @poll.poll_options.enable_captcha = params[:enable_captcha]\n @poll.candidates = posted_candidates\n\n respond_to do |format|\n @poll.poll_options.save\n if @poll.update_attributes(params[:poll])\n flash[:notice] = 'Poll was successfully updated.'\n format.html { redirect_to(:action => :admin, :key => @poll.admin_key) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @poll.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @poll_option = PollOption.find(params[:id])\n\n respond_to do |format|\n if @poll_option.update_attributes(params[:poll_option])\n format.html { redirect_to(@poll_option, :notice => 'PollOption was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @poll_option.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n poll_parameters = params[:poll]\n \n # Set page publication time, if any\n options = {}\n unless params[:have_publish_time]\n poll_parameters.each do |key, val|\n poll_parameters.delete(key) if key.include?(\"published_at\")\n end\n end\n \n # Set page expiration, if any\n unless params[:poll][:can_expire] == \"1\" || params[:poll][:can_expire] == \"on\"\n poll_parameters.each do |key, val|\n poll_parameters.delete(key) if key.include?(\"expires_at\")\n end\n end\n \n # Merge the options back and update the poll\n poll_parameters.merge!( options )\n\n#\t\t@post.tag!( params[:main_tags], params[:tags] || \"\" ) if params[:main_tags]\n\t\t\n \tif @poll.update_attributes( params[:poll] )\n#\t \t@poll.update_route({:key => @poll.route_key}) unless @poll.route_match?(@poll.route_key)\n \t flash[:notice] = _('A szavazást elmentettem, a változtatásaid rögzítésre kerültek.')\n \t redirect_to :back\n \telse\n \t render :action => params[:render_action] || :edit\n \tend\n end", "def update_poll_template_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.update_poll_template ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling MediaPollsApi.update_poll_template\"\n end\n # resource path\n local_var_path = \"/media/polls/templates/{id}\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'poll_template_resource'])\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TemplateResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaPollsApi#update_poll_template\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update\n respond_to do |format|\n if @response.update(response_params)\n format.html { redirect_to survey_response_path(params[:survey_id], @response.id), notice: 'Response was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_attributes(attributes = {}, user)\n Rails.logger.debug \"Call to poll.update_attributes\"\n self.answers=Util.arraystring_to_csv(attributes[:answers])\n if self.valid? #Validate if the Poll object is valid\n Rails.logger.debug \"The poll is valid!\"\n #Create a raw poll object\n poll_req = { 'question'=>attributes[:question],\n 'answers'=>Util.arraystring_to_csv(attributes[:answers]),#Turn the answers array in string form to a comma separated string\n 'start'=> Util.date_to_epoch(attributes[:start_date]), #Turn the start_date to epoch\n 'duration'=> attributes[:duration].to_i*60000, #Turn minutes to milliseconds\n 'ownerId'=> self.owner_id,\n 'creatorId'=> self.creator_id,\n } \n reqUrl = \"/api/poll/#{self.id}\" #Set the request url\n rest_response = MwHttpRequest.http_put_request(reqUrl,poll_req,user['email'],user['password']) #Make the PUT call to the server with the required parameters\n Rails.logger.debug \"Response from server: #{rest_response.code} #{rest_response.message}: #{rest_response.body}\"\n if rest_response.code == \"200\" #Validate if the response from the server is 200, which means OK\n poll = Poll.rest_to_poll(rest_response.body)\n return true, poll #Return success\n else\n return false, \"#{rest_response.code}\", \"#{rest_response.message}\" #Return error\n end\n else\n Rails.logger.debug self.errors.full_messages\n return false, self.errors.full_messages #Return invalid object error\n end\n end", "def update\n respond_with []\n end", "def update\n id = params[:id]\n unless is_number? id\n token = id\n decode_t = decode_link token\n id = decode_t[0]['id']\n end\n\n @opinion_poll = OpinionPoll.find(id)\n\n if @opinion_poll.update(opinion_params)\n return ok_request @opinion_poll\n else\n return bad_request @opinion_poll.errors\n end\n\n rescue ActiveRecord::RecordNotFound\n r = {opinion_poll: 'Record Not Found'}\n return not_found r\n end", "def update\n @quick_poll_option = QuickPollOption.find(params[:id])\n\n respond_to do |format|\n if @quick_poll_option.update_attributes(params[:quick_poll_option])\n format.html { redirect_to @quick_poll_option, notice: 'Quick poll option was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quick_poll_option.errors, status: :unprocessable_entity }\n end\n end\n end", "def partial_update(klass, id, patchset, options = {}, format = nil)\n headers = {}\n headers[:accept] = \"#{format}\" if format\n format ||= @default_format\n options = { resource: klass, id: id, format: format}.merge options\n if [FHIR::Formats::ResourceFormat::RESOURCE_XML, FHIR::Formats::ResourceFormat::RESOURCE_XML_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_XML\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_XML}\"\n elsif [FHIR::Formats::ResourceFormat::RESOURCE_JSON, FHIR::Formats::ResourceFormat::RESOURCE_JSON_DSTU2].include?(format)\n options[:format] = FHIR::Formats::PatchFormat::PATCH_JSON\n headers[:content_type] = \"#{FHIR::Formats::PatchFormat::PATCH_JSON}\"\n end\n headers[:prefer] = @return_preference if @use_return_preference\n reply = patch resource_url(options), patchset, fhir_headers(headers)\n reply.resource = parse_reply(klass, format, reply)\n reply.resource_class = klass\n reply\n end", "def update\n @poll = Poll.find(@pollitem.poll_id)\n respond_to do |format|\n if @pollitem.update(pollitem_params)\n format.html { redirect_to @pollitem, notice: 'Pollitem was successfully updated.' }\n format.json { render :show, status: :ok, location: @pollitem }\n format.js\n else\n format.html { render :edit }\n format.json { render json: @pollitem.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @survey_choice = Survey::Choice.find(params[:id])\n\n respond_to do |format|\n if @survey_choice.update_attributes(params[:survey_choice])\n format.html { redirect_to @survey_choice, notice: 'Choice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey_choice.errors, status: :unprocessable_entity }\n5 end\n end\n end", "def update\n respond_to do |format|\n if @pol.update(pol_params)\n format.json { render :show, status: :ok, location: @pol }\n else\n format.json { render json: @pol.errors, status: :unprocessable_entity }\n end\n end\n end", "def answer_poll_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.answer_poll ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling MediaPollsApi.answer_poll\"\n end\n # resource path\n local_var_path = \"/media/polls/{id}/response\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(opts[:'answer_key'])\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\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 => 'PollResponseResource')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MediaPollsApi#answer_poll\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def update!(**args)\n @list_update_responses = args[:list_update_responses] if args.key?(:list_update_responses)\n @minimum_wait_duration = args[:minimum_wait_duration] if args.key?(:minimum_wait_duration)\n end", "def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end", "def update\n @survey = Survey.find(params[:id])\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n\n respond_to do |format|\n if @survey.update_attributes(json)\n format.html { redirect_to @survey, notice: 'Survey was successfully updated.' }\n format.json { render json: @survey }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_mod\n if params[:title] != nil && params[:content] != nil\n @question.title = params[:title]\n @question.content = params[:content]\n\n question_json = @question.to_h.to_json\n\n url = @httpIp+'/pet.com/api/question/updateQuestion'\n uri = URI(url)\n res = Net::HTTP.post(uri, question_json, \"Content-Type\" => \"application/json\")\n puts res.body\n flash[:notice] = \"successfully updated\"\n redirect_to questions_path\n end\n end", "def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end", "def update\n appointment_request = current_user.pending_requests.find(\n params[:request_id]\n )\n\n case params[:answer]\n when 'accept'\n if appointment_request.accept!\n redirect_to root_path\n else\n render status: 500\n end\n when 'reject'\n if appointment_request.reject!\n redirect_to root_path\n else\n render status: 500\n end\n else\n render json: { appointment_request: appointment_request, status: 200 }\n end\n end", "def api_v1_poll_response_params\n params.fetch(:api_v1_poll_response, {})\n end", "def update\n respond_to do |format|\n @requirement_id = response_params[:requirement_id]\n @next_requirement_id = params[:next_requirement_id]\n @plan = Plan.find(response_params[:plan_id])\n @requirement = Requirement.find(@requirement_id)\n template_id = @plan.requirements_template_id\n @requirements_template = RequirementsTemplate.find(template_id)\n\n unless @requirements_template.nil?\n @requirements = @requirements_template.requirements\n @last_question = @requirements_template.last_question\n end\n\n if ( params[:save_and_next] == nil && params[:save_only] == nil && params[:save_on_preview] == \"true\")\n if @response.update(response_params)\n @response.plan.touch unless @response.previous_changes.blank?\n format.html { redirect_to preview_plan_path(@plan), notice: 'Response has been updated' }\n format.json { head :no_content }\n else\n if response_params[:text_value].blank?\n @response.destroy\n end\n format.html { redirect_to preview_plan_path(@plan) }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n\n elsif ( !params[:save_and_next] && !params[:save_only]) && (@requirement.id == @last_question.id)\n if @response.update(response_params)\n @response.plan.touch unless @response.previous_changes.blank?\n format.html { redirect_to details_plan_path(@plan, requirement_id: @next_requirement_id) }\n format.json { head :no_content }\n else\n if response_params[:text_value].blank?\n @response.destroy\n end\n format.html { redirect_to details_plan_path(@plan, requirement_id: @next_requirement_id) }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n\n elsif (params[:save_and_next] || !params[:save_only]) && (@requirement.id == @last_question.id)\n if @response.update(response_params)\n @response.plan.touch unless @response.previous_changes.blank?\n format.html { redirect_to preview_plan_path(@plan) }\n format.json { head :no_content }\n else\n if response_params[:text_value].blank?\n @response.destroy\n end\n format.html { redirect_to preview_plan_path(@plan) }\n format.json { head :no_content }\n end\n\n elsif (params[:save_and_next] || !params[:save_only])\n if @response.update(response_params)\n if @response.previous_changes.blank?\n format.html { redirect_to details_plan_path(@plan, requirement_id: @next_requirement_id) }\n format.json { render action: 'show', status: :created, location: @response }\n else\n @response.plan.touch\n format.html { redirect_to details_plan_path(@plan, requirement_id: @next_requirement_id), notice: 'Response was successfully updated.' }\n format.json { render action: 'show', status: :created, location: @response }\n end\n else\n if response_params[:text_value].blank?\n @response.destroy\n end\n format.html { redirect_to details_plan_path(@plan, requirement_id: @next_requirement_id) }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n\n else\n if @response.update(response_params)\n if @response.previous_changes.blank?\n format.html { redirect_to details_plan_path(@plan, requirement_id: @requirement_id) }\n format.json { head :no_content }\n else\n @response.plan.touch\n format.html { redirect_to details_plan_path(@plan, requirement_id: @requirement_id), notice: 'Response was successfully updated.' }\n format.json { head :no_content }\n end\n else\n if response_params[:text_value].blank?\n @response.destroy\n end\n format.html { redirect_to details_plan_path(@plan, requirement_id: @requirement_id) }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n end\n end\n\n rescue ActiveRecord::StaleObjectError\n flash[:error] = \"This record changed while you were editing.\"\n redirect_to details_plan_path(@plan, requirement_id: @requirement_id)\n\n end", "def set_poll\r\n @poll = Poll.find(params[:id])\r\n end", "def update\n @response = Response.find(params[:id])\n\n respond_to do |format|\n if @response.update_attributes(params[:response])\n if @response.run && @response.run.return_url\n # send the data back to the portal\n data = [{\n \"type\" => \"open_response\",\n \"question_id\" => \"1\",\n \"answer\" => params[:response][:answer]\n }]\n bearer_token = 'Bearer %s' % current_user.token\n HTTParty.post(@response.run.return_url, :body => data.to_json, :headers => {\"Authorization\" => bearer_token, \"Content-Type\" => 'application/json'})\n end\n format.html { redirect_to @response, notice: 'Response was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n end\n end", "def update # PATCH\n raise NotImplementedError\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_poll\n @poll = Poll.find(params[:id])\n end", "def set_api_v1_groups_poll\n @api_v1_groups_poll = Api::V1::GroupsPoll.find(params[:id])\n end", "def update\n @survey_response = SurveyResponse.find(params[:id])\n\n respond_to do |format|\n if @survey_response.update_attributes(params[:survey_response])\n format.html { redirect_to survey_survey_responses_path(params[:survey_id]), notice: 'Survey response was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @api_v1_poll_responses = Api::V1::PollResponse.all\n end", "def update\n @question_response = QuestionResponse.find(params[:id])\n\n respond_to do |format|\n if @question_response.update_attributes(params[:question_response])\n format.html { redirect_to @question_response, notice: 'Question response was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n streak, success = jsonapi_update.to_a\n\n if success\n render_jsonapi(streak, scope: false)\n else\n render_errors_for(streak)\n end\n end", "def set_question_poll\n @question_poll = QuestionPoll.find(params[:id])\n end", "def create_single_poll(polls__question__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :polls__question__,\n :polls__description__,\n \n ]\n\n # verify existence of params\n raise \"polls__question__ is required\" if polls__question__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :polls__question__ => polls__question__\n )\n\n # resource path\n path = path_replace(\"/v1/polls\",\n )\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:post, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:post, path, query_params, form_params, headers)\n page_params_store(:post, path)\n response\n \n end", "def update\n @response = Admin::Response.find(params[:id])\n\n respond_to do |format|\n if @response.update_attributes(params[:admin_response])\n format.html { redirect_to @response, notice: 'Response was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n end\n end", "def http_prop_patch(request, response)\n path = request.path\n\n begin\n prop_patch = @server.xml.expect('{DAV:}propertyupdate', request.body)\n rescue Tilia::Xml::ParseException => e\n raise Exception::BadRequest, e.message, nil, e\n end\n\n new_properties = prop_patch.properties\n\n result = @server.update_properties(path, new_properties)\n\n prefer = @server.http_prefer\n response.update_header('Vary', 'Brief,Prefer')\n\n if prefer['return'] == 'minimal'\n # If return-minimal is specified, we only have to check if the\n # request was succesful, and don't need to return the\n # multi-status.\n ok = true\n result.each do |_prop, code|\n ok = false if code.to_i > 299\n end\n\n if ok\n response.status = 204\n return false\n end\n end\n\n response.status = 207\n response.update_header('Content-Type', 'application/xml; charset=utf-8')\n\n # Reorganizing the result for generateMultiStatus\n multi_status = {}\n result.each do |property_name, code|\n if multi_status.key?(code)\n multi_status[code][property_name] = nil\n else\n multi_status[code] = { property_name => nil }\n end\n end\n multi_status['href'] = path\n\n response.body = @server.generate_multi_status([multi_status])\n\n # Sending back false will interupt the event chain and tell the server\n # we've handled this method.\n false\n end", "def update\r\n @survey_response = SurveyResponse.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @survey_response.update_attributes(params[:survey_response])\r\n format.html { redirect_to @survey_response, notice: 'Survey response 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: @survey_response.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update_single_poll_session(poll_id,id,poll_sessions__course_id__,poll_sessions__course_section_id__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :poll_sessions__course_id__,\n :poll_sessions__course_section_id__,\n :poll_sessions__has_public_results__,\n \n ]\n\n # verify existence of params\n raise \"poll_id is required\" if poll_id.nil?\n raise \"id is required\" if id.nil?\n raise \"poll_sessions__course_id__ is required\" if poll_sessions__course_id__.nil?\n raise \"poll_sessions__course_section_id__ is required\" if poll_sessions__course_section_id__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :poll_id => poll_id,\n :id => id,\n :poll_sessions__course_id__ => poll_sessions__course_id__,\n :poll_sessions__course_section_id__ => poll_sessions__course_section_id__\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{poll_id}/poll_sessions/{id}\",\n :poll_id => poll_id,\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end", "def update\n render_json_auto @survey.update_logic_control_rule(params[:id].to_i, params[:logic]) and return\n end", "def update\n def answer_given(question_id)\n return (params[:answer] and params[:answer][question_id.to_s] and\n params[:answer][question_id.to_s].length > 0)\n end\n \n @resp = Response.find(params[:id])\n\n @questionnaire.questions.each do |question|\n if question.kind_of? Questions::Field\n ans = Answer.find_answer(@resp, question)\n if answer_given(question.id)\n if ans.nil?\n ans = Answer.new :question_id => question.id, :response_id => @resp.id\n end\n ans.value = params[:answer][question.id.to_s]\n ans.save\n else\n # No answer provided\n if not ans.nil?\n ans.destroy\n end\n end\n end\n end\n\n respond_to do |format|\n if @resp.update_attributes(params[:response])\n format.html { redirect_to(response_url(@questionnaire, @resp)) }\n format.js { redirect_to(response_url(@questionnaire, @resp, :format => \"js\")) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.js { render :action => \"edit\" }\n format.xml { render :xml => @resp.errors, :status => :unprocessable_entity }\n end\n end\n end", "def patch\n end", "def update\n respond_to do |format|\n if @api_v1_question.update(api_v1_question_params)\n format.html { redirect_to @api_v1_question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_question }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @v1_question.update(v1_question_params)\n render json: @v1_question, status: :ok\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end", "def create\n @api_v1_poll_response = Api::V1::PollResponse.new(api_v1_poll_response_params)\n\n respond_to do |format|\n if @api_v1_poll_response.save\n format.html { redirect_to @api_v1_poll_response, notice: 'Poll response was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_poll_response }\n else\n format.html { render :new }\n format.json { render json: @api_v1_poll_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def patch options\n rest_request({ method: :patch }.merge(options))\n end", "def update\n respond_to do |format|\n if @offer.update(offers_params)\n format.jsonapi { render :show, status: :ok, location: @offer }\n else\n format.jsonapi { render jsonapi: @offer.errors, status: :unprocessable_entity }\n end\n end\n end", "def pollanswer_params\n params.require(:pollanswer).permit(:pollquestion_id, :option, :status)\n end", "def update_correct_answer\n question_params = params.permit(:question_id, :question_type_id, :option_id)\n \n render json: Question.update_correct_option(question_params)\n end", "def update\n respond_to do |format|\n if @response.update(response_params)\n format.html { redirect_to @response, notice: 'Response was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @response.update(response_params)\n format.html { redirect_to @response, notice: 'Response was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @response.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_single_poll(id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"id is required\" if id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :id => id\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{id}\",\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response\n \n end", "def set_poll_answer\n @poll_answer = PollAnswer.find(params[:id])\n end", "def update\n respond_to do |format|\n if @survey_question_response.update(survey_question_response_params)\n format.html { redirect_to @survey_question_response, notice: 'Survey question response was successfully updated.' }\n format.json { render :show, status: :ok, location: @survey_question_response }\n else\n format.html { render :edit }\n format.json { render json: @survey_question_response.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @poll = Poll.find_by_mgr_link!(params[:id])\n if @poll.update_attributes(params[:poll])\n redirect_to @poll\n else\n render action: :edit\n end\n end", "def poll_params\n params.require(:poll).permit(:name, :description, :status, :started_at, :concluded_at)\n end", "def update!(**args)\n @id = args[:id] if args.key?(:id)\n @response = args[:response] if args.key?(:response)\n end", "def set_poll\n @poll = current_user.created_polls.find(params[:id])\n end", "def update\n @choice = Choice.find(params[:id])\n\n if @choice.update(choice_params)\n head :no_content\n else\n render json: @choice.errors, status: :unprocessable_entity\n end\n end", "def poll_params\n params.require(:poll).permit(:user_id, :question, :token, :multi, :public, \n options_attributes: [:id, :name, :_destroy])\n end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end", "def update\n @question = Question.update(params[:id], { \n :body => params[:body], \n :answer_type => params[:answer_type] }, \n params[:answers].values\n )\n\n respond_to do |format|\n format.json { render :json => @question.as_json({:include => :answers}) }\n\n # if @question.update_attributes(params[:question])\n # format.html { redirect_to @question, :notice => 'Question was successfully updated.' }\n # format.json { head :no_content }\n # else\n # format.html { render :action => \"edit\" }\n # format.json { render :json => @question.errors, :status => :unprocessable_entity }\n # end\n end\n end", "def update\n respond_to do |format|\n if @survey_response.update(survey_response_params)\n format.html { redirect_to @survey_response, notice: 'Survey response was successfully updated.' }\n format.json { render :show, status: :ok, location: @survey_response }\n else\n format.html { render :edit }\n format.json { render json: @survey_response.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7025279", "0.6797401", "0.6657104", "0.66203606", "0.6583832", "0.65541863", "0.65541863", "0.65536416", "0.65536416", "0.65536416", "0.65229535", "0.651808", "0.64875567", "0.6375086", "0.63611084", "0.63481206", "0.63475144", "0.6321016", "0.63069594", "0.6281272", "0.62768894", "0.62514365", "0.622523", "0.62124753", "0.6190077", "0.61792755", "0.61553544", "0.61167455", "0.60907084", "0.6011147", "0.5984157", "0.59360135", "0.593319", "0.58700484", "0.5831443", "0.57893014", "0.5775922", "0.57577956", "0.57466906", "0.5744657", "0.5723055", "0.5721493", "0.57200104", "0.5713022", "0.5701642", "0.5688663", "0.56875", "0.56866497", "0.5683741", "0.56436414", "0.56413686", "0.5624814", "0.5602774", "0.55902994", "0.5581022", "0.5571482", "0.5559995", "0.5559995", "0.5559995", "0.5559995", "0.5559995", "0.5559995", "0.5559995", "0.5559995", "0.5559048", "0.55277693", "0.5518103", "0.55105543", "0.5509223", "0.55048406", "0.550475", "0.54987866", "0.5479372", "0.54754394", "0.5464149", "0.5461979", "0.54473066", "0.5446662", "0.5446431", "0.544598", "0.5428778", "0.542683", "0.542683", "0.5426593", "0.542342", "0.54183364", "0.5418299", "0.5418299", "0.5414474", "0.5412907", "0.5410583", "0.54097784", "0.54048675", "0.53988504", "0.53979945", "0.53967774", "0.53961295", "0.5395308", "0.5394657", "0.53895867" ]
0.70790887
0
DELETE /api/v1/poll_responses/1 DELETE /api/v1/poll_responses/1.json
def destroy @api_v1_poll_response.destroy respond_to do |format| format.html { redirect_to api_v1_poll_responses_url, notice: 'Poll response was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @poll.destroy\n respond_to do |format|\n format.html { redirect_to polls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @poll.destroy\n respond_to do |format|\n format.html { redirect_to polls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question_poll.destroy\n respond_to do |format|\n format.html { redirect_to question_polls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @poll = Poll.find(params[:id])\n @poll.destroy\n\n respond_to do |format|\n format.html { redirect_to polls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_groups_poll.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_groups_polls_url, notice: 'Groups poll was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @poll.destroy\n respond_to do |format|\n format.html { redirect_to polls_url, notice: 'Poll was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @poll.destroy\n respond_to do |format|\n format.html { redirect_to polls_url, notice: 'Poll was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @poll.destroy\n respond_to do |format|\n format.html { redirect_to polls_url, notice: 'Poll was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @poll.destroy\n respond_to do |format|\n format.html { redirect_to polls_url, notice: 'Poll was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey.polls.each do |poll|\n poll.destroy\n end\n @survey.destroy\n respond_to do |format|\n format.html { redirect_to inside_url, notice: 'Ankieta zostala pomyslnie skasowana.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @poll.destroy\n respond_to do |format|\n format.html { redirect_to admin_index_path, notice: 'Poll was successfully deleted.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @poll_question = PollQuestion.find(params[:id])\n @poll_question.destroy\n\n respond_to do |format|\n format.html { redirect_to poll_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @poll = Poll.find(params[:id])\n\n choices = Choice.find_all_by_poll_id(@poll.id)\n Choice.destroy(choices)\n\n @event = Event.find(@poll.event_id)\n @event.record_modification\n\n @poll.destroy\n\n respond_to do |format|\n format.html { redirect_to(@poll, :notice => 'poll was successfully destroyed.') }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! :index, @user, :message => 'Not authorized as an administrator.'\n @poll = Poll.find(params[:id])\n @poll.destroy\n\n respond_to do |format|\n format.html { redirect_to polls_url }\n format.json { head :no_content }\n end\n end", "def delete(user)\n Rails.logger.debug \"Call to poll.delete\"\n reqUrl = \"/api/poll/#{self.id}\" #Set the request url\n rest_response = MwHttpRequest.http_delete_request(reqUrl,user['email'],user['password']) #Make the DELETE request to the server with the required parameters\n Rails.logger.debug \"Response from server: #{rest_response.code} #{rest_response.message}: #{rest_response.body}\"\n if rest_response.code == \"200\" #Validate if the response from the server is 200, which means OK\n return true, rest_response #Return success\n else\n return false, \"#{rest_response.code}\", \"#{rest_response.message}\" #Return error\n end\n end", "def destroy\n @pollanswer.destroy\n respond_to do |format|\n format.html { redirect_to pollanswers_url, notice: 'Pollanswer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @poll_question.destroy\n respond_to do |format|\n format.html { redirect_to poll_questions_url, notice: 'Poll question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @poll = Poll.find_by_admin_key(params[:key])\n @poll.destroy\n\n respond_to do |format|\n format.html { redirect_to(polls_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @poll = Poll.find(params[:id])\n @poll.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_wpolls_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @response = Admin::Response.find(params[:id])\n @response.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_responses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @vote_poll.destroy\n respond_to do |format|\n format.html { redirect_to define_admin_routes({resourceName: 'VotePoll'}), notice: 'PollVote was successfully deleted.' }\n # format.html { redirect_to vote_polls_url, notice: 'Vote poll was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @user_poll.destroy\n respond_to do |format|\n format.html { redirect_to user_polls_url, notice: 'User poll was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n id = params[:id]\n unless is_number? id\n token = id\n decode_t = decode_link token\n id = decode_t[0]['id']\n end\n @opinion_poll = OpinionPoll.find(id)\n @opinion_poll.destroy\n\n return deleted_request\n\n rescue ActiveRecord::RecordNotFound\n r = {opinion_poll: 'Record Not Found'}\n return not_found r\n end", "def destroy\n @survey_response = SurveyResponse.find(params[:id])\n @survey_response.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_survey_responses_path(params[:survey_id]) }\n format.json { head :no_content }\n end\n end", "def destroy\n @poll_option.destroy\n respond_to do |format|\n format.html { redirect_to admin_poll_options_url, notice: 'Poll option was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @survey_response = SurveyResponse.find(params[:id])\r\n @survey_response.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to survey_responses_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @poll_answer = PollAnswer.find(params[:id])\n @poll = @poll_answer.poll\n @poll_answer.destroy\n end", "def destroy\n @poll_options_set = PollOptionsSet.find(params[:id])\n @poll_options_set.destroy\n\n respond_to do |format|\n format.html { redirect_to poll_options_sets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @listings_poll.destroy\n respond_to do |format|\n format.html { redirect_to listings_polls_url, notice: 'Listings poll was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n \t@poll.delete!\n \tredirect_to admin_polls_url\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 @poll_option = PollOption.find(params[:id])\n @poll_option.destroy\n\n respond_to do |format|\n format.html { redirect_to(poll_options_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @response.destroy\n respond_to do |format|\n format.html { redirect_to responses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @response.destroy\n respond_to do |format|\n format.html { redirect_to responses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @response.destroy\n respond_to do |format|\n format.html { redirect_to responses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @response.destroy\n respond_to do |format|\n format.html { redirect_to responses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question_attempt_response = QuestionAttemptResponse.find(params[:id])\n @question_attempt_response.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @question_response = QuestionResponse.find(params[:id])\n @question_response.destroy\n\n respond_to do |format|\n format.html { redirect_to question_responses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @response = Response.find(params[:id])\n @response.destroy\n\n respond_to do |format|\n format.html { redirect_to responses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @response = Response.find(params[:id])\n @response.destroy\n\n respond_to do |format|\n format.html { redirect_to responses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @pol.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @response.destroy\n\n respond_to do |format|\n format.html { redirect_to(survey_responses_url(@survey)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @quick_poll_option = QuickPollOption.find(params[:id])\n @quick_poll_option.destroy\n\n respond_to do |format|\n format.html { redirect_to quick_poll_options_url }\n format.json { head :no_content }\n end\n end", "def destroy\n#status_url(Status.find_by_survey_id(protocol.access_code)\n #@p = ResponseSet.where(:user_id => current_user)\n #@protocol = user_id.find_by_survey_id(protocol.access_code)\n #@p = ResponseSet.where(:question_id => @title_questions).first.string_value\n p= ResponseSet.where(:access_code => params[:id])\n p.first.destroy\n \n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end", "def destroy\n @q_response = QResponse.find(params[:id])\n @q_response.destroy\n\n respond_to do |format|\n format.html { redirect_to q_responses_url }\n format.json { head :ok }\n end\n end", "def destroy\n @survey_response.destroy\n respond_to do |format|\n format.html { redirect_to survey_responses_url, notice: 'Survey response was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey_response.destroy\n respond_to do |format|\n format.html { redirect_to survey_responses_url, notice: 'Survey response was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey_response.destroy\n respond_to do |format|\n format.html { redirect_to survey_responses_url, notice: 'Survey response was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @polling_session = PollingSession.find(params[:id])\n @polling_session.destroy\n\n respond_to do |format|\n format.html { redirect_to polling_sessions_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 @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 client.delete(\"/#{id}\")\n end", "def destroy\n @survey_question_response.destroy\n respond_to do |format|\n format.html { redirect_to survey_question_responses_url, notice: 'Survey question response was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @poll = Poll.find(@pollitem.poll_id)\n @pollitem.destroy\n respond_to do |format|\n format.html { redirect_to pollitems_url, notice: 'Pollitem was successfully destroyed.' }\n format.json { head :no_content }\n format.js\n end\n end", "def destroy\n @response = Response.find(params[:id])\n @response.destroy\n\n respond_to do |format|\n format.html { redirect_to(responses_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @request_call = RequestCall.find(params[:id])\n @request_call.destroy\n\n respond_to do |format|\n format.html { redirect_to request_calls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_post_vote = PostVote.find(params[:id])\n @api_v1_post_vote.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v1_post_votes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n self.poll = nil\n super\n end", "def destroy\n @test_call.destroy\n respond_to do |format|\n format.html { redirect_to test_calls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @response.destroy\n respond_to do |format|\n format.html { redirect_to responses_url, notice: 'Response was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @response.destroy\n respond_to do |format|\n format.html { redirect_to responses_url, notice: 'Response was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @response.destroy\n respond_to do |format|\n format.html { redirect_to responses_url, notice: 'Response was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @response.destroy\n respond_to do |format|\n format.html { redirect_to responses_url, notice: 'Response was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @response.destroy\n respond_to do |format|\n format.html { redirect_to responses_url, notice: 'Response was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_poll_choice(poll_id,id,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"poll_id is required\" if poll_id.nil?\n raise \"id is required\" if id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :poll_id => poll_id,\n :id => id\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{poll_id}/poll_choices/{id}\",\n :poll_id => poll_id,\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:delete, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:delete, path, query_params, form_params, headers)\n page_params_store(:delete, path)\n response\n \n end", "def destroy\n @survey.destroy\n respond_to do |format|\n format.html { redirect_to surveys_url, notice: \"Le questionnaire vient d'être détruit.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @response.destroy\n respond_to do |format|\n format.html { redirect_to responses_url, notice: \"Response was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @response = Response.find(params[:response_id])\n \n @request_selection = RequestSelection.find(params[:id])\n @request_selection.destroy\n\n respond_to do |format|\n format.html { redirect_to response_request_selections_path(@response) }\n format.json { head :no_content }\n end\n end", "def destroy\n @whos_home_response.destroy\n respond_to do |format|\n format.html { redirect_to whos_home_responses_url }\n format.json { head :no_content }\n end\n end", "def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end", "def destroy\n @api_v1_question.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_questions_url, notice: 'Question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy!\n self.poll = nil\n super\n end", "def delete\n api_client.delete(url)\n end", "def delete endpoint\n do_request :delete, endpoint\n end", "def destroy\n @survey = Survey.find(params[:id])\n @survey.destroy\n\n respond_to do |format|\n format.html { redirect_to surveys_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey = Survey.find(params[:id])\n @survey.destroy\n\n respond_to do |format|\n format.html { redirect_to surveys_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey = Survey.find(params[:id])\n @survey.destroy\n\n respond_to do |format|\n format.html { redirect_to surveys_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey = Survey.find(params[:id])\n @survey.destroy\n\n respond_to do |format|\n format.html { redirect_to surveys_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey = Survey.find(params[:id])\n @survey.destroy\n\n respond_to do |format|\n format.html { redirect_to surveys_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey.destroy\n respond_to do |format|\n format.html { redirect_to surveys_url, success: t('surveys.destroy') }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey = Survey.find(params[:id])\n @survey.destroy\n\n respond_to do |format|\n format.html { redirect_to surveys_url }\n format.json { head :ok }\n end\n end", "def destroy\n @survey = Survey.find(params[:id])\n @survey.destroy\n\n respond_to do |format|\n format.html { redirect_to surveys_url }\n format.json { head :ok }\n end\n end", "def delete_poll_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: MediaPollsApi.delete_poll ...\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling MediaPollsApi.delete_poll\"\n end\n # resource path\n local_var_path = \"/media/polls/{id}\".sub('{' + 'id' + '}', id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['oauth2_client_credentials_grant', 'oauth2_password_grant']\n data, status_code, headers = @api_client.call_api(:DELETE, 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: MediaPollsApi#delete_poll\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def destroy\n @api_version = ApiVersion.find(params[:id])\n @api_version.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_api_versions_url, flash: {success: t('app.msgs.success_deleted', :obj => t('mongoid.models.api_version.one'))} }\n format.json { head :no_content }\n end\n end", "def destroy\n @pollbooth.destroy\n respond_to do |format|\n format.html { redirect_to pollbooths_url, notice: 'Pollbooth was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n render_json_auto @survey.delete_filter(params[:id].to_i) and return\n end", "def destroy\n @request_status = RequestStatus.find(params[:id])\n @request_status.destroy\n\n respond_to do |format|\n format.html { redirect_to request_statuses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @call.destroy\n respond_to do |format|\n format.html { redirect_to calls_url, notice: 'Pergunta excluida com sucesso' }\n format.json { head :no_content }\n end\n end", "def destroy\n @call.destroy\n respond_to do |format|\n format.html { redirect_to calls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @call.destroy\n respond_to do |format|\n format.html { redirect_to calls_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @reqstatus.destroy\n respond_to do |format|\n format.html { redirect_to reqstatuses_url }\n format.json { head :no_content }\n end\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def delete\n url = prefix + \"delete\"\n return response(url)\n end", "def destroy\n @api.destroy\n respond_to do |format|\n format.html { redirect_to apis_url }\n format.json { head :no_content }\n end\n end", "def delete(id)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\"\n return HTTParty.delete(url, :timeout => 4)\n end\n end", "def destroy\n @offer.destroy\n respond_to do |format|\n format.jsonapi { head :no_content }\n end\n end", "def destroy\n @offer.destroy\n respond_to do |format|\n format.jsonapi { head :no_content }\n end\n end", "def destroy\n @survey_question = SurveyQuestion.find(params[:id])\n @survey_question.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_questions_url }\n # format.json { head :no_content }\n end\n end", "def destroy\n @poll_workflow_state = PollWorkflowState.find(params[:id])\n @poll_workflow_state.destroy\n\n respond_to do |format|\n format.html { redirect_to poll_workflow_states_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @lesson_response.destroy\n respond_to do |format|\n format.html { redirect_to lesson_responses_url, notice: 'Lesson response was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.7354495", "0.7354495", "0.7306613", "0.7278086", "0.72066855", "0.7093404", "0.7093404", "0.7093404", "0.7093404", "0.70714635", "0.7058218", "0.7054363", "0.70266366", "0.697133", "0.69615406", "0.69369197", "0.69322777", "0.68988866", "0.6846993", "0.6840946", "0.68324405", "0.6796256", "0.67820466", "0.6778787", "0.67779905", "0.67660856", "0.67618406", "0.675899", "0.6738994", "0.6738886", "0.6719051", "0.67143154", "0.6675062", "0.6675062", "0.6675062", "0.6675062", "0.66604435", "0.66523147", "0.66412777", "0.66412777", "0.662641", "0.66056556", "0.6600556", "0.65874636", "0.6564627", "0.6537782", "0.6537782", "0.6537782", "0.6516786", "0.65156996", "0.6484012", "0.6477231", "0.64674264", "0.6420815", "0.63866216", "0.63820744", "0.63759804", "0.6370886", "0.636098", "0.6348026", "0.6348026", "0.6348026", "0.6348026", "0.6348026", "0.634646", "0.6342858", "0.6342684", "0.63302195", "0.63264555", "0.6325995", "0.6319095", "0.63163793", "0.6304141", "0.62972987", "0.62957424", "0.62957424", "0.62957424", "0.62957424", "0.62957424", "0.62882733", "0.6287227", "0.6287227", "0.6286014", "0.6273334", "0.6251692", "0.6251416", "0.6248031", "0.6237036", "0.6236", "0.6236", "0.6232614", "0.62323266", "0.62323266", "0.62269735", "0.6224657", "0.6212851", "0.6212851", "0.6205782", "0.6200111", "0.6197783" ]
0.78573734
0
Use callbacks to share common setup or constraints between actions.
def set_api_v1_poll_response @api_v1_poll_response = Api::V1::PollResponse.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 api_v1_poll_response_params params.fetch(:api_v1_poll_response, {}) 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 valid_params_request?; 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 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 url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\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 valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def filtering_params\n params.permit(:email)\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 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 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 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 parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\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" ]
[ "0.6980384", "0.6782743", "0.6746196", "0.6742575", "0.6736", "0.6594004", "0.65037984", "0.6496699", "0.64819324", "0.64791185", "0.6456292", "0.64403296", "0.63795286", "0.6375975", "0.6365291", "0.63210756", "0.6300542", "0.6299717", "0.62943304", "0.6292561", "0.6290683", "0.6290449", "0.6282986", "0.6241265", "0.62392694", "0.62192893", "0.621427", "0.62099457", "0.6195319", "0.61785376", "0.61747766", "0.6172739", "0.6162921", "0.6152228", "0.6152062", "0.6148811", "0.6122391", "0.6117956", "0.61083806", "0.6106195", "0.609274", "0.60815483", "0.60710186", "0.6064253", "0.60213476", "0.6018128", "0.60146624", "0.601063", "0.60068774", "0.60068774", "0.60026145", "0.6000521", "0.59987193", "0.5992379", "0.59922844", "0.5991889", "0.59803206", "0.5966244", "0.5959778", "0.5959708", "0.59588563", "0.5956974", "0.5953329", "0.59528023", "0.59439695", "0.59413165", "0.59397036", "0.59397036", "0.5933782", "0.59323835", "0.59258395", "0.59253365", "0.5917244", "0.59111005", "0.59093463", "0.5907942", "0.59047514", "0.58979666", "0.58971125", "0.589613", "0.5895083", "0.5893643", "0.5892825", "0.5887658", "0.5883417", "0.5878839", "0.5874345", "0.5869008", "0.5868205", "0.58672875", "0.5867031", "0.58662426", "0.5864551", "0.5863614", "0.5862626", "0.5861952", "0.58596134", "0.5855716", "0.58536863", "0.5851665", "0.5850823" ]
0.0
-1
See codeline model for explanation of this pattern and how to utilize the associations.
def client_attributes=(params) client_to_save = Client.find_or_create_by_name(params[:name]) self.client = client_to_save client_to_save.birth_date = params[:birth_date] client_to_save.address1 = params[:address1] client_to_save.address2 = params[:address2] client_to_save.city = params[:city] client_to_save.state = params[:state] client_to_save.zip_code = params[:zip_code] client_to_save.medicare_num = params[:medicare_num] client_to_save.medicaid_num = params[:medicaid_num] client_to_save.member_num = params[:member_num] client_to_save.soc_sec_care_mgr = params[:soc_sec_care_mgr] client_to_save.sscm_ph = params[:sscm_ph] client_to_save.nurse_care_mgr = params[:nurse_care_mgr] client_to_save.ncm_ph = params[:ncm_ph] client_to_save.emer_contact = params[:emer_contact] client_to_save.ec_ph = params[:ec_ph] client_to_save.pri_care_phy = params[:pri_care_phy] client_to_save.pcp_ph = params[:pcp_ph] client_to_save.save end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def associations; end", "def setup_associations; end", "def associated\n end", "def model_relationships; end", "def associations; self.class.class_eval(\"@@associations\") end", "def child_relation; end", "def association(association_name); end", "def associated_records\n raise NotImplementedError\n end", "def call_association(object, associations); end", "def relation\n raise NotImplementedError\n end", "def association\n @association\n end", "def related\n @related ||= Artist.related(self)\n end", "def initialize(*)\n super\n @relations = {}\n end", "def association(name, *options); end", "def macro\n :belongs_to_related\n end", "def association_method\n self[:name]\n end", "def finalize_associations!(relations:)\n super do\n associations.map do |definition|\n Memory::Associations.const_get(definition.type).new(definition, relations)\n end\n end\n end", "def belongs_to?; false; end", "def related_posts; end", "def inverse_class\n ManyToOne::Relationship\n end", "def inverse_class\n ManyToOne::Relationship\n end", "def association\n @association ||= model.reflect_on_association(@name)\n end", "def associations\n @associations ||= {}\n end", "def association\n self.parent && self.parent.dbi.reflect_on_association(self.association_name)\n end", "def association\n relation(source).associations[target]\n end", "def responsable_of\n self.references\n end", "def objects_with_references\n end", "def process_association(class_name, assoc)\n\n STDERR.print \"\\t\\tProcessing model association #{assoc.name.to_s}\\n\" if @options.verbose\n\n # Skip \"belongs_to\" associations\n return if assoc.macro.to_s == 'belongs_to'\n\n # Only non standard association names needs a label\n \n # from patch #12384\n # if assoc.class_name == assoc.name.to_s.singularize.camelize\n \n assoc_class_name = (assoc.class_name.respond_to? 'underscore') ? assoc.class_name.pluralize.singularize.camelize : assoc.class_name \n if assoc_class_name == assoc.name.to_s.singularize.camelize\n assoc_name = ''\n else\n assoc_name = assoc.name.to_s\n end \n\n if assoc.macro.to_s == 'has_one' \n assoc_type = 'one-one'\n elsif assoc.macro.to_s == 'has_many' && (! assoc.options[:through])\n assoc_type = 'one-many'\n else # habtm or has_many, :through\n return if @habtm.include? [assoc.class_name, class_name, assoc_name]\n assoc_type = 'many-many'\n @habtm << [class_name, assoc.class_name, assoc_name]\n end \n # from patch #12384 \n # @graph.add_edge [assoc_type, class_name, assoc.class_name, assoc_name]\n @graph.add_edge [assoc_type, class_name, assoc_class_name, assoc_name] \n end", "def handle_association_links\n @type = @normalized_type = @subtype\n obj = model.with_pk(@type, request, request.id)\n association_links(obj)\n end", "def referenced; end", "def associated_record\n assoication.active_record\n end", "def test_should_associate_products\n # Load some products and see if they really don't have any related products.\n a_coat = items(:chinchilla_coat)\n a_towel = items(:towel)\n a_stuff = items(:the_stuff)\n assert_equal a_coat.related_products.count, 0\n assert_equal a_towel.related_products.count, 0\n assert_equal a_stuff.related_products.count, 0\n # Associate one with the other and both must know about that.\n a_coat.related_products << a_towel\n a_coat.related_products << a_stuff\n assert_equal a_coat.related_products.count, 2\n assert_equal a_towel.related_products.count, 1\n assert_equal a_stuff.related_products.count, 1\n # Break the association backwards and it should have no related again.\n a_stuff.related_products.delete(a_coat)\n a_towel.related_products.delete(a_coat)\n assert_equal a_coat.related_products.count, 0\n assert_equal a_towel.related_products.count, 0\n assert_equal a_stuff.related_products.count, 0\n end", "def association_method\n self[:name]\n end", "def associated_object\n bond.associated_object\n end", "def one_relationship(name)\n end", "def relation\n Proxy\n end", "def relation\n Proxy\n end", "def relation\n Proxy\n end", "def method_missing(meth, *args, &block)\n meth = meth.to_s\n collectible_class = active_record_class_from_association_method_name meth\n begin\n if collectible_class.method_defined?(:user_pointers) && User.method_defined?(meth)\n self.method(meth).call *args, &block\n else\n # puts \"Failed to define method '#{meth}'\"\n super\n end\n rescue Exception => e\n # puts \"D'OH! Couldn't create association between User and #{collectible_class}\"\n super\n end\n end", "def entities; end", "def association?(object, associations); end", "def associations\n @associations ||= {}.with_indifferent_access\n end", "def manual_relations(ar_instance)\n\t\t\tcase ar_instance.class.name\n\t\t\twhen 'Order'\n\t\t\t\t[:account_transactions, :billed_rates, :originator, {:customer => :rules},{:items => :originators}, {:order_status_transactions => :user}, {:order_items => :originator}]\n\t\t\twhen 'Shipnotice','ConsumerReturn'\n\t\t\t\t[{:shipnotice_items => :allocations}]\n\t\t\telse\n\t\t\t\t[]\n\t\t\tend\n\t\tend", "def referenced?; end", "def define_relationship(opts)\n [:name, :contains_references_to_types].each do |p|\n opts[p] or raise \"No #{p} given\"\n end\n\n base = self\n\n ArchivesSpaceService.loaded_hook do\n # We hold off actually setting anything up until all models have been\n # loaded, since our relationships may need to reference a model that\n # hasn't been loaded yet.\n #\n # This is also why the :contains_references_to_types property is a proc\n # instead of a regular array--we don't want to blow up with a NameError\n # if the model hasn't been loaded yet.\n\n\n related_models = opts[:contains_references_to_types].call\n\n clz = Class.new(AbstractRelationship) do\n table = \"#{opts[:name]}_rlshp\".intern\n set_dataset(table)\n set_primary_key(:id)\n\n if !self.db.table_exists?(self.table_name)\n Log.warn(\"Table doesn't exist: #{self.table_name}\")\n end\n\n set_participating_models([base, *related_models].uniq)\n set_json_property(opts[:json_property])\n set_wants_array(opts[:is_array].nil? || opts[:is_array])\n end\n\n opts[:class_callback].call(clz) if opts[:class_callback]\n\n @relationships[opts[:name]] = clz\n\n related_models.each do |model|\n model.include(Relationships)\n model.add_relationship_dependency(opts[:name], base)\n end\n\n # Give the new relationship class a name to help with debugging\n # Example: Relationships::ResourceSubject\n Relationships.const_set(self.name + opts[:name].to_s.camelize, clz)\n\n end\n end", "def belongs_to(other)\n self.send('attr_reader', other)\n self.send('define_method', \"#{other}=\") do |one|\n return if self.instance_variable_get(\"@#{other}\") == one\n\n collection_name = self.class.name.demodulize.downcase.pluralize\n\n if one.nil?\n # de-register self at one it currently belongs to\n self.instance_variable_get(\"@#{other}\").send(collection_name).delete(self) if self.instance_variable_get(\"@#{other}\")\n else\n # register self at the one\n one.send(collection_name) << self\n end\n\n self.instance_variable_set(\"@#{other}\", one)\n end\n end", "def collection; end", "def collection; end", "def associations\n @_associations.dup\n end", "def test_has_many_through_has_many_with_has_many_through_habtm_source_reflection\n greetings, more = comments(:greetings), comments(:more_greetings)\n\n assert_equal [greetings, more], authors(:bob).category_post_comments.order(\"comments.id\")\n end", "def relations\n self.class.relations\n end", "def stores_foreign_key?; true; end", "def belongs_to(direction, name = nil, options = { type: nil })\n if name.is_a?(Hash)\n options.merge(name)\n name = direction\n direction = nil\n elsif name.is_a?(Proc)\n name = direction\n direction = nil\n elsif name.nil?\n name = direction\n end\n reflections[name] = { direction: direction, type: options[:type], kind: :belongs_to }\n\n define_method(\"promise_#{name}\") do\n @fetch_states[name] = 'i'\n self.class._promise_get(\"#{self.class.resource_base_uri}/#{self.id}/relations/#{name}.json?timestamp=#{`Date.now() + Math.random()`}\").then do |response|\n @relations[name] = if response.json[self.class.to_s.underscore][name]\n self.class._convert_json_hash_to_record(response.json[self.class.to_s.underscore][name])\n else\n nil\n end\n @fetch_states[name] = 'f'\n _notify_observers\n @relations[name]\n end.fail do |response|\n error_message = \"#{self.class.to_s}[#{self.id}].#{name}, a belongs_to association, failed to fetch records!\"\n `console.error(error_message)`\n response\n end\n end\n # @!method [name] get records of the relation\n # @return [HyperRecord::Collection] either a empty one, if the data has not been fetched yet, or the\n # collection with the real data, if it has been fetched already\n define_method(name) do\n _register_observer\n if @fetch_states.has_key?(name) && 'fi'.include?(@fetch_states[name])\n @relations[name]\n elsif self.id\n send(\"promise_#{name}\")\n @relations[name]\n else\n @relations[name]\n end\n end\n # @!method update_[name] mark internal structures so that the relation data is updated once it is requested again\n # @return nil\n define_method(\"update_#{name}\") do\n @fetch_states[name] = 'u'\n nil\n end\n # TODO\n # define_method(\"#{name}=\") do |arg|\n # _register_observer\n # @relations[name] = arg\n # @fetch_states[name] = 'f'\n # @relations[name]\n # end\n end", "def def_one_to_many(opts)\n one_to_one = opts[:type] == :one_to_one\n name = opts[:name]\n key = (opts[:key] ||= opts.default_key)\n km = opts[:key_method] ||= opts[:key]\n cks = opts[:keys] = Array(key)\n opts[:key_methods] = Array(opts[:key_method])\n primary_key = (opts[:primary_key] ||= self.primary_key)\n opts[:eager_loader_key] = primary_key unless opts.has_key?(:eager_loader_key)\n cpks = opts[:primary_keys] = Array(primary_key)\n pkc = opts[:primary_key_column] ||= primary_key\n pkcs = opts[:primary_key_columns] ||= Array(pkc)\n raise(Error, \"mismatched number of keys: #{cks.inspect} vs #{cpks.inspect}\") unless cks.length == cpks.length\n uses_cks = opts[:uses_composite_keys] = cks.length > 1\n opts[:dataset] ||= opts.association_dataset_proc\n opts[:eager_loader] ||= proc do |eo|\n h = eo[:id_map]\n reciprocal = opts.reciprocal\n assign_singular = opts.assign_singular?\n delete_rn = opts.delete_row_number_column\n\n eager_load_results(opts, eo) do |assoc_record|\n assoc_record.values.delete(delete_rn) if delete_rn\n hash_key = uses_cks ? km.map{|k| assoc_record.get_column_value(k)} : assoc_record.get_column_value(km)\n next unless objects = h[hash_key]\n if assign_singular\n objects.each do |object| \n unless object.associations[name]\n object.associations[name] = assoc_record\n assoc_record.associations[reciprocal] = object if reciprocal\n end\n end\n else\n objects.each do |object| \n object.associations[name].push(assoc_record)\n assoc_record.associations[reciprocal] = object if reciprocal\n end\n end\n end\n end\n \n join_type = opts[:graph_join_type]\n select = opts[:graph_select]\n use_only_conditions = opts.include?(:graph_only_conditions)\n only_conditions = opts[:graph_only_conditions]\n conditions = opts[:graph_conditions]\n opts[:cartesian_product_number] ||= one_to_one ? 0 : 1\n graph_block = opts[:graph_block]\n opts[:eager_grapher] ||= proc do |eo|\n ds = eo[:self]\n ds = ds.graph(opts.apply_eager_graph_limit_strategy(eo[:limit_strategy], eager_graph_dataset(opts, eo)), use_only_conditions ? only_conditions : cks.zip(pkcs) + conditions, Hash[eo].merge!(:select=>select, :join_type=>eo[:join_type]||join_type, :qualify=>:deep, :from_self_alias=>eo[:from_self_alias]), &graph_block)\n # We only load reciprocals for one_to_many associations, as other reciprocals don't make sense\n ds.opts[:eager_graph][:reciprocals][eo[:table_alias]] = opts.reciprocal\n ds\n end\n \n return if opts[:read_only]\n\n save_opts = {:validate=>opts[:validate]}\n ck_nil_hash ={}\n cks.each{|k| ck_nil_hash[k] = nil}\n\n if one_to_one\n opts[:setter] ||= proc do |o|\n up_ds = _apply_association_options(opts, opts.associated_dataset.where(cks.zip(cpks.map{|k| get_column_value(k)})))\n if o\n up_ds = up_ds.exclude(o.pk_hash) unless o.new?\n cks.zip(cpks).each{|k, pk| o.set_column_value(:\"#{k}=\", get_column_value(pk))}\n end\n checked_transaction do\n up_ds.skip_limit_check.update(ck_nil_hash)\n o.save(save_opts) || raise(Sequel::Error, \"invalid associated object, cannot save\") if o\n end\n end\n opts[:_setter] = proc{|o| set_one_to_one_associated_object(opts, o)}\n else \n save_opts[:raise_on_failure] = opts[:raise_on_save_failure] != false\n\n opts[:adder] ||= proc do |o|\n cks.zip(cpks).each{|k, pk| o.set_column_value(:\"#{k}=\", get_column_value(pk))}\n o.save(save_opts)\n end\n \n opts[:remover] ||= proc do |o|\n cks.each{|k| o.set_column_value(:\"#{k}=\", nil)}\n o.save(save_opts)\n end\n\n opts[:clearer] ||= proc do\n _apply_association_options(opts, opts.associated_dataset.where(cks.zip(cpks.map{|k| get_column_value(k)}))).update(ck_nil_hash)\n end\n end\n end", "def configure_relation\n end", "def add_relationship(rel_attr); end", "def association_matcher; end", "def references; end", "def references; end", "def self_and_descendents_from_active_record\n [self]\n end", "def _load_associated_objects(opts, dynamic_opts={})\n if opts.can_have_associated_objects?(self) && opts[:type] == :many_to_one && opts.associated_class.respond_to?(:cache_get_pk)\n _load_associated_object(opts, dynamic_opts)\n else\n super\n end\n end", "def inherited(klass)\n klass.instance_variable_set(:@associations, associations.clone)\n super\n end", "def test_accessors_for_many_to_one_attr\n assert_equal TestWriter.public_method_defined?(:blog_posts), true\n assert_equal TestWriter.public_method_defined?(\"blog_posts=\"), true\n post = TestBlogPost.new({})\n author = TestWriter.new({})\n author.blog_posts << post\n assert_equal author, post.test_writer \n assert_equal true, (author.blog_posts.include? post)\n end", "def handle_belongs_to(model, associated)\n __method = __method__\n # trace __FILE__, __LINE__, self, __method__, \" : model.class=#{model.class} associated=#{associated.class} has?=#{has?}\"\n associated = [associated] unless associated.is_a?(Array)\n # trace __FILE__, __LINE__, self, __method__, \" : associated.size=#{associated.size}\"\n if has?\n associated.each do |associate|\n # trace __FILE__, __LINE__, self, __method, \" : model.class=#{model.class} associate=#{associate.class}\"\n inverse = associate.class.belongs_to_association(collection)\n # trace __FILE__, __LINE__, self, __method, \" : model.class=#{model.class} associate=#{associate.class}\"\n if inverse\n # trace __FILE__, __LINE__, self, __method, \" : setting inverse associate.class##{inverse.local_attr} to #{model.class}\"\n associate.send(:\"#{inverse.local_attr}=\", model)\n # trace __FILE__, __LINE__, self, __method\n end\n end\n end\n end", "def association_changeset(name)\n association = self.item.send(name)\n # association = association.source if association.decorated?\n\n self.changeset_class(association).new(association, self.data['associations'].fetch(name.to_s).try(:fetch, 'changes'))\n end", "def relationship(rel_class)\n @relationship = rel_class\n self\n end", "def initialize(_, context = Ramom::Schema::Definition::Context.new)\n super\n infer_base_relations\n end", "def has_and_belongs_to_many(others)\n @others = others\n @collection = ManyToManyCollection\n self.send('attr_reader', others)\n end", "def associated?\n @associated\n end", "def enable_relationships\n self.items.each do |_, content_type|\n content_type.fields.find_all(&:is_relationship?).each do |field|\n # look for the target content type from its slug\n field.class_name = field.class_slug\n field.klass = self.items[field.class_slug]\n end\n end\n end", "def method_missing(method, *args, &block)\n relation.send(method, *args, &block)\n end", "def test_has_many_through_has_and_belongs_to_many_with_has_many_source_reflection\n greetings, more = comments(:greetings), comments(:more_greetings)\n\n assert_equal [greetings, more], categories(:technology).post_comments.order(\"comments.id\")\n end", "def initialize(*args)\n super\n\n unless @ref.macro == :has_one or @ref.macro == :has_many\n raise ArgumentError, \"#{@ref.active_record.name}##{@ref.name} cannot be eager loaded because only `has_one` and `has_many` are supported for `through` associations\"\n end\n if (polys = @ref.chain.select(&:polymorphic?)).any?\n names = polys.map { |r| \"#{r.active_record.name}##{r.name}\" }\n raise ArgumentError, \"#{@ref.active_record.name}##{@ref.name} cannot be eager loaded because these `through` associations are polymorphic: #{names.join ', '}\"\n end\n unless @optimizer == :none or @optimizer == :select\n raise ArgumentError, \"Unrecognized optimizer '#{@optimizer}'\"\n end\n\n chain = @ref.chain.reverse\n @chain = chain.each_with_index.map { |x, i|\n Link.new(x.source_reflection.name, x.source_reflection.macro, x, chain[i + 1])\n }\n @loader = build_loader\n end", "def associations_after_save\n # # WARNING: the associations here are not using active_record, so they are not auto saved with user intake\n # # we are saving the associations manually here\n # collapse_associations # make obsolete ones = nil\n #\n # TODO: conflicting with 1.6.0 pre-quality. removed to check compatiblity or related errors\n # for remaining, fill login, password details only when login is empty\n # This is a 3 step process\n # \n # Thu Nov 11 00:14:24 IST 2010, ramonrails\n # Link per user, once only. compact.uniq ensures that\n [\"senior\", \"subscriber\", \"caregiver1\", \"caregiver2\", \"caregiver3\"].each do |_what|\n # \n # Sat Nov 20 02:03:52 IST 2010, ramonrails\n # * this logic is required when uset simply toggles the flag and saves\n _user = self.send( _what) # fetch the associated user\n unless _user.blank? || _user.nothing_assigned?\n # * default properties\n _user.autofill_login # create login and password if not already\n _user.lazy_associations[:user_intake] = self\n _user.skip_validation = true # TODO: patch for 1.6.0 release. fix later with business logic, if required\n\n case _what\n when 'senior'\n # _user.save\n # _user.is_halouser_of( group) unless _user.blank? || group.blank? # role\n _user.lazy_roles[:halouser] = group unless _user.blank? || group.blank? # role\n _user.save\n \n when 'subscriber'\n if subscribed_for_self? # senior is same as subscriber\n if was_subscribed_for_self?\n # * user and subscriber are same. not changed\n else\n # * subscriber was different. now same as senior\n self.subscriber_is_user = false # create old condition\n subscriber.is_not_subscriber_of( senior) unless subscriber.blank? || senior.blank? # remove old role first\n # subscriber.delete # remove this extra user\n self.subscriber_is_user = true # back to current situation\n end\n # _user.save\n # _user.is_subscriber_of( senior) unless _user.blank? || senior.blank? # role\n _user.lazy_roles[:subscriber] = senior unless _user.blank? || senior.blank? # role\n _user.save\n\n else # senior different from subscriber\n if was_subscribed_for_self?\n _user = senior.clone_with_profile if senior.equal?( subscriber) # same IDs, clone first\n senior.is_not_subscriber_of( senior) unless senior.blank? # senior was subscriber, not now\n else\n # all good. nothing changed\n end\n # _user.save\n # _user.is_subscriber_of( senior) unless _user.blank? || senior.blank? # role\n _user.lazy_roles[:subscriber] = senior unless _user.blank? || senior.blank? # role\n _user.save\n end\n \n when 'caregiver1'\n if caregiving_subscriber? # subscriber is caregiver\n if was_caregiving_subscriber?\n # all good. nothing changed\n else\n # was separate\n self.subscriber_is_caregiver = false # make old condition\n caregiver1.is_not_caregiver_of( senior) unless caregiver1.blank? || senior.blank?\n # caregiver1.delete # remove extra\n self.subscriber_is_caregiver = true # current condition again\n end\n \n else # subscriber different from caregiver1\n if was_caregiving_subscriber?\n _user = subscriber.clone_with_profile if subscriber.equal?( caregiver1) # same ID? clone first\n subscriber.is_not_caregiver_of( senior) unless subscriber.blank? || senior.blank? # remove caregiving role for subscriber\n else\n # all good. nothing changed\n end\n end\n if caregiving_subscriber? || (caregiver1_required? && _user.something_assigned? && !senior.blank? && !_user.equal?( senior))\n # _user.save\n # _user.is_caregiver_of( senior) unless _user.blank? || senior.blank? || _user.equal?( senior)\n # _user.options_for_senior( senior, mem_caregiver1_options)\n _user.lazy_roles[:caregiver] = senior\n _user.lazy_options[ senior] = mem_caregiver1_options\n _user.save\n # else\n # self.no_caregiver_1 = true\n # self.send(:update_without_callbacks)\n end\n \n when 'caregiver2'\n if caregiver2_required? && _user.something_assigned? && !senior.blank? && !_user.equal?( senior)\n # _user.save\n # _user.is_caregiver_of( senior) unless _user.blank? || senior.blank? || _user.equal?( senior)\n # _user.options_for_senior( senior, mem_caregiver2_options)\n _user.lazy_roles[:caregiver] = senior\n _user.lazy_options[ senior] = mem_caregiver2_options\n _user.save\n else\n self.no_caregiver_2 = true\n self.send(:update_without_callbacks)\n end\n\n when 'caregiver3'\n if caregiver3_required? && _user.something_assigned? && !senior.blank? && !_user.equal?( senior)\n # _user.save\n # _user.is_caregiver_of( senior) unless _user.blank? || senior.blank? || _user.equal?( senior)\n # _user.options_for_senior( senior, mem_caregiver3_options)\n _user.lazy_roles[:caregiver] = senior\n _user.lazy_options[ senior] = mem_caregiver3_options\n _user.save\n else\n self.no_caregiver_3 = true\n self.send(:update_without_callbacks)\n end\n end # case\n end # blank?\n end # _what\n \n # \n # Thu Jan 13 02:38:38 IST 2011, ramonrails\n # * Not required anymore\n # * lazy_associations attaches each user to this user intake\n # #\n # # * replace earlier associations. keep fresh ones\n # # * do not create duplicate associations\n # # QUESTION: what happens to orphaned users here?\n # # * reject new_record? anything not saved does not get assigned\n # # * only associate one copy of each\n # self.users = [senior, subscriber, caregiver1, caregiver2, caregiver3].reject(&:new_record?).compact.uniq\n # # # \n # # # Thu Jan 13 02:34:27 IST 2011, ramonrails\n # # # * pre_quality.feature had error dispatching emails\n # # # * This might dispatch the email more than once\n # # self.users.each(&:dispatch_emails)\n\n\n # [\"senior\", \"subscriber\", \"caregiver1\", \"caregiver2\", \"caregiver3\"].each do |_what|\n # \n # # \n # # Fri Nov 19 03:17:32 IST 2010, ramonrails\n # # * skip saving the object if already saved\n # # * happens when object is shared. subscriber == user, or, subscriber == caregiver\n # # * saving also dispatches emails. A few more triggers/callbacks. Please check model code\n # _skip = ((_what == 'subscriber') && subscribed_for_self?)\n # _skip = (_skip || (_what == 'caregiver1' && caregiving_subscriber?))\n # # \n # # Thu Nov 11 00:32:18 IST 2010, ramonrails\n # # Do not save any non-assigned data, or blank ones\n # unless _user.blank? || _user.nothing_assigned? || _skip\n # _user.skip_validation = true # TODO: patch for 1.6.0 release. fix later with business logic, if required\n # \n # # _user.autofill_login # Step 1: make them valid\n # if _user.save # Step 2: save them to database\n # # \n # # Thu Nov 11 00:13:31 IST 2010, ramonrails\n # # https://redmine.corp.halomonitor.com/issues/3696\n # # caused a bug that created multiple links to the same user\n # self.users << _user unless users.include?( _user) # Step 3: link them to user intake\n # end\n # end\n # end\n # #\n # # * add roles and options\n # # * roles are already handled by user model\n # # * this will not double write the roles\n # # senior\n # senior.is_halouser_of( group) unless senior.blank?\n # # subscriber\n # unless senior.blank? || subscriber.blank?\n # subscriber.is_subscriber_of( senior)\n # subscriber.is_caregiver_of( senior) if caregiving_subscriber?\n # end\n # # Wed Oct 27 23:55:22 IST 2010\n # # * no need to check subscriber_is_caregiver here. that is done in caregiver1 method\n # # * just call for each caregiver and assign position and other options\n # (1..3).each do |index|\n # _caregiver = self.send(\"caregiver#{index}\".to_sym)\n # _required = self.send(\"caregiver#{index}_required?\")\n # unless (_caregiver.blank? || !_required || _caregiver.nothing_assigned?)\n # _caregiver.is_caregiver_of( senior) unless _caregiver.is_caregiver_of?( senior)\n # # \n # # Thu Nov 4 05:57:16 IST 2010, ramonrails\n # # user values were stored with apply_attributes_from_hash\n # # now we persist them into database\n # _options = self.send(\"mem_caregiver#{index}_options\")\n # # \n # # Thu Nov 18 20:58:29 IST 2010, ramonrails\n # # * Do not use any other method here, cyclic dependency can occur\n # _caregiver.options_for_senior( senior, _options)\n # end\n # end\n\n end", "def attach; end", "def relationnal_result(method_name, *arguments)\n self.class.reload_fields_definition(false)\n if self.class.many2one_associations.has_key?(method_name)\n load_m2o_association(method_name, *arguments)\n elsif self.class.polymorphic_m2o_associations.has_key?(method_name)# && @associations[method_name]\n load_polymorphic_m2o_association(method_name, *arguments)\n# values = @associations[method_name].split(',')\n# self.class.const_get(values[0]).find(values[1], arguments.extract_options!)\n else # o2m or m2m\n load_x2m_association(method_name, *arguments)\n end\n end", "def freeze\n associations\n super\n associations.freeze\n self\n end", "def relationships\n model.relationships(repository.name)\n end", "def associations\n # is caching ok?\n unless @associations\n @associations = {}\n klass.relations.each{|name,association|\n @associations[name.to_s] = Association.new(association,self)\n }\n end\n @associations\n end", "def relationships\n @relationships ||= {}\n end", "def relationship\n return @relationship\n end", "def create_associations\n self.associates.each do |associate|\n self.add_associated(associate)\n end\n end", "def perform\n associated_records = parent_context.records.flat_map do |record|\n next if record.nil?\n\n reflection = reflection_cache[record.class]\n next if reflection.nil?\n\n record_association = record.association(association_name)\n reflection.collection? ? record_association.target : record_association.reader\n end\n\n Context.register(\n records: associated_records,\n association_tree: child_association_tree,\n auto_preload: parent_context.auto_preload?\n )\n end", "def link!\n base = ::ActiveRecord::Associations::ClassMethods::JoinDependency.new(\n @model, [], nil\n )\n \n @fields.each { |field|\n field.model ||= @model\n field.columns.each { |col|\n field.associations[col] = associations(col.__stack.clone)\n field.associations[col].each { |assoc| assoc.join_to(base) }\n }\n }\n \n @attributes.each { |attribute|\n attribute.model ||= @model\n attribute.columns.each { |col|\n attribute.associations[col] = associations(col.__stack.clone)\n attribute.associations[col].each { |assoc| assoc.join_to(base) }\n }\n }\n end", "def related_fields(method)\n \n end", "def relationship_related_link(attribute_name); end", "def initialize\n @columns = { }\n @primary_keys = []\n @to_avoid = []\n @default_values = { }\n @associations = \n {\n :belongs_to => { },\n :has_one => { },\n :has_n => { }\n }\n end", "def method_missing(method_name, *args, &block)\r\n if @loaded[method_name]\r\n @loaded[method_name]\r\n elsif self.class.associations(version)[method_name] ||\r\n self.class.model.reflect_on_association(method_name)\r\n\r\n class_eval <<CODE, __FILE__, __LINE__ + 1\r\ndef #{method_name}\r\n @loaded[#{method_name.inspect}] ||\r\n Restful::Resource::AssociationProxy.new(self, :#{method_name})\r\nend\r\nCODE\r\n\r\n send method_name\r\n elsif args.size <= 1 && attributes(*args).has_key?(method_name)\r\n self[method_name, *args]\r\n else\r\n super\r\n end\r\n # rescue => e\r\n # raise [method_name, args, block].inspect\r\n end", "def associations(*associations)\n self._associations = associations\n end", "def association\n @association ||= options[:association]\n end", "def has_one_through(name, assoc1, assoc2)\n define_method(name) do\n #grabbing the association we created in belongs_to\n params1 = self.class.assoc_params[assoc1] #Cat.assoc_params[:human]\n \n #house\n params2 = params1.other_class.assoc_params[assoc2] #Human.assoc_params[:house]\n\n primary_key1 = self.send(params1.foreign_key)\n results = DBConnection.execute(<<-SQL, primary_key1)\n SELECT \n #{params2.other_table}.*\n FROM \n #{params2.other_table}\n JOIN \n #{params1.other_table}\n ON \n #{params1.other_table}.#{params2.foreign_key}\n = #{params2.other_table}.#{params2.primary_key}\n WHERE \n #{params1.other_table}.#{params1.primary_key}\n = ?\n SQL\n\n params2.other_class.parse_all(results).first\n end\n end", "def related_employees\n ratings.employees\n end", "def test_should_associate_tags\n # Load some products and see if they really don't have any tags.\n a_stuff = items(:the_stuff)\n assert_equal a_stuff.tags.count, 0\n # Load some tags and see if they really don't have any products.\n weird_tag = tags(:weird)\n weird_counter = weird_tag.products.count\n # Associate one with the other and both must know about that.\n a_stuff.tags << weird_tag\n assert_equal a_stuff.tags.count, 1\n assert_equal weird_tag.products.count, weird_counter + 1\n\n # Break the association.\n a_stuff.tags.delete(weird_tag)\n assert_equal a_stuff.tags.count, 0\n assert_equal weird_tag.products.count, weird_counter\n end", "def begin_of_association_chain\n nil\n end", "def association(key)\n @associations[key] ||= Association.children(@model, key)\n end", "def configure\n super\n create_has_many_through :subject\n end", "def association(name)\n association = super\n reflection = self.class.reflect_on_association(name)\n case reflection.try(:macro)\n when :belongs_to\n association.extend(HasAggregatedExtension) if reflection.options[:aggregated]\n when :has_one\n association.extend(HasCurrentExtension) if reflection.options[:is_current]\n else # do nothing\n end\n association\n end", "def define_one_to_many_association(klass, attributes)\n belongs_to_id = :\"#{belongs_to}_id\"\n belongs_to_type = :\"#{belongs_to}_type\"\n\n # Track all attributes for this association, so that we can limit the scope\n # of keys for the association to only these attributes. We need to track the\n # attributes assigned to the association in case this setup code is called\n # multiple times, so we don't \"forget\" earlier attributes.\n #\n attrs_method_name = :\"#{association_name}_attributes\"\n association_attributes = (klass.instance_variable_get(:\"@#{attrs_method_name}\") || []) + attributes\n klass.instance_variable_set(:\"@#{attrs_method_name}\", association_attributes)\n\n klass.one_to_many association_name,\n reciprocal: belongs_to,\n key: belongs_to_id,\n reciprocal_type: :one_to_many,\n conditions: { belongs_to_type => klass.to_s, key_column => association_attributes },\n adder: proc { |translation| translation.update(belongs_to_id => pk, belongs_to_type => self.class.to_s) },\n remover: proc { |translation| translation.update(belongs_to_id => nil, belongs_to_type => nil) },\n clearer: proc { send_(:\"#{association_name}_dataset\").update(belongs_to_id => nil, belongs_to_type => nil) },\n class: class_name\n end", "def relations\n _relations\n end", "def relations\n _relations\n end", "def add\n association.build\n end" ]
[ "0.73459053", "0.7041705", "0.68838805", "0.6659784", "0.66216457", "0.654491", "0.64321154", "0.63897425", "0.63080287", "0.6208916", "0.612364", "0.6058486", "0.6049167", "0.60247934", "0.5866024", "0.5854072", "0.58310837", "0.5768192", "0.5764886", "0.57467175", "0.57467175", "0.5744462", "0.5743797", "0.5738132", "0.5723477", "0.5716154", "0.56984884", "0.5691866", "0.5691614", "0.5690097", "0.56778556", "0.56631637", "0.56601983", "0.5651829", "0.5644002", "0.56376785", "0.56376785", "0.56376785", "0.5611484", "0.5602777", "0.55918056", "0.55860585", "0.5564097", "0.55515677", "0.55406535", "0.55364335", "0.5532574", "0.5532574", "0.55243665", "0.55182725", "0.55144393", "0.55048394", "0.5504613", "0.5503309", "0.5502025", "0.5483947", "0.54798806", "0.5479245", "0.5479245", "0.5479161", "0.5476162", "0.5467888", "0.54647446", "0.5452137", "0.5444047", "0.54423517", "0.54423004", "0.5434748", "0.5434157", "0.542948", "0.54269415", "0.54222196", "0.541389", "0.5411518", "0.5410165", "0.54040545", "0.5404032", "0.5400327", "0.53924257", "0.5385436", "0.5372966", "0.5369618", "0.5364503", "0.53617847", "0.53506833", "0.53500783", "0.534675", "0.5338989", "0.5333821", "0.53311825", "0.53283894", "0.5325328", "0.53244984", "0.5318784", "0.53152454", "0.5310858", "0.5309421", "0.5302472", "0.5296253", "0.5296253", "0.529576" ]
0.0
-1
the folder at the root of the task scheduler
def root_folder scheduler_service.GetFolder("\\") end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cron_dot_d_directory\n end", "def work_dir; end", "def tasks_directory\n @cached_paths[:tasks_directory] ||= look_up_configured_path(\n :tasks_directory,\n :defaults => ['tasks']\n )\n end", "def job_folder\n File.join(Session.current.root, job_key)\n end", "def folder_path\n File.expand_path @folder_path\n end", "def generatedReportFolder\n currentData, currentTime = DateTime.now.strftime(\"%Y_%m_%d %H_%M\").split(' ')\n path = \"#{$ROOT}/../output\"\n creatFolder(path)\n path += \"/#{currentData}\"\n creatFolder(path)\n path += \"/#{currentTime}\"\n creatFolder(path)\n path\n end", "def folder\n @root_folder\n end", "def runDir\n if @workflow[:run_directory]\n OpenStudio.toPath(@workflow[:run_directory])\n else\n OpenStudio.toPath('./run')\n end\n end", "def run_dir\n result = File.join(osw_dir, 'run')\n if @workflow_json\n begin\n result = @workflow_json.absoluteRunDir.to_s\n rescue StandardError\n end\n end\n result\n end", "def run_dir\n result = File.join(osw_dir, 'run')\n if @workflow_json\n begin\n result = @workflow_json.absoluteRunDir.to_s\n rescue StandardError\n end\n end\n result\n end", "def hours_folder\n TEST_HOURS_FOLDER\n end", "def workspace_folder\n @pwd\n end", "def dir\n File.dirname(__FILE__)\n end", "def work_dir\n AYTests.work_dir\n end", "def new_jobdir\n @target + unique_dir\n end", "def file_path\n File.join 'lib', 'woro_tasks', file_name\n end", "def root_dir\n ManageIQ::Providers::Lenovo::Engine.root.join(\"content/ansible_runner\")\n end", "def default_file\n \"#{Dir.home()}/.calendar/calendar-events\"\nend", "def files_dir\n return File.absolute_path(File.join(@root_dir, 'weather'))\n end", "def path\n File.join(Settings.root, folder_name.to_path)\n end", "def dir\n @working_directory\n end", "def enclosed_directory\n \".\"\nend", "def root; Pathname(__dir__).parent; end", "def get_run_dir()\n \"#{node[:neon_logs][:flume_run_dir]}/#{node[:neon_logs][:flume_service_name]}\"\n end", "def root\n Pathname.new(File.dirname(__dir__))\n end", "def folder_path\n File.join(location.path, folder_name)\n end", "def root_dir\n self.class.plays_dir.join script_name\n end", "def root\n File.dirname __dir__\n end", "def folder\n @folder ||= File.expand_path('.')\n end", "def project_root\n this_file_path.ascend do |p|\n rakefile = p.join( 'Rakefile' )\n return p if rakefile.exist?\n end\n end", "def root_dir\n File.join(self.runner.path, 'public')\n end", "def relative_directory; end", "def output_root\n ETL.config.core[:job][:data_dir]\n end", "def integration_cwd\n root.to_s\n end", "def directory; end", "def directory; end", "def directory\r\n \t@directory.path\r\n end", "def root\n File.dirname __dir__\n end", "def root\n File.dirname __dir__\n end", "def current_path\n current_folder.path\n end", "def workdir\n result = base.join('cache')\n result.mkpath\n result\n end", "def runtime_dir\n File.join(@full_path, RUNTIME_DIR)\n end", "def root\n File.dirname(__FILE__)\n end", "def destination_directory\n File.join(config[\"screenshot_directory\"], Time.now.strftime(\"%Y-%m\"))\n end", "def get_root\n return File.join('/root/path', SETTINGS[:project])\n end", "def dir\n Rails.root.join(ROOT, type, name).to_s\n end", "def file_dir\n 'files'\n end", "def path\n folder.path + name\n end", "def location\n return unless exists?\n folder_pathname.relative_path_from(root_path)\n end", "def current_dir; end", "def work\n '/' + File.dirname(file)\n end", "def current_working_directory; @rye_current_working_directory; end", "def rootDir\n if @workflow[:root_dir]\n OpenStudio.toPath(@workflow[:root_dir])\n else\n OpenStudio.toPath(@osw_dir)\n end\n end", "def job_dir(base_dir, job_name)\n # All this flow is working under assumption that all task jobs called\n # in same order. We store counter for each job in Task instance and\n # it updated throug all task live time. Each time task instance is\n # recreated we use frech (zero) counter\n counter = (jobs[job_name] || -1) + 1\n jobs[job_name] = counter\n name = [job_name, counter.to_s.rjust(3, '0')].join('-')\n File.join(base_dir, name)\n end", "def root_path\n Pathname.new(File.expand_path(File.join(__dir__, '..', '..')))\nend", "def base_dir; end", "def base_dir; end", "def base_dir; end", "def base_dir; end", "def base_dir; end", "def base_dir; end", "def base_dir; end", "def destination(base_directory); end", "def directory\n self.path.directory\n end", "def store_dir\n \"uploads/#{DateTime.now.strftime('%Y%m')}/\"\n end", "def root_file_path; end", "def project_root; end", "def project_root; end", "def dir_path\n RAILS_ROOT + '/temp_files/' + Digest::MD5.hexdigest(self.id.to_s)[0..1] + '/'\n end", "def directory\n @config.get('WATCH_DIRECTORY') || abort('Missing WATCH_DIRECTORY')\n end", "def converted_root\n Pathname(__dir__).parent + \"converted\"\n end", "def root\n File.expand_path(File.dirname(__dir__))\n end", "def base_path\n Dir.pwd + \"/\"\n end", "def path\n @directory.path\n end", "def resources_root()\n \"#{project_root}/Resources\"\n end", "def folder_name\n @folder_name\n end", "def path\n Rails.root.join(ROOT, type, name, executable).to_s\n end", "def template_dir\n File.dirname(__FILE__) + '/../cfg'\n end", "def store_dir\n \"media/documents/#{Time.now.year}/#{Time.now.month}/#{Time.now.day}\"\n end", "def publish_tmp_dir_path()\n user_tmp_dir_container = ENV['DOCS_TMP_DIR_CONTAINER']\n if (not user_tmp_dir_container.nil?) && user_tmp_dir_container.length > 0\n subdir = File.join(\n user_tmp_dir_container,\n SecureRandom.uuid\n )\n else\n subdir = SecureRandom.uuid\n end\n\n return File.join(\n Dir.tmpdir(),\n subdir\n )\n end", "def getWorkingDir\n currDir = Dir.pwd\n dr = \"\"\n currDir.split(\"/\").each{ |entry|\n dr = dr+entry+\"/\"\n #puts dr\n if(File.directory? dr+\".hoster\")\n @workingDir = dr+\".hoster\"\n end\n }\n @workingDir\n end", "def daily_directory_for time, original\n File.join(top_level_of(original, settings[:input]), time.strftime(\"%Y/%m/%d\"))\n end", "def root\n Dir.pwd\n end", "def folder\n @folder ||= File.join(Rails.root,'lib','action_watchers',action)\n end", "def getfilename()\n current_time = Time.new.strftime(\"%Y-%m-%d\")\n \n # Create filename\n filename = current_time + \"_sprint_update_CS.html\"\n\n # Create folder with all file of sprint update\n foldername = \"History\"\n Dir.mkdir(foldername) unless File.exists?(foldername)\n\n return File.join(\".\", foldername, filename)\nend", "def locate\r\n File.dirname(__FILE__)\r\n end", "def locate\r\n File.dirname(__FILE__)\r\n end", "def directory\n File.dirname(@path) + '/'\n end", "def current_directory\n File.expand_path @current_directory\n end", "def run_dir\n run_base + \"/g4.#{geant_version}_cms_#{cmssw_version}/#{build_type}/CMSSW_#{cmssw_version}/src\"\n end", "def path\n File.join(self.folder, self.filename)\n end", "def base_export_dir\n \"#{@directory.slug}_files\"\n end", "def given_destination\n dir\n end", "def root\n File.expand_path(File.dirname(File.dirname(File.dirname(__dir__))))\n end", "def root\n settings[:basedir]\n end", "def my_dir\n File.dirname(__FILE__)\nend", "def root_path\n ENV['TM_PROJECT_DIRECTORY'] || File.join(ENV['TM_DIRECTORY'], \"..\")\n end", "def gen_news_dir()\n dir = \"#{Rails.root}/public/secure/news/#{@folder}\"\n if Dir.exist? dir\n dir\n else\n dir if FileUtils.mkdir_p dir\n end\n end", "def path()\n return ::File.join(@root, @name)\n end", "def root\n \"#{File.dirname(__FILE__)}/..\"\nend" ]
[ "0.7591735", "0.71050394", "0.6866237", "0.66214055", "0.6530276", "0.64892966", "0.647909", "0.6475342", "0.6454152", "0.6454152", "0.64404106", "0.64137673", "0.640872", "0.6389779", "0.63563234", "0.6304272", "0.6293728", "0.62719685", "0.62634647", "0.6256626", "0.62457466", "0.62260735", "0.6221681", "0.6216012", "0.62109625", "0.6192316", "0.6189758", "0.618056", "0.61746436", "0.61634296", "0.6162695", "0.61615384", "0.61592704", "0.61465144", "0.613305", "0.613305", "0.61010236", "0.6084828", "0.6084828", "0.6084531", "0.6067482", "0.6066065", "0.6060358", "0.60550517", "0.605094", "0.60410786", "0.60288835", "0.6026884", "0.6021182", "0.6020953", "0.60163724", "0.60156965", "0.60091555", "0.60074025", "0.59812987", "0.5981025", "0.5981025", "0.5981025", "0.5981025", "0.5981025", "0.5981025", "0.5981025", "0.59720004", "0.59706753", "0.59704894", "0.5965438", "0.5959862", "0.5959862", "0.5940332", "0.59307957", "0.59246236", "0.5919743", "0.59155095", "0.5914602", "0.59083414", "0.5896778", "0.58826005", "0.5848454", "0.5841233", "0.58410794", "0.58404255", "0.58365047", "0.58296424", "0.582855", "0.58259135", "0.582335", "0.582335", "0.5816341", "0.58107996", "0.58099693", "0.5809269", "0.58092046", "0.580084", "0.57995397", "0.5793562", "0.5790273", "0.57805246", "0.57775027", "0.5775002", "0.5774962" ]
0.82323426
0
Returns an array of scheduled task names.
def registered_tasks # Get the task folder that contains the tasks. taskCollection = root_folder.GetTasks(0) array = [] taskCollection.each do |registeredTask| array.push(registeredTask) end array end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def task_names\n map do |task|\n task.name\n end\n end", "def task_names\n @task_names ||= tasks.map { |task| task.name.underscore }\n end", "def tasks\n @tasks.values.sort_by { |t| t.name }\n end", "def get_available_tasks\n tasks_to_return = []\n @tasks_names.each{ |t_name|\n tasks_to_return.push(@tasks[t_name])\n } \n return tasks_to_return\n end", "def tasks\n TapirLogger.instance.log \"Getting tasks for #{self}\"\n tasks = TaskManager.instance.get_tasks_for(self)\n tasks.sort_by{ |t| t.name.downcase }\n end", "def tasks\n TapirLogger.instance.log \"Getting tasks for #{self}\"\n tasks = TaskManager.instance.get_tasks_for(self)\n tasks.sort_by{ |t| t.name.downcase }\n end", "def tasks\n @db[:tasks].keys.compact.uniq || []\n end", "def task_names \n\t\t\tHelpers::DATABASE[:Tasks].join(:Task_list, :Tasks__Id => :Task_list__Task_Id).join(\n\t\t\t:Lists, :Lists__Id => :Task_list__List_id).select(:Tasks__Id, :Tasks__Task_number, \n\t\t\t:Tasks__Name, :Tasks__Completed, :Tasks__Priority).filter(:Lists__Name => Config[:working_list_name])\n\t\tend", "def tasks_list\n (self.tasks || EMPTY_STRING).scan(/\\d+/).map{|x| x.to_i}.sort.uniq\n end", "def task_list\n self.tasks.map do |task|\n task.text\n end\n end", "def scheduled_tasks\n self.tasks.select { \n |t| t.interval != :startup && t.interval != :shutdown\n }\n end", "def registered_task_names(group = nil)\n task_map(group).keys.dup\n end", "def tasks\n return @tasks.values\n end", "def tasks\n task_list.tasks\n end", "def names_only(tasks)\r\n tasks.map {|task| task[\"name\"]}\r\nend", "def all_tasks\n @all_tasks ||= []\n end", "def tasks\n return @tasks\n end", "def tasks\n return @tasks\n end", "def tasks\n return @tasks\n end", "def current_context_task_names()\n @cached_tasks.fetch(@active_context.get_task_cache_id(),[]).dup\n end", "def tasks\n @client.list_tasks(cluster: @cluster, service_name: @name)[0]\n end", "def all\n return @tasks\n end", "def done_task(events)\n\tids = []\n\ttask = []\n\tevents.each do |e|\n\t\tif e.to_h[:event_type] == 'ActivityTaskCompleted'\n\t\t\tids << e.to_h[:attributes][:scheduled_event_id]\n\t\telsif e.to_h[:event_type] == 'ActivityTaskScheduled' && ids.include?(e.to_h[:event_id])\n\t\t\ttask << e.to_h[:attributes][:activity_type].name\n\t\tend\n\tend\n\treturn task\nend", "def active_tasks\n output = []\n @@task_types.each do |association_symbol|\n output = output + self.send(association_symbol).active\n end\n output\n end", "def all\n Array(@@job_scheduler_instance)\n end", "def scheduled\n jobs_index(Job.scheduled)\n end", "def list_tasks\n config = instantiate_configuration\n config.load 'deploy'\n \n set_up_config(config)\n \n config.task_list(:all)\n end", "def tasks\n tasks = []\n @ProjectFileLoader.LoadedProjectFiles().each do |projectFile|\n tasks.concat(projectFile.tasks)\n end\n return tasks\n end", "def unassigned_tasks\n output = []\n @@task_types.each do |association_symbol|\n output = output + self.send(association_symbol).unassigned\n end\n output\n end", "def scheduled\n response = get 'scheduled'\n response.map{|item| Hashie::Mash.new(item)}\n end", "def taskLabels\n object.task_labels\n end", "def tasks\n if @tasks.nil?\n @tasks = tasks_by_filters\n @tasks = filter_by_tags(@tasks)\n @tasks += unread_tasks if session[:show_all_unread].to_i > 0\n @tasks = sort_tasks(@tasks)\n end\n\n return @tasks\n end", "def getTasklist\r\n\t\t\t\t\treturn @tasklist\r\n\t\t\t\tend", "def get_tasks(param_map, *args)\n #Strip off the first element, since it is not a Task\n get(\"tasks\", param_map, Babar::Task, true, *args)\n end", "def tasks\n EarLogger.instance.log \"Getting tasks for #{self}\"\n TaskManager.instance.get_tasks_for(self)\n end", "def tasks\n @task_manager.tasks_in_scope(@scope)\n end", "def tasks\n config[:tasks]\n end", "def tasks\n @task_manager.tasks_in_scope(@scope)\n end", "def list_bare_tasks\n load_tasks\n\n Thor::Base.subclasses.each do |klass|\n unless klass == Thor\n klass.tasks.each do |t|\n puts \"#{klass.namespace}:#{t[0]}\"\n end\n end\n end\n end", "def registered_tasks\n @task_register_lock.synchronize do\n @registered_tasks.values\n end\n end", "def registered_tasks\n @task_register_lock.synchronize do\n @registered_tasks.values\n end\n end", "def names_list\n backend.queue_names\n end", "def getSubtasks\r\n\t\t\t\t\treturn @tasks\r\n\t\t\t\tend", "def tasks_for_all_configurations\n @configurations.keys.collect{ |name| \"#{@project_name}:#{name}\"}\n end", "def ids\n @schedules.map(&:id)\n end", "def task_list\n return @task_list if @task_list\n @task_list = []\n spec_file_names.each do |file_name_spec|\n next if spec_is_disabled? file_name_spec\n next if skip_globals? file_name_spec\n next unless spec_included? file_name_spec\n get_spec_runs(file_name_spec).each do |run|\n next unless run[:hiera] and run[:facts]\n next unless facts_included? run[:facts]\n next unless hiera_included? run[:hiera]\n task = Noop::Task.new file_name_spec, run[:hiera], run[:facts]\n task.parallel = true if parallel_run?\n @task_list << task\n end\n end\n @task_list\n end", "def task_file_names\n return @task_file_names if @task_file_names\n error \"No #{Noop::Config.dir_path_tasks_local} directory!\" unless Noop::Config.dir_path_tasks_local.directory?\n @task_file_names = find_files(Noop::Config.dir_path_tasks_local, Noop::Config.dir_path_tasks_local) do |file|\n file.to_s.end_with? '.pp'\n end\n end", "def task_triggers\n return @task_triggers\n end", "def tasks\n @config.map do |task_name, options|\n task_params = options.symbolize_keys\n task_params[:queue_ahead] ||= @queue_ahead\n task_params[:name] = task_name\n task_params[:tz] ||= @time_zone\n Task.new(task_params)\n end\n end", "def schedules\n workers.map(&:schedule)\n end", "def own_tasks\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:task, RDF.type, Ruta::Class.task],\n [:task, Ruta::Property.has_creator, uri]\n )\n tasks = []\n query.each_solution { |sol| tasks.push(sol.task.as(Task)) }\n tasks\n end", "def get_taskarray\n @task_array\n end", "def tasks\n @tasks ||= Evoke.tasks\n end", "def get_all_tasks(child_name)\n command_o_tasks, identifier_o_tasks = [], []\n command_o_tasks = (self[:all][child_name]||[]) + (self[:command_only][child_name]||[])\n identifier_o_tasks = (self[:all][child_name]||[]) + (self[:identifier_only][child_name]||[])\n return command_o_tasks, identifier_o_tasks\n end", "def list_tasks\n load_tasks\n\n # set '$thor_runner' to true to display full namespace\n $thor_runner = true\n\n list = [] #Thor.printable_tasks(all = true, subcommand = true)\n Thor::Base.subclasses.each do |klass|\n list += klass.printable_tasks(false) unless klass == Thor\n end\n list.sort!{ |a,b| a[0] <=> b[0] }\n\n title = \"repo_manager tasks\"\n shell.say shell.set_color(title, :blue, bold=true)\n shell.say \"-\" * title.size\n shell.print_table(list, :ident => 2, :truncate => true)\n end", "def registeredTasks _args\n \"registeredTasks _args;\" \n end", "def startup_tasks\n self.tasks.select { |t| t.interval == :startup }\n end", "def tasks\n ProjectConfiguration.templates[template]::TASKS\n end", "def tasks\n ProjectConfiguration.templates[template]::TASKS\n end", "def all_tasks\n self.stories.collect { |s| s.tasks }.flatten\n end", "def tasks\n @tasks ||= {}\n end", "def invoked_tasks\n @invoked_tasks\n end", "def tasks\n if @tasks.nil?\n @tasks ||= (filtering_by_tags? ? tasks_by_tags : tasks_by_filters)\n @tasks = filter_by_properties(@tasks)\n @tasks = sort_tasks(@tasks)\n end\n\n return @tasks\n end", "def task_definitions\n return @task_definitions\n end", "def get_sorted_list_of_tasks\r\n tasks = @current_user.tasks.find(:all, :conditions => {:is_finished => false, :active_task => true})\r\n unstarted_tasks = @current_user.tasks.find(:all, :conditions => {:is_finished => false, :started_at => nil}).sort_by {|t| t.created_at}\r\n finished_tasks = @current_user.tasks.find(:all, :conditions => {:is_finished => true}).sort_by {|t| t.created_at}\r\n\r\n tasks.concat(unstarted_tasks).concat(finished_tasks)\r\n return tasks\r\n end", "def get_tasks\n\n\ttasks = Task.all.shuffle\n\n\treturned_tasks = []\n\trand(10..18).times do\n\t\treturned_tasks << tasks.pop\n\tend\n\n\treturned_tasks\nend", "def tasks\n return self.class.get('/tasks').parsed_response.map do |task|\n Task.new(\n task['task_id'],\n task['template_id'],\n task['status'],\n task['started_at']\n )\n end\n end", "def list_tasks\r\n unless tasks\r\n puts \"No tasks yet. Add one!\"\r\n return\r\n end\r\n # Pretty-format hash and print\r\n print \" \" + \"ITEM\".ljust(30) + \" | \" +\r\n \"WHEN DUE\".ljust(15) + \" | \" +\r\n \"WHEN ADDED\".ljust(15) + \"\\n\"\r\n tasks.each do |task|\r\n print \"<#{tasks.find_index(task) + 1}>\".ljust(5) +\r\n task[:text].ljust(30) + \" | \" +\r\n task[:due].ljust(15) + \" | \" +\r\n task[:time].ljust(15) + \"\\n\"\r\n end\r\n end", "def task_schedule_status(task)\n\t\tstatus = []\n\tend", "def work_tasks\n uri = self.uri\n query = Ruta::Sparql.select.where(\n [:task, RDF.type, Ruta::Class.task],\n [:task, Ruta::Property.has_worker, uri]\n )\n tasks = []\n query.each_solution { |sol| tasks.push(sol.task.as(Task)) }\n tasks\n end", "def getTaskName\r\n\t\t\t\t\treturn @taskName\r\n\t\t\t\tend", "def actionable_tasks\n\t\tnext_tasks.select{ |t| !t.deferred? }\n\tend", "def name\n\t\t\t@task\n end", "def task_options\n task_types.map do |et|\n [et.gsub('Task', '').titlecase, et]\n end\n end", "def tasks\n Easybill::Api::Tasks\n end", "def timer_metric_names\n timers.map { |op| op.first }\n end", "def incoming_task_runs\n TapirLogger.instance.log \"Finding task runs for #{self}\"\n incoming_task_runs = []\n\n self.entity_mappings.each do |mapping|\n incoming_task_runs << mapping.get_task_run if mapping.get_child == self\n end\n incoming_task_runs\n end", "def tasks\n\t\t@tasks ||= if self.id.nil?\n\t\t\t[]\n\t\telse\n\t\t\tt_arr = document.tasks.select(container_id: self.id)\n\t\t\ti = 0\n\t\t\twhile i < t_arr.size\n\t\t\t\ttask = t_arr[i]\n\t\t\t\tif task.has_subtasks?\n\t\t\t\t\tt_arr += t_arr.delete_at(i).tasks\n\t\t\t\telse\n\t\t\t\t\ti += 1\n\t\t\t\tend\n\t\t\tend\n\t\t\tt_arr\n\t\tend\n\tend", "def scheduled\n @scheduled ||= count('scheduled')\n end", "def show # Show tasks method\n all_tasks.map.with_index { |l, i| \"(#{i.next}): #{l}\"} # Show all tasks array in numerical order and whether a task is completed\n end", "def tasks(tasklist_id = '@default')\n get gtasks_tasks_url(tasklist_id)\n end", "def list_of_node_names(options={})\n list_of_running_instances.collect {|ri| ri.name }\n end", "def due_tasks\n tasks = []\n\n all_tasks.each do |task|\n due = task.due_date.get\n\n if due.is_a?(Time) && due > Time.new\n tasks << Task.new(task.name.get, due)\n end\n end\n\n # Sorts the array of tasks by due_date\n tasks.sort! { |a,b| a.due_date <=> b.due_date }\n end", "def active_tasks\n @tasks.select { | task | task.active }\n end", "def currentTasks _args\n \"currentTasks _args;\" \n end", "def task_lists(current_token)\n session = RedboothRuby::Session.new(token: current_token)\n client = RedboothRuby::Client.new(session)\n\n client.task_list(:index, project_id: self.id).all\n end", "def scheduled_task_count\n @executor.getTaskCount\n end", "def print_tasks_in_interval\n tasks = retrieve_tasks\n @values[:result] = Array.new()\n print_tasks_to_key(tasks[:during])\n end", "def get_task_types_eng\n [\"vat_jan\", \"vat_mar\", \"vat_may\", \"vat_jul\", \"vat_sept\", \"vat_nov\", \"voucher\", \"income_tax\"]\n end", "def onetime_rake_files\n tasks_dir = self.tasks_directory\n return [] unless Dir.exist?(tasks_dir) && !Dir.empty?(tasks_dir)\n\n Dir.glob(File.join('**', '*.rake'), base: tasks_dir)\n end", "def tasks(wspace=workspace)\n\t\twspace.tasks\n\tend", "def list_all_tasks\n task = Task.all\nend", "def build_tasks\n all_output.split(\"\\n\").map do |task|\n next unless task.start_with? 'rake'\n task.split(\"#\").map{|t| t.strip.sub(/^rake /, '')}\n end.compact\n end", "def tasks_for_timeline\n tasks_f_time ||= []\n milestones.each do |mile|\n mile.tasks.each do |task|\n task.update(start_date: start_date) if task.start_date.nil?\n task.update(end_date: task.start_date + task.pm_duration_estimation.days) if task.end_date.nil?\n tasks_f_time << [task.name + ' | ' + mile.name + ' | ' + task.advance_percentage.to_s + \"% \", task.start_date, task.end_date]\n end\n end\n tasks_f_time\n end", "def collect_tasks\n tasks = []\n $sake_op = {}\n ARGV.each do |arg|\n if arg =~ /^(\\w+)=(.*)$/\n ENV[$1] = $2\n $sake_op[$1.to_sym] = $2\n else\n tasks << arg\n end\n end\n tasks.push(\"default\") if tasks.size == 0\n tasks\n end", "def custom_install_tasks_for(a=nil)\n []\n end", "def display_tasks\n puts \"What do you want to do? \\n\"\n puts TASKS.values\n end", "def custom_configure_tasks_for(a=nil)\n []\n end", "def failed_tasks\n return @failed_tasks\n end", "def failed_tasks\n return @failed_tasks\n end" ]
[ "0.8267654", "0.7885229", "0.6916532", "0.6887011", "0.68063265", "0.68063265", "0.6793123", "0.6790763", "0.67788714", "0.67696404", "0.67555577", "0.6701266", "0.66570085", "0.65295386", "0.65056837", "0.6431892", "0.6359984", "0.6359984", "0.6359984", "0.63354063", "0.6294117", "0.62649417", "0.62628686", "0.6228422", "0.6128675", "0.6098532", "0.6097049", "0.60503215", "0.6047591", "0.6019637", "0.60162807", "0.6013648", "0.60094345", "0.5979495", "0.5978934", "0.59673864", "0.59617037", "0.59582573", "0.5954182", "0.59513307", "0.595109", "0.593475", "0.5934114", "0.59310055", "0.5930787", "0.59276956", "0.59182996", "0.5910089", "0.58774066", "0.5875987", "0.58755016", "0.5874124", "0.5872328", "0.58504695", "0.583525", "0.58304596", "0.5809149", "0.5802106", "0.5802106", "0.5789875", "0.5782359", "0.5779259", "0.57788104", "0.5770363", "0.57592535", "0.5758731", "0.57559115", "0.57475597", "0.5739031", "0.57271534", "0.57147956", "0.5706936", "0.56892926", "0.56859434", "0.56802106", "0.56799245", "0.5668875", "0.56682605", "0.5667054", "0.5644609", "0.5637809", "0.56289464", "0.562878", "0.5619321", "0.5614782", "0.5598713", "0.55911505", "0.55734956", "0.55535996", "0.5552918", "0.5550243", "0.55479795", "0.554609", "0.5535681", "0.5532298", "0.550852", "0.5500687", "0.5500497", "0.54858685", "0.54858685" ]
0.6828243
4
Array of states (04) based on the constants
def current_state(name) task = get_task(name) case when task.nil? "Not Created" when task.State >= 0 && task.State <= 4 ["Unknown", "Disabled", "Queued", "Ready", "Running"].fetch(task.State) when task.State == 3 && task.LastTaskResult == 0 "Completed" end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def state_array\n %w(AK AL AR AZ CA CO CT DC DE FL GA HI IA ID IL IN KS KY LA MA MD ME MI MN MO MS MT NC ND NE NH NJ NM NV NY OH OK OR PA RI SC SD TN TX UT VA VT WA WI WV WY)\nend", "def states\n\t[:shelf,:in_use,:borrowed,:misplaced,:lost]\nend", "def state\n [\n [\"AC\",\"Acre\"],\n [\"AL\",\"Alagoas\"],\n [\"AP\",\"Amapa\"],\n [\"AM\",\"Amazonas\"],\n [\"BA\",\"Bahia\"],\n [\"CE\",\"Ceara\"],\n [\"DF\",\"Distrito Federal\"],\n [\"ES\",\"Espirito Santo\"],\n [\"GO\",\"Goias\"],\n [\"MA\",\"Maranhao\"],\n [\"MT\",\"Mato Grosso\"],\n [\"MS\",\"Mato Grosso do Sul\"],\n [\"MG\",\"Minas Gerais\"],\n [\"PA\",\"Para\"],\n [\"PB\",\"Paraiba\"],\n [\"PR\",\"Parana\"],\n [\"PE\",\"Pernambuco\"],\n [\"PI\",\"Piaui\"],\n [\"RJ\",\"Rio de Janeiro\"],\n [\"RN\",\"Rio Grande do Norte\"],\n [\"RS\",\"Rio Grande do Sul\"],\n [\"RO\",\"Rondonia\"],\n [\"RR\",\"Roraima\"],\n [\"SC\",\"Santa Catarina\"],\n [\"SP\",\"Sao Paulo\"],\n [\"SE\",\"Sergipe\"],\n [\"TO\",\"Tocantins\"],\n ]\n end", "def states\n []\n end", "def states\n []\n end", "def state\n [\n [\"AC\", \"Acre\"],\n [\"AL\", \"Alagoas\"],\n [\"AP\", \"Amapa\"],\n [\"AM\", \"Amazonas\"],\n [\"BA\", \"Bahia\"],\n [\"CE\", \"Ceara\"],\n [\"DF\", \"Distrito Federal\"],\n [\"ES\", \"Espirito Santo\"],\n [\"GO\", \"Goias\"],\n [\"MA\", \"Maranhao\"],\n [\"MT\", \"Mato Grosso\"],\n [\"MS\", \"Mato Grosso do Sul\"],\n [\"MG\", \"Minas Gerais\"],\n [\"PA\", \"Para\"],\n [\"PB\", \"Paraiba\"],\n [\"PR\", \"Parana\"],\n [\"PE\", \"Pernambuco\"],\n [\"PI\", \"Piaui\"],\n [\"RJ\", \"Rio de Janeiro\"],\n [\"RN\", \"Rio Grande do Norte\"],\n [\"RS\", \"Rio Grande do Sul\"],\n [\"RO\", \"Rondonia\"],\n [\"RR\", \"Roraima\"],\n [\"SC\", \"Santa Catarina\"],\n [\"SP\", \"Sao Paulo\"],\n [\"SE\", \"Sergipe\"],\n [\"TO\", \"Tocantins\"],\n ]\n end", "def states\r\n @states.collect {|id| $data_states[id] }\r\n end", "def available_states\n states = []\n states << :passive if passive?\n states << :pending if passive? || pending?\n states << :active\n states << :suspended unless deleted?\n states << :deleted\n states\n end", "def states; end", "def states\n [\n ['0', 'EMERGENCY_SHUTDOWN',\n 'State machine has a bug, cannot be trusted']\n ]\n end", "def states\n is = (0...grid.size).to_a\n js = (0...grid.first.size).to_a\n is.product(js).select { |i, j| grid[i][j] } + [:stop]\n end", "def known_states; end", "def known_states; end", "def known_states; end", "def states; @_hegemon_states.keys; end", "def states\n @finity.states.map { |name, _| name }\n end", "def states\n @states ||= {}\n end", "def valid_states\n aasm.states.map(&:name).map(&:to_s)\n end", "def to_states; end", "def to_states; end", "def to_a\n @_states.values\n end", "def get_sprite_states()\n [\n [\"walking\", [\"/sprites/moogle_s_w0.png\", \"/sprites/moogle_s_w1.png\"]],\n [\"alert\", [\"/sprites/moogle_s_alert0.png\"]]\n ]\n end", "def states\n no_set_states + set_bonuses\n end", "def states\r\n return @states.uniq\r\n end", "def from_states; end", "def from_states; end", "def perpetual_states\n feature_array(:perpetual_states, true).map { |state_id| $data_states[state_id] }.compact\n end", "def states(refresh=false)\n @states ||= []\n assert_states if refresh\n @states\n end", "def states\n [\n @current_domain,\n @current_schema,\n @current_relation,\n @current_attribute,\n @current_property\n ]\n end", "def get_pending_states\n self.statemap['on_pending'].map{|state, _| state}\n end", "def states\n [\n ['0', 'TEST_ACTION_LOADED', 'Test state been loaded into DB']\n ]\n end", "def states\n @attributes[\"data\"][\"states\"]\n end", "def initial_state\n []\n end", "def state_wins\n WINS.map { |win| [ $state[win[0]], $state[win[1]], $state[win[2]] ] }\nend", "def orderStates\n @states = Hash.new\n @states[0] = \"Processing\"\n @states[1] = \"Shipped\"\n @states[2] = \"Delivered\"\n @states[3] = \"Cancelled\"\n end", "def get_state\n@state.keys\nend", "def state_list(states)\n ul(states.map { |s| state_short s })\n end", "def start_states\n empty_state = State.new([0] * @board_size**2)\n states = SortedSet.new\n empty_state.random_successors.each do |one_tile_state|\n one_tile_state.random_successors.each do |two_tile_state|\n states << two_tile_state.canonicalize\n end\n end\n states.to_a\n end", "def define_states\n\treturn ({\n\t\t\"Oregon\" => \"OR\",\n\t\t\"Alabama\" => \"AL\",\n\t\t\"New Jersey\" => \"NJ\",\n\t\t\"Colorado\" => \"CO\"\n\t})\nend", "def moves\n\t\tm = []\n\t\t@@moves.each do |move|\n\t\t\tfrom, to = move\n\n\t\t\tp1 = @value & MASKS[from]\n\t\t\tp2 = @value & MASKS[to]\n\n\t\t\tshift = (to - from) * 3\n\t\t\tp1 = p1 >> shift\n\t\t\tp2 = p2 << shift\n\n\t\t\tnum = (@value & INV_MASKS[from]) | p2\n\t\t\tnum = (num & INV_MASKS[to]) | p1\n\n\t\t\tm << State.new(num, @n_moves + 1)\n\t\tend\n\t\tm\n\tend", "def get_states\n perform(:get, 'enum/states', nil, nonauth_headers).body\n end", "def status_enum\n [\n [STATUSES.active],\n [STATUSES.resolved],\n [STATUSES.cancelled],\n [STATUSES.deleted]\n ]\n end", "def states\n [\n ['Alabama', 'AL'],\n ['Alaska', 'AK'],\n ['Arizona', 'AZ'],\n ['Arkansas', 'AR'],\n ['California', 'CA'],\n ['Colorado', 'CO'],\n ['Connecticut', 'CT'],\n ['Delaware', 'DE'],\n ['District of Columbia', 'DC'],\n ['Florida', 'FL'],\n ['Georgia', 'GA'],\n ['Hawaii', 'HI'],\n ['Idaho', 'ID'],\n ['Illinois', 'IL'],\n ['Indiana', 'IN'],\n ['Iowa', 'IA'],\n ['Kansas', 'KS'],\n ['Kentucky', 'KY'],\n ['Louisiana', 'LA'],\n ['Maine', 'ME'],\n ['Maryland', 'MD'],\n ['Massachusetts', 'MA'],\n ['Michigan', 'MI'],\n ['Minnesota', 'MN'],\n ['Mississippi', 'MS'],\n ['Missouri', 'MO'],\n ['Montana', 'MT'],\n ['Nebraska', 'NE'],\n ['Nevada', 'NV'],\n ['New Hampshire', 'NH'],\n ['New Jersey', 'NJ'],\n ['New Mexico', 'NM'],\n ['New York', 'NY'],\n ['North Carolina', 'NC'],\n ['North Dakota', 'ND'],\n ['Ohio', 'OH'],\n ['Oklahoma', 'OK'],\n ['Oregon', 'OR'],\n ['Pennsylvania', 'PA'],\n ['Puerto Rico', 'PR'],\n ['Rhode Island', 'RI'],\n ['South Carolina', 'SC'],\n ['South Dakota', 'SD'],\n ['Tennessee', 'TN'],\n ['Texas', 'TX'],\n ['Utah', 'UT'],\n ['Vermont', 'VT'],\n ['Virginia', 'VA'],\n ['Washington', 'WA'],\n ['West Virginia', 'WV'],\n ['Wisconsin', 'WI'],\n ['Wyoming', 'WY']\n ]\n end", "def states\n states = Set.new([@initial_state])\n @transitions.each { |k,v| states += v.values }\n states\n end", "def available_states # :nodoc:\n if @states\n return @states\n end\n end", "def next_states\n possible = []\n # possible states going up\n possible += next_states_in_dir(1) if @elevator != 3\n # possible states going down only make sense if there are actually some items available at lower floors\n items_lower = @floors[0...@elevator].map { |floor| floor.length }.sum\n possible += next_states_in_dir(-1) if (@elevator != 0) && (items_lower > 0)\n\n return possible\n end", "def transitions\n [\n {:parked => :idling, :on => :ignite},\n {:idling => :first_gear, :first_gear => :second_gear, :on => :shift_up}\n # ...\n ]\n end", "def states\n [\n 'CREATE_IN_PROGRESS',\n 'CREATE_IN_PROGRESS',\n 'CREATE_FAILED',\n 'CREATE_COMPLETE',\n 'ROLLBACK_IN_PROGRESS',\n 'ROLLBACK_FAILED',\n 'ROLLBACK_COMPLETE',\n 'DELETE_IN_PROGRESS',\n 'DELETE_FAILED',\n 'DELETE_COMPLETE',\n 'UPDATE_IN_PROGRESS',\n 'UPDATE_COMPLETE_CLEANUP_IN_PROGRESS',\n 'UPDATE_COMPLETE',\n 'UPDATE_ROLLBACK_IN_PROGRESS',\n 'UPDATE_ROLLBACK_FAILED',\n 'UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS',\n 'UPDATE_ROLLBACK_COMPLETE',\n 'REVIEW_IN_PROGRESS'\n ]\n end", "def state_icons\r\n icons = states.collect {|state| state.icon_index }\r\n icons.delete(0)\r\n icons\r\n end", "def initialize(num_states: 100, num_actions: 4, alpha: 0.2, gamma: 0.9, rar: 0.5, radr: 0.99, dyna: 0, verbose: false)\n @states = Array.new(num_states)\n @actions = Array.new(num_actions)\n @alpha = alpha\n @gamma = gamma\n @rar = rar\n @radr = radr\n @dyna = dyna\n @verbase = verbose\n @q = (0..99).map{|_| (0..3).map{|_| 0}}\n\n @past = []\n # @q = {}\n # 100.times do |s|\n # @q[s] = {}\n # 4.times {|a| @q[s][a] = 0}\n # end\n end", "def current_board_state(brd) # returns nested arrays of each winning line and their state.\n current_state_of_lines = []\n WINNING_LINES.each do |line|\n current_state_of_lines << brd.values_at(*line)\n end\nend", "def feature_objects\r\n states\r\n end", "def state(index = :all)\n index = check_index(index)\n res = cmd(COMMANDS[:state]).ord\n res = (0...size).to_a.map { |pos| (res & (0x01 << pos)) >> pos }\n res = res[index - 1] if index && index.nonzero?\n res\n end", "def state_keys\n @state.keys\n end", "def get_ok_states\n self.statemap['on_running'].map{|_, new_states| new_states['ok']}\n end", "def light_switches(n)\n light_hash = {}\n 1.upto(n) { |i| light_hash[i] = true }\n 2.upto(n) do |current_pass|\n light_hash.map do |light, state|\n light_hash[light] = !state if light % current_pass == 0\n end\n end\n lights_left_on = light_hash.select do |_, state|\n state\n end\n result = []\n lights_left_on.to_a.flatten.each_with_index do |element, index|\n result << element if index.even?\n end\n result\nend", "def device_states_list\n get \"deviceStates\"\n end", "def assert_states\n @states ||= []\n @states.upush! *@transitions.map {|e| [e.from_state, e.to_state]}.flatten.uniq\n end", "def stringToState(position)\n state = Array.new(3) {Array.new(3,0)}\n count = 0\n for x in 0..2\n for y in 0..2\n state[x][y] = position[count].to_i\n count+=1\n end\n end\n return state\n end", "def next_states\n states = []\n for direction in [\"up\", \"down\", \"left\", \"right\"] do\n new_rows = slide(direction)\n states << Grid.new(@x, @y, new_rows) unless new_rows.nil?\n end\n states\n end", "def states\n peek_state\n if !@state_queue.empty?\n @current_state = @state_queue.last\n @state_queue,old = [],@state_queue\n old\n else\n []\n end\n end", "def get_possible_states\n if queens_size == @size\n return Array.new\n end\n\n possible_states = Array.new\n bit_state = @state\n row_number = queens_size\n\n # Find possible locations in the empty row where a queen can be placed\n @size.times { |cell|\n if !@state[(@size * row_number) + cell]\n bit_state.set((@size * row_number) + cell)\n new_state = Bitset.from_s(@state.to_s)\n possible_states << new_state\n bit_state.clear((@size * row_number) + cell)\n end\n }\n\n if @random\n possible_states.sort_by! { rand }\n end\n\n return possible_states\n end", "def states\n (ex_attr_normal_states + perpetual_states).compact.\n sort{|s1, s2| s2.priority <=> s1.priority}\n end", "def state_objs; @_hegemon_states.clone; end", "def get_possible_states\n if queens_size == @size\n return Array.new\n end\n\n possible_states = Array.new\n bit_state = @state\n row_number = queens_size\n\n # Find possible locations in the empty row where a queen can be placed\n @size.times { |cell|\n if !@state[(@size * row_number) + cell]\n bit_state.set((@size * row_number) + cell)\n new_state = Bitset.from_s(@state.to_s)\n\n if is_valid_state(new_state)\n possible_states << new_state\n end\n\n bit_state.clear((@size * row_number) + cell)\n end\n }\n\n if @random\n possible_states.sort_by! { rand }\n end\n\n return possible_states\n end", "def pseudo_state_list(label)\n [\n [label, nil],\n ['Draft (new)', 'draft'],\n ['Draft (new versions)', 'published_being_edited'],\n ['Published', 'published'],\n ['Scheduled', 'scheduled'],\n ['Unpublished', 'unpublished']\n ]\n end", "def find_start_states_without_canonicalization\n states = []\n lose_state.random_successors.each do |one_tile_state|\n one_tile_state.random_successors.each do |two_tile_state|\n states << two_tile_state\n end\n end\n states\n end", "def state_obj; @_hegemon_states[@_hegemon_state]; end", "def all_state_keys\r\n @state_keys.keys\r\n end", "def control_points_to_states(control_points, timestep)\n bez = Bezier::Curve.new(*control_points.map{ |point| [point[\"x\"], point[\"y\"], point[\"z\"], point[\"rz\"]]})\n max_time = control_points.last[\"t\"]\n states = []\n time = 0\n while time <= max_time do\n point = bez.point_on_curve(time / max_time)\n states.push({\n :t => time,\n :x => point.x,\n :y => point.y,\n :z => point.z,\n :rx => 0.0,\n :ry => 0.0,\n :rz => point.r,\n })\n time += timestep\n end\n states\n end", "def known_states\n branch.known_states\n end", "def init_states\n russia_states = Country.find_by_iso(\"RU\").states\n ukraine_states = Country.find_by_iso(\"UA\").states\n @states = russia_states + ukraine_states\n end", "def get_lambda_transitions(state)\n transitions = []\n @lambda_table[state].each.with_index do |value, index|\n if value == 1\n transitions << index\n end\n end\n return transitions\n end", "def states_events\n states_events_config.map { |se| [ se[:to_state], se[:event], se[:event_description] || '' ] }\n end", "def get_possible_states\n if queens_size == @size\n return Array.new\n end\n\n possible_states = Array.new\n bit_state = @state\n bit_counter = 0\n\n # Go through each row and locate a state where a queen can be placed\n (@size * @size).times { |cell|\n if !@state[cell]\n bit_state.set(bit_counter)\n new_state = Bitset.from_s(@state.to_s)\n possible_states << new_state\n bit_state.clear(bit_counter)\n end\n bit_counter += 1\n }\n\n if @random\n possible_states.sort_by! { rand }\n end\n\n return possible_states\n end", "def state_full\n @@us_states.rand[0] \n end", "def setting_states\n return @setting_states\n end", "def board_to_nn_inputs(state)\n result = [0] * 27\n state.each.with_index {|v, i| result[3 * i + v + 1] = 1.0}\n result\n end", "def states\n (['show'] + actions).uniq\n end", "def get_possible_states\n if queens_size == @size\n return Array.new\n end\n\n possible_states = Array.new\n bit_state = @state\n bit_counter = 0\n\n # Go through each row and locate a state where a queen can be placed\n (@size * @size).times { |cell|\n if !@state[cell]\n bit_state.set(bit_counter)\n new_state = Bitset.from_s(@state.to_s)\n\n if is_valid_state(new_state)\n possible_states << new_state\n end\n\n bit_state.clear(bit_counter)\n end\n bit_counter += 1\n }\n\n if @random\n possible_states.sort_by! { rand }\n end\n\n return possible_states\n end", "def safe_bot_states()\n return @bot_states.values.map{|state| state.clone}\n end", "def state\n board.state(index)\n end", "def transitions(curr_state = nil, **)\n curr_state = state_value(curr_state)\n next_states = state_table.dig(curr_state, :next)\n Array.wrap(next_states).compact_blank\n end", "def state_time\n\t\tarr = []\n\t\t@state_in_stock.each do |state|\n\t\t\tarr << state.time\n\t\tend\n\t\tarr.shift\n\t\tarr\n\tend", "def all_state\n result = {:cook_state => RightScale::CookState, :chef_state => RightScale::ChefState}\n end", "def light_sequence(n)\n lights = {}\n n.times {|num| lights[num+1] = \"on\"}\n\n n.times do |num|\n lights.each do |light, status|\n if light % (num+1) == 0\n lights[light] == \"on\" ? lights[light] = \"off\" : lights[light] = \"on\"\n end\n end\n end\n\n lights.select {|light, status| status == 'off'}.keys\nend", "def connection_states\n hash = {}\n names = STATENAMES.reverse\n \n STATECODES.sort.each_with_index do |code, index|\n hash[names[index]] = code\n end\n \n return hash\n end", "def thousand_lights4(n)\n lights = [false]*n\n 1.upto(n) { |i| i.step(n, i) { |j| lights[j] = !lights[j] } }\n lights.each_with_index.with_object([]) { |(light, idx), obj| obj << idx if light }\nend", "def device_states\n return @device_states\n end", "def state\n @rotor_array\n end", "def issuing_states\n IssuingStateData.issuing_states(area, date_issued)\n end", "def plus_state_set\n return []\n end", "def index_state(index)\r\n @state[index]\r\n end", "def get_possible_states\n raise \"This is an abstract function!\"\n end", "def all_values\n _acts_as_enum_state.by_ordinal.values\n end", "def off_lights(lights)\n lights.select { |_position, state| state == \"off\" }.keys\nend", "def device_states=(value)\n @device_states = value\n end", "def status_allowed(state)\n allowed_states = case status\n when 'legacy'\n ['deleted']\n when 'provisional'\n ['pending', 'approved', 'deleted']\n when 'pending'\n ['approved', 'deleted']\n when 'approved'\n ['interred', 'deleted']\n when 'interred'\n ['completed', 'deleted']\n when 'completed'\n ['deleted']\n else\n []\n end\n \n allowed_states << status if self.class.valid_states.include?(state)\n allowed_states.include? state\n end", "def get_transitions(state, char)\n transition = @transition_table[state][char]\n if transition\n return [transition]\n else\n return []\n end\n end", "def get_actions_for_state(a_state)\r\n \tactions_list=Array.new\t\r\n \tself.adjacency_matrix[a_state].each do |a_transition|\r\n \t\tactions_list.push a_transition.action\t\r\n \tend # end each\r\n \t\r\n \treturn actions_list\t\r\n end", "def allowed_states\n RetentionSchedule.state_names.tap do |states|\n states.delete(RetentionSchedule::STATE_ANONYMISED)\n states.delete(RetentionSchedule::STATE_NOT_SET) unless record.not_set?\n end\n end" ]
[ "0.7809702", "0.73638105", "0.7338036", "0.73163986", "0.73163986", "0.71895164", "0.70708686", "0.6923798", "0.6869856", "0.684979", "0.68013966", "0.67171913", "0.67171913", "0.67171913", "0.6686074", "0.6683052", "0.666808", "0.65696436", "0.6566295", "0.6566295", "0.6506406", "0.6493571", "0.6438503", "0.64084566", "0.6314256", "0.6314256", "0.6294474", "0.62680686", "0.6241275", "0.62271565", "0.6214186", "0.62109977", "0.6181568", "0.6137733", "0.6100328", "0.6078555", "0.6054951", "0.6030287", "0.5988275", "0.5985714", "0.59747106", "0.5953358", "0.5937923", "0.5937035", "0.5921062", "0.59039575", "0.58928144", "0.58882874", "0.58815145", "0.5856074", "0.5847042", "0.5844323", "0.58341086", "0.5829234", "0.5812783", "0.5809246", "0.57937574", "0.5787095", "0.5782341", "0.5763684", "0.5754092", "0.5748261", "0.57439864", "0.57359445", "0.57283807", "0.5655013", "0.56497616", "0.563963", "0.5633649", "0.56294936", "0.56253403", "0.5614074", "0.56131333", "0.56119233", "0.5607031", "0.5603839", "0.5601536", "0.5592856", "0.5590297", "0.55841964", "0.5572559", "0.55724806", "0.55684173", "0.55444235", "0.55345047", "0.55257815", "0.55090356", "0.5507926", "0.54885924", "0.5484961", "0.5483408", "0.54831934", "0.54644585", "0.54616654", "0.54530203", "0.5452059", "0.54488474", "0.5446985", "0.54446244", "0.54295796", "0.5426292" ]
0.0
-1
Load a local profile return the SharedCredentials object or nil
def loadProfile(profile=nil) # CAUTION: We are returning if profile is nil because otherwise AWS will try to use "Default" profile return nil if profile.nil? begin #ruby syntax equivalant to try # Read the credentials from the given profile credentials = Aws::SharedCredentials.new(profile_name: profile) # make sure profile exists before proceeding rescue Exception => e # ruby syntax equivalant to catch puts "\e[31mERROR: #{e.message}\e[0m" exit 1 end return credentials if credentials.loadable? puts "\e[31mERROR: Credentials are not loadable. Make sure you have ~/.aws configured correctly.\e[0m" return nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get(profile='default')\n raise 'Config File does not exist' unless File.exists?(@file)\n\n @credentials = parse if @credentials.nil?\n raise 'The profile is not specified in the config file' unless @credentials.has_key?(profile)\n\n @credentials[profile]\n end", "def load_profile(cred_opts)\n creds = Wavefront::Credentials.new(cred_opts).config\n creds.transform_keys(&:to_sym)\n end", "def load_profile(name); end", "def authenticate_for_profile\n begin\n Garb::Session.login(HHD::Config.analytics_email, HHD::Config.analytics_pwd)\n Garb::Profile.first(HHD::Config.analytics_profile)\n rescue\n nil\n end\n end", "def profile\n threaded[:profile] ||= Profile.load\n end", "def profile\n threaded[:profile] ||= Profile.load\n end", "def get_existing_profile(usr_prf)\n raise Utility::Errors::NotFound, \"Invalid UserProfile!\" unless usr_prf.present?\n get_prebuilt_profile(usr_prf.person_authenticated_key)\n end", "def get_existing_profile(usr_prf)\n raise Utility::Errors::NotFound, \"Invalid UserProfile!\" unless usr_prf.present?\n get_prebuilt_profile(usr_prf.person_authentication_key)\n end", "def get_prebuilt_profile(pak)\n profile = nil\n profile = get_storage_object(pak)\n Rails.logger.debug(\"#{self.class.name.to_s}.#{__method__}() returns: #{profile}\")\n profile\n end", "def profile\n env['profile']\n end", "def load_user_and_profile\n\t\t@user = current_user\n\t\t@user.load_profile\n\t\t@profile = @user.profile\n\tend", "def load_profile(key)\n Merit::LoadProfile.load(load_profile_path(key))\n rescue NameError => ex\n raise(ex.message.match(/Merit$/) ? MeritRequired.new : ex)\n end", "def profile\n @profile ||= Profile.find_for_uid_and_network(self.uid, self.provider)\n end", "def get_profile\n begin\n client.profile(fields: PROFILE_FIELDS)\n rescue Exception => e\n logger.error \"Linkedin #get_profile error #{e}\"\n end\n end", "def read_profile_preferences(profile)\n dir = profile.layout_on_disk\n File.read(File.join(dir, \"user.js\"))\n end", "def check_creds()\n debug_msg(\"Checking credentials for profile \\\"#{$profile}\\\"\")\n my_id=\"\"\n begin\n sts = Aws::STS::Client.new(region: \"eu-west-1\", credentials: $credentials)\n my_id= sts.get_caller_identity().account\n rescue => err\n err_msg (\"Unable to login using profile #{$profile}: #{err}\")\n exit(E_PROFILE_ERR)\n end\nend", "def profile\n if Configuration.host_based_profiles\n request_hostname\n else\n CurrentUser.user_settings[:profile].to_sym if CurrentUser.user_settings[:profile]\n end\n end", "def load_profile(params)\n db = connect()\n profile = db.execute('SELECT * FROM users WHERE Id=?', params[\"id\"])\n return profile.first\n end", "def twitter_auth_cache\n self.auth_profiles.where(provider: 'twitter').first\n end", "def current_profile\n @profile ||= JSON.parse($redis.get(\"profile\"))\n end", "def profile\n unless @profile\n if associated_profile\n @profile = Profile.new(associated_profile)\n else\n options = {:fields => 'user_id', :includes => 'Profile'}\n options = options.merge(:access_token => token, :access_secret => secret) if (token && secret)\n tmp = User.find(username, options)\n @profile = Profile.new(tmp.associated_profile)\n end\n end\n @profile\n end", "def facebook_auth_cache\n self.auth_profiles.where(provider: 'facebook').first\n end", "def load_profile( profiles )\n exception_jail{\n @opts.load_profile = nil\n profiles.each { |filename| @opts.merge!( @opts.load( filename ) ) }\n }\n end", "def get_profile\n\n # Auth\n token = auth\n\n # Get Client info based on fields provided\n client = LinkedIn::Client.new(API_KEY, API_SECRET, token)\n client.profile(:fields => @profile_fields)\n end", "def getUser(sessionId, userName)\n fullPath = \"#{@APPLICATION_HOME}/dashboard/.profiles/#{userName}.yaml\"\n if(userName != nil)\n\n return YAML.load_file(fullPath)\n end\n end", "def profile; Profile.get(self.profile_id); end", "def get_credentials\n # http://docs.aws.amazon.com/cli/latest/userguide/cli-chap-getting-started.html#cli-environment\n credentials_file = ENV.fetch(\"AWS_SHARED_CREDENTIALS_FILE\", ENV[\"AWS_CONFIG_FILE\"])\n shared_creds = ::Aws::SharedCredentials.new(\n profile_name: profile_name,\n path: credentials_file\n )\n instance_profile_creds = ::Aws::InstanceProfileCredentials.new(retries: 1)\n\n if ENV[\"AWS_ACCESS_KEY_ID\"] && ENV[\"AWS_SECRET_ACCESS_KEY\"]\n creds = ::Aws::Credentials.new(\n ENV[\"AWS_ACCESS_KEY_ID\"],\n ENV[\"AWS_SECRET_ACCESS_KEY\"],\n ENV[\"AWS_SESSION_TOKEN\"]\n )\n elsif shared_creds.set?\n creds = shared_creds\n elsif instance_profile_creds.set?\n creds = instance_profile_creds\n else\n raise LoadCredentialsError, \"Could not load credentials from the environment variables, the .aws/credentials file or the metadata service\"\n end\n creds\n end", "def profile\n @profile ||= GATEWAY.get_profile_details(self.profile_id) unless profile_id.nil?\n end", "def profile(force = false)\n force ? @profile = get_profile : @profile ||= get_profile\n end", "def credentials_file\n if @credentials_path && File.readable?(@credentials_path)\n @credentials_path\n elsif File.readable?(default_credentials_path)\n default_credentials_path\n end\n end", "def profile\n @profile ||= repository_profile\n end", "def setup_cred_opts(cli_opts)\n cred_opts = cli_opts[:config] ? { raise_on_no_profile: true } : {}\n\n if cli_opts[:config]\n cred_opts[:file] = Pathname.new(cli_opts[:config])\n\n unless cred_opts[:file].exist?\n raise WavefrontCli::Exception::ConfigFileNotFound, cred_opts[:file]\n end\n end\n\n cred_opts[:profile] = cli_opts[:profile] if cli_opts[:profile]\n cred_opts\n end", "def current_profile\n current_session.profile\n end", "def load_stored_session\n path = cache_file\n FileUtils.touch(path)\n if(File.exist?(path))\n values = load_stored_values(path)\n VAULT_CACHED_ITEMS.each do |key|\n api.connection.data[key] = values[key]\n if [:aws_access_key_id, :aws_secret_access_key].member?(key)\n ui.debug \"Updating environment #{key} with #{values[key]}\"\n # also update environment for this process\n ENV[key.to_s] = values[key]\n end\n end\n if values[:vault_lease_expiration].nil?\n values[:vault_lease_expiration] = 0\n end\n if(expired?(values[:vault_lease_expiration]))\n begin\n secret = vault_read\n # without the sleep the credentials are not ready\n # this is arbitrary\n timeout = config.fetch(:vault, :iam_delay, 30)\n ui.info \"Sleeping #{timeout}s for first time credentials system wide activation\"\n sleep(timeout)\n api.connection.data[:vault_lease_id] = secret.lease_id # maybe unused?\n api.connection.data[:vault_lease_expiration] = Time.now.to_i + secret.lease_duration\n # update keys in api connection\n api.connection.data[:aws_access_key_id] = secret.data[:access_key]\n api.connection.data[:aws_secret_access_key] = secret.data[:secret_key]\n rescue\n end\n end\n true\n else\n false\n end\n end", "def import_profile_from_twitter\n self.profile.first_name = @credentials['name']\n self.profile.website = @credentials['url']\n self.profile.federated_profile_image_url = @credentials['profile_image_url']\n self.profile.save\n end", "def load_profile(token)\n profile = GoogleService.user_info(token)\n email_field = profile[\"emails\"].select do |email| \n email[\"type\"] == \"account\"\n end\n\n email = email_field[0][\"value\"] if email_field && email_field.size > 0\n\n {:displayName => profile[\"displayName\"],\n :image => profile[\"image\"][\"url\"],\n :url => profile[\"url\"],\n :email => email} \n end", "def profile(profile_name:)\n claim_url = \"#{@@profile_service_url}/profile/#{profile_name}/next\"\n response = Faraday.get claim_url\n profile = JSON.parse(response.body)\n raise \"No profile available for #{profile_name}\" unless profile\n profile\n end", "def load_or_create\n valid_credentials? ? load_credentials : create_credentials\n self\n end", "def authenticate_profile!\n if logged_in?\n raise ProfileNotSetup unless current_user.profile\n else\n store_location and raise NotLoggedIn\n end\n end", "def load_credentials\n yml = YAML.load(File.read(credentials_file)) || {}\n @uuid, @token = yml[:uuid], yml[:token]\n yml\n end", "def profile\n return nil unless user_loa3\n\n mvi_response&.profile\n end", "def get_profile\n self.class.get '/members/private', @options\n end", "def current_profile\n @current_profile ||= Account.find_by(subdomain: current_subdomain) if current_subdomain\n end", "def get_credentials\n trackmine_path = File.join(Rails.root, 'config', 'trackmine.yml')\n raise MissingTrackmineConfig.new(\"Missing trackmine.yml configuration file in /config\") unless File.exist?(trackmine_path)\n YAML.load_file(trackmine_path)\n end", "def credentials_file\n dir['credentials']\n end", "def default_profile\n profiles.find_by_id(default_profile_id)\n end", "def profile?(profile=RC.current_profile)\n self.profile == (profile || 'default').to_s\n end", "def set_creds\n\n creds = Aws::SharedCredentials.new({profile_name: session[:current_profile], correctClockSkew: true})\n Aws.config.update({\n region: 'us-east-1',\n credentials: creds\n })\n\n get_mfa_device\n if !session[:profile_mfa].nil? && !session[:profile_mfa].empty?\n begin\n res = sts.get_session_token(duration_seconds: 3600, serial_number: session[:mfa_device], token_code: session[:profile_mfa])\n\n session[:elevated] = true\n session[session[:current_profile]] = {\n access_key_id: res.credentials['access_key_id'],\n secret_access_key: res.credentials['secret_access_key'],\n session_token: res.credentials['session_token'],\n expiration: res.credentials['expiration'],\n containers: []\n }\n creds = Aws::Credentials.new(\n res.credentials['access_key_id'],\n res.credentials['secret_access_key'],\n res.credentials['session_token']\n )\n Aws.config.update({\n region: 'us-east-1',\n credentials: creds\n })\n\n { err: false }\n rescue Exception => e\n p \"RESCUE----\"\n p e\n session[session[:current_profile]] = {\n containers: []\n }\n session[:profile_mfa] = \"\"\n session[:elevated] = false\n { err: true }\n end\n\n else\n session[session[:current_profile]] = {\n containers: []\n }\n session[:profile_mfa] = \"\"\n session[:elevated] = false\n { err: false}\n end\n\n end", "def findProfile(profile_id)\n # assuming there is only one profile with this profile_id\n @profile = Profile.where(identity: profile_id).first\n return @profile\n end", "def profile(name)\n @profiles.find { |p| p.name == name }\n end", "def single_config\n default = begin\n if profile.is_a?(Hash)\n profile\n elsif [String, Symbol].include?(profile.class)\n available[profile] ||\n raise(ProfileError, \"Profile #{profile.inspect} is undefined\")\n else\n available[:default] ||\n raise(ProfileError, 'No default profile defined')\n end\n end\n {:default => default}\n end", "def default_profile\n active_profiles.select {|prof| prof.can_start_instance?}.first\n end", "def set_current_user_profile\n @profile = custom_find do\n current_v1_user.profiles.find(params[:profile_id])\n end\n end", "def import_profile_from_google\n # forthcoming\n end", "def load_profile_data\n @profile_data = Nokogiri::HTML(open(\"#{PROFILE_URI}/#{@uid}\"))\n end", "def open_credantial_file()\n if ENV['AWS_CREDENTIAL_FILE'].to_s.empty?\n $stderr.puts \"$AWS_CREDENTIAL_FILE not set\"\n Process.exit!(4)\n end\n unless File.exist?(ENV['AWS_CREDENTIAL_FILE'])\n $stderr.puts \"Credential File not found. Please check path `#{ENV['AWS_CREDENTIAL_FILE']}`\"\n Process.exit!(4)\n end\n IniFile.load(ENV['AWS_CREDENTIAL_FILE'])\n end", "def social_profile(provider)\n social_profiles.select{ |sp| sp.provider == provider.to_s }.first\n end", "def profile\n @profile ||= @request.do_request { FacebookUserProfile.populate(user) }\n end", "def get_profile\n path = self.api_root + '/register/profile'\n process_firecloud_request(:get, path)\n end", "def profile(username)\n Person.profile(username, @api_key, @https)\n end", "def get_profile(connector, id, options={})\n brief = options.delete :brief || false\n json = connector.prepare_and_invoke_api_call(\n \"profiles/v1/providers/#{id}\" + (brief ? \"/brief\" : \"\"), :method=>:get)\n return self.new(json['profile'])\n end", "def fetch\n cfg = {}\n cfg = YAML.load_file(@default) if File.file?(@default)\n\n local = {}\n if File.file?(@local)\n # Check for bad user input in the local config.yml file.\n local = YAML.load_file(@local)\n unless local.is_a?(Hash)\n raise StandardError, \"Wrong format for the config-local file!\"\n end\n end\n\n hsh = strict_merge_with_env(cfg, local)\n add_enabled(hsh)\n end", "def profile\n\t\tif user_signed_in?\n\t\t\tdb_entry = UserSetting.where(username: current_user.username)[0]\n\t\t\tif db_entry != nil\n\t\t\t\thandle = db_entry.handle\n\t\t\t\t@problems_solved, @contests_attempted = build_solved_problems_and_attempted_contests(handle)\n\t\t\t\t@@handle_shared = handle\n\t\t\t\t@@problems_solved_shared = @problems_solved\n\t\t\t\t@@contests_attempted_shared = @contests_attempted\n\t\t\tend\n\t\tend\n\tend", "def get_profile_script(env); end", "def getSavedSessionId(session_file, username)\n if ! File.readable?(session_file)\n return nil\n end\n begin\n File.open(session_file, \"r\") {\n |f|\n u = f.readline(\"\\n\").strip\n if u == username\n return f.readline().strip\n else\n return nil\n end\n }\n rescue Exception => e\n pp 'Error reading session file', e, e.message\n return nil\n end\n end", "def get_profile(session, user_id)\n $client.authorization.update_token!(session[:token].to_hash)\n plus = $client.discovered_api('plus')\n\n Rails.logger.debug \"TokenPair: #{$client.authorization.to_yaml}\"\n result = $client.execute(\n :api_method => plus.people.get,\n :parameters => {'userId' => user_id})\n\n Rails.logger.debug \"GoogleClient: ---------------------------------> \"\n Rails.logger.debug \"GoogleClient: NM #{result.data['displayName']}\"\n Rails.logger.debug \"GoogleClient: IM #{result.data['image']['url']}\"\n Rails.logger.debug \"GoogleClient: PR #{result.data['url']}\"\n Rails.logger.debug \"GoogleClient: ---------------------------------> \"\n\n @profile = Hash.new\n @profile[:name] = result.data['displayName']\n @profile[:profile_url] = result.data['url']\n\n # Avatar sizes\n @profile[:img_url] = result.data['image']['url']\n @profile[:img_url].gsub!(/sz=\\d+$/, \"\")\n\n @profile[:img_thumb_url] = @profile[:img_url] + 'sz=100'\n @profile[:img_tiny_url] = @profile[:img_url] + 'sz=32'\n @profile[:img_badge_url] = @profile[:img_url] + 'sz=15'\n\n return @profile\n end", "def load_stored_session\n path = config.fetch(:aws_mfa, :cache_file, \".sfn-aws\")\n if File.exists?(path)\n values = load_stored_values(path)\n SESSION_STORE_ITEMS.each do |key|\n api.connection.data[key] = values[key]\n end\n if values[:aws_sts_session_token_expires]\n begin\n api.connection.data[:aws_sts_session_token_expires] = Time.parse(values[:aws_sts_session_token_expires])\n rescue\n end\n end\n true\n else\n false\n end\n end", "def load_twitter_account\n # FIXME would this be better placed in the models?\n @twitter_account = @workspace ? @workspace.twitter_account || @workspace.create_twitter_account :\n @user.twitter_account || @user.create_twitter_account\n end", "def get_stored_credentials_ar(user_id)\n row = Credential.where(user_id: user_id).last\n if row\n hash = YAML::load(row.credentials)\n Signet::OAuth2::Client.new(hash)\n else\n nil\n end\nend", "def prepare_profile\n profile || build_profile\n end", "def _profile\n @link['profile']\n end", "def current_profile\n profile = profiles.detect {|a| a.default == true}\n unless profile\n profile = profiles.first\n profile.update_attribute(:default, true) if profile\n end\n profile\n end", "def login\n open(@credentials_file, 'r').readlines.first.strip if valid_file?(@credentials_file)\n end", "def profile\n @property[:profile]\n end", "def load(name)\n name = name.to_sym\n raise \"Could not find SimpleCov Profile called '#{name}'\" unless key?(name)\n\n SimpleCov.configure(&self[name])\n end", "def file_path\n @credentials_file\n end", "def load_profiles()\n # read profiles\n puts \"Loading configs from #{@server_host}:#{@server_port}\" # Rails.logger.info\n\n res = Net::HTTP.start(@server_host, @server_port) {|http|\n http.open_timeout = 5\n http.read_timeout = 10\n http.get('/api/profiles')\n }\n raise \"HTTP status is not succeeded\" if res.code != '200'\n\n profiles_arr = JSON.parse(res.body)\n @table = ProfileTable.new(profiles_arr)\n end", "def profile cached_token=token\n uri = URI.parse(\"https://anypoint.mulesoft.com/accounts/api/me\")\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 mvp_profile\n owned_profiles.last\n end", "def load_settings\n @settings ||= Course::LeaderboardSettings.new(current_course.settings(:leaderboard))\n end", "def read_cache_file\n return nil unless File.file? @cache_file\n\n cache = YAML.load_file(@cache_file)\n\n return nil unless cache.is_a? Hash\n return nil unless cache[:userid] == @userid\n\n @token = cache[:token]\n @prev_account_info = cache[:account_info]\n @remote_folders = cache[:remote_folders]\n @remote_contexts = cache[:remote_contexts]\n @last_sync = cache[:last_sync]\n end", "def get_login_profile(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'GetLoginProfile'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'https'\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :user_name\n\t\t\targs[:query]['UserName'] = optional[:user_name]\n\t\tend\n\t\tself.run(args)\n\tend", "def get_local_pem_file\n File.read(PRIVATE_KEY_PATH) || (raise BitPayError, MISSING_KEY)\n end", "def load_credentials(username, password)\n\n if username.empty? || password.empty?\n # unused feature, for now \n\t #@username, @password = RLCredentials.load(\"lb\")\n print \"username: \"\n @username = STDIN.gets.chomp\n print \"password: \"\n @password = STDIN.noecho(&:gets).chomp\n print \"\\n\"\n else\n @username = username\n @password = password\n end\n\n # we'll want to test the credentials here by calling the rest_login\n call_rest_login\n\n end", "def user_from_session\n case RAILS_ENV\n when 'production'\n @user = User.find( :first, :conditions => {\n :screen_name => session[:screen_name],\n :token => session[:access_token]\n })\n when 'development'\n logger.debug 'session = '+session.inspect\n @user = User.find( :first, :conditions => {\n :screen_name => DEBUG_SCREEN_NAME\n })\n #nil\n end\n end", "def get_current_user\n #temporaly solution to simulate login on development \n #if env[\"REMOTE_HOST\"] == \"localhost\"\n # session[:user_id] = 1;\n #end\n return @current_reader if defined?(@current_reader)\n #@current_reader = cookies[:token] && Reader.find_by_token(cookies[:token])\n if session[:user_id]\n @current_reader ||= Reader.find_by_id(session[:user_id])\n end\n end", "def set_profile\n @profile = current_owner.profile\n end", "def set_profile\n @profile = Profile.where(user_id: current_user).first\n end", "def oauth_data\n @oauth_data ||= File.exists?(oauth_data_file) ? YAML::load_file(oauth_data_file) : {}\n end", "def load_local_cache\n return nil unless File.exists?(LOCAL_CACHE_PATH)\n yaml = File.read(LOCAL_CACHE_PATH)\n YAML.load(yaml)\n end", "def fetch_credentials\n service = @application.services.find_service FILTER\n service['credentials']\n end", "def get_profile_id\n if user_signed_in? && current_user.profile\n @profile_id = current_user.profile.id\n end\n end", "def set_authentication_local\n @authentication_local = Authentication::Local.find(params[:id])\n end", "def google_session\n google_service_account_credential_file = 'pennypoll-d23e19e91329.json'\n\n GoogleDrive::Session.from_service_account_key(\n google_service_account_credential_file\n )\nend", "def load_user(filepath)\n $user = load_yaml(filepath)\nend", "def set_profile\n @profile = current_user.profile\n end", "def set_profile\n @profile = current_user.profile\n end", "def set_profile\n @profile = current_user.profile\n end", "def set_profile\n @profile = current_user.profile\n end", "def profile\n _uuid = uuid.gsub(/-/, '')\n url = \"https://sessionserver.mojang.com/session/minecraft/profile/#{_uuid}\"\n response = Net::HTTP.get_response(URI.parse(url))\n json = JSON.parse(response.body)\n end" ]
[ "0.6701693", "0.66836864", "0.6428481", "0.62075835", "0.61399734", "0.61399734", "0.6092536", "0.6067304", "0.5955669", "0.5914697", "0.58984035", "0.5882444", "0.58014727", "0.5735554", "0.573396", "0.5713375", "0.569041", "0.5667331", "0.565998", "0.56544197", "0.5646244", "0.56450444", "0.5636887", "0.56290066", "0.5622262", "0.5610127", "0.55959475", "0.55890685", "0.55523396", "0.5548994", "0.55146825", "0.5455062", "0.54533845", "0.54221964", "0.5352061", "0.534248", "0.5322041", "0.53147393", "0.53109515", "0.5303898", "0.53038824", "0.5287403", "0.5284681", "0.52691907", "0.5256404", "0.52439266", "0.5237539", "0.5219864", "0.5214468", "0.5212965", "0.5212554", "0.52091324", "0.51659817", "0.5108322", "0.51026016", "0.5102322", "0.51007366", "0.50944364", "0.50882024", "0.5072792", "0.50709856", "0.50632745", "0.50552493", "0.5044475", "0.5042158", "0.50419205", "0.5017569", "0.50043094", "0.50007546", "0.5000726", "0.49989152", "0.4998395", "0.49859834", "0.49842367", "0.49732202", "0.49697396", "0.49620783", "0.4961494", "0.4961026", "0.49558264", "0.49381888", "0.49201843", "0.49179435", "0.4917867", "0.49163532", "0.49136755", "0.49128687", "0.48985678", "0.48977038", "0.48938078", "0.48920095", "0.48764193", "0.48763543", "0.48763135", "0.48758003", "0.48715213", "0.48715213", "0.48715213", "0.48715213", "0.4867298" ]
0.69604754
0
helper function to return a new RDS client
def createRDSClient(region,credentials) begin return Aws::RDS::Client.new(region: region,credentials: credentials) rescue Exception => e puts "\e[31mCould not create new RDS client." puts "#{e.message}\e[0m" exit 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_dbconnection_instance(schezer)\n schezer.instance_eval do\n return @conn.dup\n end\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 new_client(credentials)\n safely do\n return SBCClient.new(credentials.user, credentials.password)\n end\n end", "def db\n return @client if @client\n @client = Mysql2::Client.new(\n host: 'localhost',\n port: nil,\n username: 'root',\n password: nil,\n database: 'isucon5q',\n reconnect: true,\n )\n @client.query_options.merge!(symbolize_keys: true)\n @client\nend", "def create\n conn = EM::Hiredis::Client.new(@host, @port, @password, @database)\n conn.connect\n conn\n end", "def get_legacy_db_conn\n Mysql2::Client.new(:host => ENV[\"SDBMSS_LEGACY_DB_HOST\"],\n :username => ENV[\"SDBMSS_LEGACY_DB_USER\"],\n :database => ENV[\"SDBMSS_LEGACY_DB_NAME\"],\n :password => ENV[\"SDBMSS_LEGACY_DB_PASSWORD\"],\n )\n end", "def new_connection; end", "def create_client\n @client = if @opts[:servers]\n Monga::Clients::ReplicaSetClient.new(@opts)\n else\n Monga::Clients::SingleInstanceClient.new(@opts)\n end\n end", "def clone_conn(args = {})\r\n conn = Knj::Db.new(@opts.clone.merge(args))\r\n \r\n if block_given?\r\n begin\r\n yield(conn)\r\n ensure\r\n conn.close\r\n end\r\n \r\n return nil\r\n else\r\n return conn\r\n end\r\n end", "def connection(extra_opts={}, legacy = false, sharded = false)\n opts = connection_options.merge!(extra_opts)\n if(legacy)\n if replicaset?\n ReplSetConnection.new(node_strings, opts)\n else\n Connection.new(host, port, opts)\n end\n else\n if sharded\n MongoShardedClient.new(node_strings, opts)\n elsif replicaset?\n MongoReplicaSetClient.new(node_strings, opts)\n else\n MongoClient.new(host, port, opts)\n end\n end\n end", "def client\n set_connection unless @client\n @client\n end", "def sdb\n access_key = @uri[:access_key]\n secret_key = @uri[:secret_key]\n @sdb ||= RightAws::SdbInterface.new(access_key,secret_key,@opts)\n @sdb\n end", "def new_sqs_client type\n ::AWS::SQS.new aws_identity(type)\n end", "def new_db(options = {})\n cached = find_cached(options)\n return cached if cached && !options[:force_new]\n @cache[options] = ConnectionMaker.new(options).connection\n end", "def db_connect\n database_connect_options = @options['database']\n db_connector = DatabaseConnector.new(database_connect_options)\n return db_connector.client\n end", "def connection()\r\n\r\n begin\r\n db_params = {\r\n host: ENV['host'], # AWS link\r\n port: ENV['port'], # AWS port, always 5432\r\n username: ENV['username'],\r\n password: ENV['password'],\r\n database: ENV['database']\r\n }\r\n\r\n client = Mysql2::Client.new(db_params)\r\n\r\n rescue Mysql2::Error => e\r\n puts 'Exception occurred'\r\n puts e.message\r\n end\r\n\r\nend", "def create_client_connection(host, port, db)\n Connection.new(host, port, db, @handle)\n end", "def new_connection\n old_db_id = @db.nil? ? 0 : @db.object_id\n @db.disconnect! unless @db.nil?\n\n @db = ActiveRecord::Base.mysql2_connection(@db_config)\n\n new_db_id = @db.object_id\n logger.info(\"New cache db connection - old db id was: #{old_db_id} -- new db id is: #{new_db_id}\")\n\n return @db\n end", "def connection\n @db = Connection.client\nend", "def redshift\n @redshift ||= Aws::Redshift::Client.new aws_config\n end", "def sky_client\n return SkyDB::Client.new(:host => 'localhost', :port => 8585)\n end", "def connect_to_database\n config = Rails.configuration.database_configuration\n host = config[Rails.env][\"host\"]\n dbname = config[Rails.env][\"database\"]\n username = config[Rails.env][\"username\"]\n password = config[Rails.env][\"password\"]\n \n client = Mysql2::Client.new(:host => host, :username => username, :password => password, :flags => Mysql2::Client::MULTI_STATEMENTS)\n \n if client.query(\"SHOW DATABASES LIKE '#{dbname}'\").count == 0\n print \"Database '#{dbname}' not found, creating...\"\n client.query(\"CREATE DATABASE #{dbname}\")\n print \"\\n\" + File.open(SETUP_FILE,\"r\").read\n client.select_db(dbname)\n client.query(File.open(SETUP_FILE,\"r\").read)\n end\n \n finalClient = Mysql2::Client.new(:host => host, :username => username, :password => password, :database => dbname)\n \n return finalClient\n \n end", "def client\n @client = Gluby::Client.instance unless @client\n @client\n end", "def get_resource\n\t\t\tlogger.debug {\"ALLOCATING NEW RESOURCE --> #{ ActiveOrient.db_pool.size }\" }\n login = [ActiveOrient.default_server[:user] , ActiveOrient.default_server[:password]]\n server_adress = \"http://#{ActiveOrient.default_server[:server]}:#{ActiveOrient.default_server[:port]}\"\n\t\t\t RestClient::Resource.new(server_adress, *login)\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 client\n puts \"creating client\"\n @client ||= Vineyard::Client.new(options) #unless defined?(@client) && @client.hash == options.hash\n @client\n end", "def createEC2Client(region,credentials)\n begin\n return Aws::EC2::Client.new(region: region,credentials: credentials)\n rescue Exception => e\n puts \"\\e[31mCould not create new EC2 client\"\n puts \"#{e.message}\\e[0m\"\n exit 1\n end\nend", "def new_client(credentials)\n #Fog constructor expecting credentials[:terremark_password] and credentials[:terremark_username]\n terremark_credentials = {:terremark_vcloud_username => \"#{credentials.user}\", :terremark_vcloud_password => \"#{credentials.password}\" }\n safely do\n terremark_client = Fog::Terremark::Vcloud.new(terremark_credentials)\n vdc_id = terremark_client.default_vdc_id\n end\n if (vdc_id.nil?)\n raise \"AuthFailure\"\n end\n terremark_client\n end", "def client\n if !@client || @client.hash != options.hash\n @client = Croudia::Client.new\n end\n @client\n end", "def db_conn\n @db_conn_pool ||= ConnectionPool.new(size: 4, timeout: 2) do\n Mysql2::Client.new(self.db_settings)\n end\n end", "def ec2_client(region)\n begin\n client = Aws::EC2::Client.new(region: region)\n rescue => e\n puts e\n exit\n end\nend", "def get_db_connection\n config = read_database_config\n if config.dig(:adapter) == 'postgresql'\n config[:user] = config.delete(:username) if config[:username]\n config[:dbname] = config.delete(:database) if config[:database]\n config.delete(:adapter)\n valid_param_keys = PG::Connection.conndefaults_hash.keys + [:requiressl]\n config.slice!(*valid_param_keys)\n @db ||= PG::Connection.new(config)\n elsif config.dig(:adapter) == 'mysql2'\n @db ||= Mysql2::Client.new(config)\n else\n @db ||= SQLite3::Database.open(\"spectacles-#{Rails.env}.db\")\n end\n end", "def client\n @client ||= Client.new\n end", "def new_redshift_connection(connection_options={})\n merged_options = merge_options(connection_options)\n\n @redshift_conn = PG.connect(\n :host => merged_options[:redshift_host],\n :port => merged_options[:redshift_port],\n :dbname => merged_options[:redshift_dbname],\n :user => merged_options[:redshift_user],\n :password => merged_options[:redshift_password])\n\n return @redshift_conn\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 get(id, opts)\n # Purge connections if needed:\n purge if purge?\n\n # Find the entry for the given id and return it if the options are compatible:\n entry = @registry[id]\n return entry.connection if entry && entry.compatible?(opts)\n\n # If there is an entry but it isn't compatible, then close and remove it:\n if entry\n $rhevm_log.info(\n \"Existing connection for EMS with identifier '#{id}' and URL '#{entry.options[:url]}' isn't compatible \" \\\n \"with the requested options, will close it and create a new one.\"\n )\n close(id)\n end\n\n # At this point we know that either there was no connection or else it needs to be created again:\n $rhevm_log.info(\"Creating new connection for EMS with identifier '#{id}' and URL '#{opts[:url]}'.\")\n connection = OvirtSDK4::Connection.new(opts)\n entry = Entry.new(opts, connection)\n @registry[id] = entry\n\n # Return the new connection:\n connection\n end", "def new\n build_client\n end", "def get_instance(db_instance_identifier)\n resource = Aws::RDS::Resource.new(client: @rds)\n resource.db_instance(db_instance_identifier)\n end", "def db_connection\n {:host => new_resource.superuser_host, :username => new_resource.superuser, :password => new_resource.superuser_password}\nend", "def client\n @credentials ||= Aws::Credentials.new(@access_id, @access_key)\n @client ||= Aws::CloudFormation::Client.new(\n credentials: @credentials,\n region: @region\n )\n end", "def new\n\t\t@client = Client.new\n\tend", "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 new_client(credentials, type=\"compute\", ignore_provider=false)\n tokens = credentials.user.split(\"+\")\n if credentials.user.empty?\n raise AuthenticationFailure.new(Exception.new(\"Error: you must supply the username\"))\n end\n if (tokens.size != 2 && api_v2)\n raise ValidationFailure.new(Exception.new(\"Error: expected \\\"username+tenantname\\\" as username, you provided: #{credentials.user}\"))\n else\n user_name, tenant_name = tokens.first, tokens.last\n end\n #check if region specified with provider:\n provider = api_provider\n if (provider.include?(\";\"))\n region = provider.split(\";\").last\n provider = provider.chomp(\";#{region}\")\n end\n connection_params = {:username => user_name, :api_key => credentials.password, :authtenant => tenant_name, :auth_url => provider, :service_type => type}\n connection_params.merge!({:region => region}) if region && !ignore_provider # hack needed for 'def providers'\n safely do\n raise ValidationFailure.new(Exception.new(\"Error: tried to initialise Openstack connection using\" +\n \" an unknown service_type: #{type}\")) unless [\"volume\", \"compute\", \"object-store\", \"network\"].include? type\n OpenStack::Connection.create(connection_params)\n end\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 create_connection(region)\n \n # If we already have a connection object then return early.\n if @cf.has_key?(region) then\n return\n end\n\n debug(\"Creating new persistent aws connection for region #{region}.\") \n \n # Check this is a valid aws region.\n if not is_aws_region_name?(region)\n # If we don't have a region specified then the cloudformation endpoint will be malformed\n # resulting in networking errors.\n # Fail now with a proper error mesage.\n error_message = \"[cloudformation_backend]: AWS Region #{region} is invalid.\"\n Hiera.warn(error_message)\n raise Exception, error_message\n end\n\n # Create an AWS connecton object for this region.\n @cf[region] = AWS::CloudFormation.new(\n :access_key_id => @@aws_config['access_key_id'],\n :secret_access_key => @@aws_config['secret_access_key'],\n :region => region\n )\n end", "def get_client\n config.client.new(self)\n end", "def get_client\n @client = Ethereum::Client.create(@url) if @client.nil?\n @client\n end", "def db\n @db ||= new_connection\n end", "def get_next_client\n\t\tname = @curDclRow[@NAME].strip unless @curDclRow[@NAME].nil?\n\t\tif name.nil?\n\t\t\tnil\n\t\telse\n\t\t\tclient = Client.new(name)\n\t\t\tclient.totalCost = @curDclRow[@TOTAL_COST]\n\t\t\tservices = get_services\n\t\t\tservices.each {|service| client.add_service(service)} \n\t\t\tupdate_row\n\t\t\tget_info(client)\n\t\t\tclient\n\t\tend\n\tend", "def get_next_client\n\t\tname = @curDclRow[@NAME].strip unless @curDclRow[@NAME].nil?\n\t\tif name.nil?\n\t\t\tnil\n\t\telse\n\t\t\tclient = Client.new(name)\n\t\t\tclient.totalCost = @curDclRow[@TOTAL_COST]\n\t\t\tservices = get_services\n\t\t\tservices.each {|service| client.add_service(service)} \n\t\t\tupdate_row\n\t\t\tget_info(client)\n\t\t\tclient\n\t\tend\n\tend", "def client\n @client ||= Client.new(config[:credentials], config[:end_point])\n end", "def new_client(id, env, private_key, secret)\n app_config = AppConfig.new(\n id: id,\n env: env,\n private_key: private_key,\n secret: secret\n )\n\n Client.new(config: app_config)\n end", "def new(&block)\n Builder.new(&block).to_client\n end", "def client(ks=@keyspace)\n c = ::Cassandra.new(ks, self.to_s, CLIENT_CONNECT_OPTIONS)\n c.disable_node_auto_discovery!\n\n yield(c) if block_given?\n\n c\n end", "def client\n @@client ||= Orchestrate::Application::Connect.client\n end", "def new_http_client\n client = Net::HTTP.new(@uri.host, @uri.port)\n if @uri.scheme == \"https\"\n configure_ssl(client)\n end\n client\n end", "def pool\n pool_connection = ConnectionPool.new(size: 10, timeout: 5) do \n Redis.new :db=> redis_db_index, :password=> redis_instance.password, :host=> redis_instance.host, :port=> redis_instance.port\n end \n return pool_connection \n end", "def get_instance(id)\n CloudDB::Instance.new(self,id)\n end", "def get_instance(id)\n CloudDB::Instance.new(self,id)\n end", "def conn\n\t\treturn @conn ||= self.connect\n\tend", "def connection\n @connection || ActiveSdb::connection\n end", "def open_connection\n\tbegin\n\t\tdb = Mysql.new $db_hostname, $db_user, $db_pass\n\trescue Mysql::Error\n\t\tabort \"Oops! Couldn't connect to database! Make sure you entered the correct information.\"\n\tend\n\treturn db\nend", "def client\n Dalli::Client.new(servers, options)\n end", "def client\n @asg ||= Aws::AutoScaling::Client.new(region: ENV['aws_region'])\n end", "def retrieve_db(attempt = 0)\n require 'rubygems'\n require 'mongo'\n\n begin\n Mongo::MongoClient.new(\n @new_resource.connection['host'],\n @new_resource.connection['port'],\n :connect_timeout => 15,\n :slave_ok => true\n )\n rescue Mongo::ConnectionFailure => e\n if(attempt) < @new_resource.connection['user_management']['connection']['retries']\n Chef::Log.warn(\"Unable to connect to MongoDB instance, retrying in #{@new_resource.connection['user_management']['connection']['delay']} second(s)...\")\n sleep(@new_resource.connection['user_management']['connection']['delay'])\n retrieve_db(attempt + 1)\n end\n end\nend", "def client_instance(which, *args)\n manager = Clients.const_get \"#{which}Client\"\n manager.new(self, *args) if manager.respond_to?(:new)\n end", "def open_connection\n\tbegin\n\t\tdb = Mysql.new($db_hostname, $db_user, $db_pass)\n\trescue Mysql::Error\n\t\tabort \"Oops! Couldn't connect to database! Make sure you entered the correct information.\"\n\tend\n\treturn db\nend", "def recreate_client\n @http.close\n create_client\n end", "def client(group, version)\n # Return the client immediately if it has been created before:\n key = group + '/' + version\n client = @clients[key]\n return client if client\n\n # Determine the API path:\n if group == CORE_GROUP\n path = '/api'\n else\n path = '/apis/' + group\n end\n\n # Create the client and save it:\n url = URI::Generic.build(\n scheme: 'https',\n host: @host,\n port: @port,\n path: path\n )\n client = Kubeclient::Client.new(\n url.to_s,\n version,\n @opts\n )\n @clients[key] = client\n\n # Return the client:\n client\n end", "def select_db(db)\n query \"use #{db}\"\n self\n end", "def new_client\n Svn::Client::Context.new\n end", "def client\n @client ||= Client.new(configuration)\n end", "def with_source_connection\n config = get_test_config\n conn_hash = config.source.dup\n database = conn_hash.delete(:database)\n client = Mysql2::Client.new(conn_hash)\n begin\n yield client, database\n ensure\n client.close\n end\n end", "def _client\n @client ||= XMLRPC::Client.new(@uri.host, @uri.path, @uri.port, nil, nil, nil, nil, @uri.port == 443, @timeout)\n end", "def new_connection(config)\n username = nil\n\n if config[:jndi]\n jndi = config[:jndi].to_s\n ctx = javax.naming.InitialContext.new\n ds = nil\n\n # tomcat needs first lookup method, oc4j (and maybe other application servers) need second method\n begin\n env = ctx.lookup(\"java:/comp/env\")\n ds = env.lookup(jndi)\n rescue\n ds = ctx.lookup(jndi)\n end\n\n # check if datasource supports pooled connections, otherwise use default\n if ds.respond_to?(:pooled_connection)\n @raw_connection = ds.pooled_connection\n else\n @raw_connection = ds.connection\n end\n\n # get Oracle JDBC connection when using DBCP in Tomcat or jBoss\n if @raw_connection.respond_to?(:getInnermostDelegate)\n @pooled_connection = @raw_connection\n @raw_connection = @raw_connection.innermost_delegate\n elsif @raw_connection.respond_to?(:getUnderlyingConnection)\n @pooled_connection = @raw_connection\n @raw_connection = @raw_connection.underlying_connection\n end\n\n # Workaround FrozenError (can't modify frozen Hash):\n config = config.dup\n config[:driver] ||= @raw_connection.meta_data.connection.java_class.name\n username = @raw_connection.meta_data.user_name\n else\n # to_s needed if username, password or database is specified as number in database.yml file\n username = config[:username] && config[:username].to_s\n password = config[:password] && config[:password].to_s\n database = config[:database] && config[:database].to_s || \"XE\"\n host, port = config[:host], config[:port]\n privilege = config[:privilege] && config[:privilege].to_s\n\n # connection using TNS alias, or connection-string from DATABASE_URL\n using_tns_alias = !host && !config[:url] && ENV[\"TNS_ADMIN\"]\n if database && (using_tns_alias || host == \"connection-string\")\n url = \"jdbc:oracle:thin:@#{database}\"\n else\n unless database.match?(/^(:|\\/)/)\n # assume database is a SID if no colon or slash are supplied (backward-compatibility)\n database = \"/#{database}\"\n end\n url = config[:url] || \"jdbc:oracle:thin:@//#{host || 'localhost'}:#{port || 1521}#{database}\"\n end\n\n prefetch_rows = config[:prefetch_rows] || 100\n # get session time_zone from configuration or from TZ environment variable\n time_zone = config[:time_zone] || ENV[\"TZ\"] || java.util.TimeZone.default.getID\n\n properties = java.util.Properties.new\n raise \"username not set\" unless username\n raise \"password not set\" unless password\n properties.put(\"user\", username)\n properties.put(\"password\", password)\n properties.put(\"defaultRowPrefetch\", \"#{prefetch_rows}\") if prefetch_rows\n properties.put(\"internal_logon\", privilege) if privilege\n\n if config[:jdbc_connect_properties] # arbitrary additional properties for JDBC connection\n raise \"jdbc_connect_properties should contain an associative array / hash\" unless config[:jdbc_connect_properties].is_a? Hash\n config[:jdbc_connect_properties].each do |key, value|\n properties.put(key, value)\n end\n end\n\n begin\n @raw_connection = java.sql.DriverManager.getConnection(url, properties)\n rescue\n # bypass DriverManager to work in cases where ojdbc*.jar\n # is added to the load path at runtime and not on the\n # system classpath\n @raw_connection = ORACLE_DRIVER.connect(url, properties)\n end\n\n # Set session time zone to current time zone\n if ActiveRecord.default_timezone == :local\n @raw_connection.setSessionTimeZone(time_zone)\n elsif ActiveRecord.default_timezone == :utc\n @raw_connection.setSessionTimeZone(\"UTC\")\n end\n\n if config[:jdbc_statement_cache_size]\n raise \"Integer value expected for :jdbc_statement_cache_size\" unless config[:jdbc_statement_cache_size].instance_of? Integer\n @raw_connection.setImplicitCachingEnabled(true)\n @raw_connection.setStatementCacheSize(config[:jdbc_statement_cache_size])\n end\n\n # Set default number of rows to prefetch\n # @raw_connection.setDefaultRowPrefetch(prefetch_rows) if prefetch_rows\n end\n\n cursor_sharing = config[:cursor_sharing] || \"force\"\n exec \"alter session set cursor_sharing = #{cursor_sharing}\" if cursor_sharing\n\n # Initialize NLS parameters\n OracleEnhancedAdapter::DEFAULT_NLS_PARAMETERS.each do |key, default_value|\n value = config[key] || ENV[key.to_s.upcase] || default_value\n if value\n exec \"alter session set #{key} = '#{value}'\"\n end\n end\n\n OracleEnhancedAdapter::FIXED_NLS_PARAMETERS.each do |key, value|\n exec \"alter session set #{key} = '#{value}'\"\n end\n\n self.autocommit = true\n\n schema = config[:schema] && config[:schema].to_s\n if schema.blank?\n # default schema owner\n @owner = username.upcase unless username.nil?\n else\n exec \"alter session set current_schema = #{schema}\"\n @owner = schema\n end\n\n @raw_connection\n end", "def connection\n @connection ||= make_connection\n end", "def hubssolib_factory\n\n # See:\n # http://stackoverflow.com/questions/299219/where-is-the-correct-place-to-initialize-the-drb-service-within-a-rails-applicati\n #\n begin\n DRb.current_server\n rescue DRb::DRbServerNotFound\n DRb.start_service\n # Move to different ThreadGroup to stop Mongrel hang on exit.\n ThreadGroup.new.add DRb.thread\n end\n\n return @factory ||= DRbObject.new_with_uri(HUBSSOLIB_DRB_URI)\n end", "def get_db(dbname)\n Database.new(dbname, @socket, self)\n end", "def connection\n Connection.new(conn_spec)\n end", "def db\n @db ||= Fog::AWS::DynamoDB.new(\n @options.merge(\n :aws_access_key_id => @aws_access_key,\n :aws_secret_access_key => @aws_secret_key,\n :region => @region))\n end", "def make_conn(spec)\n case @handling_mode\n when :cache\n cache_connect(spec)\n when :pool\n # not yet implemented\n nil\n else\n nil\n end\n end", "def client(interface)\n fail_bad_interfaces(interface)\n @client ||= interface.new_connection(@data_layer_options)\n @client\n end", "def create_client!\n Chef::ApiClient::Registration.new(node_name, client_path, http_api: rest).run\n end", "def client\n @client || Client.connection\n end", "def client\n @client ||= self.class.client\n end", "def conn\n builder.conn || ::ActiveRecord::Base.connection\n end", "def connection\n Connection.new(conn_spec)\n end", "def _client\n @client ||= XMLRPCClient.new(@uri.host, @uri.path, @uri.port, nil, nil, nil, nil, @uri.scheme == 'https' ? @ssl_verify : false, @timeout)\n end", "def client\n @client ||= (begin\n if @uri.scheme\n client_class = Retrieve::Client.for(@uri.scheme)\n if client_class\n client_class.new(self)\n else\n nil\n end\n else\n nil\n end\n end)\n end", "def client\n key, secret = credentials\n @client ||= Cloudkick::Base.new(key, secret)\n end", "def connection_for(shard_name: nil, client_id: nil)\n used_shard = if client_id\n shard_name_for(client_id)\n else\n shard_name\n end\n\n Octopus.using(used_shard) do\n ActiveRecord::Base.connection.select_connection\n end\n end", "def orchestrate_client\n client\n end", "def connect(dbname, user, auth, attr)\n connection = factory.create_connection\n connection.connection_string = dbname\n connection.open\n return create_database(connection, attr);\n rescue RuntimeError, System::Data::SqlClient::SqlException => err\n raise DBI::DatabaseError.new(err.message)\n end", "def http_client\n @conn ||= Net::HTTP.start(EC2_METADATA_ADDR).tap do |h|\n h.read_timeout = 10\n h.keep_alive_timeout = 10\n end\n end", "def cass_client\n unless @cass_client\n uri_json = ENV['CASSANDRA_URIS'] || '[\"127.0.0.1:9160\"]'\n @cassandra_uris = MultiJson.load uri_json\n\n @cass_client = ::Cassandra.new(\"Hastur\", @cassandra_uris, THRIFT_OPTIONS)\n\n # for non-production and port-forwarded ssh, there will only be one URI and it\n # should not auto-discover nodes\n if @cassandra_uris.one?\n @cass_client.disable_node_auto_discovery!\n end\n end\n @cass_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 getclient\n return @client\n end", "def with_client\n begin\n @client = client_class.new\n rescue SystemExit,NoMemoryError\n raise\n rescue Exception => detail\n puts detail.backtrace if Puppet[:trace]\n Puppet.err \"Could not create instance of #{client_class}: #{detail}\"\n return\n end\n yield @client\n ensure\n @client = nil\n end" ]
[ "0.652982", "0.64181215", "0.63795197", "0.63029474", "0.6295826", "0.6175796", "0.61746156", "0.6149308", "0.61289483", "0.6127377", "0.6092965", "0.603337", "0.6030865", "0.6028998", "0.59967816", "0.59921783", "0.59913766", "0.59859556", "0.59725523", "0.59002686", "0.58950853", "0.58847106", "0.5880044", "0.5879089", "0.5866493", "0.5866394", "0.5830353", "0.58014345", "0.5786787", "0.5740154", "0.5729341", "0.5728477", "0.5719751", "0.56811017", "0.5643703", "0.5643703", "0.5643703", "0.56258637", "0.56186104", "0.56185776", "0.5615505", "0.560331", "0.5585587", "0.5581063", "0.5564293", "0.5560205", "0.555947", "0.5554612", "0.5554021", "0.5553653", "0.55402786", "0.55402786", "0.5534478", "0.55277526", "0.5522401", "0.5518607", "0.5513212", "0.5512337", "0.5510886", "0.551013", "0.551013", "0.5510099", "0.55009735", "0.54958904", "0.5466991", "0.5465591", "0.54653615", "0.54612136", "0.54599506", "0.5450309", "0.54479283", "0.54477406", "0.54434067", "0.5440298", "0.5436396", "0.54362345", "0.5434496", "0.54322296", "0.5431522", "0.54281753", "0.5425922", "0.542221", "0.5417649", "0.5403467", "0.5401173", "0.53964597", "0.5395528", "0.53890306", "0.53813356", "0.53796095", "0.5376952", "0.5359421", "0.5351427", "0.53474694", "0.5343741", "0.5340295", "0.5339088", "0.53383404", "0.53358054", "0.5335761" ]
0.73701465
0
helper function to return a new EC2 client
def createEC2Client(region,credentials) begin return Aws::EC2::Client.new(region: region,credentials: credentials) rescue Exception => e puts "\e[31mCould not create new EC2 client" puts "#{e.message}\e[0m" exit 1 end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ec2_client(region)\n begin\n client = Aws::EC2::Client.new(region: region)\n rescue => e\n puts e\n exit\n end\nend", "def ec2\n @ec2 ||= EC2::Base.new(:access_key_id => \"not a key\", :secret_access_key => \"not a key\")\n end", "def ec2\n Fog::Compute::AWS.new(aws_access_key_id: @aws_access_key_id, aws_secret_access_key: @aws_secret_access_key)\n end", "def ec2\n @ec2 ||= aws_init { AWS::EC2.new }\n end", "def http_client\n @conn ||= Net::HTTP.start(EC2_METADATA_ADDR).tap do |h|\n h.read_timeout = 10\n h.keep_alive_timeout = 10\n end\n end", "def client(region,access_key_id=nil,secret_access_key=nil)\n self.ec2_client ||= Aws::EC2::Client.new(region: region, access_key_id: access_key_id, secret_access_key: secret_access_key )\n end", "def amazon_ec2_api\n @amazon_ec2_api ||= AmazonEc2Api.new\n end", "def load_client\n @aws_client ||= Aws::EC2::Client.new(region: Mnemosyne.config.region)\n end", "def setup_ec2(access_key, secret_key)\n ec2 = AWS::EC2.new(\n access_key_id: access_key, \n secret_access_key: secret_key, \n ec2_endpoint: 'ec2.us-west-1.amazonaws.com')\n\n # Test for Auth Failures\n begin\n ec2.instances.first\n rescue AWS::EC2::Errors::AuthFailure\n ec2 = nil\n end\n\n return ec2\n end", "def initialize(aws_region:)\n @ec2_client ||= Aws::EC2::Client.new(region: aws_region)\n end", "def ec2_resource(region)\n begin\n ec2 = Aws::EC2::Resource.new(region: region)\n rescue => e\n puts e\n exit\n end\nend", "def new_client(credentials)\n safely do\n return SBCClient.new(credentials.user, credentials.password)\n end\n end", "def new_client(id, env, private_key, secret)\n app_config = AppConfig.new(\n id: id,\n env: env,\n private_key: private_key,\n secret: secret\n )\n\n Client.new(config: app_config)\n end", "def create_client!\n Chef::ApiClient::Registration.new(node_name, client_path, http_api: rest).run\n end", "def ec2_instance(instance_id)\n EC2Instance.new(instance_id)\n end", "def ec2_instance(instance_id)\n EC2Instance.new(instance_id)\n end", "def client\n @credentials ||= Aws::Credentials.new(@access_id, @access_key)\n @client ||= Aws::CloudFormation::Client.new(\n credentials: @credentials,\n region: @region\n )\n end", "def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})\n init({ :name => 'EC2',\n :default_host => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).host : DEFAULT_HOST,\n :default_port => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).port : DEFAULT_PORT,\n :default_service => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).path : DEFAULT_PATH,\n :default_protocol => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).scheme : DEFAULT_PROTOCOL,\n :default_api_version => @@api },\n aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'] , \n aws_secret_access_key|| ENV['AWS_SECRET_ACCESS_KEY'],\n params)\n end", "def client\n @client ||= Client.new(config[:credentials], config[:end_point])\n end", "def initialize(host, host_id=nil)\n @host = host\n @host_id = host_id\n\n @instance_types = PUBLIC_CLOUD_EC2_CONF['instance_types']\n\n conn_opts = get_connect_info(host, host_id)\n access_key = conn_opts[:access]\n secret_key = conn_opts[:secret]\n region_name = conn_opts[:region]\n\n #sanitize region data\n raise \"access_key_id not defined for #{host}\" if access_key.nil?\n raise \"secret_access_key not defined for #{host}\" if secret_key.nil?\n raise \"region_name not defined for #{host}\" if region_name.nil?\n\n Aws.config.merge!({\n :access_key_id => access_key,\n :secret_access_key => secret_key,\n :region => region_name\n })\n\n if (proxy_uri = PUBLIC_CLOUD_EC2_CONF['proxy_uri'])\n Aws.config(:proxy_uri => proxy_uri)\n end\n\n if @provision_type == :host\n if PUBLIC_CLOUD_EC2_CONF['state_wait_pm_timeout_seconds']\n @state_change_timeout = PUBLIC_CLOUD_EC2_CONF['state_wait_pm_timeout_seconds'].to_i\n else\n @state_change_timeout = STATE_WAIT_PM_TIMEOUT_SECONDS\n end\n else\n @state_change_timeout = PUBLIC_CLOUD_EC2_CONF['state_wait_timeout_seconds'].to_i\n end\n\n @ec2 = Aws::EC2::Resource.new\n end", "def client\n puts \"creating client\"\n @client ||= Vineyard::Client.new(options) #unless defined?(@client) && @client.hash == options.hash\n @client\n end", "def createRDSClient(region,credentials)\n begin\n return Aws::RDS::Client.new(region: region,credentials: credentials)\n rescue Exception => e\n puts \"\\e[31mCould not create new RDS client.\"\n puts \"#{e.message}\\e[0m\"\n exit 1\n end\nend", "def new\n build_client\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 client\n key, secret = credentials\n @client ||= Cloudkick::Base.new(key, secret)\n end", "def initialize(aws_access_key_id=nil, aws_secret_access_key=nil, params={})\n init({ :name => 'EC2', \n :default_host => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).host : DEFAULT_HOST, \n :default_port => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).port : DEFAULT_PORT,\n :default_service => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).path : DEFAULT_PATH, \n :default_protocol => ENV['EC2_URL'] ? URI.parse(ENV['EC2_URL']).scheme : DEFAULT_PROTOCOL }, \n aws_access_key_id || ENV['AWS_ACCESS_KEY_ID'] , \n aws_secret_access_key|| ENV['AWS_SECRET_ACCESS_KEY'],\n params)\n end", "def initialize options = {}\n @config = options[:config]\n @config ||= AWS.config\n @config = @config.with(options)\n @client = config.send(Inflection.ruby_name(self.class.to_s) + '_client')\n end", "def new_client\n Svn::Client::Context.new\n end", "def get_aws_object(ext_mgt_system, type=\"EC2\")\n require 'aws-sdk'\n AWS.config(\n :access_key_id => ext_mgt_system.authentication_userid,\n :secret_access_key => ext_mgt_system.authentication_password,\n :region => ext_mgt_system.provider_region\n )\n return Object::const_get(\"AWS\").const_get(\"#{type}\").new()\n end", "def client(group, version)\n # Return the client immediately if it has been created before:\n key = group + '/' + version\n client = @clients[key]\n return client if client\n\n # Determine the API path:\n if group == CORE_GROUP\n path = '/api'\n else\n path = '/apis/' + group\n end\n\n # Create the client and save it:\n url = URI::Generic.build(\n scheme: 'https',\n host: @host,\n port: @port,\n path: path\n )\n client = Kubeclient::Client.new(\n url.to_s,\n version,\n @opts\n )\n @clients[key] = client\n\n # Return the client:\n client\n end", "def initialize(config)\n @aws_ec2 = AWS::EC2.new(config)\n end", "def new_http_client\n client = Net::HTTP.new(@uri.host, @uri.port)\n if @uri.scheme == \"https\"\n configure_ssl(client)\n end\n client\n end", "def get_client\n @client = Ethereum::Client.create(@url) if @client.nil?\n @client\n end", "def client\n @client ||= Aws::KMS::Client.new(\n access_key_id: access_key_id,\n secret_access_key: secret_key,\n region: region\n )\n end", "def new(&block)\n Builder.new(&block).to_client\n end", "def get_client\n config.client.new(self)\n end", "def initialize(config, ec2_config=nil)\n @config = config\n @ec2_config = ec2_config\n @aws_ec2 = AWS::EC2.new(@config.global)\n end", "def client\n @client ||= Curl::Easy.new\n end", "def new\n\t\t@client = Client.new\n\tend", "def get_client(uri, http_type, method)\n return @client\n end", "def ec2\n return @ec2\n end", "def client\n @client ||= Curl::Easy.new\n end", "def client\n @client ||= Aws::ElasticTranscoder::Client.new\n end", "def new_client(credentials)\n #Fog constructor expecting credentials[:terremark_password] and credentials[:terremark_username]\n terremark_credentials = {:terremark_vcloud_username => \"#{credentials.user}\", :terremark_vcloud_password => \"#{credentials.password}\" }\n safely do\n terremark_client = Fog::Terremark::Vcloud.new(terremark_credentials)\n vdc_id = terremark_client.default_vdc_id\n end\n if (vdc_id.nil?)\n raise \"AuthFailure\"\n end\n terremark_client\n end", "def createEc2Instance\n\t\t name = @server[\"name\"]\n\t\t node = @server['mu_name']\n\t\t\tbegin\n\t\t\t\t@server['iam_role'] = MU::Server.createIAMProfile(\"Server-\"+name, base_profile: @server['iam_role'], extra_policies: @server['iam_policies'])\n\t\t\trescue Aws::EC2::Errors::RequestLimitExceeded => e\n\t\t\t\tsleep 10\n\t\t\t\tretry\n\t\t\tend\n\t\t\t@server['iam_role'] = @server['iam_role']\n\n\t\t\tbegin\n\t\t\t\t@deploy.createEc2SSHKey\n\t\t\trescue Aws::EC2::Errors::RequestLimitExceeded => e\n\t\t\t\tsleep 10\n\t\t\t\tretry\n\t\t\tend\n\n\t\t instance_descriptor = {\n\t\t :image_id => @server[\"ami_id\"],\n\t\t :key_name => @deploy.keypairname,\n\t\t :instance_type => @server[\"size\"],\n\t\t :disable_api_termination => true,\n\t\t :min_count => 1,\n\t\t :max_count => 1,\n\t\t\t\t:network_interfaces => [\n\t\t\t\t\t{\n\t\t\t\t\t\t:associate_public_ip_address => name[\"associate_public_ip\"]\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t }\n\t\t\t\n\t\t\tif !@server['private_ip'].nil?\n\t\t\t\tinstance_descriptor[:private_ip_address] = @server['private_ip']\n\t\t\tend\n\n\t\t\tvpc_id=subnet_id=nat_host_name=nat_ssh_user = nil\n\t\t\tsubnet_retries = 0\n\t\t\tif !@server[\"vpc\"].nil?\n\t\t\t\tbegin\n\t\t\t\t\tvpc_id, subnet_ids, nat_host_name, nat_ssh_user = MU::VPC.parseVPC(@server['vpc'])\n\t\t\t\trescue Aws::EC2::Errors::ServiceError => e\n\t\t\t\t\tMU.log e.message, MU::ERR, details: @server\n\t\t\t\t\tif subnet_retries < 5\n\t\t\t\t\t subnet_retries = subnet_retries + 1\n\t\t\t\t\t sleep 15\n\t\t\t\t\t retry\n\t\t\t\t\tend\n\t\t\t\t\traise e\n\t\t\t\tend\n\t\t\t\tsubnet_id = subnet_ids.first\n\t\t\t\tif subnet_id.nil? or subnet_id.empty?\n\t\t\t\t\tMU.log \"Got null Subnet id out of #{@server['vpc']}\", MU::ERR\n\t\t\t\t\traise \"deploy failure\"\n\t\t\t\tend\n\n\t\t\t\tMU.log \"Deploying #{node} into VPC #{vpc_id} Subnet #{subnet_id}\"\n\n\t\t\t\tif !@server[\"vpc\"][\"nat_host_name\"].nil? or !@server[\"vpc\"][\"nat_host_id\"].nil?\n\t\t\t\t\tadmin_sg = MU::Server.punchAdminNAT(@server, node)\n\t\t\t\telse\n\t\t\t\t\tadmin_sg = MU::FirewallRule.setAdminSG(vpc_id: vpc_id, region: @server['region'])\n\t\t\t\tend\n\n\t\t\t\tinstance_descriptor[:subnet_id] = subnet_id\n\t\t\t\tnode_sg = MU::FirewallRule.createEc2SG(\n\t\t\t\t\t\t@server[\"name\"].upcase,\n\t\t\t\t\t\t@server[\"ingress_rules\"],\n\t\t\t\t\t\tdescription: \"SG holes for #{node}\",\n\t\t\t\t\t\tvpc_id: vpc_id,\n\t\t\t\t\t\tregion: @server['region']\n\t\t\t\t)\n\t\t\telse\n\t\t\t\tadmin_sg = MU::FirewallRule.setAdminSG(region: @server['region'])\n\t\t\t\tnode_sg = MU::FirewallRule.createEc2SG(\n\t\t\t\t\t\t@server[\"name\"].upcase,\n\t\t\t\t\t\t@server[\"ingress_rules\"],\n\t\t\t\t\t\tdescription: \"SG holes for #{node}\",\n\t\t\t\t\t\tregion: @server['region']\n\t\t\t\t)\n\t\t\tend\n\t\t\tsecurity_groups = Array.new\n\t\t\tsecurity_groups << admin_sg\n\t\t\tsecurity_groups << node_sg\n\t\t\tif !@server[\"add_firewall_rules\"].nil?\n\t\t\t\t@server[\"add_firewall_rules\"].each { |acl|\n\t\t\t\t\tsg = MU::FirewallRule.find(sg_id: acl[\"rule_id\"], name: acl[\"rule_name\"], region: @server['region'])\n\t\t\t\t\tif sg.nil?\n\t\t\t\t\t\tMU.log \"Couldn't find dependent security group #{acl} for server #{node}\", MU::ERR\n\t\t\t\t\t\traise \"deploy failure\"\n\t\t\t\t\tend\n\t\t\t\t\tsecurity_groups << sg.group_id\n\t\t\t\t}\n\t\t\tend\n\n\t\t\tinstance_descriptor[:security_group_ids] = security_groups\n\n\t\t if !@userdata.nil? and !@userdata.empty?\n\t\t instance_descriptor[:user_data] = Base64.encode64(@userdata)\n\t\t end\n\n\t\t if !@server[\"iam_role\"].nil?\n\t\t instance_descriptor[:iam_instance_profile] = { name: @server[\"iam_role\"]}\n\t\t end\n\n\t\t\tconfigured_storage = Array.new\n\t\t\tif @server[\"storage\"]\n\t\t\t\t@server[\"storage\"].each { |vol|\n\t\t\t\t\tconfigured_storage << MU::Server.convertBlockDeviceMapping(vol)\n\t\t\t\t}\n\t\t\tend\n\t\t\n\t\t\tMU::Server.waitForAMI(@server[\"ami_id\"], region: @server['region'])\n\n\t\t\tinstance_descriptor[:block_device_mappings] = configured_storage\n\t\t\tinstance_descriptor[:block_device_mappings].concat(@ephemeral_mappings)\n\n\t\t\tinstance_descriptor[:monitoring] = { enabled: @server['monitoring'] }\n\n\t\t\tMU.log \"Creating EC2 instance #{node}\"\n\t\t\tMU.log \"Instance details for #{node}: #{instance_descriptor}\", MU::DEBUG\n#\t\t\t\tif instance_descriptor[:block_device_mappings].empty?\n#\t\t\t\t\tinstance_descriptor.delete(:block_device_mappings)\n#\t\t\t\tend\n#pp instance_descriptor[:block_device_mappings]\n\t\t\tretries = 0\n\t\t\tbegin\n\t\t\t\tresponse = MU.ec2(@server['region']).run_instances(instance_descriptor)\n\t\t\trescue Aws::EC2::Errors::InvalidGroupNotFound, Aws::EC2::Errors::InvalidSubnetIDNotFound, Aws::EC2::Errors::InvalidParameterValue, Aws::EC2::Errors::RequestLimitExceeded => e\n\t\t\t\tif retries < 10\n\t\t\t\t\tif retries > 7\n\t\t\t\t\t\tMU.log \"Seeing #{e.inspect} while trying to launch #{node}, retrying a few more times...\", MU::WARN, details: instance_descriptor\n\t\t\t\t\tend\n\t\t\t\t\tsleep 10\n\t\t\t\t\tretries = retries + 1\n\t\t\t\t\tretry\n\t\t\t\telse\n\t\t\t\t\traise e\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tinstance = response.instances.first\n\t\t\tMU.log \"#{node} (#{instance.instance_id}) coming online\"\n\n\n\t\t\treturn instance\n\n\t\tend", "def client\n @client ||= Utils::Box::Client.new\n end", "def groomEc2(instance)\n\t\t\treturn MU::Server.groomEc2(@server, instance, @deploy.keypairname, environment: @deploy.environment, sync_wait: @server['dns_sync_wait'])\n\t\tend", "def create_aws_connection\n Ankus::Aws.new @credentials[:aws_access_id], @credentials[:aws_secret_key], @credentials[:aws_region], @log, @mock\n end", "def new_client_application\n OAuth2::Client.new(caller_service.client_id, caller_service.client_secret, :site => authorizator_service.site, :raise_errors => false)\n end", "def client\n @client ||= Aws::ElasticTranscoder::Client.new\n end", "def client_instance(which, *args)\n manager = Clients.const_get \"#{which}Client\"\n manager.new(self, *args) if manager.respond_to?(:new)\n end", "def client\n @client ||= Aws::S3::Client.new(\n access_key_id: access_key,\n secret_access_key: secret_key,\n region: region\n )\n end", "def client\n credentials = Aws::Credentials.new(settings[:aws_access_key_id],\n settings[:aws_secret_access_key])\n region = settings[:aws_default_region]\n\n Aws::SES::Client.new(credentials: credentials, region: region)\n end", "def client\n @asg ||= Aws::AutoScaling::Client.new(region: ENV['aws_region'])\n end", "def new_sqs_client type\n ::AWS::SQS.new aws_identity(type)\n end", "def instance\n @instance ||= Artsy::Client::Instance.new(options)\n end", "def client\n @client ||= Client.new\n end", "def ecs\n Amazon::Ecs.configure do |options|\n options[:aWS_access_key_id] = @@key_id\n options[:associate_tag] = @@associate_id\n options[:aWS_secret_key] = @@secretkey\n end \n return Amazon::Ecs \nend", "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(opts = {})\n @opts = opts\n @opts[:type] ||= :block\n @opts[:timeout] ||= 10\n\n sanitize_opts!\n create_client\n end", "def client\n @client ||= Client.new(configuration)\n end", "def i2c\n @i2c ||= I2C.new(self)\n end", "def client\n @client ||= CFoundry::Client.new(@target.to_s).tap do |c|\n c.login(@username, @password)\n end\n end", "def new_i3s_client(options = {})\n OneviewSDK::ImageStreamer::Client.new(options.merge(token: @token))\n end", "def new_client(credentials, type=\"compute\", ignore_provider=false)\n tokens = credentials.user.split(\"+\")\n if credentials.user.empty?\n raise AuthenticationFailure.new(Exception.new(\"Error: you must supply the username\"))\n end\n if (tokens.size != 2 && api_v2)\n raise ValidationFailure.new(Exception.new(\"Error: expected \\\"username+tenantname\\\" as username, you provided: #{credentials.user}\"))\n else\n user_name, tenant_name = tokens.first, tokens.last\n end\n #check if region specified with provider:\n provider = api_provider\n if (provider.include?(\";\"))\n region = provider.split(\";\").last\n provider = provider.chomp(\";#{region}\")\n end\n connection_params = {:username => user_name, :api_key => credentials.password, :authtenant => tenant_name, :auth_url => provider, :service_type => type}\n connection_params.merge!({:region => region}) if region && !ignore_provider # hack needed for 'def providers'\n safely do\n raise ValidationFailure.new(Exception.new(\"Error: tried to initialise Openstack connection using\" +\n \" an unknown service_type: #{type}\")) unless [\"volume\", \"compute\", \"object-store\", \"network\"].include? type\n OpenStack::Connection.create(connection_params)\n end\n end", "def connection\n # Create connection\n # rubocop:disable UselessAssignment\n @connection ||= begin\n connection = Fog::Compute.new(\n provider: 'AWS',\n aws_access_key_id: @api_user,\n aws_secret_access_key: @api_password,\n region: @aws_region\n )\n end\n # rubocop:enable UselessAssignment\n end", "def get_client(uri, http_type, method)\n final_url = @base_url + URI.escape(uri)\n params = {\n :site => @base_url,\n :http_method => method,\n :request_token_path => \"\",\n :authorize_path => \"\",\n :access_token_path => \"\"}\n #params[:ca_file] = self.ca_cert_file unless self.ca_cert_file.nil?\n\n consumer = OAuth::Consumer.new(@oauth_consumer_key,\n @oauth_consumer_secret, params)\n request = http_type.new(final_url)\n consumer.sign!(request)\n headers = {\n 'Authorization' => request['Authorization'],\n 'accept_language' => @lang,\n 'cp-user' => 'admin'\n }\n\n # Creating a new client for every request:\n client = RestClient::Resource.new(@base_url,\n :headers => headers)\n return client\n end", "def create\n payload = {\n name: name,\n validator: validator,\n # this field is ignored in API V1, but left for backwards-compat,\n # can remove after OSC 11 support is finished?\n admin: admin,\n }\n begin\n # try API V1\n raise Chef::Exceptions::InvalidClientAttribute, \"You cannot set both public_key and create_key for create.\" if !create_key.nil? && !public_key.nil?\n\n payload[:public_key] = public_key unless public_key.nil?\n payload[:create_key] = create_key unless create_key.nil?\n\n new_client = if Chef::Config[:migrate_key_to_keystore] == true\n chef_rest_v1_with_validator.post(\"clients\", payload)\n else\n chef_rest_v1.post(\"clients\", payload)\n end\n\n # get the private_key out of the chef_key hash if it exists\n if new_client[\"chef_key\"]\n if new_client[\"chef_key\"][\"private_key\"]\n new_client[\"private_key\"] = new_client[\"chef_key\"][\"private_key\"]\n end\n new_client[\"public_key\"] = new_client[\"chef_key\"][\"public_key\"]\n new_client.delete(\"chef_key\")\n end\n\n rescue Net::HTTPClientException => e\n # rescue API V0 if 406 and the server supports V0\n supported_versions = server_client_api_version_intersection(e, SUPPORTED_API_VERSIONS)\n raise e unless supported_versions && supported_versions.include?(0)\n\n # under API V0, a key pair will always be created unless public_key is\n # passed on initial POST\n payload[:public_key] = public_key unless public_key.nil?\n\n new_client = chef_rest_v0.post(\"clients\", payload)\n end\n Chef::ApiClientV1.from_hash(to_h.merge(new_client))\n end", "def create_client\n client_public, client_private = ZMQ::Util.curve_keypair\n store_known_client(client_public)\n\n {\n server_public_key: @public_key,\n public_key: client_public,\n private_key: client_private\n }\n end", "def allocate_elastic_ip_address(ec2_client)\n response = ec2_client.allocate_address(domain: \"vpc\")\n return response.allocation_id\nrescue StandardError => e\n puts \"Error allocating Elastic IP address: #{e.message}\"\n return \"Error\"\nend", "def createEc2Instance\n\n instance_descriptor = {\n :image_id => @config[\"image_id\"],\n :key_name => @deploy.ssh_key_name,\n :instance_type => @config[\"size\"],\n :disable_api_termination => true,\n :min_count => 1,\n :max_count => 1\n }\n\n instance_descriptor[:iam_instance_profile] = getIAMProfile\n\n security_groups = myFirewallRules.map { |fw| fw.cloud_id }\n if security_groups.size > 0\n instance_descriptor[:security_group_ids] = security_groups\n else\n raise MuError, \"Didn't get any security groups assigned to be in #{@mu_name}, that shouldn't happen\"\n end\n\n if @config['private_ip']\n instance_descriptor[:private_ip_address] = @config['private_ip']\n end\n\n if !@vpc.nil? and @config.has_key?(\"vpc\")\n subnet = mySubnets.sample\n if subnet.nil?\n raise MuError, \"Got null subnet id out of #{@config['vpc']}\"\n end\n MU.log \"Deploying #{@mu_name} into VPC #{@vpc.cloud_id} Subnet #{subnet.cloud_id}\"\n allowBastionAccess\n instance_descriptor[:subnet_id] = subnet.cloud_id\n end\n\n if !@userdata.nil? and !@userdata.empty?\n instance_descriptor[:user_data] = Base64.encode64(@userdata)\n end\n\n MU::Cloud::AWS::Server.waitForAMI(@config[\"image_id\"], region: @region, credentials: @credentials)\n\n instance_descriptor[:block_device_mappings] = MU::Cloud::AWS::Server.configureBlockDevices(image_id: @config[\"image_id\"], storage: @config['storage'], region: @region, credentials: @credentials)\n\n instance_descriptor[:monitoring] = {enabled: @config['monitoring']}\n\n if @tags and @tags.size > 0\n instance_descriptor[:tag_specifications] = [{\n :resource_type => \"instance\",\n :tags => @tags.keys.map { |k|\n { :key => k, :value => @tags[k] }\n }\n }]\n end\n\n MU.log \"Creating EC2 instance #{@mu_name}\", details: instance_descriptor\n\n instance = resp = nil\n loop_if = Proc.new {\n instance = resp.instances.first if resp and resp.instances\n resp.nil? or resp.instances.nil? or instance.nil?\n }\n\n bad_subnets = []\n mysubnet_ids = if mySubnets\n mySubnets.map { |s| s.cloud_id }\n end\n begin\n MU.retrier([Aws::EC2::Errors::InvalidGroupNotFound, Aws::EC2::Errors::InvalidSubnetIDNotFound, Aws::EC2::Errors::InvalidParameterValue], loop_if: loop_if, loop_msg: \"Waiting for run_instances to return #{@mu_name}\") {\n resp = MU::Cloud::AWS.ec2(region: @region, credentials: @credentials).run_instances(instance_descriptor)\n }\n rescue Aws::EC2::Errors::Unsupported => e\n bad_subnets << instance_descriptor[:subnet_id]\n better_subnet = (mysubnet_ids - bad_subnets).sample\n if e.message !~ /is not supported in your requested Availability Zone/ and\n (mysubnet_ids.nil? or mysubnet_ids.empty? or\n mysubnet_ids.size == bad_subnets.size or\n better_subnet.nil? or better_subnet == \"\")\n raise MuError.new e.message, details: mysubnet_ids\n end\n instance_descriptor[:subnet_id] = (mysubnet_ids - bad_subnets).sample\n if instance_descriptor[:subnet_id].nil?\n raise MuError.new \"Specified subnet#{bad_subnets.size > 1 ? \"s do\" : \" does\"} not support instance type #{instance_descriptor[:instance_type]}\", details: bad_subnets\n end\n MU.log \"One or more subnets does not support instance type #{instance_descriptor[:instance_type]}, attempting with #{instance_descriptor[:subnet_id]} instead\", MU::WARN, details: bad_subnets\n retry\n rescue Aws::EC2::Errors::InvalidRequest => e\n MU.log e.message, MU::ERR, details: instance_descriptor\n raise e\n end\n\n MU.log \"#{@mu_name} (#{instance.instance_id}) coming online\"\n\n instance\n end", "def aws_instance_create(opts)\n AWS::EC2::InstanceCollection.new.create(\n image_id: Rails.configuration.x.aws[Rails.configuration.x.aws['region']][\"ami_#{self.os}\"], \n private_ip_address: self.ip_address,\n key_name: Rails.configuration.x.aws['ec2_key_pair_name'],\n user_data: self.generate_init,\n instance_type: \"t2.small\",\n subnet: self.subnet.driver_id\n )\n end", "def client\n if !@client || @client.hash != options.hash\n @client = Croudia::Client.new\n end\n @client\n end", "def new_client(username , password)\n @client = Octokit::Client.new(:login => username, :password => password)\nend", "def create_client\n @client = if @opts[:servers]\n Monga::Clients::ReplicaSetClient.new(@opts)\n else\n Monga::Clients::SingleInstanceClient.new(@opts)\n end\n end", "def load_client\n user_agent_suffix = \"fluent-#{NAME}\"\n\n options = {\n user_agent_suffix: user_agent_suffix\n }\n\n if @region\n options[:region] = @region\n end\n\n if @aws_key_id && @aws_sec_key\n options.update(\n access_key_id: @aws_key_id,\n secret_access_key: @aws_sec_key,\n )\n elsif @profile\n credentials_opts = {:profile_name => @profile}\n credentials_opts[:path] = @credentials_path if @credentials_path\n credentials = Aws::SharedCredentials.new(credentials_opts)\n options[:credentials] = credentials\n elsif @role_arn\n credentials = Aws::AssumeRoleCredentials.new(\n client: Aws::STS::Client.new(options),\n role_arn: @role_arn,\n role_session_name: \"fluent-plugin-kinesis-aggregation\",\n external_id: @external_id,\n duration_seconds: 60 * 60\n )\n options[:credentials] = credentials\n end\n\n if @debug\n options.update(\n logger: Logger.new(log.out),\n log_level: :debug\n )\n end\n\n if @http_proxy\n options[:http_proxy] = @http_proxy\n end\n\n @client = Aws::Kinesis::Client.new(options)\n end", "def createEc2Instance\n name = @config[\"name\"]\n node = @config['mu_name']\n\n instance_descriptor = {\n :image_id => @config[\"ami_id\"],\n :key_name => @deploy.ssh_key_name,\n :instance_type => @config[\"size\"],\n :disable_api_termination => true,\n :min_count => 1,\n :max_count => 1\n }\n\n arn = nil\n if @config['generate_iam_role']\n role = @deploy.findLitterMate(name: @config['name'], type: \"roles\")\n s3_objs = [\"#{@deploy.deploy_id}-secret\", \"#{role.mu_name}.pfx\", \"#{role.mu_name}.crt\", \"#{role.mu_name}.key\", \"#{role.mu_name}-winrm.crt\", \"#{role.mu_name}-winrm.key\"].map { |file| \n 'arn:'+(MU::Cloud::AWS.isGovCloud?(@config['region']) ? \"aws-us-gov\" : \"aws\")+':s3:::'+MU.adminBucketName+'/'+file\n }\n role.cloudobj.injectPolicyTargets(\"MuSecrets\", s3_objs)\n\n @config['iam_role'] = role.mu_name\n arn = role.cloudobj.createInstanceProfile\n# @cfm_role_name, @cfm_prof_name\n\n elsif @config['iam_role'].nil?\n raise MuError, \"#{@mu_name} has generate_iam_role set to false, but no iam_role assigned.\"\n end\n if !@config[\"iam_role\"].nil?\n if arn\n instance_descriptor[:iam_instance_profile] = {arn: arn}\n else\n instance_descriptor[:iam_instance_profile] = {name: @config[\"iam_role\"]}\n end\n end\n\n security_groups = []\n if @dependencies.has_key?(\"firewall_rule\")\n @dependencies['firewall_rule'].values.each { |sg|\n security_groups << sg.cloud_id\n }\n end\n\n if security_groups.size > 0\n instance_descriptor[:security_group_ids] = security_groups\n else\n raise MuError, \"Didn't get any security groups assigned to be in #{@mu_name}, that shouldn't happen\"\n end\n\n if !@config['private_ip'].nil?\n instance_descriptor[:private_ip_address] = @config['private_ip']\n end\n\n vpc_id = subnet = nil\n if !@vpc.nil? and @config.has_key?(\"vpc\")\n subnet_conf = @config['vpc']\n subnet_conf = @config['vpc']['subnets'].first if @config['vpc'].has_key?(\"subnets\") and !@config['vpc']['subnets'].empty?\n tag_key, tag_value = subnet_conf['tag'].split(/=/, 2) if !subnet_conf['tag'].nil?\n\n subnet = @vpc.getSubnet(\n cloud_id: subnet_conf['subnet_id'],\n name: subnet_conf['subnet_name'],\n tag_key: tag_key,\n tag_value: tag_value\n )\n if subnet.nil?\n raise MuError, \"Got null subnet id out of #{subnet_conf['vpc']}\"\n end\n MU.log \"Deploying #{node} into VPC #{@vpc.cloud_id} Subnet #{subnet.cloud_id}\"\n punchAdminNAT\n instance_descriptor[:subnet_id] = subnet.cloud_id\n end\n\n if !@userdata.nil? and !@userdata.empty?\n instance_descriptor[:user_data] = Base64.encode64(@userdata)\n end\n\n MU::Cloud::AWS::Server.waitForAMI(@config[\"ami_id\"], region: @config['region'], credentials: @config['credentials'])\n\n # Figure out which devices are embedded in the AMI already.\n image = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).describe_images(image_ids: [@config[\"ami_id\"]]).images.first\n ext_disks = {}\n if !image.block_device_mappings.nil?\n image.block_device_mappings.each { |disk|\n if !disk.device_name.nil? and !disk.device_name.empty? and !disk.ebs.nil? and !disk.ebs.empty?\n ext_disks[disk.device_name] = MU.structToHash(disk.ebs)\n end\n }\n end\n\n configured_storage = Array.new\n cfm_volume_map = {}\n if @config[\"storage\"]\n @config[\"storage\"].each { |vol|\n # Drop the \"encrypted\" flag if a snapshot for this device exists\n # in the AMI, even if they both agree about the value of said\n # flag. Apparently that's a thing now.\n if ext_disks.has_key?(vol[\"device\"])\n if ext_disks[vol[\"device\"]].has_key?(:snapshot_id)\n vol.delete(\"encrypted\")\n end\n end\n mapping, cfm_mapping = MU::Cloud::AWS::Server.convertBlockDeviceMapping(vol)\n configured_storage << mapping\n }\n end\n\n instance_descriptor[:block_device_mappings] = configured_storage\n instance_descriptor[:block_device_mappings].concat(@ephemeral_mappings)\n instance_descriptor[:monitoring] = {enabled: @config['monitoring']}\n\n MU.log \"Creating EC2 instance #{node}\"\n MU.log \"Instance details for #{node}: #{instance_descriptor}\", MU::DEBUG\n#\t\t\t\tif instance_descriptor[:block_device_mappings].empty?\n#\t\t\t\t\tinstance_descriptor.delete(:block_device_mappings)\n#\t\t\t\tend\n\n retries = 0\n begin\n response = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).run_instances(instance_descriptor)\n rescue Aws::EC2::Errors::InvalidGroupNotFound, Aws::EC2::Errors::InvalidSubnetIDNotFound, Aws::EC2::Errors::InvalidParameterValue => e\n if retries < 10\n if retries > 7\n MU.log \"Seeing #{e.inspect} while trying to launch #{node}, retrying a few more times...\", MU::WARN, details: instance_descriptor\n end\n sleep 10\n retries = retries + 1\n retry\n else\n raise MuError, e.inspect\n end\n end\n\n instance = response.instances.first\n MU.log \"#{node} (#{instance.instance_id}) coming online\"\n\n return instance\n\n end", "def instance_ec2\n @@cache[:fedora_image] = ImageService::create_image(nil,\n :broker_image_id => 'fedora',\n :provider_image_id => 'ami-bafcf3ce',\n :provider_id => @@cache[:ec2_provider].id,\n )\n @@cache[:instance_ec2] = LaunchService.launch(Seeding[:pool_ec2].id, 'test instance '+Time.now.to_i.to_s, Seeding[:hwp_1].name, Seeding[:fedora_image].broker_image_id,\n #:flavor => 'm1-small',\n :keyname => 'mpovolny'\n )\n end", "def get_zk()\n require 'zookeeper'\n # todo: memoize\n return Zookeeper.new(@new_resource.connect_str)\nend", "def new_client\n Savon.client(\n wsdl: @wsdl,\n endpoint: @endpoint,\n convert_request_keys_to: :none,\n soap_version: 1,\n pretty_print_xml: true,\n filters: [:password],\n logger: @soap_logger,\n log_level: @soap_log_level,\n log: @soap_log\n )\n end", "def orchestrate_client\n client\n end", "def aws_instance_get(opts)\n AWS::EC2.new.instances[opts[:instance_id]]\n end", "def _client\n @client ||= XMLRPC::Client.new(@uri.host, @uri.path, @uri.port, nil, nil, nil, nil, @uri.port == 443, @timeout)\n end", "def connection()\r\n\r\n begin\r\n db_params = {\r\n host: ENV['host'], # AWS link\r\n port: ENV['port'], # AWS port, always 5432\r\n username: ENV['username'],\r\n password: ENV['password'],\r\n database: ENV['database']\r\n }\r\n\r\n client = Mysql2::Client.new(db_params)\r\n\r\n rescue Mysql2::Error => e\r\n puts 'Exception occurred'\r\n puts e.message\r\n end\r\n\r\nend", "def client\n @client ||= MemCache.new(address)\n end", "def perform(secret, endpoint, _args = {})\n @client = ::OpenNebula::Client.new(secret, endpoint)\n end", "def with_client\n begin\n @client = client_class.new\n rescue SystemExit,NoMemoryError\n raise\n rescue Exception => detail\n puts detail.backtrace if Puppet[:trace]\n Puppet.err \"Could not create instance of #{client_class}: #{detail}\"\n return\n end\n yield @client\n ensure\n @client = nil\n end", "def create_aws_instance(config, name, instance_type=\"m3.medium\")\n config.ssh.pty = true\n config.vm.define name do |server|\n server.vm.box = AWS_BOX\n server.vm.provider :aws do |aws, override|\n aws.instance_type = instance_type\n aws.region = AWS_REGION\n aws.ami = AWS_AMI\n aws.keypair_name = AWS_PRIVATE_KEY\n override.ssh.username = AWS_SSH_USERNAME\n override.ssh.private_key_path = AWS_PRIVATE_KEY_PATH\n yield(aws,override,server)\n end\n end\nend", "def initialize(ecs_client = Aws::ECS::Client.new)\n ## DI for testing purposes\n @ecs = ecs_client\n end", "def oauth2_client(token, params = {})\n @oauth2_client = RubyLokaliseApi::OAuth2Client.new token, params\n end", "def client\n return @client if @client\n\n @client = Chef::Client.new\n @client.ohai.data = Mash.from_hash(Fauxhai.mock(options).data)\n @client.load_node\n @client.build_node\n @client.save_updated_node\n @client\n end", "def create_http_client\n c = DefaultHttpClient.new( @connection_manager, @cparams )\n c.http_request_retry_handler = @retry_handler if @retry_handler\n c\n end", "def client\n ::OAuth2::Client.new(\n options.client_id,\n options.client_secret,\n deep_symbolize(options.client_options).merge(site: site)\n )\n end", "def aws_pinpoint_client\n return @aws_pinpoint_client if @aws_pinpoint_client\n\n @aws_pinpoint_client = Aws::Pinpoint::Client.new(region: self.class.sms_aws_region)\n end", "def client\n return @client if @client\n @client = DropboxApi::Client.new(api_token)\n\n rescue => err\n raise Error.wrap(err, \"Authorization Failed\")\n end", "def create_client_of_cybozu\n cybozu = Cybozu.find(1) \n CybozuApi::Client.new(cybozu.url, cybozu.login_id, cybozu.password)\n end", "def _client\n @client ||= XMLRPCClient.new(@uri.host, @uri.path, @uri.port, nil, nil, nil, nil, @uri.scheme == 'https' ? @ssl_verify : false, @timeout)\n end", "def initialize\n endpoint = Figaro.env.cf_endpoint\n credentials = {version: 2, token: Figaro.env.cf_token, refresh_token: Figaro.env.cf_refresh_token}\n token = CFoundry::AuthToken.from_hash(credentials)\n @client = CFoundry::Client.get(endpoint, token)\n end" ]
[ "0.7484934", "0.72039455", "0.70676994", "0.7025927", "0.6948722", "0.6874134", "0.6756482", "0.6730758", "0.6627768", "0.64340407", "0.6351552", "0.63447094", "0.6336146", "0.6331109", "0.6328699", "0.6328699", "0.62763655", "0.6245043", "0.6204581", "0.61604345", "0.61189973", "0.6090154", "0.60724044", "0.6055539", "0.6055539", "0.6055539", "0.6045454", "0.60408705", "0.6030286", "0.6022269", "0.6021961", "0.60116076", "0.59565425", "0.5945012", "0.5922871", "0.5919116", "0.5914779", "0.59052444", "0.5902162", "0.5901384", "0.58880967", "0.5887524", "0.5886189", "0.5870088", "0.58644664", "0.58574545", "0.5855094", "0.5840898", "0.5823976", "0.58205116", "0.5818905", "0.5814785", "0.5812591", "0.5807249", "0.5806983", "0.57963127", "0.5796054", "0.5791265", "0.57899004", "0.5772912", "0.577289", "0.5769026", "0.57497954", "0.5740495", "0.5736238", "0.5727619", "0.57187366", "0.5704622", "0.5700369", "0.5697945", "0.5688784", "0.5687508", "0.5676691", "0.56686383", "0.56669945", "0.5660443", "0.5659845", "0.56544226", "0.5649921", "0.5645069", "0.56412345", "0.5620602", "0.5614204", "0.561217", "0.5604451", "0.55941296", "0.55864877", "0.55723447", "0.5557008", "0.5553339", "0.55502635", "0.55483824", "0.55367905", "0.55331516", "0.553224", "0.55315185", "0.5514633", "0.5511635", "0.5508285", "0.5502512" ]
0.76579565
0
Helper function to create a snapshot of an EBS volume
def createEBSSnapshot(client=nil,description='',volume_id=nil) return false if volume_id.nil? || client.nil? # Fetch the Volume Name. This will be used in the description of the snapshot resp = client.describe_volumes({dry_run: false, volume_ids: [volume_id] }) resp.volumes[0].tags.each do |t| if t.key=='Name' description = t.value unless t.value.empty? break end end # puts "Taking snapshot of volume #{volume_id}..." return client.create_snapshot({ dry_run: false, volume_id: volume_id, description: description }) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def restore_from_snap(last_snapshot, options = {})\n options[:device] = \"/dev/sdk\" unless options[:device]\n options[:vol_nickname] = last_snapshot[\"nickname\"] unless options[:vol_nickname]\n \n # 5 - Unmount and detach the current EBS volume (forcing to detach the device we're gonna need later for attching ours...)\n umount_and_detach_device({:device => options[:device]})\n # 6- Create the volume from the latest snapshot, attach it to the instance and then mount it\n STDERR.puts \"Creating new DB volume from snapshot #{last_snapshot['aws_id']}\"\n vol = ( options[:new_size_gb] ? create_volume_from_snap_size_gb(last_snapshot[\"aws_id\"],options[:vol_nickname],options[:new_size_gb] ) : create_volume_from_snap(last_snapshot[\"aws_id\"],options[:vol_nickname] ) )\n unless vol.nil?\n \tSTDERR.puts \"Attaching new DB volume: #{vol['aws_id']}\"\n \tatt = attach_volume(vol['aws_id'], options[:device])\n \twait_for_attachment(options[:device])\n \tFileUtils.mkdir_p self.MountPoint\n \tres = `mount -t xfs -o noatime #{options[:device]} #{self.MountPoint}`\n \traise EBSRemoteExecException.new(nil,$?,\"Error mounting newly created volume (#{vol['aws_id']}) on #{options[:device]}:\\n\"+res) if $? != 0 \n else\n\t raise \"create volume failed from snapshot\"\n end\n end", "def create_snapshot(device, options = {})\n # TODO - add in new param commit=explicit once the API is availible\n params = {:device => device, \n :suffix => options[:suffix], \n :description => options[:description], \n :tag => options[:tag],\n :max_snaps => options[:max_snaps],\n :prefix_override => options[:prefix_override],\n :commit => \"explicit\",\n :api_version => 1.0}\n # Perform API call to snapshot the volume attached to the device on the instance\n STDERR.puts \"Performing RightScale API call to create a new snapshot\"\n #STDERR.puts \"HERE IS THE URL: #{@api_url}/create_ebs_snapshot.js (PARAMS: #{params.inspect})\"\n json=nil\n SystemTimer.timeout_after(@api_snap_timeout) do\n body = RestClient.post @api_url+\"/create_ebs_snapshot.js\",params\n json = body.nil? ? nil: JSON.load(body)\n STDERR.puts \"CREATED_SNAP: #{json}\"\n end\n json \n rescue Exception => e\n display_exception(e, \"create_snapshot(#{device}, #{options.inspect})\")\n end", "def create_snapshot(options)\n snapshot = ec2.snapshots.new\n snapshot.volume_id = options['volume_id']\n snapshot.description = options['description']\n\n attempts = 0\n\n begin\n snapshot.save\n snapshot.reload\n rescue Fog::Compute::AWS::Error\n sleep 5\n attempts += 1\n if attempts == 5\n log \"Error communicating with API; Unable to save volume `#{options['volume_id']}` (Desc: #{options['description']})\"\n end\n return unless attempts == 5\n end\n\n options['tags'].each do |k,v|\n begin\n ec2.tags.create({resource_id: snapshot.id, key: k, value: v})\n rescue Errno::EINPROGRESS , Errno::EISCONN\n log \"API Connection Error\"\n sleep 1\n retry\n rescue Fog::Compute::AWS::Error\n log \"Failed attaching tag `'#{k}' => #{v}` to #{options['snapshot_type']} snapshot #{snapshot.id}\"\n sleep 1\n retry\n end\n end\n\n end", "def create_volume(size_or_snapshot_id, options = {})\n options = {:device => '/dev/sdh'}.merge(options)\n if size_or_snapshot_id.is_a?(Numeric)\n volume = @ec2.create_volume availability_zone, :size => size_or_snapshot_id\n else\n volume = @ec2.create_volume availability_zone, :snapshot_id => size_or_snapshot_id\n end\n if options[:tags]\n @ec2.create_tags(volume.id, options[:tags])\n end\n while volume.status != 'available'\n volume.reload\n end\n if options[:device]\n attach volume, options[:device]\n end\n volume\n end", "def create\n\t\tregion = resource[:availability_zone].to_s.gsub(/.$/,'') \n\t\tcompute = Fog::Compute.new(:provider => 'aws', :region => \"#{region}\")\n\t\tprint \"ebsvol[aws]->create: Region is #{region}\\n\" if $debug\n\t\tprint \"ebsvol[aws]->create: Availability_zone is #{resource[:availability_zone]}\\n\" if $debug\n\t\t# create the requested volume\n\t\tresponse = compute.create_volume(resource[:availability_zone],resource[:size],resource[:snapshot])\t\n\t\tif (response.status == 200)\n\t\t\tvolumeid = response.body['volumeId']\n\t\t\tprint \"ebsvol[aws]->create: I created volume #{volumeid}.\\n\" if $debug\n\t\t\t# now tag the volume with volumename so we can identify it by name\n\t\t\t# and not the volumeid\n\t\t\tresponse = compute.create_tags(volumeid,{ :Name => resource[:volume_name] })\n\t\t\tif (response.status == 200)\n\t\t\t\tprint \"ebsvol[aws]->create: I tagged #{volumeid} with Name = #{resource[:volume_name]}\\n\" if $debug\n\t\t\tend\n\t\t\t# Check if I need to attach it to an ec2 instance.\n\t\t\tattachto = resource[:attached_to].to_s\n\t\t\tprint \"attachto is #{attachto}\\n\" if $debug\n\t\t\tif ( attachto != '' )\n\t\t\t\tif ( attachto == 'me')\n\t\t\t\t\tinstance = instanceinfo(compute,myname(compute))\n\t\t\t\telse\n\t\t\t\t\tinstance = instanceinfo(compute,attachto)\n\t\t\t\tend\n\t\t\t\tif ( resource[:device] != nil )\n\t\t\t\t\t# try to attach the volume to requested instance\n\t\t\t\t\tprint \"attach the volume\\n\" if $debug\n\t\t\t\t\tvolume = volinfo(compute,resource[:volume_name])\n\t\t\t\t\tattachvol(compute,volume,instance,resource[:device])\n\t\t\t\telse\n\t\t\t\t\traise \"ebsvol[aws]->create: Sorry, I can't attach a volume with out a device to attach to!\"\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\traise \"ebsvol[aws]->create: I couldn't create the ebs volume, sorry!\"\n\t\tend\n\tend", "def create_snapshot_bundle\n # we shouldn't specify -k $EC2_PRIVATE_KEY since we assume private keys are already appended to /root/.ssh/authorized_keys\n # but it's a required parameter -- doh!\n run \"#{ec2_cmd('ec2-bundle-vol')} -v #{volume_to_bundle} -d #{bundling_directory} -k $EC2_PRIVATE_KEY -u #{@ec2_user_id} -s #{volume_size}\"\n end", "def create_snapshot(volume_id, options = {})\n action = 'CreateSnapshot'\n params = {\n 'Action' => action,\n 'VolumeId' => volume_id\n }\n params['Description'] = options[:description] unless options[:description].blank?\n\n response = send_query_request(params)\n parser = Awsum::Ec2::SnapshotParser.new(self)\n snapshot = parser.parse(response.body)[0]\n if options[:tags] && options[:tags].size > 0\n create_tags snapshot.id, options[:tags]\n end\n snapshot\n end", "def volume_create_from_snap(source, name, snapshot_id)\n retries = 3\n begin \n @log.info \"Creating volume #{name} from snapshot id #{snapshot_id}...\"\n ret = @cloud_stack.create_volume(name, ZONE, nil, snapshot_id)\n id = ret[\"createvolumeresponse\"][\"jobid\"]\n wait_for_job id\n rescue Exception => e\n retries -= 1\n if retries > 0\n @log.error \"Failed. #{e.message}. Retrying...\"\n retry\n end\n raise e\n end\n vol_id = ret[\"createvolumeresponse\"][\"id\"]\n @log.info \"Created volume id: #{vol_id}\"\n vol_id\n end", "def create_volume(availability_zone, options = {})\n raise ArgumentError.new('You must specify a size if not creating a volume from a snapshot') if options[:snapshot_id].blank? && options[:size].blank?\n\n action = 'CreateVolume'\n params = {\n 'Action' => action,\n 'AvailabilityZone' => availability_zone\n }\n params['Size'] = options[:size] unless options[:size].blank?\n params['SnapshotId'] = options[:snapshot_id] unless options[:snapshot_id].blank?\n\n response = send_query_request(params)\n parser = Awsum::Ec2::VolumeParser.new(self)\n volume = parser.parse(response.body)[0]\n if options[:tags] && options[:tags].size > 0\n create_tags volume.id, options[:tags]\n end\n volume\n end", "def create_volume(snapshot_id, size, availability_zone, timeout, volume_type, piops)\n availability_zone ||= instance_availability_zone\n\n # Sanity checks so we don't shoot ourselves.\n raise \"Invalid volume type: #{volume_type}\" unless ['standard', 'gp2', 'io1'].include?(volume_type)\n\n # PIOPs requested. Must specify an iops param and probably won't be \"low\".\n if volume_type == 'io1'\n raise 'IOPS value not specified.' unless piops >= 100\n end\n\n # Shouldn't see non-zero piops param without appropriate type.\n if piops > 0\n raise 'IOPS param without piops volume type.' unless volume_type == 'io1'\n end\n\n create_volume_opts = { :volume_type => volume_type }\n # TODO: this may have to be casted to a string. rightaws vs aws doc discrepancy.\n create_volume_opts[:iops] = piops if volume_type == 'io1'\n\n nv = ec2.create_volume(snapshot_id, size, availability_zone, create_volume_opts)\n Chef::Log.debug(\"Created new volume #{nv[:aws_id]}#{snapshot_id ? \" based on #{snapshot_id}\" : \"\"}\")\n\n # block until created\n begin\n Timeout::timeout(timeout) do\n while true\n vol = volume_by_id(nv[:aws_id])\n if vol && vol[:aws_status] != \"deleting\"\n if [\"in-use\", \"available\"].include?(vol[:aws_status])\n Chef::Log.info(\"Volume #{nv[:aws_id]} is available\")\n break\n else\n Chef::Log.debug(\"Volume is #{vol[:aws_status]}\")\n end\n sleep 3\n else\n raise \"Volume #{nv[:aws_id]} no longer exists\"\n end\n end\n end\n rescue Timeout::Error\n raise \"Timed out waiting for volume creation after #{timeout} seconds\"\n end\n\n nv[:aws_id]\n end", "def create_volume( options = {} )\n options = { :availability_zone => '' }.merge(options)\n raise ArgumentError, \"No :availability_zone provided\" if options[:availability_zone].nil? || options[:availability_zone].empty?\n options = { :size => '' }.merge(options)\n options = { :snapshot_id => '' }.merge(options)\n params = {\n \"AvailabilityZone\" => options[:availability_zone],\n \"Size\" => options[:size],\n \"SnapshotId\" => options[:snapshot_id]\n }\n return response_generator(:action => \"CreateVolume\", :params => params)\n end", "def create_snapshots(isCopy)\n ec2 = AWS::EC2.new.client\n\n #get all volumes tagged as \"backup\"\n volumes = ec2.describe_volumes(:filters => [:name => 'tag-key', :values => ['backup']])\n snapshots = []\n\n #loop thru and create snapshots for all these volumes\n if volumes \n volumes.data[:volume_set].each do |v|\n name = get_tagvalue(v, \"Name\")\n snap = ec2.create_snapshot(:volume_id => v[:volume_id], :description => \"Backup for \" + Time.now.to_s + \" - created by SDK\")\n if snap\n snapshots << snap.data\n #add name tag\n ec2.create_tags(:resources => [snap.data[:snapshot_id]], :tags => [{:key => \"Name\", :value => name + \" backup\"}])\n\n #now copy snapshots to another region\n if isCopy\n copy_snapshot(snap.data[:snapshot_id], AWSCONFIG[:default_region], AWSCONFIG[:backup_region], \n name + \" backup\", \"Backup for \" + Time.now.to_s + \" - created by SDK\")\n end\n end\n end\n end\n\n return snapshots\n end", "def createvolume\n if not checkRequirements([\"thezone\",\"thevolume\"])\n return false\n end\n checkToken(@thezone)\n req = {}\n req[\"name\"] = \"oe-#{@thevolume.name}\"\n req[\"description\"] = @thevolume.description\n req[\"sizeGb\"] = @thevolume.size\n submit = queryGCE(:path => '/compute/v1beta15/projects/#{@thezone.name}/zones/#{@thevolume.azone.name}/disks', :method => 'post', :options => '', :data => req.to_json, :access_token => @thezone.toekn )\n d = checkQuery(:type => 'zone', :token => @thezone.token, :projectname => @thezone.name, :zonename => @thevolume.azone.name, :operationname => submit[\"name\"])\n data = queryGCE(:path => '/compute/v1beta15/projects/#{@thezone.name}/zones/#{@thevolume.azone.name}/disks/#{req[\"name\"]}', :method => 'get', :options => '', :access_token => @thezone.token) if d\n data ? data[\"name\"] : false\n end", "def create_ec2_ebs_volume opts\n Ec2EbsVolume.create opts.merge :account => self\n end", "def snapshot_disk(disk_id, metadata)\n metadata = Hash[metadata.map { |key, value| [key.to_s, value] }]\n\n with_thread_name(\"snapshot_disk(#{disk_id})\") do\n volume = @ec2_client.volumes[disk_id]\n devices = []\n volume.attachments.each { |attachment| devices << attachment.device }\n\n name = ['deployment', 'job', 'index'].collect { |key| metadata[key] }\n name << devices.first.split('/').last unless devices.empty?\n\n snapshot = volume.create_snapshot(name.join('/'))\n logger.info(\"snapshot '#{snapshot.id}' of volume '#{disk_id}' created\")\n\n ['agent_id', 'instance_id', 'director_name', 'director_uuid'].each do |key|\n TagManager.tag(snapshot, key, metadata[key])\n end\n TagManager.tag(snapshot, 'device', devices.first) unless devices.empty?\n TagManager.tag(snapshot, 'Name', name.join('/'))\n\n ResourceWait.for_snapshot(snapshot: snapshot, state: :completed)\n snapshot.id\n end\n end", "def create_snapshot(rds_resource, db_instance_name)\n id = \"snapshot-#{rand(10**6)}\"\n db_instance = rds_resource.db_instance(db_instance_name)\n db_instance.create_snapshot({\n db_snapshot_identifier: id\n })\nrescue Aws::Errors::ServiceError => e\n puts \"Couldn't create DB instance snapshot #{id}:\\n #{e.message}\"\nend", "def snapshot_disk(disk_id, metadata)\n metadata = Hash[metadata.map { |key, value| [key.to_s, value] }]\n\n with_thread_name(\"snapshot_disk(#{disk_id})\") do\n volume = @ec2_resource.volume(disk_id)\n devices = []\n volume.attachments.each { |attachment| devices << attachment.device }\n\n name = ['deployment', 'job', 'index'].collect { |key| metadata[key] }\n\n unless devices.empty?\n name << devices.first.split('/').last\n metadata['device'] = devices.first\n end\n\n snapshot = volume.create_snapshot(description: name.join('/'))\n logger.info(\"snapshot '#{snapshot.id}' of volume '#{disk_id}' created\")\n\n metadata.merge!(\n 'director' => metadata['director_name'],\n 'instance_index' => metadata['index'].to_s,\n 'instance_name' => metadata['job'] + '/' + metadata['instance_id'],\n 'Name' => name.join('/')\n )\n\n %w[director_name index job].each do |tag|\n metadata.delete(tag)\n end\n\n TagManager.create_tags(snapshot, **metadata)\n ResourceWait.for_snapshot(snapshot: snapshot, state: 'completed')\n snapshot.id\n end\n end", "def create_snapshot(snap_id, snap_name)\n memory_dumps = true\n memory_dumps = CONFIG[:memory_dumps] \\\n unless CONFIG[:memory_dumps].nil?\n\n snapshot_hash = {\n :name => snap_id,\n :description => \"OpenNebula Snapshot: #{snap_name}\",\n :memory => memory_dumps,\n :quiesce => true\n }\n\n begin\n @item.CreateSnapshot_Task(snapshot_hash).wait_for_completion\n rescue StandardError => e\n error = \"Cannot create snapshot for VM: #{e.message}.\"\n\n if VCenterDriver::CONFIG[:debug_information]\n error += \"\\n\\n#{e.backtrace.join(\"\\n\")}\"\n end\n\n raise error\n end\n\n snap_id\n end", "def create_ebs_backup(options = {})\n params = options.merge( { :commit => \"explicit\", :api_version => 1.0 } )\n STDERR.puts \"Performing RightScale API call to create a new snapshot\"\n json=nil\n SystemTimer.timeout_after(@api_snap_timeout) do\n body = RestClient.post @api_url+\"/create_ebs_backup.js\", params\n json = body.nil? ? nil: JSON.load(body)\n STDERR.puts \"CREATED_SNAPS: #{json}\"\n end\n json \n rescue Exception => e\n display_exception(e, \"create_ebs_backup(#{options.inspect})\")\n end", "def snapshot_disk(disk_id, metadata)\n metadata = Hash[metadata.map { |key, value| [key.to_s, value] }]\n\n with_thread_name(\"snapshot_disk(#{disk_id})\") do\n volume = @ec2_resource.volume(disk_id)\n devices = []\n volume.attachments.each { |attachment| devices << attachment.device }\n\n name = ['deployment', 'job', 'index'].collect { |key| metadata[key] }\n name << devices.first.split('/').last unless devices.empty?\n\n snapshot = volume.create_snapshot(name.join('/'))\n logger.info(\"snapshot '#{snapshot.id}' of volume '#{disk_id}' created\")\n\n\n tags = {}\n ['agent_id', 'instance_id', 'director_name', 'director_uuid'].each do |key|\n tags[key] = metadata[key]\n end\n tags['device'] = devices.first unless devices.empty?\n tags['Name'] = name.join('/')\n TagManager.tags(snapshot, tags)\n\n ResourceWait.for_snapshot(snapshot: snapshot, state: 'completed')\n snapshot.id\n end\n end", "def snapshot_disk(disk_id, metadata={})\n # TODO: Get vhd from 'vhd' container in vm storage account and use blob client to snapshot it\n end", "def create_snapshot(name)\n unless exists?\n return Response.new :code => 1, :message => 'VM does not exist'\n end\n\n running_response = running?\n return running_response unless running_response.successful?\n\n unless running_response.data\n message = 'The VM must be running in order to take a snapshot.'\n return Response.new :code => 1, :message => message\n end\n\n conf_file_response = conf_file\n return conf_file_response unless conf_file_response.successful?\n\n snapshots_response = snapshots\n return snapshots_response unless snapshots_response.successful?\n\n if snapshots_response.data.include? name\n message = \"There is already a snapshot named '#{name}'.\"\n return Response.new :code => 1, :message => message\n end\n\n command = \"#{vmrun_cmd} snapshot \"\n command << \"#{conf_file_response.data} \\\"#{name}\\\" 2>&1\"\n\n Response.from_command(`#{command}`)\n end", "def create_storage_volume(create_opts={})\n create_resource :storage_volume, create_opts\n end", "def create_snapshot(metadata={})\n Azure::Blobs.create_snapshot(self, metadata)\n end", "def attach_blank_volume opts\n device = opts.delete :device\n opts = {:ec2_availability_zone => ec2_availability_zone }.merge opts\n volume = account.create_ec2_ebs_volume opts\n attach_volume volume, device\n end", "def create_blob_snapshot(container, blob, options={})\n query = { 'comp' => 'snapshot'}\n StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]\n\n uri = blob_uri(container, blob, query)\n\n headers = StorageService.common_headers\n unless options.empty?\n StorageService.add_metadata_to_headers(options[:metadata], headers)\n add_blob_conditional_headers(options, headers)\n end\n\n response = call(:put, uri, nil, headers, options)\n\n response.headers['x-ms-snapshot']\n end", "def volume_create(name)\n @log.info \"Creating volume #{name} from offering id #{DISK_OFFERING}...\"\n ret = @cloud_stack.create_volume(name, ZONE, DISK_OFFERING)\n id = ret[\"createvolumeresponse\"][\"jobid\"]\n wait_for_job id\n vol_id = ret[\"createvolumeresponse\"][\"id\"]\n @log.info \"Created volume id: #{vol_id}\"\n vol_id\n end", "def attachvol(compute,volume,instance,device)\n\t\tprint \"Running attachvol\\n\" if $debug\n\t\traise ArgumentError \"ebsvol[aws]->attachvol: Sorry, you must specify a valid device matching /dev/sd[a-m].\" if (device !~ /^\\/dev\\/sd[a-m]/)\n\t\tif (volume['status'] != \"in-use\" )\n\t\t\t# check instance is in the same availability zone\n\t\t\tif ( volume['availabilityZone'] != instance['placement']['availabilityZone'])\n\t\t\t\traise \"ebsvol[aws]->attachvol: Sorry, volumes must be in the same availability zone as the instance to be attached to.\\nThe volume #{volume['tagSet']['Name']} is in availability zone #{volume['availabilityZone']} and the instance is in #{instance['placement']['availabilityZone']}\" \n\t\t\telse\n\t\t\t\t# check that the device is available\n\t\t\t\tinuse = false\n\t\t\t\tinstance['blockDeviceMapping'].each { |x| inuse=true if x['deviceName'] == device }\n\t\t\t\tif ( inuse )\n\t\t\t\t\traise \"ebsvol[aws]->attachvol: Sorry, the device #{device} is already in use on #{instance['tagSet']['Name']}\" \n\t\t\t\telse\n\t\t\t\t\tresp = compute.attach_volume(instance['instanceId'],volume['volumeId'],device)\n\t\t\t\t\tif (resp.status == 200)\n\t\t\t\t\t\t# now wait for it to attach!\n\t\t\t\t\t\tcheck = volinfo(compute,volume['tagSet']['Name'])\n\t\t\t\t\t\twhile ( check['status'] !~ /(attached|in-use)/ ) do\n\t\t\t\t\t\t\tprint \"ebsvol[aws]->attachvol: status is #{check['status']}\\n\" if $debug\n\t\t\t\t\t\t\tsleep 5\n\t\t\t\t\t\t\tcheck = volinfo(compute,volume['tagSet']['Name'])\n\t\t\t\t\t\tend\n\t\t\t\t\t\tsleep 5 # allow aws to propigate the fact\n\t\t\t\t\t\tprint \"ebsvol[aws]->attachvol: volume is now attached\\n\" if $debug\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\traise \"ebsvol[aws]->attachvol: Sorry, I could not attach #{volume['volumeId']} because it is in use!\"\n\t\tend\n\tend", "def create_snapshot(droplet) # rubocop:disable MethodLength,Metrics/AbcSize\n fail_if_shutdown(droplet)\n\n logger.info \"Start creating snapshot for droplet id: #{droplet.id} name: #{droplet.name}.\"\n\n today = DateTime.now\n name = \"#{droplet.name}_#{today.strftime('%Y_%m_%d')}\"\n # noinspection RubyResolve\n snapshot_size = api.snapshots(droplet).size\n\n logger.debug 'Wait until snapshot will be created.'\n\n api.create_snapshot droplet.id, name\n\n snapshot_size += 1\n\n logger.info \"Snapshot name: #{name} created successfully.\"\n logger.info \"Droplet id: #{droplet.id} name: #{droplet.name} snapshots: #{snapshot_size}.\"\n\n # Cleanup snapshots.\n cleanup_snapshots droplet, snapshot_size if clean\n rescue => e\n case e.class.to_s\n when 'DoSnapshot::SnapshotCleanupError'\n raise e.class, e.message, e.backtrace\n when 'DoSnapshot::DropletPowerError'\n return\n else\n raise SnapshotCreateError.new(droplet.id), e.message, e.backtrace\n end\n end", "def create_db_snapshot(identifier, name)\n request({\n 'Action' => 'CreateDBSnapshot',\n 'DBInstanceIdentifier' => identifier,\n 'DBSnapshotIdentifier' => name,\n :parser => Fog::Parsers::AWS::RDS::CreateDBSnapshot.new\n })\n end", "def vm_create_evm_snapshot(vm, options = {})\n require \"OpenStackExtract/MiqOpenStackVm/MiqOpenStackInstance\"\n\n log_prefix = \"vm=[#{vm.name}]\"\n\n miq_openstack_instance = MiqOpenStackInstance.new(vm.ems_ref, openstack_handle)\n miq_snapshot = miq_openstack_instance.create_evm_snapshot(options)\n\n # Add new snapshot image to the vms table. Type is TemplateOpenstack.\n miq_templates.create!(\n :type => \"ManageIQ::Providers::Openstack::CloudManager::Template\",\n :vendor => \"openstack\",\n :name => miq_snapshot.name,\n :uid_ems => miq_snapshot.id,\n :ems_ref => miq_snapshot.id,\n :template => true,\n :location => \"unknown\"\n )\n\n # Add new snapshot to the snapshots table.\n vm.snapshots.create!(\n :name => miq_snapshot.name,\n :description => options[:desc],\n :uid => miq_snapshot.id,\n :uid_ems => miq_snapshot.id,\n :ems_ref => miq_snapshot.id\n )\n return miq_snapshot.id\n rescue => err\n _log.error \"#{log_prefix}, error: #{err}\"\n _log.debug { err.backtrace.join(\"\\n\") }\n raise\n end", "def create_volume(options)\n # Creating the volume is part of the server creation\n end", "def create_volume(options)\n # Creating the volume is part of the server creation\n end", "def create_blob_snapshot(container, blob, options={})\n query = { 'comp' => 'snapshot'}\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n uri = blob_uri(container, blob, query)\n\n headers = service_properties_headers\n unless options.empty?\n add_metadata_to_headers(options[:metadata], headers) if options[:metadata]\n\n headers['If-Modified-Since'] = options[:if_modified_since] if options[:if_modified_since]\n headers['If-Unmodified-Since'] = options[:if_unmodified_since] if options[:if_unmodified_since]\n headers['If-Match'] = options[:if_match] if options[:if_match]\n headers['If-None-Match'] = options[:if_none_match] if options[:if_none_match]\n end\n\n response = call(:put, uri, nil, headers)\n\n response.headers['x-ms-snapshot']\n end", "def create_ebs_stripe(nickname, new_volume_size_in_gb, options = {})\n self.execute_terminate_volumes if options[:force]\n devices = @disk.generate_physical_device_names(options[:stripe])\n each_volume_size = (new_volume_size_in_gb / options[:stripe].to_f).ceil\n devices.each do |d| \n vol = self.create_volume(:nickname => \"#{nickname}-#{d}\", \n :description => \"Created by RS tools to initialize new EBS stripe volume\",\n :size => each_volume_size)\n raise vol unless vol['aws_id']\n \"Attaching new EBS volume: #{vol['aws_id']}\"\n att = self.attach_volume(vol['aws_id'], d)\n end\n devices.each {|d| self.wait_for_attachment(d) }\n\n @disk.initialize_stripe(devices)\n end", "def snapshot_devices(devices, prefix, limit = 0, name = \"#{instance_id}\")\n log \"Snapshot limit set to #{limit} (0 means never purge)\"\n ts = DateTime.now.strftime(\"%Y-%m-%d-%H-%M\").to_s\n name = \"#{prefix} \" + name\n volumes = {}\n devices.each do |device|\n volumes[device] = find_volume_for_device(device)\n end\n sn = []\n volumes.each do |device, volume|\n log \"Creating volume snapshot for #{device} on instance #{instance_id}\"\n snapshot = volume.snapshots.new\n snapshot.description = name+\": #{device}\"\n snapshot.save\n sn << snapshot\n snapshot.reload\n\n @compute.tags.create(:resource_id => snapshot.id, :key =>\"device\", :value => device)\n @compute.tags.create(:resource_id => snapshot.id, :key =>\"instance_id\", :value =>instance_id)\n @compute.tags.create(:resource_id => snapshot.id, :key =>\"date\", :value => ts)\n end\n\n # DO NOT need to wait for creating EBS snapshot\n #log \"Waiting for snapshots to complete.\"\n #sn.each do |s|\n # begin\n # sleep(3)\n # s.reload\n # end while s.state == 'nil' || s.state == 'pending'\n #end\n\n if limit != 0\n # populate data structure with updated information\n snapshots = list_snapshots(devices)\n nsnaps = snapshots.keys.length\n if nsnaps-limit > 0\n dates = snapshots.keys.sort\n puts dates.inspect\n extra_snapshots = dates[0..-(limit+1)]\n remaining_snapshots = dates[-limit..-1]\n extra_snapshots.each do |date|\n snapshots[date].each do |snap|\n log \"Destroying #{snap.description} #{snap.id}\"\n snap.destroy\n end\n end\n end\n end\n end", "def createNewSnapshot\n snap_id = @deploy.getResourceName(@config[\"name\"]) + Time.new.strftime(\"%M%S\").to_s\n\n attempts = 0\n begin\n MU::Cloud::AWS.elasticache(region: @region, credentials: @credentials).create_snapshot(\n cache_cluster_id: @config[\"identifier\"],\n snapshot_name: snap_id\n )\n rescue Aws::ElastiCache::Errors::InvalidCacheClusterState => e\n if attempts < 10\n MU.log \"Tried to create snapshot for #{@config[\"identifier\"]} but cache cluster is busy, retrying a few times\"\n attempts += 1\n sleep 30\n retry\n else\n raise MuError, \"Failed to create snpashot for cache cluster #{@config[\"identifier\"]}: #{e.inspect}\"\n end\n end\n \n attempts = 0\n loop do\n MU.log \"Waiting for snapshot of cache cluster #{@config[\"identifier\"]} to be ready...\", MU::NOTICE if attempts % 20 == 0\n MU.log \"Waiting for snapshot of cache cluster #{@config[\"identifier\"]} to be ready...\", MU::DEBUG\n\n snapshot_resp = MU::Cloud::AWS.elasticache(region: @region, credentials: @credentials).describe_snapshots(snapshot_name: snap_id)\n attempts += 1\n break unless snapshot_resp.snapshots.first.snapshot_status != \"available\"\n sleep 15\n end\n\n return snap_id\n end", "def clone_volume(source, target)\n debug(\"Creating Libvirt volume #{target}\")\n debug(\"Cloning volume from #{source}\")\n\n # Attempt to locate the target or source volume\n source_image = client.volumes.get(source)\n if source_image.name =~ /^fog-\\d+/\n error(\"Could not find target image: #{source}.\")\n end\n\n # Clone the source volume\n source_image.clone_volume(target)\n client.volumes.all.find { |vol| vol.name == target }\n end", "def create_snapshot(snapshot_name)\n execute(:create_snapshot, VmId: vm_id, SnapName: snapshot_name)\n end", "def create_snapshot(uuid, snapshot_name)\n stdout = execute_prlctl('snapshot', uuid, '--name', snapshot_name)\n return Regexp.last_match(1) if stdout =~ /{([\\w-]+)}/\n\n raise Errors::SnapshotIdNotDetected, stdout: stdout\n end", "def create_volume(options={}) \n raise \"Volume nickname required\" unless options[:nickname]\n params = {:nickname => options[:nickname],:size => options[:size], :api_version => 1.0}\n params[:description] = options[:description] if options[:description]\n #STDERR.puts \"HERE IS THE URL: #{@api_url}/create_ebs_volume.js (PARAMS: #{params.inspect})\"\n body = RestClient.post @api_url+\"/create_ebs_volume.js\",params\n json = JSON.load(body)\n STDERR.puts \"CREATED_VOLUME: #{json}\"\n json\n rescue => e\n display_exception(e, \"create_volume: #{options.inspect}\")\n end", "def provision_and_mount_volume(server, disk_size, device)\n unless provider.find_server_device(server, device)\n say \"Provisioning #{disk_size}Gb persistent disk for inception VM...\"\n provider.create_and_attach_volume(\"Inception Disk\", disk_size, server, device)\n end\n\n # Format and mount the volume\n if aws?\n say \"Skipping volume mounting on AWS 12.10 inception VM until its fixed\", [:yellow, :bold]\n run_ssh_command_until_successful server, \"sudo mkdir -p /var/vcap/store\"\n else\n say \"Mounting persistent disk as volume on inception VM...\"\n run_ssh_command_until_successful server, \"sudo mkfs.ext4 #{device} -F\"\n run_ssh_command_until_successful server, \"sudo mkdir -p /var/vcap/store\"\n run_ssh_command_until_successful server, \"sudo mount #{device} /var/vcap/store\"\n end\n end", "def create!\n set_id = generate_set_id\n\n @volume_ids.each do |id|\n snapshot = @fog.snapshots.new\n\n snapshot.description = \"#{@hostname.split(\".\")[0]} #{@mount} (#{self.needed_types.join(\", \")}) (#{set_id})\"\n snapshot.volume_id = id\n\n # Actually do the snapshot\n snapshot.save\n\n # Reload to get snapshot.id so we can add tags\n snapshot.reload\n\n @fog.tags.create(:resource_id => snapshot.id, :key => \"Host\", :value => @hostname)\n @fog.tags.create(:resource_id => snapshot.id, :key => \"Mount\", :value => @mount)\n @fog.tags.create(:resource_id => snapshot.id, :key => \"SetID\", :value => set_id)\n @fog.tags.create(:resource_id => snapshot.id, :key => \"Type\", :value => self.needed_types.join(\",\"))\n end\n end", "def create_volume(options = {})\n options[:capacity] = options[:capacity] * GB if options[:capacity] < 100000\n vol = pool.create_volume_xml(Volume.to_xml(options))\n Volume.new vol, self\n end", "def addVolume(dev, size, type: \"gp2\", delete_on_termination: false)\n\n if setDeleteOntermination(dev, delete_on_termination)\n MU.log \"A volume #{dev} already attached to #{self}, skipping\", MU::NOTICE\n return\n end\n\n MU.log \"Creating #{size}GB #{type} volume on #{dev} for #{@cloud_id}\"\n creation = MU::Cloud::AWS.ec2(region: @region, credentials: @credentials).create_volume(\n availability_zone: cloud_desc.placement.availability_zone,\n size: size,\n volume_type: type\n )\n\n MU.retrier(wait: 3, loop_if: Proc.new {\n creation = MU::Cloud::AWS.ec2(region: @region, credentials: @credentials).describe_volumes(volume_ids: [creation.volume_id]).volumes.first\n if ![\"creating\", \"available\"].include?(creation.state)\n raise MuError, \"Saw state '#{creation.state}' while creating #{size}GB #{type} volume on #{dev} for #{@cloud_id}\"\n end\n creation.state != \"available\"\n })\n\n\n if @deploy\n MU::Cloud::AWS.createStandardTags(\n creation.volume_id,\n region: @region,\n credentials: @credentials,\n optional: @config['optional_tags'],\n nametag: @mu_name+\"-\"+dev.upcase,\n othertags: @config['tags']\n )\n end\n\n MU.log \"Attaching #{creation.volume_id} as #{dev} to #{@cloud_id} in #{@region} (credentials #{@credentials})\"\n attachment = nil\n MU.retrier([Aws::EC2::Errors::IncorrectState], wait: 15, max: 4) {\n attachment = MU::Cloud::AWS.ec2(region: @region, credentials: @credentials).attach_volume(\n device: dev,\n instance_id: @cloud_id,\n volume_id: creation.volume_id\n )\n }\n\n begin\n att_resp = MU::Cloud::AWS.ec2(region: @region, credentials: @credentials).describe_volumes(volume_ids: [attachment.volume_id])\n if att_resp and att_resp.volumes and !att_resp.volumes.empty? and\n att_resp.volumes.first.attachments and\n !att_resp.volumes.first.attachments.empty?\n attachment = att_resp.volumes.first.attachments.first\n if !attachment.nil? and ![\"attaching\", \"attached\"].include?(attachment.state)\n raise MuError, \"Saw state '#{creation.state}' while creating #{size}GB #{type} volume on #{dev} for #{@cloud_id}\"\n end\n end\n end while attachment.nil? or attachment.state != \"attached\"\n\n # Set delete_on_termination, which for some reason is an instance\n # attribute and not on the attachment\n setDeleteOntermination(dev, delete_on_termination)\n end", "def create\n properties = [ resource[:name],\n resource[:user],\n resource[:group],\n resource[:config],\n resource[:mode],\n ]\n\n qmgmt(['volume', 'create'] + properties)\n end", "def provision_storage host, vm\n if host['volumes']\n # Lazily create the volume client if needed\n volume_client_create\n host['volumes'].keys.each_with_index do |volume, index|\n @logger.debug \"Creating volume #{volume} for OpenStack host #{host.name}\"\n\n # The node defintion file defines volume sizes in MB (due to precedent\n # with the vagrant virtualbox implementation) however OpenStack requires\n # this translating into GB\n openstack_size = host['volumes'][volume]['size'].to_i / 1000\n\n # Create the volume and wait for it to become available\n vol = @volume_client.volumes.create(\n :size => openstack_size,\n :display_name => volume,\n :description => \"Beaker volume: host=#{host.name} volume=#{volume}\",\n )\n vol.wait_for { ready? }\n\n # Fog needs a device name to attach as, so invent one. The guest\n # doesn't pay any attention to this\n device = \"/dev/vd#{('b'.ord + index).chr}\"\n vm.attach_volume(vol.id, device)\n end\n end\n end", "def create_from_snapshot(snapshot_name, properties, volume_template = nil, is_permanent = true)\n snapshot = get_snapshot(snapshot_name)\n raise IncompleteResource, 'Snapshot not found!' unless snapshot\n storage_pool_uri = nil\n volume_template_uri = if volume_template.nil?\n storage_pool_uri = @data['storagePoolUri']\n get_volume_template_uri(isRoot: true, family: 'StoreServ')\n else\n raise IncompleteResource, 'Volume Template not found!' unless volume_template.retrieve!\n storage_pool_uri = volume_template['storagePoolUri']\n volume_template['uri']\n end\n\n data = {\n 'properties' => properties.merge('storagePool' => storage_pool_uri, 'snapshotPool' => storage_pool_uri),\n 'snapshotUri' => snapshot['uri'],\n 'templateUri' => volume_template_uri,\n 'isPermanent' => is_permanent\n }\n\n response = @client.rest_post(\"#{BASE_URI}/from-snapshot\", { 'body' => data }, @api_version)\n self.class.new(@client, client.response_handler(response))\n end", "def createRDSSnapshot(client=nil,db_instance=nil,snapshot_name=nil,tags=[])\n return false if db_instance.nil? || client.nil?\n if snapshot_name.nil?\n snapshot_name=\"#{db_instance}-#{Time.now.to_i}\"\n end\n unless tags.instance_of? Array\n puts \"\\e[31mtags must be an Array\\e[0m\"\n return false\n end\n begin\n puts \"\\e[32mTaking snapshot of db instance #{db_instance}. Snapshot will be named #{snapshot_name}\\e[0m\"\n resp = client.create_db_snapshot({\n db_snapshot_identifier: snapshot_name,\n db_instance_identifier: db_instance,\n tags: tags\n })\n rescue Exception => e\n puts \"\\e[31m#{e.message}\\e[0m\"\n return false\n end\n return resp\nend", "def snapshot_disk(disk_id, metadata)\n raise Bosh::Clouds::NotSupported.new(false),\n 'snapshot_disk is not supported.'\n end", "def snap_delete(volume,snapshot)\n output = @filer.invoke(\"snapshot-create\",\"volume\",volume,\"snapshot\",snapshot)\n if (output.results_status() == \"failed\")\n raise \"Error #{output.results_errno} creating snapshot #{snapshot} on #{volume}: #{output.results_reason()}\\n\"\n end\n end", "def execute_restore_stripe(options={})\n new_vol_name = \"#{options[:lineage]}-#{ENV['EC2_INSTANCE_ID']}\"\n json_result = self.find_latest_ebs_backup(options[:lineage], options[:from_master], options[:timestamp])\n\n if json_result.nil? \n STDERR.puts \"No existing snapshot found for the specified nickname lineage. Aborting...\"\n exit(-1)\n end\n STDERR.puts \"Restoring.. #{json_result.inspect}\"\n options[:new_size_gb] = (options[:new_volume_size_in_gb] / json_result.size.to_f).ceil if options[:new_volume_size_in_gb]\n\n @disk.sync\n @disk.umount\n @disk.disable_volume\n\n self.execute_terminate_volumes if options[:force]\n\n json_result.each do |snapshot|\n \n# create volume from snap\n create_result = ( options[:new_size_gb] ? create_volume_from_snap_size_gb(snapshot[\"aws_id\"],new_vol_name,options[:new_size_gb] ) : create_volume_from_snap(snapshot[\"aws_id\"], new_vol_name ) )\n raise \"FATAL: error occured in create_volume_from_snap(#{snapshot['aws_id']}, #{new_vol_name})\" if create_result.nil?\n\n# attach volume to instance\n retry_seconds = 0\n while retry_seconds < 200\n begin \n attach_result = attach_volume(create_result['aws_id'], snapshot['device'])\n raise \"FATAL: error occured in attach_volume(#{create_result['aws_id']}, #{snapshot['device']}\" if attach_result.nil?\n break if attach_result\n rescue => e\n puts \"CAUGHT EXCEPTION in execute_restore_stripe. Device attachment. #{e}, Retrying #{retry_seconds} of 200 seconds\"\n retry_seconds += 30\n sleep 30 \n end\n end\n raise \"FATAL: error occured in attach_volume(#{create_result['aws_id']}, #{snapshot['device']}\" if attach_result.nil?\n end\n\n# wait for devices to attach, after completing ALL the api calls\n json_result.each { |s| wait_for_attachment(s['device']) }\n @disk.enable_volume\n raise \"FATAL: mount failed!\" unless @disk.mount\n @disk.write_fstab\n# TODO - grow the filesystem if a new size was given\n end", "def create_snapshot(vm, name)\n task = vm.CreateSnapshot_Task(\n name: name,\n memory: false,\n quiesce: false)\n\n if block_given?\n task.wait_for_progress do |progress|\n yield progress unless progress.nil?\n end\n else\n task.wait_for_completion\n end\n end", "def snapshot\r\n date = self.class.service_instance.snapshot_blob(self.path)\r\n properties = self.class.service_instance.get_blob_properties(self.path)\r\n return BlobObject.new(:name => self.name, \r\n :url => self.class.service_instance.generate_request_uri(self.path) + \"?snapshot=#{date}\",\r\n :content_type => properties[:content_type],\r\n :snapshot_date => date)\r\n end", "def create_stripe_volume(server)\n options = { \"EBS_MOUNT_POINT\" => \"text:#{@mount_point}\",\n \"EBS_STRIPE_COUNT\" => \"text:#{@stripe_count}\",\n \"EBS_TOTAL_VOLUME_GROUP_SIZE\" => \"text:#{@volume_size}\",\n \"EBS_LINEAGE\" => \"text:#{@lineage}\" }\n audit = server.run_executable(@scripts_to_run['create_stripe'], options)\n audit.wait_for_completed\n end", "def addVolume(dev, size, type: \"gp2\")\n if @cloud_id.nil? or @cloud_id.empty?\n MU.log \"#{self} didn't have a cloud id, couldn't determine 'active?' status\", MU::ERR\n return true\n end\n az = nil\n MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).describe_instances(\n instance_ids: [@cloud_id]\n ).reservations.each { |resp|\n if !resp.nil? and !resp.instances.nil?\n resp.instances.each { |instance|\n az = instance.placement.availability_zone\n instance.block_device_mappings.each { |vol|\n if vol.device_name == dev\n MU.log \"A volume #{dev} already attached to #{self}, skipping\", MU::NOTICE\n return\n end\n }\n }\n end\n }\n MU.log \"Creating #{size}GB #{type} volume on #{dev} for #{@cloud_id}\"\n creation = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).create_volume(\n availability_zone: az,\n size: size,\n volume_type: type\n )\n begin\n sleep 3\n creation = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).describe_volumes(volume_ids: [creation.volume_id]).volumes.first\n if ![\"creating\", \"available\"].include?(creation.state)\n raise MuError, \"Saw state '#{creation.state}' while creating #{size}GB #{type} volume on #{dev} for #{@cloud_id}\"\n end\n end while creation.state != \"available\"\n\n if @deploy\n MU::MommaCat.listStandardTags.each_pair { |key, value|\n MU::MommaCat.createTag(creation.volume_id, key, value, region: @config['region'], credentials: @config['credentials'])\n }\n MU::MommaCat.createTag(creation.volume_id, \"Name\", \"#{MU.deploy_id}-#{@config[\"name\"].upcase}-#{dev.upcase}\", region: @config['region'], credentials: @config['credentials'])\n end\n\n attachment = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).attach_volume(\n device: dev,\n instance_id: @cloud_id,\n volume_id: creation.volume_id\n )\n\n begin\n sleep 3\n attachment = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).describe_volumes(volume_ids: [attachment.volume_id]).volumes.first.attachments.first\n if ![\"attaching\", \"attached\"].include?(attachment.state)\n raise MuError, \"Saw state '#{creation.state}' while creating #{size}GB #{type} volume on #{dev} for #{@cloud_id}\"\n end\n end while attachment.state != \"attached\"\n end", "def volume_snapshots(volume_id)\n ec2.snapshots.select { |snapshot| snapshot.volume_id == volume_id }\n end", "def attach_volumes!(server, volumes_count, size)\n #create a new block storage connection obj\n volume_service = Fog::Volume::OpenStack.new(\n :openstack_api_key => @os_password,\n :openstack_username => @os_username,\n :openstack_auth_url => @os_auth_url,\n :openstack_tenant => @os_tenant,\n )\n base = 'sdd'\n volumes_count.times do |i|\n base = base.next!\n #create a new volume\n vol = volume_service.volumes.create(\n :size => size,\n :display_name => \"#{server.name}-#{i}\",\n :description => \"Volume attached to #{server.name} - managed by ankus\"\n )\n vol.reload\n vol.wait_for { status == 'available' }\n server.attach_volume(vol.id, \"/dev/#{base}\")\n vol.wait_for { status == 'in-use' }\n end\n end", "def create_snapshot request_pb, options:, &block\n uri = \"/compute/v1/projects/#{request_pb.project}/zones/#{request_pb.zone}/disks/#{request_pb.disk}/createSnapshot\"\n body = request_pb.snapshot_resource.to_json\n\n response = @client_stub.make_post_request(\n uri: uri,\n body: body,\n options: options,\n )\n\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n\n result\n end", "def create_default_volume()\n # Create a default application_volume using the volume attributes from the cookbook\n create_node_volume(:application_volume)\n end", "def volumes\n client = Aws::EC2::Client.new\n client.describe_volumes({\n filters: [{\n name: \"tag:backup\",\n values: [\"true\"]\n }]\n }).volumes\nend", "def create_disk(size)\n @logger.info(\"create_disk(#{size})\")\n disk_name = \"bosh-disk-#{SecureRandom.uuid}\"\n logger.info(\"Start to create an empty vhd blob: blob_name: #{disk_name}.vhd\")\n @blob_manager.create_empty_vhd_blob(container_name, \"#{disk_name}.vhd\", size)\n disk_name\n end", "def take_snapshots\n snapped_volumes = []\n logger.debug \"Issuing sync command\"\n system 'sync'\n\n logger.debug \"Walking attached volumes\"\n attached_volumes.each do |vol|\n dir = device_to_directory device_name vol\n logger.debug \"Found #{vol.id} mounted on #{dir}\"\n unless should_snap vol\n logger.debug \"Skipping #{vol.id}\"\n next\n end\n\n fs_freeze dir if options[:fs_freeze]\n take_snapshot vol\n snapped_volumes.push vol\n fs_unfreeze dir if options[:fs_freeze]\n end\n snapped_volumes\n end", "def ebs(device_name, type: 'gp2', size: 8)\n {\n device_name: device_name,\n ebs: {\n delete_on_termination: true,\n volume_size: size,\n volume_type: type\n },\n no_device: ''\n }\nend", "def snapshot esurl, snapurl, options\n elastic esurl\n set_opts(options)\n set_repository snapurl, options\n initiate_snapshot snapurl\n end", "def snap(cmd, snap)\n nodes = getnodes.map{|x| x.name}\n out = `vagrant snapshot list`\n snaps = out.include?(\"No snapshots\") ? [] : out.split.uniq.sort\n curr_snap = snaps.last\n next_snap = curr_snap ? curr_snap[0..-2] + (curr_snap[-1].to_i + 1).to_s : \"snap1\"\n\n if cmd == \"save\"\n puts(\":: Creating snapshot for VMs [#{nodes * ','}]...\".colorize(:light_yellow))\n snap ||= next_snap\n Sys.exec(\"vagrant snapshot save #{snap}\")\n elsif cmd == \"restore\"\n puts(\":: Restoring previous snapshot for VMs [#{nodes * ','}]...\".colorize(:light_yellow))\n snap ||= curr_snap\n Sys.exec(\"vagrant snapshot restore #{snap}\")\n elsif cmd == \"delete\"\n puts(\":: Deleting previous snapshot for VMs [#{nodes * ','}]...\".colorize(:light_yellow))\n snap ||= curr_snap\n Sys.exec(\"vagrant snapshot delete #{snap}\")\n elsif cmd == \"list\"\n puts(\":: Listing snapshots for VMs [#{nodes * ','}]...\".colorize(:light_yellow))\n puts(snaps)\n end\n end", "def create_disk(size, cloud_properties, server_id = nil)\n volume_service_client = @openstack.volume\n with_thread_name(\"create_disk(#{size}, #{cloud_properties}, #{server_id})\") do\n raise ArgumentError, 'Disk size needs to be an integer' unless size.is_a?(Integer)\n cloud_error('Minimum disk size is 1 GiB') if size < 1024\n\n unique_name = generate_unique_name\n volume_params = {\n # cinder v1 requires display_ prefix\n display_name: \"volume-#{unique_name}\",\n display_description: '',\n # cinder v2 does not require prefix\n name: \"volume-#{unique_name}\",\n description: '',\n size: mib_to_gib(size),\n }\n\n if cloud_properties.key?('type')\n volume_params[:volume_type] = cloud_properties['type']\n elsif !@default_volume_type.nil?\n volume_params[:volume_type] = @default_volume_type\n end\n\n if server_id && @az_provider.constrain_to_server_availability_zone?\n server = @openstack.with_openstack { @openstack.compute.servers.get(server_id) }\n volume_params[:availability_zone] = server.availability_zone if server&.availability_zone\n end\n\n @logger.info('Creating new volume...')\n new_volume = @openstack.with_openstack { volume_service_client.volumes.create(volume_params) }\n\n @logger.info(\"Creating new volume `#{new_volume.id}'...\")\n @openstack.wait_resource(new_volume, :available)\n\n new_volume.id.to_s\n end\n end", "def attach_volume volume, device\n if running?\n post '/attach_volume', :query => {\n :server => {\n :ec2_ebs_volume_href => volume.uri,\n :device => device\n }\n }\n else\n volume.attach_to_server self, device, 'boot'\n end\n end", "def createVolume\n require 'rest_client'\n require 'uri'\n\n if @role.nil? and !current_actor.superadmin\n json_response({ message: \"You don't have permission to view the clusters in this project\" }, :unauthorized)\n return\n end\n\n # Service name in the query\n volumeName = params[\"volume_name\"]\n\n # Env variables for Manager host and port\n serviceManagerHost = Settings.service_manager_host\n serviceManagerPort = Settings.service_manager_port.to_s\n serviceManagerURI = 'http://' + serviceManagerHost + ':' + serviceManagerPort + '/v1/volume'\n\n # Create request for Service Manager\n stack = {\n 'name' => volumeName,\n 'engine-url' => @cluster.endpoint,\n 'ca-cert' => @cluster.ca,\n 'cert' => @cluster.cert,\n 'cert-key' => @cluster.key\n }.to_json\n\n begin\n response = RestClient.post(\n serviceManagerURI,\n stack,\n 'Accept' => 'application/json',\n 'Content-Type' => 'application/json'\n )\n puts \"Deploy Response: \" + response\n json_response(response, :created)\n rescue Exception => e\n # If error, respond with it\n puts e\n json_response({message: e}, :unprocessable_entity)\n end\n end", "def create\n @snapshot = current_account.snapshots.new(params[:snapshot])\n\n respond_to do |format|\n if @snapshot.save\n flash[:notice] = 'Snapshot was successfully created.'\n format.html { redirect_to(@snapshot) }\n format.xml { render :xml => @snapshot, :status => :created, :location => @snapshot }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @snapshot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create_vbox_hdd(client_name,vbox_disk_name)\n message = \"Creating:\\tVM hard disk for \"+client_name\n command = \"VBoxManage createhd --filename \\\"#{vbox_disk_name}\\\" --size \\\"#{$default_vm_size}\\\"\"\n execute_command(message,command)\n return\nend", "def volume_compatible_with_resource_definition?(volume)\n if new_resource.snapshot_id =~ /vol/\n new_resource.snapshot_id(find_snapshot_id(new_resource.snapshot_id, new_resource.most_recent_snapshot))\n end\n (new_resource.size.nil? || new_resource.size == volume[:aws_size]) &&\n (new_resource.availability_zone.nil? || new_resource.availability_zone == volume[:zone]) &&\n (new_resource.snapshot_id.nil? || new_resource.snapshot_id == volume[:snapshot_id])\n end", "def volume_create\n help = [\n '',\n \"Use: #{me} volume create --name=VOLUME --git=URL\",\n \"Use: #{me} volume create --name=VOLUME --dir=PATH\",\n '',\n 'Creates a volume named VOLUME from a git clone of URL',\n 'Creates a volume named VOLUME from a copy of PATH'\n ]\n # asked for help?\n if [nil,'help','--help'].include? ARGV[2]\n show help\n exit failed\n end\n # unknown arguments?\n knowns = ['name','git','dir']\n unknown = ARGV[2..-1].select do |argv|\n knowns.none? { |known| argv.start_with?('--' + known + '=') }\n end\n if unknown != []\n show help\n unknown.each { |arg| puts \"FAILED: unknown argument [#{arg.split('=')[0]}]\" }\n exit failed\n end\n # required known arguments\n args = ARGV[2..-1]\n vol = get_arg('--name', args)\n url = get_arg('--git', args)\n dir = get_arg('--dir', args)\n if vol.nil? || (url.nil? && dir.nil?)\n show help\n exit failed\n end\n if vol.length == 1\n msg = 'volume names must be at least two characters long. See https://github.com/docker/docker/issues/20122'\n puts \"FAILED: [volume create --name=#{vol}] #{msg}\"\n exit failed\n end\n if volume_exists? vol\n msg = \"#{vol} already exists\"\n puts \"FAILED: [volume create --name=#{vol}] #{msg}\"\n exit failed\n end\n # cyber-dojo.sh does actual [volume create]\nend", "def create_snapshot(snapshot, description = nil)\n ensure_uri && ensure_client\n if snapshot.is_a?(OneviewSDK::Resource) || snapshot.is_a?(Hash)\n name = snapshot[:name] || snapshot['name']\n description ||= snapshot[:description] || snapshot['description']\n else\n name = snapshot\n end\n data = generate_snapshot_data(name, description)\n response = @client.rest_post(\"#{@data['uri']}/snapshots\", { 'body' => data }, @api_version)\n @client.response_handler(response)\n true\n end", "def create_lvm_volumes( opts = {} )\n opts = deep_merge_hashes( @aws_default_instance_options, opts )\n unless exist?( opts[ :lvm_volumes ].first[1] )\n create_lvm_volumes!( opts )\n end\n end", "def new\n @snapshot = current_account.snapshots.new\n @volumes = current_account.volumes\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @snapshot }\n end\n end", "def attach_volumes(node, disk_sizes)\n if $provider == :virtualbox\n node.vm.provider :virtualbox do |v, override|\n disk_num = 0\n disk_sizes.each do |disk_size|\n disk_num += 1\n diskname = File.join(File.dirname(File.expand_path(__FILE__)), \".virtualbox\", \"#{node.vm.hostname}-#{disk_num}.vdi\")\n unless File.exist?(diskname)\n v.customize ['createhd', '--filename', diskname, '--size', disk_size * 1024]\n end\n v.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', disk_num, '--device', 0, '--type', 'hdd', '--medium', diskname]\n end\n end\n end\n\n if $provider == :vmware_fusion\n node.vm.provider :vmware_fusion do |v, override|\n vdiskmanager = '/Applications/VMware\\ Fusion.app/Contents/Library/vmware-vdiskmanager'\n unless File.exist?(vdiskmanager)\n dir = File.join(File.dirname(File.expand_path(__FILE__)), \".vmware\")\n unless File.directory?( dir )\n Dir.mkdir dir\n end\n\n disk_num = 0\n disk_sizes.each do |disk_size|\n disk_num += 1\n diskname = File.join(dir, \"#{node.vm.hostname}-#{disk_num}.vmdk\")\n unless File.exist?(diskname)\n `#{vdiskmanager} -c -s #{disk_size}GB -a lsilogic -t 1 #{diskname}`\n end\n\n v.vmx[\"scsi0:#{disk_num}.filename\"] = diskname\n v.vmx[\"scsi0:#{disk_num}.present\"] = 'TRUE'\n v.vmx[\"scsi0:#{disk_num}.redo\"] = ''\n end\n end\n end\n end\n\n if $provider == :parallels\n node.vm.provider :parallels do |v, override|\n disk_sizes.each do |disk_size|\n v.customize ['set', :id, '--device-add', 'hdd', '--size', disk_size * 1024]\n end\n end\n end\n\nend", "def create_vapp_snapshot(vmId, description=\"New Snapshot\")\n create_snapshot_action(vmId, description, :vapp)\n end", "def attach_volume( options = {} )\n options = { :volume_id => '' }.merge(options)\n options = { :instance_id => '' }.merge(options)\n options = { :device => '' }.merge(options)\n raise ArgumentError, \"No :volume_id provided\" if options[:volume_id].nil? || options[:volume_id].empty?\n raise ArgumentError, \"No :instance_id provided\" if options[:instance_id].nil? || options[:instance_id].empty?\n raise ArgumentError, \"No :device provided\" if options[:device].nil? || options[:device].empty?\n\n params = {\n \"VolumeId\" => options[:volume_id],\n \"InstanceId\" => options[:instance_id],\n \"Device\" => options[:device]\n }\n return response_generator(:action => \"AttachVolume\", :params => params)\n end", "def new_snapshot!(time = Time.now)\n snapshot_path = time.strftime(dir.path + '/%Y-%m-%dT%H:%M%z')\n Snapshot.new(self, snapshot_path).create!(current.path)\n end", "def attach(instance_id, volume)# rubocop:disable Metrics/AbcSize\n inst_details = AttrFinder.new(@instanceparameters)\n @options[:inst] = volume\n inst_details.options = @options\n inst_details.validate = @validate\n inst_details.function = 'server'\n opts = {}\n BmcAuthenticate.new(@options)\n request = OracleBMC::Core::Models::AttachVolumeDetails.new\n request.instance_id = instance_id\n request.type = 'iscsi'\n request.volume_id = inst_details.volume\n api = OracleBMC::Core::ComputeClient.new\n response = api.attach_volume(request, opts)\n end", "def copy_snapshot(source_snapshot_id, source_region, target_region, name, description)\n ec2 = AWS::EC2.new(:region => target_region).client\n snap = ec2.copy_snapshot(:source_region => source_region, :source_snapshot_id => source_snapshot_id,\n :description => description)\n if snap\n #add expiry tag if snapshots_expire_in setting > 0. if 0 they never expire\n if SNAPSHOTS_EXPIRE_IN > 0\n ec2.create_tags(:resources => [snap.data[:snapshot_id]], :tags => [{:key => \"expiring\", :value =>\n (Time.now + SNAPSHOTS_EXPIRE_IN.to_i.days).to_s}, {:key => \"Name\", :value => name}])\n end\n return snap.data[:snapshot_id]\n end\n\n return \"\"\n end", "def create_disk(size, cloud_properties, instance_id = nil)\n raise ArgumentError, 'disk size needs to be an integer' unless size.kind_of?(Integer)\n with_thread_name(\"create_disk(#{size}, #{instance_id})\") do\n volume_properties = VolumeProperties.new(\n size: size,\n type: cloud_properties['type'],\n iops: cloud_properties['iops'],\n az: @az_selector.select_availability_zone(instance_id),\n encrypted: cloud_properties['encrypted'],\n kms_key_arn: cloud_properties['kms_key_arn']\n )\n\n resp = @ec2_client.client.create_volume(volume_properties.persistent_disk_config)\n volume = AWS::EC2::Volume.new_from(:create_volume, resp, resp.volume_id, config: @ec2_client.config)\n\n logger.info(\"Creating volume '#{volume.id}'\")\n ResourceWait.for_volume(volume: volume, state: :available)\n\n volume.id\n end\n end", "def create_disk(size, cloud_properties, instance_id = nil)\n raise ArgumentError, 'disk size needs to be an integer' unless size.kind_of?(Integer)\n with_thread_name(\"create_disk(#{size}, #{instance_id})\") do\n volume_properties = VolumeProperties.new(\n size: size,\n type: cloud_properties['type'],\n iops: cloud_properties['iops'],\n az: @az_selector.select_availability_zone(instance_id),\n encrypted: cloud_properties['encrypted'],\n kms_key_arn: cloud_properties['kms_key_arn']\n )\n\n volume_resp = @ec2_client.create_volume(volume_properties.persistent_disk_config)\n volume = Aws::EC2::Volume.new(\n id: volume_resp.volume_id,\n client: @ec2_client,\n )\n\n logger.info(\"Creating volume '#{volume.id}'\")\n ResourceWait.for_volume(volume: volume, state: 'available')\n\n volume.id\n end\n end", "def create_snapshot(vmId, description=\"New Snapshot\")\n @logger.warn 'DEPRECATION WARNING: use [create,revert]_vapp_snapshot instead.'\n create_snapshot_action(vmId, description, :vapp)\n end", "def attach(volume, device = '/dev/sdh')\n @ec2.attach_volume volume.id, id, device\n end", "def volume_by_id(ec2,volid)\n ec2.describe_volumes.body['volumeSet'].each do |volume|\n if volume['volumeId'] == volid\n x= {\n :type => volume['volumeType'],\n :status => volume['status'],\n :az => volume['availabilityZone'],\n :size => volume['size']\n }\n #puts \"VOLINFO #{volid}\\n\"+volume.to_yaml\n x[:instance_id] = volume['attachmentSet'].first['instanceId'] if volume['attachmentSet'].length>0 && volume['attachmentSet'].first.has_key?('instanceId')\n return x\n end\n end\n return {}\nend", "def create_empty_vhd_blob(storage_account_name, container_name, blob_name, blob_size_in_gb)\n @logger.info(\"create_empty_vhd_blob(#{storage_account_name}, #{container_name}, #{blob_name}, #{blob_size_in_gb})\")\n blob_created = false\n initialize_blob_client(storage_account_name) do\n begin\n @logger.info(\"create_empty_vhd_blob: Start to generate vhd footer\")\n opts = {\n :type => :fixed,\n :name => \"/tmp/footer.vhd\", # Only used to initialize Vhd, no local file is generated.\n :size => blob_size_in_gb\n }\n vhd_footer = Vhd::Library.new(opts).footer.values.join\n\n # Reference Virtual Hard Disk Image Format Specification\n # http://download.microsoft.com/download/f/f/e/ffef50a5-07dd-4cf8-aaa3-442c0673a029/Virtual%20Hard%20Disk%20Format%20Spec_10_18_06.doc\n vhd_size = blob_size_in_gb * 1024 * 1024 * 1024\n blob_size = vhd_size + 512\n options = {\n :timeout => TIMEOUT_FOR_BLOB_OPERATIONS\n }\n options = merge_storage_common_options(options)\n @logger.info(\"create_empty_vhd_blob: Calling create_page_blob(#{container_name}, #{blob_name}, #{blob_size}, #{options})\")\n @blob_service_client.create_page_blob(container_name, blob_name, blob_size, options)\n blob_created = true\n\n @logger.info(\"create_empty_vhd_blob: Start to upload vhd footer\")\n\n options = merge_storage_common_options(options)\n # Do not log vhd_footer because its size is 512 bytes.\n @logger.info(\"create_empty_vhd_blob: Calling put_blob_pages(#{container_name}, #{blob_name}, #{vhd_size}, #{blob_size - 1}, [VHD-FOOTER], #{options})\")\n @blob_service_client.put_blob_pages(container_name, blob_name, vhd_size, blob_size - 1, vhd_footer, options)\n rescue => e\n if blob_created\n options = merge_storage_common_options()\n @logger.info(\"create_empty_vhd_blob: Calling delete_blob(#{container_name}, #{blob_name}, #{options})\")\n @blob_service_client.delete_blob(container_name, blob_name, options)\n end\n cloud_error(\"create_empty_vhd_blob: Failed to create empty vhd blob: #{e.inspect}\\n#{e.backtrace.join(\"\\n\")}\")\n end\n end\n end", "def create_volume(volume_name, config:, **kwargs)\n object = { name: volume_name }.merge(config).merge(kwargs)\n log.info \"Creating volume: #{object}\"\n volumes << object\n end", "def make_backup\n @backup = editor.create_snapshot\n end", "def run\n program :name, 'aws-ebs-snap'\n program :version, '0.0.1'\n program :description, 'Creates a snapshot of your EBS volume via create-snapshot'\n\n command :ebslists do |c|\n c.syntax = 'aws-ebs-snap ebslists [options]'\n c.summary = ''\n c.description = ''\n c.example 'description', 'command example'\n c.option '--some-switch', 'Some switch that does something'\n c.action do |args, options|\n # Do something or c.when_called Aws-ebs-snap::Commands::Ebs-lists\n end\n end\n\n run!\n end", "def create_vbd(vm_ref, vdi_ref, position, boot = true)\n vbd_record = {\n 'VM' => vm_ref,\n 'VDI' => vdi_ref,\n 'empty' => false,\n 'other_config' => { 'owner' => '' },\n 'userdevice' => position.to_s,\n 'bootable' => boot,\n 'mode' => 'RW',\n 'qos_algorithm_type' => '',\n 'qos_algorithm_params' => {},\n 'qos_supported_algorithms' => [],\n 'type' => 'Disk'\n }\n\n task = xapi.Async.VBD.create(vbd_record)\n ui.msg 'Waiting for VBD create'\n vbd_ref = get_task_ref(task)\n vbd_ref\n end", "def add_volume(bucket,mount,options=nil)\n s3fs_volumes << { :bucket => bucket, :mount => mount, :options => options }\n end", "def create_snapshot_action(id, description=\"New Snapshot\", type=:vapp)\n params = {\n \"method\" => :post,\n \"command\" => \"/vApp/#{type}-#{id}/action/createSnapshot\"\n }\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.CreateSnapshotParams(\n \"xmlns\" => \"http://www.vmware.com/vcloud/v1.5\") {\n xml.Description description\n }\n end\n response, headers = send_request(params, builder.to_xml, \"application/vnd.vmware.vcloud.createSnapshotParams+xml\")\n task_id = headers[:location].gsub(/.*\\/task\\//, \"\")\n task_id\n end", "def create_snapshot_action(id, description=\"New Snapshot\", type=:vapp)\n params = {\n \"method\" => :post,\n \"command\" => \"/vApp/#{type}-#{id}/action/createSnapshot\"\n }\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.CreateSnapshotParams(\n \"xmlns\" => \"http://www.vmware.com/vcloud/v1.5\") {\n xml.Description description\n }\n end\n response, headers = send_request(params, builder.to_xml, \"application/vnd.vmware.vcloud.createSnapshotParams+xml\")\n task_id = headers[:location].gsub(/.*\\/task\\//, \"\")\n task_id\n end", "def create_empty_vhd_blob(storage_account_name, container_name, blob_name, blob_size_in_gb)\n @logger.info(\"create_empty_vhd_blob(#{storage_account_name}, #{container_name}, #{blob_name}, #{blob_size_in_gb})\")\n blob_created = false\n initialize_blob_client(storage_account_name) do\n begin\n @logger.info(\"create_empty_vhd_blob: Start to generate vhd footer\")\n opts = {\n :type => :fixed,\n :name => \"/tmp/footer.vhd\", # Only used to initialize Vhd, no local file is generated.\n :size => blob_size_in_gb\n }\n vhd_footer = Vhd::Library.new(opts).footer.values.join\n\n # Reference Virtual Hard Disk Image Format Specification\n # http://download.microsoft.com/download/f/f/e/ffef50a5-07dd-4cf8-aaa3-442c0673a029/Virtual%20Hard%20Disk%20Format%20Spec_10_18_06.doc\n vhd_size = blob_size_in_gb * 1024 * 1024 * 1024\n blob_size = vhd_size + 512\n options = {\n :timeout => 300 # seconds\n }\n @logger.info(\"create_empty_vhd_blob: Create empty vhd blob #{blob_name} with size #{blob_size}\")\n @blob_service_client.create_page_blob(container_name, blob_name, blob_size, options)\n blob_created = true\n\n @logger.info(\"create_empty_vhd_blob: Start to upload vhd footer\")\n\n @blob_service_client.create_blob_pages(container_name, blob_name, vhd_size, blob_size - 1, vhd_footer, options)\n rescue => e\n @blob_service_client.delete_blob(container_name, blob_name) if blob_created\n cloud_error(\"Failed to create empty vhd blob: #{e.inspect}\\n#{e.backtrace.join(\"\\n\")}\")\n end\n end\n end", "def create_snapshot(name)\n Fission::Action::Snapshot::Creator.new(self).create_snapshot(name)\n end", "def init_ebs_volumes\n @@client.describe_volumes.volumes\n end", "def gen_pv\n pv_name = \"pv-#{gen_uuid}\"\n file = \"#{$templates_path}/#{pv_name}.yaml\"\n File.open(file, 'w') do |f|\n f.puts <<-PV\nkind: PersistentVolume\napiVersion: v1\nmetadata:\n name: #{pv_name}\nspec:\n capacity:\n storage: 1Gi\n accessModes:\n - ReadWriteOnce\n nfs:\n path: \"/\"\n server: \"10.1.1.1\"\n persistentVolumeReclaimPolicy: \"Retain\"\nPV\n end\n\n `oc create -f #{file}`\nend", "def attach_storage_volume(volume_id, instance_id, device=nil)\n must_support! :storage_volumes\n result = connection.post(api_uri(\"/storage_volumes/#{volume_id}/attach\")) do |r|\n r.params = { :instance_id => instance_id, :device => device }\n end\n if result.status.is_ok?\n from_resource(:storage_volume, result)\n end\n end" ]
[ "0.74545485", "0.7209719", "0.71685785", "0.7164354", "0.714413", "0.712002", "0.6957206", "0.695592", "0.69027597", "0.6816179", "0.6758193", "0.6449254", "0.6442236", "0.64248896", "0.6421977", "0.6413579", "0.6410388", "0.6377427", "0.63687897", "0.6337966", "0.62960404", "0.6243", "0.62285584", "0.6219652", "0.61687523", "0.61277664", "0.6098769", "0.6053202", "0.6047047", "0.6040212", "0.6036591", "0.60013676", "0.60013676", "0.59793645", "0.59668255", "0.5965271", "0.5959788", "0.59518176", "0.59243673", "0.5911226", "0.5906665", "0.59002364", "0.5884665", "0.58808196", "0.588066", "0.5866205", "0.5849416", "0.5843164", "0.58383965", "0.5836565", "0.5822988", "0.58097076", "0.58096224", "0.5764269", "0.57455146", "0.5742586", "0.57332855", "0.5726907", "0.5716442", "0.5676405", "0.5664323", "0.5597754", "0.55964446", "0.55934834", "0.55855864", "0.55783844", "0.5552088", "0.5519139", "0.5503577", "0.5502014", "0.54925203", "0.5490401", "0.5488706", "0.54579026", "0.54509264", "0.54447114", "0.54331726", "0.54261166", "0.5416717", "0.5409531", "0.5395058", "0.5390986", "0.53814775", "0.5379415", "0.53665817", "0.53663564", "0.53652513", "0.5364546", "0.5361226", "0.53569835", "0.5355528", "0.53502977", "0.5340131", "0.5331774", "0.53273433", "0.53258723", "0.53236085", "0.5315382", "0.5298594", "0.5297501" ]
0.7775452
0
Delete a snapshot of an ebs volume Can accept a single snapshot or an array of snapshots to delete.
def deleteEBSSnapshot(client=nil,snapshots_to_delete=[],dry_run=true) return false if client.nil? unless snapshots_to_delete.instance_of? Array snapshots_to_delete = [snapshots_to_delete] end snapshots_to_delete.each do |snapshot| if dry_run printf "\e[33m\"Delete snapshot #{snapshot}?\" (y/n)? \e[0m" prompt = STDIN.gets.chomp next unless prompt == "y" end print "Deleting ec2 snapshot #{snapshot}..." begin # delete_snapshot API has no response client.delete_snapshot({ dry_run: dry_run, snapshot_id: snapshot }) puts "\e[32msuccess\e[0m" rescue Exception => e puts "\e[31mfailed - #{e.message}\e[0m" end end return true end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def snap_delete(volume,snapshot)\n output = @filer.invoke(\"snapshot-delete\",\"volume\",volume,\"snapshot\",snapshot)\n if (output.results_status() == \"failed\")\n raise \"Error #{output.results_errno} deleting snapshot #{snapshot} on #{volume}: #{output.results_reason()}\\n\"\n end\n end", "def snap_delete(volume,snapshot)\n output = @filer.invoke(\"snapshot-create\",\"volume\",volume,\"snapshot\",snapshot)\n if (output.results_status() == \"failed\")\n raise \"Error #{output.results_errno} creating snapshot #{snapshot} on #{volume}: #{output.results_reason()}\\n\"\n end\n end", "def delete_snapshot(snapshot_name)\n execute(:delete_snapshot, VmID: vm_id, SnapName: snapshot_name)\n end", "def delete_snapshot snapshot\n subscriber.delete_snapshot snapshot: snapshot_path(snapshot)\n end", "def delete(params = {})\n response = client.delete \"/_snapshot/{repository}/{snapshot}\", update_params(params, action: \"snapshot.delete\", rest_api: \"snapshot.delete\")\n response.body\n end", "def delete_snapshot(snapshot_id)\n end", "def delete_snapshot(snapshot_id)\n raise Bosh::Clouds::NotSupported.new(false),\n 'delete_snapshot is not supported.'\n end", "def delete! snaps\n if snaps.count > 0\n VfSnapshots.verbose \"\\n#{snaps.count} to delete, here we go.\"\n else\n VfSnapshots.verbose \"\\nNothing to delete.\"\n end\n begin\n snaps.each_with_index do |snapshot,idx|\n VfSnapshots.verbose \"[#{idx+1} of #{snaps.length}] Deleting #{account.name} #{snapshot.description}\"\n snapshot.delete\n # puts \"Sleeping...\"\n # sleep 1\n # puts \"Woke!\"\n end\n rescue Aws::EC2::Errors::ResourceLimitExceeded\n VfSnapshots.verbose \"\\nThrottled!\"\n exit\n end\n end", "def delete_snapshot(snapshot_id)\n with_thread_name(\"delete_snapshot(#{snapshot_id})\") do\n snapshot = @ec2_resource.snapshot(snapshot_id)\n begin\n snapshot.delete\n rescue Aws::EC2::Errors::InvalidSnapshotNotFound => e\n logger.info(\"snapshot '#{snapshot_id}' not found\")\n end\n logger.info(\"snapshot '#{snapshot_id}' deleted\")\n end\n end", "def delete_snapshot(uuid, snapshot_id)\n # Sometimes this command fails with 'Data synchronization is currently\n # in progress'. Just wait and retry.\n retryable(on: VagrantPlugins::Parallels::Errors::ExecutionError, tries: 2, sleep: 2) do\n execute_prlctl('snapshot-delete', uuid, '--id', snapshot_id)\n end\n end", "def delete_snapshot(snapshot_id)\n with_thread_name(\"delete_snapshot(#{snapshot_id})\") do\n snapshot = @ec2_resource.snapshot(snapshot_id)\n snapshot.delete\n logger.info(\"snapshot '#{snapshot_id}' deleted\")\n end\n end", "def delete_snapshot(snapshot_id)\n log \"\\e[0;31m:: Deleting snapshot:\\e[0m #{snapshot_id}\"\n\n begin\n ec2.delete_snapshot(snapshot_id)\n sleep 0.2\n rescue Fog::Compute::AWS::NotFound\n log \"Failed to delete snapshot: #{snapshot_id}; setting { 'protected' => true }\"\n ec2.tags.create({resource_id: snapshot_id, key: 'protected', value: 'true'})\n rescue Fog::Compute::AWS::Error\n log \"API Error\"\n end\n\n end", "def delete_snapshot(snapshot_id)\n with_thread_name(\"delete_snapshot(#{snapshot_id})\") do\n snapshot = @ec2_client.snapshots[snapshot_id]\n\n if snapshot.status == :in_use\n raise Bosh::Clouds::CloudError, \"snapshot '#{snapshot.id}' can not be deleted as it is in use\"\n end\n\n snapshot.delete\n logger.info(\"snapshot '#{snapshot_id}' deleted\")\n end\n end", "def delete_snapshot(snapshot_id)\n link = generate_request(\"DeleteSnapshot\",\n \"SnapshotId\" => snapshot_id.to_s)\n request_info(link, RightBoolResponseParser.new(:logger => @logger))\n rescue Exception\n on_exception\n end", "def delete_snapshot(name)\n result = get_snapshot(name)\n response = @client.rest_delete(result['uri'], { 'If-Match' => result['eTag'] }, @api_version)\n @client.response_handler(response)\n true\n end", "def delete_snapshot(vm, name)\n snapshot = enumerate_snapshots(vm).find { |s| s.name == name }\n\n # No snapshot matching \"name\"\n return nil if snapshot.nil?\n\n task = snapshot.snapshot.RemoveSnapshot_Task(removeChildren: false)\n\n if block_given?\n task.wait_for_progress do |progress|\n yield progress unless progress.nil?\n end\n else\n task.wait_for_completion\n end\n end", "def delete_snapshot(name)\n Fission::Action::Snapshot::Deleter.new(self).delete_snapshot(name)\n end", "def delete_snapshot(snapshot_cid)\n @telemetry_manager.monitor('initialize') do\n _init_azure\n end\n with_thread_name(\"delete_snapshot(#{snapshot_cid})\") do\n @telemetry_manager.monitor('delete_snapshot', id: snapshot_cid) do\n snapshot_id = DiskId.parse(snapshot_cid, _azure_config.resource_group_name)\n snapshot_name = snapshot_id.disk_name\n if snapshot_name.start_with?(MANAGED_DATA_DISK_PREFIX)\n @disk_manager2.delete_snapshot(snapshot_id)\n else\n @disk_manager.delete_snapshot(snapshot_id)\n end\n @logger.info(\"The snapshot '#{snapshot_id}' is deleted\")\n end\n end\n end", "def delete_snapshot(key)\n\n raise ArgumentError.new('key must be an String') unless( key.is_a?(String) )\n\n endpoint = format( '/api/snapshots-delete/%s', key)\n @logger.debug(\"Deleting snapshot id #{key} (GET #{endpoint})\") if @debug\n\n delete(endpoint)\n end", "def process_cloud_volume_snapshots(snapshots, task)\n return if snapshots.empty?\n\n if task == \"destroy\"\n snapshots.each do |snapshot|\n audit = {\n :event => \"cloud_volume_snapshot_record_delete_initiateed\",\n :message => \"[#{snapshot.name}] Record delete initiated\",\n :target_id => snapshot.id,\n :target_class => \"CloudVolumeSnapshot\",\n :userid => session[:userid]\n }\n AuditEvent.success(audit)\n snapshot.delete_snapshot_queue(session[:userid])\n end\n add_flash(n_(\"Delete initiated for %{number} Cloud Volume Snapshot.\",\n \"Delete initiated for %{number} Cloud Volume Snapshots.\",\n snapshots.length) % {:number => snapshots.length})\n end\n end", "def process_cloud_volume_snapshots(snapshots, task)\n return if snapshots.empty?\n\n if task == \"destroy\"\n snapshots.each do |snapshot|\n audit = {\n :event => \"cloud_volume_snapshot_record_delete_initiateed\",\n :message => \"[#{snapshot.name}] Record delete initiated\",\n :target_id => snapshot.id,\n :target_class => \"CloudVolumeSnapshot\",\n :userid => session[:userid]\n }\n AuditEvent.success(audit)\n snapshot.delete_snapshot_queue(session[:userid])\n end\n add_flash(n_(\"Delete initiated for %{number} Cloud Volume Snapshot.\",\n \"Delete initiated for %{number} Cloud Volume Snapshots.\",\n snapshots.length) % {:number => snapshots.length})\n end\n end", "def delete_db_snapshot(group_name)\n \n request({\n 'Action' => 'DeleteDBSnapshot',\n 'DBSnapshotIdentifier' => group_name,\n \n :parser => Fog::Parsers::AWS::RDS::DeleteDBSnapshot.new\n })\n end", "def delete_blob(container, blob, options={})\n query = { }\n query['snapshot'] = options[:snapshot] if options[:snapshot]\n query['timeout'] = options[:timeout].to_s if options[:timeout]\n\n uri = blob_uri(container, blob, query)\n\n options[:delete_snapshots] = :include unless options[:delete_snapshots]\n\n headers = service_properties_headers\n headers['x-ms-delete-snapshots'] = options[:delete_snapshots].to_s if options[:delete_snapshots] && options[:snapshot] == nil\n\n call(:delete, uri, nil, headers)\n nil\n end", "def delete\n @service.delete_snapshot(self)\n end", "def delete_fusion_vm_snapshot(options)\n clone_list = []\n if options['clone'].to_s.match(/\\*/) or options['clone'].to_s.match(/all/)\n clone_list = get_fusion_vm_snapshots(options)\n clone_list = clone_list.split(\"\\n\")[1..-1]\n else\n clone_list[0] = options['clone']\n end\n clone_list.each do |clone|\n fusion_vmx_file = get_fusion_vm_vmx_file(options)\n message = \"Information:\\tDeleting snapshot \"+clone+\" for #{options['vmapp']} VM \"+options['name']\n command = \"'#{options['vmrun']}' -T fusion deleteSnapshot '#{fusion_vmx_file}' '#{clone}'\"\n execute_command(options,message,command)\n end\n return\nend", "def delete_blob(container, blob, options={})\n query = { }\n StorageService.with_query query, 'snapshot', options[:snapshot]\n StorageService.with_query query, 'timeout', options[:timeout].to_s if options[:timeout]\n\n uri = blob_uri(container, blob, query)\n\n options[:delete_snapshots] = :include unless options[:delete_snapshots]\n\n headers = StorageService.common_headers\n StorageService.with_header headers, 'x-ms-delete-snapshots', options[:delete_snapshots].to_s if options[:delete_snapshots] && options[:snapshot] == nil\n add_blob_conditional_headers options, headers\n\n call(:delete, uri, nil, headers, options)\n nil\n end", "def delete_db_snapshot( options = {} )\n raise ArgumentError, \"No :db_snapshot_identifier provided\" if options.does_not_have?(:db_snapshot_identifier)\n\n params = {}\n params['DBSnapshotIdentifier'] = options[:db_snapshot_identifier]\n\n return response_generator(:action => \"DeleteDBSnapshot\", :params => params)\n end", "def destroy\n @snapshot.destroy\n\n respond_to do |format|\n format.html { redirect_to(snapshots_url) }\n format.xml { head :ok }\n end\n end", "def purgeOldSnapshots(profile,region)\n json = `aws --profile #{profile} --region #{region} ec2 describe-snapshots --owner-ids self`\n parsed = JSON.parse(json)\n parsed[\"Snapshots\"].each do |snapshot|\n desc = snapshot[\"Description\"]\n snapid = snapshot[\"SnapshotId\"]\n if desc.to_s.match('deleteafter')\n deletedate = desc.to_s.split('-deleteafter').last\n vol = desc.to_s.split('-deleteafter').first\n if Date.strptime(deletedate, \"%Y-%m-%d\") < Date.today\n puts \"Deleting #{snapid} for volume #{vol}- Due date: #{deletedate}\"\n `aws --profile #{profile} --region #{region} ec2 delete-snapshot --snapshot-id #{snapid}`\n end\n end\n end\nend", "def delete\n ensure_service!\n service.delete_snapshot name\n true\n end", "def delete_db_instance(identifier, snapshot_identifier, skip_snapshot = false) \n params = {}\n params['FinalDBSnapshotIdentifier'] = snapshot_identifier if snapshot_identifier\n request({\n 'Action' => 'DeleteDBInstance',\n 'DBInstanceIdentifier' => identifier,\n 'SkipFinalSnapshot' => skip_snapshot, \n :parser => Fog::Parsers::AWS::RDS::DeleteDBInstance.new\n }.merge(params))\n end", "def delete\n response = client[\"/vaults/#{vault_id}/blobs/#{blob_id}\"].delete\n response.code == 200\n end", "def user_deleted_snapshot _user, snapshot\n data = {\n category: 'Snapshots',\n action: 'Deleted a Snapshot',\n label: snapshot.name,\n value: nil,\n bounce: false,\n }\n\n create_event data\n end", "def deletevolume\n if not checkRequirements([\"thezone\",\"thevolume\"])\n return false\n end\n checkToken(@thezone)\n submit = queryGCE(:path => '/compute/v1beta15/projects/#{@thezone.name}/zones/#{@thevolume.azone.name}/disks/#{@thevolume.serial}', :method => 'delete', :options => '', :access_token => @thezone.token )\n checkQuery(:type => 'zone', :token => @thezone.token, :projectname => @thezone.name, :zonename => @thevolume.azone.name, :operationname => submit[\"name\"])\n end", "def delete_db_instance(identifier, snapshot_identifier, skip_snapshot = false)\n params = {}\n params['FinalDBSnapshotIdentifier'] = snapshot_identifier if snapshot_identifier\n request({\n 'Action' => 'DeleteDBInstance',\n 'DBInstanceIdentifier' => identifier,\n 'SkipFinalSnapshot' => skip_snapshot,\n :parser => Fog::Parsers::AWS::RDS::DeleteDBInstance.new\n }.merge(params))\n end", "def delete_snapshot request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_snapshot_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def delete_volume_snapshot_post(delete_volume_snapshot_param, opts = {})\n data, _status_code, _headers = delete_volume_snapshot_post_with_http_info(delete_volume_snapshot_param, opts)\n return data\n end", "def destroy!\n destroy_storage_snapshot(_id)\n end", "def delete(volume)\n dest_path = dest_path_resolver.path(volume)\n removed = fs.remove(dest_path)\n log(volume, removed ? \"removed\" : \"not present\")\n fs.rm_empty_tree(dest_path.parent)\n end", "def delete_all_snapshot(regex)\n @admin.deleteSnapshots(Pattern.compile(regex)).to_a\n end", "def delete_blob(container, blob, key = nil, options = {})\n key ||= properties.key1\n\n url = File.join(properties.primary_endpoints.blob, container, blob)\n url += \"?snapshot=\" + options[:date] if options[:date]\n\n headers = build_headers(url, key, :blob, :verb => 'DELETE')\n\n response = ArmrestService.send(\n :rest_delete,\n :url => url,\n :headers => headers,\n :proxy => proxy,\n :ssl_version => ssl_version,\n :ssl_verify => ssl_verify\n )\n\n headers = Azure::Armrest::ResponseHeaders.new(response.headers)\n headers.response_code = response.code\n\n headers\n end", "def delete_volume_snapshot_post_with_http_info(delete_volume_snapshot_param, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SnapshotApi.delete_volume_snapshot_post ...\"\n end\n # verify the required parameter 'delete_volume_snapshot_param' is set\n if @api_client.config.client_side_validation && delete_volume_snapshot_param.nil?\n fail ArgumentError, \"Missing the required parameter 'delete_volume_snapshot_param' when calling SnapshotApi.delete_volume_snapshot_post\"\n end\n # resource path\n local_var_path = \"/deleteVolumeSnapshot\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(delete_volume_snapshot_param)\n auth_names = ['basicAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'SnapShotDeletionStatus')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SnapshotApi#delete_volume_snapshot_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def delete_table_snapshots(tableNameRegex, snapshotNameRegex = '.*')\n @admin.deleteTableSnapshots(Pattern.compile(tableNameRegex),\n Pattern.compile(snapshotNameRegex)).to_a\n end", "def destroy\n @snap = Snap.find(params[:id])\n @snap.destroy\n\n respond_to do |format|\n format.html { redirect_to(snaps_url) }\n format.xml { head :ok }\n end\n end", "def delete_volume_snapshot_with_http_info(volume_id, id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VolumesApi.delete_volume_snapshot ...'\n end\n # verify the required parameter 'volume_id' is set\n if @api_client.config.client_side_validation && volume_id.nil?\n fail ArgumentError, \"Missing the required parameter 'volume_id' when calling VolumesApi.delete_volume_snapshot\"\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling VolumesApi.delete_volume_snapshot\"\n end\n # resource path\n local_var_path = '/storage/{volume_id}/snapshots/{id}'.sub('{' + 'volume_id' + '}', CGI.escape(volume_id.to_s)).sub('{' + 'id' + '}', CGI.escape(id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type]\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['x_auth_token']\n\n new_options = opts.merge(\n :operation => :\"VolumesApi.delete_volume_snapshot\",\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(:DELETE, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VolumesApi#delete_volume_snapshot\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def destroy\n ret = qmgmt(['volume', 'delete', resource[:name]])\n out = Array.new\n ret.each_line { |l|\n out.push(' ' + l)\n }\n if ( ret.exitstatus != 0 )\n fail(\"quobyte volume delete #{resource[:name]} failed with status #{ret.exitstatus.to_s}. Output follows.\" + out.join(\"\\n\"))\n end\n end", "def delete_volume_snapshot(volume_id, id, opts = {})\n delete_volume_snapshot_with_http_info(volume_id, id, opts)\n nil\n end", "def destroy_zero_sized_snapshots(snapshots)\n ### Shift off the last, so it maintains the changes\n saved_snapshot = snapshots.shift(1)\n remaining_snapshots = [saved_snapshot]\n snapshots.each do |snapshot|\n if snapshot.is_zero?\n puts \"Destroying zero-sized snapshot: #{snapshot.name}\" if $verbose\n snapshot.destroy\n else\n remaining_snapshots << snapshot\n end\n end\n remaining_snapshots\nend", "def delete_db_instance(db_instance_identifier, db_snapshot_identifier = nil)\n unless does_db_exist?(db_instance_identifier)\n raise Aws::RDS::Errors::DBInstanceNotFound.new(\n db_instance_identifier,\n ''\n )\n end\n\n if db_snapshot_identifier.nil?\n @rds.delete_db_instance(db_instance_identifier: db_instance_identifier, skip_final_snapshot: true)\n else\n @rds.delete_db_instance(db_instance_identifier: db_instance_identifier,\n final_db_snapshot_identifier: db_snapshot_identifier)\n end\n\n @rds.wait_until(:db_instance_deleted, db_instance_identifier: db_instance_identifier)\n end", "def destroy\n @inventory_snapshot_content.destroy\n respond_to do |format|\n format.html { redirect_to inventory_snapshot_contents_url, notice: 'Inventory snapshot content was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def check_snapshot(vmname, node)\n if node.name =~ /^prekernel/\n compare_time = Time.now - CLEAN_AFTER_DAYS * 24 * 60 * 60\n if compare_time > node.createTime\n puts 'Deleting snapshot for ' + vmname + ' | ' + node.name + ' | ' + node.createTime.iso8601\n\n snapshot_task = node.snapshot.RemoveSnapshot_Task(removeChildren: false)\n snapshot_task = snapshot_task.wait_for_completion\n end\n end\n\n unless node.childSnapshotList.empty?\n node.childSnapshotList.each { |item| check_snapshot(vmname, item) }\n end\nend", "def delete_volume( options = {} )\n options = { :volume_id => '' }.merge(options)\n raise ArgumentError, \"No :volume_id provided\" if options[:volume_id].nil? || options[:volume_id].empty?\n params = {\n \"VolumeId\" => options[:volume_id]\n }\n return response_generator(:action => \"DeleteVolume\", :params => params)\n end", "def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend", "def detachvol(compute,volume)\n\t\tprint \"ebsvol[aws]->destroy: detaching #{volume['volumeId']} from #{volume['attachmentSet'][0]['instanceId']}\\n\" if $debug\n\t\tresponse = compute.detach_volume(volume['volumeId'], \n\t\t\t\t\t\t\t\t\t\t\t\t\t{ 'Device' => volume['attachmentSet'][0]['device'], \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Force' => true, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'InstanceId' => volume['attachmentSet'][0]['instanceId'] })\n\t\tif (response.status == 200)\n\t\t\t# now wait for it to detach!\n\t\t\tcheck = volinfo(compute,volume['tagSet']['Name'])\n\t\t\twhile ( check['status'] != 'available' ) do\n\t\t\t\tprint \"ebsvol[aws]->detachvol: status is #{check['status']}\\n\" if $debug\n\t\t\t\tsleep 5\n\t\t\t\tcheck = volinfo(compute,volume['tagSet']['Name'])\n\t\t\tend\n\t\t\tsleep 5 # allow aws to propigate the fact\n\t\t\tprint \"ebsvol[aws]->detachvol: volume is now detached\\n\" if $debug\n\t\telse\n\t\t\traise \"ebsvol[aws]->detachvol: Sorry, I could not detach #{volume['volumeId']} from #{volume['attachmentSet'][0]['instanceId']}\"\n\t\tend\n\tend", "def delete_errant_volumes(volumes)\n volumes_literal = \"\\\"#{volumes.keys.join('\",\"')}\\\"\"\n command = \"delete from results where volume_id not in (#{volumes_literal});\"\n puts \"Executing: #{command}\"\n @db.execute(command)\n end", "def destroy_volume(id, volume_id=nil, params={}, payload={})\n url = nil\n if volume_id.is_a?(Array)\n url = \"#{base_path}/#{id}/volumes\"\n params['volumeId'] = volume_id\n elsif volume_id.is_a?(Numeric) || volume_id.is_a?(String)\n url = \"#{base_path}/#{id}/volumes/#{volume_id}\"\n else\n raise \"passed a bad volume_id: #{volume_id || '(none)'}\" # lazy\n end\n headers = { :params => params, :authorization => \"Bearer #{@access_token}\", 'Content-Type' => 'application/json' }\n execute(method: :delete, url: url, headers: headers, payload: payload.to_json)\n end", "def remove_photos(db, selected)\n\n photos = selected.split(\",\")\n\n photos.each do |photo|\n delete_s3_file(photo)\n delete_db_record(db, photo)\n end\n\nend", "def destroy\n @volume.destroy\n respond_to do |format|\n format.html { redirect_to volumes_url }\n format.json { head :no_content }\n end\n end", "def detach_volume(id, attachment)\n return delete_request(address(\"/servers/\"+id+\"/os-volume_attachments/\"+volume), @token)\n end", "def delete_share_snapshot_post(delete_share_snapshot_param, opts = {})\n data, _status_code, _headers = delete_share_snapshot_post_with_http_info(delete_share_snapshot_param, opts)\n return data\n end", "def delete_db_record(db, photo)\n\n begin\n\n query = \"delete from imageuploader where photo = $1\"\n db.prepare('q_statement', query)\n rs = db.exec_prepared('q_statement', [photo])\n db.exec(\"deallocate q_statement\")\n\n rescue PG::Error => e\n\n puts 'Exception occurred'\n puts e.message\n\n end\n\nend", "def delete_db_cluster(identifier, snapshot_identifier, skip_snapshot = false)\n params = {}\n params[\"FinalDBSnapshotIdentifier\"] = snapshot_identifier if snapshot_identifier\n request({\n 'Action' => 'DeleteDBCluster',\n 'DBClusterIdentifier' => identifier,\n 'SkipFinalSnapshot' => skip_snapshot,\n }.merge(params))\n end", "def batch_delete(uuids)\n body = uuids.to_json\n request_delete(uri: '/files/storage/', content: body)\n end", "def delete(*args)\n execute(:delete, *args)\n end", "def terminate_volume\n device = get_device_mount_point(self.MountPoint)\n STDERR.puts \"EBS device detected: #{device}...umounting it...\"\n umount_dir(self.MountPoint)\n #detache the mounted volume\n STDERR.puts \"Detaching current EBS volume:\"\n detached_vol=detach_volume(device)\n STDERR.puts \"detachment started (#{detached_vol.inspect})\"\n# this is necessary, for delete to succeed. however it may be too long of a wait time for decom\n wait_for_detachment(device, 60)\n delete_volume(detached_vol['aws_id'])\n detached_vol['aws_id']\n rescue => e\n display_exception(e, \"terminate_volume\")\n end", "def delete_volume(volume_id)\n data = false\n conn = @ec2_main.environment.volume_connection\n if conn != nil\n if @ec2_main.settings.openstack\n response = conn.delete_volume(volume_id)\n if response.status == 202\n data = response.body\n else\n data = {}\n end\n elsif ((conn.class).to_s).start_with? \"Fog::Compute::AWS\"\n response = conn.delete_volume(volume_id)\n if response.status == 200\n data = true\n else\n data = false\n end\n else\n data = conn.delete_volume(volume_id)\n end\n else\n raise \"Connection Error\"\n end\n return data\n end", "def delete_consistency_group_snapshot_view(sys_id, cg_id, view_id)\n\t response = request(:delete, \"/devmgr/v2/storage-systems/#{sys_id}/consistency-groups/#{cg_id}/views/#{view_id}\")\n status(response, 204, 'Failed to remove consistency group snapshot view')\n end", "def restore_from_snap(last_snapshot, options = {})\n options[:device] = \"/dev/sdk\" unless options[:device]\n options[:vol_nickname] = last_snapshot[\"nickname\"] unless options[:vol_nickname]\n \n # 5 - Unmount and detach the current EBS volume (forcing to detach the device we're gonna need later for attching ours...)\n umount_and_detach_device({:device => options[:device]})\n # 6- Create the volume from the latest snapshot, attach it to the instance and then mount it\n STDERR.puts \"Creating new DB volume from snapshot #{last_snapshot['aws_id']}\"\n vol = ( options[:new_size_gb] ? create_volume_from_snap_size_gb(last_snapshot[\"aws_id\"],options[:vol_nickname],options[:new_size_gb] ) : create_volume_from_snap(last_snapshot[\"aws_id\"],options[:vol_nickname] ) )\n unless vol.nil?\n \tSTDERR.puts \"Attaching new DB volume: #{vol['aws_id']}\"\n \tatt = attach_volume(vol['aws_id'], options[:device])\n \twait_for_attachment(options[:device])\n \tFileUtils.mkdir_p self.MountPoint\n \tres = `mount -t xfs -o noatime #{options[:device]} #{self.MountPoint}`\n \traise EBSRemoteExecException.new(nil,$?,\"Error mounting newly created volume (#{vol['aws_id']}) on #{options[:device]}:\\n\"+res) if $? != 0 \n else\n\t raise \"create volume failed from snapshot\"\n end\n end", "def cleanup_storage vm\n vm.volumes.each do |vol|\n @logger.debug \"Deleting volume #{vol.name} for OpenStack host #{vm.name}\"\n vm.detach_volume(vol.id)\n vol.wait_for { ready? }\n vol.destroy\n end\n end", "def delete_volume request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_volume_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def delete_storage(storage_uuid)\n response = delete \"storage/#{storage_uuid}\"\n\n response\n end", "def delete_storage(storage_uuid)\n response = delete \"storage/#{storage_uuid}\"\n\n response\n end", "def delete_expired_snapshots(region = AWSCONFIG[:default_region])\n #find snapshots with tags of expiring and less than today's date\n ec2 = AWS::EC2.new(:region => region).client\n snapshots = ec2.describe_snapshots(:owner_ids => [\"self\"], :filters => [:name => 'tag-key', :values => ['expiring']])\n deleted_snapshots = []\n\n #loop thru to see if they are in the past\n if snapshots\n snapshots.data[:snapshot_set].each do |s|\n expdate = get_tagvalue(s, \"expiring\")\n if expdate.length > 0\n begin\n expdate = Time.parse(expdate)\n if expdate < Time.now\n #expired in the past so delete\n deleted_snapshots << s\n ec2.delete_snapshot(:snapshot_id => s[:snapshot_id])\n end\n rescue => e\n #error parsing - do something or nothing\n end\n end\n end\n end\n\n return deleted_snapshots\n end", "def destroy\n @lab_book_snapshot = Embeddable::LabBookSnapshot.find(params[:id])\n respond_to do |format|\n format.html { redirect_to(lab_book_snapshots_url) }\n format.xml { head :ok }\n format.js\n end\n\n # TODO: We should move this logic into the model!\n @lab_book_snapshot.page_elements.each do |pe|\n pe.destroy\n end\n @lab_book_snapshot.destroy\n end", "def delete_volume(vol_id,wait=true)\n params = {:aws_id => vol_id,:api_version => 1.0}\n success=false\n 20.times do |i| \n begin\n STDERR.puts \"Making RightScale API call to delete EBS volume\"\n #STDERR.puts \"HERE IS THE URL: #{@api_url}/delete_ebs_volume.js (PARAMS: #{requestify(params)})\"\n body = RestClient.delete @api_url+\"/delete_ebs_volume.js\"+\"?\"+requestify(params)\n success=true\n #json = JSON.load(body)\n STDERR.puts \"Deleted VOLUME: #{vol_id}\"\n break\n rescue Exception => e\n display_exception(e, \"delete_volume(#{vol_id}, #{wait})\")\n sleep 5\n end\n end\n raise \"Couldn't delete volume #{vol_id}...aborting.\" unless success\n end", "def createEBSSnapshot(client=nil,description='',volume_id=nil)\n return false if volume_id.nil? || client.nil?\n # Fetch the Volume Name. This will be used in the description of the snapshot\n resp = client.describe_volumes({dry_run: false, volume_ids: [volume_id] })\n resp.volumes[0].tags.each do |t|\n if t.key=='Name'\n description = t.value unless t.value.empty?\n break\n end\n end\n # puts \"Taking snapshot of volume #{volume_id}...\"\n return client.create_snapshot({\n dry_run: false,\n volume_id: volume_id,\n description: description\n })\nend", "def destroy_storage_volume(volume_id)\n destroy_resource :storage_volume, volume_id\n end", "def delete_storage(request, params)\n # --- Get the Image ---\n image = ImageOCCI.new(\n Image.build_xml(params[:id]),\n @client)\n\n # --- Delete the Image ---\n rc = image.delete\n if OpenNebula.is_error?(rc)\n return rc, CloudServer::HTTP_ERROR_CODE[rc.errno]\n end\n\n return \"\", 204\n end", "def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end", "def delete_volume(volume_id)\n link = generate_request(\"DeleteVolume\",\n \"VolumeId\" => volume_id.to_s)\n request_info(link, RightBoolResponseParser.new(:logger => @logger))\n rescue Exception\n on_exception\n end", "def revert_snapshot(snap_id)\n snapshot_list = self['snapshot.rootSnapshotList']\n snapshot = find_snapshot_in_list(snapshot_list, snap_id)\n\n return unless snapshot\n\n begin\n revert_snapshot_hash = { :_this => snapshot }\n snapshot\n .RevertToSnapshot_Task(\n revert_snapshot_hash\n ).wait_for_completion\n rescue StandardError => e\n error = \"Cannot revert snapshot of VM: #{e.message}.\"\n\n if VCenterDriver::CONFIG[:debug_information]\n error += \"\\n\\n#{e.backtrace.join(\"\\n\")}\"\n end\n\n raise error\n end\n end", "def off\n attachment = hpg_resolve(shift_argument)\n return unless confirm_command(attachment.config_var, 'Deactiving will destroy all backups')\n action(\"Dectivating #{attachment.config_var} (#{attachment.resource_name})\") do\n RestClient.delete( authed_pgsnapshot_url(\"/client/resource/#{attachment.resource_name}\"))\n end\n end", "def detach()\n $ec2.describe_volumes([self.id]).each do |result|\n if result[:aws_attachment_status] == 'attached'\n $ec2.detach_volume(self.id)\n end\n end\n self.attached_instance = nil\n self.save()\n end", "def destroy\n @sm_volume = SmVolume.find(params[:id])\n @sm_volume.destroy\n\n respond_to do |format|\n format.html { redirect_to sm_volumes_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @volume.destroy\n respond_to do |format|\n format.html { redirect_to volumes_url, notice: 'Volume was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete_share_snapshot_post_with_http_info(delete_share_snapshot_param, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SnapshotApi.delete_share_snapshot_post ...\"\n end\n # verify the required parameter 'delete_share_snapshot_param' is set\n if @api_client.config.client_side_validation && delete_share_snapshot_param.nil?\n fail ArgumentError, \"Missing the required parameter 'delete_share_snapshot_param' when calling SnapshotApi.delete_share_snapshot_post\"\n end\n # resource path\n local_var_path = \"/deleteShareSnapshot\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(delete_share_snapshot_param)\n auth_names = ['basicAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'SnapShotDeletionStatus')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SnapshotApi#delete_share_snapshot_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def delete_bundle(bundle)\n args = [\"bundle=#{u(bundle)}\"]\n get('tags/bundles/delete?' << args.join('&amp;'))\n nil\n end", "def delete(*arguments, &block)\n objects = q(*arguments, &block).map { |o| o.removed_from_bibliography(self) }\n @data = @data - objects\n objects.length == 1 ? objects[0] : objects\n end", "def delete\n @service.delete_blob(self)\n end", "def destroy\n @volume = Volume.find(params[:id])\n @volume.destroy\n\n respond_to do |format|\n format.html { redirect_to(volumes_url) }\n format.xml { head :ok }\n end\n end", "def delete_db_instance( options = {} )\n raise ArgumentError, \"No :db_instance_identifier provided\" if options.does_not_have?(:db_instance_identifier)\n\n params = {}\n params['DBInstanceIdentifier'] = options[:db_instance_identifier]\n\n params[\"SkipFinalSnapshot\"] = options[:skip_final_snapshot].to_s if options.has?(:skip_final_snapshot)\n params[\"FinalDBSnapshotIdentifier\"] = options[:final_db_snapshot_identifier].to_s if options.has?(:final_db_snapshot_identifier)\n\n return response_generator(:action => \"DeleteDBInstance\", :params => params)\n end", "def destroy\n @snap.update(viewed: true)\n end", "def destroy\n @photo = Photo.find(params[:id])\n\n # Destroy s3 objects\n aws_s3_delete(@photo.key)\n Sebitmin::Application.config.thumbnail_sizes.each do |thumbnail_size|\n aws_s3_delete(@photo[\"thumbnail_key_#{thumbnail_size}\"])\n end\n\n @photo.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @event.bundles.delete(@bundle)\n redirect_to :back\n end", "def usage\n \"store delete_vol SHARE_NAME\"\n end", "def delete_volume_snapshot_policy_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VolumesApi.delete_volume_snapshot_policy ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling VolumesApi.delete_volume_snapshot_policy\"\n end\n # resource path\n local_var_path = '/storage/snapshot-policies/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type]\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['x_auth_token']\n\n new_options = opts.merge(\n :operation => :\"VolumesApi.delete_volume_snapshot_policy\",\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(:DELETE, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VolumesApi#delete_volume_snapshot_policy\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def delete(*args)\n commit(\"delete\", *args)\n end", "def delete_metadata(key_name)\n requires :id\n service.delete_snapshot_metadata(id, key_name)\n true\n end", "def delete # rubocop:disable Metrics/AbcSize\n attrcheck = { 'container name' => @options[:container] }\n @validate.attrvalidate(@options, attrcheck)\n containerview = ObjectStorage.new(@options[:id_domain], @options[:user_name], @options[:passwd])\n if @options[:recurse]\n contents = containerview.contents(@options[:container])\n container_contents = contents.body.split(/\\n/)\n container_contents.each do |content|\n containerview.delete_content(@options[:container], content)\n puts 'deleted ' + content\n end\n end\n containerview = containerview.delete(@options[:container])\n if containerview.code == '204'\n puts \"Container #{@options[:container]} deleted\"\n else\n @util.response_handler(containerview)\n end\n end", "def delete_image_attachment\n @image = ActiveStorage::Attachment.find(params[:id])\n @image.purge\n redirect_back(fallback_location: items_path)\n end" ]
[ "0.83315086", "0.8071649", "0.7675575", "0.7647696", "0.76228946", "0.7597437", "0.747701", "0.74748755", "0.7357728", "0.7287723", "0.72469103", "0.7159488", "0.7154855", "0.71026874", "0.7101158", "0.70001864", "0.6991289", "0.6960998", "0.6926973", "0.68717057", "0.68717057", "0.6838362", "0.67870337", "0.67710984", "0.65971947", "0.659607", "0.6591138", "0.64819586", "0.6461662", "0.643401", "0.6412077", "0.6360216", "0.63582027", "0.63238645", "0.62886864", "0.6278675", "0.6240979", "0.61776686", "0.60404295", "0.60235393", "0.5989447", "0.59627086", "0.5875409", "0.5844552", "0.58241445", "0.5810094", "0.5801712", "0.5758994", "0.5700225", "0.5645666", "0.56145227", "0.5603806", "0.5602734", "0.55358917", "0.54899347", "0.54521656", "0.54305756", "0.54131657", "0.54125863", "0.53919846", "0.5380616", "0.5370719", "0.53686863", "0.536132", "0.5358883", "0.5355751", "0.5351369", "0.53414625", "0.53087586", "0.5302802", "0.52836215", "0.52836215", "0.5274018", "0.5249489", "0.52405983", "0.5233593", "0.52315795", "0.52299523", "0.52226615", "0.5220989", "0.52145094", "0.52069145", "0.5204023", "0.51875347", "0.517923", "0.517716", "0.5163838", "0.5163428", "0.5154129", "0.5142385", "0.5141056", "0.5137182", "0.5120089", "0.5110061", "0.5089185", "0.5081098", "0.50739396", "0.5063979", "0.50619435", "0.50603783" ]
0.7583896
6
helper function to create RDS Snapshots return the response on success, otherwise false.
def createRDSSnapshot(client=nil,db_instance=nil,snapshot_name=nil,tags=[]) return false if db_instance.nil? || client.nil? if snapshot_name.nil? snapshot_name="#{db_instance}-#{Time.now.to_i}" end unless tags.instance_of? Array puts "\e[31mtags must be an Array\e[0m" return false end begin puts "\e[32mTaking snapshot of db instance #{db_instance}. Snapshot will be named #{snapshot_name}\e[0m" resp = client.create_db_snapshot({ db_snapshot_identifier: snapshot_name, db_instance_identifier: db_instance, tags: tags }) rescue Exception => e puts "\e[31m#{e.message}\e[0m" return false end return resp end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_snapshot(rds_resource, db_instance_name)\n id = \"snapshot-#{rand(10**6)}\"\n db_instance = rds_resource.db_instance(db_instance_name)\n db_instance.create_snapshot({\n db_snapshot_identifier: id\n })\nrescue Aws::Errors::ServiceError => e\n puts \"Couldn't create DB instance snapshot #{id}:\\n #{e.message}\"\nend", "def create_snapshot(options)\n snapshot = ec2.snapshots.new\n snapshot.volume_id = options['volume_id']\n snapshot.description = options['description']\n\n attempts = 0\n\n begin\n snapshot.save\n snapshot.reload\n rescue Fog::Compute::AWS::Error\n sleep 5\n attempts += 1\n if attempts == 5\n log \"Error communicating with API; Unable to save volume `#{options['volume_id']}` (Desc: #{options['description']})\"\n end\n return unless attempts == 5\n end\n\n options['tags'].each do |k,v|\n begin\n ec2.tags.create({resource_id: snapshot.id, key: k, value: v})\n rescue Errno::EINPROGRESS , Errno::EISCONN\n log \"API Connection Error\"\n sleep 1\n retry\n rescue Fog::Compute::AWS::Error\n log \"Failed attaching tag `'#{k}' => #{v}` to #{options['snapshot_type']} snapshot #{snapshot.id}\"\n sleep 1\n retry\n end\n end\n\n end", "def create_db_snapshot( options = {} )\n raise ArgumentError, \"No :db_snapshot_identifier provided\" if options.does_not_have?(:db_snapshot_identifier)\n raise ArgumentError, \"No :db_instance_identifier provided\" if options.does_not_have?(:db_instance_identifier)\n\n params = {}\n params['DBSnapshotIdentifier'] = options[:db_snapshot_identifier]\n params['DBInstanceIdentifier'] = options[:db_instance_identifier]\n\n return response_generator(:action => \"CreateDBSnapshot\", :params => params)\n end", "def create_db_snapshot(identifier, name)\n request({\n 'Action' => 'CreateDBSnapshot',\n 'DBInstanceIdentifier' => identifier,\n 'DBSnapshotIdentifier' => name,\n :parser => Fog::Parsers::AWS::RDS::CreateDBSnapshot.new\n })\n end", "def create_snapshot(device, options = {})\n # TODO - add in new param commit=explicit once the API is availible\n params = {:device => device, \n :suffix => options[:suffix], \n :description => options[:description], \n :tag => options[:tag],\n :max_snaps => options[:max_snaps],\n :prefix_override => options[:prefix_override],\n :commit => \"explicit\",\n :api_version => 1.0}\n # Perform API call to snapshot the volume attached to the device on the instance\n STDERR.puts \"Performing RightScale API call to create a new snapshot\"\n #STDERR.puts \"HERE IS THE URL: #{@api_url}/create_ebs_snapshot.js (PARAMS: #{params.inspect})\"\n json=nil\n SystemTimer.timeout_after(@api_snap_timeout) do\n body = RestClient.post @api_url+\"/create_ebs_snapshot.js\",params\n json = body.nil? ? nil: JSON.load(body)\n STDERR.puts \"CREATED_SNAP: #{json}\"\n end\n json \n rescue Exception => e\n display_exception(e, \"create_snapshot(#{device}, #{options.inspect})\")\n end", "def create_snapshot(snapshot, description = nil)\n ensure_uri && ensure_client\n if snapshot.is_a?(OneviewSDK::Resource) || snapshot.is_a?(Hash)\n name = snapshot[:name] || snapshot['name']\n description ||= snapshot[:description] || snapshot['description']\n else\n name = snapshot\n end\n data = generate_snapshot_data(name, description)\n response = @client.rest_post(\"#{@data['uri']}/snapshots\", { 'body' => data }, @api_version)\n @client.response_handler(response)\n true\n end", "def create_ebs_backup(options = {})\n params = options.merge( { :commit => \"explicit\", :api_version => 1.0 } )\n STDERR.puts \"Performing RightScale API call to create a new snapshot\"\n json=nil\n SystemTimer.timeout_after(@api_snap_timeout) do\n body = RestClient.post @api_url+\"/create_ebs_backup.js\", params\n json = body.nil? ? nil: JSON.load(body)\n STDERR.puts \"CREATED_SNAPS: #{json}\"\n end\n json \n rescue Exception => e\n display_exception(e, \"create_ebs_backup(#{options.inspect})\")\n end", "def create_snapshot(name)\n unless exists?\n return Response.new :code => 1, :message => 'VM does not exist'\n end\n\n running_response = running?\n return running_response unless running_response.successful?\n\n unless running_response.data\n message = 'The VM must be running in order to take a snapshot.'\n return Response.new :code => 1, :message => message\n end\n\n conf_file_response = conf_file\n return conf_file_response unless conf_file_response.successful?\n\n snapshots_response = snapshots\n return snapshots_response unless snapshots_response.successful?\n\n if snapshots_response.data.include? name\n message = \"There is already a snapshot named '#{name}'.\"\n return Response.new :code => 1, :message => message\n end\n\n command = \"#{vmrun_cmd} snapshot \"\n command << \"#{conf_file_response.data} \\\"#{name}\\\" 2>&1\"\n\n Response.from_command(`#{command}`)\n end", "def create\n @snapshot = current_account.snapshots.new(params[:snapshot])\n\n respond_to do |format|\n if @snapshot.save\n flash[:notice] = 'Snapshot was successfully created.'\n format.html { redirect_to(@snapshot) }\n format.xml { render :xml => @snapshot, :status => :created, :location => @snapshot }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @snapshot.errors, :status => :unprocessable_entity }\n end\n end\n end", "def createNewSnapshot\n snap_id = @deploy.getResourceName(@config[\"name\"]) + Time.new.strftime(\"%M%S\").to_s\n\n attempts = 0\n begin\n MU::Cloud::AWS.elasticache(region: @region, credentials: @credentials).create_snapshot(\n cache_cluster_id: @config[\"identifier\"],\n snapshot_name: snap_id\n )\n rescue Aws::ElastiCache::Errors::InvalidCacheClusterState => e\n if attempts < 10\n MU.log \"Tried to create snapshot for #{@config[\"identifier\"]} but cache cluster is busy, retrying a few times\"\n attempts += 1\n sleep 30\n retry\n else\n raise MuError, \"Failed to create snpashot for cache cluster #{@config[\"identifier\"]}: #{e.inspect}\"\n end\n end\n \n attempts = 0\n loop do\n MU.log \"Waiting for snapshot of cache cluster #{@config[\"identifier\"]} to be ready...\", MU::NOTICE if attempts % 20 == 0\n MU.log \"Waiting for snapshot of cache cluster #{@config[\"identifier\"]} to be ready...\", MU::DEBUG\n\n snapshot_resp = MU::Cloud::AWS.elasticache(region: @region, credentials: @credentials).describe_snapshots(snapshot_name: snap_id)\n attempts += 1\n break unless snapshot_resp.snapshots.first.snapshot_status != \"available\"\n sleep 15\n end\n\n return snap_id\n end", "def list_instance_snapshots(rds_resource)\n instance_snapshots = []\n rds_resource.db_snapshots.each do |s|\n instance_snapshots.append({\n \"id\": s.snapshot_id,\n \"status\": s.status\n })\n end\n instance_snapshots\nrescue Aws::Errors::ServiceError => e\n puts \"Couldn't list instance snapshots:\\n #{e.message}\"\nend", "def create_snapshots(isCopy)\n ec2 = AWS::EC2.new.client\n\n #get all volumes tagged as \"backup\"\n volumes = ec2.describe_volumes(:filters => [:name => 'tag-key', :values => ['backup']])\n snapshots = []\n\n #loop thru and create snapshots for all these volumes\n if volumes \n volumes.data[:volume_set].each do |v|\n name = get_tagvalue(v, \"Name\")\n snap = ec2.create_snapshot(:volume_id => v[:volume_id], :description => \"Backup for \" + Time.now.to_s + \" - created by SDK\")\n if snap\n snapshots << snap.data\n #add name tag\n ec2.create_tags(:resources => [snap.data[:snapshot_id]], :tags => [{:key => \"Name\", :value => name + \" backup\"}])\n\n #now copy snapshots to another region\n if isCopy\n copy_snapshot(snap.data[:snapshot_id], AWSCONFIG[:default_region], AWSCONFIG[:backup_region], \n name + \" backup\", \"Backup for \" + Time.now.to_s + \" - created by SDK\")\n end\n end\n end\n end\n\n return snapshots\n end", "def exists?(params = {})\n response = client.get \"/_snapshot/{repository}/{snapshot}\", update_params(params, action: \"snapshot.exists\", rest_api: \"snapshot.get\")\n response.success?\n rescue ElastomerClient::Client::Error => err\n if err.error && err.error.dig(\"root_cause\", 0, \"type\") == \"snapshot_missing_exception\"\n false\n else\n raise err\n end\n end", "def create_snapshot(snapshot_name)\n execute(:create_snapshot, VmId: vm_id, SnapName: snapshot_name)\n end", "def create_snapshot\n @attributes[:create_snapshot]\n end", "def create_snap # rubocop:disable Metrics/AbcSize\n authcookie = ComputeBase.new\n authcookie = authcookie.authenticate(id_domain, user, passwd, restendpoint)\n url = restendpoint + @function\n uri = URI.parse(url)\n #account = '/Compute-' + @id_domain + '/' + @user\n account = '/Compute-' + id_domain + '/cloud_storage'\n create_data = Hash.new\n create_data = { 'account' => account, 'instance' => container }\n create_data['machineimage'] = @machine_image if !@machine_image.nil?\n http = Net::HTTP.new(uri.host, uri.port, @proxy_addr, @proxy_port) # Creates a http object\n http.use_ssl = true # When using https\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Post.new(uri.request_uri)\n request.add_field 'Cookie', authcookie\n request.add_field 'Content-type', 'application/oracle-compute-v3+json'\n http.request(request, create_data.to_json)\n end", "def create_snapshot(snap_id, snap_name)\n memory_dumps = true\n memory_dumps = CONFIG[:memory_dumps] \\\n unless CONFIG[:memory_dumps].nil?\n\n snapshot_hash = {\n :name => snap_id,\n :description => \"OpenNebula Snapshot: #{snap_name}\",\n :memory => memory_dumps,\n :quiesce => true\n }\n\n begin\n @item.CreateSnapshot_Task(snapshot_hash).wait_for_completion\n rescue StandardError => e\n error = \"Cannot create snapshot for VM: #{e.message}.\"\n\n if VCenterDriver::CONFIG[:debug_information]\n error += \"\\n\\n#{e.backtrace.join(\"\\n\")}\"\n end\n\n raise error\n end\n\n snap_id\n end", "def create_snapshot(uuid, snapshot_name)\n stdout = execute_prlctl('snapshot', uuid, '--name', snapshot_name)\n return Regexp.last_match(1) if stdout =~ /{([\\w-]+)}/\n\n raise Errors::SnapshotIdNotDetected, stdout: stdout\n end", "def find_rds_snapshots(options = {}, snapshot_type = 'manual')\n days_old = options[:days_old]\n found_snap_shots = []\n\n snapshots_info = @rds.describe_db_snapshots(snapshot_type: snapshot_type)[:db_snapshots]\n\n snapshots_info.each do |snapshot_info|\n next if snapshot_info[:status] != 'available'\n if !days_old.nil?\n snapshot_days_old = (Time.now.to_i - snapshot_info[:snapshot_create_time].to_i) / Cucloud::SECONDS_IN_A_DAY\n if snapshot_days_old > days_old\n found_snap_shots.push(snapshot_info[:db_snapshot_identifier])\n end\n else\n found_snap_shots.push(snapshot_info[:db_snapshot_identifier])\n end\n end\n found_snap_shots\n end", "def createEBSSnapshot(client=nil,description='',volume_id=nil)\n return false if volume_id.nil? || client.nil?\n # Fetch the Volume Name. This will be used in the description of the snapshot\n resp = client.describe_volumes({dry_run: false, volume_ids: [volume_id] })\n resp.volumes[0].tags.each do |t|\n if t.key=='Name'\n description = t.value unless t.value.empty?\n break\n end\n end\n # puts \"Taking snapshot of volume #{volume_id}...\"\n return client.create_snapshot({\n dry_run: false,\n volume_id: volume_id,\n description: description\n })\nend", "def create_snapshot(droplet) # rubocop:disable MethodLength,Metrics/AbcSize\n fail_if_shutdown(droplet)\n\n logger.info \"Start creating snapshot for droplet id: #{droplet.id} name: #{droplet.name}.\"\n\n today = DateTime.now\n name = \"#{droplet.name}_#{today.strftime('%Y_%m_%d')}\"\n # noinspection RubyResolve\n snapshot_size = api.snapshots(droplet).size\n\n logger.debug 'Wait until snapshot will be created.'\n\n api.create_snapshot droplet.id, name\n\n snapshot_size += 1\n\n logger.info \"Snapshot name: #{name} created successfully.\"\n logger.info \"Droplet id: #{droplet.id} name: #{droplet.name} snapshots: #{snapshot_size}.\"\n\n # Cleanup snapshots.\n cleanup_snapshots droplet, snapshot_size if clean\n rescue => e\n case e.class.to_s\n when 'DoSnapshot::SnapshotCleanupError'\n raise e.class, e.message, e.backtrace\n when 'DoSnapshot::DropletPowerError'\n return\n else\n raise SnapshotCreateError.new(droplet.id), e.message, e.backtrace\n end\n end", "def create_snapshot(volume_id, options = {})\n action = 'CreateSnapshot'\n params = {\n 'Action' => action,\n 'VolumeId' => volume_id\n }\n params['Description'] = options[:description] unless options[:description].blank?\n\n response = send_query_request(params)\n parser = Awsum::Ec2::SnapshotParser.new(self)\n snapshot = parser.parse(response.body)[0]\n if options[:tags] && options[:tags].size > 0\n create_tags snapshot.id, options[:tags]\n end\n snapshot\n end", "def create_snapshot request_pb, options:, &block\n uri = \"/compute/v1/projects/#{request_pb.project}/zones/#{request_pb.zone}/disks/#{request_pb.disk}/createSnapshot\"\n body = request_pb.snapshot_resource.to_json\n\n response = @client_stub.make_post_request(\n uri: uri,\n body: body,\n options: options,\n )\n\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n\n result\n end", "def create\n @snap = Snap.new(snap_params)\n @snap.user = User.first\n\n if @snap.save\n render :show, status: :created, location: @snap\n else\n render json: @snap.errors, status: :unprocessable_entity\n end\n end", "def snapshotted?\n snapshot.present?\n end", "def create(body = {}, params = {})\n response = client.put \"/_snapshot/{repository}/{snapshot}\", update_params(params, body: body, action: \"snapshot.create\", rest_api: \"snapshot.create\")\n response.body\n end", "def pending_snapshots(rds_instance)\n snaps = rds_instance.snapshots\n snaps.select do |snap|\n snap.status == 'creating'\n end\n end", "def save_snapshot()\r\n result={}\r\n\tresult[:session]=[]\r\n\tdt=Time.now()\r\n\t#logger.debug(\"Hello Jerry World #{snap_data[:image_buffer].inspect()}\\n\")#[:image_buffer].inspect()\r\n\tsite_id=params[1]\r\n\ts_session=params[3]\r\n\ttrace=params[2]\r\n\tuser_ip=params[0]\r\n\tan=Site.find(site_id.to_i).analyzer\r\n\tn_f=Datalog.cal_noise_floor(trace,an.id)\r\n f_session= (s_session!=\"\" && Snapshot.exists?(:session=>s_session)) ? s_session : \"#{dt.to_i}_#{site_id}_#{user_ip}\"\r\n\tsnap=Snapshot.new()\t \r\n\tsnap.update_attributes(:image=>trace,:source=>'Realview',:noise_floor=>n_f,:create_dt=>dt,:site_id=>site_id,:session=>f_session,:description=>\"livetrace\")\r\n result[:session]=f_session \r\n respond_to do |format|\r\n\t\t\tformat.amf { \r\n\t\t render :amf => result\r\n\t\t \t}\r\n\t end\r\n end", "def create_snapshot subscription, snapshot_name, labels: nil\n subscriber.create_snapshot name: snapshot_path(snapshot_name),\n subscription: subscription_path(subscription),\n labels: labels\n end", "def create(name)\n p \"Doing a create ...\"\n params = {:backup => {:lineage => \"ns_backup_test_lineage\", :name => name, :volume_attachment_hrefs => [@volume_attachment_href_1, @volume_attachment_href_2]}}\n return @test_client.backups.create(params)\nend", "def create_snapshot_action(id, description=\"New Snapshot\", type=:vapp)\n params = {\n \"method\" => :post,\n \"command\" => \"/vApp/#{type}-#{id}/action/createSnapshot\"\n }\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.CreateSnapshotParams(\n \"xmlns\" => \"http://www.vmware.com/vcloud/v1.5\") {\n xml.Description description\n }\n end\n response, headers = send_request(params, builder.to_xml, \"application/vnd.vmware.vcloud.createSnapshotParams+xml\")\n task_id = headers[:location].gsub(/.*\\/task\\//, \"\")\n task_id\n end", "def snapshot\n begin\n response = resource[\"/snapshot/#{app}\"].post(nil)\n rescue RestClient::InternalServerError\n display \"An error has occurred.\"\n end\n display response.to_s\n end", "def create_snapshot(metadata={})\n Azure::Blobs.create_snapshot(self, metadata)\n end", "def save_snapshot\n return unless @current_snapshot\n current_state = @bitmap.to_json\n return if snapshots_match?(@current_snapshot, current_state)\n\n @snapshots << @current_snapshot\n end", "def create_snapshot_action(id, description=\"New Snapshot\", type=:vapp)\n params = {\n \"method\" => :post,\n \"command\" => \"/vApp/#{type}-#{id}/action/createSnapshot\"\n }\n builder = Nokogiri::XML::Builder.new do |xml|\n xml.CreateSnapshotParams(\n \"xmlns\" => \"http://www.vmware.com/vcloud/v1.5\") {\n xml.Description description\n }\n end\n response, headers = send_request(params, builder.to_xml, \"application/vnd.vmware.vcloud.createSnapshotParams+xml\")\n task_id = headers[:location].gsub(/.*\\/task\\//, \"\")\n task_id\n end", "def describe_db_snapshots( options = {} )\n raise ArgumentError, \"No :db_instance_identifier provided\" if options.does_not_have?(:db_instance_identifier)\n\n params = {}\n params['DBInstanceIdentifier'] = options[:db_instance_identifier]\n\n params['DBSnapshotIdentifier'] = options[:db_snapshot_identifier] if options.has?(:db_snapshot_identifier)\n params['MaxRecords'] = options[:max_records].to_s if options.has?(:max_records)\n params['Marker'] = options[:marker] if options.has?(:marker)\n\n return response_generator(:action => \"DescribeDBSnapshots\", :params => params)\n end", "def create_share_snapshot_post_with_http_info(create_share_snapshot_param, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SnapshotApi.create_share_snapshot_post ...\"\n end\n # verify the required parameter 'create_share_snapshot_param' is set\n if @api_client.config.client_side_validation && create_share_snapshot_param.nil?\n fail ArgumentError, \"Missing the required parameter 'create_share_snapshot_param' when calling SnapshotApi.create_share_snapshot_post\"\n end\n # resource path\n local_var_path = \"/createShareSnapshot\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(create_share_snapshot_param)\n auth_names = ['basicAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SnapshotApi#create_share_snapshot_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create_snapshot\n @current_snapshot = @bitmap.to_json if @bitmap\n end", "def create_snapshot(name)\n Fission::Action::Snapshot::Creator.new(self).create_snapshot(name)\n end", "def snapshots\n unless @vm.exists?\n return Response.new :code => 1, :message => 'VM does not exist'\n end\n\n conf_file_response = @vm.conf_file\n return conf_file_response unless conf_file_response.successful?\n\n command = \"#{vmrun_cmd} listSnapshots \"\n command << \"'#{conf_file_response.data}' 2>&1\"\n\n command_exec = Fission::Action::ShellExecutor.new command\n result = command_exec.execute\n\n response = Response.new :code => result['process_status'].exitstatus\n\n if response.successful?\n response.data = parse_snapshot_names_from_output result['output']\n else\n response.message = result['output']\n end\n\n response\n end", "def volume_create_from_snap(source, name, snapshot_id)\n retries = 3\n begin \n @log.info \"Creating volume #{name} from snapshot id #{snapshot_id}...\"\n ret = @cloud_stack.create_volume(name, ZONE, nil, snapshot_id)\n id = ret[\"createvolumeresponse\"][\"jobid\"]\n wait_for_job id\n rescue Exception => e\n retries -= 1\n if retries > 0\n @log.error \"Failed. #{e.message}. Retrying...\"\n retry\n end\n raise e\n end\n vol_id = ret[\"createvolumeresponse\"][\"id\"]\n @log.info \"Created volume id: #{vol_id}\"\n vol_id\n end", "def create_db_instance(db_name, options={})\n \n if security_groups = options.delete('DBSecurityGroups')\n options.merge!(Fog::AWS.indexed_param('DBSecurityGroups.member.%d', [*security_groups]))\n end\n \n request({\n 'Action' => 'CreateDBInstance',\n 'DBInstanceIdentifier' => db_name,\n :parser => Fog::Parsers::AWS::RDS::CreateDBInstance.new,\n }.merge(options))\n end", "def create\n # Check some authenticity token, username, password (must be logged into a session)...\n @snap = Snap.create(params[:snap].merge(:user_id => 1, :url => 'http://www.yahoo.com'))\n\n @snap.save\n render :inline => @snap.try(:body)\n \n #respond_to do |format|\n #if @snap.save\n #format.html { redirect_to(@snap, :notice => 'Snap was successfully created.') }\n #format.xml { render :xml => @snap, :status => :created, :location => @snap }\n #else\n #format.html { render :action => \"new\" }\n #format.xml { render :xml => @snap.errors, :status => :unprocessable_entity }\n #end\n #end\n end", "def backup(options = {})\n my_aws = {\n region: ENV['AWS_REGION'],\n access_method: 'api_key',\n access_key: ENV['AWS_API_KEY'],\n secret_key: ENV['AWS_SECRET_KEY']\n }\n conn = ::Skejuler::Aws::Connector.new(my_aws)\n\n rds = conn.rds # Aws RDS Client library\n\n rds.describe_db_instances\n instance_id = options.fetch(:instance_id)\n puts instance_id\n # do something on it\n\nend", "def snapshots\n unless exists?\n return Response.new :code => 1, :message => 'VM does not exist'\n end\n\n conf_file_response = conf_file\n return conf_file_response unless conf_file_response.successful?\n\n command = \"#{vmrun_cmd} listSnapshots \"\n command << \"#{conf_file_response.data} 2>&1\"\n output = `#{command}`\n\n response = Response.new :code => $?.exitstatus\n\n if response.successful?\n snaps = output.split(\"\\n\").select { |s| !s.include? 'Total snapshots:' }\n response.data = snaps.map { |s| s.strip }\n else\n response.message = output\n end\n\n response\n end", "def snapshot esurl, snapurl, options\n elastic esurl\n set_opts(options)\n set_repository snapurl, options\n initiate_snapshot snapurl\n end", "def restore_db\n\n begin\n self.rds.restore_db_instance_from_db_snapshot(new_snap.id,\n backup_server_id,\n {\"DBSubnetGroupName\" => @opts['db_subnet_group_name'],\n \"DBInstanceClass\" => @opts['db_instance_type'] } )\n rescue Exception => e\n raise MyRDSException.new(\"Error in #{self.class}:restore_db: #{e.class}: #{e}\")\n end\n\n end", "def create_images(isCopy)\n ec2 = AWS::EC2.new.client\n instances = ec2.describe_instances(:filters => [:name => 'tag-key', :values => ['backup']])\n images = []\n if instances\n if instances.data[:reservation_set].count > 0\n instances.data[:reservation_set].each do |rs|\n rs[:instances_set].each do |i|\n #get name of instance\n name = get_tagvalue(i, \"Name\") + \" backup at \" + Time.now.to_s.gsub(\":\", \"-\")\n image = ec2.create_image(:instance_id => i[:instance_id], \n :name => name,\n :description => \"Created - \" + Time.now.to_s + \" - created by SDK\", :no_reboot => true)\n images << image if image\n if (isCopy)\n copy_image(i[:image_id], AWSCONFIG[:default_region], AWSCONFIG[:backup_region], \n name, \"Backup for \" + Time.now.to_s + \" - created by SDK\")\n end\n end\n end\n end\n end\n\n return images\n end", "def create_snapshot( dashboard = {} )\n\n raise ArgumentError.new('dashboard must be an Hash') unless( dashboard.is_a?(String) )\n\n endpoint = '/api/snapshots'\n @logger.debug(\"Creating dashboard snapshot (POST #{endpoint})\") if @debug\n\n post(endpoint, dashboard)\n end", "def snapshot\n if disk_usage_exceeds?(90)\n $stderr.puts \"WARNING: The application's disk usage is very close to the quota limit. The snapshot may fail unexpectedly\"\n $stderr.puts \"depending on the amount of data present and the snapshot procedure used by your application's cartridges.\"\n end\n\n pre_snapshot_state = @state.value\n stop_gear\n\n scalable_snapshot = !!@cartridge_model.web_proxy\n\n if scalable_snapshot\n begin\n handle_scalable_snapshot\n rescue => e\n $stderr.puts \"We were unable to snapshot this application due to communication issues with the OpenShift broker. Please try again later.\"\n $stderr.puts \"#{e.message}\"\n $stderr.puts \"#{e.backtrace}\"\n return false\n end\n end\n\n @cartridge_model.each_cartridge do |cartridge|\n @cartridge_model.do_control('pre-snapshot',\n cartridge,\n err: $stderr,\n pre_action_hooks_enabled: false,\n post_action_hooks_enabled: false,\n prefix_action_hooks: false,)\n end\n\n exclusions = []\n\n @cartridge_model.each_cartridge do |cartridge|\n exclusions |= snapshot_exclusions(cartridge)\n end\n\n write_snapshot_archive(exclusions)\n\n result = @cartridge_model.each_cartridge do |cartridge|\n @cartridge_model.do_control('post-snapshot',\n cartridge,\n err: $stderr,\n pre_action_hooks_enabled: false,\n post_action_hooks_enabled: false)\n end\n\n # Revert to the pre-snapshot state of the currently snapshotted gear\n #\n if @state.value != pre_snapshot_state\n (@state.value != State::STARTED) && start_gear\n end\n\n result\n end", "def createRDSClient(region,credentials)\n begin\n return Aws::RDS::Client.new(region: region,credentials: credentials)\n rescue Exception => e\n puts \"\\e[31mCould not create new RDS client.\"\n puts \"#{e.message}\\e[0m\"\n exit 1\n end\nend", "def restore_db_instance_from_snapshot( options = {} )\n raise ArgumentError, \"No :db_snapshot_identifier provided\" if options.does_not_have?(:db_snapshot_identifier)\n raise ArgumentError, \"No :db_instance_identifier provided\" if options.does_not_have?(:db_instance_identifier)\n raise ArgumentError, \"No :db_instance_class provided\" if options.does_not_have?(:db_instance_class)\n\n params = {}\n params['DBSnapshotIdentifier'] = options[:db_snapshot_identifier]\n params['DBInstanceIdentifier'] = options[:db_instance_identifier]\n params['DBInstanceClass'] = options[:db_instance_class]\n\n params['Port'] = options[:port].to_s if options.has?(:port)\n params['AvailabilityZone'] = options[:availability_zone] if options.has?(:availability_zone)\n\n return response_generator(:action => \"RestoreDBInstanceFromDBSnapshot\", :params => params)\n end", "def create_set(data)\n result = @connection.request(\n url: \"/snapshot-sets\",\n method: :post,\n payload: {\n snapshotSet: data\n }\n )\n\n # Blocks async task\n result = @connection.wait_for_task(result['taskUri'].split('/').last)\n\n get_set(result['associatedResource']['resourceUri'].split('/').last)\n end", "def snapshots\n client = Aws::EC2::Client.new\n client.describe_snapshots({\n filters: [{\n name: \"tag:type\",\n values: [\"auto\"]\n }]\n }).snapshots\nend", "def execute_restore_stripe(options={})\n new_vol_name = \"#{options[:lineage]}-#{ENV['EC2_INSTANCE_ID']}\"\n json_result = self.find_latest_ebs_backup(options[:lineage], options[:from_master], options[:timestamp])\n\n if json_result.nil? \n STDERR.puts \"No existing snapshot found for the specified nickname lineage. Aborting...\"\n exit(-1)\n end\n STDERR.puts \"Restoring.. #{json_result.inspect}\"\n options[:new_size_gb] = (options[:new_volume_size_in_gb] / json_result.size.to_f).ceil if options[:new_volume_size_in_gb]\n\n @disk.sync\n @disk.umount\n @disk.disable_volume\n\n self.execute_terminate_volumes if options[:force]\n\n json_result.each do |snapshot|\n \n# create volume from snap\n create_result = ( options[:new_size_gb] ? create_volume_from_snap_size_gb(snapshot[\"aws_id\"],new_vol_name,options[:new_size_gb] ) : create_volume_from_snap(snapshot[\"aws_id\"], new_vol_name ) )\n raise \"FATAL: error occured in create_volume_from_snap(#{snapshot['aws_id']}, #{new_vol_name})\" if create_result.nil?\n\n# attach volume to instance\n retry_seconds = 0\n while retry_seconds < 200\n begin \n attach_result = attach_volume(create_result['aws_id'], snapshot['device'])\n raise \"FATAL: error occured in attach_volume(#{create_result['aws_id']}, #{snapshot['device']}\" if attach_result.nil?\n break if attach_result\n rescue => e\n puts \"CAUGHT EXCEPTION in execute_restore_stripe. Device attachment. #{e}, Retrying #{retry_seconds} of 200 seconds\"\n retry_seconds += 30\n sleep 30 \n end\n end\n raise \"FATAL: error occured in attach_volume(#{create_result['aws_id']}, #{snapshot['device']}\" if attach_result.nil?\n end\n\n# wait for devices to attach, after completing ALL the api calls\n json_result.each { |s| wait_for_attachment(s['device']) }\n @disk.enable_volume\n raise \"FATAL: mount failed!\" unless @disk.mount\n @disk.write_fstab\n# TODO - grow the filesystem if a new size was given\n end", "def wait_for_snapshots\n timeout=1500\n step=10\n while timeout > 0\n puts \"Checking for snapshot completed\"\n snapshots = behavior(:find_snapshots)\n status= snapshots.map { |x| x.aws_status } \n break unless status.include?(\"pending\")\n sleep step\n timeout -= step\n end\n raise \"FATAL: timed out waiting for all snapshots in lineage #{@lineage} to complete\" if timeout == 0\n end", "def create\n\n @inventory_snapshot_content = InventorySnapshotContent.new(inventory_snapshot_content_params)\n\n respond_to do |format|\n if @inventory_snapshot_content.save\n format.html { redirect_to @inventory_snapshot_content, notice: 'Inventory snapshot content was successfully created.' }\n format.json { render :show, status: :created, location: @inventory_snapshot_content }\n else\n format.html { render :new }\n format.json { render json: @inventory_snapshot_content.errors, status: :unprocessable_entity }\n end\n end\n end", "def list_snapshots_post_with_http_info(list_snapshots_param, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SnapshotApi.list_snapshots_post ...\"\n end\n # verify the required parameter 'list_snapshots_param' is set\n if @api_client.config.client_side_validation && list_snapshots_param.nil?\n fail ArgumentError, \"Missing the required parameter 'list_snapshots_param' when calling SnapshotApi.list_snapshots_post\"\n end\n # resource path\n local_var_path = \"/listSnapshots\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(list_snapshots_param)\n auth_names = ['basicAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'Array<String>')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SnapshotApi#list_snapshots_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create_snapshot(user, responses, checkpoint_id)\n # get the response ids out of the hash passed\n resp_ids = responses.map{|k1,v1| v1.map{|k2,v2| v2 if k2 == \"id\"}.compact!.join(\"\").to_i }\n \n # get all the measurement_category_ids\n mc_ids = MeasurementCategory.all.map{|mc| mc.id}\n \n # create two new hashes we need to store info temporarily\n earned = Hash.new\n possible = Hash.new\n \n resp_ids.each do |r_id|\n # get the response\n response = Response.find(r_id)\n mc_id = response.question.measurement.measurement_category.id \n # get points earned and add to hash\n pts_earned = response.points_earned\n if earned.has_key? mc_id\n earned[mc_id] += pts_earned\n else\n earned[mc_id] = pts_earned\n end\n # get points possible and add to hash\n pts_possible = response.points_total\n if possible.has_key? mc_id\n possible[mc_id] += pts_possible\n else\n possible[mc_id] = pts_possible\n end\n end\n \n mc_ids.each do |mc_id|\n if earned.keys.include? mc_id \n snap = Snapshot.new\n # set the object's values\n snap.percent_score = earned[mc_id].to_f/possible[mc_id]\n snap.user_id = user.id\n snap.checkpoint_id = checkpoint_id\n snap.measurement_category_id = mc_id\n # save this snapshot\n snap.save!\n end\n end\n end", "def get_share_snapshot_creation_status_post_with_http_info(get_share_snapshot_creation_status_param, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SnapshotApi.get_share_snapshot_creation_status_post ...\"\n end\n # verify the required parameter 'get_share_snapshot_creation_status_param' is set\n if @api_client.config.client_side_validation && get_share_snapshot_creation_status_param.nil?\n fail ArgumentError, \"Missing the required parameter 'get_share_snapshot_creation_status_param' when calling SnapshotApi.get_share_snapshot_creation_status_post\"\n end\n # resource path\n local_var_path = \"/getShareSnapshotCreationStatus\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(get_share_snapshot_creation_status_param)\n auth_names = ['basicAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'SnapshotProgressStatus')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SnapshotApi#get_share_snapshot_creation_status_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create(*args)\n create!(*args)\n rescue *exceptions\n false\n end", "def delete_snapshot(snapshot_id)\n log \"\\e[0;31m:: Deleting snapshot:\\e[0m #{snapshot_id}\"\n\n begin\n ec2.delete_snapshot(snapshot_id)\n sleep 0.2\n rescue Fog::Compute::AWS::NotFound\n log \"Failed to delete snapshot: #{snapshot_id}; setting { 'protected' => true }\"\n ec2.tags.create({resource_id: snapshot_id, key: 'protected', value: 'true'})\n rescue Fog::Compute::AWS::Error\n log \"API Error\"\n end\n\n end", "def create_volume_snapshot_post_with_http_info(create_volume_snapshot_param, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SnapshotApi.create_volume_snapshot_post ...\"\n end\n # verify the required parameter 'create_volume_snapshot_param' is set\n if @api_client.config.client_side_validation && create_volume_snapshot_param.nil?\n fail ArgumentError, \"Missing the required parameter 'create_volume_snapshot_param' when calling SnapshotApi.create_volume_snapshot_post\"\n end\n # resource path\n local_var_path = \"/createVolumeSnapshot\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(create_volume_snapshot_param)\n auth_names = ['basicAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SnapshotApi#create_volume_snapshot_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def create_snapshot_schedule_post_with_http_info(create_snapshot_schedule_param, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SnapshotApi.create_snapshot_schedule_post ...\"\n end\n # verify the required parameter 'create_snapshot_schedule_param' is set\n if @api_client.config.client_side_validation && create_snapshot_schedule_param.nil?\n fail ArgumentError, \"Missing the required parameter 'create_snapshot_schedule_param' when calling SnapshotApi.create_snapshot_schedule_post\"\n end\n # resource path\n local_var_path = \"/createSnapshotSchedule\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(create_snapshot_schedule_param)\n auth_names = ['basicAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SnapshotApi#create_snapshot_schedule_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def check_snapshot_folder\n Dir.mkdir(snapshot_folder_path) unless Dir.exists?(snapshot_folder_path)\n end", "def create_or_update\n\n return if @deleted == true\n\n cf = connect\n\n if @record_id.nil?\n rec = cf.rec_new('ec.vg','A',name, content, self.ttl)\n logger.debug rec\n self.record_id = rec[\"response\"][\"rec\"][\"obj\"][\"rec_id\"].to_i\n else\n rec = cf.rec_edit('ec.vg', 'A', record_id, name, content, self.ttl, false)\n logger.debug rec\n end\n\n end", "def created?\n @data[:status_code] == '201'\n end", "def takeSnapshot(description= nil)\n\n #@return : the Snapshot instance for this snapshot\t\n\t\t response = RestClient.post(\"https://#{Cbthelper.username}:#{Cbthelper.authkey}@crossbrowsertesting.com/api/v3/selenium/#{@testId}/snapshots\",\n\t\t \t\"selenium_test_id=#{@testId}\")\n\t\t hash = /(?<=\"hash\": \")((\\w|\\d)*)/.match(response)[0]\n\t\t snap = Snapshot.new(hash, @testId)\n\t\t if description != nil\n\t\t \tsnap.setDescription(description)\n\t\t end\n\t\t return snap\n\n\tend", "def create_from_snapshot(snapshot_name, properties, volume_template = nil, is_permanent = true)\n snapshot = get_snapshot(snapshot_name)\n raise IncompleteResource, 'Snapshot not found!' unless snapshot\n storage_pool_uri = nil\n volume_template_uri = if volume_template.nil?\n storage_pool_uri = @data['storagePoolUri']\n get_volume_template_uri(isRoot: true, family: 'StoreServ')\n else\n raise IncompleteResource, 'Volume Template not found!' unless volume_template.retrieve!\n storage_pool_uri = volume_template['storagePoolUri']\n volume_template['uri']\n end\n\n data = {\n 'properties' => properties.merge('storagePool' => storage_pool_uri, 'snapshotPool' => storage_pool_uri),\n 'snapshotUri' => snapshot['uri'],\n 'templateUri' => volume_template_uri,\n 'isPermanent' => is_permanent\n }\n\n response = @client.rest_post(\"#{BASE_URI}/from-snapshot\", { 'body' => data }, @api_version)\n self.class.new(@client, client.response_handler(response))\n end", "def update_snapshot(aws_id,commit_state)\n params = {:aws_id => aws_id, :commit_state => commit_state, :api_version => 1.0 }\n json=nil\n SystemTimer.timeout_after(@api_snap_timeout) do\n body = RestClient.put @api_url+\"/update_ebs_snapshot.js\",params\n puts \"UPDATED SNAP: #{aws_id}\"\n end\n json \n rescue Exception => e\n display_exception(e, \"update_snapshot(#{aws_id}, #{commit_state})\")\n end", "def create_backup_with_data\n @test_backup = @instance.backup @backup_id\n\n return @test_backup if @test_backup\n\n database = create_singers_albums_database\n\n capture do\n write_using_dml project_id: @project_id,\n instance_id: @instance.instance_id,\n database_id: database.database_id\n end\n\n client = @spanner.client @instance.instance_id, database.database_id\n version_time = client.execute(\"SELECT CURRENT_TIMESTAMP() as timestamp\").rows.first[:timestamp]\n\n capture do\n create_backup project_id: @project_id,\n instance_id: @instance.instance_id,\n database_id: database.database_id,\n backup_id: @backup_id,\n version_time: version_time\n\n @test_backup = @instance.backup @backup_id\n end\n\n @test_backup\n end", "def create_snapshot(vm, name)\n task = vm.CreateSnapshot_Task(\n name: name,\n memory: false,\n quiesce: false)\n\n if block_given?\n task.wait_for_progress do |progress|\n yield progress unless progress.nil?\n end\n else\n task.wait_for_completion\n end\n end", "def route_table_created_and_associated?(\n ec2_resource,\n vpc_id,\n subnet_id,\n gateway_id,\n destination_cidr_block,\n tag_key,\n tag_value\n)\n route_table = ec2_resource.create_route_table(vpc_id: vpc_id)\n puts \"Created route table with ID '#{route_table.id}'.\"\n route_table.create_tags(\n tags: [\n {\n key: tag_key,\n value: tag_value\n }\n ]\n )\n puts \"Added tags to route table.\"\n route_table.create_route(\n destination_cidr_block: destination_cidr_block,\n gateway_id: gateway_id\n )\n puts \"Created route with destination CIDR block \" \\\n \"'#{destination_cidr_block}' and associated with gateway \" \\\n \"with ID '#{gateway_id}'.\"\n route_table.associate_with_subnet(subnet_id: subnet_id)\n puts \"Associated route table with subnet with ID '#{subnet_id}'.\"\n return true\nrescue StandardError => e\n puts \"Error creating or associating route table: #{e.message}\"\n puts \"If the route table was created but not associated, you should \" \\\n \"clean up by deleting the route table.\"\n return false\nend", "def check_status\n response = $RDS.describe_db_instances(:db_instance_identifier => \"#{name}-#{Rails.env}\")\n status = response[:db_instances].first[:db_instance_status]\n if status == \"available\"\n self.url = response[:db_instances].first[:endpoint][:address]\n self.save\n end\n return status\n end", "def create\n @database = Database.new(database_params)\n @database.name = @database.name.downcase\n @database.user = @user[\"uid\"]\n @database.password = SecureRandom.urlsafe_base64(16)\n result = true\n if @database.postgres?\n result = create_postgresql_db(@database.name, @database.password)\n end\n\n if @database.mysql?\n result = create_mysql_db(@database.name, @database.password)\n end\n\n if result then\n result = @database.save\n end\n\n respond_to do |format|\n if result\n format.html { redirect_to @database, notice: 'La base de données à bien été créée.' }\n format.json { render :show, status: :created, location: @database }\n else\n format.html { render :new }\n format.json { render json: @database.errors, status: :unprocessable_entity }\n end\n end\n end", "def restore_from_snap(last_snapshot, options = {})\n options[:device] = \"/dev/sdk\" unless options[:device]\n options[:vol_nickname] = last_snapshot[\"nickname\"] unless options[:vol_nickname]\n \n # 5 - Unmount and detach the current EBS volume (forcing to detach the device we're gonna need later for attching ours...)\n umount_and_detach_device({:device => options[:device]})\n # 6- Create the volume from the latest snapshot, attach it to the instance and then mount it\n STDERR.puts \"Creating new DB volume from snapshot #{last_snapshot['aws_id']}\"\n vol = ( options[:new_size_gb] ? create_volume_from_snap_size_gb(last_snapshot[\"aws_id\"],options[:vol_nickname],options[:new_size_gb] ) : create_volume_from_snap(last_snapshot[\"aws_id\"],options[:vol_nickname] ) )\n unless vol.nil?\n \tSTDERR.puts \"Attaching new DB volume: #{vol['aws_id']}\"\n \tatt = attach_volume(vol['aws_id'], options[:device])\n \twait_for_attachment(options[:device])\n \tFileUtils.mkdir_p self.MountPoint\n \tres = `mount -t xfs -o noatime #{options[:device]} #{self.MountPoint}`\n \traise EBSRemoteExecException.new(nil,$?,\"Error mounting newly created volume (#{vol['aws_id']}) on #{options[:device]}:\\n\"+res) if $? != 0 \n else\n\t raise \"create volume failed from snapshot\"\n end\n end", "def build_snapshot\n Sherlock::Models::Snapshot.new(\n :node_id => snapshot_json[:node_id],\n :timestamp => Time.now\n )\n end", "def write_snapshots\n FileUtils.mkdir_p(snapshots_path)\n File.write(snapshot_path, Snapshot.dump(snapshots))\n end", "def getSnapshots()\n\t\tsnaps = JSON.parse(RestClient.get(\"https://#{Cbthelper.username}:#{Cbthelper.authkey}@crossbrowsertesting.com/api/v3/selenium/#{@testId}/snapshots/\"))\t\n\t\tret = []\n\n\t\tfor snap in snaps\n\t\t\tret.push(Snapshot.new(snap[\"hash\"], @testId))\n\n\t\tend\n\t\treturn ret\n\tend", "def response_db_master(method, database, master, uuid)\n \n #5.times { puts }\n #puts \"#{method} requested [database] /#{database}/#{master};#{uuid}\"\n \n if database == XDCR_BUCKET \n return [200]\n else\n return [404]\n end\nend", "def get_snapshots\n ensure_uri && ensure_client\n uri = \"#{@data['uri']}/snapshots\"\n self.class.find_with_pagination(@client, uri)\n end", "def build_snapshot\n raise \"build_snapshot not implemented in #{self}\"\n end", "def list_instances\n puts \"OK, Listing instances..\"\n\n response = RestClient.post( \n $uri,\n 'Version' => '2010-12-30',\n 'ACSAccessKeyId' => $ACSAccessKeyId,\n 'Format' => 'json',\n 'Timestamp' => $current_time,\n 'Rndguid' => $rndguid,\n 'Signature' => calculate_signature($api_private_key, $rndguid, $current_time),\n 'Action' => \"list-instances\")\n\n puts response\n puts response.code\nend", "def create!\n set_id = generate_set_id\n\n @volume_ids.each do |id|\n snapshot = @fog.snapshots.new\n\n snapshot.description = \"#{@hostname.split(\".\")[0]} #{@mount} (#{self.needed_types.join(\", \")}) (#{set_id})\"\n snapshot.volume_id = id\n\n # Actually do the snapshot\n snapshot.save\n\n # Reload to get snapshot.id so we can add tags\n snapshot.reload\n\n @fog.tags.create(:resource_id => snapshot.id, :key => \"Host\", :value => @hostname)\n @fog.tags.create(:resource_id => snapshot.id, :key => \"Mount\", :value => @mount)\n @fog.tags.create(:resource_id => snapshot.id, :key => \"SetID\", :value => set_id)\n @fog.tags.create(:resource_id => snapshot.id, :key => \"Type\", :value => self.needed_types.join(\",\"))\n end\n end", "def get_share_snapshot_creation_status_post(get_share_snapshot_creation_status_param, opts = {})\n data, _status_code, _headers = get_share_snapshot_creation_status_post_with_http_info(get_share_snapshot_creation_status_param, opts)\n return data\n end", "def list_cluster_snapshots(rds_resource)\n cluster_snapshots = []\n rds_resource.db_clusters.each do |c|\n c.snapshots.each do |s|\n cluster_snapshots.append({\n \"cluster\": c.id,\n \"snapshot_id\": s.snapshot_id,\n \"snapshot_status\": s.status\n })\n end\n end\n cluster_snapshots\nrescue Aws::Errors::ServiceError => e\n puts \"Couldn't list cluster snapshots:\\n #{e.message}\"\nend", "def bucket_created?(s3_client, bucket_name)\r\n s3_client.create_bucket(bucket: bucket_name)\r\n return true\r\nrescue StandardError => e\r\n puts \"Error creating bucket: #{e.message}\"\r\n return false\r\nend", "def bucket_created?(s3_client, bucket_name)\r\n response = s3_client.create_bucket(bucket: bucket_name)\r\n if response.location == '/' + bucket_name\r\n return true\r\n else\r\n return false\r\n end\r\nrescue StandardError => e\r\n puts \"Error creating bucket: #{e.message}\"\r\n return false\r\nend", "def create_snapshot request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_create_snapshot_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def get_volume_snapshot_creation_status_post_with_http_info(get_volume_snapshot_creation_status_param, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SnapshotApi.get_volume_snapshot_creation_status_post ...\"\n end\n # verify the required parameter 'get_volume_snapshot_creation_status_param' is set\n if @api_client.config.client_side_validation && get_volume_snapshot_creation_status_param.nil?\n fail ArgumentError, \"Missing the required parameter 'get_volume_snapshot_creation_status_param' when calling SnapshotApi.get_volume_snapshot_creation_status_post\"\n end\n # resource path\n local_var_path = \"/getVolumeSnapshotCreationStatus\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(get_volume_snapshot_creation_status_param)\n auth_names = ['basicAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'SnapshotProgressStatus')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SnapshotApi#get_volume_snapshot_creation_status_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def deleteEBSSnapshot(client=nil,snapshots_to_delete=[],dry_run=true)\n return false if client.nil?\n unless snapshots_to_delete.instance_of? Array\n snapshots_to_delete = [snapshots_to_delete]\n end\n snapshots_to_delete.each do |snapshot|\n if dry_run\n printf \"\\e[33m\\\"Delete snapshot #{snapshot}?\\\" (y/n)? \\e[0m\"\n prompt = STDIN.gets.chomp\n next unless prompt == \"y\"\n end\n print \"Deleting ec2 snapshot #{snapshot}...\"\n begin\n # delete_snapshot API has no response\n client.delete_snapshot({\n dry_run: dry_run,\n snapshot_id: snapshot\n })\n puts \"\\e[32msuccess\\e[0m\"\n rescue Exception => e\n puts \"\\e[31mfailed - #{e.message}\\e[0m\"\n end\n end\n return true\nend", "def vm_create_evm_snapshot(vm, options = {})\n require \"OpenStackExtract/MiqOpenStackVm/MiqOpenStackInstance\"\n\n log_prefix = \"vm=[#{vm.name}]\"\n\n miq_openstack_instance = MiqOpenStackInstance.new(vm.ems_ref, openstack_handle)\n miq_snapshot = miq_openstack_instance.create_evm_snapshot(options)\n\n # Add new snapshot image to the vms table. Type is TemplateOpenstack.\n miq_templates.create!(\n :type => \"ManageIQ::Providers::Openstack::CloudManager::Template\",\n :vendor => \"openstack\",\n :name => miq_snapshot.name,\n :uid_ems => miq_snapshot.id,\n :ems_ref => miq_snapshot.id,\n :template => true,\n :location => \"unknown\"\n )\n\n # Add new snapshot to the snapshots table.\n vm.snapshots.create!(\n :name => miq_snapshot.name,\n :description => options[:desc],\n :uid => miq_snapshot.id,\n :uid_ems => miq_snapshot.id,\n :ems_ref => miq_snapshot.id\n )\n return miq_snapshot.id\n rescue => err\n _log.error \"#{log_prefix}, error: #{err}\"\n _log.debug { err.backtrace.join(\"\\n\") }\n raise\n end", "def create_region\n Region.create!(params[:record])\n render :json => {}\n end", "def createRecord(sObject,records_to_insert)\n puts \"in @helper::createRecord\"\n puts records_to_insert\n record = @restForce.createRecord(sObject,records_to_insert)\n puts record\n return record\nend", "def find_latest_snapshot(db_instance_identifier, snapshot_type = 'manual')\n latest_snapshot_time = Time.new(2002)\n latest_snap_shot = nil\n snapshots_info = @rds.describe_db_snapshots(\n db_instance_identifier: db_instance_identifier, snapshot_type: snapshot_type\n )[:db_snapshots]\n\n snapshots_info.each do |snapshot_info|\n next if snapshot_info[:status] != 'available'\n\n if latest_snapshot_time.to_i < snapshot_info[:snapshot_create_time].to_i\n latest_snapshot_time = snapshot_info[:snapshot_create_time].to_i\n latest_snap_shot = snapshot_info\n end\n end\n\n latest_snap_shot.nil? ? nil : latest_snap_shot[:db_snapshot_identifier]\n end", "def execute_backup_stripe(options={})\n @disk.sync\n\n# Ensure filesystem is frozen and uses retry\n raise \"FATAL: unable to freeze lvm filesystem!\" unless @disk.freeze\n\n create_opts = {\n :lineage => options[:lineage],\n :prefix_override => options[:lineage], #Make sure we use the volume_nickname \"lineage\" as the prefix for our snaps (even if the volume has a different, perhaps more descriptive name)\n :description => \"Snapshot created by RightScale DB tools on instance #{ENV['EC2_INSTANCE_ID']}.\",\n :max_snaps => options[:max_snapshots],\n :keep_dailies => options[:keep_dailies],\n :keep_weeklies => options[:keep_weeklies],\n :keep_monthlies => options[:keep_monthlies],\n :keep_yearlies => options[:keep_yearlies],\n :devices => options[:devices].join(\",\")\n }\n create_opts[:suffix] = options[:suffix] if options[:suffix]\n\n # TODO: retry on the http requests? sounds like a good idea to me\n result = self.create_ebs_backup(create_opts)\n raise \"FATAL: unable to create snapshots!\" if result.nil?\n aws_ids = result['aws_ids']\n raise \"FATAL: result not recognized #{result}\" unless aws_ids.is_a?(Array)\n\n# Ensure filesystem is unfrozen and uses retry\n raise \"FATAL: could not unfreeze filesystem!\" unless @disk.unfreeze\n\n aws_ids.each do |snap|\n # TODO: does this http call need to be retried also? \n self.update_snapshot(snap, \"committed\")\n end\n\n # e) - Perform snapshot cleanup\n lst = self.cleanup_snapshots_stripe(options[:cleanup_prefix],{:keep_last => options[:max_snapshots], :dailies => options[:keep_dailies], :weeklies => options[:keep_weeklies], :monthlies => options[:keep_monthlies], :yearlies => options[:keep_yearlies]})\n puts \"Cleanup resulted in deleting #{lst.length} snapshots : #{lst.inspect}\"\n \n end", "def create_project_snapshot_post_with_http_info(create_project_snapshot_param, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: SnapshotApi.create_project_snapshot_post ...\"\n end\n # verify the required parameter 'create_project_snapshot_param' is set\n if @api_client.config.client_side_validation && create_project_snapshot_param.nil?\n fail ArgumentError, \"Missing the required parameter 'create_project_snapshot_param' when calling SnapshotApi.create_project_snapshot_post\"\n end\n # resource path\n local_var_path = \"/createProjectSnapshot\"\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(create_project_snapshot_param)\n auth_names = ['basicAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SnapshotApi#create_project_snapshot_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def check_response!(response, object_name)\n if response.status.success?\n puts \" - Created #{object_name}\"\n else\n puts \" - Failed to create #{object_name}\"\n exit 1\n end\nend", "def create_snapshot(vmId, description=\"New Snapshot\")\n @logger.warn 'DEPRECATION WARNING: use [create,revert]_vapp_snapshot instead.'\n create_snapshot_action(vmId, description, :vapp)\n end", "def create_at_launch?\n volume_id.to_s.empty? && (not snapshot_id.to_s.empty?)\n end" ]
[ "0.6959942", "0.67721385", "0.65424186", "0.6512461", "0.64462155", "0.64253855", "0.63869953", "0.6346291", "0.63259506", "0.60574883", "0.6020189", "0.6013806", "0.5990513", "0.58852404", "0.5823208", "0.57886815", "0.5770304", "0.57429475", "0.5702567", "0.5682292", "0.5607317", "0.5555903", "0.5547147", "0.5516564", "0.5499794", "0.54948336", "0.54800165", "0.5455303", "0.54308003", "0.5418843", "0.5357314", "0.53386426", "0.53036684", "0.5266476", "0.5260899", "0.52562064", "0.52298373", "0.5225456", "0.5208672", "0.5185995", "0.51792383", "0.51765823", "0.51724267", "0.51639295", "0.51486975", "0.51174533", "0.5106861", "0.5093298", "0.50908947", "0.50898695", "0.50824946", "0.50726444", "0.50592935", "0.50464815", "0.5044047", "0.5024008", "0.50102764", "0.49818975", "0.49800742", "0.49743313", "0.4970054", "0.49630857", "0.49568254", "0.49545807", "0.49425197", "0.4930139", "0.49294984", "0.49259615", "0.49232653", "0.49210736", "0.49188754", "0.49084538", "0.4897139", "0.4894121", "0.4891756", "0.48908517", "0.489008", "0.48805726", "0.48677692", "0.48667303", "0.4866627", "0.48656005", "0.48648533", "0.48606762", "0.4838625", "0.48372182", "0.48366043", "0.48349732", "0.48328185", "0.4821713", "0.4820971", "0.48100713", "0.4806753", "0.479654", "0.47915724", "0.4789602", "0.47836748", "0.47805843", "0.47549263", "0.47515193" ]
0.7413599
0
GET /discipline_sections GET /discipline_sections.json
def index @discipline_sections = DisciplineSection.all end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n course = Course.find(params[:course_id])\n sections = course.sections.all\n render json: sections.order(:id)\n end", "def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end", "def get_sections (subdomain,course_id)\n token = get_token\n courses = get_all_pages(\n token,\n \"https://#{subdomain}.instructure.com/api/v1/courses/#{course_id}/sections\"\n )\n end", "def set_discipline_section\n @discipline_section = DisciplineSection.find(params[:id])\n end", "def get_exam_sections(user_id, course_id, exam_id)\r\n get(Path::USERS_COURSES_EXAMS_SECTIONS % [user_id, course_id, exam_id])\r\n end", "def sections\n respond_with @page.sections\n end", "def sections\n respond_with @page.sections\n end", "def index\n @disciplines = Discipline.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @disciplines }\n end\n end", "def index\n @sections = params[:path].nil? ? Section.all : Section.where(path: params[:path])\n\n respond_to do |format|\n format.html { render html: @sections }\n format.json { render json: @sections }\n end\n end", "def show\n @sections = @course.sections.all.to_a\n end", "def list_sections\n \n end", "def show\n @sections = Section.find(params[:id])\n end", "def index\n #@sections = Section.find(params[:course_id])\n #@sections = Section.all\n end", "def show\n @discipline = Discipline.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @discipline }\n end\n end", "def course_sections\n ['1', '2']\n end", "def index\n @disciplines = Discipline.all\n #respond_to do |format|\n # format.json { render json: @disciplines, status: :ok }\n #end\n #render json: @disciplines, status: :ok\n respond_with @disciplines\n end", "def show\n @discipline = Discipline.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @discipline }\n end\n end", "def index\n @menu = Menu.find(params[:menu_id])\n @sections = @menu.sections\n render json: SectionSerializer.new(@sections)\n end", "def sections\n result = @nsx_client.get(@url_sections)\n result['results']\n end", "def index\n @disciplines = Discipline.paginate(:page => params[:page], per_page: 30)\n @number = Discipline.count\n respond_to do |format|\n format.html\n format.json { render :json => Discipline.all.to_json(include: :department) }\n end\n end", "def index\n @disciplines = Discipline.all\n end", "def index\n @disciplines = Discipline.all\n end", "def show\n #render json: @discipline\n respond_with @discipline\n end", "def subsections\n Section.where(parent_id: id)\n end", "def show\n @sections = Section.where(\"course_id = ?\", params[:course_id])\n\n end", "def show\r\n @section = Section.find_by_id(params[:id])\r\n @lesson = @section.lesson\r\n @activities = @section.activities\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @section }\r\n end\r\n end", "def index\n @sections = Section.all\n end", "def index\n @sections = Section.all\n end", "def index\n @sections = Section.all\n end", "def index\n @sections = Section.all\n end", "def index\n @sections = Section.all\n end", "def index\n @sections = Section.all\n end", "def index\n @sections = Section.all\n end", "def show\n @discipline = Discipline.find(params[:id])\n\n respond_with @discipline\n end", "def show\n if !params.has_key?(:section)\n redirect_to courses_path and return\n end\n\n @course = Course.find(params[:id])\n authorize! :read, @course\n @section = Section.find(params[:section])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end", "def sections(project_id, suite_id)\n get(\"get_sections/#{project_id}&suite_id=#{suite_id}\")\n end", "def getEnrollmentsInSection(sid)\r\n\turi = sprintf(\"/api/v1/sections/%d/enrollments?type[]=StudentEnrollment&per_page=999\", sid)\r\n\tenrollments = $canvas.get(uri)\r\n\treturn enrollments\r\nend", "def getEnrollmentsInSection(sid)\r\n\turi = sprintf(\"/api/v1/sections/%d/enrollments?type[]=StudentEnrollment&per_page=999\", sid)\r\n\tenrollments = $canvas.get(uri)\r\n\treturn enrollments\r\nend", "def index\n @sections = Section.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sections }\n end\n end", "def sections\n temp_sections = []\n if @section_ids.count > 0\n @section_ids.each do |section_id|\n temp_sections.push @client.section(@org_id, section_id)\n end\n end\n return temp_sections\n end", "def list_sections(opts = {})\n data, _status_code, _headers = list_sections_with_http_info(opts)\n data\n end", "def index\n authorize! :read, Course\n\n if is_student?\n @course_sections = Course.find_student_courses(current_user.id)\n else\n @course_sections = Course.find_professor_courses(current_user.id)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end", "def index\n @matrix = CourseMatrix.find(params[:course_matrix_id])\n @matrix_disciplines = MatrixDiscipline.where(:matrix_id => @matrix.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @matrix_disciplines }\n end\n end", "def show\n @section = Section.find(params[:id]) \t\n @nav_sections = Section.where(scenario_id: @section.scenario_id).order(:order)\n @inquests = Inquest.where(section_id: params[:id]).order(:order)\n @scenario = Scenario.where(id: @section.scenario_id)[0]\n end", "def sections\n @sections.values\n end", "def scubooks\n sections = Section.all\n render json: sections\n end", "def show\r\n @disciplines_study = DisciplinesStudy.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @disciplines_study }\r\n end\r\n end", "def show\n @section = Section.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section }\n end\n end", "def show\n @section = Section.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section }\n end\n end", "def show\n @section = Section.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section }\n end\n end", "def index\n @sections=Section.all\n end", "def show\n @encyclopaedia = Encyclopaedia.find(params[:id])\n @sections = @encyclopaedia.sections.all\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @encyclopaedia}\n end\n end", "def index\n if current_user.has_role? :admin\n @sectionalizations = Sectionalization.all\n else\n @classroom = Classroom.find(session[:classroom_id])\n @sectionalizations = Sectionalization.where(classroom_id: @classroom.id)\n session[:sectionalization_id] = nil\n end\n end", "def discipline_section_params\n params.require(:discipline_section).permit(:discipline_type, :section_name, :section_type, :weight, :min_score, :max_score, :require_type, :attenuation_constant, :optimal_time, :limit_time, :discipline_id, :community_id)\n end", "def courses_json\n raise Exceptions::EducatorNotAuthorized unless current_educator.districtwide_access\n courses = Course.all\n .where(school_id: @school.id)\n .includes(sections: :students)\n\n courses_json = courses.as_json({\n :only => [:id, :course_number, :course_description],\n :include => {\n :sections => {\n :only => [:id, :section_number, :term_local_id, :schedule, :room_number],\n :include => {\n :students => {\n :only => [:id, :grade, :date_of_birth],\n :include => {\n :school => {\n :only => [:id, :name]\n }\n }\n }\n }\n }\n }\n })\n\n render json: {\n courses: courses_json,\n school: @school.as_json(only: [:id, :name])\n }\n end", "def show\n @matrix_discipline = MatrixDiscipline.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @matrix_discipline }\n end\n end", "def index\n @studentsections = Studentsection.all\n end", "def show\n @section_category = SectionCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section_category }\n end\n end", "def show\n @discipline = Discipline.find(params[:discipline_id])\n @lecturer = @discipline.lecturers.find(params[:id])\n end", "def sections\n @pages.collect { |p| p.sections }.flatten\n end", "def sell_shop_sections (params={})\r\n url = api_url \"/sell/shop/sections\"\r\n req = request_params(params)\r\n\r\n feed_or_retry do\r\n RestClient.get url, req\r\n end \r\n end", "def sections\n parsed {\n @sections\n }\n end", "def load_sections(solution_to_load = nil, show_previews = false)\n\n user = User.find session[:user]\n plan = user.semesters.find(params[:id]).course_plan\n semester = Semester.find(params[:id]);\n courses = semester.cis_courses\n\n if solution_to_load\n plan.cis_sections.delete plan.cis_sections\n plan.cis_sections.concat session[:solution][solution_to_load]\n end\n\n # previews stuff\n npreviews = 6\n @solutions = session[:solution]\n\n @total_width = 100\n @total_height = 100\n padding_horiz = 5\n padding_vert = 5\n ndays = 6\n nhours = 15\n @start_hour = 8\n\n @seconds_per_pixel = nhours * 60 * 60 / (@total_height - 2 * padding_vert)\n\n @width = (@total_width - 2 * padding_horiz)/ ndays\n\n @day_left = {\n 'M' => 0,\n 'T' => @width,\n 'W' => @width * 2,\n 'R' => @width * 3,\n 'F' => @width * 4,\n 'S' => @width * 5,\n }\n\n if !session[:generator_error] && (!session[:solution] || session[:solution].length == 0)\n session[:generator_error] = 'No possible schedules (Click here to close).'\n end\n\n render :update do |page|\n if solution_to_load\n page.replace_html 'times_row', :partial => 'times_row', :locals => {:semester => semester}\n courses.each do |course|\n if course.sections_for_semester(semester) && course.sections_for_semester(semester).length != 0\n page.replace_html \"sects_#{semester.id}_#{course.id}\", :partial => 'section_choice', :collection => course.sections_for_semester(semester), :locals => {:semester => semester}\n end\n end\n else\n if session[:generator_error]\n page.replace_html 'generator_error', session[:generator_error]\n else\n page.replace_html 'previews_list', :partial => 'solution', :collection => @solutions[session[:marker], npreviews]\n end\n end\n if show_previews\n page.visual_effect :toggle_blind, 'previews_window'\n end\n end\n end", "def index\n @lab_sections = LabSection.all\n end", "def sections=(value)\n @sections = value\n end", "def section\n return @section if @section\n\n resp = HTTP\n .headers(authorization: \"Bearer #{access_token[:access_token]}\")\n .get(LIST_SECTIONS_ENDPOINT % notebook[:id], params: {\n select: 'id,name',\n filter: \"name eq '#{Config[:section]}'\"\n })\n if resp.code.to_s.start_with? '2'\n json = response_body(resp)\n @section = JSON.parse(json, symbolize_names: true)[:value].first\n end\n return @section\n end", "def index\n @community_sections = CommunitySection.all\n end", "def index\n @section_instructors = SectionInstructor.all\n end", "def get_students\n @course = Course.find(params[:course_id])\n\n render json: @course.students\n end", "def sections\n return @sections\n end", "def index\n @sections = Section.order(\"position asc\")\n\n authorize Section\n end", "def get_sections(request)\n data, _status_code, _headers = get_sections_with_http_info(request)\n request_token if _status_code == 401\n data\n end", "def create\n @discipline_section = DisciplineSection.new(discipline_section_params)\n respond_to do |format|\n if @discipline_section.save\n #format.html { redirect_to @discipline_section, notice: 'Discipline section was successfully created.' }\n #format.json { render :show, status: :created, location: @discipline_section }\n format.js { render('discipline_sections/create')}\n else\n #raise @discipline_section.errors.inspect\n #format.html { render :new }\n #format.json { render json: @discipline_section.errors, status: :unprocessable_entity }\n format.js { render ('discipline_sections/error')}\n end\n end\n end", "def show\n @discipline_type = DisciplineType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @discipline_type }\n end\n end", "def discipline_params\n params[:discipline]\n end", "def show\n begin\n @course = Course.find(params[:id])\n raise if @course.nil?\n \n conditions = [\"course_id = ?\",@course.id]\n @holes = Hole.find(:all, :conditions => conditions)\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n rescue\n render :layout => 'error', :template => 'errors/error'\n end\n end", "def subsections\n return suite.sections.select do |sect|\n sect.parent_id == data.id\n end\n end", "def show\n @menu_section = MenuSection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @menu_section }\n end\n end", "def index\n @section_categories = SectionCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @section_categories }\n end\n end", "def show\n @curriculum = Curriculum.find(params[:id])\n @curriculum_disciplines = @curriculum.curriculum_disciplines.by_module.paginate :page => params[:page]\n\n respond_with @curriculum\n end", "def show\n @section = Section.includes(:profile).find(params[:id])\n # @teachers = @section.teachers.page(params[:page])\n @users = @section.students.page(params[:page])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section }\n end\n end", "def section_courses\n all_sections = sections.to_a.concat(sections_as_student).uniq\n\n # In the future we may want to make it so that if assigned a script, but that\n # script has a default course, it shows up as a course here\n all_sections.map(&:course).compact.uniq\n end", "def index\n @disciplines = Discipline.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:per_page => 10, :page =>params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @disciplines }\n end\n end", "def show\n raise Exceptions::EducatorNotAuthorized unless current_educator.districtwide_access\n educator = Educator.find(params[:id])\n render json: educator.as_json({\n :only => [\n :id,\n :email,\n :full_name,\n :staff_type,\n :restricted_to_sped_students,\n :restricted_to_english_language_learners,\n :can_view_restricted_notes,\n :schoolwide_access,\n :districtwide_access,\n :grade_level_access,\n :admin\n ],\n :methods => [:labels],\n :include => {\n :school => { :only => [:id, :name] },\n :sections => {\n :only => [:id, :section_number],\n :methods => [:course_description]\n },\n :homeroom => { :only => [:id, :name] }\n }\n })\n end", "def index\n @survey_sections = SurveySection.page(params[:page]).per(100)\n end", "def index\n @sections = @page.sections.sorted\n end", "def index\n @sections = case current_user.rc\n when 'EA'\n Section.includes(:profile).order('profiles.firstname').page(params[:page])\n when 'IA','EO'\n current_user.sections.includes(:profile).order('profiles.firstname').page(params[:page])\n when 'MOE'\n current_user.sections.includes(:profile).order('profiles.firstname').page(params[:page])\n when 'CR'\n current_user.sections.includes(:profile).order('profiles.firstname').page(params[:page])\n when 'ET'\n current_user.center.sections.includes(:profile).order('profiles.firstname').page(params[:page])\n end\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sections }\n end\n end", "def disciplines_for(discipline)\n if discipline\n [Discipline[discipline]]\n else\n #alphere this is causing nil discipline error in UpcomingEvents.find_all\n #[Discipline[:road], Discipline[:mountain_bike], Discipline[:bmx], Discipline[:track], Discipline[:cyclocross]]\n #works: [Discipline[:road]]\n disciplines = Array.new\n Discipline.find_all_names.each do | name |\n disciplines << (Discipline[name.to_sym]) unless name.to_s == ''\n end\n disciplines\n end\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def parse_sections(url, semester)\n # Parse with Nokogiri\n page = Nokogiri::HTML(open(url))\n course_divs = page.search(\"div.course-sections\")\n section_array = []\n\n # for each of the courses on the page\n course_divs.each do |course_div|\n course_id = course_div.attr('id')\n # for each section of the course\n course_div.search(\"div.section\").each do |section|\n # add section to array to add\n instructors = section.search('span.section-instructors').text.gsub(/\\t|\\r\\n/,'').encode('UTF-8', :invalid => :replace).split(',').map(&:strip)\n dept = course_id.match(/^([A-Z]{4})\\d{3}[A-Z]?$/)[1]\n\n # add course and department to professor object for each instructor\n profs = []\n instructors.each do |x|\n if x != 'Instructor: TBA'\n professor_name = x.squeeze(' ')\n profs << professor_name\n end\n end\n\n meetings = []\n section.search('div.class-days-container div.row').each do |meeting|\n start_time = meeting.search('span.class-start-time').text\n end_time = meeting.search('span.class-end-time').text\n\n meetings << {\n days: meeting.search('span.section-days').text,\n start_time: start_time,\n end_time: end_time,\n start_seconds: time_to_int(start_time),\n end_seconds: time_to_int(end_time),\n building: meeting.search('span.building-code').text,\n room: meeting.search('span.class-room').text,\n classtype: meeting.search('span.class-type').text || \"Lecture\"\n }\n end\n number = section.search('span.section-id').text.gsub(/\\s/, '')\n open_seats = section.search('span.open-seats-count').text\n waitlist = section.search('span.waitlist-count').text\n section_array << {\n section_id: \"#{course_id}-#{number}\",\n course_id: course_id,\n number: number,\n instructors: profs,\n seats: section.search('span.total-seats-count').text,\n semester: semester,\n meetings: meetings,\n open_seats: open_seats,\n waitlist: waitlist\n }\n end\n end\n\n return section_array\nend", "def get_page\n render_page_sections_json\n end", "def semester\n return Section.where(semester_id: self.id)\n end", "def index\n @sections = Section.all.paginate(:page => params[:page], :per_page => 100)\n end", "def index\r\n if current_user.admin?\r\n @dashboard_disciplines = Discipline.includes(\"materials\")\r\n .paginate(:page => params[:page], :per_page => 10) \r\n else\r\n @dashboard_disciplines = current_user.disciplines \r\n .includes(\"materials\")\r\n .paginate(:page => params[:page], :per_page => 10) \r\n end\r\n end", "def show\n @section_heading = SectionHeading.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section_heading }\n end\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end" ]
[ "0.6833717", "0.67551106", "0.6714686", "0.6649415", "0.6637861", "0.6535805", "0.6535805", "0.65237075", "0.6502826", "0.64867806", "0.6430026", "0.6425808", "0.6383433", "0.6356851", "0.6354435", "0.6317796", "0.63121754", "0.6298093", "0.62769955", "0.6209616", "0.62046283", "0.62046283", "0.62005895", "0.61519325", "0.61204064", "0.61038756", "0.61004317", "0.61004317", "0.61004317", "0.61004317", "0.61004317", "0.61004317", "0.61004317", "0.60903037", "0.6027379", "0.6017794", "0.60169035", "0.60169035", "0.60098284", "0.5993826", "0.5980203", "0.59313494", "0.59252256", "0.5891183", "0.5889194", "0.58836514", "0.58608013", "0.58410513", "0.58410513", "0.58410513", "0.58402735", "0.5838902", "0.58171296", "0.58012456", "0.57951003", "0.5766773", "0.5737178", "0.57146263", "0.57117903", "0.57106906", "0.57024443", "0.56865305", "0.5683736", "0.56617314", "0.565212", "0.5649786", "0.5645479", "0.56284714", "0.56281257", "0.5611161", "0.5585102", "0.55662537", "0.55626255", "0.5549742", "0.55356383", "0.5526782", "0.55240214", "0.55185133", "0.5517501", "0.5515704", "0.55053115", "0.55051154", "0.5500984", "0.5495294", "0.54939985", "0.5493752", "0.5488626", "0.54810286", "0.5479004", "0.5479004", "0.54785275", "0.5472322", "0.546848", "0.5430165", "0.5425091", "0.5424793", "0.54217666", "0.54217666", "0.54217666", "0.54217666" ]
0.7759907
0
GET /discipline_sections/1 GET /discipline_sections/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @discipline_sections = DisciplineSection.all\n end", "def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end", "def show\n @discipline = Discipline.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @discipline }\n end\n end", "def show\n @discipline = Discipline.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @discipline }\n end\n end", "def set_discipline_section\n @discipline_section = DisciplineSection.find(params[:id])\n end", "def index\n course = Course.find(params[:course_id])\n sections = course.sections.all\n render json: sections.order(:id)\n end", "def index\n @disciplines = Discipline.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @disciplines }\n end\n end", "def show\n #render json: @discipline\n respond_with @discipline\n end", "def show\n @discipline = Discipline.find(params[:id])\n\n respond_with @discipline\n end", "def show\n @sections = Section.find(params[:id])\n end", "def show\r\n @section = Section.find_by_id(params[:id])\r\n @lesson = @section.lesson\r\n @activities = @section.activities\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @section }\r\n end\r\n end", "def index\n #@sections = Section.find(params[:course_id])\n #@sections = Section.all\n end", "def index\n @disciplines = Discipline.paginate(:page => params[:page], per_page: 30)\n @number = Discipline.count\n respond_to do |format|\n format.html\n format.json { render :json => Discipline.all.to_json(include: :department) }\n end\n end", "def index\n @disciplines = Discipline.all\n #respond_to do |format|\n # format.json { render json: @disciplines, status: :ok }\n #end\n #render json: @disciplines, status: :ok\n respond_with @disciplines\n end", "def index\n @sections = params[:path].nil? ? Section.all : Section.where(path: params[:path])\n\n respond_to do |format|\n format.html { render html: @sections }\n format.json { render json: @sections }\n end\n end", "def index\n @disciplines = Discipline.all\n end", "def index\n @disciplines = Discipline.all\n end", "def show\r\n @disciplines_study = DisciplinesStudy.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @disciplines_study }\r\n end\r\n end", "def show\n @matrix_discipline = MatrixDiscipline.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @matrix_discipline }\n end\n end", "def show\n if !params.has_key?(:section)\n redirect_to courses_path and return\n end\n\n @course = Course.find(params[:id])\n authorize! :read, @course\n @section = Section.find(params[:section])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n end", "def show\n @sections = @course.sections.all.to_a\n end", "def show\n @discipline_type = DisciplineType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @discipline_type }\n end\n end", "def show\n @section = Section.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section }\n end\n end", "def show\n @section = Section.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section }\n end\n end", "def show\n @section = Section.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section }\n end\n end", "def index\n @menu = Menu.find(params[:menu_id])\n @sections = @menu.sections\n render json: SectionSerializer.new(@sections)\n end", "def get_exam_sections(user_id, course_id, exam_id)\r\n get(Path::USERS_COURSES_EXAMS_SECTIONS % [user_id, course_id, exam_id])\r\n end", "def show\n @sections = Section.where(\"course_id = ?\", params[:course_id])\n\n end", "def get_sections (subdomain,course_id)\n token = get_token\n courses = get_all_pages(\n token,\n \"https://#{subdomain}.instructure.com/api/v1/courses/#{course_id}/sections\"\n )\n end", "def show\n @section_category = SectionCategory.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section_category }\n end\n end", "def sections\n respond_with @page.sections\n end", "def sections\n respond_with @page.sections\n end", "def list_sections\n \n end", "def show\n @section = Section.find(params[:id]) \t\n @nav_sections = Section.where(scenario_id: @section.scenario_id).order(:order)\n @inquests = Inquest.where(section_id: params[:id]).order(:order)\n @scenario = Scenario.where(id: @section.scenario_id)[0]\n end", "def course_sections\n ['1', '2']\n end", "def section\n return @section if @section\n\n resp = HTTP\n .headers(authorization: \"Bearer #{access_token[:access_token]}\")\n .get(LIST_SECTIONS_ENDPOINT % notebook[:id], params: {\n select: 'id,name',\n filter: \"name eq '#{Config[:section]}'\"\n })\n if resp.code.to_s.start_with? '2'\n json = response_body(resp)\n @section = JSON.parse(json, symbolize_names: true)[:value].first\n end\n return @section\n end", "def show\n @discipline = Discipline.find(params[:discipline_id])\n @lecturer = @discipline.lecturers.find(params[:id])\n end", "def index\n @sections = Section.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sections }\n end\n end", "def index\n @matrix = CourseMatrix.find(params[:course_matrix_id])\n @matrix_disciplines = MatrixDiscipline.where(:matrix_id => @matrix.id)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @matrix_disciplines }\n end\n end", "def show\n @section_heading = SectionHeading.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section_heading }\n end\n end", "def index\n @sections = Section.all\n end", "def index\n @sections = Section.all\n end", "def index\n @sections = Section.all\n end", "def index\n @sections = Section.all\n end", "def index\n @sections = Section.all\n end", "def index\n @sections = Section.all\n end", "def index\n @sections = Section.all\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def show\n @encyclopaedia = Encyclopaedia.find(params[:id])\n @sections = @encyclopaedia.sections.all\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @encyclopaedia}\n end\n end", "def show\n @curriculum = Curriculum.find(params[:id])\n @curriculum_disciplines = @curriculum.curriculum_disciplines.by_module.paginate :page => params[:page]\n\n respond_with @curriculum\n end", "def scubooks\n sections = Section.all\n render json: sections\n end", "def show\n @section_comment = SectionComment.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section_comment }\n end\n end", "def discipline_section_params\n params.require(:discipline_section).permit(:discipline_type, :section_name, :section_type, :weight, :min_score, :max_score, :require_type, :attenuation_constant, :optimal_time, :limit_time, :discipline_id, :community_id)\n end", "def show\n \n begin\n @section = @account.sections.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n @section = @account.sections.find_by_name(params[:id]) \n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @section }\n end\n end", "def show\n @menu_section = MenuSection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @menu_section }\n end\n end", "def sections\n result = @nsx_client.get(@url_sections)\n result['results']\n end", "def show\n begin\n @course = Course.find(params[:id])\n raise if @course.nil?\n \n conditions = [\"course_id = ?\",@course.id]\n @holes = Hole.find(:all, :conditions => conditions)\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @course }\n end\n rescue\n render :layout => 'error', :template => 'errors/error'\n end\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def index\n authorize! :read, Course\n\n if is_student?\n @course_sections = Course.find_student_courses(current_user.id)\n else\n @course_sections = Course.find_professor_courses(current_user.id)\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @courses }\n end\n end", "def create\n @discipline_section = DisciplineSection.new(discipline_section_params)\n respond_to do |format|\n if @discipline_section.save\n #format.html { redirect_to @discipline_section, notice: 'Discipline section was successfully created.' }\n #format.json { render :show, status: :created, location: @discipline_section }\n format.js { render('discipline_sections/create')}\n else\n #raise @discipline_section.errors.inspect\n #format.html { render :new }\n #format.json { render json: @discipline_section.errors, status: :unprocessable_entity }\n format.js { render ('discipline_sections/error')}\n end\n end\n end", "def getEnrollmentsInSection(sid)\r\n\turi = sprintf(\"/api/v1/sections/%d/enrollments?type[]=StudentEnrollment&per_page=999\", sid)\r\n\tenrollments = $canvas.get(uri)\r\n\treturn enrollments\r\nend", "def getEnrollmentsInSection(sid)\r\n\turi = sprintf(\"/api/v1/sections/%d/enrollments?type[]=StudentEnrollment&per_page=999\", sid)\r\n\tenrollments = $canvas.get(uri)\r\n\treturn enrollments\r\nend", "def subsections\n Section.where(parent_id: id)\n end", "def new\n @discipline = Discipline.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @discipline }\n end\n end", "def index\n @discipline_types = DisciplineType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @discipline_types }\n end\n end", "def show\n @time_section = TimeSection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_section }\n end\n end", "def index\n @sections=Section.all\n end", "def show\n @section_test = SectionTest.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section_test }\n end\n end", "def course_resource\n section = full.attributes[\"Section\"].try(:attributes)\n @course_resuorce ||= CourseResource.find [section[\"Year\"], section[\"Quarter\"], section[\"CurriculumAbbreviation\"], section[\"CourseNumber\"]].join(\",\") + \"/\" + section[\"SectionID\"]\n end", "def show\n @clinicalsection = Clinicalsection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clinicalsection }\n end\n end", "def index\n @lab_sections = LabSection.all\n end", "def show\n respond_to do |format|\n format.html { render html: @section }\n format.json { render json: @section }\n end\n end", "def show\n @discipline_class_exam_type = DisciplineClassExamType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @discipline_class_exam_type }\n end\n end", "def show\n @critic = Critic.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @critic }\n end\n end", "def show\n @conclusion = Conclusion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @conclusion }\n end\n end", "def show\n @study_course = StudyCourse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @study_course }\n end\n end", "def create\n @discipline = Discipline.new(discipline_params)\n respond_to do |format|\n if @discipline.save\n format.html { redirect_to management_disciplines_path }\n format.json { render :json => @discipline.to_json(include: :department), status: :created }\n else\n format.html { render :new }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @discipline = Discipline.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @discipline }\n end\n end", "def courses_json\n raise Exceptions::EducatorNotAuthorized unless current_educator.districtwide_access\n courses = Course.all\n .where(school_id: @school.id)\n .includes(sections: :students)\n\n courses_json = courses.as_json({\n :only => [:id, :course_number, :course_description],\n :include => {\n :sections => {\n :only => [:id, :section_number, :term_local_id, :schedule, :room_number],\n :include => {\n :students => {\n :only => [:id, :grade, :date_of_birth],\n :include => {\n :school => {\n :only => [:id, :name]\n }\n }\n }\n }\n }\n }\n })\n\n render json: {\n courses: courses_json,\n school: @school.as_json(only: [:id, :name])\n }\n end", "def show\n @course = @course_section.course\n end", "def index\n @disciplines = Discipline.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:per_page => 10, :page =>params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @disciplines }\n end\n end", "def show\n @section = Section.includes(:profile).find(params[:id])\n # @teachers = @section.teachers.page(params[:page])\n @users = @section.students.page(params[:page])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @section }\n end\n end", "def get_students\n @course = Course.find(params[:course_id])\n\n render json: @course.students\n end", "def index\n @studentsections = Studentsection.all\n end", "def show\n render json: @course\n end", "def show\n raise Exceptions::EducatorNotAuthorized unless current_educator.districtwide_access\n educator = Educator.find(params[:id])\n render json: educator.as_json({\n :only => [\n :id,\n :email,\n :full_name,\n :staff_type,\n :restricted_to_sped_students,\n :restricted_to_english_language_learners,\n :can_view_restricted_notes,\n :schoolwide_access,\n :districtwide_access,\n :grade_level_access,\n :admin\n ],\n :methods => [:labels],\n :include => {\n :school => { :only => [:id, :name] },\n :sections => {\n :only => [:id, :section_number],\n :methods => [:course_description]\n },\n :homeroom => { :only => [:id, :name] }\n }\n })\n end", "def index\n if current_user.has_role? :admin\n @sectionalizations = Sectionalization.all\n else\n @classroom = Classroom.find(session[:classroom_id])\n @sectionalizations = Sectionalization.where(classroom_id: @classroom.id)\n session[:sectionalization_id] = nil\n end\n end", "def get_page\n render_page_sections_json\n end", "def discipline_params\n params[:discipline]\n end", "def show\n render json: course\n end", "def show\n @colaboration = Colaboration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @colaboration }\n end\n end", "def index\n @section_categories = SectionCategory.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @section_categories }\n end\n end", "def show\n @title = \"Prima Lingua: #{@section.name}\"\n if params[:unit_id]\n @overview_unit = Unit.find(params[:unit_id])\n else\n @overview_unit = @section.lesson.unit\n end\n respond_to do |format|\n format.html { render_flex_layout }\n format.json { render :json => @section }\n end\n end", "def update\n respond_to do |format|\n if @discipline.update(discipline_params)\n format.html { redirect_to management_disciplines_path }\n format.json { render :json => @discipline.to_json(include: :department), status: :created }\n else\n format.html { render :edit }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @community_sections = CommunitySection.all\n end", "def show\n @assessment_course = AssessmentCourse.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @assessment_course }\n end\n end", "def section_by_id(section_id = @one_section_id)\n url = @url_sections + '/' + section_id\n @nsx_client.get(url)\n end" ]
[ "0.77392906", "0.704878", "0.6965042", "0.69634855", "0.6935452", "0.68402404", "0.6734015", "0.6661768", "0.6600624", "0.6562233", "0.65423656", "0.6511122", "0.6508988", "0.65064764", "0.64560604", "0.64074576", "0.64074576", "0.63547015", "0.63494515", "0.63456553", "0.63217455", "0.6316843", "0.6316674", "0.6316674", "0.6316674", "0.62449247", "0.6238035", "0.62347627", "0.6221067", "0.61966884", "0.6194054", "0.6194054", "0.61499566", "0.6132007", "0.6119494", "0.6118908", "0.61173606", "0.6115164", "0.609981", "0.60562474", "0.60496765", "0.60496765", "0.60496765", "0.60496765", "0.60496765", "0.60496765", "0.60496765", "0.5982673", "0.5982673", "0.5939046", "0.59375983", "0.5918157", "0.5911552", "0.5910052", "0.5877048", "0.5873749", "0.58712876", "0.5870611", "0.586791", "0.586791", "0.586791", "0.586791", "0.58652127", "0.58602303", "0.5830795", "0.5830795", "0.58237565", "0.58177257", "0.58126664", "0.580533", "0.5802259", "0.5801179", "0.5784318", "0.57807046", "0.57800126", "0.5776125", "0.5770427", "0.5758345", "0.574621", "0.57310015", "0.57278305", "0.5713881", "0.57117856", "0.57109946", "0.5708465", "0.5695793", "0.5694381", "0.56933856", "0.56892085", "0.5682887", "0.5677194", "0.5666254", "0.56631315", "0.56595516", "0.5650665", "0.5649754", "0.56440085", "0.5643208", "0.5637409", "0.5628756", "0.561456" ]
0.0
-1
POST /discipline_sections POST /discipline_sections.json
def create @discipline_section = DisciplineSection.new(discipline_section_params) respond_to do |format| if @discipline_section.save #format.html { redirect_to @discipline_section, notice: 'Discipline section was successfully created.' } #format.json { render :show, status: :created, location: @discipline_section } format.js { render('discipline_sections/create')} else #raise @discipline_section.errors.inspect #format.html { render :new } #format.json { render json: @discipline_section.errors, status: :unprocessable_entity } format.js { render ('discipline_sections/error')} end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @discipline_sections = DisciplineSection.all\n end", "def set_discipline_section\n @discipline_section = DisciplineSection.find(params[:id])\n end", "def create\n @section = Section.new(params[:section])\n\n Course.find(params[:section][:add_section]).sections << @section if params[:section][:add_section]\n\n respond_to do |format|\n if @section.save\n format.html { redirect_to @section, notice: 'Section was successfully created.' }\n format.json { render json: @section, status: :created, location: @section }\n else\n format.html { render action: \"new\" }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def discipline_section_params\n params.require(:discipline_section).permit(:discipline_type, :section_name, :section_type, :weight, :min_score, :max_score, :require_type, :attenuation_constant, :optimal_time, :limit_time, :discipline_id, :community_id)\n end", "def create\n @discipline = Discipline.new(discipline_params)\n respond_to do |format|\n if @discipline.save\n format.html { redirect_to management_disciplines_path }\n format.json { render :json => @discipline.to_json(include: :department), status: :created }\n else\n format.html { render :new }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def createSection(section)\r\n uri = sprintf(\"/api/v1/courses/%d/sections/\", $tocid) \r\n \r\n dbg(\"POST #{uri}\")\r\n dbg(\"course_section[name]=#{section[\"name\"]}\")\r\n newSection = $canvas.post(uri, {'course_section[name]' => section[\"name\"]})\r\n dbg(newSection)\r\n return newSection\r\nend", "def create # rubocop:disable Metrics/AbcSize\n @discipline = Discipline.new(discipline_params)\n\n respond_to do |format|\n if @discipline.save\n current_user.notebook.disciplines << @discipline\n format.html { redirect_to @discipline, notice: 'Discipline was successfully created.' }\n format.json { render :show, status: :created, location: @discipline }\n else\n format.html { render :new }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @discipline = Discipline.new(discipline_params)\n\n respond_to do |format|\n if @discipline.save\n format.html { redirect_to @discipline, notice: 'Discipline was successfully created.' }\n format.json { render :show, status: :created, location: @discipline }\n else\n format.html { render :new }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @section = Section.new(section_params)\n if @section.save\n render json: SectionSerializer.new(@section)\n else\n render json: @section.errors, status: :unprocessable_entity\n end\n end", "def create\n @section = Section.new(section_params)\n\n respond_to do |format|\n if @section.save\n # Add section to course.\n if params.has_key?('course_id')\n course_id = params['course_id']\n add_section_to_course(@section, course_id)\n end\n \n format.js { render \"\", json: @section }\n else\n format.js { render json: @section.errors, status: :unprocessable_entity }\n end\n # if add_section_to_course(@section, course_id)\n # # Use the sections helper to create the relation between the section and its course.\n # format.html { redirect_to Course.find(course_id), notice: 'Section was successfully created.' }\n # format.json { render :show, status: :created, location: @section }\n # else\n # format.html { render :new }\n # format.json { render json: @section.errors, status: :unprocessable_entity }\n # end\n end\n end", "def create\n @discipline = Discipline.new(params[:discipline])\n \n respond_to do |format|\n if @discipline.save\n format.html { redirect_to @discipline, :notice => t('selecao_admin.flash_messages.successfully_created', :model => @discipline.class.model_name.human) }\n format.json { render :json => @discipline, :status => :created, :location => @discipline }\n format.js\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @discipline.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end", "def create\n @discipline = Discipline.new(params[:discipline])\n @discipline.course = @course\n @discipline.version = 1\n @discipline.save\n \n respond_with @discipline, :location => [:admin, @course, @discipline]\n end", "def create\n @subdiscipline = Subdiscipline.new(subdiscipline_params)\n respond_to do |format|\n if @subdiscipline.save\n format.html { redirect_to @subdiscipline, notice: 'Subdiscipline was successfully created.' }\n format.json { render :show, status: :created, location: @subdiscipline }\n else\n format.html { render :new }\n format.json { render json: @subdiscipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @section = Section.new(section_params)\n\n if @section.save\n render :show, status: :created, location: @section\n else\n render json: @section.errors, status: :unprocessable_entity\n end\n end", "def create\n @survey_section = SurveySection.new(survey_section_params)\n\n respond_to do |format|\n if @survey_section.save\n format.html { redirect_to @survey_section, notice: 'Survey section was successfully created.' }\n format.json { render :show, status: :created, location: @survey_section }\n else\n format.html { render :new }\n format.json { render json: @survey_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @section = Section.new(section_params)\n @course = Course.find(params[:course_id])\n @section.course_id = @course.id\n respond_to do |format|\n if @section.save\n format.html { redirect_to course_section_url(@section.course_id, @section), notice: 'Section was successfully created.' }\n format.json { render :show, status: :created, location: @section }\n format.js {}\n else\n format.html { render :new }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n format.js {}\n end\n end\n end", "def create\n @discipline = Discipline.new(discipline_params)\n @discipline.users_id = current_user.id\n\n respond_to do |format|\n if @discipline.save\n @discipline.codigo = \"DISC-%04d\" % [@discipline.id]\n @discipline.save\n if params[:anexos]\n\n params[:anexos].each { |anx|\n @discanexo = Discanexo.new\n @discanexo.anexo = anx\n @discanexo.Discipline_id = @discipline.id\n @discanexo.save\n }\n end\n flash[:success] = \"Disciplina cadastrada com sucesso.\"\n format.html { redirect_to @discipline}\n format.json { render :show, status: :created, location: @discipline }\n else\n format.html { render :new }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @discipline = Discipline.new(params[:discipline])\n @discipline.discipline_id = UUIDTools::UUID.timestamp_create().to_s\n\n respond_to do |format|\n if @discipline.save\n format.html { redirect_to @discipline, notice: t(:discipline_successfully_created) }\n format.json { render json: @discipline, status: :created, location: @discipline }\n else\n format.html { render action: \"new\" }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @section = Section.new(section_params)\n @section.title = @section.title || \"\"\n\n document = @section.document\n @section.order = 1\n unless document.sections.blank?\n @section.order = document.sections.last.order + 1\n end\n\n @section.visibility = document.visibility\n @section.status = document.status\n\n update_user_attribution @section, true\n\n respond_to do |format|\n if @section.save\n format.html { redirect_to @section, notice: 'Section was successfully created.' }\n format.any(:json, :js) { render :show, status: :created, location: @section }\n else\n puts @section.errors.full_messages\n format.html { render :new }\n format.any(:json, :js) { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @course_section = CourseSection.new(course_section_params)\n\n respond_to do |format|\n if @course_section.save\n format.html { redirect_to @course_section, notice: 'Course section was successfully created.' }\n format.json { render action: 'show', status: :created, location: @course_section }\n else\n format.html { render action: 'new' }\n format.json { render json: @course_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize! :manage, CourseSection\n @course_section = CourseSection.new(course_section_params)\n\n respond_to do |format|\n if @course_section.save\n format.html { redirect_to @course_section, notice: 'Course section was successfully created.' }\n format.json { render :show, status: :created, location: @course_section }\n else\n format.html { render :new }\n format.json { render json: @course_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @studentsection = Studentsection.new(studentsection_params)\n\n respond_to do |format|\n if @studentsection.save\n format.html { redirect_to @studentsection, notice: 'Studentsection was successfully created.' }\n format.json { render :show, status: :created, location: @studentsection }\n else\n format.html { render :new }\n format.json { render json: @studentsection.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @section = Section.new(params[:section])\n\n respond_to do |format|\n if @section.save\n format.html { redirect_to @section, notice: 'Section was successfully created.' }\n format.json { render json: @section, status: :created, location: @section }\n else\n format.html { render action: \"new\" }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n authorize! :manage, Course\n @course = Course.new(course_params)\n @course.course_sections.each do |course_section|\n course_section.name = \"#{@course.name} #{course_section.grade_section.name}\"\n end\n\n respond_to do |format|\n if @course.save\n format.html { redirect_to @course, notice: 'Course was successfully created.' }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render :new }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @form_section = FormSection.new(form_section_params)\n @form_section.save\n respond_with( [ :admin, @form_section] )\n end", "def creat_discipline(json)\n # Create Discipline\n discipline = Discipline.new(:name => json[\"disciplin\"], :year => \"1.1.2013\")\n # save query in vars for Discipline joins\n sp = Sport.find_by_name(json[\"disc_group\"])\n cat = Category.find_by_name(json[\"category\"])\n ge = Gender.find_by_sex(json[\"gender\"])\n # when no unit set\n if json[\"req_unit\"].nil?\n un = Unit.find_by_name(\"bestanden\")\n else\n un = Unit.find_by_name(json[\"req_unit\"])\n end\n # joins Diciplines\n sp.disciplines << discipline\n cat.disciplines << discipline\n un.disciplines << discipline\n ge.disciplines << discipline\n # save Discipline\n discipline.save\nend", "def create\n @course = Course.new(course_params)\n\n #section_chunks = get_chunks(params)\n sections = JSON.parse(params['sections'])\n\n # The course has been created by the signed-in user.\n @course.user_id = current_user.id\n respond_to do |format|\n if @course.save\n # Save the course's subcomponents to the course.\n update_section_chunks(sections)\n\n format.html { redirect_to @course }\n format.json { render :show, status: :created, location: @course }\n else\n format.html { render new_course_path }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @section = Section.new(section_params)\n\n respond_to do |format|\n if @section.save\n format.html { redirect_to @section,\n notice: 'Section was successfully created.' }\n format.json { render :show,\n status: :created, location: @section }\n else\n format.html { render :new }\n format.json { render json: @section.errors,\n status: :unprocessable_entity }\n end\n end\n end", "def create\n @section = Section.new(section_params)\n\n respond_to do |format|\n if @section.save\n format.html { redirect_to @section, notice: 'Section was successfully created.' }\n format.json { render :show, status: :created, location: @section }\n else\n format.html { render :new }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @section = Section.new(section_params)\n\n respond_to do |format|\n if @section.save\n format.html { redirect_to @section, notice: 'Section was successfully created.' }\n format.json { render :show, status: :created, location: @section }\n else\n format.html { render :new }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @section = Section.new(section_params)\n\n respond_to do |format|\n if @section.save\n format.html { redirect_to @section, notice: 'Section was successfully created.' }\n format.json { render :show, status: :created, location: @section }\n else\n format.html { render :new }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @section = Section.new(section_params)\n\n respond_to do |format|\n if @section.save\n format.html { redirect_to @section, notice: 'Section was successfully created.' }\n format.json { render :show, status: :created, location: @section }\n else\n format.html { render :new }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @disciplines = Discipline.all\n\n render json: @disciplines\n end", "def create\n if current_user.has_role? :admin\n @sectionalization = Sectionalization.new(sectionalization_params)\n\n respond_to do |format|\n if @sectionalization.save\n format.html { redirect_to @sectionalization, notice: 'Sectionalization was successfully created.' }\n format.json { render :show, status: :created, location: @sectionalization }\n else\n format.html { render :new }\n format.json { render json: @sectionalization.errors, status: :unprocessable_entity }\n end\n end\n else\n @sectionalization = Sectionalization.new(sectionalization_params)\n @sectionalization.user_id = current_user.id\n @sectionalization.classroom_id = session[:classroom_id]\n respond_to do |format|\n if @sectionalization.save\n format.html { redirect_to @sectionalization, notice: 'Sectionalization was successfully created.' }\n format.json { render :show, status: :created, location: @sectionalization }\n else\n format.html { render :new }\n format.json { render json: @sectionalization.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def create\r\n @section = Section.new(params[:section])\r\n\r\n respond_to do |format|\r\n if @section.save\r\n format.html { redirect_to @section, notice: 'Section was successfully created.' }\r\n format.json { render json: @section, status: :created, location: @section }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @section.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n @section = Section.new(section_params)\n\n respond_to do |format|\n if @section.save\n format.html { redirect_to @section, notice: 'Section was successfully created.' }\n format.json { render json: @section }\n else\n format.html { render action: 'new' }\n format.json { render json: ErrorSerializer.serialize(@section.errors), status: :unprocessable_entity }\n end\n end\n end", "def section_params\n params.require(:section).permit(:start_date, :end_date, :meeting_scheme, :meeting_time, :section_hours, :course_id)\n end", "def update\n respond_to do |format|\n if @discipline_section.update(discipline_section_params)\n format.html { redirect_to @discipline_section, notice: 'Раздел дисциплины был успешно обновлен' }\n format.json { render :show, status: :ok, location: @discipline_section }\n else\n format.html { render :edit }\n format.json { render json: @discipline_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \t@section_comment = SectionComment.new\n @section_comment.section_id = params[:section_comment][:section_id]\n\t\t@section_comment.teacher_id = params[:section_comment][:teacher_id]\n\t\t@section_comment.period = params[:section_comment][:period]\n @section_comment.comment = params[:section_comment][:comment]\n\n respond_to do |format|\n if @section_comment.save\n format.html { redirect_to schedules_path, notice: 'Section comment was successfully created.' }\n format.json { render json: @section_comment, status: :created, location: @section_comment }\n else\n format.html { render action: \"new\" }\n format.json { render json: @section_comment.errors, status: :unprocessable_entity }\n end\n end\n end", "def associate\n @discipline = Discipline.find(params[:discipline_id])\n\n respond_to do |format|\n current_user.notebook.disciplines << @discipline\n format.js\n end\n end", "def create\n @post_section = PostSection.new(post_section_params)\n\n respond_to do |format|\n if @post_section.save\n format.html { redirect_to @post_section, notice: 'Post section was successfully created.' }\n format.json { render :show, status: :created, location: @post_section }\n else\n format.html { render :new }\n format.json { render json: @post_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @discipline.update(discipline_params)\n format.html { redirect_to management_disciplines_path }\n format.json { render :json => @discipline.to_json(include: :department), status: :created }\n else\n format.html { render :edit }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @section_instructor = SectionInstructor.new(section_instructor_params)\n\n respond_to do |format|\n if @section_instructor.save\n format.html { redirect_to @section_instructor, notice: 'Section instructor was successfully created.' }\n format.json { render :show, status: :created, location: @section_instructor }\n else\n format.html { render :new }\n format.json { render json: @section_instructor.errors, status: :unprocessable_entity }\n end\n end\n end", "def discipline_params\n params.require(:discipline).permit(:nome, :cargahoraria, :Course_id, :users_id, :anexos, :disciplineMat, :senha)\n end", "def create\n @section = Section.new(:name => params[:value])\n @section.resume_id = params[:pk]\n\n if @section.save\n render json: { :results => true }\n else\n render json: { :results => false }\n end\n end", "def create\n @post = find_post\n @post_section = @post.sections.build(post_section_params)\n\n respond_to do |format|\n if @post_section.save\n format.html { redirect_to admin_post_section_url(@post, @post_section), notice: 'Section was successfully created.' }\n format.json { render :show, status: :created, location: admin_post_section_url(@post, @post_section) }\n else\n format.html { render :new }\n format.json { render json: @post_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @feedback = Feedback.new(feedback_params)\n @feedback.user_id = current_user.id\n @feedback.status_id = 2;\n sections = params[:sections]\n\n #puts \"Sections ######\"\n #puts sections\n\n respond_to do |format|\n if @feedback.save\n for section in sections\n feedbackSection = FeedbackSection.new\n feedbackSection.feedback_id = @feedback.id\n feedbackSection.question = section[\"question\"]\n feedbackSection.answer = section[\"answer\"]\n\n feedbackSection.rating = 0\n feedbackSection.question_type = 1\n feedbackSection.action_plan = ''\n feedbackSection.category = ''\n feedbackSection.save\n end\n\n format.html { redirect_to @feedback, notice: 'Feedback was successfully created.' }\n format.json { render :show, status: :created, location: @feedback }\n else\n format.html { render :new }\n format.json { render json: @feedback.errors, status: :unprocessable_entity }\n end\n end\n end", "def section_params\n params.require(:section).permit(:name, :description, :location_id, :interior_map)\n end", "def discipline_params\n params.require(:discipline).permit(:name, :field, :job_title, :abbreviation)\n end", "def studentsection_params\n params.require(:studentsection).permit(:studentsection)\n end", "def create\n @section = Section.new(section_params)\n\n authorize Section\n\n respond_to do |format|\n if @section.save\n format.html { redirect_to @section, notice: 'Section was successfully created.' }\n format.json { render :show, status: :created, location: @section }\n else\n @section_count = Section.count + 1\n\n format.html { render :new }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\nlogger.debug \"create curr_user: \" + current_user.inspect\n @discipline = Discipline.new(discipline_params)\n @discipline.creator_id = current_user\n @discipline.updater_id = current_user\nlogger.debug \"discipline: \"+@discipline.inspect\n \n if @discipline.save\n #respond_with @discipline\n render json: @discipline\n #format.html { redirect_to @discipline, notice: 'Discipline was successfully created.' }\n #format.json { render action: 'show', status: :created, location: @discipline }\n else\n respond_with @discipline.errors, status: :unprocessable_entity\n #format.html { render action: 'new' }\n #format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end", "def discipline_params\n params[:discipline]\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def create_new_section(title, options={})\n send_request('create_new_section', normalize_options(title, options))\n end", "def create\n @section = Section.new(params[:section])\n @section.page = @page\n\n respond_to do |format|\n if @section.save\n format.html { redirect_to @page, :notice => 'Section was successfully created.' }\n format.json { render :json => @section, :status => :created, :location => @section }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @section.errors, :status => :unprocessable_entity }\n end\n end\n end", "def subdiscipline_params\n params.require(:subdiscipline).permit(:name, :discipline_id, :description)\n end", "def discipline_params\n params.fetch(:discipline, {})\n end", "def create\n @section = Section.new(params[:section])\n \n @section.user_id=session[:userid]\n @section.subject_id=session[:subjectid]\n respond_to do |format|\n if @section.save\n format.html { redirect_to(@section, :notice => 'Section was successfully created.') }\n format.xml { render :xml => @section, :status => :created, :location => @section }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @section.errors, :status => :unprocessable_entity }\n end \n end\n \n end", "def create\n @section = Section.new(params[:section])\n\n respond_to do |format|\n if @section.save\n format.html { redirect_to(admin_sections_path, :notice => 'Section was successfully created.') }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @section.errors, :status => :unprocessable_entity }\n end\n end\n end", "def create\n @sections = Section.find(:all)\n @section = Section.new(params[:section])\n\n respond_to do |format|\n if @section.save\n flash[:notice] = 'Section was successfully created.'\n format.html { redirect_to(@section) }\n format.xml { render :xml => @section, :status => :created, :location => @section }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @section.errors, :status => :unprocessable_entity }\n end\n end\n end", "def sectionalization_params\n params.require(:sectionalization).permit(:user_id, :classroom_id, :name, :deleted_at)\n end", "def create\n @section = Section.new(section_params)\n\n respond_to do |format|\n if @section.save\n @section.check_index()\n form_wrapper = FormWrapper.find(@section.form_wrapper_id)\n format.html { redirect_to sections_section_path(form_wrapper), alert: I18n.t('activerecord.models.section.single') + I18n.t('helpers_locale.models.created') }\n format.json { render action: 'show', status: :created, location: @section }\n else\n format.html { render action: 'new' }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def section_params\n params.require(:section).permit(:course_id, :year_id, :term_id, :block_id)\n end", "def create\n @manage_section = Manage::Section.new(manage_section_params)\n\n respond_to do |format|\n if @manage_section.save\n format.html { redirect_to manage_compete_url(@compete), notice: 'Section was successfully created.' }\n format.json { render :show, status: :created, location: @manage_section }\n else\n format.html { render :new }\n format.json { render json: @manage_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @menu_section = MenuSection.new(params[:menu_section])\n\n respond_to do |format|\n if @menu_section.save\n format.html { redirect_to @menu_section, notice: 'Menu section was successfully created.' }\n format.json { render json: @menu_section, status: :created, location: @menu_section }\n else\n format.html { render action: \"new\" }\n format.json { render json: @menu_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @lab_section = LabSection.new(lab_section_params)\n\n respond_to do |format|\n if @lab_section.save\n format.html { redirect_to @lab_section, notice: 'Lab section was successfully created.' }\n format.json { render :show, status: :created, location: @lab_section }\n else\n format.html { render :new }\n format.json { render json: @lab_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def sections\n respond_with @page.sections\n end", "def sections\n respond_with @page.sections\n end", "def new\n @discipline = Discipline.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @discipline }\n end\n end", "def create\n @matrix = CourseMatrix.find(params[:course_matrix_id])\n @matrix_discipline = MatrixDiscipline.new(params[:matrix_discipline])\n @matrix_discipline.matrix_id = @matrix.id\n\n respond_to do |format|\n if @matrix_discipline.save\n format.html { redirect_to course_matrix_matrix_disciplines_path, :notice => 'Disciplina cadastrada na matriz com sucesso.' }\n format.json { render :json => @matrix_discipline, :status => :created, :location => @matrix_discipline }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @matrix_discipline.errors, :status => :unprocessable_entity }\n end\n end\n end", "def discipline_params\n params.require(:discipline).permit(:name, :label)\n end", "def new\n @discipline = Discipline.new\n \n respond_with @discipline\n end", "def course_section_params\n params.require(:course_section).permit(:name, :instructor_id)\n end", "def section_params\n params.require(:section).permit(:section,{:grade_ids => []})\n end", "def section_params\n params.require(:section).permit(:name, :teacher_id, :code, :lesson_id)\n end", "def sections=(value)\n @sections = value\n end", "def create\n @community_section = CommunitySection.new(community_section_params)\n\n respond_to do |format|\n if @community_section.save\n format.html { redirect_to @community_section, notice: 'Community section was successfully created.' }\n format.json { render :show, status: :created, location: @community_section }\n else\n format.html { render :new }\n format.json { render json: @community_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def add_new_section\n @section = Section.new\n end", "def create\n @domicile_type_section = DomicileTypeSection.new(params[:domicile_type_section])\n\n respond_to do |format|\n if @domicile_type_section.save\n format.html { redirect_to(@domicile_type_section, :notice => 'Domicile type section was successfully created.') }\n format.xml { render :xml => @domicile_type_section, :status => :created, :location => @domicile_type_section }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @domicile_type_section.errors, :status => :unprocessable_entity }\n end\n end\n end", "def test_insert_subsection\n\n section_01_1 = sections(:section_01_1)\n assert_equal(2, section_01_1.subsections.size)\n\n new_subsection = {\n 'name' => 'subsection_01_1_0.5',\n 'note' => 'inserting before the first subsection',\n 'url' => '',\n 'date_code_check' => '1',\n 'dot_rev_check' => '1',\n 'full_review' => '1'\n }\n\n post(:insert_subsection,\n { :new_subsection => new_subsection,\n :subsection => { 'id' => subsections(:subsection_01_1_1).id } },\n cathy_admin_session)\n section_01_1.reload\n subsections = section_01_1.subsections\n assert_equal(3, subsections.size)\n\n assert_equal('subsection_01_1_0.5', subsections[0].name)\n assert_equal('Subsection 1 Note', subsections[1].note)\n assert_equal('Subsection 2 Note', subsections[2].note)\n\n end", "def section_params\n params.require(:section).permit(:name, :description)\n end", "def create\r\n @academic_work=AcademicWork.find(params[:academic_work_id])\r\n @disciplines_study = @academic_work.disciplines_studies.new(params[:disciplines_study])\r\n\r\n respond_to do |format|\r\n if @disciplines_study.save\r\n format.html { redirect_to @disciplines_study, notice: 'Disciplines study was successfully created.' }\r\n format.json { render json: @disciplines_study, status: :created, location: @disciplines_study }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @disciplines_study.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def discipline_params\n params.require(:discipline).permit(:name,:description)\n end", "def create\n @section = Section.new(section_params)\n\n if @section.save\n redirect_to sections_path, primary: 'Section was successfully created.'\n else\n render :new\n end\n end", "def section_params\n params.require(:section).permit(:start_time, :end_time, :professor, :section_letter, :semester, :section_year, :section_days, :course_id)\n end", "def create\n @psi_discipline = PsiDiscipline.new(psi_discipline_params)\n\n respond_to do |format|\n if @psi_discipline.save\n format.html { redirect_to @psi_discipline, notice: 'Psi discipline was successfully created.' }\n format.json { render :show, status: :created, location: @psi_discipline }\n else\n format.html { render :new }\n format.json { render json: @psi_discipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @section = Section.new(section_params)\n\n respond_to do |format|\n if @section.save\n format.html { redirect_to teacher_path(@section.teacher), notice: 'Section was successfully created.' }\n format.json { render action: 'show', status: :created, location: @section }\n else\n flash[:error] = @section.errors.full_messages\n @teacher = @section.teacher\n format.html { render action: :new, layout: \"workspace\" }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @discipline = Discipline.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @discipline }\n end\n end", "def section_params\n params.require(:section).permit(:name, questions_attributes: [:content, :cans, answers_attributes: [:content]])\n end", "def course_section_params\n params.require(:course_section).permit!\n end", "def create\n @section_configuration = SectionConfiguration.new(section_configuration_params)\n\n respond_to do |format|\n if @section_configuration.save\n format.html { redirect_to @section_configuration, notice: 'Section configuration was successfully created.' }\n format.json { render :show, status: :created, location: @section_configuration }\n else\n format.html { render :new }\n format.json { render json: @section_configuration.errors, status: :unprocessable_entity }\n end\n end\n end", "def create_first\n\n @section = Section.find(params[:id])\n\n @new_subsection = Subsection.new\n @new_subsection.section_id = @section.id \n @new_subsection.name = ''\n @new_subsection.note = ''\n \n @new_subsection.date_code_check = @section.date_code_check\n @new_subsection.dot_rev_check = @section.dot_rev_check\n\n end", "def create\n @time_section = TimeSection.new(params[:time_section])\n\n respond_to do |format|\n if @time_section.save\n format.html { redirect_to @time_section, notice: 'Time section was successfully created.' }\n format.json { render json: @time_section, status: :created, location: @time_section }\n else\n format.html { render action: \"new\" }\n format.json { render json: @time_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def discipline_params\n # Requer um nome para tabela\n params.require(:discipline).permit(:name)\n end" ]
[ "0.6858734", "0.66750294", "0.6632172", "0.6621222", "0.6584435", "0.651913", "0.6359858", "0.62716115", "0.62380826", "0.62144756", "0.620074", "0.6187932", "0.6124004", "0.6103947", "0.6091024", "0.6054053", "0.60031754", "0.5955929", "0.59447634", "0.5942246", "0.5941796", "0.5878651", "0.58593786", "0.5845795", "0.5822809", "0.58204365", "0.5815429", "0.5810103", "0.58091146", "0.58091146", "0.58091146", "0.58091146", "0.58089095", "0.58062476", "0.5800143", "0.5792793", "0.578517", "0.5769421", "0.5766033", "0.5763695", "0.5735775", "0.57315946", "0.56858164", "0.5685308", "0.5683527", "0.56806463", "0.5666609", "0.56592125", "0.56462914", "0.5626076", "0.56104773", "0.5608838", "0.55988914", "0.5596228", "0.5596228", "0.55947834", "0.55931264", "0.5591839", "0.55916345", "0.5580296", "0.5567604", "0.55529666", "0.5549857", "0.5545244", "0.5542638", "0.5535924", "0.55340046", "0.5532553", "0.5528073", "0.5528073", "0.55195147", "0.5513028", "0.55053425", "0.55029374", "0.5500512", "0.54964894", "0.54953885", "0.54940397", "0.5485633", "0.5477774", "0.5477774", "0.5477774", "0.5477774", "0.54692376", "0.54680246", "0.54667723", "0.5465013", "0.5464227", "0.54571116", "0.5449414", "0.5447156", "0.544355", "0.54426616", "0.54416806", "0.5441553", "0.54405177", "0.5426497", "0.54244685", "0.54168266", "0.5415223" ]
0.70951676
0
PATCH/PUT /discipline_sections/1 PATCH/PUT /discipline_sections/1.json
def update respond_to do |format| if @discipline_section.update(discipline_section_params) format.html { redirect_to @discipline_section, notice: 'Раздел дисциплины был успешно обновлен' } format.json { render :show, status: :ok, location: @discipline_section } else format.html { render :edit } format.json { render json: @discipline_section.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\nlogger.debug \"update discipline: \"+@discipline.inspect\n discipline_params.each_pair do |property,value|\n @discipline.send(property+'=',value)if @discipline.respond_to?(property+'=')\n end\n @discipline.updater_id = current_user\n if @discipline.save\n set_discipline\n #respond_with @discipline\n render json: @discipline, status: :ok\n else\n ##render json: @discipline.errors, status: :unprocessable_entity\n respond_with @discipline.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @discipline.update(discipline_params)\n format.html { redirect_to management_disciplines_path }\n format.json { render :json => @discipline.to_json(include: :department), status: :created }\n else\n format.html { render :edit }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @discipline = Discipline.find(params[:id])\n\n respond_to do |format|\n if @discipline.update_attributes(params[:discipline])\n format.html { redirect_to @discipline, notice: t(:discipline_successfully_updated) }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @discipline.update(discipline_params)\n format.html { redirect_to @discipline, notice: 'Discipline was successfully updated.' }\n format.json { render :show, status: :ok, location: @discipline }\n else\n format.html { render :edit }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @discipline.update(discipline_params)\n format.html { redirect_to @discipline, notice: 'Discipline was successfully updated.' }\n format.json { render :show, status: :ok, location: @discipline }\n else\n format.html { render :edit }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @discipline = Discipline.find(params[:id])\n \n respond_to do |format|\n if @discipline.update_attributes(params[:discipline])\n format.html { redirect_to @discipline, :notice => t('selecao_admin.flash_messages.successfully_updated', :model => @discipline.class.model_name.human) }\n format.json { head :no_content }\n format.js\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @discipline.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end", "def update\n respond_to do |format|\n if @subdiscipline.update(subdiscipline_params)\n format.html { redirect_to @subdiscipline, notice: 'Subdiscipline was successfully updated.' }\n format.json { render :show, status: :ok, location: @subdiscipline }\n else\n format.html { render :edit }\n format.json { render json: @subdiscipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_discipline_section\n @discipline_section = DisciplineSection.find(params[:id])\n end", "def update\n respond_to do |format|\n @senha = @discipline.senha\n if @discipline.update(discipline_params)\n if @discipline.senha == \"\"\n @discipline.senha = @senha\n @discipline.update( senha: @senha)\n end\n if params[:anexos]\n\n params[:anexos].each { |anx|\n @discanexo = Discanexo.new\n @discanexo.anexo = anx\n @discanexo.Discipline_id = @discipline.id\n @discanexo.save\n }\n end\n flash[:success] = \"Disciplina atualizada com sucesso.\"\n format.html { redirect_to disciplines_url}\n format.json { render :show, status: :ok, location: @discipline }\n else\n format.html { render :edit }\n format.json { render json: @discipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n section_chunks = get_chunks(params)\n\n puts params\n redirect_to @course\n\n return\n\n sections = params['sections']\n if sections.nil?\n # Loop through course's existing sections.\n @course.sections.each do |section|\n\n end\n end\n \n respond_to do |format|\n # Update subcontents\n if update_section_chunks(section_chunks)\n format.html { redirect_to @course }\n format.json { render :show, status: :ok, location: @course }\n else\n format.html { render :edit }\n format.json { render json: @course.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @section = Section.find(params[:id])\n\n respond_to do |format|\n if @section.update_attributes(params[:section])\n format.html { redirect_to @section, notice: 'Section was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @section = Section.find(params[:id])\n\n respond_to do |format|\n if @section.update_attributes(params[:section])\n format.html { redirect_to @section, notice: 'Section was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n @disciplines_study = DisciplinesStudy.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @disciplines_study.update_attributes(params[:disciplines_study])\r\n format.html { redirect_to @disciplines_study, notice: 'Disciplines study 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: @disciplines_study.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\r\n @section = Section.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @section.update_attributes(params[:section])\r\n format.html { redirect_to @section, notice: 'Section was successfully updated.' }\r\n format.json { head :ok }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @section.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n base_params = subject_params.select {|k,v| k != \"discipline\"}\n base_params.each_pair do |property,value|\n @subject.send(property+'=',value)if @subject.respond_to?(property+'=')\n end\n @subject.discipline= Discipline.find(subject_params[:discipline][:id])\n if @subject.save\n set_subject\n #respond_with @subject\n render json: @subject, status: :ok\n else\n ##render json: @subject.errors, status: :unprocessable_entity\n respond_with @subject.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @psi_discipline.update(psi_discipline_params)\n format.html { redirect_to @psi_discipline, notice: 'Psi discipline was successfully updated.' }\n format.json { render :show, status: :ok, location: @psi_discipline }\n else\n format.html { render :edit }\n format.json { render json: @psi_discipline.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @survey_section.update(survey_section_params)\n format.html { redirect_to @survey_section, notice: 'Survey section was successfully updated.' }\n format.json { render :show, status: :ok, location: @survey_section }\n else\n format.html { render :edit }\n format.json { render json: @survey_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @course_section.update(course_section_params)\n format.html { redirect_to @course_section, notice: 'Course section was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @course_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @discipline = Discipline.find(params[:id])\n @new_discipline = Discipline.new(params[:discipline])\n @new_discipline.code = @discipline.code\n @new_discipline.course = @discipline.course\n @new_discipline.version = @discipline.version + 1\n \n @changed = false\n\n for field_to_check in ['syllabus', 'credits', 'name', 'equivalent_ids']\n @changed = true if @new_discipline.get(field_to_check) != @discipline.get(field_to_check)\n end\n\n if @changed\n flash[:notice] = I18n.t('flash.admin.disciplines.update.notice', :resource_name => 'discipline') if @new_discipline.save\n \n respond_with @new_discipline, :location => [:admin, @course, @new_discipline] \n else\n respond_with @discipline, :location => [:admin, @course, @discipline]\n end\n end", "def update\n @discipline_type = DisciplineType.find(params[:id])\n\n respond_to do |format|\n if @discipline_type.update_attributes(params[:discipline_type])\n format.html { redirect_to @discipline_type, :notice => 'Tipo de disciplina atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @discipline_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if section.update_attributes(params[:section_datum])\n head :no_content\n else\n render json: section.errors.full_messages,\n status: :unprocessable_entity\n end\n end", "def update\n authorize! :update, @course_section\n respond_to do |format|\n if @course_section.update(course_section_params)\n format.html { redirect_to @course_section, notice: 'Course section was successfully updated.' }\n format.json { render :show, status: :ok, location: @course_section }\n else\n format.html { render :edit }\n format.json { render json: @course_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # { subsection:\n # {\n # \"id\" : id\n # \"subsection_datum_id\":references\n # }\n # }\n if @subsection.update_attributes(params[:module])\n head :no_content\n else\n render json: @subsection.errors.full_messages,\n status: :unprocessable_entity\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 update\n respond_to do |format|\n if @lab_section.update(lab_section_params)\n format.html { redirect_to @lab_section, notice: 'Lab section was successfully updated.' }\n format.json { render :show, status: :ok, location: @lab_section }\n else\n format.html { render :edit }\n format.json { render json: @lab_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @section.update(section_params)\n format.html { redirect_to @section, notice: 'Section was successfully updated.' }\n format.json { render json: @section }\n else\n format.html { render action: 'edit' }\n format.json { render json: ErrorSerializer.serialize(@section.errors), status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @section.update(section_params)\n @section.check_index()\n form_wrapper = FormWrapper.find(@section.form_wrapper_id)\n format.html { redirect_to sections_section_path(form_wrapper), alert: I18n.t('activerecord.models.section.single') + I18n.t('helpers_locale.models.created') }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @sivic_discipulo.update(sivic_discipulo_params_netested)\n format.html { redirect_to @sivic_discipulo, notice: 'Registro alterado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sivic_discipulo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @guide_section.update(guide_section_params)\n format.html { redirect_to guide_sections_url, notice: 'Guide section was successfully updated.' }\n format.json { render :show, status: :ok, location: @guide_section }\n else\n format.html { render :edit }\n format.json { render json: @guide_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @section.update(section_params)\n render :show, status: :ok, location: @section\n else\n render json: @section.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @section.update(section_params)\n format.html { redirect_to @section, notice: 'Section was successfully updated.' }\n format.json { render :show, status: :ok, location: @section }\n else\n format.html { render :edit }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @section.update(section_params)\n format.html { redirect_to @section, notice: 'Section was successfully updated.' }\n format.json { render :show, status: :ok, location: @section }\n else\n format.html { render :edit }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @section.update(section_params)\n format.html { redirect_to @section, notice: 'Section was successfully updated.' }\n format.json { render :show, status: :ok, location: @section }\n else\n format.html { render :edit }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @section.update(section_params)\n format.html { redirect_to @section, notice: 'Section was successfully updated.' }\n format.json { render :show, status: :ok, location: @section }\n else\n format.html { render :edit }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @section.update(section_params)\n format.html { redirect_to @section, notice: 'Section was successfully updated.' }\n format.json { render :show, status: :ok, location: @section }\n else\n format.html { render :edit }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @section.update(section_params)\n format.html { redirect_to @section, notice: 'Section was successfully updated.' }\n format.json { render :show, status: :ok, location: @section }\n else\n format.html { render :edit }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @section.update(section_params)\n format.html { redirect_to @section,\n notice: 'Section was successfully updated.' }\n format.json { render :show, status: :ok, location: @section }\n else\n format.html { render :edit }\n format.json { render json: @section.errors,\n status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @soa_section.update(soa_section_params.merge({serial_number: @soa_section.serial_number += 1, revision: @soa_section.revision += 1 }))\n format.html { redirect_to domain_dns_zone_path(@soa_section.dns_zone.domain, @soa_section.dns_zone), notice: 'Soa section was successfully updated.' }\n format.json { head :no_content }\n else\n format.html do\n flash[:alert] = \"SoaSection validation failed: #{@soa_section.errors.messages}\"\n render action: :edit\n end\n format.json { render json: @soa_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @matrix = CourseMatrix.find(params[:course_matrix_id])\n @matrix_discipline = MatrixDiscipline.find(params[:id])\n\n respond_to do |format|\n if @matrix_discipline.update_attributes(params[:matrix_discipline])\n format.html { redirect_to course_matrix_matrix_discipline_path(:id => @matrix_discipline.id), :notice => 'Disciplina da matriz atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @matrix_discipline.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @studentsection.update(studentsection_params)\n format.html { redirect_to @studentsection, notice: 'Studentsection was successfully updated.' }\n format.json { render :show, status: :ok, location: @studentsection }\n else\n format.html { render :edit }\n format.json { render json: @studentsection.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @subsection.update(subsection_params)\n format.html { redirect_to @subsection, notice: 'Subsection was successfully updated.' }\n format.json { render :show, status: :ok, location: @subsection }\n else\n format.html { render :edit }\n format.json { render json: @subsection.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @section.update(section_params)\n render json: SectionSerializer.new(@section)\n else\n render json: @menu.errors, status: :unprocessable_entity\n end\n end", "def update\n sections = params[:sections]\n\n respond_to do |format|\n if @feedback.update(feedback_params)\n for section in sections\n if section[\"id\"] == 0 || section[\"id\"] == \"\"\n feedbackSection = FeedbackSection.new\n elsif\n feedbackSection = FeedbackSection.find(section[\"id\"])\n end\n\n feedbackSection.feedback_id = @feedback.id\n feedbackSection.question = section[\"question\"]\n feedbackSection.answer = section[\"answer\"]\n\n feedbackSection.rating = 0\n feedbackSection.question_type = 1\n feedbackSection.action_plan = ''\n feedbackSection.category = ''\n feedbackSection.save\n end\n format.html { redirect_to @feedback, notice: 'Feedback was successfully updated.' }\n format.json { render :show, status: :ok, location: @feedback }\n else\n format.html { render :edit }\n format.json { render json: @feedback.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sections = Section.find(:all)\n @section = Section.find(params[:section_id])\n\n respond_to do |format|\n if @section.update_attributes(params[:section])\n flash[:notice] = 'Section was successfully updated.'\n format.html { redirect_to(@section) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @section.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @section_test = SectionTest.find(params[:id])\n\n respond_to do |format|\n if @section_test.update_attributes(params[:section_test])\n format.html { redirect_to @section_test, notice: 'Section test was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @section_test.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @hr_config_discipline_type.update(hr_config_discipline_type_params)\n format.html { redirect_to @hr_config_discipline_type, notice: 'Discipline type was successfully updated.' }\n format.json { render :show, status: :ok, location: @hr_config_discipline_type }\n else\n format.html { render :edit }\n format.json { render json: @hr_config_discipline_type.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @section_heading = SectionHeading.find(params[:id])\n\n respond_to do |format|\n if @section_heading.update_attributes(params[:section_heading])\n format.html { redirect_to @section_heading, notice: 'Section heading was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @section_heading.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @section.update(section_params)\n format.html { redirect_to teacher_path(@section.teacher), notice: 'Section was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def update\n @section_comment = SectionComment.find(params[:id])\n\t\t@section_comment.comment = params[:section_comment][:comment]\n\t\t\n respond_to do |format|\n if @section_comment.save\n format.html { redirect_to schedules_path, notice: 'Section comment was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @section_comment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @disciplina.update(disciplina_params)\n format.html { redirect_to @disciplina, notice: 'Disciplina was successfully updated.' }\n format.json { render :show, status: :ok, location: @disciplina }\n else\n format.html { render :edit }\n format.json { render json: @disciplina.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @section = Section.find(params[:id])\n\n respond_to do |format|\n if @section.update_attributes(params[:section])\n format.html { redirect_to(admin_sections_path, :notice => 'Section was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @section.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @discipline = Discipline.find(params[:discipline_id])\n @lecturer = Lecturer.find(params[:id])\n if @lecturer.update_attributes(params[:lecturer])\n redirect_to discipline_lecturer_url(@discipline, @lecturer)\n else\n render :action => \"edit\"\n end\n end", "def update\n @initiative = Initiative.find(params[:id])\n \n respond_to do |format|\n if @initiative.update_attributes(params[:initiative])\n \n format.html { redirect_to @initiative, notice: 'Initiative was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @initiative.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @section = Section.find(params[:id])\n\n respond_to do |format|\n if @section.update_attributes(params[:section])\n format.html { redirect_to(@section, :notice => 'Section was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @section.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @section = Section.find(params[:id])\n\n respond_to do |format|\n if @section.update_attributes(params[:section])\n format.html { redirect_to(@section, :notice => 'Section was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @section.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @time_section = TimeSection.find(params[:id])\n\n respond_to do |format|\n if @time_section.update_attributes(params[:time_section])\n format.html { redirect_to @time_section, notice: 'Time section was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @race_discipline = RaceDiscipline.find(params[:id])\n\n respond_to do |format|\n if @race_discipline.update_attributes(params[:race_discipline])\n format.html { redirect_to(admin_race_discipline_path, :notice => 'RaceDiscipline was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @race_discipline.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n action_message_for(@guide.content_item.status)\n if update_guide\n format.html { redirect_to redirect_target(@guide), flash: @feedback_flash }\n format.json { render :show, status: :ok, location: @guide }\n else\n 1.times { @guide.sections.new } if @guide.subtype == 'detailed_guide'\n @guide.content_item.status = session[:content_item_status]\n format.html { render :edit }\n format.json { render json: @guide.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @recipy = Recipy.find(params[:id])\n\n respond_to do |format|\n if @recipy.update_attributes(params[:recipy])\n format.html { redirect_to @recipy, notice: 'Recipy was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @recipy.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize Section\n\n respond_to do |format|\n if @section.update(section_params)\n format.html { redirect_to @section.article, notice: 'Section was successfully updated.' }\n format.json { render :show, status: :ok, location: @section }\n else\n @section_count = article.sections.count\n format.html { render :edit }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @home = Home.first\n @about = About.first\n\n @section = Section.find(params[:id])\n\n respond_to do |format|\n if @section.update(section_params)\n format.html { redirect_to admin_section_path(@section), notice: 'Section was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @form_section.update(form_section_params)\n respond_with( [ :admin, @form_section] )\n end", "def update\n @domicile_type_section = DomicileTypeSection.find(params[:id])\n\n respond_to do |format|\n if @domicile_type_section.update_attributes(params[:domicile_type_section])\n format.html { redirect_to(@domicile_type_section, :notice => 'Domicile type section was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @domicile_type_section.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @menu_section = MenuSection.find(params[:id])\n\n respond_to do |format|\n if @menu_section.update_attributes(params[:menu_section])\n format.html { redirect_to @menu_section, notice: 'Menu section was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @menu_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n \n @section = Section.find(params[:id])\n\n @section.users << User.find(params[:user_add]) if params[:user_add]\n @section.users.delete(User.find(params[:user_remove])) if params[:user_remove]\n # @section.announcements << Announcement.find(params[:announcement_add]) if params[:announcement_add]\n respond_to do |format|\n if @section.update_attributes(params[:section])\n format.html { redirect_to @section, notice: 'Section was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @section.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def set_discipline\n @discipline = Discipline.find(params[:id])\n end", "def update\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to quiz_path(@question.subsection_id), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @section_configuration.update(section_configuration_params)\n format.html { redirect_to @section_configuration, notice: 'Section configuration was successfully updated.' }\n format.json { render :show, status: :ok, location: @section_configuration }\n else\n format.html { render :edit }\n format.json { render json: @section_configuration.errors, status: :unprocessable_entity }\n end\n end\n end", "def discipline_section_params\n params.require(:discipline_section).permit(:discipline_type, :section_name, :section_type, :weight, :min_score, :max_score, :require_type, :attenuation_constant, :optimal_time, :limit_time, :discipline_id, :community_id)\n end", "def update\n respond_to do |format|\n if @sectionalization.update(sectionalization_params)\n format.html { redirect_to @sectionalization, notice: 'Sectionalization was successfully updated.' }\n format.json { render :show, status: :ok, location: @sectionalization }\n else\n format.html { render :edit }\n format.json { render json: @sectionalization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @idiom = Idiom.find(params[:id])\n\n respond_to do |format|\n if @idiom.update_attributes(params[:idiom])\n format.html { redirect_to @idiom, notice: 'Idiom was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @idiom.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @conclusion = Conclusion.find(params[:id])\n\n respond_to do |format|\n if @conclusion.update_attributes(params[:conclusion])\n format.html { redirect_to @conclusion, notice: 'Conclusion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @conclusion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_initiative.update(api_v1_initiative_params)\n format.html { redirect_to @api_v1_initiative, notice: 'Initiative was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_initiative }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_initiative.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @section = Section.find(params[:pk])\n @section.update_attributes( params[:name] => params[:value] )\n \n if @section.save\n render json: { :results => true }\n else\n render json: { :results => false }\n end\n \n end", "def update\n authorize @specialization\n\n respond_to do |format|\n if @specialization.update(specialization_update_params)\n format.html { redirect_to @specialization, notice: I18n.t(\"activerecord.notice.specialization.success_update\") }\n format.json { render :show, status: :ok, location: @specialization }\n else\n format.html { render :edit }\n format.json { render json: @specialization.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @example_section = ExampleSection.find(params[:id])\n\n respond_to do |format|\n if @example_section.update_attributes(params[:example_section])\n flash[:notice] = 'ExampleSection was successfully updated.'\n format.html { redirect_to(@example_section) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @example_section.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n if @physician.update(survey_params)\n head :no_content\n else\n render json: @physician.errors, status: :unprocessable_entity\n end\n end", "def update\n authorize! :edit, @questionnaire\n\n @questionnaire.load_JSON(params[:questionnaire], current_user)\n\n respond_to do |format|\n# if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to @questionnaire, notice: 'Kysymyslomakkeen muokkaaminen onnistui.' }\n format.json { head :no_content }\n# else\n# format.html { render action: \"edit\" }\n# format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n# end\n\n end\n end", "def update\n professor = Professor.find(params[:id])\n professor.update!(professor_params)\n\n render json: professor.to_json(include: :courses)\n end", "def update\n course = Course.includes(:professors).find(params[:id])\n course.update!(course_params)\n \n course.professor_ids=(params[:professors])\n\n render json: course.to_json(include: :professors)\n end", "def update\n respond_to do |format|\n if @assessment_info.update(assessment_info_params)\n format.html { redirect_to edit_concept_url(@assessment_info.concept_id), notice: 'assessment_info was successfully updated.' }\n format.json { render :show, status: :ok, location: @assessment_info }\n else\n format.html { render :edit }\n format.json { render json: @assessment_info.errors, status: :unprocessable_entity }\n end\n end\nend", "def update\n respond_to do |format|\n if @section.update(admin_section_params)\n format.html { redirect_to admin_sections_path, notice: 'Section was successfully updated.' }\n format.json { render :show, status: :ok, location: @admin_section }\n else\n format.html { render :edit }\n format.json { render json: @admin_section.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @section_heading.update(section_heading_params)\n format.html { redirect_to @section_heading, notice: 'Section heading was successfully updated.' }\n format.json { render :show, status: :ok, location: @section_heading }\n else\n format.html { render :edit }\n format.json { render json: @section_heading.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @set_aside.update(set_aside_params)\n format.html { redirect_to @set_aside, notice: 'Set aside was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @set_aside.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_discipline\nlogger.debug \"set_discipline curr_user: \" + current_user.inspect\n begin\n @discipline = Discipline.find(params[:id])\n rescue ActiveRecord::RecordNotFound\n logger.error \"Attempt to access invalid discipline #{params[:id]}\"\n @discipline_not_found = true\n render json: {message: \"Illegal discipline access request\"}, status: :unauthorized\n return\n else\n @discipline_not_found = false\n end\n end", "def update\n respond_to do |format|\n if @incident_proof.update(incident_proof_params)\n format.html { redirect_to @incident_proof, notice: 'Incident proof was successfully updated.' }\n format.json { render :show, status: :ok, location: @incident_proof }\n else\n format.html { render :edit }\n format.json { render json: @incident_proof.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @sectioneight_form = SectioneightForm.find(params[:id])\n\n respond_to do |format|\n if @sectioneight_form.update_attributes(params[:sectioneight_form])\n format.html { redirect_to @sectioneight_form, notice: 'Sectioneight form was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @sectioneight_form.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @focusing_section = FocusingSection.find(params[:id])\n\n respond_to do |format|\n if @focusing_section.update_attributes(params[:focusing_section])\n format.html { redirect_to(@focusing_section, :notice => 'Focusing section was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @focusing_section.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @inclusion.update(inclusion_params)\n format.html { redirect_to @inclusion, notice: 'Inclusion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @inclusion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @section = @account.sections.find(params[:id])\n @section.account = @account\n\n respond_to do |format|\n if @section.update_attributes(params[:section])\n flash[:notice] = 'Section updated'\n format.js\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @section.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @section_instructor.update(section_instructor_params)\n format.html { redirect_to @section_instructor, notice: 'Section instructor was successfully updated.' }\n format.json { render :show, status: :ok, location: @section_instructor }\n else\n format.html { render :edit }\n format.json { render json: @section_instructor.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @discipulador.update(discipulador_params)\n format.html { redirect_to @discipulador, notice: 'Discipulador was successfully updated.' }\n format.json { render :show, status: :ok, location: @discipulador }\n else\n format.html { render :edit }\n format.json { render json: @discipulador.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @court_complex.update(court_complex_params)\n format.html { redirect_to @court_complex, notice: 'Court complex was successfully updated.' }\n format.json { render :show, status: :ok, location: @court_complex }\n else\n format.html { render :edit }\n format.json { render json: @court_complex.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @orderable_concept = OrderableConcept.find(params[:id])\n\n respond_to do |format|\n if @orderable_concept.update_attributes(params[:orderable_concept])\n format.html { redirect_to @orderable_concept, notice: 'Orderable concept was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @orderable_concept.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @golf_cource = GolfCource.find(params[:id])\n\n respond_to do |format|\n if @golf_cource.update_attributes(params[:golf_cource])\n format.html { redirect_to scaffold_golf_cource_url(@golf_cource), notice: 'Golf cource was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @golf_cource.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.7019297", "0.6986113", "0.68933535", "0.6844664", "0.6844664", "0.67145896", "0.670726", "0.65858907", "0.65282524", "0.63720644", "0.63639146", "0.6342503", "0.63086236", "0.6301386", "0.6289386", "0.62810093", "0.6272424", "0.626786", "0.62410516", "0.6239754", "0.6237415", "0.62161803", "0.6209517", "0.6172336", "0.6163751", "0.61012095", "0.6084306", "0.60577595", "0.602563", "0.6025292", "0.6019774", "0.6019774", "0.6019774", "0.6019774", "0.6019774", "0.6019774", "0.60091573", "0.6005827", "0.599769", "0.5985032", "0.5966491", "0.5962978", "0.59629405", "0.59621316", "0.595748", "0.5955569", "0.5953254", "0.59473693", "0.5940273", "0.5940273", "0.5922252", "0.59062874", "0.5904613", "0.58981955", "0.58960295", "0.5893582", "0.5893582", "0.5886691", "0.5875158", "0.5873153", "0.58656025", "0.5859737", "0.58577025", "0.58480513", "0.58411527", "0.5839924", "0.583332", "0.5826973", "0.5826973", "0.5826973", "0.5826973", "0.5824257", "0.58235794", "0.5822624", "0.58032596", "0.5799571", "0.57903934", "0.5789653", "0.5776839", "0.5774377", "0.5769474", "0.57599795", "0.575943", "0.5758795", "0.57564116", "0.57545567", "0.57515544", "0.57487315", "0.5740572", "0.573615", "0.5724333", "0.5721888", "0.5716981", "0.57024664", "0.56993824", "0.5698808", "0.5697426", "0.5697345", "0.56964827", "0.5695521" ]
0.711616
0
DELETE /discipline_sections/1 DELETE /discipline_sections/1.json
def destroy @discipline_section.destroy respond_to do |format| #format.html { redirect_to discipline_sections_url, notice: 'Раздел дисциплины был успешно удален' } #format.json { head :no_content } format.js { render ('discipline_sections/delete')} end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @discipline = Discipline.find(params[:id])\n @discipline.destroy\n\n respond_to do |format|\n format.html { redirect_to disciplines_url }\n format.json { head :ok }\n end\n end", "def destroy\n @discipline.destroy\n respond_to do |format|\n format.html { redirect_to management_disciplines_path, notice: 'Discipline was successfully removed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @discipline.destroy\n respond_to do |format|\n format.html { redirect_to disciplines_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @discipline.destroy\n respond_to do |format|\n format.html { redirect_to disciplines_url, notice: 'Discipline was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @discipline = Discipline.find(params[:id])\n @discipline.destroy\n \n respond_with @discipline, :location => admin_course_disciplines_url(@course)\n end", "def destroy\n @subdiscipline.destroy\n respond_to do |format|\n format.html { redirect_to subdisciplines_url, notice: 'Subdiscipline was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @discipline.topics.delete_all\n @discipline.destroy\n\n respond_to do |format|\n format.html { redirect_to disciplines_url, notice: 'Discipline was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @section.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @discipline = Discipline.find(params[:id])\n @discipline.destroy\n \n respond_to do |format|\n format.html { redirect_to disciplines_url }\n format.json { head :no_content }\n format.js\n end\n end", "def destroy\n @section.destroy\n render json: SectionSerializer.new(@section)\n end", "def destroy\n @section = Section.find(params[:id])\n @section.destroy\n\n respond_to do |format|\n format.html { redirect_to sections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @section = Section.find(params[:id])\n @section.destroy\n\n respond_to do |format|\n format.html { redirect_to sections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @section.destroy\n respond_to do |format|\n format.html { redirect_to sections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @section.destroy\n respond_to do |format|\n format.html { redirect_to sections_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @disciplines_study = DisciplinesStudy.find(params[:id])\r\n @disciplines_study.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to disciplines_studies_url }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @discipline_type = DisciplineType.find(params[:id])\n @discipline_type.destroy\n\n respond_to do |format|\n format.html { redirect_to discipline_types_url, :notice => 'Tipo de disciplina excluído com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @section = Section.find(params[:id])\n @section.destroy\n\n render nothing: true\n end", "def destroy\n @domicile_type_section = DomicileTypeSection.find(params[:id])\n @domicile_type_section.destroy\n\n respond_to do |format|\n format.html { redirect_to(domicile_type_sections_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @discanexos = Discanexo.where(\"id in (?)\", @discipline.discanexo_ids)\n if @discanexos\n @discanexos.each { |anx|\n anx.anexo = nil\n anx.save\n }\n end\n @discipline.save\n @discipline.destroy\n respond_to do |format|\n format.html { redirect_to disciplines_url, notice: 'Discipline was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def delete\n @section = Section.find(params[:id])\n end", "def destroy\n @survey_section.destroy\n respond_to do |format|\n format.html { redirect_to survey_sections_url, notice: 'Survey section was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @hr_config_discipline_type.destroy\n respond_to do |format|\n format.html { redirect_to hr_config_discipline_types_url, notice: 'Discipline type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @section_heading = SectionHeading.find(params[:id])\n @section_heading.destroy\n\n respond_to do |format|\n format.html { redirect_to section_headings_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @psi_discipline.destroy\n respond_to do |format|\n format.html { redirect_to psi_disciplines_url, notice: 'Psi discipline was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @time_section = TimeSection.find(params[:id])\n @time_section.destroy\n\n respond_to do |format|\n format.html { redirect_to time_sections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @sections = Section.find(:all)\n @section = Section.find(params[:section_id])\n @section.destroy\n\n respond_to do |format|\n format.html { redirect_to(sections_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @sivic_discipulo.destroy\n respond_to do |format|\n format.html { redirect_to sivic_discipulos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n authorize! :destroy, @course_section\n @course_section.destroy\n respond_to do |format|\n format.html { redirect_to course_sections_url, notice: 'Course section was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @recipy = Recipy.find(params[:id])\n @recipy.destroy\n\n respond_to do |format|\n format.html { redirect_to recipies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @section_category = SectionCategory.find(params[:id])\n @section_category.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 @menu_section = MenuSection.find(params[:id])\n @menu_section.destroy\n\n respond_to do |format|\n format.html { redirect_to menu_sections_url }\n format.json { head :no_content }\n end\n end", "def delete_course_by_id(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/courses/#{org_unit_id}\" # setup user path\n # ap path\n _delete(path)\n puts '[+] Course data deleted successfully'.green\nend", "def destroy\n @guide_section.destroy\n respond_to do |format|\n format.html { redirect_to guide_sections_url, notice: 'Guide section was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n # Test this query on rail console for menu section that has food\n ActiveRecord::Base.connection.exec_query(\n \"DELETE FROM menu_sections\n WHERE url_id = #{params[:id]}\n AND NOT EXISTS (\n SELECT 1\n FROM Foods\n WHERE ms_url_id = #{params[:id]}\n );\"\n ) \n\n menu_section = ActiveRecord::Base.connection.exec_query(\n \"SELECT 1\n FROM menu_sections\n WHERE url_id = #{params[:id]}\"\n )\n\n if (!menu_section.empty?)\n render json: {errors: \"Cannot delete menu section that has dish in it!\"}, status: 500\n end\n end", "def destroy\n @lab_section.destroy\n respond_to do |format|\n format.html { redirect_to lab_sections_url, notice: 'Lab section was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @home = Home.first\n @about = About.first\n \n @section = Section.find(params[:id])\n \n @section.destroy\n respond_to do |format|\n format.html { redirect_to admin_sections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @storyline = Storyline.find(params[:id])\n @storyline.destroy\n\n respond_to do |format|\n format.html { redirect_to storylines_url }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @section = Section.find(params[:id])\r\n @section.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to :back }\r\n format.json { head :ok }\r\n end\r\n end", "def destroy\n @example_section = ExampleSection.find(params[:id])\n @example_section.destroy\n\n respond_to do |format|\n format.html { redirect_to(example_sections_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n authorize Section\n \n @section.destroy\n respond_to do |format|\n format.html { redirect_to @section.article, notice: 'Section was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @section = Section.find(params[:id])\n @section.destroy\n\n respond_to do |format|\n format.html { redirect_to(sections_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @section = Section.find(params[:id])\n @section.destroy\n\n respond_to do |format|\n format.html { redirect_to(sections_url) }\n format.xml { head :ok }\n end\n end", "def destroy \n section = SectionDatum.find(params[:id])\n if section.destroy\n head :no_content\n else\n render json: section.errors.full_messages,\n status: :unprocessable_entity\n end\n end", "def destroy\n @sectionalization.destroy\n respond_to do |format|\n format.html { redirect_to sectionalizations_url, notice: 'Sectionalization was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @section_test = SectionTest.find(params[:id])\n @section_test.destroy\n\n respond_to do |format|\n format.html { redirect_to section_tests_url }\n format.json { head :ok }\n end\n end", "def destroy\n @disciplina.destroy\n respond_to do |format|\n format.html { redirect_to disciplinas_url, notice: 'Disciplina was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @studentsection.destroy\n respond_to do |format|\n format.html { redirect_to studentsections_url, notice: 'Studentsection was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @critic = Critic.find(params[:id])\n @critic.destroy\n\n respond_to do |format|\n format.html { redirect_to critics_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @race_discipline = RaceDiscipline.find(params[:id])\n @race_discipline.destroy\n\n respond_to do |format|\n format.html { redirect_to(admin_race_disciplines_url) }\n format.xml { head :ok }\n end\n end", "def delete_course_template(org_unit_id)\n path = \"/d2l/api/lp/#{$lp_ver}/coursetemplates/#{org_unit_id}\"\n _delete(path)\n puts '[+] Course template data deleted successfully'.green\nend", "def destroy\n @chiropractic_assessment = ChiropracticAssessment.find(params[:id])\n @chiropractic_assessment.destroy\n\n respond_to do |format|\n format.html { redirect_to chiropractic_assessments_url }\n format.json { head :ok }\n end\n end", "def destroy\n @discipline = Discipline.find(params[:discipline_id])\n @lecturer = Lecturer.find(params[:id])\n @lecturer.destroy\n\n respond_to do |format|\n format.html { redirect_to discipline_lecturers_path(@discipline) }\n format.xml { head :ok }\n end\n end", "def destroy\n @section = @account.sections.find(params[:id])\n @section.destroy\n\n respond_to do |format|\n format.html { redirect_to(account_sections_url(@account)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @course_section.destroy\n if @course_section.student_count\n flash[:notice] = \"This section has student(s). You can't delete this section!\"\n end\n flash.now[:error] = \"Section record deleted\"\n respond_to do |format|\n format.html { redirect_to course_sections_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @ways_of_admission = WaysOfAdmission.find(params[:id])\n @ways_of_admission.destroy\n\n respond_to do |format|\n format.html { redirect_to ways_of_admissions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @section.destroy\n respond_to do |format|\n format.html { redirect_to sections_url, notice: 'Section was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @section.destroy\n respond_to do |format|\n format.html { redirect_to sections_url, notice: 'Section was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @section.destroy\n respond_to do |format|\n format.html { redirect_to sections_url, notice: 'Section was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @section.destroy\n respond_to do |format|\n format.html { redirect_to sections_url, notice: 'Section was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @section.destroy\n respond_to do |format|\n format.html { redirect_to sections_url, notice: 'Section was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @section.destroy\n respond_to do |format|\n format.html { redirect_to sections_url, notice: 'Section was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @section.destroy\n respond_to do |format|\n format.html { redirect_to sections_url,\n notice: 'Section was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def maintenance_delete(statuspage_id, maintenance_id)\n data = {}\n data['statuspage_id'] = statuspage_id\n data['maintenance_id'] = maintenance_id\n\n request :method => :post,\n :url => @url + 'maintenance/delete',\n :payload => data\n end", "def destroy\n @clinicalsection = Clinicalsection.find(params[:id])\n @clinicalsection.destroy\n\n respond_to do |format|\n format.html { redirect_to clinicalsections_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def delete_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by_id(params[:pathway_id])\n suggested_pathway.destroy\n render json: suggested_pathway\n end", "def destroy\n\n subsection = Subsection.find(params['id']) \n index = subsection.section.subsections.index(subsection)\n checklist_id = subsection.checklist.id\n \n if subsection.remove\n flash['notice'] = 'Subsection deletion successful.'\n else\n flash['notice'] = 'Subsection deletion failed - Contact DTG'\n end\n \n redirect_to(:controller => 'checklist', :action => 'edit', :id => checklist_id)\n \n end", "def destroy\n @line_detail.destroy\n respond_to do |format|\n format.html { redirect_to line_details_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @headline.destroy\n respond_to do |format|\n format.html { redirect_to headlines_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @headline.destroy\n respond_to do |format|\n format.html { redirect_to headlines_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @disciplina = Disciplina.find(params[:id])\n @disciplina.destroy\n\n respond_to do |format|\n format.html { redirect_to(disciplinas_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @oncourse_exercise.destroy\n respond_to do |format|\n format.html { redirect_to oncourse_exercises_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @section_configuration.destroy\n respond_to do |format|\n format.html { redirect_to section_configurations_url, notice: 'Section configuration was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @complexity = Complexity.find(params[:id])\n @complexity.destroy\n\n respond_to do |format|\n format.html { redirect_to complexities_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @assignment = Assignment.find(params[:id])\n @section = @assignment.section\n @assignment.destroy\n\n respond_to do |format|\n format.html { redirect_to section_path(@section) }\n format.json { head :no_content }\n end\n end", "def destroy\n @medium_mission = MediumMission.find(params[:id])\n @medium_mission.destroy\n\n respond_to do |format|\n format.html { redirect_to medium_missions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @so_header = SoHeader.find(params[:so_header_id])\n @so_line = @so_header.so_lines.find(params[:id])\n @so_line.destroy\n\n respond_to do |format|\n format.html { redirect_to so_header_so_lines_url(@so_header) }\n format.json { head :ok }\n end\n end", "def destroy\n @admin_section.destroy\n respond_to do |format|\n format.html { redirect_to admin_sections_url, notice: 'Section was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @section_heading.destroy\n respond_to do |format|\n format.html { redirect_to section_headings_url, notice: 'Section heading was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @section_comment = SectionComment.find(params[:id])\n @section_comment.destroy\n\n respond_to do |format|\n format.html { redirect_to section_comments_url }\n format.json { head :ok }\n end\n end", "def destroy\n @section.destroy\n respond_to do |format|\n form_wrapper = FormWrapper.find(@section.form_wrapper_id)\n format.html { redirect_to sections_section_path(form_wrapper), alert: I18n.t('activerecord.models.section.single') + I18n.t('helpers_locale.models.created') }\n format.json { head :no_content }\n end\n end", "def disassociate\n @discipline = Discipline.find(params[:discipline_id])\n\n respond_to do |format|\n current_user.notebook.disciplines.delete(@discipline)\n format.js\n end\n end", "def destroy\n @idiom = Idiom.find(params[:id])\n @idiom.destroy\n\n respond_to do |format|\n format.html { redirect_to idioms_url }\n format.json { head :no_content }\n end\n end", "def remove_course_section_from_schedule\n @course_schedule = CourseSchedule.find_or_create_by(:user => current_user)\n\n section_id = params[:section_id]\n @course_section = CourseSection.find_by(:id => section_id)\n @course_schedule.course_sections.delete(@course_section)\n\n respond_to do |format|\n format.js\n end\n end", "def destroy\n @study_course = StudyCourse.find(params[:id])\n @study_course.destroy\n\n respond_to do |format|\n format.html { redirect_to study_courses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @admin_interview = Interview.find(params[:id])\n @admin_interview.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_interviews_url }\n format.json { head :no_content }\n end\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 destroy\n @mission = Mission.find(params[:id])\n @mission.destroy\n\n respond_to do |format|\n format.html { redirect_to missions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @manage_section.destroy\n respond_to do |format|\n format.html { redirect_to manage_compete_url(@compete), notice: 'Section was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @routine_interview = RoutineInterview.find(params[:id])\n @routine_interview.destroy\n\n respond_to do |format|\n format.html { redirect_to routine_interviews_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @section_instructor.destroy\n respond_to do |format|\n format.html { redirect_to section_instructors_url, notice: 'Section instructor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @form_section.destroy\n respond_with( [ :admin, @form_section] )\n end", "def destroy\n @formulary = Formulary.find(params[:id])\n @formulary.destroy\n\n respond_to do |format|\n format.html { redirect_to formularies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @line = Line.find(params[:id])\n @line.destroy\n\n respond_to do |format|\n format.html { redirect_to budget_path(@line.budget) }\n format.json { head :no_content }\n end\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 @occasion = Occasion.find(params[:id])\n @occasion.destroy\n\n respond_to do |format|\n format.html { redirect_to occasions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @golf_cource = GolfCource.find(params[:id])\n @golf_cource.destroy\n\n respond_to do |format|\n format.html { redirect_to scaffold_golf_cources_url }\n format.json { head :ok }\n end\n end", "def destroy\n @tutorial_section.destroy\n respond_to do |format|\n format.html { redirect_to tutorial_sections_url, notice: 'Tutorial section was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @cruise_line.destroy\n respond_to do |format|\n format.html { redirect_to cruise_lines_url, notice: 'Cruise line was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @donation_line = DonationLine.find(params[:id])\n @donation_line.destroy\n\n respond_to do |format|\n format.html { redirect_to donation_lines_url }\n format.json { head :ok }\n end\n end" ]
[ "0.7371484", "0.7189136", "0.71649116", "0.70629275", "0.7014427", "0.7007249", "0.7002153", "0.69809365", "0.69650245", "0.67637247", "0.67394334", "0.67394334", "0.6717208", "0.6717208", "0.6706647", "0.6678262", "0.66756576", "0.6648608", "0.6625008", "0.6620597", "0.66081905", "0.6593508", "0.65705144", "0.65503085", "0.65393054", "0.65166557", "0.6515038", "0.6487299", "0.6486117", "0.6479326", "0.6470045", "0.6463652", "0.64600027", "0.64553046", "0.64544874", "0.64511883", "0.6442939", "0.6441091", "0.6434862", "0.6427976", "0.6426973", "0.6426973", "0.64188653", "0.6405661", "0.6405198", "0.6399985", "0.6393598", "0.6393403", "0.63853157", "0.6371204", "0.6369913", "0.6364713", "0.635574", "0.6312464", "0.63084555", "0.63051844", "0.63051844", "0.63051844", "0.63051844", "0.63051844", "0.63051844", "0.62927383", "0.6291832", "0.62864786", "0.627364", "0.6270537", "0.6255873", "0.6253447", "0.62497574", "0.62497574", "0.6244332", "0.62428874", "0.62399626", "0.6232933", "0.6232137", "0.6226011", "0.6224917", "0.62212765", "0.6219996", "0.6214135", "0.62139004", "0.62101746", "0.6203261", "0.6201012", "0.61963105", "0.6187055", "0.6185669", "0.61842644", "0.61814314", "0.6177627", "0.6175475", "0.6166689", "0.6163885", "0.61631525", "0.6162327", "0.616142", "0.616113", "0.61593604", "0.61552805", "0.6154635" ]
0.71084684
3
Use callbacks to share common setup or constraints between actions.
def set_discipline_section @discipline_section = DisciplineSection.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def set_actions\n actions :all\n end", "def define_action_helpers?; end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def setup_handler\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def 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 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 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\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def setup(&block)\n define_method(:setup, &block)\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 setup(easy)\n super\n easy.customrequest = @verb\n end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def default_action; 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 callback_phase\n super\n end", "def advice\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 _handle_action_missing(*args); end", "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 duas1(action)\n action.call\n action.call\nend" ]
[ "0.6163821", "0.6045432", "0.5945441", "0.5916224", "0.58894575", "0.5834073", "0.57764685", "0.5702474", "0.5702474", "0.5653258", "0.56211996", "0.54235053", "0.5410683", "0.5410683", "0.5410683", "0.53948104", "0.5378064", "0.5356684", "0.53400385", "0.53399503", "0.53312254", "0.53121567", "0.52971965", "0.52964705", "0.52956307", "0.52587366", "0.52450675", "0.5237777", "0.5237777", "0.5237777", "0.5237777", "0.5237777", "0.5233381", "0.52325714", "0.52288216", "0.52229726", "0.5218362", "0.52142864", "0.5207988", "0.5206337", "0.51762295", "0.51745105", "0.51728606", "0.516616", "0.5161016", "0.5157393", "0.5152562", "0.51524293", "0.5152397", "0.5144533", "0.513982", "0.51342106", "0.5113793", "0.5113793", "0.5113671", "0.51092553", "0.51062804", "0.50921935", "0.5088855", "0.5082236", "0.5079901", "0.5066569", "0.5055307", "0.5053106", "0.50499666", "0.50499666", "0.5035068", "0.50258636", "0.50220853", "0.5015893", "0.50134486", "0.5001442", "0.50005543", "0.4998581", "0.49901858", "0.49901858", "0.4986648", "0.49809486", "0.49792925", "0.4978855", "0.49685496", "0.49656174", "0.49576473", "0.49563017", "0.4955349", "0.49536878", "0.4952439", "0.49460214", "0.494239", "0.49334687", "0.49315962", "0.49266812", "0.49261138", "0.4925925", "0.4922542", "0.4920779", "0.49173284", "0.49169463", "0.4916256", "0.49162322", "0.49156886" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def discipline_section_params params.require(:discipline_section).permit(:discipline_type, :section_name, :section_type, :weight, :min_score, :max_score, :require_type, :attenuation_constant, :optimal_time, :limit_time, :discipline_id, :community_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 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
Parse the name into its component parts
def parse split_name Governator::Name.new(original, first, middle, nickname, last, suffix) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def name_components\n @_name_components ||= name.scan(/[[:alnum:]]+/)\n end", "def parse_name(name)\n words = name.path_to_name.strip.split(/\\s+/)\n first = words.shift\n { first: first, last: words.join('-') }\n end", "def parts\n name.split(\" \")\n end", "def parse_name(name)\n parsed = name.split(' ')\n if parsed.size == 2\n return parsed[0], parsed[1]\n end\n end", "def split_name_into_components(component)\n raise ArgumentError, \"Must pass a :row, :version AND :field\" if component.nil?\n component[:field] = [component[:field]] unless component[:field].is_a?(Array)\n \n component[:field].each do |field|\n NAME_BITS.zip(PEOPLE_BITS).each do |field_name, people_name|\n t.combine(:row => component[:row], :version => component[:version],\n :field => \"#{field}_#{field_name}\") do |row|\n \n # Grab the original, composite name\n name = row.send(\"#{field}_name\")\n \n unless name.nil?\n # Fix various name formatting errors\n name = self.class.fix_carrot_names(name) unless name.index(\"^\").nil?\n \n # Extract just the component you want\n (Fech::Translator::NAME_PARSER.parse(name)[people_name] || \"\").strip\n else\n nil\n end\n end\n end\n end\n end", "def parse_name\n self.name.downcase.chomp! ':'\n\n if self.name.include? ':'\n parts = self.name.split(':')\n\n if %w(copyright character artist circle).include? parts[0]\n self.category = parts[0].to_sym\n end\n\n self.name = parts[1]\n end\n end", "def determine_name_parts(name)\n @first_name = name[0..name.index(\" \")].strip.downcase\n @last_name = name[name.index(\" \")..name.length].strip.downcase\n end", "def process_element_name(name, level)\n name = name.strip\n \n return name if @name_type == NAME_NORMAL_TYPE\n \n if @name_type == NAME_SECTION_TYPE\n return name.sub(/^[0-9.]+/, '').strip\n end\n \n rootName = name[/^[0-9a-zA-Z_:-]+/] \n puts \"No match for #{name}\" if rootName.nil?\n rootName\n end", "def parse_name(name)\n name = name.to_s\n @title = name.capitalize unless @title\n name\n end", "def parse_name(full_name)\n letter = full_name[0].upcase\n octave = full_name[/\\d+/].to_i\n accidental = full_name[/[b#x]+/] || \"\"\n return letter, octave, accidental\n end", "def parse_name name\n parts = name.split(/(::?|#|\\.)/)\n\n if parts.length == 1 then\n if parts.first =~ /^[a-z]|^([%&*+\\/<>^`|~-]|\\+@|-@|<<|<=>?|===?|=>|=~|>>|\\[\\]=?|~@)$/ then\n type = '.'\n meth = parts.pop\n else\n type = nil\n meth = nil\n end\n elsif parts.length == 2 or parts.last =~ /::|#|\\./ then\n type = parts.pop\n meth = nil\n elsif parts[1] == ':' then\n klass = parts.shift\n type = parts.shift\n meth = parts.join\n elsif parts[-2] != '::' or parts.last !~ /^[A-Z]/ then\n meth = parts.pop\n type = parts.pop\n end\n\n klass ||= parts.join\n\n [klass, type, meth]\n end", "def parse_name\n name = ''\n content = file_content\n\n s = content.index(NAME_START_DELIMITER)\n e = content.index(NAME_END_DELIMITER)\n\n unless s.nil?\n s += NAME_START_DELIMITER.size\n name = content[s..e-1].strip\n end\n\n return name\n end", "def split_name(name)\n classified_name = name.to_s.classify\n name_parts = classified_name.split(\"::\")\n namespace_name = name_parts[0...-1].join(\"::\")\n return [nil, classified_name] if namespace_name.empty?\n\n [namespace_name, name_parts.last]\n end", "def extract_name_from_text(text); end", "def namesplit(fullname)\n ary = fullname.split(\"::\")\n n = ary.pop || \"\"\n ns = ary.join(\"::\")\n return ns, n\n end", "def split_name\n\t\t@full_name.split('')\n\tend", "def name_parts(namething, count)\n parts = namething.split(\" \")\n first_name_count = parts.count - count\n return nil if count < 1\n { given: parts.first(first_name_count).join(\" \"), family: parts.last(count).join(\" \") }\n end", "def split_name_for_automatic_splitting\n temp = name\n if temp\n if temp.match /\\A[A-Z]{3}[a-z]/\n temp = temp[2..-1]\n end\n (temp && temp.split(/([A-Z]?[a-z]+)/).map(&:downcase) || []).reject do |part|\n part.size < 3\n end\n else\n []\n end\n end", "def parse_name(name)\n parts = name.split(/(::|#|\\.)/)\n if parts.length == 1 then\n # Daniel Choi fixed this line from the official rdoc \n if parts.first =~ /^[a-z=<|^&*-+\\/\\[]/ then\n type = '.'\n meth = parts.pop\n else\n type = nil\n meth = nil\n end\n elsif parts.length == 2 or parts.last =~ /::|#|\\./ then\n type = parts.pop\n meth = nil\n elsif parts[-2] != '::' or parts.last !~ /^[A-Z]/ then\n meth = parts.pop\n type = parts.pop\n end\n klass = parts.join\n [klass, type, meth]\n end", "def split_name(name)\n file_name = File.basename(name)\n mres = /^([^\\/\\.]+)\\.(.+)$/i.match(file_name)\n mres.nil? ? [file_name, ''] : [mres[1], mres[2]]\n end", "def format_name(str)\n parts = str.split(\" \")\n print parts\nend", "def parse_name(name)\n parts = name.split(/(::|\\#|\\.)/)\n\n if parts[-2] != '::' or parts.last !~ /^[A-Z]/ then\n meth = parts.pop\n parts.pop\n end\n\n klass = parts.join\n\n [klass, meth]\n end", "def parse_cust_name\n @name_parsed = true\n\n @cust_tl = ''\n @cust_fs = ''\n @cust_ls = ''\n\n\n temp = subject_cname\n temp = body_cname if temp == nil\n temp = '' if temp == nil\n\n temp.gsub!(/^.*:/, '') # remove RE: FW: etc\n\n res = Customer.split_name(temp)\n\n @cust_tl = res[0]\n @cust_fs = res[1]\n @cust_ls = res[2]\n end", "def clean_name\n return name.split(':').pop\n end", "def handle\n @name.to_str.strip.downcase.split(/[_ ]+/).join(\"_\")\n end", "def process_name(data)\n validate_name(data['name'])\n author, @module_name = data['name'].split(/[-\\/]/, 2)\n\n data['author'] ||= author if @data['author'] == DEFAULTS['author']\n end", "def parse_name(name)\n if (match = name.match(NAME_REGEX))\n {\n :host => match[1],\n :dir => fix_dir(match[2])\n }\n else\n raise WebappError, \"#{name} is not a valid webapp name\"\n end\n end", "def name_parser(uri)\n base_uri = uri.dup\n File.basename(base_uri, '.*')\n end", "def parse_name(name)\n name = [name] unless name.is_a? Array\n name_element = [*name].first\n given = [*name_element.locate('given')].map { |el| el.nodes.first.capitalize }\n family = name_element.locate('family').first.nodes.first.capitalize\n suffix = name_element.locate('suffix')&.first&.nodes&.first&.capitalize\n { given: given, family: family, suffix: suffix }\n rescue => e\n Rails.logger.warn \"MVI::Response.parse_name failed: #{e.message}\"\n { given: nil, family: nil }\n end", "def normalised_name\n /(.*?)(_\\d+)?\\z/.match(@name).captures.first\n end", "def formatNameFromString( name )\n name.split(\",\")\n end", "def formatNameFromString( name )\n name.split(\",\")\n end", "def split_name_package(fullname)\n fixing = fullname.gsub(/:/, \".\")\n split = fixing.match(/^(?:((?:\\w+\\.?)*)\\.)?(\\w+)$/) || []\n name = split[2] || \"\"\n package = split[1] || \"\"\n # downcase the first letter of each package name\n package = package.split(\".\").map {|s| s[0].downcase+s[1..-1]}.join(\".\")\n [name, package]\n end", "def components\n @components ||= @string.split('/').reject{|x| x == '' || x == nil} rescue []\n end", "def strip_part_from_activity_name(name)\n name.to_s.sub(/(.*?)\\s*Part\\b.*\\Z/i) { $1 }\n end", "def name\n name_parts.compact.join(' ')\n end", "def split_os_name(name)\n tokens = name.split(' ')\n is_number = Float(tokens[-1]) rescue false\n if is_number\n (major, minor) = tokens[-1].split('.').flatten\n name = tokens[0...-1].join(' ')\n else\n name = tokens.join(' ')\n end\n [name, major || \"\", minor || \"\"]\n end", "def normalize_name(name, prefixes); end", "def split_name(name)\n name.split(/(?<=\\S)(?=\\s)|(?<=\\s)(?=\\S)|\\b/)\n end", "def locate part_name\n @parts[part_name]\n end", "def split_name\n first, *rest = name.split(/\\b/)\n initials, after_initials = first.split(/(?=[A-Z][a-z])/, 2)\n [\n name,\n initials,\n after_initials,\n first,\n *rest,\n *name.split(/([A-Z]?[a-z]+)/)\n ].compact.map(&:downcase).uniq.map(&:freeze)\n end", "def simple_name\n name.split('::').last\n end", "def simple_name\n name.split('::').last\n end", "def parts(pathname)\n # [\"005010\", \"X221 HP835 Health Care Claim Payment Advice\"]\n parts = pathname.each_filename.to_a\n version, name, = parts\n\n case name\n when /^(X[^ ]+) ([^ ]+)/ # (X221) (HP835) Health Care Claim Payment Advice\n a, b = $1, $2\n gs01 = b[/^.{2}/]\n gs08 = [version, a]\n st01 = b[/.{3}$/]\n\n [versions.fetch(version, version), \"Implementations\", gs01, gs08, st01]\n\n when /^([A-Z]{2})(\\d{3})/ # (HP835) Health Care Claim Payment Advice\n gs01 = $1\n gs08 = [version]\n st01 = $2\n\n [versions.fetch(version, version), \"Standards\", gs01, gs08, st01]\n else\n raise name.inspect\n end\n end", "def parse_names\n strings = bibliography ? bibliography.strings.values : []\n\n NAME_FIELDS.each do |key|\n if name = fields[key]\n name = name.dup.replace(strings).join.to_name\n fields[key] = name unless name.nil?\n end\n end\n\n self\n end", "def extract_name_by_multi_name\n name = ''\n names_arr = []\n @text.scan(/(Family|FAMILY|family|First|first|FIRST|Given|GIVEN|given|LAST|Last|last){1}[\\s|\\W]{0,}(name|Name|NAME){1}([\\:|\\s|\\,|\\W]{1,})+([A-Z]{1}[A-Za-z]+)/) do | track |\n names_arr << track\n end \n if names_arr.size == 2\n name = names_arr[0][-1] + names_arr[1][-1]\n end\n return name \n end", "def parse_localname(path)\n # localname appears after the second slash\n remainder, slash, localname = path.rpartition('/')\n return [path, ''] unless remainder.index('/')\n return [remainder, localname]\n end", "def name = (name)", "def nameparts(f)\n File.basename(f).scan(/([^_]+)_([\\d]+)([^\\.]*)/)[0]\nend", "def updateName(name)\n name_array = name.split(\"\\\\\")\n return name_array[0]\nend", "def name(full_name)\n name = full_name.split(' ')\n @first_name = name[0]\n @last_name = name[1]\n end", "def normal_name(text)\n\t\t\tar = text.split(', ')\n\t\t\tlastname = ar[0]\n\t\t\tfirstpart = ar[1]\n\t\t\tfirstname = firstpart.gsub(/[[:upper:]]\\./, '').strip\n\t\t\tfirstname + ' ' + lastname\n\t\tend", "def normalize_name(name, prefixes) #:nodoc:\n\t prefixes = prefixes.presence\n\t parts = name.to_s.split('/')\n\t parts.shift if parts.first.empty?\n\t name = parts.pop\n\n\t # return here if name is just like \"show\"\n\t return name, prefixes || [\"\"] if parts.empty?\n\n\t # otherwise, change prefixes\n\t parts = parts.join('/')\n\t prefixes = prefixes ? prefixes.map { |p| \"#{p}/#{parts}\" } : [parts]\n\n\t # for input \"my/show\", [\"users\", \"application\"]\n\t # it would become\n\t # \"show\", [\"users/my\", \"application/my\"]\n\t return name, prefixes\n\t end", "def check_name\n parts = name.split '_'\n fail NotImplementedError, \\\n 'Result fetcher naming convention not being followed' \\\n unless parts.length == 2 || parts.length == 3\n end", "def split(parts); end", "def normalize_name(name, prefix)\n handlers = Template::Handlers.extensions.join('|')\n name = name.to_s.gsub(/\\.(?:#{handlers})$/, '')\n\n parts = name.split('/')\n return parts.pop, [prefix, *parts].compact.join(\"/\")\n end", "def resolve_name(inner_text, run_options)\n if inner_text.end_with?('|')\n inner_text.chop.chomp('/').split(%r{[:/]}, 2).last\n else\n inner_text\n end\n end", "def createlabelname(name)\t\t\n\n\t\tsplitname=name.split(\"/\")\n\t\tfor i in 1..splitname.length do\n# If the name is within brackets, then actual name of the person is unknown\n\t\t\tif(splitname[i-1] =~ /^\\(.+\\)/) \n\t\t\t\tsplitname[i-1] = \"(....)\\\\n\" \n\t\t\tend\n\t\tend\t\n\t\t\t\n\t\tname=splitname.join(\"\")\n\n# Initialize long name\n\t\tsplitname=name.split(\" \")\n\t\tfor i in 1..splitname.length do\n# If there are more than 2 names, and this is not 1st name or last name, and it is not already initialized, and this is not 2nd name while the first name is a title such as \"Ompu\"\n\t\t\tif(splitname.length>2 && i != 1 && i != splitname.length && !(i==2 && (splitname[0].strip==\"Ompu\" || splitname[0].strip==\"O.\" || splitname[0].strip==\"Amani\"|| splitname[0].strip==\"A.\" || splitname[0].strip==\"Aman\" || splitname[0].strip==\"Datu\" || splitname[0].strip==\"Nai\" || splitname[0].strip==\"Apa\" || splitname[0].strip==\"Pu\" || splitname[0].strip==\"Na\" || splitname[0].strip==\"Boru\" || splitname[0].strip==\"Apa\" || splitname[0].strip==\"Raja\")) )\n\t\t\t\t\tsplitname[i-1] = splitname[i-1][0,1].capitalize + \".\"\n\t\t\tend\t\n\t\tend\n\n# Put each name in new line to shorthen it\n#\t\tname.gsub!(\" \",\"\\n\")\n\n\t\tfor i in 1..splitname.length do\n# If this name is not an initial (ended by \".\"), or if it is an initial but before a non-initial\n\t\t\tif(splitname[i-1] && splitname[i])\n\t\t\t\tif(splitname[i-1][-1,1] != \".\" || (splitname[i-1][-1,1] == \".\" && splitname[i][-1,1] != \".\"))\n#\t\t\t\t\tif $orientation==\"horizontal\" then splitname[i-1]=splitname[i-1] + \" \"\n#\t\t\t\t\telse splitname[i-1]=splitname[i-1] + \"\\\\n\" end\n\t\t\t\t\tsplitname[i-1]=splitname[i-1] + \"\\\\n\"\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\tname=splitname.join(\"\")\n\n\t\tlabel= name\t\n\t\treturn label\n\tend", "def normalized_name(name)\n YangtseEveningPost.name_it_by_section_page(name)\n end", "def extract_name(full_address)\n full_address = full_address.strip\n name = full_address.split('<').first.strip\n if name.present? && name != full_address\n name\n end\n end", "def parsed_file_name\n data_file_name.split('.')[0]\n end", "def quote_name_part(part)\n part =~ /^\\[.*\\]$/ ? part : \"[#{part.gsub(']', ']]')}]\"\n end", "def get_name\n token = \"\"\n\n return expected(\"Name\") unless is_alpha($lookahead)\n\n while is_alnum($lookahead)\n token << $lookahead\n lookahead\n end\n\n skip_white\n\n \"_#{token}\"\nend", "def entity_name\n parse\n return @names.first\n end", "def rearrange(name)\n match = /(\\w+), (\\w+)( \\w+)?/.match(name) # (1)\n\n last_name = match[1]\n first_name = match[2]\n if match[3]\n separator = \"#{match[3][0,2]}. \" # (2)\n else\n separator = ' ' # (3)\n end\n \n \"#{first_name}#{separator}#{last_name}\" # (4)\nend", "def name\n $0.split(\"/\").last\n end", "def normalize_header_name(name)\n name.\n # remove heading HTTP if present\n sub(/^#{RACK_PREFIX}/, '').\n # split on underscore\n split('_').\n # transform UPCASE to Upcase\n map(&:capitalize).\n # join back on a dash\n join('-')\n end", "def split(name)\n extension = nil\n dirname, basename = File.dirname(name), File.basename(name)\n if basename =~ /^(.*)\\.(#{extensions.keys.map {|e| Regexp.escape(e)}.join('|')})$/\n basename = $1\n extension = $2\n end\n [dirname, basename, extension]\n end", "def name\n @name ||= to_s.split(\"#\").last.delete(\">\")\n end", "def name\n @token\n #match(/^Information\\son\\s([^\\s]+)/)\n end", "def process_names(name = nil, name_formula = nil) # :nodoc:\n # Name looks like a formula, use it to set name_formula.\n if name && name =~ /^=[^!]+!\\$/\n name_formula = name\n name = ''\n end\n\n [name, name_formula]\n end", "def validate_name(name)\n return if name =~ /\\A[a-z0-9]+[-\\/][a-z][a-z0-9_]*\\Z/i\n\n namespace, modname = name.split(/[-\\/]/, 2)\n modname = :namespace_missing if namespace == ''\n\n err = case modname\n when nil, '', :namespace_missing\n \"the field must be a namespaced module name\"\n when /[^a-z0-9_]/i\n \"the module name contains non-alphanumeric (or underscore) characters\"\n when /^[^a-z]/i\n \"the module name must begin with a letter\"\n else\n \"the namespace contains non-alphanumeric characters\"\n end\n\n raise ArgumentError, \"Invalid 'name' field in metadata.json: #{err}\"\n end", "def element_parse_naming\n OBJ_ELEMENT_PARSE_NAMING\n end", "def initialize(name)\n splits = name.to_s.split(\":\")\n\n splits.size < 2 ? @name = splits.first : (@curie, @name = splits)\n end", "def normalize_name(name)\n return name.to_s if !name.is_a?(String) && !name.is_a?(MatchData)\n name = name.captures.compact.join('-') if name.is_a?(MatchData)\n name.split('-').map { |s| s[/\\A[0-9]\\Z/].nil? ? s : \"0#{s}\" }.join('-').upcase\nrescue\n name.to_s\nend", "def process(name)\n self.ext = File.extname(name)\n self.basename = name.split('.')[0..-2].first\n end", "def name(entered_name)\n split_name = entered_name.split\n @first_name = split_name[0].capitalize\n @last_name = split_name[1].capitalize\n end", "def _prepareName ( name )\n name.to_s.gsub /[\\W]/, ''\n end", "def name\n return @name if @name\n candidate = Reality::Naming.jsonize(struct.name)\n return candidate[0, candidate.size-4] if candidate =~ /_dto$/\n return candidate[0, candidate.size-3] if candidate =~ /_vo$/\n return candidate\n end", "def middle_name\n name.split[1..-2].join(' ')\n end", "def first_name\n # self.name.split[0] atau\n \tself.name.split.first\n end", "def parse_name\n\tname = ARGV.shift\n\tunless %w(jo caro wir).include?(name)\n\t\tname = 'jo' \n\t\tputs \"assuming jo...\"\n\tend\n\treturn name\nend", "def extract_full_names(s)\n\ts = \" \".concat(s).concat(\" \")\n\t#puts \"###############################################\"\n\t#puts s\n\tlist = s.scan(/\\s'?\"?\\w+,?\\s\\w+[,']?\\.?\\s?\\w*\\s?&?\\s?\\w*\"?'?\\s/)\n\t#puts \"=>\", list\n\tlist.map! do |name| \n\t\ttmp = name.sub(/^\\s*/, \"\").sub(/\\s*$/, \"\").sub(/<.+>/, \"\").sub(/,$/, \"\").delete(\"\\\"\\'\\.\")\n\t\tif tmp.include?(\",\") and !tmp.include?(\"&\")then\n\t\t\tl = tmp.split(\",\")\n\t\t\tl[1].sub!(/^\\s*/, \"\")\n\t\t\t#assert(l.length == 2, \"fails at #{tmp} out of #{s}\")\n\t\t\tif (l.length != 2) then\n\t\t\t\ttmp = \"\"\n\t\t\telse\n\t\t\t\ttmp = l[1].concat(\" \").concat(l[0])\n\t\t\tend\n\t\tend\n\t\ttmp\n\tend\n\tlist\nend", "def parse_domain_attr(name)\n unless name.is_a?(String)\n fail 'domain attribute name must be a string'\n end\n\n *first, last = name.split('.')\n [first.join('.'), last]\n end", "def parse_directory_name path\n dirname = path.basename.to_s\n dirname.split('.')\n end", "def parse_params(params)\n name = params[:splat].first\n version = 'master'\n tag_name = nil\n\n if name.index(/^v\\d/)\n repo = Grit::Repo.new(repository.path)\n tag_name = name.split('/').first\n repo.tags.each do |tag|\n if tag.name == tag_name # TODO: don't assume actual v prefix\n version = tag.commit.id\n name = name.split('/')[1..-1].join('/')\n end\n end\n end\n\n return name, version, tag_name\n end", "def create_first_name(name)\n name.split[1]\n end", "def get_namespace_and_name(input_remote_name, delimiter)\n if (input_remote_name||'').include?(delimiter)\n input_remote_name.split(delimiter)\n # support ns/name as well as ns:name\n elsif (input_remote_name||'').include?('/')\n input_remote_name.split('/')\n else\n [nil, input_remote_name]\n end\n end", "def human_from_name; end", "def fragment_of_variable_or_method_name(name)\n \t_IDENTIFIER14 = nil\n\n\n\n\n # 269:7: '.' IDENTIFIER\n match(:DOT)\n _IDENTIFIER14 = @input.look_ahead(1)\n match(:IDENTIFIER)\n name << \".#{_IDENTIFIER14.text}\"\n\n\n\n end", "def consume_name\n result = ''\n\n while true\n if match = @s.scan(RE_NAME)\n result << match\n next\n end\n\n char = @s.peek\n\n if char == '\\\\' && valid_escape?\n @s.consume\n result << consume_escaped\n\n # NON-STANDARD: IE * hack\n elsif @options[:preserve_hacks] && char == '*'\n result << @s.consume\n\n else\n return result\n end\n end\n end", "def pretty_name\n name.gsub(/\\.([^.]+)$/, '')\n end", "def process(name)\n return unless name\n\n self.ext = File.extname(name)\n self.basename = name[0..-ext.length - 1].gsub(%r!\\.*\\z!, \"\")\n end", "def cap_name(name)\n node_name = \"\"\n name.split('_').each { |k| node_name << k.up} \n node_name\n end", "def _validate_name(name)\n if name =~ %r{/}\n results.add_error('name', 'The name of a spec should not contain ' \\\n 'a slash.')\n end\n\n if name =~ /\\s/\n results.add_error('name', 'The name of a spec should not contain ' \\\n 'whitespace.')\n end\n\n if name[0, 1] == '.'\n results.add_error('name', 'The name of a spec should not begin' \\\n ' with a period.')\n end\n end", "def parse_tag_with_name(tag_name, text); end", "def full_name\n name_tuple.full_name\n end", "def parse_container_name(service_name, instance_number)\n base = service_name.gsub('/', '-')\n unless service_name.include?('/')\n base = \"null-#{base}\"\n end\n \"#{base}-#{instance_number}\"\n end", "def name\n parse('superhero.name')\n end", "def name\n @name ||= details.at(\"h1.header span[itemprop='name']\").text.strip.clean_name\n end" ]
[ "0.74915344", "0.73031646", "0.72734565", "0.7090266", "0.6967317", "0.67970014", "0.6673841", "0.65575314", "0.6501499", "0.64541054", "0.643271", "0.63899785", "0.63636893", "0.62957394", "0.62590694", "0.62526435", "0.6192063", "0.61659515", "0.6164098", "0.6126027", "0.61152273", "0.60974485", "0.60737914", "0.6054853", "0.6040819", "0.6039372", "0.6008452", "0.6007832", "0.59883904", "0.59435046", "0.58957887", "0.58957887", "0.58852166", "0.58670825", "0.5861704", "0.5847233", "0.5844121", "0.583916", "0.5765847", "0.5759626", "0.57473075", "0.57270944", "0.57270944", "0.57164294", "0.57145625", "0.57037616", "0.56948346", "0.5691951", "0.5639964", "0.56399494", "0.56016415", "0.55773884", "0.55666804", "0.55497575", "0.5531934", "0.5524984", "0.5524845", "0.5511288", "0.5503624", "0.54935044", "0.5484055", "0.5482941", "0.5481201", "0.54762197", "0.54752326", "0.5467887", "0.54641885", "0.54637736", "0.5448519", "0.5448207", "0.54376566", "0.5434717", "0.5431479", "0.54308444", "0.54279053", "0.5426218", "0.54197973", "0.5406162", "0.53932714", "0.53864646", "0.5375687", "0.5367725", "0.53663486", "0.53552085", "0.5352835", "0.5343398", "0.5337008", "0.53342676", "0.53318715", "0.53240144", "0.5323031", "0.5319621", "0.53189176", "0.5311045", "0.53085303", "0.53067213", "0.53052676", "0.529938", "0.52983963", "0.5292209" ]
0.61358863
19
Returns a bean from the +RequestStore+ RequestStore is a wrapper for Thread.current which clears it on each new HTTP request
def get_bean(bean_metadata) RequestStore.store[:_iocrb_beans] ||= {} if bean = RequestStore.store[:_iocrb_beans][bean_metadata.name] bean else @bean_factory.create_bean_and_save(bean_metadata, RequestStore.store[:_iocrb_beans]) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def current_store_id\n Thread.current[REQUEST_STORE_ID]\n end", "def store\n @store ||= Store.new\n end", "def request\n @request ||= Request.find request_id\n end", "def request; return @request end", "def store\r\n return @store\r\n end", "def fetch_store\n @store ||= self.store || create_store!\n end", "def request\n SharedStorage.get(:request)\n end", "def request\n @@request\n end", "def store\n return self.class.store\n end", "def request\n @@request\n end", "def store\n @store ||= Store.first || Store.create\n end", "def store\n @store ||= storage.new self\n end", "def request\n @_context[:request]\n end", "def request\n @request ||= ::Lotus::Action::Request.new(@_env)\n end", "def request\n @_request\n end", "def store\n @@store ||= Store.get_store(0)\n end", "def new_store\n Cache.new\n end", "def store\n Thread.current\n end", "def store\n @store ||= {}\n end", "def get_store\n ActiveRecord::MemoryStore.new\n end", "def request_data\n Thread.current[THREAD_LOCAL_NAME] ||= {}\n end", "def request\n @controller.request\n end", "def request\n @controller.request\n end", "def request\n @controller.request\n end", "def request\n @request\n end", "def store\n @store ||= Hash.new\n end", "def current_request\n controller.request if has_request?\n end", "def request # :doc:\n @request ||= begin\n environment = Rails.application.env_config.merge(env) if defined?(Rails.application) && Rails.application\n ActionDispatch::Request.new(environment || env)\n end\n end", "def cache_request\n cache\n end", "def store\n @cache.compute_if_absent(current_store_id) { new_store }\n end", "def request\n OpenStruct.new\n end", "def store\n @store ||= OpenStruct.new\n end", "def store\n @store\n end", "def store\n @store\n end", "def request_object\n $REQUEST\n end", "def context\n Thread.current[NAME] ||= Hash.new\n end", "def read(request, klass = Faraday::HttpCache::Response)\n cache_key = cache_key_for(request)\n found = @cache.read(cache_key)\n\n if found\n payload = @serializer.load(found).each_with_object({}) do |(key,value), hash|\n hash[key.to_sym] = value\n end\n\n klass.new(payload)\n end\n end", "def request\n @request ||= Request.new(::Minfraud::HTTPService.configuration)\n end", "def in(store)\n store_class = if store.is_a? Symbol\n MobileStores::STORES[store]\n elsif store.is_a? String\n Object.const_get(store) rescue nil\n elsif store.is_a? Class\n store\n end\n\n raise NotImplementedError, \"#{ store } is not implemented yet.\" if store.nil?\n\n store_class.new\n end", "def current_store\n @current_store = session[:store_id].nil? ? Sap::Store.first : Sap::Store.find(session[:store_id])\n end", "def index\n @request_master = RequestMaster.new\n end", "def set_store\n @store = Store.where(id: params[:id]).take\n end", "def store\n self.class.store\n end", "def store_request(object)\n return unless ensure_rack_loaded\n SharedStorage.set(:request, Rack::Request.new(object))\n SharedStorage.inc(:stored_requests)\n end", "def request\n @request ||= Rack::Request.new(@env)\n end", "def request\n @request ||= Rack::Request.new(@env)\n end", "def sysuser_\n RequestStore[:current_user] = User.system_user\nend", "def session\n @session ||= Session.new(@request)\n end", "def set_request\n $request = request\n end", "def cached_instance\n @cached_instance ||= read_instance\n end", "def request\n double(ActionDispatch::Request, { path: \"/\" })\n end", "def request\n @request ||= Rack::Request.new(env)\n end", "def current_request_id\n RequestStore.store[:current_request_id] || \"NONE\"\n end", "def request\n nil\n end", "def initialize\n @store = {}\n end", "def request=(request); @request = request end", "def store\n @store ||= MotionPrime::Store.shared_store\n end", "def cache_store\n return nil if context.environment.cache.nil?\n\n CacheStore.new context.environment\n end", "def current_store\n user = current_user\n return nil unless user\n return nil unless session[:store_id]\n user.stores.get(session[:store_id])\nend", "def request_context(request)\n @request_context ||= Request.retriever_for_request(request)&.call\n end", "def proxy\n self.class.proxy.new(session)\n end", "def store_request(request)\n @requests_lock.synchronize { @requests << request } if @keep_requests\n end", "def instance\n\t\t\tthread = Thread.current\n\t\t\tname = self.name\n\t\t\t\n\t\t\tunless instance = thread.thread_variable_get(name)\n\t\t\t\tif instance = self.local\n\t\t\t\t\tthread.thread_variable_set(name, instance)\n\t\t\t\tend\n\t\t\tend\n\t\t\t\n\t\t\treturn instance\n\t\tend", "def session\n @session ||= Session.new(request)\n end", "def request(&_)\n if block_given?\n @request ||= Request.new\n yield @request\n end\n @request\n end", "def request_context\n @requester ? @requester.request : \"(unknown)\"\n end", "def store\n @store ||= Globot::Plugins.store.proxy_for(self)\n end", "def store\n @store ||= Store.find(options[:store]).new(options[:source])\n end", "def call(request)\r\n self\r\n end", "def new\n #@request = Request.new\n end", "def session\n @session ||= Session.new(@request)\n @session\n end", "def session\n # lazy assign so session persists for entire controller life\n @session ||= Session.new(@req)\n end", "def store\n _store_id = store_id\n ::Spree::User.logger.debug \"| ByParameters: store_id #{_store_id}\"\n store = _store_id ? ::Spree::Store.where(id: _store_id).first : nil\n store || Spree::Store.new\n end", "def request\n @request ||= Rack::MockRequest.new(mack_app)\n end", "def new\n @request = Request.new\n end", "def get\n BabboShop.instance ||= BabboShop.new\n end", "def request_source\n return @request_source\n end", "def session\n @request.session\n end", "def cache_store\n return nil if _cache.nil?\n return _cache if _cache.class != ActiveSupport::Cache::NullStore\n if ActiveModelSerializers.config.cache_store\n self._cache = ActiveModelSerializers.config.cache_store\n else\n nil\n end\n end", "def cache_store\n return nil if _cache.nil?\n return _cache if _cache.class != ActiveSupport::Cache::NullStore\n if ActiveModelSerializers.config.cache_store\n self._cache = ActiveModelSerializers.config.cache_store\n else\n nil\n end\n end", "def request\n view_context.request\n end", "def request\n @req\n end", "def params\n RequestStore.store[:params]\n end", "def get(context = Context.current)\n context[self]\n end", "def root; thread_local_store[:root] end", "def request\n @request ||= ActionDispatch::TestRequest.create.tap do |request|\n request.request_id = SecureRandom.uuid\n end\n end", "def session\n @request.session\n end", "def req\n return @req\n end", "def retrieve\n http_class = http_proxy @proxy[:host], @proxy\n\n @_req = http_class.new @uri.host, @uri.port\n\n @_req.read_timeout = @timeout if @timeout\n @_req.use_ssl = true if @uri.scheme =~ /^https$/\n\n elapsed_time = nil\n socket = nil\n socket_io = nil\n\n @_res = @_req.start do |http|\n socket = http.instance_variable_get \"@socket\"\n socket.debug_output = socket_io = StringIO.new\n\n start_time = Time.now\n res = http.request self.http_request, @body\n elapsed_time = Time.now - start_time\n\n res\n end\n\n Kronk.cookie_jar.set_cookies_from_headers @uri.to_s, @_res.to_hash if\n self.use_cookies\n\n @response = Response.new socket_io, @_res, self\n @response.time = elapsed_time\n\n @response\n end", "def drag_pool_store\n session[:pool_store]\n end", "def retrieve_store_class(store)\n # require_relative cannot be used here because the class might be\n # provided by another gem, like redis-activesupport for example.\n require \"active_support/cache/#{store}\"\n rescue LoadError => e\n raise \"Could not find cache store adapter for #{store} (#{e})\"\n else\n ActiveSupport::Cache.const_get(store.to_s.camelize)\n end", "def reload\n self.replace( CouchSpring.get( uri ) )\n end", "def fetch\n Starwars::Request.new(request_attributes).perform_request\n end", "def ensure_store\n @store ||= LocalStorage.new\n end", "def set_request_property\n @request_property = RequestProperty.find(params[:id])\n end", "def save\n store = NotFoundCatcher.request_store.store\n store.transaction do\n\n store[self.role] = self\n\n end\n\n\n end", "def new(request, url_generator)\n Context.new(@store, @message_bus, @application_id, url_generator, request.content_type)\n end", "def query ; @query ||= Waves::Request::Query.new( request.query ) ; end", "def show\n @request = Request.new\n end", "def set_request\n @request = nil\n if Request.where(id: params[:id]).count > 0\n @request = Request.find(params[:id])\n end\n end" ]
[ "0.60839844", "0.58515716", "0.5803903", "0.57329524", "0.5674762", "0.56621367", "0.5658496", "0.56380916", "0.5631599", "0.5599377", "0.5575453", "0.5530602", "0.5525201", "0.5510733", "0.54759634", "0.54513603", "0.54027766", "0.5393321", "0.53845966", "0.53569484", "0.53486794", "0.5311261", "0.5311261", "0.5311261", "0.52669597", "0.52630126", "0.5243673", "0.5184723", "0.51709664", "0.5164471", "0.51063", "0.5105179", "0.50900656", "0.50900656", "0.50669193", "0.5064596", "0.5062387", "0.5059526", "0.5036379", "0.5033859", "0.5010705", "0.5009987", "0.50071025", "0.49956685", "0.49873778", "0.49873778", "0.49791497", "0.49687776", "0.49141988", "0.49091375", "0.49046892", "0.49040797", "0.48678523", "0.48599216", "0.48358202", "0.48339927", "0.4823556", "0.48161197", "0.48125425", "0.48124716", "0.47908065", "0.4785756", "0.47711557", "0.47706342", "0.47655883", "0.47569636", "0.47406584", "0.47364575", "0.4733304", "0.47332022", "0.4716287", "0.47152692", "0.47135478", "0.471121", "0.47060046", "0.4700413", "0.46980733", "0.46918768", "0.4688912", "0.4688912", "0.46872032", "0.46862978", "0.46812293", "0.4678382", "0.4676385", "0.4672743", "0.46689546", "0.4668085", "0.46662015", "0.4664703", "0.46516678", "0.46497297", "0.4649572", "0.46490502", "0.4647023", "0.46448988", "0.4641579", "0.46391946", "0.46364507", "0.4633393" ]
0.5112336
30
Delete bean from scope
def delete_bean(bean_metadata) RequestStore.store[:_iocrb_beans].delete(bean_metadata.name) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete_bean(bean_metadata)\n @beans.delete(bean_metadata.name)\n end", "def delete(connection)\n connection.delete_engine(@id, @scope)\n end", "def destroy; delete end", "def del\n delete\n end", "def _destroy_delete\n delete\n end", "def _destroy_delete\n delete\n end", "def destroy\n @coffee_bean = CoffeeBean.find(params[:id])\n @coffee_bean.destroy\n\n respond_to do |format|\n format.html { redirect_to coffee_beans_url }\n format.json { head :no_content }\n end\n end", "def delete!\n @resource.delete!\n end", "def delete\n before_delete\n this.delete\n self\n end", "def destroy!\n destroy { trigger :refresh }\n end", "def delete\n destroy\n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy\n @binder=Binder.find(params[:binder_id])\n\n @tab.destroy\n respond_with(@binder, @tab)\n end", "def destroy!; end", "def delete\n destroy\n # update_attributes(deleted: true)\n end", "def remove!\n destroy\n end", "def remove\r\n self.update(deleted: true)\r\n end", "def destroy\n self.delete_\n end", "def destroy\n\t\t@flavor = Flavor.find(params[:id])\n\t\t@flavor.destroy\n\t\tredirect_to new_beanformed_company_bean_flavor_path(params[:company_id], params[:bean_id])\n\tend", "def destroy\n @exp_attribute.destroy\n end", "def destroy\n @dhcp_scope = DhcpScope.find(params[:id])\n @dhcp_scope.destroy\n\n respond_to do |format|\n format.html { redirect_to(dhcp_scopes_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n self.update_attribute :deleted, true\n end", "def destroy\n @rcontroller.destroy\n end", "def destroy\r\n do_without_exception(:destroy!)\r\n end", "def delete\n Fission::Action::VM::Deleter.new(self).delete\n end", "def deleted(build)\n end", "def destroy\n onetemplate('delete', resource[:name])\n @property_hash.clear\n end", "def delete\n self.class.delete(\"evss_dependents_retrieve_#{@user.uuid}\")\n end", "def destroy!\n self.destroy\n end", "def destroy\r\n\r\n end", "def destroy\n\t\trun_callbacks(:destroy) { delete } \n\tend", "def delete(sector)\n @sectors.delete(sector) \n end", "def delete!\n clear!\n delete\n end", "def delete\n @resource.delete\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def destroy\n end", "def delete\n destroy\n end", "def delete\n destroy\n end", "def destroy\n @service.destroy\n end", "def destroy\n @service.destroy\n end", "def destroy\n @service.destroy\n end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy; end", "def destroy\r\n end", "def destroy\r\n end", "def destroy\r\n end", "def delete\n appctrl_delete( 'User' )\n end", "def delete\n self.store -= self\n end", "def destroy\n update_attributes! deleted:true\n end", "def destroy\n self.is_deleted = true\n self.save!\n run_callbacks :destroy do\n delete\n end\n end", "def remove (exp)\n\n exp, _fei = fetch(exp) if exp.is_a?(FlowExpressionId)\n\n return unless exp\n\n #ldebug { \"remove() fe #{exp.fei.to_debug_s}\" }\n\n onotify(:remove, exp.fei)\n\n remove_environment(exp.environment_id) if exp.owns_its_environment?\n end", "def delete_object\n controller_session[\"object\"] = nil\n end", "def destroy\n\n end", "def destroy\n\n end", "def delete\n # TODO: implement delete\n end", "def delete\n del unless new_record?\n set_deleted_properties\n end", "def delete!\n Model.model_store.delete!(self)\n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy\n \n end", "def destroy_persona\n persona.destroy\n end", "def destroy\n @customer.destroy\n end", "def destroy\n @command.destroy\n end", "def destroy\n onesecgroup('delete', resource[:name])\n @property_hash.clear\n end", "def destroy\n self.class.delete(id)\n end", "def delete!\n deleted\n save!\n end", "def delete\n self.class.delete_service_instance(@service_name, @name)\n end", "def destroy\n\n end", "def destroy\n\n end", "def destroy\n\n end", "def destroy\n\n end", "def destroy\n\n end", "def destroy\n\n end", "def destroy\n\n end", "def destroy\n\n end", "def destroy\n\n end", "def destroy\n\n end", "def destroy\n\n end", "def destroy\n\n end", "def destroy\n\n end", "def destroy\n\n end", "def destroy\n\n end", "def destroy\n\n end", "def destroy\n\n end" ]
[ "0.6948997", "0.61377937", "0.60326993", "0.60160136", "0.60052586", "0.60052586", "0.5998532", "0.59936553", "0.5950794", "0.58859587", "0.5831397", "0.58312243", "0.58312243", "0.58285487", "0.5824112", "0.58174294", "0.58138067", "0.5801735", "0.5779715", "0.5778879", "0.5776025", "0.5773118", "0.575623", "0.5742685", "0.5736087", "0.5715741", "0.57107943", "0.5709243", "0.57066655", "0.5705575", "0.5701707", "0.57007253", "0.5698084", "0.56863874", "0.5684629", "0.5670666", "0.5670666", "0.5670666", "0.5670666", "0.5670666", "0.5669657", "0.5669657", "0.56643444", "0.56643444", "0.56643444", "0.56642103", "0.56642103", "0.56642103", "0.56642103", "0.56642103", "0.56642103", "0.56642103", "0.56642103", "0.56642103", "0.56642103", "0.5663302", "0.56608355", "0.56608355", "0.56538063", "0.56528324", "0.5647693", "0.5640578", "0.56368774", "0.5634606", "0.5627598", "0.5627598", "0.5623355", "0.5621127", "0.5620415", "0.5615957", "0.5615957", "0.5615957", "0.5615957", "0.5615957", "0.5615957", "0.5615957", "0.5607827", "0.56053567", "0.56049526", "0.5594564", "0.5593841", "0.55875826", "0.5584515", "0.5582228", "0.5582228", "0.5582228", "0.5582228", "0.5582228", "0.5582228", "0.5582228", "0.5582228", "0.5582228", "0.5582228", "0.5582228", "0.5582228", "0.5582228", "0.5582228", "0.5582228", "0.5582228", "0.5582228" ]
0.7090844
0
Use callbacks to share common setup or constraints between actions.
def set_trade_charge @trade_charge = TradeCharge.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 trade_charge_params params.require(:trade_charge).permit(:kind_class, :subtype, :premium, :runt, :revenue) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def strong_params\n params.require(:user).permit(param_whitelist)\n end", "def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end", "def allow_params_authentication!; end", "def allowed_params\n ALLOWED_PARAMS\n end", "def default_param_whitelist\n [\"mode\"]\n end", "def param_whitelist\n [:role, :title]\n end", "def expected_permitted_parameter_names; end", "def safe_params\n params.except(:host, :port, :protocol).permit!\n end", "def strong_params\n params.require(:team_member).permit(param_whitelist)\n end", "def permitir_parametros\n \t\tparams.permit!\n \tend", "def strong_params\n params.require(:community).permit(param_whitelist)\n end", "def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end", "def strong_params\n params.require(:education).permit(param_whitelist)\n end", "def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end", "def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end", "def param_whitelist\n [:rating, :review]\n end", "def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end", "def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end", "def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end", "def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end", "def valid_params_request?; end", "def strong_params\n params.require(:experience).permit(param_whitelist)\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end", "def allowed_params\n params.require(:allowed).permit(:email)\n end", "def permitted_params\n []\n end", "def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end", "def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end", "def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend", "def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end", "def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end", "def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end", "def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end", "def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end", "def safe_params\n params.require(:user).permit(:name)\n end", "def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend", "def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end", "def check_params; true; end", "def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end", "def quote_params\n params.permit!\n end", "def valid_params?; end", "def paramunold_params\n params.require(:paramunold).permit!\n end", "def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend", "def filtered_parameters; end", "def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end", "def filtering_params\n params.permit(:email, :name)\n end", "def check_params\n true\n end", "def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end", "def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend", "def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend", "def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end", "def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end", "def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end", "def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend", "def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end", "def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end", "def active_code_params\n params[:active_code].permit\n end", "def filtering_params\n params.permit(:email)\n end", "def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end", "def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end", "def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end", "def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end", "def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end", "def list_params\n params.permit(:name)\n end", "def filter_parameters; end", "def filter_parameters; end", "def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end", "def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end", "def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end", "def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end", "def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end", "def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end", "def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end", "def url_whitelist; end", "def admin_social_network_params\n params.require(:social_network).permit!\n end", "def filter_params\n params.require(:filters).permit(:letters)\n end", "def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end", "def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end", "def sensitive_params=(params)\n @sensitive_params = params\n end", "def permit_request_params\n params.permit(:address)\n end", "def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end", "def secure_params\n params.require(:location).permit(:name)\n end", "def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end", "def question_params\n params.require(:survey_question).permit(question_whitelist)\n end", "def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end", "def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end", "def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end", "def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end", "def url_params\n params[:url].permit(:full)\n end", "def backend_user_params\n params.permit!\n end", "def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend", "def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end", "def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end", "def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end", "def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end", "def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end", "def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end", "def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end", "def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end" ]
[ "0.69792545", "0.6781151", "0.67419964", "0.674013", "0.6734356", "0.6591046", "0.6502396", "0.6496313", "0.6480641", "0.6477825", "0.64565", "0.6438387", "0.63791263", "0.63740575", "0.6364131", "0.63192815", "0.62991166", "0.62978333", "0.6292148", "0.6290449", "0.6290076", "0.62894756", "0.6283177", "0.6242471", "0.62382483", "0.6217549", "0.6214457", "0.6209053", "0.6193042", "0.6177802", "0.6174604", "0.61714715", "0.6161512", "0.6151757", "0.6150663", "0.61461", "0.61213595", "0.611406", "0.6106206", "0.6105114", "0.6089039", "0.6081015", "0.6071004", "0.60620916", "0.6019971", "0.601788", "0.6011056", "0.6010898", "0.6005122", "0.6005122", "0.6001556", "0.6001049", "0.59943926", "0.5992201", "0.59909594", "0.5990628", "0.5980841", "0.59669393", "0.59589154", "0.5958826", "0.5957911", "0.5957385", "0.5953072", "0.59526145", "0.5943361", "0.59386164", "0.59375334", "0.59375334", "0.5933856", "0.59292704", "0.59254247", "0.5924164", "0.59167904", "0.59088355", "0.5907542", "0.59064597", "0.5906243", "0.5898226", "0.589687", "0.5896091", "0.5894501", "0.5894289", "0.5891739", "0.58860534", "0.5882406", "0.587974", "0.58738774", "0.5869024", "0.58679986", "0.5867561", "0.5865932", "0.5864461", "0.58639693", "0.58617616", "0.5861436", "0.5860451", "0.58602303", "0.5854586", "0.58537364", "0.5850427", "0.5850199" ]
0.0
-1
Method to find and return both the mean and the standard deviation
def mean_sigma(v) mean = mean(v); diff = []; mean_delta = 0.0; i=0; v.each{|n|; mean_delta = (n-mean).abs; diff[i] = mean_delta; i += 1;} std_dev = mean(diff); return mean, std_dev; end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stddev()\n if mean == -1\n mean()\n end\n\n sum = 0\n @difference.each do |item|\n sum += (item - @mean) ** 2\n end\n\n stddev = (sum / difference.length) ** 0.5\n\n return stddev\n end", "def calc_stdev(data)\n # Calculate the mean\n sum = 0\n count = data.length\n data.each do |d|\n sum += d \n end\n mean = sum / count\n \n # Calculate the square of the difference from the mean, for each value in the array\n sqr_diffs = Array.new\n data.each do |d|\n sqr_diffs.push((d - mean) ** 2)\n end\n \n # Calculate the mean of the squared differences\n # This is the variance\n sum = 0\n count = sqr_diffs.length\n sqr_diffs.each do |d|\n sum += d\n end\n variance = sum / count\n \n # Calculate the square root of the variance\n # This is the standard deviation\n stdev = Math.sqrt(variance)\n \n return stdev\nend", "def std_dev\n count = self.size\n mean = self.avg\n return Math.sqrt( self.inject(0) { |sum, e| sum + (e - mean) ** 2 } / count.to_f )\n end", "def stddev\n sum = 0\n meanerror = mean\n @test.each do |value|\n sum += (value[2] - value[3] - meanerror) ** 2\n end\n\n Math.sqrt(sum/@test.length.to_f)\n end", "def std_dev\n avg = mean()\n sum_sqrd_diffs = 0\n @errors.each do |e|\n sum_sqrd_diffs += ((e - avg) ** 2)\n end\n return Math.sqrt(sum_sqrd_diffs/(@total_predictions.to_f - 1))\n end", "def stddev\n mean = self.mean\n @list.each do |tuple|\n temp += (tuple['rating'] - tuple['predicted_rating'] - mean) ** 2\n end\n Math.sqrt(temp)\n end", "def std_dev\n Math.sqrt((@sum2.to_f - ((@sum.to_f * @sum.to_f)/@count.to_f)) / (@count.to_f - 1))\n end", "def stddev()\n meanPredictionError = mean\n diffSquare = @list.collect {|item| ((item[:prediction] - item[:rating]) - meanPredictionError) ** 2}\n Math.sqrt(sum(diffSquare) / (diffSquare.length - 1))\n end", "def stddev\n deviation = 0\n @predictions.each do |p|\n deviation += (p.error - @mean) * (p.error-@mean)\n end\n return Math.sqrt(deviation/predictions.size)\n end", "def standard_deviation(values)\n mu = mean(values) # mean will usually have already been calculated\n # naive algorithm risks underflow\n variance = sum(values.collect {|x| (x - mu)**2 }) / (values.count)\n Math::sqrt(variance)\nend", "def standard_deviation\n\t\tif (self.size == 0)\n\t\t\t0.0\n\t\telse\n\t\t\tmean = self.mean\n\t\t\tMath.sqrt(self.collect{ |e| (mean - e) ** 2.0 }.inject(&:+) / self.size)\n\t\tend\n\tend", "def stddev()\n\t\tmean = mean()\n\t\tav_error = 0.0\n\t\tresults.each do |row|\n\t\t\tav_error += ((row[\"rating\"].to_f-row[\"predicted\"].to_f).abs - mean)**2\n\t\tend\n\t\ttobesquared = av_error/results.length.to_f\n\t\treturn Math.sqrt(tobesquared)\n\tend", "def std_dev(ary, mean)\n Math.sqrt( (ary.inject(0) { |dev, i| \n dev += (i - mean) ** 2}/ary.length.to_f) )\nend", "def stddev\n\t\tsum = 0\n\t\tm = mean\n\t\tpred_list.each do |pred|\n\t\t\tsum += (pred[:error] - m) ** 2\n\t\tend\n\t\treturn Math.sqrt(sum / size)\n\tend", "def stddev()\n return Math.sqrt(self.var())\n end", "def stddev\n sum = @data.inject(0) do |accu, hash|\n err = hash[:prediction] - hash[:rating]\n accu + (err - @mean) ** 2\n end\n return Math.sqrt(sum.to_f / (@data.size - 1))\n end", "def stddev\n Math.sqrt(variance)\n end", "def standard_deviation\n Math.sqrt sample_variance\n end", "def stddev\n\t\tMath.sqrt(variance)\n\tend", "def stddev\n\t\tMath.sqrt(variance)\n\tend", "def standardDeviation( values )\n sum = 0.0\n values.each { |value|\n sum += value\n }\n fMean = sum / values.size\n\n deviations = Array.new(0)\n values.each{ |value|\n dev = value - fMean\n deviations.push( dev * dev )\n }\n\n devSum = 0.0\n deviations.each{ |dev|\n devSum += dev\n }\n\n fVariance = devSum / (deviations.size - 1)\n return Math.sqrt(fVariance)\n end", "def standard_deviation(sample = false)\n Math.sqrt(self.variance(sample))\n end", "def std_dev\n Statistics.std_dev @data\n end", "def get_standard_deviation\n return Math.sqrt(get_variance)\n end", "def get_standard_deviation\n return Math.sqrt(get_variance)\n end", "def get_standard_deviation\n return Math.sqrt(get_variance)\n end", "def standard_deviation\n Math.sqrt(sample_variance)\n end", "def standard_deviation\n Math.sqrt(self.sample_variance)\n end", "def stdev\n Math.sqrt(variance)\n end", "def standard_deviation\n return Math.sqrt(self.sample_variance)\n end", "def standard_deviation\n return Math.sqrt(self.sample_variance)\n end", "def standard_deviation\n return Math.sqrt(self.sample_variance)\n end", "def standard_deviation\n return Math.sqrt(self.sample_variance)\n end", "def standard_deviation\n return Math.sqrt(self.sample_variance)\n end", "def standard_deviation\n return Math.sqrt(self.sample_variance)\n end", "def standard_deviation\n return Math.sqrt(self.sample_variance)\n end", "def standard_deviation\n return Math.sqrt(self.sample_variance)\n end", "def stddev\n return 0.0 unless @count > 1\n Math.sqrt((@sumsq - ((@sum * @sum)/@count)) / (@count - 1))\n end", "def standard_deviation(array)\n sum = array.inject(0.0) { | result, value | result + value}\n average = sum / array.size\n variance = (array.inject(0.0) { | total, result | total + (average - result)**2}) / array.size\n Math.sqrt(variance)\n end", "def standard_deviation\n Math.sqrt(variance)\n end", "def standard_deviation\n Math.sqrt(variance)\n end", "def stddev\n Math::sqrt(@variance)\n end", "def standard_deviation\n Math.sqrt(self.variance)\n end", "def standard_deviation\n\t\treturn nil unless any?\n\n\t\tMath.sqrt(variance)\n\tend", "def stddev\n return @stddev if @stddev\n @stddev = 0\n return if @t == 1\n @thresholds.each { |t| @stddev += (t - @mean)*(t - @mean) }\n @stddev /= @t - 1\n @stddev = @stddev\n end", "def standard_deviation(ages)\n sum_of_all_nums = sum_all(ages)\n total_number_in_array = num_of_integers(ages)\n average = average(sum_of_all_nums, total_number_in_array)\n average_subtracted = subtract_each_by_average(ages, average)\n squared = result_squared(average_subtracted)\n squared_sum = sum_all_squared(squared)\n number = divide_squared_sum_by_count(squared_sum, squared)\n result = square_root(number)\nend", "def std_var\n first_pass = @raw.reduce(0) do |acc, elem|\n ((elem.score.to_f - mean)**2) + acc\n end\n Math.sqrt(first_pass / (@raw.size - 1))\n end", "def standard_deviation(data)\n return Math.sqrt(variance(data))\n end", "def std_deviation(measure = :avg_total_payments)\n measure_values = charges.map{|c| c.read_attribute(measure)}\n stats = DescriptiveStatistics::Stats.new(measure_values)\n stats.standard_deviation\n end", "def std\n @data.cast_to(Numo::DFloat).stddev\n end", "def std_dev\n return nil if length == 0\n Math.sqrt(pop_var)\n end", "def sample_std_dev\n # even though Math.sqrt doesn't operate on arbitrary precision numbers, we'll use it anyway\n Math.sqrt(sample_variance)\n end", "def stdev\n return Math.sqrt(self.var)\n end", "def stdev\n\t\t\tval = ((self.sum_of_squares / self.size.to_f) - (self.mean ** 2)) ** 0.5\n\t\tend", "def standard_deviation(values)\n average = values.reduce(:+)/values.length.to_f\n average_average = values.reduce(0) {|val, num| val += ((num - average)**2) }\n Math.sqrt(average_average / (values.length-1)).round(2)\n end", "def standard_deviation\n return Math.sqrt(self.variance / (self.length - 1))\n end", "def stddev\n return 0.0 if errors.size < 2\n errors.stdev.to_f.round(1)\n end", "def sd\n return 0 unless size>1\n _mean = mean\n sum_of_squares = 0\n each { |e| sum_of_squares += ( e - _mean )**2 }\n Math.sqrt( sum_of_squares / (size-1) )\n end", "def stddev(cat)\n Math.sqrt(variance(cat))\n end", "def sample_stats\n _len = size\n return [nil, nil] if _len == 0\n _sum = 0.0\n _sum_sq = 0.0\n self.each do |val|\n _sum += val\n _sum_sq += val * val\n end\n std_dev = _sum_sq - ((_sum * _sum)/_len)\n std_dev /= ( _len > 1 ? _len-1 : 1 )\n std_dev = Math.sqrt(std_dev)\n mean = _sum.to_f/_len\n return mean, std_dev\n end", "def deviation(datum)\n datum.to_f - mean.to_f\n end", "def std\n @std ||= stats(logical_indents).standard_deviation || 0.0\n end", "def stdev\n stats.stdev\n end", "def sd\n Math.sqrt(variance)\n end", "def std(dimen=0)\n variance(dimen).sqrt\n end", "def population_std_dev\n # even though Math.sqrt doesn't operate on arbitrary precision numbers, we'll use it anyway\n Math.sqrt(population_variance)\n end", "def standard_deviation(array)\n return nil if array.empty?\n\n Math.sqrt(sample_variance(array))\n end", "def standardDeviation n\r\n\t\t\treturn Math::sqrt( variance( n ) )\r\n\t\tend", "def std_dev(list)\n total = 0\n\n list.each do |n|\n total += n\n end\n return total / list.size.to_f\n\n sum_squares = 0\n\n list.each do |n|\n sum_squares += (n - avg) * (n - avg)\n end\n return Math.sqrt(sum_squares / (list.size - 1))\nend", "def standard_deviation(list_of_numbers)\n return variance(list_of_numbers)**0.5\n end", "def std_dev(list)\n total = 0\n list.each do |n|\n total = total + n\n end\n\n avg = total / list.size.to_f\n\n su,_squares = 0\n list.each do |n|\n sum_square = sum_square + (n - avg)**2\n end\n\n return Math.sqrt(sum_square / (list.size - 1))\nend", "def standard_deviation(population)\n Math.sqrt(variance(population)[0])\n end", "def standard_deviation (list)\n\n\ttotal_sum = 0\n\taverage = 0\n\tlist.each do |number|\n\t\ttotal_sum += number\n\tend\n\taverage = total_sum / list.count\n\n\tsquare_list = []\n\ttotal_square_sum = 0\n\tstandard_deviation = 0\n\tlist.each do |number|\n\t\tsquare_list.push((number - average)*(number - average))\n\tend\n\tsquare_list.each do |number|\n\t\ttotal_square_sum += number.to_f\n\t\tstandard_deviation = Math.sqrt(total_square_sum / list.count)\n\tend\n\treturn standard_deviation.to_f\nend", "def ld_standard_deviation\n ld_variance.map { |e| Math.sqrt(e) }\n end", "def standard_deviation(population)\n Math.sqrt(variance(population))\n end", "def standard_deviation(population)\n Math.sqrt(variance(population))\n end", "def standard_deviation(population)\n Math.sqrt(variance(population))\n end", "def standard_deviation(population)\n Math.sqrt(variance(population))\n end", "def standard_deviation(population)\n Math.sqrt(variance(population))\n end", "def standard_deviation_pre\n [Math.sqrt(variance + volatility ** 2), MIN_SD].min\n end", "def standard_deviation\n\t\t\tBigDecimal.new(variance).sqrt(5)\n\t\tend", "def standard_deviation\n StandardDeviation.new(self)\n end", "def ssdev\n Math.sqrt(svariance)\n end", "def std_dev(list)\n total = 0\n list.each do |n|\n total += n\n end\n avg = total / list.size.to_f\n sum_squares = 0\n list.each do |n|\n sum_squares += (n - avg) * (n - avg)\n end\n return Math.sqrt(sum_squares / list.size - 1)\nend", "def sample_stdev\n stats.sample_stdev\n end", "def std_err\n std / Math.sqrt(size)\n end", "def return_mean_stdev_from_excel(a=\"\",b=\"\")\n a = a.split\"\\n\"\n b = b.split\"\\n\"\n h = {}\n (0..(a.size-1)).each do |n|\n h[a[n].to_i] = b[n].to_i\n end\n aa = []\n h.each {|k,v| v.times {aa << k}}\n r1 = aa.mean\n r2 = aa.stdev\n return [r1,r2]\nend", "def calcStandardDeviation(numArray)\n\tresult = 0\n\t\n\tif (numArray.length() == 1)\n\t\tresult = numArray[0];\n\telse\n\t\tavg = calcAvg(numArray);\n\t\tsum = 0\n\t\tnumArray.each do |x|\n\t\t\tsum = sum + ((x - avg)**2);\n\t\tend\n\t\t\n\t\tresult = Math.sqrt(sum.to_f() / (numArray.length() - 1));\n\tend\n\t\n\treturn result;\nend", "def sample_std_err\n sample_std_dev / Math.sqrt(length)\n end", "def test_stddev\n assert Mathematics.stddev(1,2,3) > 0.8164 && Mathematics.stddev(1,2,3) < 0.8165\n assert Mathematics.sd(1,2,3) > 0.8164 && Mathematics.sd(1,2,3) < 0.8165\n end", "def mean_sigma(v)\n length = v.length.to_f\n sum = v.inject(0, :+).to_f\n mean = sum/length\n stdDev = Math.sqrt(v.collect {|x| ((x - mean)**2)}.inject(0, :+) * (1/length))\n return mean, stdDev\nend", "def standard_deviation(population=false)\n size > 1 ? Math.sqrt(variance(population)) : 0.0\n end", "def standard_deviation_p\n Math.sqrt(self.variance_p)\n end", "def mean()\n sum = 0\n @difference.each do |item|\n sum += item\n end\n @mean = sum / @difference.length\n return @mean\n end", "def std(dim=0)\n variance(dim).map! { |e| Math.sqrt(e) }\n end", "def get_mean \n return Math.exp(@meanlog + @sdlog**2 / 2.0)\n end", "def impl_std(x)\n Math.sqrt(impl_variance(x))\n end", "def standard_deviation\n\t\treturn standard_deviation_population\n\tend", "def variance\n n = 0\n mean = 0.0\n s = 0.0\n numeric_items.each { |x|\n n = n + 1\n delta = x - mean\n mean = mean + (delta / n)\n s = s + delta * (x - mean)\n }\n # if you want to calculate std deviation of a sample change this to \"s / (n-1)\"\n return s / n\n end", "def get_mean\n end" ]
[ "0.84271824", "0.80154055", "0.79858017", "0.79836136", "0.79429185", "0.7905637", "0.78093594", "0.7772725", "0.7747277", "0.7726669", "0.7688306", "0.76777", "0.7676736", "0.76734895", "0.7656445", "0.76515436", "0.76474184", "0.7592434", "0.75923306", "0.75923306", "0.7587727", "0.75767434", "0.75757575", "0.75657016", "0.75657016", "0.75657016", "0.7543517", "0.75383896", "0.7533829", "0.752781", "0.752781", "0.752781", "0.752781", "0.752781", "0.752781", "0.752781", "0.752781", "0.7504716", "0.750463", "0.749332", "0.749332", "0.7489605", "0.7475089", "0.7460334", "0.74590105", "0.7438718", "0.7417898", "0.74170595", "0.74057376", "0.73980504", "0.73850065", "0.73361933", "0.7333729", "0.7326757", "0.7306309", "0.72998315", "0.72959185", "0.7293793", "0.72868305", "0.72654766", "0.72441053", "0.7217368", "0.7196924", "0.7188776", "0.71566397", "0.71376574", "0.7107045", "0.710513", "0.71020263", "0.7083655", "0.7082787", "0.7076999", "0.7052476", "0.7035078", "0.7021129", "0.7021129", "0.7021129", "0.7021129", "0.7021129", "0.700579", "0.7005663", "0.69985497", "0.6991288", "0.6983938", "0.69429237", "0.69138664", "0.68671393", "0.68471223", "0.6814741", "0.67891514", "0.67858046", "0.67773014", "0.6772913", "0.6768842", "0.6743623", "0.6710907", "0.67011315", "0.6670644", "0.6659104", "0.6635455" ]
0.71512836
65
Use callbacks to share common setup or constraints between actions.
def set_address @address = Address.find(params[:id]) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def set_actions\n actions :all\n end", "def define_action_helpers?; end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def setup_handler\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def 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 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 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\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def setup(&block)\n define_method(:setup, &block)\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 setup(easy)\n super\n easy.customrequest = @verb\n end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def default_action; 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 callback_phase\n super\n end", "def advice\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 _handle_action_missing(*args); end", "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 duas1(action)\n action.call\n action.call\nend" ]
[ "0.6163821", "0.6045432", "0.5945441", "0.5916224", "0.58894575", "0.5834073", "0.57764685", "0.5702474", "0.5702474", "0.5653258", "0.56211996", "0.54235053", "0.5410683", "0.5410683", "0.5410683", "0.53948104", "0.5378064", "0.5356684", "0.53400385", "0.53399503", "0.53312254", "0.53121567", "0.52971965", "0.52964705", "0.52956307", "0.52587366", "0.52450675", "0.5237777", "0.5237777", "0.5237777", "0.5237777", "0.5237777", "0.5233381", "0.52325714", "0.52288216", "0.52229726", "0.5218362", "0.52142864", "0.5207988", "0.5206337", "0.51762295", "0.51745105", "0.51728606", "0.516616", "0.5161016", "0.5157393", "0.5152562", "0.51524293", "0.5152397", "0.5144533", "0.513982", "0.51342106", "0.5113793", "0.5113793", "0.5113671", "0.51092553", "0.51062804", "0.50921935", "0.5088855", "0.5082236", "0.5079901", "0.5066569", "0.5055307", "0.5053106", "0.50499666", "0.50499666", "0.5035068", "0.50258636", "0.50220853", "0.5015893", "0.50134486", "0.5001442", "0.50005543", "0.4998581", "0.49901858", "0.49901858", "0.4986648", "0.49809486", "0.49792925", "0.4978855", "0.49685496", "0.49656174", "0.49576473", "0.49563017", "0.4955349", "0.49536878", "0.4952439", "0.49460214", "0.494239", "0.49334687", "0.49315962", "0.49266812", "0.49261138", "0.4925925", "0.4922542", "0.4920779", "0.49173284", "0.49169463", "0.4916256", "0.49162322", "0.49156886" ]
0.0
-1
GET /evaluations GET /evaluations.json
def index session[:evaluation_id] = nil if current_user.has_role? :admin @evaluations = Evaluation.all else @lesson = Lesson.find(session[:lesson_id]) if session[:lesson_id] @evaluations = Evaluation.where(user_id: current_user.id).order(updated_at: :desc) end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_eval\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluation = @student.evaluations.find(params[:eval_id])\n\t\trender json: @evaluation\n\tend", "def index\n @score_evaluations = ScoreEvaluation.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @score_evaluations }\n end\n end", "def evaluations(id)\n connection.get do |req|\n req.url \"job/#{id}/evaluations\"\n end\n end", "def get_evaluations\n\t\tif current_student.id.to_i == params[:id].to_i\n\t\t\t@student = Student.find(params[:id])\n\t\t\t@evaluations = @student.evaluations\n\t\tend\n\t\trender 'get_evaluations'\n\tend", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = @course.evaluations\n end", "def index\n @evaluations = @course.evaluations\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def getEvaluations\n\t\tharness.evaluations\n\tend", "def index\n @evaluaciones = Evaluacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @evaluaciones }\n end\n end", "def show\n @evaluations = Evaluation.find(params[:id])\n end", "def index\n @evaluates = Evaluate.all\n end", "def completed_evaluations_list\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluations = []\n\t\tfor evaluation in @student.evaluations\n\t\t\tif evaluation.isCompleted\n\t\t\t\t@evaluations << evaluation\n\t\t\tend\n\t\tend\n\t\trender json: @evaluations\n\tend", "def index\r\n @evaluaciones = Evaluacione.all\r\n end", "def index\n @evals = Eval.all\n respond_with(@evals) \n end", "def show\n @score_evaluation = ScoreEvaluation.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @score_evaluation }\n end\n end", "def index\n @evaluation_results = EvaluationResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @evaluation_results }\n end\n end", "def index\n @evaluations = Evaluation.accessible_by(current_ability, :read)\n end", "def index\n \n @evaluation = Evaluation.find_by(user_id: params[:user_id], study_case_id: params[:study_case_id])\n\n if @evaluation.present?\n render :show\n else\n render json: nil\n end\n \n end", "def show\n @evaluation_criterium = EvaluationCriterium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluation_criterium }\n end\n end", "def evaluate\n response = Quiz.find(params[:quiz_id]).evaluate(params[:questions], current_user)\n @answers = response[:answers]\n @nota = response[:grade]\n\n respond_to do |format|\n format.html { render 'evaluate' }\n end\n end", "def index\n @evaluations = Evaluation.all\n @evaluation = Evaluation.new\n end", "def show\n @evaluacion = Evaluacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluacion }\n end\n end", "def evaluation\n @api_v1_reservation.evaluate(evaluation_params[:comment], evaluation_params[:rating].to_i) unless @api_v1_reservation.evaluation\n render json: { success: true }, status: 200\n rescue Exception => errors\n render json: errors, status: :unprocessable_entity\n end", "def index\n @performance_evaluations = PerformanceEvaluation.all\n end", "def index\n @course_evaluations = CourseEvaluation.all\n end", "def list_model_evaluations request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_model_evaluations_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::AutoML::V1::ListModelEvaluationsResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def list_model_evaluations request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_model_evaluations_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::AutoML::V1beta1::ListModelEvaluationsResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def course_complete_eval\n\t\t@student_evals = Student.find(params[:student_id]).evaluations.where('course_id = ?', params[:course_id])\n\t\t@evaluations = []\n\t\tif @student_evals != nil\n\t\t\tfor e in @student_evals\n\t\t\t\tif e.isCompleted\n\t\t\t\t\t@evaluations << e\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\trender json: @evaluations\n\tend", "def incomplete_evaluations_list\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluations = []\n\t\tfor evaluation in @student.evaluations\n\t\t\tif !evaluation.isCompleted\n\t\t\t\t@evaluations << evaluation\n\t\t\tend\n\t\tend\n\n\t\trender json: @evaluations\n\tend", "def index\n @tutee = Tutee.find params[:tutee_id]\n @evaluations = @tutee.evaluations.where(:status => 'Pending')\n end", "def index\n @project_evaluations = ProjectEvaluation.all\n end", "def course_incomplete_eval\n\t\t@student_evals = Student.find(params[:student_id]).evaluations.where('course_id = ?', params[:course_id])\n\t\t@evaluations = []\n\t\tif @student_evals != nil\n\t\t\tfor e in @student_evals\n\t\t\t\tif !e.isCompleted\n\t\t\t\t\t@evaluations << e\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\trender json: @evaluations\n\tend", "def show\n @evaluation_result = EvaluationResult.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluation_result }\n end\n end", "def new\n @score_evaluation = ScoreEvaluation.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @score_evaluation }\n end\n end", "def show\n @competency_pertenece_evaluation = CompetencyPerteneceEvaluation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @competency_pertenece_evaluation }\n end\n end", "def index\n @evaluos = Evaluo.all\n end", "def index\n iterations = policy_scope(Iteration)\n render json: iterations\n end", "def project_evaluations\n ProjectEvaluation.where(user_id: @id)\n end", "def index\n @evaluations = current_customer.customer_evaluations.order('evaluations.id desc')\n session[:left_service_orderitem] = 'theme'\n session[:right_service_orderitem] = 'theme'\n session[:right_service_query] = ''\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {render json: @evaluations}\n end\n end", "def index\n @expressions = Expression.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expressions }\n end\n end", "def show\r\n @evaluation = Evaluation.find(params[:id])\r\n @responses = Response.find_all_by_Evaluation_id params[:id]\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @evaluation }\r\n end\r\n end", "def show\n @evaluable_competency = EvaluableCompetency.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluable_competency }\n end\n end", "def index\n @psicologic_evaluations = PsicologicEvaluation.all\n end", "def index\n @student_goal_evaluations = StudentGoalEvaluation.all\n end", "def create\n @evaluations = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @evaluators }\n end\n end", "def index\n @dish_evaluations = DishEvaluation.all\n end", "def new\n @evaluation_criterium = EvaluationCriterium.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @evaluation_criterium }\n end\n end", "def show\n @evaluationstatus = Evaluationstatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluationstatus }\n end\n end", "def show\n @qc_evaluation = QcEvaluation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qc_evaluation }\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n if @evaluation.save\n render :show, status: :created\n else\n render json: @evaluation.errors, status: :unprocessable_entity\n end\n end", "def set_evaluacion\n @evaluacions = Evaluacion.find(params[:id])\n end", "def index\n @matrix_evaluation_types = MatrixEvaluationType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @matrix_evaluation_types }\n end\n end", "def new\n @evaluation = current_customer.customer_evaluations.new\n\n @evaluation.name = Evaluation.sample_evaluation.name if params[:testing]\n respond_to do |format|\n format.html # new.html.erb\n format.json {render json: @evaluation}\n end\n end", "def update\n if @evaluation.update(evaluation_params)\n render :show, status: :ok\n else\n render json: @evaluation.errors, status: :unprocessable_entity\n end\n end", "def show\n if @employee.type.nil?\n @evaluations = @employee.evaluations.paginate(page: params[:page]).order(date: :asc).per_page(10)\n end\n end", "def index\n unless params[:assignment_id]\n render json: format_errors({ base: ['This Endpoint requires a assignment_id in the params'] }),\n status: :bad_request\n return\n end\n\n @iterations = current_user.iterations(includes: includes_array)\n .where(assignment_id: params[:assignment_id])\n serialize_collection @iterations, :ok\n end", "def index\n @test_subject_evaluations = @test_subject.test_subject_evaluations.find(:all, :order => 'evaluated_on DESC')\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @test_subject_evaluations }\n end\n end", "def index\n @evaluacion_servicios = EvaluacionServicio.all\n end", "def show\n @current_team = current_team\n\n @not_evaluated_count = current_team.evaluations.where(evaluation_code_id: 1).count\n @watchlist_count = current_team.evaluations.where(evaluation_code_id: 2).count\n @reject_count = current_team.evaluations.where(evaluation_code_id: 3).count\n end", "def evaluation_data_of(evaluations)\n class_index = Wikipedia::VandalismDetection::Instances::VANDALISM_CLASS_INDEX\n total_count = evaluations.count.to_f\n\n recall = evaluations.reduce(0.0) { |result, sample| result + sample.recall(class_index) } / total_count\n precision = evaluations.reduce(0.0) { |result, sample| result + sample.precision(class_index) } / total_count\n area_under_prc = evaluations.reduce(0.0) { |result, sample| result + sample.area_under_prc(class_index) } / total_count\n\n { precision: precision, recall: recall, area_under_prc: area_under_prc }\nend", "def index\n @policy_valuations = PolicyValuation.all\n end", "def update\n if ENV[\"NEW_EVALUATION\"] == nil\n raise ActionController::RoutingError\n return\n end\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n if current_user\n @evaluations = current_user.readable_evaluations\n else\n @circle = Circle.where(name: 'Public').try(:first)\n @evaluations = @circle.present? ? @circle.evaluations : []\n end\n user_ids = @evaluations.map(&:created_by_id)\n @users = User.in(id: user_ids)\n @users = @users.index_by(&:id)\n end", "def index\n if params[:query]\n @evaluations = Evaluation.text_search(params[:query]).paginate(page: params[:page]).\n order(date: :asc).per_page(10)\n flash[:notice] = 'Ningún resultado' if @evaluations.empty?\n else\n @evaluations = Evaluation.paginate(page: params[:page]).order(date: :asc).per_page(10)\n end\n end", "def show\n @evaluation_sheet = EvaluationSheet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluation_sheet }\n end\n end", "def show\n @evaluation = Evaluation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evaluation }\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @expression_relationships = ExpressionRelationship.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expression_relationships }\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @evaluation }\n else\n format.html { render action: 'new' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @evaluation }\n else\n format.html { render action: 'new' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def index \n @calculation = Calculation.all # retrieve all calculations from calculations table \n json_response(@calculation) # respond with the array of calculations\n end", "def index\n @requisitions = Requisition.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @requisitions }\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @rcrieval = Rcrieval.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rcrieval }\n end\n end", "def new\n @competency_pertenece_evaluation = CompetencyPerteneceEvaluation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competency_pertenece_evaluation }\n end\n end", "def index\n @educations = Education.all\n render json: @educations\n end", "def show\n @evaluacion_servicios = EvaluacionServicio.find(params[:id])\n end", "def set_evaluacione\r\n @evaluacione = Evaluacione.find(params[:id])\r\n end", "def index\n if params[:project_team_id] && params[:project_id]\n @evaluations = Evaluation.joins(:project, team: :project_teams)\n .where project_teams: { id: params[:project_team_id] }, projects: { id: params[:project_id] }\n elsif params[:team_id]\n @evaluations = Evaluation.joins(:team).where teams: { id: params[:team_id] }\n elsif params[:project_id]\n @evaluations = Evaluation.joins(:project).where projects: { id: params[:project_id] }\n elsif params[:course_id]\n @evaluations = Evaluation.joins(:project).where(projects: { course_id: params[:course_id] })\n else\n @evaluations = Evaluation.all\n end\n end", "def index\n\t\tevals = Evaluation.where(appliable: false, processed: false)\n\t\tif evals.count == 1\n\t\t\t@eval = evals[0]\n\t\t\tselected = Selected.where(developer_id: current_developer.id, evaluation_id: @eval.id)\n\t\t\tif selected.count == 1\n\t\t\t\tmappings = Mapping.where(rater_group_id: selected[0].rater_group_id)\n\t\t\t\tapplieds = []\n\t\t\t\tfor i in 0..mappings.count-1\n\t\t\t\t\tapplieds += Applied.where(ratee_group_id: mappings[i].ratee_group_id)\n\t\t\t\tend\n\n\t\t\t\t@jobs = []\n\t\t\t\tfor i in 0..applieds.count-1\n\t\t\t\t\t@jobs += Material.where(developer_id: applieds[i].developer_id)\n\t\t\t\tend\n\n\t\t\t\tresults = Result.where(evaluation_id: @eval.id)\n\t\t\t\tresulted_materials = []\n\t\t\t\tfor i in 0..results.count-1\n\t\t\t\t\tresulted_materials += [Material.find(results[i].material_id)]\n\t\t\t\tend\n\t\t\t\t@jobs = @jobs - resulted_materials\n\t\t\tend\n\t\tend\n\tend", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: \"Evaluation was successfully updated.\" }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_evaluacion\n @evaluacion = Evaluacion.find(params[:id])\n end", "def index\n @decisions = Decision.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @decisions }\n end\n end", "def show\n @run = Run.find(params[:id])\n \n if @run.evaluations.length > 0\n @globalMark = 0\n @run.evaluations.each do |eval|\n @globalMark += eval.note\n end\n \n @globalMark /= @run.evaluations.length\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @run }\n end\n end", "def index\n @expenses = find_expenses.all\n render json: @expenses\n end", "def show\n @evaluation = Evaluation.find(params[:id])\n @observation = @evaluation.observation\n respond_to do |format|\n format.html { render :layout=>\"evaluation_tabs\"}\n format.json { render json: @evaluation }\n end\n end", "def get_model_evaluation request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_get_model_evaluation_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::AutoML::V1::ModelEvaluation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def get_model_evaluation request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_get_model_evaluation_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::AutoML::V1beta1::ModelEvaluation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end", "def show\n @evaluation = Evaluation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluation }\n format.pdf { render :layout=>false }\n end\n end", "def show\n @eval = Eval.find(params[:id])\n end", "def new\n @qc_evaluation = QcEvaluation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @qc_evaluation }\n end\n end" ]
[ "0.7649412", "0.7279398", "0.72450113", "0.7144004", "0.7141227", "0.70988876", "0.7048806", "0.702481", "0.702481", "0.702481", "0.702481", "0.702481", "0.6986356", "0.68509716", "0.679744", "0.67658156", "0.67023426", "0.66693366", "0.6639267", "0.6623286", "0.6612441", "0.6589322", "0.65231997", "0.6496988", "0.64937276", "0.6492541", "0.6426895", "0.6424966", "0.6387227", "0.6383195", "0.6333001", "0.6298831", "0.6291192", "0.6276601", "0.6175383", "0.61398214", "0.61350536", "0.61268234", "0.6125482", "0.61063206", "0.6103801", "0.6094454", "0.6082441", "0.60753727", "0.6073318", "0.6043752", "0.6027387", "0.60192657", "0.59790874", "0.5962833", "0.5932436", "0.5920223", "0.5919571", "0.589717", "0.58697224", "0.58684844", "0.5868168", "0.58194876", "0.58102673", "0.5795159", "0.5773871", "0.57699794", "0.5763945", "0.5729096", "0.56953657", "0.56925434", "0.56801754", "0.5667665", "0.5667065", "0.5648088", "0.56460685", "0.56372076", "0.5616114", "0.55938035", "0.5590868", "0.5590868", "0.5583673", "0.5577865", "0.55774754", "0.556446", "0.55632156", "0.5536667", "0.55345803", "0.5525283", "0.55168563", "0.5494411", "0.54938734", "0.54938734", "0.54938734", "0.54935485", "0.54909575", "0.5476625", "0.5475058", "0.54643655", "0.54620236", "0.5458686", "0.5458074", "0.5454961", "0.5447076", "0.54282" ]
0.5836772
57
GET /evaluations/1 GET /evaluations/1.json
def show session[:evaluation_id] = @evaluation.id @justices = Justice.where(evaluation_id: @evaluation.id) end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_eval\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluation = @student.evaluations.find(params[:eval_id])\n\t\trender json: @evaluation\n\tend", "def show\n @evaluations = Evaluation.find(params[:id])\n end", "def evaluations(id)\n connection.get do |req|\n req.url \"job/#{id}/evaluations\"\n end\n end", "def show\n @score_evaluation = ScoreEvaluation.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @score_evaluation }\n end\n end", "def show\n @evaluacion = Evaluacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluacion }\n end\n end", "def get_evaluations\n\t\tif current_student.id.to_i == params[:id].to_i\n\t\t\t@student = Student.find(params[:id])\n\t\t\t@evaluations = @student.evaluations\n\t\tend\n\t\trender 'get_evaluations'\n\tend", "def show\n @evaluation_criterium = EvaluationCriterium.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluation_criterium }\n end\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @score_evaluations = ScoreEvaluation.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @score_evaluations }\n end\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n \n @evaluation = Evaluation.find_by(user_id: params[:user_id], study_case_id: params[:study_case_id])\n\n if @evaluation.present?\n render :show\n else\n render json: nil\n end\n \n end", "def index\n @evaluations = @course.evaluations\n end", "def show\n @evaluation_result = EvaluationResult.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluation_result }\n end\n end", "def index\n @evaluations = @course.evaluations\n end", "def index\n @evaluaciones = Evaluacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @evaluaciones }\n end\n end", "def show\n @evaluationstatus = Evaluationstatus.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluationstatus }\n end\n end", "def index\n @evaluates = Evaluate.all\n end", "def index\n @evaluation_results = EvaluationResult.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @evaluation_results }\n end\n end", "def index\n @evaluations = Evaluation.all\n @evaluation = Evaluation.new\n end", "def show\n @competency_pertenece_evaluation = CompetencyPerteneceEvaluation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @competency_pertenece_evaluation }\n end\n end", "def index\r\n @evaluaciones = Evaluacione.all\r\n end", "def index\n @evals = Eval.all\n respond_with(@evals) \n end", "def show\n @evaluable_competency = EvaluableCompetency.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluable_competency }\n end\n end", "def new\n @score_evaluation = ScoreEvaluation.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @score_evaluation }\n end\n end", "def show\n @qc_evaluation = QcEvaluation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @qc_evaluation }\n end\n end", "def getEvaluations\n\t\tharness.evaluations\n\tend", "def evaluation\n @api_v1_reservation.evaluate(evaluation_params[:comment], evaluation_params[:rating].to_i) unless @api_v1_reservation.evaluation\n render json: { success: true }, status: 200\n rescue Exception => errors\n render json: errors, status: :unprocessable_entity\n end", "def show\r\n @evaluation = Evaluation.find(params[:id])\r\n @responses = Response.find_all_by_Evaluation_id params[:id]\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.xml { render :xml => @evaluation }\r\n end\r\n end", "def evaluate\n response = Quiz.find(params[:quiz_id]).evaluate(params[:questions], current_user)\n @answers = response[:answers]\n @nota = response[:grade]\n\n respond_to do |format|\n format.html { render 'evaluate' }\n end\n end", "def show\n @rcrieval = Rcrieval.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @rcrieval }\n end\n end", "def show\n @eval = Eval.find(params[:id])\n end", "def new\n @evaluation_criterium = EvaluationCriterium.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @evaluation_criterium }\n end\n end", "def index\n @evaluations = Evaluation.accessible_by(current_ability, :read)\n end", "def new\n @evaluation = current_customer.customer_evaluations.new\n\n @evaluation.name = Evaluation.sample_evaluation.name if params[:testing]\n respond_to do |format|\n format.html # new.html.erb\n format.json {render json: @evaluation}\n end\n end", "def index\n @tutee = Tutee.find params[:tutee_id]\n @evaluations = @tutee.evaluations.where(:status => 'Pending')\n end", "def index\n @performance_evaluations = PerformanceEvaluation.all\n end", "def show\n @matrix_evaluation_type = MatrixEvaluationType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @matrix_evaluation_type }\n end\n end", "def show\n @evaluation = Evaluation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evaluation }\n end\n end", "def show\n @run = Run.find(params[:id])\n \n if @run.evaluations.length > 0\n @globalMark = 0\n @run.evaluations.each do |eval|\n @globalMark += eval.note\n end\n \n @globalMark /= @run.evaluations.length\n end\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @run }\n end\n end", "def show\n @evaluacion_servicios = EvaluacionServicio.find(params[:id])\n end", "def show\n @evaluation = Evaluation.find(params[:id])\n @observation = @evaluation.observation\n respond_to do |format|\n format.html { render :layout=>\"evaluation_tabs\"}\n format.json { render json: @evaluation }\n end\n end", "def set_evaluacion\n @evaluacions = Evaluacion.find(params[:id])\n end", "def show\n @evaluation_sheet = EvaluationSheet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluation_sheet }\n end\n end", "def index\n @evaluos = Evaluo.all\n end", "def index\n @course_evaluations = CourseEvaluation.all\n end", "def index\n @project_evaluations = ProjectEvaluation.all\n end", "def update\n if ENV[\"NEW_EVALUATION\"] == nil\n raise ActionController::RoutingError\n return\n end\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluations = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @evaluation.update(evaluation_params)\n render :show, status: :ok\n else\n render json: @evaluation.errors, status: :unprocessable_entity\n end\n end", "def index\n iterations = policy_scope(Iteration)\n render json: iterations\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n if @evaluation.save\n render :show, status: :created\n else\n render json: @evaluation.errors, status: :unprocessable_entity\n end\n end", "def fetch_experiment(id)\n url = @base + \"experiments/#{id}.json?token=#{@token}\"\n puts url\n response = JSON.parse(RestClient.get(url))\nend", "def completed_evaluations_list\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluations = []\n\t\tfor evaluation in @student.evaluations\n\t\t\tif evaluation.isCompleted\n\t\t\t\t@evaluations << evaluation\n\t\t\tend\n\t\tend\n\t\trender json: @evaluations\n\tend", "def new\n @competency_pertenece_evaluation = CompetencyPerteneceEvaluation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competency_pertenece_evaluation }\n end\n end", "def set_evaluacione\r\n @evaluacione = Evaluacione.find(params[:id])\r\n end", "def new\n @qc_evaluation = QcEvaluation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @qc_evaluation }\n end\n end", "def index\n @expressions = Expression.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @expressions }\n end\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluacion\n @evaluacion = Evaluacion.find(params[:id])\n end", "def show\n @evaluation = Evaluation.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @evaluation }\n format.pdf { render :layout=>false }\n end\n end", "def index\n @evaluations = current_customer.customer_evaluations.order('evaluations.id desc')\n session[:left_service_orderitem] = 'theme'\n session[:right_service_orderitem] = 'theme'\n session[:right_service_query] = ''\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {render json: @evaluations}\n end\n end", "def show\n if @employee.type.nil?\n @evaluations = @employee.evaluations.paginate(page: params[:page]).order(date: :asc).per_page(10)\n end\n end", "def index\n @answers = Answer.where(url_params)\n if @answers.size == 1\n @answers.first!\n end\n render json: @answers\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def index\n @matrix_evaluation_types = MatrixEvaluationType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @matrix_evaluation_types }\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @evaluation }\n else\n format.html { render action: 'new' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @evaluation }\n else\n format.html { render action: 'new' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @scoring_method = ScoringMethod.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @scoring_method }\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @evaluacione = Evaluacione.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @evaluacione }\n end\n end", "def set_evaluation\n @evaluation = Evaluation.find(params[:id])\n end", "def show\n @test_subject_evaluation = @test_subject.test_subject_evaluations.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @test_subject_evaluation }\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n session[:evaluation_id] = nil\n if current_user.has_role? :admin\n @evaluations = Evaluation.all\n else\n @lesson = Lesson.find(session[:lesson_id]) if session[:lesson_id]\n @evaluations = Evaluation.where(user_id: current_user.id).order(updated_at: :desc)\n end\n\n end", "def course_complete_eval\n\t\t@student_evals = Student.find(params[:student_id]).evaluations.where('course_id = ?', params[:course_id])\n\t\t@evaluations = []\n\t\tif @student_evals != nil\n\t\t\tfor e in @student_evals\n\t\t\t\tif e.isCompleted\n\t\t\t\t\t@evaluations << e\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\trender json: @evaluations\n\tend", "def new\n @evaluable_competency = EvaluableCompetency.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @evaluable_competency }\n end\n end", "def index\n @psicologic_evaluations = PsicologicEvaluation.all\n end", "def new\n @rcrieval = Rcrieval.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rcrieval }\n end\n end", "def index\n @student_goal_evaluations = StudentGoalEvaluation.all\n end", "def set_evaluation\n @evaluation = @course.evaluations.find(params[:id])\n # @evaluation = Evaluation.find(params[:id])\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: \"Evaluation was successfully updated.\" }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.77651966", "0.6981567", "0.69376636", "0.68618554", "0.68131685", "0.673956", "0.6719614", "0.66970426", "0.6682116", "0.6674504", "0.6674504", "0.6674504", "0.6674504", "0.6674504", "0.6662183", "0.6624913", "0.6612468", "0.6604192", "0.6585361", "0.6463337", "0.6439866", "0.6418438", "0.64081", "0.6383968", "0.63283354", "0.63274026", "0.6314842", "0.63139963", "0.63070405", "0.6261652", "0.62227035", "0.6196579", "0.61706907", "0.61501515", "0.6149359", "0.6146265", "0.6124738", "0.61209923", "0.6105141", "0.60267425", "0.6001848", "0.5968201", "0.5962146", "0.59612155", "0.594224", "0.59250534", "0.5923947", "0.5923729", "0.58915573", "0.58747196", "0.587416", "0.5873449", "0.5869326", "0.5862706", "0.5859015", "0.5826688", "0.5814887", "0.58142364", "0.58115005", "0.5809642", "0.57918155", "0.5777523", "0.5770148", "0.57634306", "0.57359034", "0.5710632", "0.57026166", "0.57015824", "0.57015824", "0.57015824", "0.57015824", "0.57015824", "0.57015824", "0.57015824", "0.57015824", "0.57015824", "0.57015824", "0.57015824", "0.57015824", "0.57015824", "0.57015824", "0.57015824", "0.57015824", "0.5679493", "0.56586933", "0.56586933", "0.56521726", "0.5651783", "0.56473315", "0.5646016", "0.5638159", "0.5637608", "0.5636687", "0.56272775", "0.5619288", "0.5614598", "0.5611355", "0.5610692", "0.56062996", "0.56025195", "0.56012195" ]
0.0
-1
POST /evaluations POST /evaluations.json
def create if current_user.has_role? :admin @evaluation = Evaluation.new(evaluation_params) else @practice = Practice.find(session[:practice_id]) @evaluation = Evaluation.new(evaluation_params) @evaluation.lesson_id = session[:lesson_id] @evaluation.user_id = current_user.id @evaluation.practice_id = @practice.id @evaluation.title = @practice.title @evaluation.material = @practice.material @evaluation.question = @practice.question @evaluation.answer = @practice.answer @evaluation.practice_score ||= @practice.score if session[:papertest_id] @papertest = Papertest.find(session[:papertest_id]) if Time.now < @papertest.end_at @evaluation.end_at = @papertest.end_at @evaluation.papertest_id = @papertest.id else session[:papertest_id] = nil redirect_to paper_url(@papertest.paper_id), notice: "考试已结束!" return end end end respond_to do |format| if @evaluation.save if @practice.answer.gsub(/(<(\w|\/)+[^>]*>|\s)/, "") == @evaluation.your_answer.gsub(/(<(\w|\/)+[^>]*>|\s)/, "") # 如果答对了 @justice = Justice.create!( user_id: 1, evaluation_user_id: @evaluation.user_id, practice_id: @evaluation.practice_id, evaluation_id: @evaluation.id, score: @evaluation.practice_score, # 得到满分 p_score: @evaluation.practice_score, remark: "完全正确!", ) @evaluation.update(score: @evaluation.practice_score) end format.html { redirect_to @evaluation, notice: '答案提交成功' } format.json { render :show, status: :created, location: @evaluation } else format.html { render :new } format.json { render json: @evaluation.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create\n @evaluations = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n if @evaluation.save\n render :show, status: :created\n else\n render json: @evaluation.errors, status: :unprocessable_entity\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @evaluation }\n else\n format.html { render action: 'new' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render action: 'show', status: :created, location: @evaluation }\n else\n format.html { render action: 'new' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @evaluation = Evaluation.new(params[:evaluation])\r\n @answers = @evaluation.responses\r\n\r\n respond_to do |format|\r\n if @evaluation.save && @answers.each{|a| a.save }.all?\r\n format.html { redirect_to(@evaluation, :notice => 'Evaluation was successfully created.') }\r\n format.xml { render :xml => @evaluation, :status => :created, :location => @evaluation }\r\n else\r\n format.html { render :action => \"new\" }\r\n format.xml { render :xml => @evaluation.errors, :status => :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n \n \n @evaluation = @course.evaluations.new(evaluation_params)\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to course_evaluation_path(@course,@evaluation) , notice: 'La evaluación fue creada con éxito.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Avaliação criada.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def post_evaluate(excon, body)\n excon.request(\n method: :post,\n path: '/evaluate',\n headers: { 'Content-Type' => 'application/json' },\n body: body\n )\nend", "def create\n @evaluation = Evaluation.new(evaluation_params)\n @evaluation.collection = evaluation_params[:collection]\n \n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: \"Evaluation was successfully created.\" }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\r\n @evaluacione = Evaluacione.new(evaluacione_params)\r\n\r\n respond_to do |format|\r\n if @evaluacione.save\r\n format.html { redirect_to @evaluacione, notice: 'Evaluacione was successfully created.' }\r\n format.json { render :show, status: :created, location: @evaluacione }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @evaluacione.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def create\n \n if ENV[\"NEW_EVALUATION\"] == nil\n raise ActionController::RoutingError\n return\n end\n @entry = Entry.find(params[:id])\n @evaluation = @entry.evaluations.find_by(school_num:params[:evaluation][:school_num])\n success_flag = true\n begin \n if(@evaluation == nil)then\n \n @evaluation = Evaluation.create(evaluation_params)\n @entry.evaluations<<@evaluation\n else\n success_flag = @evaluation.update(evaluation_params)\n end\n rescue\n success_flag = false\n end\n\n if @evaluation.id == nil\n # @evaluation = Evaluation.new\n success_flag = false\n end\n respond_to do |format|\n if success_flag == true\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n format.html { redirect_to \"/evaluations/\"+params[:id].to_s + \"/new\", json: @evaluation.errors}\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @user_evaluation = ::UserEvaluation.new(user_evaluation_params)\n @user_evaluation.evaluation = @evaluation\n @user_evaluation.account = current_user.account\n \n if @user_evaluation.save\n render json: @user_evaluation, status: :created, \n serializer: ::Admin::Evaluation::UserEvaluationSerializer\n else\n render json: @user_evaluation.errors, status: :unprocessable_entity\n end\n end", "def evaluation\n @api_v1_reservation.evaluate(evaluation_params[:comment], evaluation_params[:rating].to_i) unless @api_v1_reservation.evaluation\n render json: { success: true }, status: 200\n rescue Exception => errors\n render json: errors, status: :unprocessable_entity\n end", "def create_evaluation\n @professor_form = ProfessorForm.new(professor_form_params)\n if @professor_form.save\n render json: @professor_form\n else\n render json: @professor_form.errors\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n if @evaluation.save\n redirect_to action: \"index\", notice: 'Evaluation was successfully created.' \n else\n @evaluations = Evaluation.all\n\n render :new, locals: {evaluation: @evaluation, evaluations: @evaluations } \n end\n end", "def create\n @evaluation = current_customer.customer_evaluations.new(evaluation_params)\n if params['clone'] == 'true'\n @evaluation = @evaluation.clone_last_evaluation\n @evaluation.name = params[:evaluation][:name]\n @evaluation.status = Evaluation::STATUSES.index(\"draft\")\n @evaluation.published_at = nil\n end\n\n if params[:testing] == 'true'\n @evaluation = Evaluation.sample_evaluation.clone_evaluation\n @evaluation.name = params[:evaluation][:name]\n @evaluation.status = Evaluation::STATUSES.index(\"draft\")\n @evaluation.published_at = nil\n @evaluation.distinguish_type = Evaluation::TYPES.index(:sandbox)\n end\n\n @evaluation.company_id = current_company.id\n @evaluation.customer_id = current_customer.id\n @evaluation.created_by = current_user.id\n\n respond_to do |format|\n if @evaluation.save\n @evaluation.create_default_evaluation_services if params['clone'] != 'true'\n format.html {redirect_to customer_evaluation_path(current_customer, @evaluation), notice: I18n.t('evaluations.messages.successfully_created')}\n format.json {render json: @evaluation, status: :created, location: @evaluation}\n else\n format.html {render action: \"new\"}\n format.json {render json: @evaluation.errors, status: :unprocessable_entity}\n end\n end\n end", "def create\n @evaluation_criterium = EvaluationCriterium.new(params[:evaluation_criterium])\n\n respond_to do |format|\n if @evaluation_criterium.save\n format.html { redirect_to @evaluation_criterium, notice: 'Evaluation criterium was successfully created.' }\n format.json { render json: @evaluation_criterium, status: :created, location: @evaluation_criterium }\n else\n format.html { render action: \"new\" }\n format.json { render json: @evaluation_criterium.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:collection, :resource, :body, :result, :executor, :title, :metrics, :subject)\n end", "def evaluation_params\n params.require(:evaluation).permit(:collection, :resource, :body, :result, :executor, :title, :metrics, :subject)\n end", "def create\n @score_evaluation = ScoreEvaluation.new(params[:score_evaluation])\n \n respond_to do |format|\n if @score_evaluation.save\n format.html { redirect_to @score_evaluation, :notice => t('selecao_admin.flash_messages.successfully_created.', :model => @score_evaluation.class.model_name.human) }\n format.json { render :json => @score_evaluation, :status => :created, :location => @score_evaluation }\n format.js\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @score_evaluation.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end", "def create\n @evaluation = Evaluation.new(params[:evaluation])\n\n respond_to do |format|\n if @evaluation.save\n flash[:notice] = 'Evaluation was successfully created.'\n format.html { redirect_to(@evaluation) }\n format.xml { render :xml => @evaluation, :status => :created, :location => @evaluation }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @evaluation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:value, :study_case_id, :user_id)\n end", "def create\n @eval = Eval.new(params[:eval])\n @eval.save and flash[:notice] = \"Yay! New Eval Created!\"\n respond_with(@eval)\n end", "def create\n @competency_pertenece_evaluation = CompetencyPerteneceEvaluation.new(params[:competency_pertenece_evaluation])\n\n respond_to do |format|\n if @competency_pertenece_evaluation.save\n format.html { redirect_to @competency_pertenece_evaluation, notice: 'Competency pertenece evaluation was successfully created.' }\n format.json { render json: @competency_pertenece_evaluation, status: :created, location: @competency_pertenece_evaluation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @competency_pertenece_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:date, :time, :event, :name, :team, :parent, :email, :bodypart, :left, :right, :subjective, :visual, :palpation, :rom, :mmt, :neurological, :specialtests, :functionaltesting, :assessment, :plan, :rice, :taping, :mdreferral, :crutches, :instruction, :screen, :erreferral, :hospitalname, :notifiedparent, :whomnotified, :datetime)\n end", "def create\n @student_goal_evaluation = StudentGoalEvaluation.new(student_goal_evaluation_params)\n\n respond_to do |format|\n if @student_goal_evaluation.save\n format.html { redirect_to root_path, notice: 'Evalueringen er gemt.' }\n format.json { render :show, status: :created, location: @student_goal_evaluation }\n else\n format.html { render :new }\n format.json { render json: @student_goal_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:title, :approbation_grade, :date)\n end", "def create\n @evaluate = Evaluate.new(evaluate_params)\n @evaluate.user_id= current_user.id\n @evaluate.review_id = @review.id\n\n respond_to do |format|\n if @evaluate.save\n format.html { redirect_to @review, notice: 'Evaluate was successfully created.' }\n format.json { render :show, status: :created, location: @evaluate }\n else\n format.html { render :new }\n format.json { render json: @evaluate.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:restaurant_id, :standards, :name, :message)\n end", "def create\n # ToDo: 名前の変更\n score = params[:score]\n \n\n if @evaluation.update_attributes(score: score)\n render :show, status: :ok, location: @evaluation\n else\n render json: @evaluation.errors, status: :unprocessable_entity\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:school_num, :evaluate1, :evaluate2, :evaluate3, :evaluate4, :comment)\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n @evaluation.course = @course\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to course_evaluations_url, notice: 'La evaluacion fue creada correctamente!' }\n else\n format.html { render :new }\n end\n end\n end", "def create\n puts evaluation_params\n @evaluation = Evaluation.new(evaluation_params)\n #De aca en adelante es para lograr insertar datos en la tabla intermedia \n #La Tabla intermedia se la evaluation_question\n respond_to do |format|\n puts \"Entre al respond\"\n if @evaluation.save\n puts \"Pude guardarlo\"\n evaluation = Evaluation.last\n evaluation.update(course_id: params[:course_id])\n evaluation_id = evaluation.id\n question_ids = params[:questions]\n question_ids.each do |question_id|\n EvaluationQuestion.create(question_id: question_id, evaluation_id: evaluation_id)\n end\n format.html { redirect_to @evaluation, notice: 'La evaluación fue creada con éxito' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n @question = Question.all\n @courses = Course.all\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:title, :description)\n end", "def create\n @course_evaluation = CourseEvaluation.new(course_evaluation_params)\n\n respond_to do |format|\n if @course_evaluation.save\n format.html { redirect_to @course_evaluation, notice: 'Course evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @course_evaluation }\n else\n format.html { render :new }\n format.json { render json: @course_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:usuario_avaliado_id, :usuario_avaliador_id, :date, :done, :evaluation_model_id)\n end", "def create\n @psicologic_evaluation = PsicologicEvaluation.new(psicologic_evaluation_params)\n\n respond_to do |format|\n if @psicologic_evaluation.save\n format.html { redirect_to @psicologic_evaluation, notice: 'Psicologic evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @psicologic_evaluation }\n else\n format.html { render :new }\n format.json { render json: @psicologic_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def evals_questions evaluation_id\n call_path = \"evals/questions\"\n request = {\"evaluationID\": evaluation_id}.to_json\n data = build_post_data(request)\n perform_post(build_url(call_path), data)\n end", "def evaluation_params\n params.require(:evaluation).permit(:employee_id, :task_id, :result, :comment, :image, :date)\n end", "def evaluations(id)\n connection.get do |req|\n req.url \"job/#{id}/evaluations\"\n end\n end", "def create\n @evaluacione = Evaluacione.new(params[:evaluacione])\n\n respond_to do |format|\n if @evaluacione.save\n format.html { redirect_to(@evaluacione, :notice => 'Evaluacione was successfully created.') }\n format.xml { render :xml => @evaluacione, :status => :created, :location => @evaluacione }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @evaluacione.errors, :status => :unprocessable_entity }\n end\n end\n end", "def new\n @evaluation = current_customer.customer_evaluations.new\n\n @evaluation.name = Evaluation.sample_evaluation.name if params[:testing]\n respond_to do |format|\n format.html # new.html.erb\n format.json {render json: @evaluation}\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:moyenne, :annee_scolaire, :matiere, :periode, :coefficient)\n end", "def evaluation_params\n params.require(:evaluation).permit(:organization, :standard, :suitability, :funding, :assessment, :report)\n end", "def evaluation_params\n params.permit(:evaluation, :evaluator_id, :evaluee_id, :project_id, :comment, :team_id)\n end", "def create\n @evaluo = Evaluo.new(evaluo_params)\n\n respond_to do |format|\n if @evaluo.save\n format.html { redirect_to @evaluo, notice: 'Evaluo was successfully created.' }\n format.json { render :show, status: :created, location: @evaluo }\n else\n format.html { render :new }\n format.json { render json: @evaluo.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:candidate_id, :user_id, :attitude_id, :intention_id, :production_id, :localization_id, :comment, :boost)\n end", "def evaluation_params\n params.require(:evaluation).permit(:score, :comment, :project_id, :team_member_id)\n end", "def index\n @evaluations = Evaluation.all\n @evaluation = Evaluation.new\n end", "def evaluation_params\n params.require(:evaluation).permit(:date_evaluation, :typeevaluation, :cla_id, :matiere_id, :anneeacademique_id, :user_id)\n end", "def create\n @qc_evaluation = QcEvaluation.new(params[:qc_evaluation])\n\n respond_to do |format|\n if @qc_evaluation.save\n format.html { redirect_to @qc_evaluation, notice: 'Qc evaluation was successfully created.' }\n format.json { render json: @qc_evaluation, status: :created, location: @qc_evaluation }\n else\n format.html { render action: \"new\" }\n format.json { render json: @qc_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:user_id, :lesson_id, :practice_id, :title, :material, :question, :answer, :your_answer, :score, :practice_score, :picture_ya, :end_at, :papertest)\n end", "def evaluation_params\n params.require(:evaluation).permit(:objetivo, :fecha, :course_id)\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n if Evaluation.where('title=?', @evaluation.title).first\n @evaluation.errors[:nameexists] << \"An evaluation by that title already exists\"\n end\n\n resource = @evaluation.resource\n if (resource =~ /doi:/ or resource =~ /dx\\.doi\\.org/)\n canonicalizedDOI = resource.match(/(10.\\d{4,9}\\/[-\\._;()\\/:A-Z0-9]+$)/i)[1]\n @evaluation.resource = canonicalizedDOI\n end\n \n validate_orcid(@evaluation, @evaluation.executor) # sets an error if there was a problem\n \n respond_to do |format|\n if !@evaluation.errors.any? && @evaluation.save\n format.html { redirect_to @evaluation, notice: \"Evaluation was successfully created.\" }\n format.json { render :show, status: :created, location: @evaluation }\n else\n @collections = Collection.all\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @project_evaluation = ProjectEvaluation.new(project_evaluation_params)\n\n respond_to do |format|\n if @project_evaluation.save\n format.html { redirect_to @project_evaluation, notice: 'Project evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @project_evaluation }\n else\n format.html { render :new }\n format.json { render json: @project_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:user_id, :project_id, :comment, :rating)\n end", "def update\n unless @submission.evaluated.blank?\n respond_to do |format|\n format.html { redirect_to test_submission_path(@test, @submission), info: \"Evaluated!\" }\n end\n return\n end\n\n unless Time.now > @timeout + 5.seconds\n @submission.answers_of_questions.each do |user_answer|\n user_answer.update(choice: submission_params.fetch(user_answer.answer_id.to_s, \"false\"))\n end\n end\n if Time.now > @timeout || params[:evaluate]\n @test.questions.each do |question|\n crrct = get_result(question)\n @submission.increment!(:point, question.point) if crrct\n @submission.question_evaluations.create({question_id: question.id, value: crrct})\n end\n @submission.update(evaluated: true)\n respond_to do |format|\n format.html { redirect_to test_submission_path(@test, @submission) }\n end\n else\n respond_to do |format|\n format.html { redirect_to submissions_path, success: 'Submission was successfully saved.' }\n end\n end\n\n end", "def evaluate\n response = Quiz.find(params[:quiz_id]).evaluate(params[:questions], current_user)\n @answers = response[:answers]\n @nota = response[:grade]\n\n respond_to do |format|\n format.html { render 'evaluate' }\n end\n end", "def update\n if @evaluation.update(evaluation_params)\n render :show, status: :ok\n else\n render json: @evaluation.errors, status: :unprocessable_entity\n end\n end", "def new\n @evaluation_criterium = EvaluationCriterium.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @evaluation_criterium }\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:course_id, :professor_id, :course_score, :teacher_score)\n end", "def new\n @score_evaluation = ScoreEvaluation.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @score_evaluation }\n end\n end", "def update\n if ENV[\"NEW_EVALUATION\"] == nil\n raise ActionController::RoutingError\n return\n end\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluate_params\n params.require(:evaluate).permit(:rating, :comment)\n end", "def create\n @employee = Employee.find(1)\n @performance_evaluation = @employee.performance_evaluations.build(performance_evaluation_params)\n #@performance_evaluation = PerformanceEvaluation.new(performance_evaluation_params)\n\n respond_to do |format|\n if @performance_evaluation.save\n format.html { redirect_to @performance_evaluation, notice: 'Performance evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @performance_evaluation }\n else\n format.html { render :new }\n format.json { render json: @performance_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @evaluations = Evaluation.all\n end", "def get_eval\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluation = @student.evaluations.find(params[:eval_id])\n\t\trender json: @evaluation\n\tend", "def create\n @evaluation = Evaluation.new(evaluation_params)\n @evaluation.project_id = params[:projectId]\n @evaluation.team_member_id = params[:teamMemberId]\n @evaluation.user_id = helpers.current_user.id\n\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @evaluation }\n else\n # restore relations\n if(@evaluation.project_id)\n @project = Project.find @evaluation.project_id\n end\n if(@evaluation.team_member_id)\n @member = TeamMember.find(@evaluation.team_member_id).user\n end\n\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluationstatus = Evaluationstatus.new(params[:evaluationstatus])\n\n respond_to do |format|\n if @evaluationstatus.save\n format.html { redirect_to @evaluationstatus, notice: 'Evaluation status was successfully created.' }\n format.json { render json: @evaluationstatus, status: :created, location: @evaluationstatus }\n else\n format.html { render action: \"new\" }\n format.json { render json: @evaluationstatus.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @dish_evaluation = DishEvaluation.new(dish_evaluation_params)\n\n respond_to do |format|\n if @dish_evaluation.save\n format.html { redirect_to @dish_evaluation, notice: 'Dish evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @dish_evaluation }\n else\n format.html { render :new }\n format.json { render json: @dish_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @evaluations = Evaluation.all\n end", "def index\n @score_evaluations = ScoreEvaluation.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @score_evaluations }\n end\n end", "def create\n @anstoeval = Anstoeval.new(anstoeval_params)\n\n respond_to do |format|\n if @anstoeval.save\n format.html { redirect_to @anstoeval, notice: 'anstoeval was successfully created.' }\n format.json { render :show, status: :created, location: @anstoeval }\n else\n format.html { render :new }\n format.json { render json: @anstoeval.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluation_params\n params.require(:evaluation).permit(:user_id, :mode)\n end", "def create\n @restaurant_evaluation = RestaurantEvaluation.new(restaurant_evaluation_params)\n @restaurant_evaluation.user_id = current_user.id\n respond_to do |format|\n if @restaurant_evaluation.save\n format.html { redirect_to Restaurant.find_by_id(@restaurant_evaluation.restaurant_id), notice: 'Restaurant evaluation was successfully created.' }\n format.json { render :show, status: :created, location: @restaurant_evaluation }\n else\n format.html { render :new }\n format.json { render json: @restaurant_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def user_evaluation_params\n params.require(:user_evaluation).permit(:evaluator_id)\n end", "def evaluacion_params\n params.require(:evaluacion).permit(:pregunta_1, :pregunta_2, :pregunta_3, :pregunta_4, :pregunta_5, :pregunta_6, :pregunta_7, :pregunta_8, :observacion, :fecha_evaluacion, :nota, :nota_informe_practica)\n end", "def send_evaluate_prop\n task = @proposal.evaluate_proposals.create\n task.workbench = Organization.find params[:organization][:organization_id]\n task.save\n redirect_to :action => \"pending\"\n end", "def addEval\n #puts \"hi student being evaluatied\"\n #puts params[:evaluation][:student_evaluated]\n #@team_member = User.find_by(u_name: params[:evaluation][:student_evaluated])\n @specific_user = User.find_by(u_name: params[:evaluation][:student_evaluating])\n @current_project = Project.find_by(p_name: params[:evaluation][:project])\n\n #puts \"start11\"\n #puts @team_member.inspect\n #puts @specific_user.inspect\n #puts @current_project.inspect\n\n # Klass.create subject: 'Maths', student: bart, tutor: edna\n # object = Student.new(:name => \"a\", :age => 2)\n @evaluation = Evaluation.new(student_evaluated: params[:evaluation][:student_evaluated], content: params[:evaluation][:content], rating: params[:evaluation][:rating], user: @specific_user, project: @current_project)\n puts \"hi2\"\n puts @evaluation.inspect\n #@evaluation = Evaluation.new(student_evaluated: @team_member.u_name, content: params[:content], \n #rating: params[:rating], user: @specific_user, project: @current_project)\n if @evaluation.save\n redirect_to userSpecificProjects_url\n #format.html { redirect_to evalAndSuccess_url(@evaluation), notice: 'Evaluation was successfully created.' }\n #format.json { render :evalAddSuccess, status: :created, location: @evaluation }\n else\n redirect_to userSpecificProjects_url\n #format.html { render :ratingPage_path(:team_member => @team_member.id) }\n end\n end", "def new\n @evaluations = Evaluation.new\n end", "def create\n #@observation = Observation.find params[:observation_id]\n @evaluation = Evaluation.new(params[:evaluation])\n @observation = @evaluation.observation\n respond_to do |format|\n if @evaluation.save\n session.delete(:teacher_id)\n session.delete(:guarant_id)\n session.delete(:path)\n format.html { redirect_to observation_evaluation_path(@observation,@evaluation), notice: 'Hodnocení bylo úspěšně vytvořeno.' }\n format.json { render json: @evaluation, status: :created, location: @evaluation }\n else\n format.html { render action: \"new\", :layout => \"tabs\" }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n\n if @evaluation.save\n flash[:success] = 'Evaluación creada con éxito.'\n if @evaluation.is_a? Course and params[:areas]\n params[:areas].each do |a|\n\n area = Area.find a\n area.inscriptions.preinscrito.each do |pr|\n pr.evaluation_id = @evaluation.id\n pr.save\n end\n\n @evaluation.area_courses.create(area_id: a)\n end\n end\n else\n flash[:danger] = \"Error: #{@evaluation.errors.full_messages.to_sentence}\"\n end\n\n redirect_back fallback_location: \"#{evaluations_path}?#{@evaluation.type}=true\"\n\n end", "def create\n @evaluation = Evaluation.new(evaluation_params)\n @evaluation.group_id = params[:group_id]\n @evaluation.student_id = current_student.id\n respond_to do |format|\n if @evaluation.save\n format.html { redirect_to student_dashboard_path, notice: 'Evaluation was successfully created.' }\n format.json { render :show, status: :created, location: student_dashboard_path }\n else\n format.html { render :new }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def new\n @competency_pertenece_evaluation = CompetencyPerteneceEvaluation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competency_pertenece_evaluation }\n end\n end", "def create\n @pacient = Pacient.find(params[:pacient_id])\n @evaluare = @pacient.evaluares.create(params[:evaluare])\n\n respond_to do |format|\n if @evaluare.save\n format.html { redirect_to @pacient, notice: 'Evaluare was successfully created.' }\n format.json { render json: @evaluare, status: :created, location: @evaluare }\n else\n format.html { render action: \"new\" }\n format.json { render json: @evaluare.errors, status: :unprocessable_entity }\n end\n end\n end", "def completed_evaluations_list\n\t\t@student = Student.find(params[:student_id])\n\t\t@evaluations = []\n\t\tfor evaluation in @student.evaluations\n\t\t\tif evaluation.isCompleted\n\t\t\t\t@evaluations << evaluation\n\t\t\tend\n\t\tend\n\t\trender json: @evaluations\n\tend", "def create\n @evaluation_result = current_evaluation.evaluation_results.new(evaluation_result_params)\n @evaluation_result.created = current_user\n @evaluation_result.updated_by = current_user.id\n @evaluation_result.company_branch_ids = params[\"evaluation_result\"][\"evaluation_result_company_branches\"].reject!{ |c| !c.present? }\n\n if params[:links].present? and params[:links].is_a?(Array)\n @evaluation_result.links = params[:links][1..-1].select(&:present?)\n end\n\n respond_to do |format|\n if @evaluation_result.save\n track_evaluation_update\n\n format.html { redirect_to customer_evaluation_path(current_customer, current_evaluation), notice: I18n.t('evaluation_results.messages.successfully_created') }\n format.json { render json: @evaluation_result, status: :created, location: @evaluation_result }\n else\n format.html { render action: :new }\n format.json { render json: @evaluation_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @evaluacion_servicio = EvaluacionServicio.new(evaluacion_servicio_params)\n \n respond_to do |format|\n if @evaluacion_servicio.save\n format.html { redirect_to servicio_sociales_path, notice: 'Evaluacion servicio was successfully created.' }\n format.json { render :show, status: :created, location: @evaluacion_servicio }\n else\n format.html { render :new }\n format.json { render json: @evaluacion_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def evaluacione_params\r\n params.require(:evaluacione).permit(:contestada, :curso_id, :encuesta_id, :nombre)\r\n end", "def index\n @evaluates = Evaluate.all\n end", "def update\n @response_to_the_evaluation = ResponseToTheEvaluation.find(params[:id])\n @response_to_the_evaluation.save\n respond_to do |format|\n if @response_to_the_evaluation.save\n format.json\n format.js\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'La evaluación fue actualizada correctamente' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @evaluaciones = Evaluacion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @evaluaciones }\n end\n end", "def evaluate(id)\n connection.post do |req|\n req.url \"job/#{id}/evaluate\"\n end\n end", "def create\n @current_student = Student.find_by(id: session[:student_id]) # ADDED THIS BUT NOT DONE\n # Get the two params then add the rest later? Still need to figure out how to get evaluee id\n @evaluation = Evaluation.new(evaluation_params)\n if @evaluation.save\n flash[:success] = \"Evaluation submitted\"\n redirect_to student_evaluation_path\n else\n flash[:warning] = \"Could not submit\"\n redirect_to student_evaluation_path\n end\n end" ]
[ "0.7273974", "0.70637333", "0.69349927", "0.6858234", "0.6858234", "0.6789653", "0.67693055", "0.6732888", "0.6721708", "0.66040987", "0.6552739", "0.6520129", "0.64986", "0.6492909", "0.64158195", "0.6408603", "0.63761246", "0.6324832", "0.63137615", "0.63137615", "0.6295575", "0.6277479", "0.62640053", "0.6252639", "0.61895406", "0.61878484", "0.6182659", "0.61731935", "0.6157265", "0.61422485", "0.6108931", "0.6097073", "0.60879403", "0.60830396", "0.6081391", "0.60725105", "0.6060356", "0.6056718", "0.6048866", "0.60442495", "0.604424", "0.60336435", "0.6033484", "0.60329705", "0.6017782", "0.6016468", "0.6004926", "0.6000799", "0.5974908", "0.59723276", "0.5956593", "0.5925222", "0.59174913", "0.5914246", "0.590798", "0.5907554", "0.58920383", "0.588781", "0.5883795", "0.58749986", "0.58689237", "0.5862783", "0.5858798", "0.5844147", "0.5836803", "0.5830056", "0.5828253", "0.5828253", "0.5828253", "0.5828253", "0.5828253", "0.5825644", "0.58101255", "0.5805122", "0.5796112", "0.57953316", "0.5792183", "0.578321", "0.57771474", "0.5773397", "0.57646596", "0.57620525", "0.5731663", "0.5718036", "0.5716851", "0.5699499", "0.5690932", "0.56813836", "0.56693166", "0.5658556", "0.5657261", "0.56486505", "0.56478906", "0.56372607", "0.5632514", "0.561434", "0.5613847", "0.5607543", "0.56044555", "0.5596483" ]
0.56916785
86
PATCH/PUT /evaluations/1 PATCH/PUT /evaluations/1.json
def update respond_to do |format| if @evaluation.update(evaluation_params) @practice = Practice.find(@evaluation.practice_id) if @practice.answer == @evaluation.your_answer @justice = Justice.create!( user_id: 1, evaluation_user_id: @evaluation.user_id, practice_id: @evaluation.practice_id, evaluation_id: @evaluation.id, score: @evaluation.practice_score, # 得到满分 p_score: @evaluation.practice_score, remark: "完全正确!", ) @evaluation.update(score: @evaluation.practice_score) end format.html { redirect_to @evaluation, notice: "答案更新成功" } format.json { render :show, status: :ok, location: @evaluation } else format.html { render :edit } format.json { render json: @evaluation.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if ENV[\"NEW_EVALUATION\"] == nil\n raise ActionController::RoutingError\n return\n end\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @evaluacion = Evaluacion.find(params[:id])\n\n respond_to do |format|\n if @evaluacion.update_attributes(params[:evaluacion])\n format.html { redirect_to @evaluacion, notice: 'Evaluacion was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @evaluacion.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @evaluation = Evaluation.find(params[:id])\n\n respond_to do |format|\n if @evaluation.update_attributes(params[:evaluation])\n format.html { redirect_to @evaluation, notice: 'Avaliacao atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: \"Evaluation was successfully updated.\" }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @evaluation.update(evaluation_params)\n render :show, status: :ok\n else\n render json: @evaluation.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @evaluate.update(evaluate_params)\n format.html { redirect_to @evaluate, notice: 'Evaluate was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluate }\n else\n format.html { render :edit }\n format.json { render json: @evaluate.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'La evaluación fue actualizada correctamente' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @eval = Eval.find(params[:id])\n if @eval.update_attributes(params[:eval])\n flash[:notice] = \"Eval was successfully updated.\"\n respond_with(@eval)\n else\n respond_with(@eval.errors)\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to @evaluation, notice: 'Avaliação atualizada.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to result_url(@evaluation), notice: \"\" }\n format.json { redirect_to result_url(@evaluation) }\n #else\n # format.html { render :edit }\n # format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @evaluation_criterium = EvaluationCriterium.find(params[:id])\n\n respond_to do |format|\n if @evaluation_criterium.update_attributes(params[:evaluation_criterium])\n format.html { redirect_to @evaluation_criterium, notice: 'Evaluation criterium was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @evaluation_criterium.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @evaluation = Evaluation.find(params[:id])\n\n respond_to do |format|\n if @evaluation.update_attributes(params[:evaluation])\n format.html { redirect_to(@evaluation, :notice => 'Evaluation was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @evaluation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\r\n respond_to do |format|\r\n if @evaluacione.update(evaluacione_params)\r\n format.html { redirect_to @evaluacione, notice: 'Evaluacione was successfully updated.' }\r\n format.json { render :show, status: :ok, location: @evaluacione }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @evaluacione.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n @evaluation.updated_by = current_user.id\n\n respond_to do |format|\n if @evaluation.update_attributes(evaluation_params)\n format.html {redirect_to customer_evaluation_path(current_customer, @evaluation), notice: I18n.t('evaluations.messages.successfully_updated')}\n format.json {head :no_content}\n else\n format.html {render action: \"edit\"}\n format.json {render json: @evaluation.errors, status: :unprocessable_entity}\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n format.html { redirect_to course_evaluations_url, notice: 'La evaluación fue modificada correctamente!' }\n else\n format.html { render :edit }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluo.update(evaluo_params)\n format.html { redirect_to @evaluo, notice: 'Evaluo was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluo }\n else\n format.html { render :edit }\n format.json { render json: @evaluo.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluation_builder.update(evaluation_builder_params)\n format.html { redirect_to @evaluation_builder, notice: 'Evaluation builder was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluation_builder }\n else\n format.html { render :edit }\n format.json { render json: @evaluation_builder.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @evaluationstatus = Evaluationstatus.find(params[:id])\n\n respond_to do |format|\n if @evaluationstatus.update_attributes(params[:evaluationstatus])\n format.html { redirect_to @evaluationstatus, notice: 'Evaluation status was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @evaluationstatus.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @evaluare = Evaluare.find(params[:id])\n\n respond_to do |format|\n if @evaluare.update_attributes(params[:evaluare])\n format.html { redirect_to @evaluare, notice: 'Evaluare was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @evaluare.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @evaluation = Evaluation.find(params[:id])\n\n respond_to do |format|\n if @evaluation.update_attributes(params[:evaluation])\n flash[:notice] = 'Evaluation was successfully updated.'\n format.html { redirect_to(@evaluation) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @evaluation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @response_to_the_evaluation = ResponseToTheEvaluation.find(params[:id])\n @response_to_the_evaluation.save\n respond_to do |format|\n if @response_to_the_evaluation.save\n format.json\n format.js\n end\n end\n end", "def update\n @evaluacione = Evaluacione.find(params[:id])\n\n respond_to do |format|\n if @evaluacione.update_attributes(params[:evaluacione])\n format.html { redirect_to(@evaluacione, :notice => 'Evaluacione was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @evaluacione.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @anstoeval.update(anstoeval_params)\n format.html { redirect_to @anstoeval, notice: 'anstoeval was successfully updated.' }\n format.json { render :show, status: :ok, location: @anstoeval }\n else\n format.html { render :edit }\n format.json { render json: @anstoeval.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @performance_evaluation.update(performance_evaluation_params)\n format.html { redirect_to @performance_evaluation, notice: 'Performance evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @performance_evaluation }\n else\n format.html { render :edit }\n format.json { render json: @performance_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch!\n request! :patch\n end", "def update\n respond_to do |format|\n if @psicologic_evaluation.update(psicologic_evaluation_params)\n format.html { redirect_to @psicologic_evaluation, notice: 'Psicologic evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @psicologic_evaluation }\n else\n format.html { render :edit }\n format.json { render json: @psicologic_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @qc_evaluation = QcEvaluation.find(params[:id])\n\n respond_to do |format|\n if @qc_evaluation.update_attributes(params[:qc_evaluation])\n format.html { redirect_to @qc_evaluation, notice: 'Qc evaluation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @qc_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @evaluation = Evaluation.find(params[:id])\n @observation = @evaluation.observation\n \n respond_to do |format|\n if @evaluation.update_attributes(params[:evaluation])\n session.delete(:teacher_id)\n session.delete(:guarant_id)\n session.delete(:path)\n format.html { redirect_to evaluation_path(@evaluation), notice: 'Hodnocení bylo úspěšně upraveno.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\", :layout => \"evaluation_tabs\" }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @evaluacion_servicio.update(evaluacion_servicio_params)\n format.html { redirect_to @evaluacion_servicio, notice: 'Evaluacion servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @evaluacion_servicio }\n else\n format.html { render :edit }\n format.json { render json: @evaluacion_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @pe.update(update_project_evaluation_params)\n render json: @pe, status: :ok\n else\n render json: format_errors(@pe.errors), status: :unprocessable_entity\n end\n end", "def update\n @rcrieval = Rcrieval.find(params[:id])\n\n respond_to do |format|\n if @rcrieval.update_attributes(params[:rcrieval])\n format.html { redirect_to @rcrieval, notice: 'Rcrieval was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @rcrieval.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @competency_pertenece_evaluation = CompetencyPerteneceEvaluation.find(params[:id])\n\n respond_to do |format|\n if @competency_pertenece_evaluation.update_attributes(params[:competency_pertenece_evaluation])\n format.html { redirect_to @competency_pertenece_evaluation, notice: 'Competency pertenece evaluation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @competency_pertenece_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @course_evaluation.update(course_evaluation_params)\n format.html { redirect_to @course_evaluation, notice: 'Course evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @course_evaluation }\n else\n format.html { render :edit }\n format.json { render json: @course_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @evaluation.update(evaluation_params)\n redirect_to action: \"index\", notice: 'Evaluation was successfully updated.' \n else\n render :edit \n end\n end", "def update\n if @evaluation.update(evaluation_params)\n flash[:success] = 'Actualizado correctamente'\n redirect_to evaluations_url\n else\n flash[:danger] = 'Ocurrió un error'\n render :edit\n end\n end", "def update\n @expectation = Expectation.find(params[:id])\n\n respond_to do |format|\n if @expectation.update_attributes(params[:expectation])\n format.html { redirect_to @expectation, notice: 'Expectation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @expectation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @model_evaluations = args[:model_evaluations] if args.key?(:model_evaluations)\n @next_page_token = args[:next_page_token] if args.key?(:next_page_token)\n end", "def update # PATCH\n raise NotImplementedError\n end", "def update\n respond_to do |format|\n if @student_goal_evaluation.update(student_goal_evaluation_params)\n format.html { redirect_to root_path, notice: 'Evalueringen er opdateret.' }\n format.json { render :show, status: :ok, location: @student_goal_evaluation }\n else\n format.html { render :edit }\n format.json { render json: @student_goal_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @evaluation_sheet = EvaluationSheet.find(params[:id])\n\n respond_to do |format|\n if @evaluation_sheet.update_attributes(params[:evaluation_sheet])\n format.html { redirect_to @evaluation_sheet, notice: 'Evaluation sheet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @evaluation_sheet.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :update, @theorem\n if @theorem.update(theorem_params)\n render json: @theorem, status: :ok, location: @theorem\n else\n render json: @theorem.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @expression.update_attributes expression_params\n format.html { redirect_to @expression, notice: 'Expression was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @expression.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n \n if @evaluation.update(evaluation_params)\n if params[:evaluation][:grades_attributes].present?\n @evaluation.set_grade=true\n @evaluation.save\n end\n format.html { redirect_to course_evaluation_path(@course,@evaluation), notice: 'La evaluación fue actualizada con éxito.' }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n if params[:evaluation][:grades_attributes].present?\n format.html { render :show }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end\n end", "def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end", "def update\n respond_to do |format|\n if @project_evaluation.update(project_evaluation_params)\n format.html { redirect_to @project_evaluation, notice: 'Project evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @project_evaluation }\n else\n format.html { render :edit }\n format.json { render json: @project_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n render_json_auto @survey.update_logic_control_rule(params[:id].to_i, params[:logic]) and return\n end", "def update\n respond_to do |format|\n if @restaurant_evaluation.update(restaurant_evaluation_params)\n format.html { redirect_to @restaurant_evaluation, notice: 'Restaurant evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @restaurant_evaluation }\n else\n format.html { render :edit }\n format.json { render json: @restaurant_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @survey = Survey.find(params[:id])\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n\n respond_to do |format|\n if @survey.update_attributes(json)\n format.html { redirect_to @survey, notice: 'Survey was successfully updated.' }\n format.json { render json: @survey }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @evaluable_competency = EvaluableCompetency.find(params[:id])\n\n respond_to do |format|\n if @evaluable_competency.update_attributes(params[:evaluable_competency])\n format.html { redirect_to @evaluable_competency, :notice => t('successfully_updated', :model => t('EvaluableCompetency.gender', :count => 1)) }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @evaluable_competency.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @test_subject_evaluation = @test_subject.test_subject_evaluations.find(params[:id])\n\n #Check if symptoms and past_medical is empty\n if !params.has_key?(:symptoms)\n @test_subject_evaluation.symptoms = []\n end\n if !params.has_key?(:past_medical)\n @test_subject_evaluation.past_medical = []\n end\n\n respond_to do |format|\n if @test_subject_evaluation.update_attributes(params[:test_subject_evaluation])\n flash[:notice] = \"#{TestSubject.title} Evaluation was successfully updated.\"\n format.html { redirect_to(test_subject_test_subject_evaluation_url(@test_subject, @test_subject_evaluation)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @test_subject_evaluation.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @review = Review.find(params[:id])\n @review.update(review_params)\n render json: @review\n end", "def update\n unless @submission.evaluated.blank?\n respond_to do |format|\n format.html { redirect_to test_submission_path(@test, @submission), info: \"Evaluated!\" }\n end\n return\n end\n\n unless Time.now > @timeout + 5.seconds\n @submission.answers_of_questions.each do |user_answer|\n user_answer.update(choice: submission_params.fetch(user_answer.answer_id.to_s, \"false\"))\n end\n end\n if Time.now > @timeout || params[:evaluate]\n @test.questions.each do |question|\n crrct = get_result(question)\n @submission.increment!(:point, question.point) if crrct\n @submission.question_evaluations.create({question_id: question.id, value: crrct})\n end\n @submission.update(evaluated: true)\n respond_to do |format|\n format.html { redirect_to test_submission_path(@test, @submission) }\n end\n else\n respond_to do |format|\n format.html { redirect_to submissions_path, success: 'Submission was successfully saved.' }\n end\n end\n\n end", "def update\n @predict = Predict.find(params[:id])\n\n respond_to do |format|\n if @predict.update_attributes(params[:predict])\n format.html { redirect_to @predict, notice: 'Predict was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @predict.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n put :update\n end", "def update\n if @review.update(review_params)\n render json: @review\n else\n render json: @review.errors, status: :unprocessable_entity\n end\nend", "def update\n @specification = Specification.find(params[:id])\n\n respond_to do |format|\n if @specification.update_attributes(params[:specification])\n format.html { redirect_to @specification, notice: 'Specification was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @specification.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #raise params.inspect\n @evaluation_result = EvaluationResult.find(params[:id])\n\n if params[:commit].to_s == \"Gravar Rascunho\"\n app = Appointment.find(params[:appoint_id].to_i)\n s = AppointmentStatus.find_by_name(\"Em Avaliacao\")\n app.appointment_status = s\n app.save\n else\n app = Appointment.find(params[:appoint_id].to_i)\n s = AppointmentStatus.find_by_name(\"Realizada\")\n app.appointment_status = s\n app.save\n end\n\n respond_to do |format|\n if @evaluation_result.update_attributes(params[:evaluation_result])\n if params[:commit].to_s == \"Gravar Rascunho\"\n format.html { redirect_to appointments_path, notice: 'Resultados da avaliacao guardados com sucesso.' }\n else\n format.html { redirect_to \"http://localhost:8000/reporting?report=Avaliacao&Appointment_Id=#{params[:appoint_id].to_s}\", notice: 'Resultados da avaliacao guardados com sucesso.' }\n end\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @evaluation_result.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @dish_evaluation.update(dish_evaluation_params)\n format.html { redirect_to @dish_evaluation, notice: 'Dish evaluation was successfully updated.' }\n format.json { render :show, status: :ok, location: @dish_evaluation }\n else\n format.html { render :edit }\n format.json { render json: @dish_evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @matrix_evaluation_type = MatrixEvaluationType.find(params[:id])\n\n respond_to do |format|\n if @matrix_evaluation_type.update_attributes(params[:matrix_evaluation_type])\n format.html { redirect_to @matrix_evaluation_type, :notice => 'Avaliação de Matriz atualizada com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @matrix_evaluation_type.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @experiment = Experiment.find(params[:id])\n\n respond_to do |format|\n if @experiment.update_attributes(params[:experiment])\n format.html { redirect_to @experiment, notice: 'Experiment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @experiment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @experiment = Experiment.find(params[:id])\n\n respond_to do |format|\n if @experiment.update_attributes(params[:experiment])\n format.html { redirect_to @experiment, notice: 'Experiment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @experiment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n authorize! :edit, @questionnaire\n\n @questionnaire.load_JSON(params[:questionnaire], current_user)\n\n respond_to do |format|\n# if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to @questionnaire, notice: 'Kysymyslomakkeen muokkaaminen onnistui.' }\n format.json { head :no_content }\n# else\n# format.html { render action: \"edit\" }\n# format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n# end\n\n end\n end", "def update\n @experiment = Experiment.find(params[:id])\n\n respond_to do |format|\n if @experiment.update_attributes(params[:experiment])\n format.html { redirect_to @experiment, notice: 'experiment was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @experiment.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @diff_expr.update(diff_expr_params)\n format.html { redirect_to @diff_expr, notice: 'Diff expr was successfully updated.' }\n format.json { render :show, status: :ok, location: @diff_expr }\n else\n format.html { render :edit }\n format.json { render json: @diff_expr.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @criterio_evalucion_servicio.update(criterio_evalucion_servicio_params)\n format.html { redirect_to @criterio_evalucion_servicio, notice: 'Criterio evalucion servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @criterio_evalucion_servicio }\n else\n format.html { render :edit }\n format.json { render json: @criterio_evalucion_servicio.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @calculation = Calculation.find(params[:id])\n\n respond_to do |format|\n if @calculation.update_attributes(params[:calculation])\n format.html { redirect_to @calculation, notice: 'Calculation was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @calculation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\r\n @calculation = Calculation.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @calculation.update_attributes(params[:calculation])\r\n format.html { redirect_to @calculation, notice: 'Calculation updated.' }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @calculation.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end", "def update\n respond_to do |format|\n if @question_learned.update(question_learned_params)\n format.html { redirect_to @question_learned, notice: 'Question learned was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question_learned.errors, status: :unprocessable_entity }\n end\n end\n end", "def update(&block)\n validate_request()\n\n # Params includes all of the PATCH data at the top level along with other\n # other Rails-injected params like 'id', 'action', 'controller'. These\n # are harmless given no namespace collision and we're only interested in\n # the 'Operations' key for the actual patch data.\n #\n render(json: yield(self.safe_params()[:id], self.safe_params().to_hash()))\n end", "def update\n if @specification.update(specification_params)\n audit(@specification, current_user)\n render json: @specification, status: :ok, serializer: Web::V1::SpecificationSerializer\n else\n render json: @specification.errors, status: :unprocessable_entity\n end\n end", "def update\n if @v1_question.update(v1_question_params)\n render json: @v1_question, status: :ok\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @calculation.update(calculation_params)\n format.html { redirect_to calculation_path(@calculation, token: @calculation.edit_token) }\n format.json { render :show, status: :ok, location: @calculation }\n else\n format.html { render :edit }\n format.json { render json: @calculation.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_exercise.update(api_v1_exercise_params)\n format.html { redirect_to @api_v1_exercise, notice: 'Exercise was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_exercise }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_exercise.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @api_v1_outcome.update(api_v1_outcome_params)\n format.html { redirect_to @api_v1_outcome, notice: 'Outcome was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_outcome }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_outcome.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @score_evaluation = ScoreEvaluation.find(params[:id])\n params[:score_evaluation][:discipline_ids] ||= []\n \n respond_to do |format|\n if @score_evaluation.update_attributes(params[:score_evaluation])\n format.html { redirect_to @score_evaluation, :notice => t('selecao_admin.flash_messages.successfully_updated', :model => @score_evaluation.class.model_name.human) }\n format.json { head :no_content }\n format.js\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @score_evaluation.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end", "def update\n respond_to do |format|\n if @expression_of_interest.update(expression_of_interest_params)\n format.html { redirect_to @expression_of_interest, notice: 'Expression of interest was successfully updated.' }\n format.json { render :show, status: :ok, location: @expression_of_interest }\n else\n format.html { render :edit }\n format.json { render json: @expression_of_interest.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @answer = Answer.find(params[:id])\n\n if @answer.update(answer_params)\n head :no_content\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n end", "def update\n #debugger\n if @enrollment.update(update_params)\n head :no_content\n else\n render json: @enrollment.errors, status: :unprocessable_entity\n end\n end", "def update\n @request.assign_json_attributes(params) if @request.resume?\n respond_to do |format|\n if @request.update(request_params)\n format.html { redirect_to @request, notice: 'Request was successfully updated.' }\n format.json { render :show, status: :ok, location: @request }\n else\n format.html { render :edit }\n format.json { render json: @request.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n recipe.update(recipe_params)\n render json: recipe\n end", "def update\n @criterion = Criterion.find(params[:id])\n\n if @criterion.update_attributes(params[:criterion])\n head :no_content\n else\n render json: @criterion.errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @exam.update(exam_params)\n format.html { redirect_to @exam, notice: 'Exam was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @model_evaluation = args[:model_evaluation] if args.key?(:model_evaluation)\n end", "def update\n respond_to do |format|\n if @grade_calc.update(grade_calc_params)\n format.html { redirect_to @grade_calc, notice: 'Grade calc was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @grade_calc.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @scoring_method = ScoringMethod.find(params[:id])\n\n respond_to do |format|\n if @scoring_method.update_attributes(params[:scoring_method])\n format.html { redirect_to @scoring_method, notice: 'Scoring method was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @scoring_method.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n # @person = Person.find(params[:id])\n # @person.pct_complete = @person.requirement_progress\n respond_to do |format|\n if @person.update_attributes(params[:person])\n format.html { redirect_to @person, :notice => 'Person was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @person.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @formula.update(formula_params)\n format.html { redirect_to @formula, notice: 'Formula was successfully updated.' }\n format.json { render :show, status: :ok, location: @formula }\n else\n format.html { render :edit }\n format.json { render json: @formula.errors, status: :unprocessable_entity }\n end\n end\n end", "def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end", "def update\n official = Official.find(params[:id])\n if official.update(official_params)\n render json: official, status: 200, location: [:api, official]\n else\n failed_to_update(official, \"official\")\n end\n end", "def update\n @testing_algorithm = TestingAlgorithm.find(params[:id])\n\n if @testing_algorithm.update(params[:testing_algorithm])\n head :no_content\n else\n render json : @testing_algorithm.errors, status : :unprocessable_entity\n end\n end", "def update_rest\n @entry_answer = EntryAnswer.find(params[:id])\n\n respond_to do |format|\n if @entry_answer.update_attributes(params[:entry_answer])\n flash[:notice] = 'EntryAnswer was successfully updated.'\n format.html { redirect_to(@entry_answer) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @entry_answer.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @exam = Exam.find(params[:id])\n\n respond_to do |format|\n if @exam.update_attributes(params[:exam])\n format.html { redirect_to exams_path, notice: 'Exam was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @exp = Exp.find(params[:id])\n\n respond_to do |format|\n if @exp.update_attributes(params[:exp])\n format.html { redirect_to @exp, notice: 'Successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exp.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @survey_choice = Survey::Choice.find(params[:id])\n\n respond_to do |format|\n if @survey_choice.update_attributes(params[:survey_choice])\n format.html { redirect_to @survey_choice, notice: 'Choice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey_choice.errors, status: :unprocessable_entity }\n5 end\n end\n end", "def update\n p = trial_params.clone\n if p[\"question_ids\"].nil?\n p[\"question_ids\"] = []\n end\n\n respond_to do |format|\n if @trial.update(p)\n format.html { redirect_to @trial, notice: 'Trial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trial.errors, status: :unprocessable_entity }\n end\n end\n end" ]
[ "0.6757492", "0.6757492", "0.6750937", "0.66880345", "0.65852636", "0.65578616", "0.6551743", "0.6551743", "0.6551743", "0.6516151", "0.6515917", "0.6453893", "0.6448572", "0.6440103", "0.64335555", "0.6425717", "0.6365227", "0.6329448", "0.6310252", "0.62973964", "0.6282295", "0.6273407", "0.6256658", "0.6234015", "0.622335", "0.62143093", "0.6198596", "0.6183403", "0.6163907", "0.6134908", "0.6115301", "0.6112063", "0.6096818", "0.6075616", "0.6071964", "0.607074", "0.6054603", "0.6046962", "0.60321325", "0.6030144", "0.60268295", "0.5981172", "0.5978452", "0.5973909", "0.59713596", "0.59683156", "0.59674615", "0.5951609", "0.5944046", "0.59426016", "0.5899536", "0.58915293", "0.58693135", "0.5861224", "0.5823644", "0.5822047", "0.58182305", "0.5799759", "0.57949513", "0.57938504", "0.57909536", "0.578335", "0.57743835", "0.5774293", "0.5768477", "0.5760399", "0.5760399", "0.5753652", "0.5753112", "0.5751337", "0.57348686", "0.5728914", "0.57248354", "0.5721642", "0.5716241", "0.5710731", "0.57103974", "0.5710059", "0.57090837", "0.57080925", "0.57079047", "0.5705221", "0.56983393", "0.5693487", "0.5691176", "0.5689819", "0.5689227", "0.5686478", "0.56864506", "0.56851786", "0.56834203", "0.5662943", "0.5658399", "0.56544524", "0.56523985", "0.56499535", "0.56499356", "0.56441885", "0.56439626", "0.56368345", "0.5632616" ]
0.0
-1
DELETE /evaluations/1 DELETE /evaluations/1.json
def destroy @evaluation.destroy respond_to do |format| format.html { redirect_to evaluations_url, notice: '答题记录已被删除' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluacion = Evaluacion.find(params[:id])\n @evaluacion.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluaciones_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation = Evaluation.find(params[:id])\n @evaluation.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'La evaluación fue eliminada satisfactoriamente' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Avaliação deletada.' }\n format.json { head :no_content }\n end\n end", "def destroy\n entry = @evaluation.entry\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation_criterium = EvaluationCriterium.find(params[:id])\n @evaluation_criterium.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluation_criteria_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation = Evaluation.find(params[:id])\n @evaluation.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @evaluation = Evaluation.find(params[:id])\n @evaluation.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @evaluare = Evaluare.find(params[:id])\n @evaluare.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluares_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @qc_evaluation = QcEvaluation.find(params[:id])\n @qc_evaluation.destroy\n\n respond_to do |format|\n format.html { redirect_to qc_evaluations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluate.destroy\n respond_to do |format|\n format.html { redirect_to evaluates_url, notice: 'Evaluate was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\r\n @evaluation = Evaluation.find(params[:id])\r\n @evaluation.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to(evaluations_url) }\r\n format.xml { head :ok }\r\n end\r\n end", "def destroy\n @evaluationstatus = Evaluationstatus.find(params[:id])\n @evaluationstatus.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluationstatuses_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluacione = Evaluacione.find(params[:id])\n @evaluacione.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluaciones_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @evaluation_result = EvaluationResult.find(params[:id])\n @evaluation_result.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluation_results_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to evaluations_url, notice: 'Evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @rcrieval = Rcrieval.find(params[:id])\n @rcrieval.destroy\n\n respond_to do |format|\n format.html { redirect_to rcrievals_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluator.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluators_url) }\n format.xml { head :ok }\n end\n end", "def destroy\r\n @evaluacione.destroy\r\n respond_to do |format|\r\n format.html { redirect_to evaluaciones_url, notice: 'Evaluacione was successfully destroyed.' }\r\n format.json { head :no_content }\r\n end\r\n end", "def destroy\n @evaluo.destroy\n respond_to do |format|\n format.html { redirect_to evaluos_url, notice: 'Evaluo was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @competency_pertenece_evaluation = CompetencyPerteneceEvaluation.find(params[:id])\n @competency_pertenece_evaluation.destroy\n\n respond_to do |format|\n format.html { redirect_to competency_pertenece_evaluations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @student_goal_evaluation.destroy\n respond_to do |format|\n format.html { redirect_to student_goal_evaluations_url, notice: 'Evalueringen er slettet.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @eval = Eval.find(params[:id])\n @eval.destroy\n redirect_to(evals_url)\n end", "def destroy\n @test_subject_evaluation = @test_subject.test_subject_evaluations.find(params[:id])\n @test_subject_evaluation.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_subject_test_subject_evaluations_url(@test_subject)) }\n format.xml { head :ok }\n end\n end", "def destroy\n @performance_evaluation.destroy\n respond_to do |format|\n format.html { redirect_to performance_evaluations_url, notice: 'Performance evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluable_competency = EvaluableCompetency.find(params[:id])\n @evaluable_competency.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluable_competencies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation.destroy\n respond_to do |format|\n format.html { redirect_to course_evaluations_url, notice: 'La evaluación fue eliminada correctamente!' }\n end\n end", "def destroy\n respond_to do |format|\n if @evaluation.destroy\n format.html { redirect_to course_evaluations_path(@course), notice: 'La evaluación fue eliminada con éxito.' }\n format.json { head :no_content }\n else\n format.html { render :show }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end", "def destroy\n @anstoeval.destroy\n respond_to do |format|\n format.html { redirect_to anstoevals_url, notice: 'anstoeval was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @score_evaluation = ScoreEvaluation.find(params[:id])\n @score_evaluation.destroy\n \n respond_to do |format|\n format.html { redirect_to score_evaluations_url }\n format.json { head :no_content }\n format.js\n end\n end", "def destroy\n @restaurant_evaluation.destroy\n respond_to do |format|\n format.html { redirect_to restaurant_evaluations_url, notice: 'Restaurant evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @psicologic_evaluation.destroy\n respond_to do |format|\n format.html { redirect_to psicologic_evaluations_url, notice: 'Psicologic evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @course_evaluation.destroy\n respond_to do |format|\n format.html { redirect_to course_evaluations_url, notice: 'Course evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation_builder.destroy\n respond_to do |format|\n format.html { redirect_to event_evaluation_builders_url(@event), notice: 'Evaluation builder was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @dish_evaluation.destroy\n respond_to do |format|\n format.html { redirect_to dish_evaluations_url, notice: 'Dish evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expression.destroy\n respond_to do |format|\n format.html { redirect_to expressions_url }\n format.json { head :ok }\n end\n end", "def destroy\n @evaluation.destroy\n flash[:success] = 'Eliminado correctamente'\n redirect_to evaluations_url\n end", "def destroy\n @evaluation.destroy\n\n respond_to do |format|\n format.html {redirect_to customer_path(current_customer)}\n format.json {head :no_content}\n end\n end", "def destroy\n @evaluation.destroy\n end", "def destroy\n @project_evaluation.destroy\n respond_to do |format|\n format.html { redirect_to project_evaluations_url, notice: 'Project evaluation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def deleteExecution(execution_id)\n uri = URI(RUNDECKSERVER + ':' + RUNDECKPORT + '/api/12/execution/' + execution_id)\n http = Net::HTTP.new(uri.host, uri.port)\n headers = {'Content-Type'=> 'application/jsonr','X-RunDeck-Auth-Token'=> API_KEY }\n r = http.delete(uri.path, headers) \n return r\nend", "def destroy\n @evaluation.destroy\n redirect_to action: \"index\", notice: 'Evaluation was successfully destroyed.' \n end", "def destroy\n @expectation = Expectation.find(params[:id])\n @expectation.destroy\n\n respond_to do |format|\n format.html { redirect_to expectations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluacion_servicio.destroy\n respond_to do |format|\n format.html { redirect_to evaluacion_servicios_url, notice: 'Evaluacion servicio was successfully destroyed.' }\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 @exercise_execution.destroy\n respond_to do |format|\n format.html { redirect_to exercise_executions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expectation = RiGse::Expectation.find(params[:id])\n @expectation.destroy\n\n respond_to do |format|\n format.html { redirect_to(expectations_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @exp = Exp.find(params[:id])\n @exp.destroy\n\n respond_to do |format|\n format.html { redirect_to exps_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @estimation.destroy\n respond_to do |format|\n format.html { redirect_to estimations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluation_sheet = EvaluationSheet.find(params[:id])\n @evaluation_sheet.destroy\n\n respond_to do |format|\n format.html { redirect_to evaluation_sheets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @assumption.destroy\n respond_to do |format|\n format.html { redirect_to assumptions_url }\n format.json { head :no_content }\n end\n end", "def delete!\n Recliner.delete(uri)\n end", "def destroy\n @assertion.destroy\n respond_to do |format|\n format.html { redirect_to assertions_url, notice: 'Assertion was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @explaination = Explaination.find(params[:id])\n @explaination.destroy\n\n respond_to do |format|\n format.html { redirect_to explainations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @accuracy = Accuracy.find(params[:id])\n @accuracy.destroy\n\n respond_to do |format|\n format.html { redirect_to accuracies_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @calculated_data_assessment = CalculatedDataAssessment.find(params[:id])\n @calculated_data_assessment.destroy\n\n respond_to do |format|\n format.html { redirect_to calculated_data_assessments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @weekly_expectation = WeeklyExpectation.find(params[:id])\n @weekly_expectation.destroy\n\n respond_to do |format|\n format.html { redirect_to weekly_expectations_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @matrix_evaluation_type = MatrixEvaluationType.find(params[:id])\n @matrix_evaluation_type.destroy\n\n respond_to do |format|\n format.html { redirect_to matrix_evaluation_types_url, :notice => 'Avaliação de Matriz excluída com sucesso.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @expression_relationship = ExpressionRelationship.find(params[:id])\n @expression_relationship.destroy\n\n respond_to do |format|\n format.html { redirect_to expression_relationships_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @policy_valuation.destroy\n respond_to do |format|\n format.html { redirect_to policy_valuations_url, notice: 'Policy valuation was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @rh.destroy\n respond_to do |format|\n format.html { redirect_to rhs_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @evaluate_course = EvaluateCourse.find(params[:id])\n @evaluate_course.destroy\n\n respond_to do |format|\n format.html { redirect_to(evaluate_courses_url) }\n format.xml { head :ok }\n end\n end", "def delete path\n make_request(path, \"delete\", {})\n end", "def destroy\n @criterion = Criterion.find(params[:id])\n @criterion.destroy\n\n respond_to do |format|\n format.html { redirect_to criteria_url }\n format.json { head :no_content }\n end\n end", "def delete\n request(:delete)\n end", "def destroy\n @retroaspecto = Retroaspecto.find(params[:id])\n @retroaspecto.destroy\n\n respond_to do |format|\n format.html { redirect_to retroaspectos_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @predicate = Predicate.find(params[:id])\n @predicate.destroy\n\n respond_to do |format|\n format.html { redirect_to predicates_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @criterion_grade.destroy\n respond_to do |format|\n format.html { redirect_to criterion_grades_url }\n format.json { head :no_content }\n end\n end", "def destroy\n render_json_auto @survey.delete_logic_control_rule(params[:id].to_i) and return\n end", "def destroy\n render_json_auto @survey.delete_filter(params[:id].to_i) and return\n end", "def destroy\n @assert = Assert.find(params[:id])\n @assert.destroy\n\n respond_to do |format|\n format.html { redirect_to asserts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @analyst_score.destroy\n respond_to do |format|\n format.html { redirect_to analyst_scores_url }\n format.json { head :no_content }\n end\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 @criterio_evalucion_servicio.destroy\n respond_to do |format|\n format.html { redirect_to criterio_evalucion_servicios_url, notice: 'Criterio evalucion servicio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @predict = Predict.find(params[:id])\n @predict.destroy\n\n respond_to do |format|\n format.html { redirect_to predicts_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @experiment = Experiment.find(params[:id])\n @experiment.destroy\n\n respond_to do |format|\n format.html { redirect_to experiments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @experiment = Experiment.find(params[:id])\n @experiment.destroy\n\n respond_to do |format|\n format.html { redirect_to experiments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @experiment = Experiment.find(params[:id])\n @experiment.destroy\n\n respond_to do |format|\n format.html { redirect_to experiments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @expression = Expression.find(params[:id])\n @expression.destroy\n\n respond_to do |format|\n format.html { redirect_to(expressions_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @rule.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @assert = Assert.find(params[:id])\n @assert.destroy\n\n respond_to do |format|\n format.html { redirect_to asserts_url }\n format.json { head :ok }\n end\n end", "def destroy\n @exam.destroy\n respond_to do |format|\n format.html { redirect_to exams_url }\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 set_experiments\n @experiment.destroy\n respond_to do |format|\n format.html { redirect_to experiments_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exam = Exam.find(params[:id])\n @exam.destroy\n\n respond_to do |format|\n format.html { redirect_to exams_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @requisition = Requisition.find(params[:id])\n @requisition.destroy\n\n respond_to do |format|\n format.html { redirect_to requisitions_url }\n format.json { head :no_content }\n end\n end", "def delete\n client.delete(\"/#{id}\")\n end", "def destroy\n @student_evaluation_case2.destroy\n respond_to do |format|\n format.html { redirect_to student_evaluation_case2s_url, notice: 'Student evaluation case2 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @api_v1_outcome.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_outcomes_url, notice: 'Outcome was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @formula.destroy\n respond_to do |format|\n format.html { redirect_to formulas_url, notice: 'Formula was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @criterium.destroy\n respond_to do |format|\n format.html { redirect_to criteria_url, notice: 'Criterium was successfully destroyed.' }\n format.json { head :no_content }\n end\n end" ]
[ "0.7423415", "0.7423415", "0.742291", "0.74181527", "0.71981627", "0.7197589", "0.7195351", "0.7195351", "0.7195351", "0.7195351", "0.7195351", "0.7195351", "0.71747017", "0.71078193", "0.70771676", "0.70721006", "0.70721006", "0.70574003", "0.70446515", "0.70344424", "0.70009774", "0.69889873", "0.6979415", "0.69696254", "0.69391304", "0.6933874", "0.6931643", "0.69188416", "0.6910973", "0.68683493", "0.6850852", "0.6842851", "0.6831354", "0.68118066", "0.6792649", "0.67620826", "0.6752384", "0.67314684", "0.6713716", "0.67082816", "0.6691969", "0.66512513", "0.6641324", "0.66377133", "0.6630316", "0.66117734", "0.6611711", "0.65649873", "0.65459436", "0.6534273", "0.6534198", "0.65107584", "0.65007275", "0.64847666", "0.6470485", "0.64608467", "0.645378", "0.63943946", "0.63902336", "0.6378803", "0.6375563", "0.63544804", "0.63536584", "0.6349071", "0.6348754", "0.63461477", "0.634158", "0.6328356", "0.63241196", "0.63219416", "0.63197064", "0.6319389", "0.63179684", "0.63132644", "0.63119847", "0.631122", "0.6308282", "0.63035923", "0.6292604", "0.6285706", "0.62821025", "0.6281968", "0.62818056", "0.62811315", "0.62781644", "0.62781644", "0.62781644", "0.62780106", "0.6275265", "0.6258488", "0.62568414", "0.62535536", "0.62480414", "0.62421715", "0.62407815", "0.62387514", "0.6237505", "0.6235613", "0.6234567", "0.62228644" ]
0.6711852
39
Use callbacks to share common setup or constraints between actions.
def set_evaluation @evaluation = Evaluation.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 evaluation_params params.require(:evaluation).permit(:user_id, :lesson_id, :practice_id, :title, :material, :question, :answer, :your_answer, :score, :practice_score, :picture_ya, :end_at, :papertest) 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
Fetch our toplevel settings, which apply to all endpoints in the API.
def top_level_setting @top_level_setting ||= build_top_level_setting end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_settings\n get_uri = @data['uri'] + '/settings'\n response = @client.rest_get(get_uri, {}, @api_version)\n @client.response_handler(response)\n end", "def get_settings\n request :get, \"_settings\"\n end", "def get_settings\n request :get, \"_settings\"\n end", "def get_settings\n get_uri = @data['uri'] + '/settings'\n response = @client.rest_get(get_uri, {}, @api_version)\n @client.response_handler(response)\n end", "def settings\n @settings ||= get('/settings')['settings']\n end", "def get_settings\n return @client.raw(\"get\", \"/config/settings\")\n end", "def settings\n CircleCi.request(conf, \"#{base_path}/settings\").get\n end", "def get_settings\n settings.get\n end", "def get_config()\n return @api.do_request(\"GET\", get_base_api_path() + \"/config\")\n end", "def get_all_settings\n return @db[:settings].as_hash(:name, :body) if onblock(:u, -1, @client).admin?\n end", "def settings\n get('/account/settings.json')\n end", "def build_top_level_setting\n Grape::Util::InheritableSetting.new.tap do |setting|\n # Doesn't try to inherit settings from +Grape::API::Instance+ which also responds to\n # +inheritable_setting+, however, it doesn't contain any user-defined settings.\n # Otherwise, it would lead to an extra instance of +Grape::Util::InheritableSetting+\n # in the chain for every endpoint.\n setting.inherit_from superclass.inheritable_setting if defined?(superclass) && superclass.respond_to?(:inheritable_setting) && superclass != Grape::API::Instance\n end\n end", "def settings\n get \"/setup/api/settings\", password_hash\n end", "def get_settings\n @bridge.get_settings\n end", "def all\n JSON.parse(@client.call('config.get'))\n end", "def get_default_settings\n get_uri = self.class::BASE_URI + '/defaultSettings'\n response = @client.rest_get(get_uri, @api_version)\n @client.response_handler(response)\n end", "def settings\n # TODO\n {}\n end", "def settings\n CircleCi.request(@conf, \"/project/#{username}/#{project}/settings\").get\n end", "def settings\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/account/settings').settings\n end", "def all\n response, status = BeyondApi::Request.get(@session, \"/checkout-settings\")\n\n handle_response(response, status)\n end", "def settings\n @settings ||= {}\n end", "def settings\n @settings ||= {}\n end", "def settings\n @settings ||= {}\n end", "def load_appl_settings\n Configuration::Application::SETTINGS\n end", "def company_settings_load(refresh=false)\n company_settings_info = session[:company_settings]\n\n unless company_settings_info.nil?\n company_settings_current = JSON.parse(company_settings_info)\n if company_settings_current['last_update'].nil? || (DateTime.parse(company_settings_current['last_update']).to_i + 15.minutes.to_i) < DateTime.now.to_i\n refresh = true\n end\n end\n\n if company_settings_info.nil? || refresh\n company_settings = {}\n email = current_user.email\n appKey = APP_CONFIG['api_app_key']\n token = session[:token]\n\n apiFullUrl_authentication = RequestStore.store[:api_url] + '/company/settings/authentication'\n curlRes_authentication = `curl -X GET -H \"Authorization: Token token=\"#{token}\", email=\"#{email}\", app_key=\"#{appKey}\"\" -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" \"#{apiFullUrl_authentication}\"`\n company_authentication = JSON.parse(curlRes_authentication)\n company_settings['authentication'] = company_authentication['company']['settings']['authentication']\n\n apiFullUrl_preferences = RequestStore.store[:api_url] + '/company/settings/preferences'\n curlRes_preferences = `curl -X GET -H \"Authorization: Token token=\"#{token}\", email=\"#{email}\", app_key=\"#{appKey}\"\" -H \"Content-Type: application/json\" -H \"Cache-Control: no-cache\" \"#{apiFullUrl_preferences}\"`\n company_preferences = JSON.parse(curlRes_preferences)\n company_settings['preferences'] = company_preferences['company']['settings']['preferences']\n\n unless company_settings.nil?\n company_settings['last_update'] = DateTime.now\n end\n\n session[:company_settings] = company_settings.to_json\n else\n company_settings = JSON.parse(company_settings_info)\n end\n\n company_settings\n end", "def settings\n {}\n end", "def settings\n {}\n end", "def get_api_defaults\n res = {}\n @api_defaults_proc.call(res)\n res\n end", "def index\n get_settings\n end", "def api_defaults\n @api_defaults ||= self.class.api_defaults\n @api_defaults\n end", "def get_settings(options = {}, request_options = {})\n options['getVersion'] = 2 if !options[:getVersion] && !options['getVersion']\n client.get(Protocol.settings_uri(name, options).to_s, :read, request_options)\n end", "def settings\n {}\n end", "def index\n @api_settings = ApiSetting.all\n end", "def settings\n self.class.settings\n end", "def list_settings_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SettingsApi.list_settings ...'\n end\n # resource path\n local_var_path = '/settings'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'TenantSettings' \n\n # auth_names\n auth_names = opts[:auth_names] || ['BasicAuth']\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: SettingsApi#list_settings\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def settings\n @settings ||= {}\n end", "def all(params = {})\n response, status = BeyondApi::Request.get(@session, \"/order-settings\")\n\n handle_response(response, status)\n end", "def get_settings\n settings = {}\n settings['sharing_scope'] = self.sharing_scope\n settings['access_type'] = self.access_type\n settings['use_custom_sharing'] = self.use_custom_sharing\n settings['use_whitelist'] = self.use_whitelist\n settings['use_blacklist'] = self.use_blacklist\n return settings\n end", "def get_settings_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: Class1InstanceApi.get_settings ...'\n end\n # resource path\n local_var_path = '/settings'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'Settings'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['instanceId', 'token']\n\n new_options = opts.merge(\n :operation => :\"Class1InstanceApi.get_settings\",\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: Class1InstanceApi#get_settings\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def get_routing_settings_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: RoutingApi.get_routing_settings ...\"\n end\n \n # resource path\n local_var_path = \"/api/v2/routing/settings\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\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 => 'RoutingSettings')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RoutingApi#get_routing_settings\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def settings\n @scope.settings\n end", "def query_settings(options={})\n path = \"/api/v2/settings\"\n get(path, options)\n end", "def get_settings(params = {})\n response = client.get \"/_cluster/settings\", params.merge(action: \"cluster.get_settings\", rest_api: \"cluster.get_settings\")\n response.body\n end", "def settings\n {\n name: @client.self.name,\n team: @client.team.name,\n domain: @client.team.domain\n }\n end", "def get_serv_config\n\t\taction = \"configuration\"\n\t\tresponse = call_api(action)\n\tend", "def load_settings\n @settings = Instance::Settings::Effective.new(current_tenant, Course::ControllerComponentHost)\n end", "def settings\r\n @@settings\r\n end", "def auth_settings\n {\n 'apikey' =>\n {\n type: 'api_key',\n in: 'header',\n key: 'api-key',\n value: api_key_with_prefix('api-key')\n },\n 'userid' =>\n {\n type: 'api_key',\n in: 'header',\n key: 'user-uid',\n value: api_key_with_prefix('user-uid')\n },\n }\n end", "def settings\n # JSONSettingDataSource.file_semaphore.synchronize do\n return @settings\n # end\n end", "def load_general_settings\n settings = {}\n sites_to_load.each do |site|\n site_object = eval \"Configuration::#{site.camelize}::SETTINGS\"\n site_settings = {site.to_sym => site_object}\n settings.merge!(site_settings)\n end\n global_object = eval \"Configuration::#{global_name.camelize}::SETTINGS\"\n settings.merge({:global => global_object})\n end", "def auth_settings\n {\n 'api-key' =>\n {\n type: 'api_key',\n in: 'header',\n key: 'api-key',\n value: api_key_with_prefix('api-key')\n },\n }\n end", "def appl_settings\n @appl_settings\n end", "def load_settings\n @leaderboard_settings = component.settings\n end", "def load_settings\n @leaderboard_settings = component.settings\n end", "def settings\n base_configuration.settings + self.class.settings\n end", "def auth_settings\n {\n 'api_key' =>\n {\n type: 'api_key',\n in: 'header',\n key: 'API-Key',\n value: api_key_with_prefix('API-Key')\n },\n }\n end", "def get_client_settings\n cp = ClientPlan.get_client_plan_from_memcache(@client_id)\n pepo_campaign = ClientPepoCampaignDetail.get_from_memcache(@client_id)\n web_host = ClientWebHostDetail.get_from_memcache_by_client_id(@client_id)\n token_sale_detail = ClientTokenSaleDetail.get_from_memcache(@client_id)\n kyc_config_detail = @client.client_kyc_config_detail\n super_admins = Admin.where(default_client_id: @client_id, role: GlobalConstant::Admin.super_admin_role).not_deleted.all\n\n super_admins_data = super_admins.map {|x|\n {\n email: x.email,\n password: SecureRandom.hex,\n name: x.name\n }\n }\n\n @client_setting = {\n client_plan: {\n add_ons: cp.add_ons_array,\n kyc_submissions_count: cp.kyc_submissions_count\n },\n super_admins: super_admins_data,\n double_opt_in: @client.is_verify_page_active_for_client?,\n client_name: @client.name,\n pepo_campaign: {\n api_key: pepo_campaign.api_key,\n api_secret: decrypted_value(pepo_campaign.api_secret)\n },\n token_sale_details: {\n token_name: token_sale_detail.token_name,\n token_symbol: token_sale_detail.token_symbol,\n sale_start_timestamp: token_sale_detail.sale_start_timestamp,\n registration_end_timestamp: token_sale_detail.registration_end_timestamp,\n sale_end_timestamp: token_sale_detail.sale_end_timestamp,\n },\n kyc_config: {\n kyc_fields: kyc_config_detail.kyc_fields_array,\n residency_proof_nationalities: kyc_config_detail.residency_proof_nationalities,\n blacklisted_countries: kyc_config_detail.blacklisted_countries,\n auto_send_kyc_emails: kyc_config_detail.auto_send_kyc_emails_array\n }\n }\n\n if web_host.present?\n @client_setting[:web_host] = {\n domain: web_host.domain\n }\n\n r = SandboxManagement::CmsConfigurator::GetPublishedDraft.new(\n {decoded_token_data: {uuid: @uuid}}).perform\n return r unless r.success?\n\n @client_setting[:entity_type_and_data_hash] = r.data[:entity_type_and_data_hash]\n end\n\n success\n\n end", "def settings\n return @settings\n end", "def settings\n return @settings\n end", "def api_base_url; @opts[:api_base_url]; end", "def current_settings\n Weby::Settings\n end", "def settings\n request(Resources::RESOURCE_SETTINGS, HTTP_METHOD_POST)\n end", "def load_settings\n @settings ||= Instance::Settings::Components.new(current_tenant)\n end", "def auth_settings\n {\n }\n end", "def auth_settings\n {\n }\n end", "def auth_settings\n {\n }\n end", "def get_override_settings\n {}\n end", "def load_settings\n @settings ||= Course::LeaderboardSettings.new(current_course.settings(:leaderboard))\n end", "def settings\n @settings\n end", "def parse_oauth_options\n {\n :request_token_url => full_oauth_url_for(:request_token, :api_host),\n :access_token_url => full_oauth_url_for(:access_token, :api_host),\n :authorize_url => full_oauth_url_for(:authorize, :auth_host),\n :site => @consumer_options[:site] || @consumer_options[:api_host] || DEFAULT_OAUTH_OPTIONS[:api_host]\n }\n end", "def get(base_url, options)\n System::GeneralConfiguration.new(\"#{base_url}/api/system/configuration\", options)\n end", "def auth_settings\n {\n 'Bearer' =>\n {\n type: 'api_key',\n in: 'header',\n key: 'Authorization',\n value: api_key_with_prefix('Authorization')\n },\n 'Educator' =>\n {\n type: 'api_key',\n in: 'query',\n key: 'educator_slug',\n value: api_key_with_prefix('educator_slug')\n },\n }\n end", "def settings\n cmd.settings\n end", "def get_settings(*args)\n SafeIndex.log_or_throw(:get_settings, @raise_on_failure) do\n begin\n @index.get_settings(*args)\n rescue Algolia::AlgoliaError => e\n return {} if e.code == 404 # not fatal\n raise e\n end\n end\n end", "def settings; end", "def settings; end", "def current_client_settings\n client.symbolize_keys.reverse_merge(CLIENT.dup)\n end", "def automatic_request_settings\n return @automatic_request_settings\n end", "def settings\n return @settings if instance_variable_defined?(:@settings)\n\n @settings = Settings.load_for_slice(self)\n end", "def settings\n return {} if description.blank?\n @settings ||= description['settings']\n return {} if @settings.blank?\n @settings.symbolize_keys\n end", "def config\n ModelApi.config\n end", "def settings\n attributes.fetch(:settings)\n end", "def auth_settings\n {\n 'Bearer' =>\n {\n type: 'api_key',\n in: 'header',\n key: 'Authorization',\n value: api_key_with_prefix('Authorization')\n },\n 'Client Credentials' =>\n {\n type: 'oauth2',\n in: 'header',\n key: 'Authorization',\n value: \"Bearer #{access_token}\"\n },\n 'OAuth' =>\n {\n type: 'oauth2',\n in: 'header',\n key: 'Authorization',\n value: \"Bearer #{access_token}\"\n },\n }\n end", "def list_settings\n configure do |settings|\n settings.reject { |_, setting| setting.internal? }.each do |name, setting|\n @env.ui.info \"#{name}\\t#{setting.description}\", bold: true\n @env.ui.info indent(setting.help, 2) unless setting.help.nil?\n value_info = \"Current value: #{setting.value}\"\n value_info += ' (default)' unless setting.set?\n @env.ui.info indent(value_info, 2)\n @env.ui.info ''\n end\n end\n end", "def get_webchat_settings_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: WebChatApi.get_webchat_settings ...\"\n end\n \n # resource path\n local_var_path = \"/api/v2/webchat/settings\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\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 => 'WebChatSettings')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: WebChatApi#get_webchat_settings\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def settings\n @settings ||= self.class.settings.dup\n end", "def settings\n @settings_manager\n end", "def load_settings\n @settings = Course::Settings::Effective.new(current_course, current_component_host)\n end", "def all\n load_clients\n load_preferences\n end", "def config\n requester.config \n end", "def get_dictionary_settings(opts = {})\n @transporter.read(:GET, '/1/dictionaries/*/settings', {}, opts)\n end", "def settings\n end", "def show\n @global_config = AppConfig.where(:section => params[:sect])\n @global_config.each do |conf|\n puts conf.confkey\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @global_config }\n end\n end", "def index\n @api_configs = ApiConfig.all\n end", "def load_settings\n @settings = Setting.all(:order => 'id')\n @settings.each do |setting|\n # set instance variables\n instance_variable_set(\"@#{setting.slug}\", setting.instance_value)\n end\n end", "def settings_list\n setting.list\n end", "def get_global_settings\n json = get_global_settings_json\n pretty_json = JSON.pretty_generate(JSON.parse(json))\n Dir.mkdir(File.expand_path(\"~/.nexus\")) unless Dir.exists?(File.expand_path(\"~/.nexus\"))\n destination = File.join(File.expand_path(\"~/.nexus\"), \"global_settings.json\")\n artifact_file = File.open(destination, 'wb') do |file|\n file.write(pretty_json)\n end\n end", "def auth_settings\n {\n AuthZ:\n {\n type: 'oauth2',\n in: 'header',\n key: 'Authorization',\n value: \"Bearer #{access_token}\"\n },\n apiKeyAuth:\n {\n type: 'api_key',\n in: 'header',\n key: 'DD-API-KEY',\n value: api_key_with_prefix('apiKeyAuth')\n },\n appKeyAuth:\n {\n type: 'api_key',\n in: 'header',\n key: 'DD-APPLICATION-KEY',\n value: api_key_with_prefix('appKeyAuth')\n },\n }\n end", "def get_request_log_settings_with_http_info()\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: DiagnosticsApi.get_request_log_settings ...\"\n end\n # resource path\n local_var_path = \"/v2.1/diagnostics/settings\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'DiagnosticsSettingsInformation')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DiagnosticsApi#get_request_log_settings\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end", "def settings\n\t\tif setting = params[\"settings\"]\n\t\t\tsetting.each do |k,v|\n\t\t\t\tv = v == \"1\" if v == \"1\" or v == \"0\"\n\t\t\t\tlogger.debug \"Setting #{k} to #{v.inspect}\"\n\t\t\t\tSettings[k] = v\n\t\t\tend\n\t\tend\n\t\thead :ok\n\tend" ]
[ "0.71056044", "0.7087893", "0.7087893", "0.7039612", "0.67418766", "0.67215997", "0.666675", "0.6639393", "0.6449629", "0.6420636", "0.6358111", "0.6343898", "0.6293532", "0.6276921", "0.62553173", "0.6214821", "0.6155574", "0.6150323", "0.6084203", "0.60667557", "0.6047745", "0.60418487", "0.60418487", "0.6027969", "0.59901124", "0.5977177", "0.5977177", "0.59766287", "0.5972142", "0.59661543", "0.5952927", "0.5946751", "0.59409016", "0.59385216", "0.59274876", "0.591721", "0.591367", "0.5903056", "0.5895917", "0.5890973", "0.58856016", "0.5873649", "0.58541733", "0.5847093", "0.5838857", "0.5818283", "0.5806896", "0.580402", "0.58036", "0.5790312", "0.57748145", "0.5772131", "0.5766069", "0.5766069", "0.575959", "0.575716", "0.574701", "0.57293916", "0.57293916", "0.57222444", "0.5720328", "0.5718843", "0.57136697", "0.57031024", "0.57031024", "0.57031024", "0.5697043", "0.5693583", "0.5674433", "0.5669826", "0.5662809", "0.5654084", "0.56512135", "0.5646846", "0.5645084", "0.5645084", "0.56428087", "0.5642663", "0.5639645", "0.5620277", "0.56170934", "0.5615704", "0.56140745", "0.56014454", "0.5594762", "0.5572508", "0.5570547", "0.55667555", "0.55628574", "0.55584085", "0.5554906", "0.5535132", "0.5529842", "0.5529173", "0.5523181", "0.5518449", "0.5512614", "0.55068946", "0.5498606", "0.54956037" ]
0.637231
10
Fetch our current inheritable settings, which are inherited by nested scopes but not shared across siblings.
def inheritable_setting @inheritable_setting ||= Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from top_level_setting } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inheritable_settings\n return @inheritable_settings\n end", "def settings\n @scope.settings\n end", "def inheritable_settings=(value)\n @inheritable_settings = value\n end", "def compute_effective_settings\n execution_context.inject({}) { |m,(level, identifier)|\n level_attrs = @settings_hierarchy[level]\n next if level_attrs.nil?\n identifier_attrs = level_attrs[identifier]\n next if identifier_attrs.nil?\n context_settings = identifier_attrs['settings']\n next if context_settings.nil?\n context_settings.each { |key, val|\n m[key] = val\n }\n m\n }\n end", "def settings\n base_configuration.settings + self.class.settings\n end", "def all(include_inherited = true)\n hash = {}\n @association.all.each { |setting| hash[setting.name.to_sym] = setting.value }\n if include_inherited\n proxy = parent\n while proxy\n proxy_hash = proxy.__send__(:all, false)\n hash.reverse_merge! proxy_hash\n proxy = proxy.__send__(:parent)\n end\n end\n hash\n end", "def parental_control_settings\n return @parental_control_settings\n end", "def get_override_settings\n {}\n end", "def build_top_level_setting\n Grape::Util::InheritableSetting.new.tap do |setting|\n # Doesn't try to inherit settings from +Grape::API::Instance+ which also responds to\n # +inheritable_setting+, however, it doesn't contain any user-defined settings.\n # Otherwise, it would lead to an extra instance of +Grape::Util::InheritableSetting+\n # in the chain for every endpoint.\n setting.inherit_from superclass.inheritable_setting if defined?(superclass) && superclass.respond_to?(:inheritable_setting) && superclass != Grape::API::Instance\n end\n end", "def available_settings\n instance.available_settings\n end", "def setting_extra_methods\n belongs_to :account\n def self.get_all_settings(conditions = {})\n $CURRENT_ACCOUNT = nil\n with_exclusive_scope{find(:all, :conditions => conditions)}\n end\n end", "def settings\n self.class.settings\n end", "def current_base\n current = @@policies\n @@scopes.each do |scope|\n next unless scope\n current[scope] = {} unless current[scope]\n current = current[scope]\n end\n current\n end", "def available_settings\n return @@settings_by_type[self.resource_type]\n end", "def settings\n attributes.fetch(:settings)\n end", "def settings\r\n Mutable[self]\r\n end", "def settings\n @settings ||= self.class.settings.dup\n end", "def config\n @_config ||= self.class.config.inheritable_copy\n end", "def value_cache_options\n @value_cache_options ||= if superclass.respond_to?(:value_cache_options)\n my_settings = Settings.new(self)\n my_settings.raw_settings = superclass.value_cache_options.raw_settings.dup\n my_settings\n else\n Settings.new(self)\n end\n end", "def default_config # including inherited defaults \n calling_class = klass = self\n my_defaults = @@default_config[klass.to_s.downcase.to_sym] ||\n HashWithIndifferentAccess.new\n inherited_defaults = HashWithIndifferentAccess.new\n\n until ancestor_class(klass) == NilClass\n ancestor_defaults = @@default_config[ancestor_class(klass).to_s.downcase.to_sym] ||\n HashWithIndifferentAccess.new\n inherited_defaults.merge!(ancestor_defaults)\n klass = ancestor_class(klass)\n end\n inherited_defaults.merge(my_defaults)\n end", "def get_settings\n @bridge.get_settings\n end", "def get_settings\n settings.get\n end", "def get_settings\n settings = {}\n settings['sharing_scope'] = self.sharing_scope\n settings['access_type'] = self.access_type\n settings['use_custom_sharing'] = self.use_custom_sharing\n settings['use_whitelist'] = self.use_whitelist\n settings['use_blacklist'] = self.use_blacklist\n return settings\n end", "def get_all_settings\n return @db[:settings].as_hash(:name, :body) if onblock(:u, -1, @client).admin?\n end", "def instance_ancestors_cache; end", "def settings\r\n @@settings\r\n end", "def enforced_settings\n return @enforced_settings\n end", "def base_and_descendants\n return descendants_base unless Group.supports_nested_groups?\n\n read_only(base_and_descendants_cte.apply_to(model.all))\n end", "def permissable_options; read_inheritable_attribute(:permissable_options); end", "def all\n if current_scope\n current_scope.clone\n else\n default_scoped\n end\n end", "def inherited_contexts\n #ancestors order by lft\n if @inherited_contexts.blank?\n ancestor_context = self.ancestors.where('section_context!=?','').collect{|page_layout| page_layout.section_context }.last\n @inherited_contexts = ( ancestor_context.present? ? ancestor_context.split(',').map(&:to_sym) : [ContextEnum.either] )\n end\n @inherited_contexts\n end", "def permissable_associations; read_inheritable_attribute(:permissable_associations); end", "def value_provider_options\n @value_provider_options ||= if superclass.respond_to?(:value_provider_options)\n my_settings = Settings.new(self)\n my_settings.raw_settings = superclass.value_provider_options.raw_settings.dup\n my_settings\n else\n Settings.new(self)\n end\n end", "def settings\n return @settings\n end", "def settings\n return @settings\n end", "def get_scope(cur_scope = nil)\n # base default scope is set up here so that deactivated module can update this\n cur_scope = StateComponentTypeTax.scoped if (cur_scope.nil?)\n return (defined?(super)) ? super(cur_scope) : cur_scope\n end", "def settings_list\n setting.list\n end", "def get_scope(cur_scope = nil)\n # base default scope is set up here so that deactivated module can update this\n cur_scope = AssemblyComponent.scoped if (cur_scope.nil?)\n return (defined?(super)) ? super(cur_scope) : cur_scope\n end", "def default_includes\r\n read_inheritable_attribute(\"include_by_default\").to_a\r\n end", "def configurations\n return @configurations if @configurations\n \n configurations = CONFIGURATIONS_CLASS.new\n configurations.extend(IndifferentAccess) if @use_indifferent_access\n \n ancestors.reverse.each do |ancestor|\n next unless ancestor.kind_of?(ClassMethods)\n ancestor.config_registry.each_pair do |key, value|\n if value.nil?\n configurations.delete(key)\n else\n configurations[key] = value\n end\n end\n end\n \n configurations\n end", "def settings\n @settings ||= {}\n end", "def settings\n @settings ||= {}\n end", "def update_descendant_settings\n return if changed_setting_attributes.nil? && settings_inheritance == :none\n\n case settings_inheritance\n when :merge\n merge_descendant_settings\n when :override\n override_descendant_settings\n end\n end", "def available_settings\n []\n end", "def included_attributes\n return @base_model.instance_variables\n end", "def one_instance_ancestors_cache; end", "def namespace_start\n @inheritable_setting = Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from inheritable_setting }\n end", "def settings\n CircleCi.request(conf, \"#{base_path}/settings\").get\n end", "def top_level_setting\n @top_level_setting ||= build_top_level_setting\n end", "def settings\n @settings ||= {}\n end", "def scopes\n read_inheritable_attribute(:scopes) || write_inheritable_attribute(:scopes, {})\n end", "def settings\n self.network[self.class]\n end", "def settings\n return @settings if instance_variable_defined?(:@settings)\n\n @settings = Settings.load_for_slice(self)\n end", "def settings\n @cmd.settings\n end", "def settings\n cmd.settings\n end", "def inherited_constants; end", "def singleton_ancestors_cache; end", "def load_settings\n @settings = Instance::Settings::Effective.new(current_tenant, Course::ControllerComponentHost)\n end", "def load_settings\n @settings ||= Instance::Settings::Components.new(current_tenant)\n end", "def settings\n @settings ||= {}\n end", "def base_and_ancestors(upto: nil)\n return ancestors_base unless Group.supports_nested_groups?\n\n read_only(base_and_ancestors_cte(upto).apply_to(model.all))\n end", "def settings\n {}\n end", "def settings\n self.class.settings + View.settings - NON_FORWARDABLE_METHODS\n end", "def settings\n @settings ||= settings_class&.new(self)\n end", "def settings\n # JSONSettingDataSource.file_semaphore.synchronize do\n return @settings\n # end\n end", "def scoped_collection\n super.preload(:gateway, :gateway_group, :routing_group, :routing_tag_mode, :vendor, :account, :statistic,\n :routeset_discriminator, network_prefix: %i[country network])\n end", "def get_default_settings\n return INTERNAL_DEFAULT_SETTINGS.merge @@default_settings if (@@default_settings)\n return INTERNAL_DEFAULT_SETTINGS\n end", "def get_default_settings\n return INTERNAL_DEFAULT_SETTINGS.merge @@default_settings if (@@default_settings)\n return INTERNAL_DEFAULT_SETTINGS\n end", "def parent_nonheritable_keys\n if @parent_configuration.respond_to?(:nonheritable_keys)\n @parent_configuration.nonheritable_keys\n else\n []\n end\n end", "def get_settings\n request :get, \"_settings\"\n end", "def get_settings\n request :get, \"_settings\"\n end", "def settings\n @log.debug \"merging settings\"\n setting_sources = [get_override_settings, load_config, default_settings]\n merged_settings = setting_sources.inject({}) { |merged, hash| merged.deep_merge(hash) }\n @log.debug \"using merged settings: \" + merged_settings.to_s\n @log.debug \"validating merged settings\"\n if validate_settings(merged_settings)\n @log.debug \"successfully validated merged settings\"\n return merged_settings\n else\n @log.warn \"validation of merged settings failed\"\n @log.warn \"unable to validate settings in #{self.name} validator\"\n raise \"settings validation error\"\n end\n end", "def settings\n {\n name: @client.self.name,\n team: @client.team.name,\n domain: @client.team.domain\n }\n end", "def current_client_settings\n client.symbolize_keys.reverse_merge(CLIENT.dup)\n end", "def getSettingsForDash\n\t\tif(!self.customCode)\n\t\t\treturn {}\n\t\telse\n\t\t\tsettings = Hash.new\n\t\t\tcustomSettings.each do |k,v|\n\t\t\t\tsettings[k] = v[:val]\n\t\t\tend\n\n\t\t\treturn settings\n\t\tend\n\tend", "def settings\n # TODO\n {}\n end", "def settings\n @settings_manager\n end", "def one_singleton_ancestors_cache; end", "def settings\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n make_get_call('/account/settings').settings\n end", "def settings\n {}\n end", "def settings\n {}\n end", "def review_settings\n return @review_settings\n end", "def base_scope\n ApplicationRecord.none\n end", "def requestor_settings\n return @requestor_settings\n end", "def ancestor_options(generation_number = 3)\n ensure_ancestor(generation_number) { |ancestor_context| context_hash(ancestor_context)[:options] || {} }\n end", "def settings\n @settings ||= get('/settings')['settings']\n end", "def settings\n @settable.settings(:components)\n end", "def default_settings()\n @default_settings ||= {}\n end", "def settings\n settings_name = self.class.settings_name\n unless settings_name\n raise Exception.new(\"settings_name undefined for #{self.class}\")\n end\n if Settings.instance[settings_name].nil?\n Settings.instance[settings_name] = self.class.default_settings\n end\n return Settings.instance[settings_name]\n end", "def current_settings\n Weby::Settings\n end", "def default_scope\n Configuration::Scope.new(Configuration.new)\n end", "def read_inheritable_attr(key)\n inheritable_attrs[key]\n end", "def theme_settings\n (settings_data ? settings_data['general'].presence : nil) || {}\n end", "def scopes\n self.class.scopes\n end", "def context_overrides()\n {\n :current_environment => environment,\n :global_scope => @topscope, # 4x placeholder for new global scope\n :loaders => @loaders, # 4x loaders\n :rich_data => true,\n }\n end", "def settings\n @settings\n end", "def gather_current_settings\n\t\treturn self.log_hosts_to_affect.each_with_object( {} ) do |host, hash|\n\t\t\thash[ host ] = host.logger.settings\n\t\tend\n\tend", "def descendants\n model_base_class.scoped(:conditions => descendant_conditions)\n end", "def levels_from_parent\n bridge_class.levels_from_parent\n end", "def settings\n\t\traise NotImplementedError\n\tend" ]
[ "0.8205748", "0.67785126", "0.6500825", "0.64961547", "0.6437371", "0.6434576", "0.64129734", "0.63033265", "0.61839736", "0.6166299", "0.6158082", "0.6036863", "0.5952977", "0.590812", "0.58808297", "0.58739185", "0.58702785", "0.58688277", "0.5860874", "0.58515215", "0.5849709", "0.5847998", "0.58285564", "0.5819408", "0.57735723", "0.57468873", "0.5733561", "0.5726905", "0.57144946", "0.57140714", "0.56229526", "0.5612584", "0.5608776", "0.5561202", "0.5561202", "0.5549526", "0.5531735", "0.5524143", "0.55194485", "0.55126524", "0.549957", "0.549957", "0.5488894", "0.5480901", "0.5480826", "0.5474359", "0.54663765", "0.54644716", "0.54402095", "0.54296243", "0.54284835", "0.5428238", "0.54105806", "0.5400313", "0.5397946", "0.5395307", "0.53873956", "0.5362043", "0.53585166", "0.5351231", "0.53464895", "0.5339287", "0.53364754", "0.5328402", "0.53158337", "0.5314992", "0.531449", "0.531408", "0.5294771", "0.52717537", "0.52717537", "0.52711195", "0.5266462", "0.5262408", "0.5255056", "0.52475035", "0.52461845", "0.5232797", "0.52302617", "0.52284384", "0.52284384", "0.52013993", "0.51915306", "0.51817477", "0.5181534", "0.51789445", "0.51745987", "0.5165443", "0.51640296", "0.51622516", "0.5152725", "0.5152565", "0.51522946", "0.51453847", "0.51447886", "0.5139376", "0.51354676", "0.5131735", "0.51293457", "0.51219606" ]
0.7279893
1
Fork our inheritable settings to a new instance, copied from our parent's, but separate so we won't modify it. Every call to this method should have an answering call to namespace_end.
def namespace_start @inheritable_setting = Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from inheritable_setting } end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def initialize_copy( original )\n\t\t@settings = original.settings.dup\n\t\t@overridden_settings = {}\n\tend", "def update_descendant_settings\n return if changed_setting_attributes.nil? && settings_inheritance == :none\n\n case settings_inheritance\n when :merge\n merge_descendant_settings\n when :override\n override_descendant_settings\n end\n end", "def build_top_level_setting\n Grape::Util::InheritableSetting.new.tap do |setting|\n # Doesn't try to inherit settings from +Grape::API::Instance+ which also responds to\n # +inheritable_setting+, however, it doesn't contain any user-defined settings.\n # Otherwise, it would lead to an extra instance of +Grape::Util::InheritableSetting+\n # in the chain for every endpoint.\n setting.inherit_from superclass.inheritable_setting if defined?(superclass) && superclass.respond_to?(:inheritable_setting) && superclass != Grape::API::Instance\n end\n end", "def namespace_inheritance=(_arg0); end", "def namespace_inheritance=(_arg0); end", "def inheritable_setting\n @inheritable_setting ||= Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from top_level_setting }\n end", "def initialize( settings={} )\n\t\tsuper()\n\n\t\t@settings = settings\n\t\t@overridden_settings = {}\n\tend", "def setup\n return Squire::Settings.new unless @source\n\n parser = Squire::Parser.of(@type)\n\n hash = parser.parse(source).with_indifferent_access\n\n if base_namespace\n hash.except(base_namespace).each do |key, values|\n # favours value from namespace over value from defaults\n hash[key] = hash[base_namespace].deep_merge(values) { |_, default, value| value.nil? ? default : value }\n end\n end\n\n Squire::Settings.from_hash(hash)\n end", "def fork instance, attrs = {}\n object_type = instance.class\n\n role_value_map =\n object_type.all_role_transitive.inject({}) do |hash, (role_name, role)|\n next hash if !role.unique\n next hash if role.fact_type.class == ActiveFacts::API::TypeInheritanceFactType\n old_value = instance.send(role.getter)\n if role.counterpart && role.counterpart.unique && old_value != nil\n # It's a one-to-one which is populated. We must not change the counterpart\n if role.mandatory && !attrs.include?(role.name)\n # and cannot just nullify the value\n raise \"#{object_type.basename} cannot be forked unless a replacement value for #{role.name} is provided\"\n end\n value = attrs[role_name]\n else\n value = attrs.include?(role_name) ? attrs[role_name] : instance.send(role.getter)\n end\n hash[role_name] = value if value != nil\n hash\n end\n\n assert(object_type, role_value_map)\n end", "def namespace_end\n route_end\n @inheritable_setting = inheritable_setting.parent\n end", "def dup\n Settings.new(self)\n end", "def freeze\n super\n @ini.each_value(&:freeze)\n @ini.freeze\n self\n end", "def call\n\t\tself.apply_overrides\n\t\tyield\n\tensure\n\t\tself.restore_overridden_settings\n\tend", "def call\n\t\tself.apply_overrides\n\t\tyield\n\tensure\n\t\tself.restore_overridden_settings\n\tend", "def duplicate\n Configuration.new.tap do |c|\n c.namespace = namespace\n c.root = root.dup\n c.modules = modules.dup\n c.delivery_method = delivery_method\n c.default_charset = default_charset\n end\n end", "def initialize_copy( original )\n\t\t@log_hosts = original.log_hosts.dup if original.log_hosts\n\t\t@settings = original.settings.dup\n\t\t@overridden_settings = nil\n\tend", "def clone_with( new_settings, &block )\n\t\tnewobj = self.dup\n\t\tnewobj.settings.merge!( new_settings )\n\n\t\tif block\n\t\t\treturn newobj.call( &block )\n\t\telse\n\t\t\treturn newobj\n\t\tend\n\tend", "def freeze\n super\n @ini.each_value {|h| h.freeze}\n @ini.freeze\n self\n end", "def initialize settings = {}\n @settings = DEFAULT_SETTINGS.merge settings\n @scale = @settings.get :scale\n @rotation = @settings.get :rotation\n @has_solids_manager = !!@settings.get(:has_solids_manager)\n @solids_manager = SolidsManager.new if (has_solids_manager?)\n super @settings #.get.reject { |key,val| next key == :assign_to }\n end", "def settings\n copy = OpenStruct.new\n @lock.synchronize do\n copy.marshal_load(@settings.marshal_dump)\n end\n copy\n end", "def inheritable_settings=(value)\n @inheritable_settings = value\n end", "def inherited( subclass )\n\t\t\tsuper\n\t\t\tsubclass.instance_variable_set( :@session_namespace, @session_namespace )\n\t\tend", "def namespace_inheritance; end", "def namespace_inheritance; end", "def initialize_copy(orig)\n super\n @config = ConfigHash.new(self, orig.config.store.dup, false)\n end", "def clone\n if frozen?\n super\n else\n super.tap do |copy|\n copy.instance_variable_set(:@config, @config.dup)\n end\n end\n end", "def freeze\n root.freeze\n super\n end", "def clone_with( new_settings, &block )\n\t\tnewobj = self.dup\n\t\tnewobj.merge_settings( new_settings )\n\n\t\tif block\n\t\t\treturn newobj.call( &block )\n\t\telse\n\t\t\treturn newobj\n\t\tend\n\tend", "def set_inherit(device)\n device.inherit = true\n owner.save_config\n end", "def dup\n ConfigurationManager.new.tap { |c| c.load_settings(all_settings) }\n end", "def initialize_copy(original)\n @options = original.options.dup\n @connect_lock = Mutex.new\n @monitoring = @cluster ? monitoring : Monitoring.new(options)\n @database = nil\n @read_preference = nil\n @write_concern = nil\n end", "def fork(attributes_overrides={})\n # Always empty out the data in fork nodes. Data will be read from parent node.\n attributes_overrides[:data] = nil\n child = Node.copy(self,attributes_overrides)\n child.is_fork = true\n child.save\n child\n end", "def settings\n base_configuration.settings + self.class.settings\n end", "def parent=(obj); end", "def dup\n other = super\n other.instance_variable_set(:@ini, Hash.new { |h, k| h[k] = {} })\n @ini.each_pair { |s, h| other[s].merge! h }\n other.taint if tainted?\n other\n end", "def dup\n super.tap do |copy|\n copy.instance_variable_set(:@config, @config.dup)\n end\n end", "def parent=(other)\n raise 'Cannot set parent of root namespace' if root?\n @parent = other\n @registry = nil\n end", "def clone\n super\n end", "def settings\n @settings ||= self.class.settings.dup\n end", "def namespace\n # Not using superclass_delegating_reader because don't want subclasses to modify superclass instance\n #\n if defined?(@namespace)\n @namespace\n elsif superclass != Object && superclass.site\n superclass.site.dup.freeze\n end\n end", "def inherited(cls)\n super(cls)\n SETTINGS.each do |type|\n Resource.store_settings(cls, type, [])\n end\n end", "def namespace=(ns); end", "def namespace=(ns); end", "def inheritable_settings\n return @inheritable_settings\n end", "def spawn attributes={}\n child = self.dup\n self.work_groups.each do |wg|\n new_wg = WorkGroup.new(:institution=>wg.institution,:project=>child)\n child.work_groups << new_wg\n wg.group_memberships.each do |gm|\n new_gm = GroupMembership.new(:person=>gm.person, :work_group=>wg)\n new_wg.group_memberships << new_gm\n end\n end\n child.assign_attributes(attributes)\n child.avatar=nil\n child.lineage_ancestor=self\n child\n end", "def default_config # including inherited defaults \n calling_class = klass = self\n my_defaults = @@default_config[klass.to_s.downcase.to_sym] ||\n HashWithIndifferentAccess.new\n inherited_defaults = HashWithIndifferentAccess.new\n\n until ancestor_class(klass) == NilClass\n ancestor_defaults = @@default_config[ancestor_class(klass).to_s.downcase.to_sym] ||\n HashWithIndifferentAccess.new\n inherited_defaults.merge!(ancestor_defaults)\n klass = ancestor_class(klass)\n end\n inherited_defaults.merge(my_defaults)\n end", "def inherited(klass)\n super\n klass.instance_variable_set(:@transforms, transforms.dup)\n klass.instance_variable_set(:@translations_hash, translations_hash.dup)\n end", "def initialize_copy( other )\n\t\tsuper\n\t\tself.apply_applicable_mixins( @dn, @entry )\n\t\tself.after_initialize\n\tend", "def inherited( subclass )\n\t\t\tsuper\n\t\t\tsubclass.instance_variable_set( :@idle_timeout, self.idle_timeout.dup )\n\t\t\tsubclass.instance_variable_set( :@heartbeat_rate, self.heartbeat_rate.dup )\n\t\tend", "def inherited(subclass)\n subclass.namespace self.namespace\n subclass.build_filelist self.build_filelist\n end", "def inherited(subclass)\n super\n subclass.attributes = attributes.dup\n end", "def compact\n\n load_parent_state\n \n return super\n\n end", "def inherit!(inheritance)\n current_target_definition.inheritance = inheritance\n end", "def value_cache_options\n @value_cache_options ||= if superclass.respond_to?(:value_cache_options)\n my_settings = Settings.new(self)\n my_settings.raw_settings = superclass.value_cache_options.raw_settings.dup\n my_settings\n else\n Settings.new(self)\n end\n end", "def dup\n other = super\n other.instance_variable_set(:@ini, Hash.new {|h,k| h[k] = Hash.new})\n @ini.each_pair {|s,h| other[s].merge! h}\n other.taint if self.tainted?\n other\n end", "def parent=(other); end", "def initialize settings\n super\n end", "def clone\n super\n end", "def namespace=(obj); end", "def initialize_child_run\n self.workflow = parent.workflow\n end", "def inherited(subclass)\n super\n sm = serialization_map.dup\n subclass.instance_eval{@serialization_map = sm}\n end", "def initialize_copy(original)\n @command_path = original.command_path.dup\n @parsed_tokens = original.parsed_tokens.dup\n @node = original.node\n end", "def init_default_settings!\n self.class.default_settings.dup.each do |var, vals|\n setting_objects.detect { |s| s.var == var.to_s } || setting_objects.create(var: var.to_s, value: vals, target: self)\n end\n end", "def inherited(base); end", "def child(namespace)\n scope = self.class.new(self)\n\n scope.instance_variable_get(:@value_by_namespace_and_key).send(:[]=, namespace, inflector.convert_hash({}))\n\n scope\n end", "def inherited(subclass)\n super\n nsr = subclass.opts[:namespaced_routes]\n opts[:namespaced_routes].each{|k, v| nsr[k] = v.dup}\n subclass::RodaRequest.instance_variable_set(:@namespaced_route_regexps, {})\n end", "def freeze\n __getobj__.freeze\n super()\n end", "def initialize_copy(original)\n @BasePath = Clone(original.BasePath)\n @RelativePath = Clone(original.RelativePath)\n end", "def inherited( subclass )\n\t\t\tsuper\n\n\t\t\tverbs_copy = Strelka::DataUtilities.deep_copy( self.resource_verbs )\n\t\t\tsubclass.instance_variable_set( :@resource_verbs, verbs_copy )\n\n\t\t\topts_copy = Strelka::DataUtilities.deep_copy( self.service_options )\n\t\t\tsubclass.instance_variable_set( :@service_options, opts_copy )\n\t\tend", "def inherit(device, opts = {})\n sync do\n dev = device.clone\n dev.inherited = true\n do_add(dev)\n end\n end", "def freeze\n freeze_all_instance_variables\n\n super\n end", "def settings(&block)\n @settings ||= setup\n\n settings = instance_variable_defined?(:@namespace) ? @settings.get_value(@namespace) : @settings\n\n if block_given?\n block.arity == 0 ? settings.instance_eval(&block) : block.call(settings)\n end\n\n settings\n end", "def inherited(subclass)\n instance_values.each do |ivar, ival|\n subclass.instance_variable_set(:\"@#{ivar}\", ival.dup)\n end\n end", "def resume_after_fork_in_parent\n super\n end", "def dup\r\n other = super\r\n [:@opts, :@description].each do |var|\r\n d = instance_variable_get(var).dup\r\n other.instance_variable_set(var, d)\r\n end\r\n other\r\n end", "def clone\n rule_base = RuleBase.new(self.name)\n #Clone the facts\n self.facts.each do |entity, properties|\n rule_base.facts[entity] = {}\n properties.each do |property, value|\n rule_base.facts[entity][property] = value.collect {|fact| fact.clone(rule_base)}\n end\n end\n #Clone the rules\n self.rules.each do |rule|\n rule_base.rules << rule.clone(rule_base)\n end\n return rule_base\n end", "def inherited(subclass)\n subclass.instance_variable_set(:@opts, opts.dup)\n subclass.opts.each do |key, value|\n if value.is_a?(Enumerable) && !value.frozen?\n subclass.opts[key] = value.dup\n end\n end\n subclass.instance_variable_set(:@storages, storages.dup)\n\n file_class = Class.new(self::UploadedFile)\n file_class.shrine_class = subclass\n subclass.const_set(:UploadedFile, file_class)\n\n attachment_class = Class.new(self::Attachment)\n attachment_class.shrine_class = subclass\n subclass.const_set(:Attachment, attachment_class)\n\n attacher_class = Class.new(self::Attacher)\n attacher_class.shrine_class = subclass\n subclass.const_set(:Attacher, attacher_class)\n end", "def cloneNode(deep = true)\n super(deep, @name, @pubid, @sysid)\n end", "def inherit( obj )\n case obj\n when Hash\n Thread.current[NAME] = obj.dup\n when Thread\n return if Thread.current == obj\n Thread.exclusive {\n Thread.current[NAME] = obj[NAME].dup if obj[NAME]\n }\n end\n\n self\n end", "def apply_overrides\n\t\tself.synchronize do\n\t\t\traise LocalJumpError, \"can't be called re-entrantly\" unless\n\t\t\t\t@overridden_settings.empty?\n\t\t\t@overridden_settings = self.gather_current_settings\n\t\tend\n\n\t\tLoggability.log_hosts.each do |key, host|\n\t\t\thost.logger.restore_settings( self.settings )\n\t\tend\n\tend", "def initialize( settings={} )\n\t\tsuper()\n\n\t\t@log_hosts = settings.delete( :log_hosts )\n\t\t@settings = settings\n\t\t@overridden_settings = nil\n\tend", "def initialize_copy(orig)\n @enum = orig.instance_variable_get(:@enum)\n super\n end", "def inherited(child)\n super\n child.attribute_definitions = attribute_definitions.dup\n end", "def freeze\n @default_values.freeze\n super\n end", "def superclass=(object); end", "def value_provider_options\n @value_provider_options ||= if superclass.respond_to?(:value_provider_options)\n my_settings = Settings.new(self)\n my_settings.raw_settings = superclass.value_provider_options.raw_settings.dup\n my_settings\n else\n Settings.new(self)\n end\n end", "def parent=(_arg0); end", "def parent=(_arg0); end", "def parent=(_arg0); end", "def parent=(_arg0); end", "def parent=(_arg0); end", "def freeze\n @original_deserialized_values ||= {}\n @original_deserialized_values.freeze\n super\n end", "def initialize(parent); end", "def inherited(klass)\n klass.instance_variable_set(:@associations, associations.clone)\n super\n end", "def inherited(subclass)\n super\n subclass.scopes = scopes.dup\n end", "def add_config_inheritance!\n class_eval do\n def self.inherited(subclass)\n subclass.class_eval do\n class << self\n attr_accessor :sorcery_config\n end\n end\n # Pass parent config to subclass\n subclass.sorcery_config = sorcery_config\n super\n end\n end\n end", "def parent!(parent)\n @parent = parent\n @cache = {}\n self\n end", "def apply_overrides\n\t\tself.synchronize do\n\t\t\traise LocalJumpError, \"can't be called re-entrantly\" if self.overridden_settings\n\t\t\tself.overridden_settings = self.gather_current_settings\n\t\tend\n\n\t\tself.log_hosts_to_affect.each do |host|\n\t\t\thost.logger.restore_settings( self.settings )\n\t\tend\n\tend", "def settings=(_arg0); end", "def settings=(_arg0); end" ]
[ "0.6501519", "0.611109", "0.60726625", "0.5822752", "0.5822752", "0.57910305", "0.57194155", "0.5694648", "0.563503", "0.56314284", "0.56116605", "0.5607835", "0.55847454", "0.55847454", "0.5568596", "0.5560046", "0.55238324", "0.5497667", "0.547759", "0.5459084", "0.5447626", "0.54253596", "0.54045105", "0.54045105", "0.5401504", "0.5396475", "0.5371546", "0.5370469", "0.53563327", "0.53531045", "0.53467554", "0.52840865", "0.5279137", "0.52481157", "0.52443814", "0.52361137", "0.5226499", "0.5220518", "0.5207068", "0.5197553", "0.51952624", "0.5193323", "0.5193323", "0.51844364", "0.518345", "0.5181642", "0.51684165", "0.51673025", "0.5153805", "0.5142797", "0.5108418", "0.5101227", "0.50951385", "0.509407", "0.50926834", "0.50798434", "0.50791216", "0.5077936", "0.5075162", "0.50564265", "0.5043468", "0.5040179", "0.50382495", "0.50346905", "0.5033019", "0.5026869", "0.5009804", "0.50078696", "0.5003278", "0.5001806", "0.4998643", "0.4989652", "0.49862212", "0.497204", "0.49633312", "0.49629098", "0.4956507", "0.4953556", "0.49408004", "0.49386156", "0.4928563", "0.4922967", "0.49210495", "0.49172905", "0.49131718", "0.49108654", "0.49018037", "0.49018037", "0.49018037", "0.49018037", "0.49018037", "0.48816416", "0.48785734", "0.48760882", "0.48757944", "0.48744062", "0.4873749", "0.48648405", "0.4863161", "0.4863161" ]
0.7305435
0
Set the inheritable settings pointer back up by one level.
def namespace_end route_end @inheritable_setting = inheritable_setting.parent end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inheritable_settings=(value)\n @inheritable_settings = value\n end", "def namespace_start\n @inheritable_setting = Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from inheritable_setting }\n end", "def inheritable_setting\n @inheritable_setting ||= Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from top_level_setting }\n end", "def parental_control_settings=(value)\n @parental_control_settings = value\n end", "def update_descendant_settings\n return if changed_setting_attributes.nil? && settings_inheritance == :none\n\n case settings_inheritance\n when :merge\n merge_descendant_settings\n when :override\n override_descendant_settings\n end\n end", "def set_inherit(device)\n device.inherit = true\n owner.save_config\n end", "def build_top_level_setting\n Grape::Util::InheritableSetting.new.tap do |setting|\n # Doesn't try to inherit settings from +Grape::API::Instance+ which also responds to\n # +inheritable_setting+, however, it doesn't contain any user-defined settings.\n # Otherwise, it would lead to an extra instance of +Grape::Util::InheritableSetting+\n # in the chain for every endpoint.\n setting.inherit_from superclass.inheritable_setting if defined?(superclass) && superclass.respond_to?(:inheritable_setting) && superclass != Grape::API::Instance\n end\n end", "def set_setting\n end", "def settings=(_arg0); end", "def settings=(_arg0); end", "def parent=(obj); end", "def inheritable_settings\n return @inheritable_settings\n end", "def initialize( settings={} )\n\t\tsuper()\n\n\t\t@settings = settings\n\t\t@overridden_settings = {}\n\tend", "def parent=(_arg0); end", "def parent=(_arg0); end", "def parent=(_arg0); end", "def parent=(_arg0); end", "def parent=(_arg0); end", "def inherited(cls)\n super(cls)\n SETTINGS.each do |type|\n Resource.store_settings(cls, type, [])\n end\n end", "def setting; end", "def afp_inherit_perms=(inherit)\n @share_edit_args += [ \"-i\", inherit ? \"10\" : \"00\" ]\n end", "def initialize settings\n super\n end", "def initialize settings = {}\n @settings = DEFAULT_SETTINGS.merge settings\n @scale = @settings.get :scale\n @rotation = @settings.get :rotation\n @has_solids_manager = !!@settings.get(:has_solids_manager)\n @solids_manager = SolidsManager.new if (has_solids_manager?)\n super @settings #.get.reject { |key,val| next key == :assign_to }\n end", "def setbase(base)\n\t\t\t@base = base\n\t\tend", "def set_parent(parent)\n @parent = parent\n end", "def superclass=(object); end", "def set_yaml\n if @parent\n @yaml.has_key?(@parent) ? set(defaults.recursive_merge(@yaml[@parent])) : raise(Configarrr::OptionError, \"Please provide a valid parent value. #{@parent} does not exist.\")\n else\n set defaults.recursive_merge(@yaml)\n end\n end", "def set_setting\n ap @setting = Setting.first\n end", "def settings\n base_configuration.settings + self.class.settings\n end", "def initialize_copy( original )\n\t\t@settings = original.settings.dup\n\t\t@overridden_settings = {}\n\tend", "def top_level_setting\n @top_level_setting ||= build_top_level_setting\n end", "def set_inheritance_root\n @is_content_inheritance_root = true\n dataset.row_proc = Spontaneous::Content.dataset.row_proc\n end", "def settings\r\n Mutable[self]\r\n end", "def set_general_settings_value(index, value)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n if value.handle.ptr == nil\n raise \"value is disposed\"\n end\n Native.LayoutEditor_set_general_settings_value(@handle.ptr, index, value.handle.ptr)\n value.handle.ptr = nil\n end", "def parent=(other); end", "def update_inherited_mode(device, mode, changes)\n device.mode = mode\n owner.save_config\n do_apply_changes(changes)\n end", "def set_parent(parent)\n @parent = parent\n end", "def set_parent(parent)\n @parent = parent\n end", "def set_defaults\n super\n self.parent ||= transam_asset.try(:parent)\n self.asset_event_type ||= AssetEventType.find_by_class_name(self.name)\n end", "def settings=(new_settings)\n settings.merge!(new_settings)\n end", "def inherit(alelo)\n @alelo = alelo\n end", "def settings\n @settings ||= self.class.settings.dup\n end", "def child_pre_set_hook( key, object, parent_hash = nil )\n\n return object\n \n end", "def set_settings\r\n @settings[\"deck_name\"] = @curr_deck_key if @curr_deck_key\r\n end", "def setcharexpan(*)\n super\n end", "def set_appearance_set(charset_base)\n @charset_base = charset_base\n update_appearance\n end", "def set_default_settings settings\n default_settings = nil\n if ([String, Pathname].include? settings.class)\n filepath = settings\n filepath = Pathname.new filepath unless (filepath.is_a? Pathname)\n if (filepath.absolute?)\n default_settings = Settings.new filepath\n else\n if (File.file?(filepath))\n default_settings = Settings.new filepath\n else\n default_settings = Settings.new get_root_directory.join(filepath)\n end\n end\n elsif (settings.is_a? Hash)\n default_settings = Settings.new settings\n end\n @@default_settings = default_settings\n end", "def set_default_settings settings\n default_settings = nil\n if ([String, Pathname].include? settings.class)\n filepath = settings\n filepath = Pathname.new filepath unless (filepath.is_a? Pathname)\n if (filepath.absolute?)\n default_settings = Settings.new filepath\n else\n if (File.file?(filepath))\n default_settings = Settings.new filepath\n else\n default_settings = Settings.new get_root_directory.join(filepath)\n end\n end\n elsif (settings.is_a? Hash)\n default_settings = Settings.new settings\n end\n @@default_settings = default_settings\n end", "def settings\n @settings ||= settings_class&.new(self)\n end", "def setting( name, **options, &block )\n\t\tself.log.debug \" adding %s setting to %p\" % [ name, self.target ]\n\t\tself.add_setting_accessors( name, options, &block )\n\t\tself.add_default( name, options )\n\tend", "def set_setting\n @setting = Setting.first\n end", "def call\n setting_item = build_setting_item(name, type, default)\n register_setting setting_item\n define_setting setting_item\n setting_item\n end", "def init_default_settings!\n self.class.default_settings.dup.each do |var, vals|\n setting_objects.detect { |s| s.var == var.to_s } || setting_objects.create(var: var.to_s, value: vals, target: self)\n end\n end", "def set_inherited_privileges!\n rules.each do |resource, rule|\n privileges = privileges(resource)\n privileges.each { |k, v| rule.privileges[k] = v if rule.privileges.key?(k) }\n end\n\n self\n end", "def call\n\t\tself.apply_overrides\n\t\tyield\n\tensure\n\t\tself.restore_overridden_settings\n\tend", "def call\n\t\tself.apply_overrides\n\t\tyield\n\tensure\n\t\tself.restore_overridden_settings\n\tend", "def parental_control_settings\n return @parental_control_settings\n end", "def settings=(value)\n @settings = value\n end", "def settings=(value)\n @settings = value\n end", "def settings\n\t\traise NotImplementedError\n\tend", "def namespace_inheritance=(_arg0); end", "def namespace_inheritance=(_arg0); end", "def inherit!(inheritance)\n current_target_definition.inheritance = inheritance\n end", "def point_base=(new_point_base)\n @point_base = new_point_base\n post_initialize\n @point_base\n end", "def initialize(owner, association, heritage)\n @owner = owner\n @association = @owner.send(association)\n if heritage.is_a? Array\n @parent_object = heritage.first\n @parent_accessor = heritage.second\n else\n @parent_object = heritage\n end\n if @parent_object && @parent_accessor.nil?\n if @parent_object.is_a? Class\n @parent_accessor = HasSettings.config[:global_settings_attribute_name]\n else\n @parent_accessor = HasSettings.config[:settings_attribute_name]\n end\n end\n end", "def settings; end", "def settings; end", "def load_settings\n @leaderboard_settings = component.settings\n end", "def load_settings\n @leaderboard_settings = component.settings\n end", "def enable_settings_override\n Ubiquo::Settings[:ubiquo][:settings_overridable] = true\nend", "def set_resource\n @setting = Setting.first!\n end", "def setCategoryChain()\n @parentCategory = getParentCategory\n \n if (@parentCategory != false)\n @parentCategory.subparent = self\n superParent = @parentCategory.setCategoryChain \n elsif\n superParent = self\n end\n \n return superParent\nend", "def inherit(device, opts = {})\n sync do\n dev = device.clone\n dev.inherited = true\n do_add(dev)\n end\n end", "def initialize settings\n self.settings = settings\n end", "def load_settings\n @settings = Instance::Settings::Effective.new(current_tenant, Course::ControllerComponentHost)\n end", "def set_parent(parent)\n @parent = parent\n\n self\n end", "def promote(device)\n device.inherited = false\n owner.save_config\n end", "def parent_type=(sType)\n super(sType.to_s.classify.constantize.base_class.to_s)\n end", "def load_settings\n @settings = Course::Settings::Effective.new(current_course, current_component_host)\n end", "def setup(&block)\n settings.instance_eval(&block) if block_given?\n end", "def setParent(parent)\n oldParent = @parent\n @parent = parent\n\n if parent.nil?\n # Remove from parent\n onDetach() if oldParent and oldParent.isAttached\n elsif parent.isAttached\n onAttach()\n end\n end", "def update_settings\n setting = company.setting_fallback\n RoomSetting.delete(setting.room_settings)\n setting.send(:create_room_settings)\n end", "def value_provider_options\n @value_provider_options ||= if superclass.respond_to?(:value_provider_options)\n my_settings = Settings.new(self)\n my_settings.raw_settings = superclass.value_provider_options.raw_settings.dup\n my_settings\n else\n Settings.new(self)\n end\n end", "def __parent_hash=(hash)\n @__parent_hash = hash\n end", "def superclass=(other)\n @superclass = other\n end", "def superclass=(other)\n @superclass = other\n end", "def set_defaultsettings\n AppSettings.item.to_hash.each do |setting, value|\n s = RailsSettings::Settings.new \n s.var = setting.to_s\n s.value = value[:default]\n s.thing_id = self.id\n s.thing_type = \"Group\" \n s.save\n end\n end", "def parent!(parent)\n @parent = parent\n @cache = {}\n self\n end", "def parent=(parent)\n @parent = parent\n end", "def parent=(parent)\n @parent = parent\n end", "def parent=(parent_node); end", "def parent=(parent_node); end", "def set_config_value!(config_parent, key, value)\n #find the configuration\n configuration = config_parent.configurations.find_by(class_name: self.class.to_s, key: key)\n if !configuration.nil?\n configuration.create_or_update_config(self, value)\n end\n end", "def default_settings=(hash)\n @default_settings = hash\n end", "def level=( level )\n super(level || 0)\n end", "def set_user_settings\n @settings = Setting.includes(:features).find_or_create_by(provider: @user_domain)\n end", "def set_defaults\n super\n end", "def set_defaults\n super\n end", "def settings\n @settings ||= DriverSettings.new(@bridge)\n end", "def owner_class=(klass); end", "def use_shadow_info=(setting)\n end" ]
[ "0.68554926", "0.65363944", "0.64698386", "0.63258374", "0.6272368", "0.62422377", "0.5891196", "0.5800336", "0.5769383", "0.5769383", "0.5766804", "0.5653603", "0.55423373", "0.53751326", "0.53751326", "0.53751326", "0.53751326", "0.53751326", "0.5360351", "0.5326902", "0.53055394", "0.5302796", "0.53017586", "0.529454", "0.52817625", "0.5277448", "0.5267671", "0.5264862", "0.5244229", "0.52404386", "0.5226646", "0.5211387", "0.52082473", "0.51824015", "0.51669484", "0.5122107", "0.5103145", "0.5103145", "0.51020026", "0.51009566", "0.5095043", "0.5090014", "0.5086552", "0.5085198", "0.5078262", "0.50663257", "0.50647074", "0.50647074", "0.50620323", "0.5060493", "0.505737", "0.50450724", "0.5039905", "0.5038641", "0.5038413", "0.5038413", "0.5035812", "0.5033981", "0.5033981", "0.5021176", "0.5013194", "0.5013194", "0.50114554", "0.49979433", "0.49955028", "0.4988737", "0.4988737", "0.49815777", "0.49815777", "0.49810478", "0.4973644", "0.49700302", "0.496931", "0.49569744", "0.49544114", "0.4932358", "0.4922971", "0.49156213", "0.49105582", "0.4904158", "0.49035066", "0.48982626", "0.48972836", "0.4892998", "0.4887596", "0.4887596", "0.48797694", "0.48725173", "0.4859134", "0.4859134", "0.48586854", "0.48586854", "0.4849374", "0.48407862", "0.48399964", "0.4838733", "0.48381022", "0.48381022", "0.48372418", "0.48370448", "0.48356888" ]
0.0
-1
Stop defining settings for the current route and clear them for the next, within a namespace.
def route_end inheritable_setting.route_end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def reset!\n ATTRIBUTES.each {|attr| send(\"#{attr.to_s}=\", nil)}\n routes.clear\n end", "def reset\n @routes.clear\n end", "def reset!\n @root = Root.new(self)\n @request_methods_specified = Set.new\n @routes = []\n @named_routes = {}\n @variable_names = Set.new\n end", "def reset!\n reset_endpoints!\n reset_routes!\n reset_validations!\n end", "def reset!\n @routes = []\n @current = 0\n @prepared = nil\n end", "def reset!\n @route_map = {}\n end", "def clear!\n defined_settings.each {|setting| instance_variable_set(\"@#{setting}\", nil)}\n @storage_adapters = []\n @cached_paths = {}\n end", "def reset\n [:@sitemap_url, :@models, :@delay, :@environments, :@ping_urls, :@background, :@notified_urls].each do |var|\n remove_instance_variable var if instance_variable_defined?(var)\n end\n end", "def reset_routes!\n router.reset!\n default_routes!\n end", "def clear_routes\n @routes = Hash.new { |h, k| h[k] = Set.new }\n end", "def reset!\n @routes = []\n @current_order = 0\n @prepared = nil\n end", "def reset_settings\n Thread.current[:shoppe_settings] = nil\n end", "def reset\n @config = nil\n end", "def reset\n (@settings||{}).each do |name,instance| \n remove_setter(name)\n remove_getter(name)\n remove_boolean_getter(name)\n instance.destroy\n end\n @settings = Hash.new\n end", "def namespace_end\n route_end\n @inheritable_setting = inheritable_setting.parent\n end", "def reset!\n @root = Node::Root.new(self, request_methods)\n @named_routes = {}\n @routes = []\n @grapher = Grapher.new(self)\n @priority_lookups = false\n end", "def reset!\n remove_instance_variable \"@service_definitions\" if defined? @service_definitions\n remove_instance_variable \"@services_config_list\" if defined? @services_config_list\n end", "def reset\n configure({})\n end", "def reset_conf(&block)\n reset_conf_sub\n yield\n\n # reset again to go back to default setting later. Otherwise,\n # above setting is kept later.\n reset_conf_sub\n end", "def reset!\n @root = class_for_root.new(self, request_methods)\n @named_routes = {}\n @routes = []\n @grapher = Grapher.new(self)\n @priority_lookups = false\n @parser = Util::Parser.new(self, valid_regex)\n end", "def reset!\n @setting_objects = @setting_templates.map { |k, _| [k, []] }.to_h\n @settings.values.each(&:reset!)\n end", "def reset\n @@config_instance = nil\n end", "def reset\n self.configuration = ({})\n config_contexts.values.each(&:reset)\n end", "def reset\n @config = nil\n @client = nil\n end", "def reset!\n class << self\n alias_method :match, :match_before_compilation\n end\n self.routes, self.named_routes, self.resource_routes = [], {}, {}\n end", "def clear\n namespace + '_clear'\n end", "def reset_routes(routes=[])\n request :put, '/routes', routes\n end", "def reset\n @protocols = {}\n @servers = {}\n @routes = {}\n @subscribers = {}\n @agents = {}\n @channels = {}\n end", "def reset_configuration\n @configuration = nil\n end", "def reset\n reset_adapters\n reset_config\n reset_handlers\n reset_hooks\n end", "def reset!\n class << self\n alias_method :match, :match_before_compilation\n end\n self.routes, self.named_routes = [], {}\n end", "def tcfg_reset\n @tcfg_resolved_config = nil\n end", "def reset\n @lookup_paths = {} # (Hash.new)\n @tree = Rack::App::Router::Tree.new\n compile_registered_endpoints!\n end", "def clear\n self.configuration = {}\n end", "def reset! # :nodoc:\n @params = nil\n @request = nil\n @headers = nil\n end", "def reset!\n @apps = {}\n @default_params = {}\n @basic_auth = nil\n end", "def reset\n [topics, queues, subscriptions].each do |resource|\n resource.values.each(&:delete)\n resource.clear\n end\n end", "def reset\n @config = empty_config\n end", "def reset\n @params = nil\n @logger = nil\n end", "def reset(namespace)\n @store.keys([namespace].to_yaml + '*').each do |key|\n @store.del(key)\n end\n end", "def reset()\n @api.do_request(\"DELETE\", get_base_api_path())\n end", "def flush_routes\n _init\n\n # Remove each of the individual routes so the comms don't think they're\n # still routing after a flush.\n self.routes.each { |r|\n if r.comm.respond_to? :routes\n r.comm.routes.delete(\"#{r.subnet}/#{r.netmask}\")\n end\n }\n # Re-initialize to an empty array\n self.routes = Array.new\n end", "def reset_routing_cache\n\t\t\t\t@inheritance.each {|sub| sub.reset_routing_cache} if @inheritance\n\t\t\tend", "def cmd_clear_routes argv\n setup argv\n response = @api.clear_routes\n msg response\n return response\n end", "def clear!\n @handlers = {}\n @environments = {}\n @requests = []\n end", "def clear\n reset_defaults\n self\n end", "def reset_config\n config.reset_to_defaults\n end", "def reset!\n self.instance_variables.each { |variable| instance_variable_set(variable, nil) }\n self\n end", "def reset\n Configuration.new\n end", "def reset\n cleanup(true)\n end", "def reset(scope = :all)\n configuration.reset(scope)\n end", "def reset(options={})\n options = {\n :clear => true\n }.merge(options)\n\n registry.each do |option|\n if option.respond_to?(:reset)\n option.reset\n end\n end\n\n config.clear if options[:clear]\n self\n end", "def clear!\n Padrino.clear_middleware!\n Padrino.mounted_apps.clear\n @_load_paths = nil\n @_dependency_paths = nil\n @_global_configuration = nil\n Padrino.before_load.clear\n Padrino.after_load.clear\n Padrino::Reloader.clear!\n Thread.current[:padrino_loaded] = nil\n end", "def fuel_settings_with_renew\n @fuel_settings = nil\n fuel_settings\n end", "def clear\n self.request = nil\n end", "def clear\n @mutex.synchronize do\n raise ConfigurationLockedError if @locked\n @patterns.clear\n @types.clear\n @categories.clear\n @methods.clear\n end\n self\n end", "def reset!\n default_tags.clear\n adapters.clear\n groups.each_key { |group| singleton_class.send(:remove_method, group) if group && respond_to?(group) }\n @groups = nil\n metrics.each_key { |metric| singleton_class.send(:remove_method, metric) if respond_to?(metric) }\n @metrics = nil\n collectors.clear\n configurators.clear\n instance_variable_set(:@configured_by, nil)\n instance_variable_set(:@debug_was_enabled_by, nil)\n end", "def reset!\n configure do |c|\n DEFAULTS.each { |k, v| c.send(\"#{k}=\", v) }\n end\n end", "def reset!\n @orm = @namespace = @source = @setting_class = nil\n self.config = nil\n self.raise_missing = nil\n self.report_missing = nil\n self.typecast_on_write = nil\n self.password_secret = nil\n end", "def reset!\n self.api_key = nil\n self.host = nil\n self.request_headers = nil\n self.version = nil\n self.retry_max_count = nil\n self.retry_wait_seconds = nil\n self.return_response = nil\n self.logger = nil\n @settings = nil\n end", "def clearNamespaces() \n @obj.clearNamespaces()\n end", "def reset\n VALID_CONFIG_OPTIONS.each { |opt| self.send(\"#{opt}=\", nil) }\n self.logger = nil\n end", "def reset_mappings\n yield self if block_given?\n http.post('/__admin/mappings/reset', '')\n end", "def reset_config\n\t\t\t@config = {}\n\t\tend", "def reset_config!\n @log = nil\n @logger = nil\n @log_level = nil\n end", "def reset_config!\n @log = nil\n @logger = nil\n @log_level = nil\n end", "def reset\n @current_recording = nil\n @configuration = nil\n end", "def reset\n @current_recording = nil\n @configuration = nil\n end", "def reset!\n CodesWholesale::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", CodesWholesale::Default.options[key])\n end\n self\n end", "def stop_path\n # force_move_route(EMPTY_MOVE_ROUTE)\n clear_path\n Pathfinding.remove_request(self)\n end", "def unset_settings(names)\n configure do |settings|\n names.each { |name| settings.unset!(name) }\n end\n end", "def reset\n @config = {}\n write_config\n end", "def reset\n @context = nil\n end", "def reset\n @config = Config.new\n end", "def reset!\n Whitehouse::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", Whitehouse::Default.options[key])\n end\n self\n end", "def reset!\n instance_variables.each { |var| remove_instance_variable var }\n end", "def reset\n # self.instance_variable_names.each do |var_name|\n # self.instance_variable_set var_name, nil\n # end\n instance_variables.each { |name, value|\n instance_variable_set(name, nil)\n }\n end", "def clear_scoping\n selector.clear\n options.clear\n end", "def reset\n self.options = nil\n self.option_processors = nil\n end", "def reset\n self.configuration = Configuration.new\n end", "def reset!\n tap { set_defaults }\n end", "def clear_request\n @url = nil\n @options = nil\n end", "def resetValues\n @@multinode = nil\n @@serverList = nil\n @@proxy = nil\n @@serviceList = {}\n end", "def reset\n NETWORKS_KEYS.each do |network_key|\n network = {}\n DEFAULT_SETTINGS_KEYS.each do |key|\n network[key] = \"SharingCounter::Configuration::#{default(key)}\".constantize\n end\n INDIVIDUAL_SETTINGS_KEYS.each do |key|\n network[key] = \"SharingCounter::API::#{network_key.to_s.capitalize }::#{ default(key) }\".constantize\n end\n send \"#{network_key}=\", network\n end\n end", "def reset\n VALID_CONFIG_OPTIONS.each { |opt| self.reset_attribute(opt) }\n end", "def reset\n @params = {}\n @query_filters = []\n @uri = ''\n self\n end", "def delete_all\n super\n Rails.cache.delete_matched(/#{self.configure.cache.namespace}/)\n end", "def reset\n self.namespace = DEFAULT_NAMESPACE\n self.filters = DEFAULT_FILTERS\n self.use_sandbox = USE_SANDBOX_MODE\n self.use_test_wsdl = USE_TEST_WSDL_COPY\n self.strip_namespaces = true\n self.pretty_print_xml = true\n\n # We default to using the local, production copy of the WSDL\n self.wsdl = \"spec/fixtures/wsdl/voip_production_wsdl.asmx\"\n\n # Add more directives here\n end", "def reset\n self.time = Time.now\n if config[\"time\"]\n self.time = Bridgetown::Utils.parse_date(\n config[\"time\"].to_s, \"Invalid time in bridgetown.config.yml.\"\n )\n end\n self.layouts = HashWithDotAccess::Hash.new\n self.pages = []\n self.static_files = []\n self.data = HashWithDotAccess::Hash.new\n @post_attr_hash = {}\n @collections = nil\n @documents = nil\n @docs_to_write = nil\n @regenerator.clear_cache\n @liquid_renderer.reset\n frontmatter_defaults.reset\n\n raise ArgumentError, \"limit_posts must be a non-negative number\" if limit_posts.negative?\n\n Bridgetown::Cache.clear_if_config_changed config\n Bridgetown::Hooks.trigger :site, :after_reset, self\n end", "def reset\n self.send(\"endpoint=\", DEFAULTS[:endpoint])\n end", "def reset!\n @config = Configuration.new\n end", "def reset!\n Unleashed::Configurable.keys.each do |key|\n instance_variable_set(:\"@#{key}\", Unleashed::Default.options[key])\n end\n\n self\n end", "def reset!\n self.configuration = Configuration.new\n end", "def reset\n VALID_OPTIONS_KEYS.each{|k| send(\"#{k}=\", nil)}\n self.endpoint = DEFAULT_ENDPOINT\n self.proxy = DEFAULT_PROXY\n self.api_version = DEFAULT_API_VERSION\n self\n end", "def reset\n @debug_indent = 0\n @uri_to_term_or_curie = {}\n @uri_to_prefix = {}\n @references = Hash.new{|h,k| h[k] = 0}\n @prefixes = {}\n @serialized = {}\n @subjects = {}\n @ordered_subjects = []\n @titles = {}\n @doc_title = \"\"\n end", "def reset!\n self.api_key \t = DEFAULT_API_KEY\n self.adapter = DEFAULT_ADAPTER\n self.endpoint = DEFAULT_ENDPOINT\n self.user_agent = DEFAULT_USER_AGENT\n self\n end", "def clear_page_settings\n shaz_nolock_clear_page_settings\n @nolock = false\n end", "def clear_middleware!\n @middleware = []\n end", "def clear_properties\n Config::Collection.clear\n end", "def reset\n set Exchange::Configuration::DEFAULTS[key]\n end", "def reset\n self.instance_variables.each do |var|\n instance_variable_set(var, nil)\n end\n initialize\n end" ]
[ "0.73625636", "0.68651235", "0.63947785", "0.6388679", "0.6387845", "0.63765323", "0.6315466", "0.6292918", "0.62262845", "0.6219216", "0.6209891", "0.6151193", "0.6113523", "0.6109841", "0.6081563", "0.6061381", "0.6055719", "0.6049361", "0.60243446", "0.6005195", "0.60019296", "0.5958067", "0.5951897", "0.5913073", "0.59093255", "0.58854055", "0.5834267", "0.5819091", "0.5783597", "0.57693", "0.5763407", "0.57282007", "0.5721655", "0.5712482", "0.57098246", "0.5693977", "0.5683611", "0.56801975", "0.56764597", "0.56730247", "0.56651974", "0.5658237", "0.56462646", "0.5622013", "0.5618899", "0.5609622", "0.56083065", "0.5600854", "0.5600301", "0.559907", "0.5595816", "0.558702", "0.55867636", "0.558561", "0.55837655", "0.5581831", "0.5581221", "0.5575617", "0.5571564", "0.5567238", "0.5566058", "0.5565391", "0.55593467", "0.5553968", "0.5551214", "0.5551214", "0.5550201", "0.5550201", "0.55488443", "0.55402815", "0.5537509", "0.55344373", "0.55299556", "0.5515722", "0.550919", "0.55087805", "0.5508464", "0.550421", "0.54843396", "0.5478109", "0.5477956", "0.546785", "0.5466318", "0.54367495", "0.5429189", "0.5427275", "0.5422783", "0.542115", "0.54205805", "0.5420498", "0.5418261", "0.54127204", "0.54076415", "0.5406595", "0.5401534", "0.5399914", "0.5399769", "0.5395582", "0.53946304", "0.5393762", "0.53917956" ]
0.0
-1
Execute the block within a context where our inheritable settings are forked to a new copy (see namespace_start).
def within_namespace(&block) namespace_start result = yield if block namespace_end reset_validations! result end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def namespace_start\n @inheritable_setting = Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from inheritable_setting }\n end", "def call\n\t\tself.apply_overrides\n\t\tyield\n\tensure\n\t\tself.restore_overridden_settings\n\tend", "def call\n\t\tself.apply_overrides\n\t\tyield\n\tensure\n\t\tself.restore_overridden_settings\n\tend", "def run_in_context(o={}, &block)\n proc = Proc.new do\n set_vars_from_options(:name => o[:name]) if o.has_key?(:name) # Name MUST be set first\n set_vars_from_options(o)\n instance_eval &block if block\n end\n super(&proc)\n end", "def resume_after_fork_in_parent\n super\n end", "def when_inherited(&block)\n @cautious_inherited_block = block\n end", "def take_while( & block )\n \n load_parent_state\n \n return super\n\n end", "def pause_before_fork_in_parent\n super\n end", "def fork\n forking\n yield\n forked\n end", "def initialize_child_run\n self.workflow = parent.workflow\n end", "def config(&block)\n instance_exec(&block)\n end", "def alter(&block)\n dup.tap { |o| o.instance_eval(&block) }\n end", "def configure &block\n\t\tinstance_eval &block\n\tend", "def inherit(_, context = {})\n throw context[:abort] if context[:pallet][context[:key]]\n end", "def configure(&block); end", "def configure(&block); end", "def select( & block )\n\n load_parent_state\n \n return super\n\n end", "def parent &block\n unless @_iv.context\n raise 'Host scope is not available'\n end\n\n if block\n @_iv.context.instance_exec(&block)\n else\n @_iv.context\n end\n end", "def update_descendant_settings\n return if changed_setting_attributes.nil? && settings_inheritance == :none\n\n case settings_inheritance\n when :merge\n merge_descendant_settings\n when :override\n override_descendant_settings\n end\n end", "def clone_with( new_settings, &block )\n\t\tnewobj = self.dup\n\t\tnewobj.settings.merge!( new_settings )\n\n\t\tif block\n\t\t\treturn newobj.call( &block )\n\t\telse\n\t\t\treturn newobj\n\t\tend\n\tend", "def collect( & block )\n \n load_parent_state\n \n return super\n\n end", "def setup(&block)\n settings.instance_eval(&block) if block_given?\n end", "def with_options(options = {}, &block)\n return unless block\n backup_options = @stkw_config[:base_opt]\n @stkw_config[:base_opt] = @stkw_config[:base_opt].merge(options)\n begin\n instance_eval &block\n ensure\n @stkw_config[:base_opt] = backup_options\n end\n end", "def clone_with( new_settings, &block )\n\t\tnewobj = self.dup\n\t\tnewobj.merge_settings( new_settings )\n\n\t\tif block\n\t\t\treturn newobj.call( &block )\n\t\telse\n\t\t\treturn newobj\n\t\tend\n\tend", "def before_fork(&block); end", "def block(block)\n @components[:__base__] = self.class.build(&block)\n @load_order << :__base__\n true\n end", "def after_fork(&block)\n end", "def exec\n super\n end", "def configure(&block)\n instance_eval(&block)\n end", "def configure(&block)\n instance_eval(&block)\n end", "def configure &blk\n instance_eval &blk\n end", "def run_in_new_process\n fork do # rubocop:todo Style/ExplicitBlockArgument\n yield\n end\nend", "def exec_in_staging(nested, &block)\n cmd = ExecCmd.new(self.staging, nested, &block)\n cmd.actor = self.actor\n cmd.perform\n end", "def fork(&block)\n Kernel.fork(&block)\n end", "def in_environment(&block)\n initialize_settings\n\n Puppet::Pal.in_tmp_environment(\"choria\", :modulepath => @modulepath, :facts => facts, &block)\n end", "def call(*args, &block)\n sp = clone\n sp.sproc_args = args\n sp.run(&block)\n end", "def work(&block)\n Celluloid::Logger.info \"Preparing work...\"\n self.working_code = block if block_given?\n end", "def fork instance, attrs = {}\n object_type = instance.class\n\n role_value_map =\n object_type.all_role_transitive.inject({}) do |hash, (role_name, role)|\n next hash if !role.unique\n next hash if role.fact_type.class == ActiveFacts::API::TypeInheritanceFactType\n old_value = instance.send(role.getter)\n if role.counterpart && role.counterpart.unique && old_value != nil\n # It's a one-to-one which is populated. We must not change the counterpart\n if role.mandatory && !attrs.include?(role.name)\n # and cannot just nullify the value\n raise \"#{object_type.basename} cannot be forked unless a replacement value for #{role.name} is provided\"\n end\n value = attrs[role_name]\n else\n value = attrs.include?(role_name) ? attrs[role_name] : instance.send(role.getter)\n end\n hash[role_name] = value if value != nil\n hash\n end\n\n assert(object_type, role_value_map)\n end", "def configure(&block)\n self.instance_eval(&block)\n end", "def global_expand\n DrawExt::Merio.snapshot do\n snapshot do\n DrawExt::Merio.copy_settings(self)\n yield self\n end\n end\n end", "def __execute(&block)\n self.instance_eval(&block)\n end", "def alter(&blk)\n dup.tap { |o| o.instance_eval(&blk) }\n end", "def run_stored_block\n self.run_in_context @stored_block if @stored_block\n end", "def before_fork\n \n end", "def before_fork(&block)\r\n @before_fork = block\r\n end", "def configure_with_block(&block)\n self.instance_eval(&block) if block_given?\n end", "def configure_with_block(&block)\n self.instance_eval(&block) if block_given?\n end", "def initialize_copy( original )\n\t\t@settings = original.settings.dup\n\t\t@overridden_settings = {}\n\tend", "def inside_cookbook(&block)\n cookbook_path = File.join(Strainer.sandbox_path.to_s, @cookbook.cookbook_name)\n Strainer.ui.debug \"Changing working directory to '#{cookbook_path}'\"\n original_pwd = ENV['PWD']\n\n ENV['PWD'] = cookbook_path\n success = Dir.chdir(cookbook_path, &block)\n ENV['PWD'] = original_pwd\n\n Strainer.ui.debug \"Restoring working directory to '#{original_pwd}'\"\n success\n end", "def prepare_for_configuration \n # clear_base_directory\n make_base_directory\n copy_misc_templates\n copy_custom_monitors\n store_keys_in_file\n Script.save!(self)\n # not my favorite...\n copy_ssh_key\n before_configuration_tasks\n end", "def apply_start_block_option_overrides(options)\n @requested_args.each { |option_name, option_value| options.update(option_name, option_value, add_missing: false) }\n end", "def configure(&block)\n cfg = self.class::CONFIGURATOR.new(self)\n block.call(cfg)\n # allow configuration tuning for derived recipes\n post_configure\n end", "def target_init_ac(ac)\n # Set parent scope of AddressContainer outer Block to GLOBAL scope\n ac.block.scope.parent = scope\n end", "def block(block)\n @components[:__base__] = block\n @load_order << :__base__\n true\n end", "def set_inherit(device)\n device.inherit = true\n owner.save_config\n end", "def block_node=(_); end", "def configure\n yield flags if block_given?\n end", "def initialize(&block)\n @required_options = []\n instance_exec &block\n end", "def forking\n call_hooks :before, :fork\n end", "def forking\n call_hooks :before, :fork\n end", "def base_recipe()\n warn \"#{self} hasn't been overridden to return a Proc!!\"\n lambda {\n # put your capistrano config and tasks in here\n }\n end", "def context(&block); end", "def context(&block); end", "def cxx_configuration(&block)\n @myblock = block\n @all_blocks = []\n end", "def run()\n super() \n @@run_env[@name] = @value \n end", "def configure(&block)\n self.instance_eval(&block) if block_given?\n end", "def build(&block)\n # provide access to 'this' in configuration block\n self.instance_exec(&block)\n end", "def configure(&blk)\n instance_eval &blk\n end", "def settings(&block)\n @settings ||= setup\n\n settings = instance_variable_defined?(:@namespace) ? @settings.get_value(@namespace) : @settings\n\n if block_given?\n block.arity == 0 ? settings.instance_eval(&block) : block.call(settings)\n end\n\n settings\n end", "def fork(attributes_overrides={})\n # Always empty out the data in fork nodes. Data will be read from parent node.\n attributes_overrides[:data] = nil\n child = Node.copy(self,attributes_overrides)\n child.is_fork = true\n child.save\n child\n end", "def _new_setting_object_method(config_key, &block)\n new_config = @setting_templates[config_key].clone_and_reset\n new_config.instance_eval(&block)\n @setting_objects[config_key] << new_config\n end", "def with_tenant(tenant, &block)\n Multitenant.current_tenant = tenant\n Multitenant.in_block = true\n save_and_change_default_scope_for_all\n yield\n ensure\n restore_default_scope\n Multitenant.in_block = false\n Multitenant.current_tenant = nil\n end", "def apply_to!(&block)\n raise ArgumentError, \"Seccomp::Filter#apply_block!: block required\" unless block_given?\n\n pid = Process.fork do\n apply!\n yield self\n end\n\n pid, status = Process.wait2(pid)\n if status.signaled? && Signal.signame(status.termsig) == \"SYS\"\n raise Error, \"Subprocess called unauthorized syscall (see dmesg for details)\"\n end\n\n self\n end", "def run(config_id)\n super.run config_id\n end", "def settings(&block)\n if block\n @settings_block = block\n elsif @settings_block\n @settings = Settings::DSL.new(identifier, &@settings_block).call\n else\n @settings\n end\n end", "def initialize(settings={}, &block)\n @format = nil\n @autopath = nil\n @chdir = nil\n @files = []\n @tags = []\n @match = []\n @units = []\n @requires = []\n @loadpath = []\n\n #apply_environment\n\n apply(settings)\n\n # save for lazy execution\n @block = block\n end", "def parentloop; end", "def configure(&block)\n yield(self)\n end", "def configure(&block)\n yield(self)\n end", "def configure(args={}, &block)\n save_state\n configure_with_args args\n configure_with_block &block if block_given?\n self\n end", "def configure(args={}, &block)\n save_state\n configure_with_args args\n configure_with_block &block if block_given?\n self\n end", "def cxx_configuration(&block)\n @all_blocks = []\n block.call\n end", "def run(context, options = {})\n #@block.call(options)\n\n if @options[:defaults]\n options = @options[:defaults].merge(options)\n end\n\n context.instance_exec(options, &@block)\n end", "def compact\n\n load_parent_state\n \n return super\n\n end", "def config(&blk)\n scope &blk\n self\n end", "def forked\n call_hooks :after, :fork\n end", "def forked\n call_hooks :after, :fork\n end", "def override() # Note that despite the module.override, this still overrides\r\n puts \"CHILD override()\"\r\n end", "def before_fork\n yield @resqued\n end", "def preconfigure(&block)\n @preconfigure ||= block\n end", "def extends(parent, options)\n attributes(options)\n @block = Proc.new { build parent => attributes }\n end", "def parent_command; end", "def from_block\n options = new\n dsl = ExecutionOptionsDSL.new(options)\n yield dsl\n options\n end", "def configure\n yield settings\n end", "def on_child_start(&block)\n raise \"block required\" unless block_given?\n @on_child_start_blk = block\n end", "def configure(&block)\n default_values!\n yield self\n end", "def apply_vcr(&block)\n verify_define_event!\n\n fixtures, options = @fixtures, @options.clone_options\n\n if block_given?\n fixtures = adjust_fixtures(options, &block)\n end\n\n fixtures_manager = Fixtures::Manager.inject(\n fixtures, options\n )\n\n @event_action.call\n\n Waiter.wait(\n @node,\n fixtures_manager,\n options\n )\n end", "def construct( &block )\n self.instance_eval(&block)\n @options\n end", "def context\n @_context ||= {\n :argv => START_CTX[:argv].map { |arg| arg.dup },\n :cwd => START_CTX[:cwd].dup,\n 0 => START_CTX[0].dup,\n }.tap do |ctx|\n rewrite_context(ctx)\n end\n end", "def across_pool_state\n super\n end", "def chain_state\n super\n end" ]
[ "0.6312879", "0.62218815", "0.62218815", "0.59767395", "0.586216", "0.5690287", "0.5593462", "0.55868745", "0.5499361", "0.5481921", "0.54791725", "0.54714525", "0.5461349", "0.5431632", "0.54289937", "0.54289937", "0.5412068", "0.54108393", "0.5407315", "0.53949064", "0.5372004", "0.5371405", "0.5335921", "0.5303156", "0.5271153", "0.52602595", "0.5257337", "0.52545094", "0.5244783", "0.5244783", "0.5217023", "0.52161777", "0.5214892", "0.5198949", "0.5198939", "0.51793367", "0.517241", "0.5162533", "0.516158", "0.51595473", "0.515434", "0.5145086", "0.5143395", "0.51401305", "0.51379746", "0.51276195", "0.51276195", "0.51260966", "0.5117789", "0.50988936", "0.50986886", "0.50949615", "0.5094083", "0.50845724", "0.50826937", "0.5078822", "0.5078497", "0.50733835", "0.5072744", "0.5072744", "0.50700396", "0.50518954", "0.50518954", "0.50491333", "0.5015371", "0.50143516", "0.5010007", "0.50010115", "0.49946517", "0.49937373", "0.49914262", "0.4986674", "0.49794364", "0.4978379", "0.49737063", "0.497041", "0.49670437", "0.49625576", "0.49625576", "0.4960117", "0.4960117", "0.49567568", "0.49464548", "0.4941676", "0.49329025", "0.49236548", "0.49236548", "0.49217772", "0.49107322", "0.49034402", "0.489641", "0.4895752", "0.48957124", "0.4887816", "0.4884522", "0.4880269", "0.4879898", "0.4876554", "0.4874602", "0.48734045", "0.4872664" ]
0.0
-1
Builds the current class :inheritable_setting. If available, it inherits from the superclass's :inheritable_setting.
def build_top_level_setting Grape::Util::InheritableSetting.new.tap do |setting| # Doesn't try to inherit settings from +Grape::API::Instance+ which also responds to # +inheritable_setting+, however, it doesn't contain any user-defined settings. # Otherwise, it would lead to an extra instance of +Grape::Util::InheritableSetting+ # in the chain for every endpoint. setting.inherit_from superclass.inheritable_setting if defined?(superclass) && superclass.respond_to?(:inheritable_setting) && superclass != Grape::API::Instance end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def inheritable_setting\n @inheritable_setting ||= Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from top_level_setting }\n end", "def inheritable_settings\n return @inheritable_settings\n end", "def inheritable_settings=(value)\n @inheritable_settings = value\n end", "def namespace_start\n @inheritable_setting = Grape::Util::InheritableSetting.new.tap { |new_settings| new_settings.inherit_from inheritable_setting }\n end", "def config\n @_config ||= self.class.config.inheritable_copy\n end", "def default_config # including inherited defaults \n calling_class = klass = self\n my_defaults = @@default_config[klass.to_s.downcase.to_sym] ||\n HashWithIndifferentAccess.new\n inherited_defaults = HashWithIndifferentAccess.new\n\n until ancestor_class(klass) == NilClass\n ancestor_defaults = @@default_config[ancestor_class(klass).to_s.downcase.to_sym] ||\n HashWithIndifferentAccess.new\n inherited_defaults.merge!(ancestor_defaults)\n klass = ancestor_class(klass)\n end\n inherited_defaults.merge(my_defaults)\n end", "def settings\n base_configuration.settings + self.class.settings\n end", "def value_provider_options\n @value_provider_options ||= if superclass.respond_to?(:value_provider_options)\n my_settings = Settings.new(self)\n my_settings.raw_settings = superclass.value_provider_options.raw_settings.dup\n my_settings\n else\n Settings.new(self)\n end\n end", "def base\n _base = base_inheritable\n _base = configuration[:base] if _base.nil? and configuration\n _base ||= base_inheritable(true)\n [prefix, _base].find_all do |component|\n component and !component.empty?\n end.join(\",\")\n end", "def inherited_with_inheritable_attributes(child)\n inherited_without_inheritable_attributes(child) if respond_to?(:inherited_without_inheritable_attributes)\n \n new_inheritable_attributes = {}\n inheritable_attributes.each do |key, value|\n new_inheritable_attributes[key] = value.dup rescue value\n end\n \n child.instance_variable_set('@inheritable_attributes', new_inheritable_attributes)\n end", "def add_config_inheritance!\n class_eval do\n def self.inherited(subclass)\n subclass.class_eval do\n class << self\n attr_accessor :sorcery_config\n end\n end\n # Pass parent config to subclass\n subclass.sorcery_config = sorcery_config\n super\n end\n end\n end", "def value_cache_options\n @value_cache_options ||= if superclass.respond_to?(:value_cache_options)\n my_settings = Settings.new(self)\n my_settings.raw_settings = superclass.value_cache_options.raw_settings.dup\n my_settings\n else\n Settings.new(self)\n end\n end", "def read_inheritable_attr(key)\n inheritable_attrs[key]\n end", "def config\n Setting[klass_name]\n end", "def write_inheritable_attr(key, value)\n inheritable_attrs[key] = value\n end", "def inherited_constants; end", "def base_class!\n @base_class = self\n end", "def inherited(base)\n Base.inherited(base)\n end", "def inherited(subclass)\n [:resource_ivar_name, :nested_resource_ivar_name].each do |inheritable_attribute|\n instance_var = \"@#{inheritable_attribute}\"\n subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))\n end\n end", "def inherited(subclass)\n @inheritable_attributes.each do |inheritable_attribute|\n instance_var = \"@#{inheritable_attribute}\"\n subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))\n end\n end", "def permissable_options; read_inheritable_attribute(:permissable_options); end", "def child_record_property_builder\n ManifestBuilder::ChildRecordPropertyBuilder\n end", "def inherited(base) #:nodoc:\n base.class_eval do\n class << self\n attr_reader *ATTR_READERS\n end\n end\n\n ATTR_READERS.each do |attr|\n current_value = self.instance_variable_get(\"@#{attr}\")\n base.instance_variable_set(\"@#{attr}\", current_value ? current_value.dup : [])\n end\n end", "def make_base_env(klass)\n TypeEnv::BaseTypeEnv.new(klass)\n end", "def initialize_setting\n unless new_record?\n if cached_setting.nil?\n create_setting\n if self.class.respond_to?(:object_caches_suffix)\n clear_cache! caches_suffix_list= [], object_caches_suffix=[\"setting\"]\n end\n end\n parameterize_name = setting_options[:name].downcase.parameterize.underscore\n setting_options[:options].except(:validations).keys.each do |opt_key|\n send(\"#{parameterize_name}_#{opt_key}=\", cached_setting.get_setting_of(opt_key))\n end\n end\n end", "def update_descendant_settings\n return if changed_setting_attributes.nil? && settings_inheritance == :none\n\n case settings_inheritance\n when :merge\n merge_descendant_settings\n when :override\n override_descendant_settings\n end\n end", "def inherited_hash(name)\n class_eval <<RUBY, __FILE__, __LINE__ + 1\n def #{name}(name)\n _#{name}(name.gsub('_', '-'))\n end\n\n def _#{name}(name)\n @#{name}s[name] || @parent && @parent._#{name}(name)\n end\n protected :_#{name}\n\n def set_#{name}(name, value)\n name = name.gsub('_', '-')\n @#{name}s[name] = value unless try_set_#{name}(name, value)\n end\n\n def try_set_#{name}(name, value)\n if @#{name}s.include?(name)\n @#{name}s[name] = value\n true\n elsif @parent\n @parent.try_set_#{name}(name, value)\n else\n false\n end\n end\n protected :try_set_#{name}\n\n def set_local_#{name}(name, value)\n @#{name}s[name.gsub('_', '-')] = value\n end\nRUBY\n end", "def builder_method\n config[:child_builder]\n end", "def inherited(base)\n klasses << base\n end", "def inherited(base)\n base.send :create_dynamic_classes\n super\n end", "def inherited(subclass)\n super\n ivs = subclass.instance_variables.map(&:to_s)\n inherited_instance_variables.each do |iv, dup|\n next if ivs.include?(iv.to_s)\n if (sup_class_value = instance_variable_get(iv)) && dup\n sup_class_value = case dup\n when :dup\n sup_class_value.dup\n when :hash_dup\n h = {}\n sup_class_value.each{|k,v| h[k] = v.dup}\n h\n when Proc\n dup.call(sup_class_value)\n else\n raise Error, \"bad inherited instance variable type: #{dup.inspect}\"\n end\n end\n subclass.instance_variable_set(iv, sup_class_value)\n end\n\n unless ivs.include?(\"@dataset\")\n if @dataset && self != Model\n subclass.set_dataset(@dataset.clone, :inherited=>true)\n elsif (n = subclass.name) && !n.to_s.empty?\n db\n subclass.set_dataset(subclass.implicit_table_name)\n end\n end\n end", "def get_override_settings\n {}\n end", "def inheritable?\n @inherit\n end", "def inherited(subclass)\n super\n ivs = subclass.instance_variables\n inherited_instance_variables.each do |iv, dup|\n next if ivs.include?(iv)\n if (sup_class_value = instance_variable_get(iv)) && dup\n sup_class_value = case dup\n when :dup\n sup_class_value.dup\n when :hash_dup\n h = {}\n sup_class_value.each{|k,v| h[k] = v.dup}\n h\n when Proc\n dup.call(sup_class_value)\n else\n raise Error, \"bad inherited instance variable type: #{dup.inspect}\"\n end\n end\n subclass.instance_variable_set(iv, sup_class_value)\n end\n\n unless ivs.include?(\"@dataset\")\n if @dataset && self != Model\n subclass.set_dataset(@dataset.clone, :inherited=>true)\n elsif (n = subclass.name) && !n.to_s.empty?\n db\n subclass.set_dataset(subclass.implicit_table_name)\n end\n end\n end", "def top_level_setting\n @top_level_setting ||= build_top_level_setting\n end", "def make_builder_settings(extra_settings = {})\n opts = super\n opts[:auto_inventory_attributes] = false\n opts\n end", "def base_class\n @base_class ||= self.class.basename(path,'.yml').classify.constantize\n end", "def included(base)\n install_configure_in(base)\n base.instance_eval do\n extend ClassMethods\n\n # call configuration_mutex once to initialize the value\n #\n initialize_configuration!\n end\n end", "def included(base)\n install_configure_in(base)\n base.instance_eval do\n extend ClassMethods\n\n # call configuration_mutex once to initialize the value\n #\n initialize_configuration!\n end\n end", "def inherit_stuff\n return unless accepted_genus\n\n self.classification ||= accepted_genus.classification\n self.lifeform ||= accepted_genus.lifeform\n end", "def set_inherit(device)\n device.inherit = true\n owner.save_config\n end", "def inheritable?\n @klass.columns_hash.has_key?( inheritance_column )\n end", "def inherited(child)\n super\n child.attribute_names = self.attribute_names ? self.attribute_names.dup : [:id]\n child.reverse_solr_name_cache = self.reverse_solr_name_cache ? self.reverse_solr_name_cache.dup : {}\n child.attribute_cache = self.attribute_cache ? self.attribute_cache.dup : {}\n child.facets = self.facets ? self.facets.dup : []\n child.solr_calc_attributes = self.solr_calc_attributes.present? ? self.solr_calc_attributes.dup : {}\n # child.derived_af_class\n\n # If there's no class between +LockedLdpObject+ and this child that's\n # already had +visibility+ and +owner+ defined, define them.\n child.class_eval do\n unless attribute_names.include?(:visibility)\n has_attribute :visibility, ::VOCABULARY[:jupiter_core].visibility, solrize_for: [:exact_match, :facet]\n end\n unless attribute_names.include?(:owner)\n has_attribute :owner, ::VOCABULARY[:jupiter_core].owner, solrize_for: [:exact_match]\n end\n unless attribute_names.include?(:record_created_at)\n has_attribute :record_created_at, ::VOCABULARY[:jupiter_core].record_created_at, type: :date,\n solrize_for: [:sort]\n end\n end\n end", "def inheritance_field\n options[:inheritance_field] || :type\n end", "def base_model\n raise ConfigurationError.new(\"Base model not defined for '#{self.class.name}'\")\n end", "def inherited(cls)\n super(cls)\n SETTINGS.each do |type|\n Resource.store_settings(cls, type, [])\n end\n end", "def inherited(child_class)\n HasFields.add_default_resolve_module(child_class)\n super\n end", "def save_inherited_fields\n inherited_fields.each do |name|\n fields[name] = parent.provide(name)\n end\n\n self\n end", "def include_configuration_type!(base)\n return if base.ancestors.include?(configuration_type)\n\n base.send :include, configuration_type\n end", "def include_configuration_type!(base)\n return if base.ancestors.include?(configuration_type)\n\n base.send :include, configuration_type\n end", "def initialize(owner, association, heritage)\n @owner = owner\n @association = @owner.send(association)\n if heritage.is_a? Array\n @parent_object = heritage.first\n @parent_accessor = heritage.second\n else\n @parent_object = heritage\n end\n if @parent_object && @parent_accessor.nil?\n if @parent_object.is_a? Class\n @parent_accessor = HasSettings.config[:global_settings_attribute_name]\n else\n @parent_accessor = HasSettings.config[:settings_attribute_name]\n end\n end\n end", "def initialize(parent_configuration = nil)\n @parent_configuration = parent_configuration || ActiveSupport::HashWithIndifferentAccess.new\n @storage = ActiveSupport::HashWithIndifferentAccess.new\n\n #\n # Nonheritable keys are a bit peculiar: they make the lookup for a key\n # specified as nonheritable to return no result when it falls back to\n # the parent configuration.\n #\n # These keys themselves are inheritable; in this way, a class that\n # descends from another will keep the same behaviour as its superclass\n # without necessarily having the same data. Or to put it another way,\n # if you have specified that 'title' is not inheritable in a\n # superclass's configuration, that is a property of that class, and\n # descendent classes should behave the same way.\n #\n # It is also unlikely that subclasses will modify the list of\n # nonheritable keys.\n parent_nh_keys = parent_configuration &&\n parent_configuration.nonheritable_keys\n @nonheritable_keys = InheritableAppendSet.new(parent_nh_keys)\n end", "def build_supplement(config_base, config_more)\n # merge in our post-build additions to base configuration hash\n config_base.deep_merge!( config_more )\n\n # flatten our addition hash\n config_more_flattened = @configurator_builder.flattenify( config_more )\n\n # merge our flattened hash with built hash from previous build\n @project_config_hash.deep_merge!( config_more_flattened )\n store_config()\n\n # create more constants and accessors\n @configurator_setup.build_constants_and_accessors(config_more_flattened, binding())\n\n # recreate constants & update accessors with new merged, base values\n config_more.keys.each do |key|\n hash = { key => config_base[key] }\n @configurator_setup.build_constants_and_accessors(hash, binding())\n end\n end", "def settings_class\n @settings_class ||= \"Course::Settings::#{name.demodulize}\".safe_constantize\n end", "def inherited(subclass)\n @inheritable_attribute_list.each do |attribute|\n instance_var = \"@#{attribute}\"\n subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))\n end\n end", "def genPiledDefaultConf(klass = self.class())\n if(klass == WithConfParam) then\n return klass::DefaultConf.dup() ;\n else\n newConf = genPiledDefaultConf(klass.superclass()) ;\n if(klass.const_defined?(:DefaultConf)) \n newConf.update(klass::DefaultConf) ;\n end\n \n return newConf ;\n end\n end", "def construct_data\n add_properties(@adv_settings, :if_missing)\n super\n end", "def parental_control_settings\n return @parental_control_settings\n end", "def setting_class\n @setting_class ||= case orm\n when :activerecord\n require 'settler/orm/activerecord/setting'\n Settler::ORM::Activerecord::Setting\n else\n require 'settler/orm/ruby/setting'\n Settler::ORM::Ruby::Setting\n end\n end", "def child_constants_cache; end", "def inheritance_column\n @inheritance_column ||= @klass.inheritance_column.to_s\n end", "def inherit? key\n ! ! (data(key, INHERIT) && data(key, DEFAULT))\n end", "def base\n return @config[\"base\"]\n end", "def inherited(subclass)\n instance_variables.grep(/^@\\w+_group_accessor$/) do |v|\n subclass.instance_variable_set(v, instance_variable_get(v).clone)\n end\n super\n end", "def inherited(subclass)\n [:steps, :failed_steps].each do |inheritable_attribute|\n instance_var = \"@#{inheritable_attribute}\"\n subclass.instance_variable_set(instance_var, instance_variable_get(instance_var).dup || [])\n end\n end", "def derived_attributes\n @derive_attribute ||= {}\n end", "def settings\n @settings ||= settings_class&.new(self)\n end", "def ensure_setting\n self.setting ||= Setting.build_default(self)\n end", "def default_build_settings(key: nil, optional: true)\n options[:scheme] ||= schemes.first if is_workspace\n build_settings(key: key, optional: optional)\n end", "def base; @options[:base]; end", "def attr_redactor_options\n @attr_redactor_options ||= superclass.attr_redactor_options.dup\n end", "def parental_control_settings=(value)\n @parental_control_settings = value\n end", "def setting_for(key)\n ensure_config_loaded!\n setting_class.find_by_key(key.to_s)\n end", "def init_default_settings!\n self.class.default_settings.dup.each do |var, vals|\n setting_objects.detect { |s| s.var == var.to_s } || setting_objects.create(var: var.to_s, value: vals, target: self)\n end\n end", "def settings(*args)\n @memoized_settings ||= @options[:settings] || __get_class_value(:settings) || (super && @settings)\n end", "def subclass_from_attrs(attrs)\n active_authorizer[:default].deny?(inheritance_column) ? nil : super\n end", "def initialize( settings={} )\n\t\tsuper()\n\n\t\t@settings = settings\n\t\t@overridden_settings = {}\n\tend", "def base=(value)\n @base = value\n valid_base?\n return @base\n end", "def parent_nonheritable_keys\n if @parent_configuration.respond_to?(:nonheritable_keys)\n @parent_configuration.nonheritable_keys\n else\n []\n end\n end", "def inherited(subclass)\n raise BudaError, \"Cannot subclass a frozen Buda class\" if frozen?\n super\n subclass.instance_variable_set(:@inherit_middleware, @inherit_middleware)\n subclass.instance_variable_set(:@middleware, @inherit_middleware ? @middleware.dup : [])\n subclass.instance_variable_set(:@opts, opts.dup)\n subclass.opts.to_a.each do |k,v|\n if (v.is_a?(Array) || v.is_a?(Hash)) && !v.frozen?\n subclass.opts[k] = v.dup\n end\n end\n subclass.instance_variable_set(:@route_block, @route_block)\n subclass.send(:build_rack_app)\n \n # request_class = Class.new(self::BudaRequest)\n # request_class.buda_class = subclass\n # request_class.match_pattern_cache = BudaCache.new\n # subclass.const_set(:BudaRequest, request_class)\n #\n # response_class = Class.new(self::BudaResponse)\n # response_class.buda_class = subclass\n # subclass.const_set(:BudaResponse, response_class)\n end", "def default_chart_attributes(attrs={})\n return @chart_attributes if attrs.empty?\n # if superclass.respond_to? :chart_attributes \n # keys = attrs.keys + (superclass.chart_attributes || [])\n # else\n # keys = attrs.keys\n # end\n \n # chart attributes method\n meta_def :chart_attributes do \n if superclass.respond_to? :chart_attributes\n # if we have attrs in the super class, union them with this\n attrs.keys | (superclass.chart_attributes || [])\n else\n attrs.keys\n end\n end\n \n # accessors for the attributes/keys\n attrs.keys.each do |sym|\n module_eval(<<-EVAL, __FILE__, __LINE__)\n def #{sym}; @#{sym}; end\n \n def #{sym}=(value)\n @#{sym} = value\n end\n EVAL\n end\n \n # set the defaults\n class_eval do\n define_method :initialize do |*options|\n super rescue super() # call to super\n # set instance variables for the attributes\n attrs.each do |k,v|\n # FIXME: we call dup here, which means that we have one extra class instance defined for every call. Ugh.\n v = v.dup unless %w(NilClass Fixnum TrueClass FalseClass Float).include? v.class.name \n instance_variable_set( \"@#{k}\", v )\n end\n # Provides a way to pass a hash of values to the initialize method\n # of a class and have any keys that are attributes of that class\n # sent to the class with the corresponding value.\n #\n # example = SomeClass.new(:name => 'Buckaroo', :girlfriend => 'Penny Priddy')\n # Would set example.name = 'Buckaroo' and example.girlfriend = 'Penny Priddy'\n #\n # Skips any keys that aren't attributes of the class.\n # Provides an options attribute to retrieve the passed in hash \n opts = options.first || Hash.new\n opts.each do |k,v| \n # use send rather than instance_variable so we can get aliased methods/attributes\n self.send(\"#{k.to_sym}=\",v) if self.respond_to? k.to_sym\n # instance_variable_set( \"@#{k}\", v ) \n end \n end\n # method to return a hash of attributes and values\n define_method :chart_attribute_values do\n self.class.chart_attributes.inject({}) do |values, name|\n values[name.to_s] = instance_variable_get(\"@#{name}\")\n values\n end \n end\n end\n \n end", "def hiera_classifier_settings(certname, settings)\n duplicates = []\n overrides_hiera, overrides_classifier = hiera_classifier_overrides(certname, settings)\n Puppet.debug(\"Settings from Hiera for: #{certname}: #{overrides_hiera}\")\n Puppet.debug(\"Settings from Classifier for: #{certname}: #{overrides_classifier}\")\n overrides = overrides_hiera\n overrides_classifier.each do |classifier_k, classifier_v|\n next unless settings.include?(classifier_k)\n if overrides.key?(classifier_k)\n duplicates.push(\"#{classifier_k} ... Hiera: #{overrides_hiera[classifier_k]} ... Classifier: #{classifier_v} \")\n end\n # Classifer settings take precedence over Hiera settings.\n # Hiera settings include pe.conf.\n overrides[classifier_k] = classifier_v\n end\n return { 'params' => overrides, 'duplicates' => duplicates }\n rescue Puppet::Error\n return nil\n end", "def build_class\n return klass if klass\n\n included_attrs = attributes.reject do |_name, opts|\n opts && opts[:exclude]\n end\n builder&.call(included_attrs.map(&:first))\n end", "def inherited(subclass)\n subclass.instance_variable_set(:@opts, opts.dup)\n subclass.opts.each do |key, value|\n if value.is_a?(Enumerable) && !value.frozen?\n subclass.opts[key] = value.dup\n end\n end\n subclass.instance_variable_set(:@storages, storages.dup)\n\n file_class = Class.new(self::UploadedFile)\n file_class.shrine_class = subclass\n subclass.const_set(:UploadedFile, file_class)\n\n attachment_class = Class.new(self::Attachment)\n attachment_class.shrine_class = subclass\n subclass.const_set(:Attachment, attachment_class)\n\n attacher_class = Class.new(self::Attacher)\n attacher_class.shrine_class = subclass\n subclass.const_set(:Attacher, attacher_class)\n end", "def inherited(base); end", "def configurations\n return @configurations if @configurations\n \n configurations = CONFIGURATIONS_CLASS.new\n configurations.extend(IndifferentAccess) if @use_indifferent_access\n \n ancestors.reverse.each do |ancestor|\n next unless ancestor.kind_of?(ClassMethods)\n ancestor.config_registry.each_pair do |key, value|\n if value.nil?\n configurations.delete(key)\n else\n configurations[key] = value\n end\n end\n end\n \n configurations\n end", "def compute_effective_settings\n execution_context.inject({}) { |m,(level, identifier)|\n level_attrs = @settings_hierarchy[level]\n next if level_attrs.nil?\n identifier_attrs = level_attrs[identifier]\n next if identifier_attrs.nil?\n context_settings = identifier_attrs['settings']\n next if context_settings.nil?\n context_settings.each { |key, val|\n m[key] = val\n }\n m\n }\n end", "def base_package\n base = {\n 'Packaging' => {\n 'Code' => PACKAGING_TYPES[@model.packaging_type]\n },\n 'PackageWeight' => {\n 'UnitOfMeasurement' => {\n 'Code' => WEIGHT_UNITS[@model.weight_units]\n },\n 'Weight' => @model.weight,\n :order! => ['UnitOfMeasurement', 'Weight']\n },\n 'PackageServiceOptions' => {}\n }\n\n if @model.insured_value\n base['PackageServiceOptions']['InsuredValue'] = {\n 'CurrencyCode' => 'USD',\n 'MonetaryValue' => @model.insured_value\n }\n end\n\n if @model.declared_value\n base['PackageServiceOptions']['DeclaredValue'] = {\n 'CurrencyCode' => 'USD',\n 'MonetaryValue' => @model.declared_value\n }\n end\n\n base\n end", "def inherited(subclass)\n super\n subclass.acts_as_cacheable_cache = acts_as_cacheable_cache\n subclass.acts_as_cacheable_time_to_live = acts_as_cacheable_time_to_live\n subclass.acts_as_cacheable_logger = acts_as_cacheable_logger\n end", "def base_path\n raise NotImplementedError, \"Subclass #{self.class.name} of Configuration must implement base_path\"\n end", "def set_default_attrs\n self.state = 'Texas' if self.respond_to? :state\n self.origin = 'hunted' if self.respond_to? :origin\n self.gender = 'male' if self.respond_to? :gender\n if self.respond_to? :parts\n parts = Part::NAMES.map { |part_name| {name: part_name} }\n parts << { other: true }\n self.parts = parts\n end\n if self.respond_to? :taxidermy_parts\n taxidermy_parts = self.class::DEFAULT_TAXIDERMY_PARTS.map { |part_name| {name: part_name} }\n taxidermy_parts << { other: true }\n self.taxidermy_parts = taxidermy_parts\n end\n self\n end", "def add_standard_properties\n super\n\n @config_manager.add_override_property('run.config_name', self.class.basename)\n end", "def all(include_inherited = true)\n hash = {}\n @association.all.each { |setting| hash[setting.name.to_sym] = setting.value }\n if include_inherited\n proxy = parent\n while proxy\n proxy_hash = proxy.__send__(:all, false)\n hash.reverse_merge! proxy_hash\n proxy = proxy.__send__(:parent)\n end\n end\n hash\n end", "def create_config_base\n # Create keys directory for environment\n FileUtils.cd(self.project_root) { FileUtils.mkdir_p \"config/environments/#{self.name}\" }\n FileUtils.cd(\"#{project_root}/config/environments/#{self.name}\") { FileUtils.mkdir_p %w{steps keys} }\n # Create ssh key for puppet user if environment is vagrant\n generate_puppet_user_keys('vagrant') if self.name == 'vagrant'\n end", "def subclass_from_attributes(attrs)\n active_authorizer[:default].deny?(inheritance_column) ? nil : super\n end", "def inherit(device, opts = {})\n sync do\n dev = device.clone\n dev.inherited = true\n do_add(dev)\n end\n end", "def inherit!(inheritance)\n current_target_definition.inheritance = inheritance\n end", "def override_department_setting_for_cops(base_hash, derived_hash); end", "def inherited_instance_variables\n {\n :@cache_anonymous_models=>nil,\n :@dataset_method_modules=>:dup,\n :@dataset_module_class=>nil,\n :@db=>nil,\n :@default_set_fields_options=>:dup,\n :@fast_instance_delete_sql=>nil,\n :@fast_pk_lookup_sql=>nil,\n :@plugins=>:dup,\n :@primary_key=>nil,\n :@raise_on_save_failure=>nil,\n :@raise_on_typecast_failure=>nil,\n :@require_modification=>nil,\n :@require_valid_table=>nil,\n :@restrict_primary_key=>nil,\n :@setter_methods=>nil,\n :@simple_pk=>nil,\n :@simple_table=>nil,\n :@strict_param_setting=>nil,\n :@typecast_empty_string_to_nil=>nil,\n :@typecast_on_assignment=>nil,\n :@use_transactions=>nil\n }\n end", "def options_with_subtype(subtype_classes)\n return @options if @subtype.nil? || subtype.nil?\n\n @options.merge({ class: subtype_classes[@subtype] })\n end" ]
[ "0.7957203", "0.7130535", "0.6866926", "0.62060326", "0.60595685", "0.5905518", "0.57345766", "0.56353176", "0.562738", "0.55533844", "0.554984", "0.5530771", "0.5474511", "0.5354502", "0.5298053", "0.519122", "0.51908803", "0.5186303", "0.5158098", "0.5152635", "0.5135044", "0.5133313", "0.51264495", "0.5116991", "0.511479", "0.50726", "0.506964", "0.5065681", "0.50574213", "0.50452685", "0.50370103", "0.50304604", "0.5026279", "0.50222576", "0.50201946", "0.5016719", "0.50043565", "0.4998454", "0.4998454", "0.49980298", "0.49887687", "0.49501505", "0.49476454", "0.49299735", "0.49234352", "0.49220517", "0.491797", "0.49068296", "0.4904621", "0.4904621", "0.48940274", "0.48680052", "0.48640358", "0.486117", "0.48604423", "0.4860115", "0.48335314", "0.4818252", "0.48142174", "0.48050857", "0.47951138", "0.47882435", "0.47871137", "0.4778069", "0.47650108", "0.47404712", "0.47313747", "0.4728588", "0.47251642", "0.4715862", "0.47152767", "0.47144893", "0.4713166", "0.4702392", "0.4699847", "0.46909752", "0.46802792", "0.46775386", "0.46716222", "0.4670116", "0.46690673", "0.46663356", "0.46598023", "0.46510488", "0.4650274", "0.4637278", "0.46227694", "0.46153313", "0.4614637", "0.46091607", "0.460886", "0.4599084", "0.4594412", "0.45809197", "0.45776892", "0.45772767", "0.4575992", "0.45752543", "0.45720246", "0.45712093" ]
0.7307081
1
Generates the RBS lines for this method.
def generate_rbs(indent_level, options) definition = "def #{class_method ? 'self.' : ''}#{name}: " lines = generate_comments(indent_level, options) # Handle each signature signatures.each.with_index do |sig, i| this_sig_lines = [] # Start off the first line of the signature, either with the definition # for the first signature, or a pipe for the rest if i == 0 this_sig_lines << options.indented(indent_level, definition) else this_sig_lines << options.indented(indent_level, "#{' ' * (definition.length - 2)}| ") end # Generate the signature's lines, we'll append them afterwards partial_sig_lines = sig.generate_rbs(options) # Merge the first signature line, and indent & concat the rest first_line, *rest_lines = *partial_sig_lines this_sig_lines[0] = T.unsafe(this_sig_lines[0]) + first_line rest_lines&.each do |line| this_sig_lines << ' ' * definition.length + options.indented(indent_level, line) end # Add on all this signature's lines to the complete lines lines += this_sig_lines end lines end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ruling_lines\n get_ruling_lines!\n end", "def get_ruling_lines!\n self.get_rulings\n end", "def generate\n end", "def generate; end", "def generate; end", "def generate()\n\t\t\t@out = []\n\t\t\t@context = []\n\n\t\t\ttrim_nil_lines\n\n\t\t\t@lines.each_with_index do |line, i|\n\t\t\t\twrite_with_context(line.line, line.context, next_context(i))\n\t\t\tend\n\t\t\twrite_with_context(nil, [], [])\n\t\t\treturn @out.join\n\t\tend", "def render ( )\n @bprints.each do | bp |\n bp.render()\n end\n end", "def generate\n super\n end", "def start_page\n @lines ||= []\n @lines.push \"{|border=\\\"0\\\" cellpadding=\\\"2\\\" width=\\\"95%\\\"\"\n @lines.push \"|#{CELL_STYLE} width=20%| Method\"\n @lines.push \"|#{CELL_STYLE} width=45%| Description\"\n @lines.push \"|#{CELL_STYLE} width=20%| Parameters\"\n @lines.push \"|#{CELL_STYLE} width=15%| Output\"\n @lines.push \"|-\"\n end", "def generate\n end", "def lines; end", "def lines; end", "def scribble(x1, y1, x2, y2, steps, scrib_val, style)\n \n x_step = (x2-x1) / steps\n y_step = (y2-y1) / steps\n (0 ... steps).each do |i|\n if(style == SCRIBBLE)\n if (i < steps-1)\n line(x1, y1, x1 += x_step+rand(-scrib_val..scrib_val), y1 += y_step + rand(-scrib_val..scrib_val)) \n else\n # extra line needed to attach line back to point- not necessary in HATCHING style\n line(x1, y1, x2, y2)\n end\n elsif (style == HATCHING)\n line(x1, y1, (x1 += x_step)+rand(-scrib_val..scrib_val), (y1 += y_step) + rand(-scrib_val..scrib_val))\n end\n end\nend", "def list_lines\n RailLine.list_lines\n end", "def draw\n lines = []\n\n indent = @height - 1\n draw_braches(lines, indent)\n\n lines\n end", "def generate\n # sort steps by either ascending or descending times\n order = @order == :asc ? 1 : -1\n sorted = @names_and_time_ms.sort_by { |(_, time_ms)| time_ms * order }\n\n # convert times from milliseconds into seconds and add to collection\n sorted.map! { |(name, time_ms)| [name, time_ms, time_ms / 1000.0] }\n\n # for calculating widths of name and time columns\n longest_name = sorted.map { |(name, _, _)| name.length }.max\n longest_time = sorted.map { |(_, _, time_s)| time_s.to_s.length }.max\n\n # output line for each name\n sorted.reduce(\"\") do |result, (name, time_ms, time_s)|\n name_column = \"#{name}:\".rjust(longest_name + 1)\n time_column = \"(#{time_s}s)\".ljust(longest_time + 3)\n bar_column = \"#\" * (time_ms / @scale.to_f).ceil\n result + [name_column, time_column, bar_column].join(\" \") + \"\\n\"\n end\n end", "def render_grid_lines\n outputs.lines << (0..grid.width).map { |x| vertical_line(x) }\n outputs.lines << (0..grid.width).map { |x| shifted_vertical_line(x) }\n outputs.lines << (0..grid.height).map { |y| horizontal_line(y) }\n outputs.lines << (0..grid.height).map { |y| shifted_horizontal_line(y) }\n end", "def draw_lines\n @dim.times do |i|\n if @type.nil?\n draw_line(i+1)\n draw_edge\n puts\n elsif @type == \"allx\" || @type == \"alt\"\n draw_alt_line\n draw_edge\n puts\n end\n end\n end", "def rover_controller_report\n @rover_bay.each{|x| x.print_rover}\n end", "def set_lines\n create_data_line(1)\n end", "def lines\n @lines ||= build_lines\n end", "def how_to_render_lines args\n # Render a horizontal line at the bottom\n args.nokia.lines << { x: 0, y: 0, x2: 83, y2: 0 }\n\n # Render a vertical line at the left\n args.nokia.lines << { x: 0, y: 0, x2: 0, y2: 47 }\n\n # Render a diagonal line starting from the bottom left and going to the top right\n args.nokia.lines << { x: 0, y: 0, x2: 83, y2: 47 }\nend", "def process\n self.generate\n end", "def render_grid_lines\n outputs.lines << (0..grid.width).map { |x| vertical_line(x) }\n outputs.lines << (0..grid.height).map { |y| horizontal_line(y) }\n end", "def line_items\n move_down 20\n data = line_item_data\n options = { width: bounds.width }\n header_styles = {\n border_width: 2,\n border_color: \"333333\"\n }\n table data, options do |table|\n table.rows(0).style(table_style.merge(header_styles))\n table.rows(1).style(table_style.merge(padding_top: 30))\n table.rows(2..data.length-1).style(table_style)\n end\n move_down 10\n stroke_color \"999999\"\n stroke_horizontal_rule\n end", "def generate_linenumbers\n (0...@hilbert_basis.basis.to_a.size).to_a.combination(VERTICES).to_a\n end", "def render_to_step_barb(calm=false)\n\t\tstroke ARROW_STROKE_COLOR\n\t\tstroke_weight ARROW_STROKE_WEIGHT\n\t\t\n\t\t# Initial trig calculations for the arrow head\n\t\tadj = @to_barb.pos.x - @from_barb.pos.x\n\t\topp = @to_barb.pos.y - @from_barb.pos.y\n\t\tangle = Math.atan(opp/adj)\n\t\t\n\t\tif adj>0 and opp<0.001 and opp>-0.001\n\t\t\tline_from = Point.new(@from_barb.pos.x+OFFSET_LENGTH, @from_barb.pos.y)\n\t\t\tline_to = Point.new(@to_barb.pos.x-OFFSET_LENGTH, @to_barb.pos.y)\n\t\telsif adj<0 and opp<0.001 and opp>-0.001\n\t\t\tline_from = Point.new(@from_barb.pos.x-OFFSET_LENGTH, @from_barb.pos.y)\n\t\t\tline_to = Point.new(@to_barb.pos.x+OFFSET_LENGTH, @to_barb.pos.y)\n\t\telsif adj<0.001 and adj>-0.001 and opp<0\n\t\t\tline_from = Point.new(@from_barb.pos.x, @from_barb.pos.y-OFFSET_LENGTH)\n\t\t\tline_to = Point.new(@to_barb.pos.x, @to_barb.pos.y+OFFSET_LENGTH)\n\t\telsif adj<0.001 and adj>-0.001 and opp>0\n\t\t\tline_from = Point.new(@from_barb.pos.x, @from_barb.pos.y+OFFSET_LENGTH)\n\t\t\tline_to = Point.new(@to_barb.pos.x, @to_barb.pos.y-OFFSET_LENGTH)\n\t\telsif adj>0 and opp<0\n\t\t\tline_from = Point.new(@from_barb.pos.x+OFFSET_LENGTH*(Math.cos(angle)).abs, @from_barb.pos.y-OFFSET_LENGTH*(Math.sin(angle)).abs)\n\t\t\tline_to = Point.new(@to_barb.pos.x-OFFSET_LENGTH*(Math.cos(angle)).abs, @to_barb.pos.y+OFFSET_LENGTH*(Math.sin(angle)).abs)\n\t\telsif adj<0 and opp<0\n\t\t\tline_from = Point.new(@from_barb.pos.x-OFFSET_LENGTH*Math.cos(angle), @from_barb.pos.y-OFFSET_LENGTH*(Math.sin(angle)).abs)\n\t\t\tline_to = Point.new(@to_barb.pos.x+OFFSET_LENGTH*Math.cos(angle), @to_barb.pos.y+OFFSET_LENGTH*(Math.sin(angle)).abs)\n\t\telsif adj<0 and opp>0\n\t\t\tline_from = Point.new(@from_barb.pos.x-OFFSET_LENGTH*Math.cos(angle), @from_barb.pos.y+OFFSET_LENGTH*(Math.sin(angle)).abs)\n\t\t\tline_to = Point.new(@to_barb.pos.x+OFFSET_LENGTH*Math.cos(angle), @to_barb.pos.y-OFFSET_LENGTH*(Math.sin(angle)).abs)\n\t\telsif adj>0 and opp>0\n\t\t\tline_from = Point.new(@from_barb.pos.x+OFFSET_LENGTH*Math.cos(angle), @from_barb.pos.y+OFFSET_LENGTH*(Math.sin(angle)).abs)\n\t\t\tline_to = Point.new(@to_barb.pos.x-OFFSET_LENGTH*Math.cos(angle), @to_barb.pos.y-OFFSET_LENGTH*(Math.sin(angle)).abs)\n\t\telse\n\t\t\tputs \"default arrow\"\n\t\t\tline_from = @from_barb.pos\n\t\t\tline_to = @to_barb.pos\n\t\tend\n\t\t\n\t\t# Draw a line from one point to the next.\n\t\tline line_from.x, line_from.y, line_to.x, line_to.y\n\t\t\n\t\t# Draw the arrow head\n\t\tif !calm\n\t\t\tpush_matrix\n\t\t\ttranslate line_to.x, line_to.y\n\t\t\trotate calculate_rotation(adj, opp, angle)\n\t\t\tline 0, 0, ARROW_WIDTH, -ARROW_HEIGHT\n\t\t\tline 0, 0, -ARROW_WIDTH, -ARROW_HEIGHT\n\t\t\tpop_matrix\n\t\tend\n\tend", "def begin_of_line\n write_raw \"\\r\"\n end", "def line\n puts \"########################################################\"\nend", "def endline\n\t\t@@bold = @@objs = false\n\tend", "def GenSilkLine(x1, y1, x2, y2)\n thickness = GetDim('silkwidth')\n PcbElementLine(x1, y1, x2, y2, thickness)\nend", "def line\n end", "def line\n end", "def compile_ribbons(path = \"PBS/ribbons.txt\")\r\n GameData::Ribbon::DATA.clear\r\n ribbon_names = []\r\n ribbon_descriptions = []\r\n pbCompilerEachPreppedLine(path) { |line, line_no|\r\n line = pbGetCsvRecord(line, line_no, [0, \"vnss\"])\r\n ribbon_number = line[0]\r\n ribbon_symbol = line[1].to_sym\r\n if GameData::Ribbon::DATA[ribbon_number]\r\n raise _INTL(\"Ribbon ID number '{1}' is used twice.\\r\\n{2}\", ribbon_number, FileLineData.linereport)\r\n elsif GameData::Ribbon::DATA[ribbon_symbol]\r\n raise _INTL(\"Ribbon ID '{1}' is used twice.\\r\\n{2}\", ribbon_symbol, FileLineData.linereport)\r\n end\r\n # Construct ribbon hash\r\n ribbon_hash = {\r\n :id => ribbon_symbol,\r\n :id_number => ribbon_number,\r\n :name => line[2],\r\n :description => line[3]\r\n }\r\n # Add ribbon's data to records\r\n GameData::Ribbon.register(ribbon_hash)\r\n ribbon_names[ribbon_number] = ribbon_hash[:name]\r\n ribbon_descriptions[ribbon_number] = ribbon_hash[:description]\r\n }\r\n # Save all data\r\n GameData::Ribbon.save\r\n MessageTypes.setMessages(MessageTypes::RibbonNames, ribbon_names)\r\n MessageTypes.setMessages(MessageTypes::RibbonDescriptions, ribbon_descriptions)\r\n Graphics.update\r\n end", "def generate_itemdef_drill(type,name)\n generate_itemdef_line(type,name,true,true)\n end", "def lines_to_tryton\n result = []\n \n # Build lines\n result.concat(items_to_tryton) if booking_lines.size > 0\n\n # Build extras\n result.concat(extras_to_tryton) if booking_extras.size > 0\n\n return result\n end", "def line_item_builder(key)\n line_items = \"\"\n number_of_items = @basket[key] unless key == :TOTAL\n\n case key\n when :CH1\n for i in 1..number_of_items \n line_items += \"#{key} #{get_item_price(key)}\\n\"\n end\n when :MK1\n for i in 1..number_of_items \n line_items += \"#{key} #{get_item_price(key)}\\n\"\n line_items += \" CHMK #{get_discount_price(:CHMK)}\\n\" if number_of_items > 0 && i == 1 && @basket[:CH1]\n end\n when :CF1\n for i in 1..number_of_items \n line_items += \"#{key} #{get_item_price(key)}\\n\"\n line_items += \" BOGO #{get_discount_price(:BOGO)}\\n\" if number_of_items >= 2 && i <= number_of_items / 2 \n end\n when :AP1\n for i in 1..number_of_items\n line_items += \"#{key} #{get_item_price(key)}\\n\"\n line_items += \" APPL #{get_discount_price(:APPL)}\\n\" if number_of_items >= 3 \n end\n when :TOTAL\n line_items += \" #{get_basket_total}\\n\"\n else\n line_items += \"Invalid item\"\n end\n\n line_items\n end", "def bowline\n page.Bowline\n end", "def generate!\n total_width = self.column_width + self.gutter_width\n height = @baseline_height\n RVG::dpi = 100\n\n width_in_inches = (total_width.to_f/RVG::dpi).in\n height_in_inches = (height.to_f/RVG::dpi).in\n rvg = RVG.new(width_in_inches, height_in_inches).viewbox(0, 0, total_width, height) do |canvas|\n canvas.background_fill = \"white\"\n end\n\n white = ChunkyPNG::Color.from_hex(\"ffffff\")\n background = ChunkyPNG::Color.from_hex(\"e8effb\")\n line = ChunkyPNG::Color.from_hex(\"e9e9e9\")\n\n png = ChunkyPNG::Image.new(total_width, height, white)\n png.rect(0, 0, column_width - 1, height, background, background)\n png.rect(0, height - 1, total_width, height - 1, line, line)\n\n FileUtils.mkdir(self.output_path) unless File.exists?(self.output_path)\n png.save(File.join(self.output_path, \"grid.png\"))\n end", "def gen_raw_line\n return nil unless self.valid?\n line = ''\n data = []\n SUB_STR_ATTRIBUTES.each do |field,field_regex|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n unless data.empty?\n line = \"#{data.join ' ,'}\"\n end\n\n data = []\n BOOL_ATTRIBUTES.each do |field|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n unless data.empty?\n if line == ''\n line += \"#{data.join ','} \"\n else\n line += \",#{data.join ','} \"\n end\n end\n\n data = []\n ARR_STR_ATTRIBUTES.each do |field|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n unless data.empty?\n if line == ''\n line += \"#{data.join ','} \"\n else\n line += \", #{data.join ','} \"\n end\n end\n\n data = []\n STR_ATTRIBUTES.each do |field|\n val = self.raw_getter field\n data.push val if val.nil? == false\n end\n line += data.join ' '\n return line\n end", "def generate\n raise \"must implement\"\n end", "def sc_recorders(file_base, interval, limit)\n recs = []\n\n # Real power loss recorders\n loss_types = {\n 'overhead_line' => 'OHL',\n 'underground_line' => 'UGL',\n 'triplex_line' => 'TPL',\n 'transformer' => 'TFR'\n }\n loss_types.each do |ltype, abbrev|\n # Only set up recorders for classes that actually exist in the feeder\n # (Specifically, R3_1247_2 doesn't have any triplex_lines,\n # and trying to record on class=triplex_line crashes GridLAB-D)\n if @lines.detect {|line| line.is_a?(GLMObject) && line[:class] == ltype}\n recs << new_obj({\n class: 'collector',\n group: \"\\\"class=#{ltype}\\\"\",\n property: 'sum(power_losses.real),sum(power_losses.imag)',\n interval: interval,\n limit: limit,\n file: file_base + abbrev + '_losses.csv'\n })\n end\n end\n\n # Aging_Transformer loss of life and replacements\n # All we really care about is these values at the end of the run,\n # so we'll only collect them once a day to save space\n xfmr_props = {\n 'percent_loss_of_life' => 'pct_lol',\n 'transformer_replacement_count' => 'replacements'\n }\n xfmr_props.each do |prop, abbrev|\n recs << new_obj({\n class: 'group_recorder',\n group: \"\\\"groupid=#{AGING_GROUPID}\\\"\",\n property: prop,\n interval: DAY_INTERVAL,\n limit: limit,\n file: file_base + 'xfmr_' + abbrev + '.csv'\n })\n end\n\n # Also collect power profiles for Aging_Transformers so we\n # can have some sense of why we're seeing what we're seeing\n recs << new_obj({\n class: 'group_recorder',\n group: \"\\\"groupid=#{AGING_GROUPID}\\\"\",\n property: 'power_in',\n complex_part: 'MAG',\n interval: interval,\n limit: limit,\n file: file_base + 'xfmr_va.csv'\n })\n\n # Tap-change recorders\n find_by_class('regulator').each do |reg|\n recs << new_obj({\n class: 'recorder',\n parent: reg[:name],\n property: 'tap_A_change_count,tap_B_change_count,tap_C_change_count,tap_A,tap_B,tap_C,power_in_A.real,power_in_A.imag,power_in_B.real,power_in_B.imag,power_in_C.real,power_in_C.imag,power_out_A.real,power_out_A.imag,power_out_B.real,power_out_B.imag,power_out_C.real,power_out_C.imag,current_in_A.real,current_in_A.imag,current_in_B.real,current_in_B.imag,current_in_C.real,current_in_C.imag,current_out_A.real,current_out_A.imag,current_out_B.real,current_out_B.imag,current_out_C.real,current_out_C.imag',\n interval: interval,\n limit: limit,\n file: file_base + reg[:name][-5..-1] + '.csv'\n })\n end\n\n # Record voltage at the point of use, which conveniently is always\n # a triplex_meter\n recs << new_obj({\n class: 'group_recorder',\n group: 'class=triplex_meter',\n property: \"voltage_12\",\n complex_part: 'MAG',\n interval: interval,\n limit: limit,\n file: file_base + 'v_profile_12.csv'\n })\n\n # Record total PV output, if there is any SC solar to record\n if find_by_class('house').any? {|h| h.nested.any? {|n| n[:groupid] == SC_GROUPID }}\n recs << new_obj({\n class: 'collector',\n group: \"\\\"class=ZIPload AND groupid=#{SC_GROUPID}\\\"\",\n property: 'sum(actual_power.real)',\n interval: MINUTE_INTERVAL,\n limit: limit,\n file: file_base + 'sc_gen.csv'\n })\n end\n\n # Record aggregate SC storage stats, if there's any storage\n unless find_by_four_quadrant_control_mode(SC_CONTROL_MODE).empty?\n recs << new_obj({\n class: 'collector',\n group: \"\\\"class=inverter\\\"\",\n property: 'sum(sc_dispatch_power),avg(battery_soc),std(battery_soc),min(battery_soc),max(battery_soc)',\n interval: MINUTE_INTERVAL,\n limit: limit,\n file: file_base + 'sc_storage.csv'\n })\n end\n\n # Record capacitor switch states, if any\n caps = find_by_class('capacitor')\n unless caps.empty?\n\n prop = caps.map do |cap|\n PHASES.map do |ph|\n \"#{cap[:name]}:switch#{ph}\"\n end\n end.flatten.join ','\n\n recs << new_obj({\n class: 'multi_recorder',\n property: prop,\n interval: interval,\n limit: limit,\n file: file_base + 'cap_switch.csv'\n })\n end\n\n recs\n end", "def draw_rates(x, y, width, attributes, descr)\n change_color(crisis_color)\n draw_text(x, y, width, line_height, descr)\n y += line_height\n columns = BestiaryConfig::ELEMENTS_PER_ROW\n block_width = width / columns\n attributes.each_with_index do |element, index|\n block_x = block_width * (index % columns) + x\n block_y = line_height * (index / columns) + y\n draw_element(element, block_x, block_y, block_width)\n end\n change_color(normal_color)\n y + line_height * (attributes.size / columns)\n end", "def lines(*args)\n #This is a stub, used for indexing\n end", "def line_feed\n write_raw \"\\n\"\n end", "def buffer_lines\n buffer_line_cycle.map { |i| self[i] }.join(\"\\n\")\n end", "def line_ending\n @line_ending ||= \"\\r\\n\"\n end", "def claim_loop\n segments = []\n @eobs.each_with_index do |eob, index|\n @check_grouper.last_eob = eob\n @check = eob.check_information\n @job = @check.job\n if @check.micr_line_information && @check.micr_line_information.payer && @facility.details[:micr_line_info]\n @payer = @check.micr_line_information.payer\n else\n @payer = @check.payer\n end\n @facility_output_config = @facility.output_config(@payer.payer_type)\n @reason_codes = nil #this variable is used in child class for configurable section\n @eob = eob\n @claim = eob.claim_information\n @eob_index = index\n @services = eob.service_payment_eobs\n @is_claim_eob = (eob.category.upcase == \"CLAIM\")\n @count = count\n segments << transaction_set_line_number(index + 1)\n segments << transaction_statistics([eob])\n segments += generate_eobs\n end\n segments.flatten.compact\n end", "def generate_eobs\n Output835.log.info \"\\n\\nPatient account number : #{@eob.patient_account_number}\"\n Output835.log.info \"This EOB has #{@services.length} service lines\"\n Output835.log.info \"This is a CLAIM LEVEL EOB\" if @is_claim_eob\n claim_segments = [claim_payment_loop, include_claim_dates]\n claim_segments << claim_supplemental_info unless @facility.details[:interest_in_service_line]\n claim_segments << claim_level_allowed_amount\n claim_segments << standard_industry_code_segments(@eob, @is_claim_eob) if @is_claim_eob\n claim_segments << service_payment_info_loop unless @is_claim_eob\n update_clp! claim_segments\n claim_segments.flatten.compact\n end", "def receipt_builder\n header = \"Item Price\\n\"\n divider = \"---- -----\\n\"\n line_items = \"\"\n @basket.keys.each do |key|\n line_items += line_item_builder(key)\n end\n end_divider = \"-----------------------------------\\n\"\n total = line_item_builder(:TOTAL)\n\n return header += divider += line_items += end_divider += total\n end", "def generate_receipts\n\t\t## and now display this.\n\t\tif self.finalize_order == YES\n\t\t\tself.reports.each do |report|\n\t\t\t\tif report.consider_for_processing?(self.history_tags)\n\t\t\t\t\t## ready for processing.\n\t\t\t\t\tif report.is_outsourced?\n\t\t\t\t\t\t#puts \"report is outsourced.\"\n\t\t\t\t\t\tif bill_direct_to_patient?\n\t\t\t\t\t\t\t#this will be true.\n\t\t\t\t\t\t\t#puts \"we are on bill direct to patient.\"\n\t\t\t\t\t\t\t#will be receipt to patient via organizaiton.\n\t\t\t\t\t\t\treceipt_to_patient(report.currently_held_by_organization,report)\n\t\t\t\t\t\t\t#(from_organization_id,report) \n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t#puts \"we are on double bill\"\n\t\t\t\t\t\t\treceipt_to_patient(self.organization.id.to_s,report)\n\t\t\t\t\t\t\treceipt_to_order_organization(report)\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\t\n\t\t\t\t\t\treceipt_to_patient(self.organization.id.to_s,report)\n\t\t\t\t\t\n\t\t\t\t\t\tunless self.outsourced_by_organization_id.blank?\n\t\t\t\t\t\t\treceipt_to_outsourced_organization(report)\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\tend", "def prepare_RLT(num_ops)\n rlt = (num_ops + 0.2) * 350#ul\n b_me = rlt.to_f/1000.0\n rlt_tab = [\n [\"# of Samples\", \"RLT (mL)\"],\n [num_ops].concat([(rlt/1000).round(2)].map { |v| { content: v, check: true } })\n ]\n show do \n title \"Preparing Lysis Buffer (RLT)\"\n separator\n if rlt > 15000\n check \"Grab a clean 50mL Falcon tube and label => <b>RLT Buffer</b>\"\n elsif rlt.between?(1500, 14900)\n check \"Grab a clean 15mL Falcon tube and label => <b>RLT Buffer</b>\"\n else\n check \"Grab a clean 1.5 Eppie tube and label => <b>RLT Buffer</b>\"\n end\n \n note \"From the RNeasy Kit, grab the RLT reagent and follow the table below:\"\n table rlt_tab\n note \"Once done, place RLT Buffer on ice until ready for use!\"\n end\n return b_me\n end", "def generate\n raise NotImplementedError\n end", "def generate\n raise NotImplementedError\n end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def line; end", "def setup_recorders(style, region)\n sub_rec = find_by_class('recorder').first\n raise \"Substation recorder wasn't where I expected\" unless sub_rec[:parent] == 'substation_transformer'\n rec_i = @lines.index(sub_rec)\n\n # Setup an incomplete file name for all recorders to send their output to\n # The filename puts all the output in a directory named after the model file\n # Each recorder has to complete the filename for itself, of course\n out_basename = File.basename @outfilename, EXT\n file_base = File.join out_basename, \"#{out_basename}_\"\n sub_rec[:file] = file_base + 'substation_power.csv'\n\n # default other recorders to having the same interval and limit\n # as the default substation recorder\n interval = sub_rec[:interval]\n limit = sub_rec[:limit]\n\n # We're most interested in the power_in to the substation transformer\n # for peak load purposes\n sub_rec[:property] = 'power_in.real,power_in.imag,power_in_A.real,power_in_A.imag,power_in_B.real,power_in_B.imag,power_in_C.real,power_in_C.imag'\n # and we're actually interested in recording it every minute to get as close\n # to the \"true\" peak load as possible\n sub_rec[:interval] = MINUTE_INTERVAL\n\n remove_classes_from_top_layer 'recorder', 'collector', 'billdump'\n\n # adjust EOLVolt multi-recorder file destinations\n find_by_class('multi_recorder').each do |obj|\n volt_match = /EOLVolt[1-9]\\.csv/.match(obj[:file])\n raise \"I found a multi-recorder that doesn't appear to be an EOLVolt recorder\" if volt_match.nil?\n obj[:file] = file_base + volt_match[0]\n end\n\n # Add custom baseline or sc (production run) recorders as dictated\n # by the style parameter\n recs = [sub_rec] + send(:\"#{style}_recorders\", file_base, interval, limit)\n\n # Add blank lines before each recorder\n recs = recs.inject([]) {|new_recs, rec| new_recs << '' << rec}\n\n @lines.insert rec_i, *recs\n end", "def genFileContent(cls, bld)\n bld.separate\n\n for inc in cls.includes\n bld.add(\"require '\" << inc.path << inc.name << \".\" << Utils.instance.getExtension(\"body\"))\n end\n\n bld.separate\n\n render_namespace_starts(cls, bld)\n\n inheritFrom = \"\"\n\n if cls.baseClasses.length > 0\n inheritFrom = \" < \" + Utils.instance.getClassTypeName(cls.baseClasses[0])\n end\n\n if cls.baseClasses.length > 1\n Log.error(\"Ruby doesn't support multiple inheritance\")\n end\n\n bld.startClass(\"class \" + getClassName(cls) + inheritFrom)\n\n accessors = Accessors.new\n # Do automatic static array size declairations at top of class\n process_var_accessors(accessors, cls, bld, cls.model.varGroup)\n\n add_accessors(\"attr_accessor\", accessors.both, bld)\n add_accessors(\"attr_attr_reader\", accessors.readers, bld)\n add_accessors(\"attr_attr_writer\", accessors.writers, bld)\n\n bld.separate\n\n # Do automatic static array size declairations at top of class\n process_var_group(cls, bld, cls.model.varGroup)\n\n bld.separate\n # Generate code for functions\n for fun in cls.functions\n process_function(cls, bld, fun)\n end\n\n bld.endClass\n render_namespace_ends(cls, bld)\n end", "def lineBreak \n \"lineBreak\" \n end", "def genFileContent(cls, bld)\r\n bld.startClass(\"class \" + getClassName(cls))\r\n\r\n bld.separate\r\n # Generate code for class variables\r\n eachVar(uevParams().wCls(cls).wBld(bld).wSeparate(true).wVarCb(lambda { |var| }))\r\n\r\n bld.separate\r\n # Generate code for functions\r\n render_functions(cls, bld)\r\n\r\n bld.endClass\r\n end", "def render outputs\n\n # Work through each brick in the current brick orientation\n @bricks[@rotation].each do |brick|\n\n outputs.primitives << {\n x: @board_origin_x + ( ( @grid_col + brick[1] ) * 32 ),\n y: @board_origin_y + ( ( @grid_row + brick[0] ) * 32 ),\n w: 32,\n h: 32,\n path: \"sprites/brick_#{@type.to_s}.png\"\n }.sprite\n\n end\n\n end", "def draw_line\n print H_SEP * columns\n end", "def build_line(multiplier, products)\n multiplier.to_s + \": \" + products.to_s + \"\\n\"\n end", "def draw_data\n\n # Set font.\n font = \"SF Mono\"\n color = '000000'\n\n # Format dates.\n ship_date = Time.iso8601(@data[:date]).strftime(\"%m/%d/%y\")\n\n # Repeat format on all pages.\n self.repeat(:all) do\n\n # Carrier, shipper #s, and date.\n self.txtb(@data[:carrier], 1.171, 8.55 + 10.pt, 4, 10.pt, size: 10, style: :bold, h_align: :left, font: font, color: color)\n self.txtb(@data[:shipper], 6.75, 8.75 + 10.pt, 6.65, 10.pt, size: 10, style: :bold, h_align: :left, font: font, color: color)\n self.txtb(ship_date, 6.75, 8.55 + 10.pt, 6.65, 10.pt, size: 10, style: :bold, h_align: :left, font: font, color: color)\n\n # Ship to.\n if @data[:ship_to][:name].length == 2\n self.txtb(@data[:ship_to][:name][0], 1.006, 8.35 + 10.pt, 4, 10.pt, size: 10, style: :bold, h_align: :left, font: font, color: color)\n self.txtb(@data[:ship_to][:name][1], 1.006, 8.175 + 10.pt, 4, 10.pt, size: 10, style: :bold, h_align: :left, font: font, color: color)\n else\n self.txtb(@data[:ship_to][:name][0], 1.006, 8.175 + 10.pt, 4, 10.pt, size: 10, style: :bold, h_align: :left, font: font, color: color)\n end\n self.txtb(@data[:ship_to][:address], 1.006, 8 + 10.pt, 4, 10.pt, size: 10, style: :bold, h_align: :left, font: font, color: color)\n self.txtb(@data[:ship_to][:city_state], 1.006, 7.825 + 10.pt, 4, 10.pt, size: 10, style: :bold, h_align: :left, font: font, color: color)\n self.txtb(@data[:ship_to][:zip].to_s.rjust(5, '0'), 3.65, 7.825 + 10.pt, 4, 10.pt, size: 10, style: :bold, h_align: :left, font: font, color: color)\n\n # Ship from.\n self.txtb(@data[:initials], 7.65, 7.825 + 10.pt, 4, 10.pt, size: 10, style: :bold, h_align: :left, font: font, color: color)\n\n # Table.\n y = 7.1 + 10.pt\n 0.upto(8) do |i|\n self.txtb(@data[:units][i], 0.25, y, 1.25, 10.pt, size: 10, style: :bold, font: font, color: color) unless @data[:units][i] == 0\n self.txtb(@data[:hazardous][i], 1.5, y, 0.4, 10.pt, size: 10, style: :bold, font: font, color: color)\n self.txtb(@data[:descriptions][i], 1.95, y, 3.25, 10.pt, size: 10, style: :bold, h_align: :left, font: font, color: color)\n self.txtb(@data[:weights][i], 5.25, y, 1.25, 10.pt, size: 10, style: :bold, font: font, color: color)\n self.txtb(@data[:rates][i], 6.5, y, 0.6, 10.pt, size: 10, style: :bold, font: font, color: color)\n y -= 0.193\n end\n\n # Draw special instructions.\n self.txtb(@data[:special_instructions][0], 0.35, 3.67 + 10.pt, 7.8, 10.pt, size: 10, style: :bold, h_align: :left, font: font, color: color)\n self.txtb(@data[:special_instructions][1], 0.35, 3.5325 + 10.pt, 7.8, 10.pt, size: 10, style: :bold, h_align: :left, font: font, color: color)\n self.txtb(@data[:special_instructions][2], 0.35, 3.395 + 10.pt, 7.8, 10.pt, size: 10, style: :bold, h_align: :left, font: font, color: color)\n\n # Check box for collect.\n self.txtb(\"XX\", 7.377, 1.81 + 10.pt, 0.2, 0.2, size: 10, style: :bold, font: font, color: color) if @data[:collect]\n\n # Draw certification info.\n self.txtb(@data[:carrier], 4.95, 0.725 + 10.pt, 5, 10.pt, size: 10, style: :bold, h_align: :left, font: font, color: color)\n self.txtb(ship_date, 6.8, 0.575 + 10.pt, 5, 10.pt, size: 10, style: :bold, h_align: :left, font: font, color: color)\n\n # Draw signatures.\n if @data[:auto_sign]\n person = nil\n case @data[:user]\n when \"TERRY\"\n person = :terry_marshall\n when \"ROB\"\n person = :rob_caudill\n when \"TIM\"\n person = :tim_hudson\n when \"MITCH\"\n person = :mike_mitchell\n when \"CAP\"\n person = :gerald_cappelletti\n when \"DALLAS\"\n person = :dallas_roll\n when \"JAMES\"\n person = :james_hill\n end\n unless person.blank?\n self.signature(person, 4.35, 2.425, 2.05, 0.5)\n self.signature(person, 0.95, 0.8, 2.05, 0.25, h_align: :left)\n end\n end\n\n end\n\n end", "def draw\n\t\t#\n\t\t# Draw the \"top\" line.\n\t\t#\n\t\tputs \" \" + \"_\" * (@width * 2 - 1)\n\t\n\t\t#\t\n\t\t# Draw each of the rows.\n\t\t#\n\t\t@height.times do |y|\n\t\t\tprint \"|\"\n\t\t\t@width.times do |x|\n\t\t\t\t# render \"bottom\" using \"S\" switch\n\t\t\t\tprint( (@grid[y][x] & @@S != 0) ? \" \" : \"_\" )\n\t\t\t\n\t\t\t\t# render \"side\" using \"E\" switch\t\n\t\t\t\tif @grid[y][x] & @@E != 0\n\t\t\t\t\tprint( ( ( @grid[y][x] | @grid[y][x+1] ) & @@S != 0 ) ? \" \" : \"_\" )\n\t\t\t\telse\n\t\t\t\t\tprint \"|\"\n\t\t\t\tend\n\t\t\tend\n\t\t\tputs\n\t\tend\n\n\t\t# \n\t\t# Output metadata\n\t\t#\n\t\tputs metadata\n\tend", "def generated\n end", "def generate_lyric\n if month == \"july\" && day == \"6\"\n curtis_bday_song\n else\n puts \"\\nOkay. Here's your 50 Cent Lyric that will guide you in your celebration:\\n*****pretend he wrote it just for you*****\"\n bday_lyric = GoShawty::Lyric.new\n puts\"Song: #{bday_lyric.song_name}\\n\"\n puts \"#{bday_lyric.album_name}\\n\"\n puts \"\\n\\n#{bday_lyric.lines}\\n\"\n list_celebrities\n end\n end", "def write(path = @path)\n \n gline = Gruff::Line.new(@size)\n @methods.each do |m, args|\n gline.send(\"#{m}=\", args)\n end\n @dataxy.each do |dxy| \n gline.dataxy(dxy[0], dxy[1], dxy[2]) \n end\n\n @filename ||= filename(@methods[:title])\n @filename ||= \"rbPlot\"\n gline.write(path + @filename + '.png')\n end", "def generate\n generate_header_row + (@data.map {|x| generate_row(x)}).join\n end", "def cr\n\t\t\toy = @cursor.y\n\t\t\t@buffer.insert Ruvim::API::CR\n\t\t\tredraw_line(oy ... @height)\n\t\t\tdown.goto_bol\n\t\tend", "def make_block_header_lines(block, model)\n puts \"${color1}#{model} (#{block})\"\n #puts \"${color1}Read: ${color2}${diskio_read #{block}} ${goto 175}\" \\\n # \"${color1}Write: ${color2}${diskio_write #{block}}\"\n #puts \"${color5}${diskiograph_read #{block} 18,150 0000ff ff0000 -t} ${goto 175}\" \\\n # \"${color5}${diskiograph_write #{block} 18,150 0000ff ff0000 -t}\"\nend", "def print_brands\n\treturn \"\n ____ _ \n | __ ) _ __ __ _ _ __ __| |___ \n | _ \\\\| '__/ _` | '_ \\\\ / _` / __|\n | |_) | | | (_| | | | | (_| \\\\__ \\\\\n |____/|_| \\\\__,_|_| |_|\\\\__,_|___/\\n\\n\"\n\nend", "def progress_line; end", "def lines\n self\n end", "def generate(obj, options = {})\n opts = Lines.generate_default_options.merge(options.to_hash)\n @generator.generate(obj.to_hash, opts)\n end", "def print_brands\n\t$report_file.puts\"\n _\n| | | |\n| |__ _ __ __ _ _ __ __| |___\n| '_ \\\\| '__/ _` | '_ \\\\ / _` / __|\n| |_) | | | (_| | | | | (_| \\\\__ \\\\\n|_.__/|_| \\\\__,_|_| |_|\\\\__,_|___/\n\n\"\nend", "def draw\n <<~RUBY\n def initialize(#{initialize_parameters})\n #{initialize_body}\n end\n RUBY\n end", "def draw\n\t\t@branches.each do |a|\n\t\t a.each do |b|\n\t\t\t@window.draw_line(b[0][0], b[0][1], @color, b[1][0], b[1][1], @color, @layer)\n\t\t end\n\t\tend\n\t end", "def generating_notes\n puts\n notes = \"Generating release notes\"\n puts bold(notes)\n puts notes.length.times.map {\"=\"}.join\n puts\n end", "def lines_above_method\n added_lines = []\n lines_to_add = []\n block_level = 0\n ensure_line_breaks(controller_content.lines).first(action_line).reverse_each do |line|\n if line =~ /\\s*\\bend\\b\\s*/\n block_level += 1\n end\n if block_level > 0\n lines_to_add << line\n else\n added_lines << line\n end\n if line =~ /\\s*\\b(module|class|def)\\b /\n break\n end\n next unless line =~ /do\\s*(\\|.*?\\|)?\\s*$/\n block_level -= 1\n if block_level == 0\n added_lines.concat(lines_to_add)\n lines_to_add = []\n end\n end\n return added_lines.reverse.join\n end", "def rla\n end", "def set_lines\n set_line(:receiving_line,OLE_QA::Framework::OLEFS::Receiving_Line)\n end", "def source_lines; end", "def source_lines; end", "def source_lines; end", "def source_lines; end", "def getLines\n\t\t@lines\n\tend" ]
[ "0.6484955", "0.64685106", "0.58297396", "0.57131875", "0.57131875", "0.5706199", "0.55833036", "0.55117637", "0.5476175", "0.54385424", "0.5436468", "0.5436468", "0.5375646", "0.5360394", "0.53524673", "0.5348188", "0.53149784", "0.53030133", "0.5284046", "0.52635384", "0.52595836", "0.5254277", "0.5247902", "0.52376425", "0.52375764", "0.52263707", "0.522352", "0.52177995", "0.520405", "0.519401", "0.5188969", "0.51480144", "0.51480144", "0.51399016", "0.5136503", "0.51187265", "0.51074016", "0.50975263", "0.5096765", "0.50743645", "0.50741637", "0.50696105", "0.5046875", "0.50413036", "0.50381935", "0.5035698", "0.5000442", "0.5000312", "0.49965757", "0.49860778", "0.49853006", "0.49839067", "0.49827465", "0.49823028", "0.49705297", "0.49705297", "0.49705297", "0.49705297", "0.49705297", "0.49705297", "0.49705297", "0.49705297", "0.49705297", "0.49705297", "0.49705297", "0.49705297", "0.49705297", "0.49705297", "0.49705297", "0.49544138", "0.49531436", "0.4949146", "0.49391404", "0.49390557", "0.49290663", "0.49261206", "0.49185237", "0.49160874", "0.49106404", "0.4902356", "0.48966092", "0.4893892", "0.48923397", "0.48870432", "0.4886854", "0.48867813", "0.48850662", "0.48814893", "0.48738593", "0.4871499", "0.48505622", "0.48487347", "0.4845827", "0.48443413", "0.48267922", "0.48242384", "0.48242384", "0.48242384", "0.48242384", "0.47989604" ]
0.65714455
0
Use callbacks to share common setup or constraints between actions.
def set_page @page = @current_site.pages.find(params[:id]) @program = @page.program end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def set_required_actions\n # TODO: check what fields change to asign required fields\n end", "def action_hook; end", "def run_actions; end", "def define_action_hook; end", "def actions; end", "def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end", "def add_actions; end", "def callbacks; end", "def callbacks; end", "def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end", "def define_action_helpers; end", "def post_setup\n end", "def action_methods; end", "def action_methods; end", "def action_methods; end", "def before_setup; end", "def action_run\n end", "def execute(setup)\n @action.call(setup)\n end", "def set_actions\n actions :all\n end", "def define_action_helpers?; end", "def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end", "def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end", "def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end", "def setup_handler\n end", "def before_actions(*logic)\n self.before_actions = logic\n end", "def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end", "def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end", "def action; end", "def action; end", "def action; end", "def action; end", "def action; end", "def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end", "def workflow\n end", "def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end", "def before(action)\n invoke_callbacks *self.class.send(action).before\n end", "def process_action(...)\n send_action(...)\n end", "def before_dispatch(env); end", "def setup\n # override and do something appropriate\n end", "def after_actions(*logic)\n self.after_actions = logic\n end", "def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end", "def setup(_context)\n end", "def setup(resources) ; end", "def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end", "def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end", "def determine_valid_action\n\n end", "def 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 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 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\n transition_to(:setup)\n end", "def setup\n transition_to(:setup)\n end", "def setup(&block)\n define_method(:setup, &block)\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 setup(easy)\n super\n easy.customrequest = @verb\n end", "def save_action; end", "def action_target()\n \n end", "def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end", "def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end", "def before_setup\n # do nothing by default\n end", "def default_action; 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 callback_phase\n super\n end", "def advice\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 _handle_action_missing(*args); end", "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 duas1(action)\n action.call\n action.call\nend" ]
[ "0.6163821", "0.6045432", "0.5945441", "0.5916224", "0.58894575", "0.5834073", "0.57764685", "0.5702474", "0.5702474", "0.5653258", "0.56211996", "0.54235053", "0.5410683", "0.5410683", "0.5410683", "0.53948104", "0.5378064", "0.5356684", "0.53400385", "0.53399503", "0.53312254", "0.53121567", "0.52971965", "0.52964705", "0.52956307", "0.52587366", "0.52450675", "0.5237777", "0.5237777", "0.5237777", "0.5237777", "0.5237777", "0.5233381", "0.52325714", "0.52288216", "0.52229726", "0.5218362", "0.52142864", "0.5207988", "0.5206337", "0.51762295", "0.51745105", "0.51728606", "0.516616", "0.5161016", "0.5157393", "0.5152562", "0.51524293", "0.5152397", "0.5144533", "0.513982", "0.51342106", "0.5113793", "0.5113793", "0.5113671", "0.51092553", "0.51062804", "0.50921935", "0.5088855", "0.5082236", "0.5079901", "0.5066569", "0.5055307", "0.5053106", "0.50499666", "0.50499666", "0.5035068", "0.50258636", "0.50220853", "0.5015893", "0.50134486", "0.5001442", "0.50005543", "0.4998581", "0.49901858", "0.49901858", "0.4986648", "0.49809486", "0.49792925", "0.4978855", "0.49685496", "0.49656174", "0.49576473", "0.49563017", "0.4955349", "0.49536878", "0.4952439", "0.49460214", "0.494239", "0.49334687", "0.49315962", "0.49266812", "0.49261138", "0.4925925", "0.4922542", "0.4920779", "0.49173284", "0.49169463", "0.4916256", "0.49162322", "0.49156886" ]
0.0
-1
Never trust parameters from the scary internet, only allow the white list through.
def page_params params.require(:page).permit(:slug, :title, :content) 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
This function has bee deprecated in favour of the separate profile? data? and drill? functions
def type raise AMEE::Deprecated end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def profiles; end", "def profile; end", "def profile; end", "def profile\n end", "def profile\n end", "def profile\n end", "def profile\n end", "def profile\n end", "def profile\n end", "def profile\n \n end", "def profile\n\n end", "def profiles__potential_values(options = {})\r\nif options.has_key?(:page)\r\n Profile.paginate(options)\r\nelse\r\n Profile.all(options)\r\nend\r\nend", "def profiles__potential_values(options = {})\r\nif options.has_key?(:page)\r\n Profile.paginate(options)\r\nelse\r\n Profile.all(options)\r\nend\r\nend", "def profile_accesses__potential_values(options = {})\r\nif options.has_key?(:page)\r\n ProfileAccess.paginate(options)\r\nelse\r\n ProfileAccess.all(options)\r\nend\r\nend", "def myprofile\n \n end", "def scrape_data_for_profile_page(html)\n page = Nokogiri::HTML(html)\n return nil if !page.css(\"div[class~=errorMessage]\").empty?\n profile_name = page.css(\"div[class~=aboutBar]\").css(\"div[class~=about]\").css(\"div[class~=name]\").text.to_s.strip\n if profile_name.empty?\n profile_name = page.css(\"h1[class~=userProfileHeaderName]\").text.strip\n end\n followers_count = page.css(\"div[class~=FollowerCount]\").text.to_s.strip.split[0].tr(\",\", \"\")\n info_bar = page.css(\"div[class~=UserInfoBar]\").css(\"div[class~=tabs]\").text.to_s.strip.tr(\"\\n\",\" \")\n if info_bar.empty?\n info_bar = page.css(\"div[class~=UserInfoBar]\").css(\"ul[class~=userStats]\").text.to_s.strip.tr(\"\\n\",\" \")\n followed_info_bar = page.css(\"div[class~=UserInfoBar]\").css(\"ul[class~=followersFollowingLinks]\").text.to_s.strip.tr(\"\\n\",\" \")\n followed = followed_info_bar.match(/\\d?,?\\d+ Following/).to_s.split[0].tr(\",\",\"\")\n else\n followed = info_bar.match(/\\d?,?\\d+ Following/).to_s.split[0].tr(\",\",\"\")\n end\n pins = info_bar.match(/\\d?,?\\d+ Pins/).to_s.split[0].tr(\",\",\"\")\n likes = info_bar.match(/\\d?,?\\d+ Likes/).to_s.split[0].tr(\",\",\"\")\n bio = page.css(\"p[class~=aboutText]\").text.to_s.strip\n if bio.empty?\n bio = page.css(\"p[class~=userProfileHeaderBio]\").text.to_s.strip\n end\n boards = page.css(\"div[class~=BoardCount]\").text.to_s.split[0].tr(\",\", \"\")\n return {\"profile_name\" => profile_name, \"followers_count\" => followers_count, \"profile_description\" => bio,\n \"boards_count\" => boards, \"pins_count\" => pins, \"likes_count\" => likes, \"followed\" => followed}\n end", "def home_page_profiles__potential_values(options = {})\r\nif options.has_key?(:page)\r\n Profile.paginate(options)\r\nelse\r\n Profile.all(options)\r\nend\r\nend", "def prepare_profile\n profile || build_profile\n end", "def get_profile_data(profile_data, parent_one={}, parent_two={})\n {\n :first_name => profile_data[:first_name],\n :last_name => profile_data[:last_name],\n :birthday => profile_data[:birthday],\n :gender => profile_data[:gender],\n :email_address => profile_data[:email_address],\n\n :street_address => profile_data[:address][:street_address],\n :secondary_address => profile_data[:address][:secondary_address] ? profile_data[:address][:secondary_address] : nil,\n :city => profile_data[:address][:city],\n :state => profile_data[:address][:state],\n :zip => profile_data[:address][:zip_code],\n :country => profile_data[:address][:country],\n :phone_number => profile_data[:phone_number],\n\n :parent_one_first_name => !parent_one.empty? ? parent_one[:first_name] : nil,\n :parent_one_last_name => !parent_one.empty? ? parent_one[:last_name] : nil,\n :parent_one_email => !parent_one.empty? ? parent_one[:email_address] : nil,\n\n :parent_two_first_name => !parent_two.empty? ? parent_two[:first_name] : nil,\n :parent_two_last_name => !parent_two.empty? ? parent_two[:last_name] : nil,\n :parent_two_email => !parent_two.empty? ? parent_two[:email_address] : nil,\n\n :grade => profile_data[:grade],\n :weight => profile_data[:weight]\n }\n end", "def profile_parameter; end", "def profile_datasets_advance\n advance = []\n each_dataset_profile_advance { |adv| advance << adv }\n advance\n end", "def pull_profiles\n @user = current_user\n @accessible_artists = @user.artists.includes(:artist_musics, :songs)\n @accessible_venues = @user.venues\n get_fan_objects_for_right_column(@user)\n respond_to do |format|\n format.js\n format.html\n end\n end", "def profiler; end", "def profiler; end", "def fetch_profile_data\n puts \"Step 10: Extracting freelancer profile data\"\n freelance_profile_page = FreelancerProfilePage.new\n data = freelance_profile_page.get_profile_header\n data2 = data.find_element(css: \".overlay-container\")\n title = data2.find_element(css: \"h3\").text\n description = data2.find_elements(css: \"o-profile-overview\").first.text\n skills = freelance_profile_page.get_profile_skills.collect{|t| t.text}\n\n @profile_data = {\n title: title,\n description: description,\n skills: skills\n }\n puts \"Profile data extracted successfully\"\n end", "def index\n @profiles = Profile.all.order(\"username ASC\")\n @directors = Profile.where('is_director = 1').order(\"username ASC\")\n @assistants = Profile.where('is_assistant = 1').order(\"username ASC\")\n @phd = Profile.where('is_phd = 1').order(\"phD_entrance_year DESC\")\n @msc = Profile.where('is_msc = 1').order(\"MSc_entrance_year DESC\")\n @bsc = Profile.where('is_bsc = 1').order(\"BSc_entrance_year DESC\")\n @intern = Profile.where('is_intern = 1').order(\"guest_entrance_year DESC\")\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 show\n redirect_to edit_profile_url if @profile.nil?\n\n @no_trade_owned_products = @profile.user.listings.where(category_id: 'products', status: 'owned', item_type: 'no-trade')\n @no_trade_owned_skills = @profile.user.listings.where(category_id: 'skills', status: 'owned', item_type: 'no-trade')\n @trade_owned_products_or_skills = @profile.user.listings.where(category_id: ['skills', 'products'], status: 'owned', item_type: 'trade')\n @trade_wanted_skills = @profile.user.listings.where(category_id: 'skills', status: 'wanted')\n @trade_wanted_products = @profile.user.listings.where(category_id: 'products', status: 'wanted')\n\n end", "def profileinfo(user_id)\n categories = db.execute(\"SELECT category FROM categories\")\n arr = []\n categories.each do |category|\n arr << category[\"category\"]\n end\n return [db.execute(\"SELECT * FROM users WHERE user_id=?\", user_id), db.execute(\"SELECT * FROM listings WHERE user_id=?\", user_id), db.execute(\"SELECT * FROM listing_cate_rel\"), arr]\nend", "def show\n @profiles_all = current_user.profiles.order('lastname ASC')\n if current_user.business\n @business = current_user.business.name\n end\n @profile = current_user.profiles.find(params[:id])\n @profile_tickets = Ticket.where(:user => @user).order('date_opened DESC')\n .paginate(page: params[:page])\n @profile_assets = Asset.where(:owner => @user).order('serial ASC')\n .paginate(page: params[:page])\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 profile\n super\n end", "def profile\n super\n end", "def profile\n borrows = Transaction.find_by_id_b(current_user.id)\n lends = Transaction.find_by_id_l(current_user.id)\n\n if borrows == nil and lends == nil\n @empty = true\n @all_charts = [].to_json\n else\n @empty = false\n all_charts = {}\n\n #line chart - All\n res = Transaction.historygraph(current_user.id)\n all_charts.store('DebtLevel', JSON.parse(res))\n\n #pie chart - Debt\n res = Transaction.borrower_piechart(current_user.id)\n all_charts.store('Pie_d', JSON.parse(res))\n\n #pie chart - AR\n res = Transaction.lender_piechart(current_user.id)\n all_charts.store('Pie_ar', JSON.parse(res))\n\n #bubble chart - Debt\n res = Transaction.paidbackhistory(current_user.id)\n all_charts.store('History_d', JSON.parse(res))\n\n #bubble chart - AR\n #uri = URI('http://iou.azurewebsites.net/api/values/History/spaceholder/AR/' + session[:user])\n #res = Net::HTTP.get(uri)\n #all_charts.store('History_ar', JSON.parse(res))\n\n @all_charts = all_charts.to_json\n end\n\n end", "def detailed_graphs\n\n#users\n\t\t@users = User.all \n\t\t@user = current_user\n\n\t\tif @user.profiles.empty?\n\t\t\tflash[:notice] = \"Please complete a User Profile to continue\"\n\t\t\tredirect_to new_user_profile_path\n\t\tend\n\n\t\tif @user.utilities.empty?\n\t\t\tflash[:notice] = \"Please complete the Utilities survey to continue\"\n\t\t\tredirect_to new_user_utility_path\n\t\tend\n\t\t\n\t\tif @user.recyclings.empty?\n\t\t\tflash[:notice] = \"Please complete the Recycling survey to continue\"\n\t\t\tredirect_to new_user_recycling_path\n\t\tend\n\n\t\tif @user.travels.empty?\n\t\t\tflash[:notice] = \"Please complete the Travel survey to continue\"\n\t\t\tredirect_to new_user_travel_path\n\t\tend\n\t\n\n\t\t# @profile = @user.profiles\n\t \t@profiles = Profile.all\n\t\t@profile = Profile.last(params[:profile])\n\t\t\n\t\t@utility = @user.utilities\n\t\t@utilities = Utility.all\n\t\t\n\t\t@recycling = @user.recyclings\n\t\t@recyclings = Recycling.all\n\n\t\t@travel = @user.travels\n\t\t@travels = Travel.all\n#profile\n\t\t@average_age = Profile.average(:age)\n\t\t@average_total_household_members = Profile.average(:total_household_members)\n\t\t@average_zip = Profile.average(:zip)\n#utlity\n\t\t@average_kwh = Utility.average(:kwh)\n\t\t@average_therms = Utility.average(:therms)\n\t\t@average_gallons = Utility.average(:gallons)\n#recycling\n\t\t@average_local = Recycling.average(:local)\n\t\t@average_compost = Recycling.average(:compost)\n\t\t@average_fabric = Recycling.average(:fabric)\n\t\t@average_ewaste = Recycling.average(:ewaste)\n\n# travel\n\t\t@average_walk = Travel.average(:walk)\n\t\t@average_bicycle = Travel.average(:bicycle)\n\t\t@average_train = Travel.average(:train)\n\t\t@average_bus = Travel.average(:bus)\n\t\t@average_car = Travel.average(:car)\n\t\t@average_plane = Travel.average(:plane)\n\t\t\n# travel totals\n\t\t\n\t\t@user_average_total_travels = Travel.where('user_id = ?', @user.id).average(:total)\n\t\t@user_average_total_utilities = Utility.where('user_id = ?', @user.id).average(:total)\n\t\t@CO2 = (@user_average_total_travels + @user_average_total_utilities) \n\n\t\t@user_average_total_recyclings = Recycling.where('user_id = ?', @user.id).average(:total)\n\t\t@average_total_recyclings = Recycling.average(:total)\n\n\t\t@average_total_travels = Travel.average(:total)\n\t\t@average_total_utilities = Utility.average(:total)\n\t\t@aCO2 = (@average_total_travels + @average_total_utilities) \n\n\t\t\n\n\n\n\t\tend", "def profile; Profile.get(self.profile_id); end", "def can_read?(profile)\n \n can_access?(profile, [2,6])\n \n end", "def get_da_summary(page, da_container, detail_page)\n\n # Todo: Put your code to process the da_container to get the Development Application Summary here\n\n #get info by list item page\n item_general_info = get_item_general_info(page, da_container, detail_page)\n \n #get info by item detail page\n item_detail_info= get_item_detail_info(detail_page)\n\n da_summary = {\n\n 'info_url' => item_general_info[:info_url],\n 'comment_url' => item_general_info[:comment_url],\n 'council_reference' => item_general_info[:council_reference],\n 'address' => item_general_info[:address],\n 'description' => item_general_info[:description],\n 'date_scraped' => item_general_info[:date_scraped],\n\n 'people' => item_detail_info[:people],\n 'property' => item_detail_info[:property],\n 'fee' => item_detail_info[:fee],\n 'decision' => item_detail_info[:decision]\n }\n item_detail_info[:info_group] = get_info_group(detail_page)\n item_detail_info[:info_group].each do |item|\n da_summary[item[:key]] = item[:field]\n end\n return da_summary\n\nend", "def get_da_summary(page, da_container, detail_page)\n\n # Todo: Put your code to process the da_container to get the Development Application Summary here\n\n #get info by list item page\n item_general_info = get_item_general_info(page, da_container, detail_page)\n \n #get info by item detail page\n item_detail_info= get_item_detail_info(detail_page)\n\n da_summary = {\n\n 'info_url' => item_general_info[:info_url],\n 'comment_url' => item_general_info[:comment_url],\n 'council_reference' => item_general_info[:council_reference],\n 'address' => item_general_info[:address],\n 'description' => item_general_info[:description],\n 'date_scraped' => item_general_info[:date_scraped],\n\n 'people' => item_detail_info[:people],\n 'property' => item_detail_info[:property],\n 'fee' => item_detail_info[:fee],\n 'decision' => item_detail_info[:decision]\n }\n item_detail_info[:info_group] = get_info_group(detail_page)\n item_detail_info[:info_group].each do |item|\n da_summary[item[:key]] = item[:field]\n end\n return da_summary\n\nend", "def index\n @profiles = Profile.all\n @user = current_user\n if current_user.profile\n @profile = current_user.profile\n @explores = @profile.explore_categories.uniq\n @guides = @profile.guide_categories.uniq\n @projects = @profile.projects.includes(:categories).sort_by_created_desc\n @explore_ratings = @profile.explore_ratings.includes(:category).sort_by_created_desc.group_by(&:category)\n @guide_ratings = @profile.guide_ratings.includes(:category).sort_by_created_desc.group_by(&:category)\n @new_profile = false\n\n else\n @new_profile = true\n @profile = Profile.new\n @explores = []\n @guides = []\n end\n @filterrific = initialize_filterrific(\n Category,\n params[:filterrific]\n ) or return\n @categories = @filterrific.find.page(params[:page])\n respond_to do |format|\n format.html\n format.js\n end\n @list = current_user.profile.explore_categories.pluck(:id).uniq\n @listg = current_user.profile.guide_categories.pluck(:id).uniq\n\n @category = Category.all\n end", "def show\n redirect_to '/unauthorized' if current_user.blocked_by? User.find(params[:user_id])\n @user = User.find(params[:user_id])\n @dm_profile = @user.dm_profile\n unless @dm_profile.nil?\n @similar_profiles = User.recommender(@dm_profile, \"dm\")\n @similar_profiles = recommend_set(@similar_profiles, @user) & User.location(current_user, \"1\")\n else\n @similar_profiles = nil\n end\n if !@dm_profile\n redirect_to new_user_dm_profiles_path(@user, tutorial: params[:tutorial])\n else\n render 'show'\n end\n end", "def getUsers\r\n if params[:userTerm].blank? \r\n params[:userTerm] = nil\r\n end\r\n if params[:page].nil?\r\n params[:page] = 1\r\n end\r\n if params[:type].blank?\r\n params[:type] = 0 # 0 - ue part. ,1 - exp followers, 2 user following, 3 user followers\r\n end\r\n if params[:id].blank? && !UsersExprience.isExists(params[:id].to_i) && params[:typeview] == 0\r\n params[:id] = 0 # 0 - ue part. , user exp follow , 1 - reported, 2- global\r\n end\r\n users = nil\r\n case params[:type].to_i\r\n when 0\r\n user_existed = ''\r\n if params[:id].to_i != 0\r\n user_existed = UsersExprienceFollowers.following(params[:id].to_i).map(&:users_id).join(\",\") \r\n else \r\n user_existed = UsersExprienceFollowers.following(params[:id].to_i).map(&:user_id).join(\",\") \r\n end\r\n unless UsersExprienceFollowers.following(params[:id].to_i).size != 0\r\n users = UsersFollows.followers(params[:user].id).uniq\r\n else\r\n users = UsersFollows.followers(params[:user].id).where(\"users_follows.user_id not in (\" + user_existed +\")\").uniq\r\n end \r\n when 1 \r\n users = UsersExprienceFollowers.following(params[:id].to_i).uniq\r\n when 2\r\n users = UsersFollows.following(params[:user].id).uniq\r\n else \r\n users = UsersFollows.followers(params[:user].id).uniq\r\n end\r\n unless params[:userTerm].blank? \r\n searchTerms = \"%\" + params[:userTerm].downcase + \"%\"\r\n users = users.where(\"lower(users_profiles.lname) like ? or lower(users_profiles.fname) like ?\",searchTerms,searchTerms)\r\n end \r\n users = users.page(params[:page].to_i).per(APP_CONFIG[\"Max_Page\"])\r\n usersProfile = Array.new\r\n users.each do |item|\r\n userObj = nil\r\n case params[:type].to_i\r\n when 2\r\n userObj = UsersProfile.byUser(item.ref_user_id).first\r\n when 3\r\n userObj = UsersProfile.byUser(item.user_id).first\r\n else\r\n userObj = UsersProfile.byUser(item.id).first\r\n end\r\n\r\n unless userObj.nil?\r\n asset = {\r\n :id => -1,\r\n :uri=> ''\r\n }\r\n unless userObj.image_id.nil?\r\n if userObj.image_id != 0 \r\n assetObj = Assets.where({id:userObj.image_id}).first.asset.url(:small)\r\n asset[:id] = userObj.image_id\r\n asset[:uri] = assetObj\r\n end\r\n end\r\n is_ue = false\r\n is_follow = false\r\n if params[:type].to_i == 1&& !UsersExprience.isExists(params[:id].to_i)\r\n is_uep = !UsersExprienceParticipants.isExists(item.id,params[:id].to_i)\r\n end\r\n if params[:type].to_i == 2 \r\n is_follow = !UsersFollows.isExists(item.user_id,params[:user].id)\r\n end\r\n if params[:type].to_i == 3\r\n is_follow = UsersFollows.isExists(item.user_id,params[:user].id)\r\n end\r\n \tdataHash ={\r\n \t\tfname: userObj.fname,\r\n \t\tlname: userObj.lname,\r\n \t\tid: userObj.user_id,\r\n \t\timage: asset,\r\n status: {\r\n is_follow: is_follow\r\n }\r\n \t}\r\n \tusersProfile.push(dataHash)\r\n end\r\n end\r\n @responseObject = OpenStruct.new({\r\n status: true,\r\n errors: [],\r\n code: API_CODE_ERRORS['Services']['Global']['success'],\r\n objectData: OpenStruct.new({ items: usersProfile, total: users.num_pages }),\r\n timestamp: (Date.new).to_time.to_i.abs\r\n })\r\n \trender :template => 'api/v1/users/members/getUsers' ,:handlers => [:rabl], :formats => [:json]\r\n\tend", "def index\n if current_user.profile.blank?\n redirect_to update_profile_url ,:alert => \"Please fill in required fields.\" \n end\n #all values loaded from load_user filter\n @user = current_user\n @associated_providers = current_user.authentications.map{|authentication| authentication.provider}\n @not_yet_associated_providers = SUPPORTED_PROVIDER - @associated_providers\n \n # this is for feed\n @following_ids = @user.all_following.map{|user| user.id}\n \n @following_ids << current_user.id\n \n\n @feeds = ActivityFeed.where(\"user_id in (?)\",@following_ids).order(\"created_at DESC\").paginate(:per_page => 20,:page => params[:page])\n\n \n end", "def show\n impressionist(@profile)\n @profile = Profile.friendly.find(params[:id])\n\n @profile_urbanterms = @profile.urbanterms.order(\"created_at DESC\") #important! to enable profiles urbanterms on profile\n \n\n end", "def load_profile(name); end", "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 quick_stats\n\tend", "def set_profile\n end", "def show_profile\n if GeneralInfo.exists?(:userKey => params[:id])\n @general_info = GeneralInfo.find_by(userKey: params[:id])\n @general_info_attributes = GeneralInfo.attribute_names\n @general_info_values = @general_info.attribute_values\n \n case @general_info.specific_profile_id\n when 1\n @profile_type = \"Designer\"\n if SpecificDesigner.exists?(:user_key => params[:id])\n @specific_designer = SpecificDesigner.find_by(user_key: params[:id])\n @profile_info = @specific_designer.attribute_values\n else\n #stuff\n end\n when 2\n @profile_type = \"Model\"\n if SpecificModel.exists?(:user_key => params[:id])\n @specific_model = SpecificModel.find_by(user_key: params[:id])\n @profile_info = @specific_model.attribute_values\n else\n #stuff\n end\n when 3\n @profile_type = \"Photographer\"\n if SpecificPhotographer.exists?(:user_key => params[:id])\n @specific_photographer = SpecificPhotographer.find_by(user_key: params[:id])\n @profile_info = @specific_photographer.attribute_values\n else\n #stuff\n end\n else\n puts \"Unknown profile type! Profile type given: \" + @general_info.specific_profile_id\n @profile_type = \"Error\"\n end\n else\n #SHOULD DISPLAY BLANK STUFF!!!!\n @general_info = GeneralInfo.new\n @general_info_values = Hash.new\n end\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 profile_data(uid, field)\n begin\n JSON.parse(RestClient.get construct_url(\"user/#{uid}/#{field}\"))\n rescue RestClient::BadRequest => e\n @last_error = e.http_body\n @last_error_code = e.http_code\n false\n end \n end", "def profile_example_summaries()\n \"\"\nend", "def filters\n # Call model column on self (metadata since element in array is a string, not a variable hence we use send) <=> self.send(profile) == true\n %w[sight_seeing_adventurer art_lover serial_shopper nature_lover food_addict sport_lover history_passionate tech_fan relaxed city_wanderer].select! {|profile| send(profile) == true }\n end", "def profile(username = nil, uid = nil)\n\n end", "def getInfoProfiles\r\n @data = Hash.new\r\n @@wait.until{@@driver.find_element(:css =>\".filters-button\")}\r\n @sections= @@driver.find_elements(:css => \"[data-qa=freelancer]\")\r\n @i=0\r\n @sections.each do |section|\r\n datosPro = {\r\n \"Country\" => section.find_element(:css => \"strong.d-none.d-md-inline-block\").attribute(\"innerText\").strip,\r\n \"Title\" => section.find_element(:css => \"[data-qa='tile_title']\").attribute(\"innerText\").strip,\r\n \"Salary\" => section.find_element(:css =>\"strong[class='pull-left']\").attribute(\"innerText\").strip,\r\n \"Skills\"=> getSkills(section.find_elements(:css =>(\"[data-log-label='skill pill']\")))\r\n }\r\n @data.store(@i, datosPro )\r\n @i=@i+1\r\n end\r\n return @data\r\n end", "def mybb_signups\n @user_pages, @users = paginate :users, :per_page => 40, :conditions => \"q_hear is not null\", :order => \"id desc\"\n end", "def page_users(context='access')\n usrs = []\n self.where(active: true).find_each do |u|\n usrs << Secure::UserProfile.new(u)\n end\n usrs\n rescue Exception => e\n Rails.logger.error(\" #{self.name.to_s}.#{__method__}() returns: #{e.class.name} msg: #{e.message}\")\n []\n end", "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 show\n @profile = Profile.includes(:user).friendly.find(params[:id])\n @user = @profile.user\n @explores = @profile.explore_categories.uniq\n @guides = @profile.guide_categories.uniq\n @explore_categories = @profile.explore_categories.uniq\n @guide_categories = @profile.guide_categories.uniq\n @projects = @profile.projects\n @explore_ratings = @profile.explore_ratings.includes(:category).sort_by_created_desc.group_by(&:category)\n @guide_ratings = @profile.guide_ratings.includes(:category).sort_by_created_desc.group_by(&:category)\n end", "def profileName \n \"profileName\" \n end", "def get_item_general_info(page, da_container, detail_page)\n\n #get td item that contains detail general info\n\n tds = da_container.search('td')\n item_general_info = {}\n item_general_info[:info_url] = get_info_url(page, tds)\n item_general_info[:council_reference] = get_council_reference(tds)\n item_general_info[:comment_url] = get_comment_url(tds)\n item_general_info[:address] = get_address(tds)\n item_general_info[:description] = get_description(detail_page, tds)\n item_general_info[:date_scraped] = get_date_scraped\n return item_general_info\n\nend", "def get_item_general_info(page, da_container, detail_page)\n\n #get td item that contains detail general info\n\n tds = da_container.search('td')\n item_general_info = {}\n item_general_info[:info_url] = get_info_url(page, tds)\n item_general_info[:council_reference] = get_council_reference(tds)\n item_general_info[:comment_url] = get_comment_url(tds)\n item_general_info[:address] = get_address(tds)\n item_general_info[:description] = get_description(detail_page, tds)\n item_general_info[:date_scraped] = get_date_scraped\n return item_general_info\n\nend", "def profile_mode\n super\n end", "def profile_mode\n super\n end", "def find_profile\n\t\t# Find particular Profile \n\t\t@profile = Profile.find(params[:id])\n\tend", "def chargeable_profiles\n profile ? [profile] : []\n end", "def get_item_detail_info(detail_page)\n\n item_detail_info = {}\n #get detail info by approciate syn_fieldsetItem\n item_detail_info[:info_group] = get_info_group(detail_page)\n item_detail_info[:people] = get_people(detail_page)\n item_detail_info[:property] = get_property(detail_page)\n item_detail_info[:fee] = get_fee(detail_page)\n item_detail_info[:decision] = get_decision(detail_page)\n return item_detail_info\n\nend", "def get_item_detail_info(detail_page)\n\n item_detail_info = {}\n #get detail info by approciate syn_fieldsetItem\n item_detail_info[:info_group] = get_info_group(detail_page)\n item_detail_info[:people] = get_people(detail_page)\n item_detail_info[:property] = get_property(detail_page)\n item_detail_info[:fee] = get_fee(detail_page)\n item_detail_info[:decision] = get_decision(detail_page)\n return item_detail_info\n\nend", "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 details; end", "def index\n\n # @profile = Profile.where(user_id: current_user.id).first\n @profile = Profile.find_by(user_id: current_user.id)\n # these above two lines work in same\n \n # there is difference between .where and .find_by and .find methodes\n # .where return an array. to be able to read this array we need to a loop (eg. each loop) or .first .last or [0] methodes\n # .find_by return the first object found.\n # . find return the object the object we are looking for\n\n # example:\n # Person table\n # id| name\n # 1| luke\n # 2| Mathew\n # 3| Ali\n # 4| luke\n # 5| Ali\n # 6| Ali\n\n # person.find (id:1) return luke\n # Person.find_by (first_name:\"ALi\") returen ALi just for id: 3\n # person.where(first_name:\"ali\") return [Ali,ALi,ALi]\n\n # more information :\n # http://guides.rubyonrails.org/active_record_querying.html\n\n end", "def show\n @company = Company.friendly.find(params[:id])\n #@profile_photos = @profile.photos.order(\"created_at DESC\") #important! to enable users posts on user profile\n @company_jobs = @company.jobs #paginate(page: params[:page], per_page: 5)\n @company_listings = @company.listings #paginate(page: params[:page], per_page: 5)\n @company_profiles = @company.profiles #paginate(page: params[:page], per_page: 5)\n\n impressionist(@company)\n #@how = How.find(params[:id])\n \n end", "def index\n if @profile == current_profile\n @filters = @profile.filters\n else\n @filters = @profile.filters.opt_in\n end\n end", "def each_dataset_profile_advance(&blk)\n each_dataset { |ds| blk.call(ds.profile_advance) }\n end", "def getUserProfile(uid)\r\n uri = sprintf(\"/api/v1/users/%d/profile\",uid)\r\n dbg(uri)\r\n profile = $canvas.get(uri)\r\n return profile\r\nend", "def getUserProfile(uid)\r\n uri = sprintf(\"/api/v1/users/%d/profile\",uid)\r\n dbg(uri)\r\n profile = $canvas.get(uri)\r\n return profile\r\nend", "def initialise_profile(page)\r\n @profile[:name] = Helper.get_name(page)\r\n @profile[:server] = Helper.get_server(page)\r\n @profile[:introduction] = Helper.get_introduction(page)\r\n @profile[:title] = Helper.get_title(page)\r\n @profile[:portrait] = Helper.get_portrait(page)\r\n @profile[:hp] = Helper.get_hp(page)\r\n @profile[:mp] = Helper.get_mp(page)\r\n @profile[:tp] = Helper.get_tp(page)\r\n @profile[:sex] = Helper.get_sex(page)\r\n @profile[:race] = Helper.get_race(page)\r\n @profile[:clan] = Helper.get_clan(page)\r\n @profile[:nameday] = Helper.get_nameday(page)\r\n @profile[:guardian] = Helper.get_guardian(page)\r\n @profile[:city] = Helper.get_city(page)\r\n @profile[:grand_company] = Helper.get_grand_company(page)\r\n @profile[:free_company] = Helper.get_free_company(page)\r\n @profile[:disciple] = DiscipleList.new(page.xpath(\"//table[@class='class_list']/tr/td\"))\r\n @profile[:gear] = GearList.new(page.xpath(\"(//div[@class='item_detail_box'])[position() < 14]\"))\r\n @profile[:attribute] = AttributeList.new(page.xpath('//div[starts-with(@class, \"param_left_area_inner\")]/ul/li'))\r\n @mounts = CollectableList.new(page.xpath('(//div[@class=\"minion_box clearfix\"])[1]/a'))\r\n @minions = CollectableList.new(page.xpath('(//div[@class=\"minion_box clearfix\"])[2]/a'))\r\n end", "def index\n @retail_buyer_profile = @profile if (params[:from] && params[:from] == \"buyer_leads\" )\n @page_number = (params[:page_number] || \"1\").to_i\n @result_filter = (params[:result_filter] || \"all\")\n default_sort_type = @profile.owner? ? \"has_profile_image,desc\" : \"privacy,desc\"\n @sort = (params[:sort] || default_sort_type)\n @sort_type = @sort.split(',')[0]\n @sort_order = @sort.split(',')[1]\n @sort_string = \"#{@sort_type} #{@sort_order}\"\n @offset = @page_number == 1 ? nil : (@page_number-1) * PROFILES_PER_PAGE\n @listing_type = params[:listing_type] || \"all\"\n @listing_type = \"all\" if @listing_type.empty?\n\n # Fetch results, with custom pagination support\n @profiles,@total_profiles_fetched,@total_pages = MatchingEngine.get_matches(:profile=>@profile, :offset=>@offset, :result_filter=>@result_filter, :number_to_fetch=> PROFILES_PER_PAGE, :sort=>@sort_string, :listing_type=>@listing_type, :use_cache => true)\n\n unless (@profile.is_wholesale_profile? or @profile.is_wholesale_owner_finance_profile?)\n offset,number_to_fetch = Profile.get_limit_and_offset(@total_profiles_fetched,@page_number,PROFILES_PER_PAGE)\n #Near Match\n if @result_filter=='all' || @result_filter=='new'\n @near_profiles,@near_total_profiles,@near_total_pages = MatchingEngine.get_matches(:profile=>@profile, :offset=>offset, :result_filter=>@result_filter, :number_to_fetch=> number_to_fetch, :sort=>@sort_string, :listing_type=>@listing_type, :use_cache => true, :near_match => true)\n else\n @near_profiles,@near_total_profiles,@near_total_pages = NearMatchingEngine.get_near_matches(:profile=>@profile, :offset=>offset, :result_filter=>@result_filter, :number_to_fetch=> number_to_fetch, :sort=>@sort_string, :listing_type=>@listing_type)\n end\n else\n @near_profiles,@near_total_profiles,@near_total_pages = [], 0, 0\n end\n\n if @result_filter=='all' || @result_filter=='new' || @result_filter=='favorites'\n @total_pages = ( (@total_profiles_fetched.to_i + @near_total_profiles.to_i) / PROFILES_PER_PAGE.to_i)\n @total_pages += 1 if ((@total_profiles_fetched.to_i + @near_total_profiles.to_i) % PROFILES_PER_PAGE.to_i) != 0\n @total_pages = 1 if @total_pages == 0\n end\n # Prime the profile models for their display purpose\n @profiles.each { |profile| profile.prepare_for_match_display(@profile, profile_profile_view_path(@profile, profile))}\n\n # prepare the map\n @map = ZipCodeMap.prepare_map(@profiles.first.zip_code.to_s) unless @profiles.first == nil\n @map = ZipCodeMap.prepare_map(@profile.zip_code.to_s) if @profiles.first == nil\n\n @boundary_overlays = ZipCodeMap.prepare_boundary_overlays(@profile.zip_code.to_s)\n\n @marker_overlays = ZipCodeMap.prepare_marker_overlays(@profiles, :context_profile=>@profile, :return_params=>encode_return_dashboard_variables) unless @profiles.first == nil\n @marker_overlays = [] if @profiles.first == nil\n\n respond_to do |format|\n format.html do\n # if we need some special javascript to update the buyer map, change this call to render a different partial\n # with this call embeded within\n render :partial=>\"#{@profile.profile_type.permalink_to_generic_page}_matches\" and return if request.xhr?\n end\n format.xml { render :xml => @profiles.to_xml }\n format.json { render :json => @profiles.to_json(:only=>[:id], :methods =>[:display_name, :display_type, :display_description, :display_features, :display_price, :display_is_favorite, :display_details_uri]) }\n end\n end", "def get_user_profile(uid,fields)\n begin\n @user_details = graph.get_object(\"#{uid}\",\"fields\" => \"#{fields}\")\n rescue Exception => e\n error(\"get_user_profile :: #{e.message}\")\n end\n end", "def is_base_profile\n super\n end", "def is_base_profile\n super\n end", "def is_base_profile\n super\n end", "def is_base_profile\n super\n end", "def is_base_profile\n super\n end", "def is_base_profile\n super\n end", "def is_base_profile\n super\n end", "def is_base_profile\n super\n end", "def index\n\n sort_columns = {\n 'default' => 'latest_github_activity_at',\n 'github-joined' => 'github_created_at',\n 'github-followers' => 'followers'\n }\n\n params[:sort_order] = params[:sort_order] || 'desc'\n\n if params[:sort_by].present?\n order_by_string = \"#{sort_columns[params[:sort_by]]} #{params[:sort_order].upcase}\"\n else\n order_by_string = \"#{sort_columns['default']} #{params[:sort_order].upcase}\"\n end\n\n if params[:language].present?\n\n language = Language.find_by(slug: params[:language])\n @profiles = language.profiles.includes([:code_wars_datum, :languages]).reorder(order_by_string).paginate(:page => (params[:page] || 1), :per_page => 100)\n\n elsif params[:username].present?\n\n @profiles = Profile.includes([:code_wars_datum, :languages]).search(params[:username]).reorder(order_by_string).paginate(:page => (params[:page] || 1), :per_page => 100)\n\n else\n\n @profiles = Profile.includes([:code_wars_datum, :languages]).reorder(order_by_string).paginate(:page => (params[:page] || 1), :per_page => 100)\n\n end\n\n end", "def get_profile_configuration(args = {}) \n get(\"/profiles.json/#{args[:profileId]}/configuration\", args)\nend", "def profile\n # grab the username from the URL as :id\n @user = User.find(session[:user_id])\n #@followers = Relationship.all.where(\"followed_id = ?\", User.find_by_username(params[\"id\"]).id)\n #@following = Relationship.all.where(\"follower_id = ?\", User.find_by_username(params[\"id\"]).id)\n #@posts = Post.all.where(\"user_id = ?\", User.find_by_username(params[\"id\"]).id)\n end", "def get_infos\n #detail = Info.find_by_status(true).detail\n #if detail \n # return detail\n #else\n # return \"wating for updatting.....\"\n #end\n info = Info.random_to_show_info\n return info.detail\n\n end", "def profile\n # Current logged in trader\n @current = current_trader\n # Trader whose profile page it is\n @trader = Trader.find(params[:id])\n # All active buy it now posts (newest first)\n @posts = Post.where(trader_id: @trader.id).where(active:true).where(auction:false).order(created_at: :desc)\n # All active auction posts (newest first)\n @auctions = Post.where(trader_id: @trader.id).where(active:true).where(auction:true).order(created_at: :desc)\n # All auctions the trader is currently winning\n @winning_auctions = Post.where(active:true).where(auction:true).where(highest_bidder: @trader.id)\n # All bids the trader has made\n @bids = Bid.where(trader_id: current_trader)\n # All items the trader has sold (newest first)\n @sold = Trade.all.order(time: :desc).select { |m| m.post.trader == @trader}\n # All items the trader has bought (newest first)\n @bought = Trade.where(trader_id: @trader.id).order(time: :desc)\n # All samples that the trader has had requested of them\n @requested_samples = Request_Sample.where(seller_id: @trader.id).select { |m| m.post.trader == @trader}\n # All categories the trader is approved to buy in\n @approvedBuy = ApprovedBuyCat.where(trader_id: @trader.id).where(status: '1')\n # All categories the trader is approved to sell in\n @approvedSell = ApprovedSellCat.where(trader_id: @trader.id).where(status: '1')\n # The overall rating of the trader\n ratings = Trade.includes(:post).where(posts: { trader_id: @trader.id} ).collect{|m| m.rating.to_i}.compact\n length = ratings.collect{|m| if m != 0\n m\n end}.compact.length\n\n @rating = ratings.sum.to_f / (length == 0? 1 : length)\n if @rating == nil\n @rating = 0\n end\n end", "def _profile\n @link['profile']\n end", "def profile_info_items(user)\n occupation = [\"Occupation\", user.occupation]\n company = [\"Company\", user.company]\n location = [\"Location\", user.location]\n birthday = [\"Birthday\", user.birthday? ? user.birthday.strftime(\"%m/%d/%Y\") : nil]\n [ occupation, company, location, birthday ]\n end", "def load_profile_data\n @profile_data = Nokogiri::HTML(open(\"#{PROFILE_URI}/#{@uid}\"))\n end", "def profile_name\n return self.profile.name\n end", "def profile_name\n name.present? ? name : identifier\n end", "def probers; end", "def pager; end", "def dump_profile(_profile); end", "def get_user_data\n raise NotImplementedError\n end" ]
[ "0.637077", "0.6257748", "0.6257748", "0.5986313", "0.5986313", "0.5986313", "0.5986313", "0.5986313", "0.5986313", "0.5930492", "0.58486456", "0.5842035", "0.5842035", "0.5834898", "0.5795784", "0.57316446", "0.5707439", "0.5523409", "0.54929745", "0.54835665", "0.5441558", "0.5388782", "0.53824824", "0.53824824", "0.534856", "0.53280264", "0.5312267", "0.5305886", "0.5301925", "0.52797735", "0.5239089", "0.5236488", "0.5236488", "0.5233159", "0.52015847", "0.51874083", "0.5175108", "0.51585877", "0.51585877", "0.51513296", "0.5140407", "0.5135455", "0.51275605", "0.51261926", "0.51210904", "0.5120616", "0.5085868", "0.5085428", "0.5084803", "0.5084099", "0.50729126", "0.5060243", "0.5051342", "0.5039451", "0.5037555", "0.5033759", "0.50330544", "0.50163245", "0.5002561", "0.5000903", "0.4999852", "0.4999852", "0.4991486", "0.4991486", "0.49708888", "0.49687952", "0.4963235", "0.4963235", "0.4961985", "0.496029", "0.4959877", "0.49549976", "0.494248", "0.49418", "0.49373156", "0.49373156", "0.49353763", "0.49330688", "0.49256852", "0.49235615", "0.49235615", "0.49235615", "0.49235615", "0.49235615", "0.49235615", "0.49235615", "0.49235615", "0.492303", "0.49223366", "0.49221665", "0.49186504", "0.49130586", "0.48835808", "0.4880503", "0.4880349", "0.48717836", "0.48681355", "0.4868088", "0.4867661", "0.4862048", "0.4860806" ]
0.0
-1
Version Modules ECC Level Data bits Numeric Alfanumeric Binary Kanji 1 21x21 L 152 41 25 17 10 M 128 34 20 14 8 Q 104 27 16 11 7 H 72 17 10 7 4 ... 40 177x177 L 23,648 7,089 4,296 2,953 1,817 M 18,672 5,596 3,391 2,331 1,435 Q 13,328 3,993 2,420 1,663 1,024 H 10,208 3,057 1,852 1,273 784
def module_size @version * 4 + 17 end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "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 level_for(binary_code)\n binary_code_length = binary_code.to_s(2).length\n binary_code_length += 1 unless binary_code_length.even?\n binary_code_length / 2\n end", "def sbc_a_hl\n end", "def kex_byte_requirement; end", "def get_coeffs\n (\"%0#{DIGITS}d\" % [self]).chars.map(&:to_i)\n end", "def binary_version; end", "def eccentricity\n (\"0.\"+@line2[26...33]).to_f\n end", "def pack_data value\r\n [value].pack('l>').split('').map(&:ord)\r\nend", "def version\n return ExtKey.version_from_purpose(number) if depth == 1\n ver ? ver : Bitcoin.chain_params.extended_privkey_version\n end", "def get_node_type_and_version_abca\n # Yes, it's reverse endian\n a, = @data[@ofs-1, 2].unpack(\"n\")\n @ofs += 1\n version = (a >> 9) & 0x0f\n node_type = @node_types[a & 0x1ff]\n version = nil if version == DefaultVersions[node_type]\n [node_type, version]\n end", "def get_data\n gamma = @data[0..3].unpack(\"C*\")\n gamma = Shared::interpret_bytes_4(gamma)/100000.0\n return gamma\n end", "def vvec( ver )\n\t\treturn ver.split('.').collect {|char| char.to_i }.pack('N*')\n\tend", "def vvec( ver )\n\t\treturn ver.split('.').collect {|char| char.to_i }.pack('N*')\n\tend", "def vvec( ver )\n\t\treturn ver.split('.').collect {|char| char.to_i }.pack('N*')\n\tend", "def vvec( ver )\n\t\treturn ver.split('.').collect {|char| char.to_i }.pack('N*')\n\tend", "def vvec( ver )\n\t\treturn ver.split('.').collect {|char| char.to_i }.pack('N*')\n\tend", "def vvec( ver )\n\t\treturn ver.split('.').collect {|char| char.to_i }.pack('N*')\n\tend", "def cp_hl\n end", "def version_hex\n @version_hex ||= control_transfer(function: :version, dataIn: 1).unpack('c').first\n end", "def version\n @version ||= version_hex.to_s(16).chars.entries.join('.')\n end", "def verification_code\n raise ArgumentError, 'Hash is not set' if @hash.nil?\n\n binary = @hash.unpack1('B*').split //\n [*binary.first(6), *binary.last(7)].join.to_i(2)\n end", "def ins_find_initial_exponent(nbits)\n nbits = nbits / 2 + 2 while nbits > 53\n nbits\nend", "def allowed_number_of_ebt_card_digits\n [16]\n end", "def allowed_number_of_ebt_card_digits\n [16]\n end", "def bits\n Net::SSH::Buffer.from(:key, @key).to_s.split(\"\\001\\000\").last.size * 8\n end", "def bits\n Net::SSH::Buffer.from(:key, @key).to_s.split(\"\\001\\000\").last.size * 8\n end", "def bsb_number; end", "def initialize( n, p=0.01, b=8 )\n @n, @p, @b = n, p, b\n @m = ( -(@n * Math.log(@p) / (Math.log(2)**2)) ).ceil\n @k = (0.7 * (@m/@n)).round\n @bit_fields = \"\\0\" * (@m/@b + 1)\n end", "def version\n return ExtPubkey.version_from_purpose(number) if depth == 1\n ver ? ver : Bitcoin.chain_params.extended_pubkey_version\n end", "def g3\n [0x00, 0x03, 0x06, 0x05, 0x0c, 0x0f, 0x0a, 0x09, 0x18, 0x1b, 0x1e, 0x1d, 0x14, 0x17, 0x12, 0x11,\n 0x30, 0x33, 0x36, 0x35, 0x3c, 0x3f, 0x3a, 0x39, 0x28, 0x2b, 0x2e, 0x2d, 0x24, 0x27, 0x22, 0x21,\n 0x60, 0x63, 0x66, 0x65, 0x6c, 0x6f, 0x6a, 0x69, 0x78, 0x7b, 0x7e, 0x7d, 0x74, 0x77, 0x72, 0x71,\n 0x50, 0x53, 0x56, 0x55, 0x5c, 0x5f, 0x5a, 0x59, 0x48, 0x4b, 0x4e, 0x4d, 0x44, 0x47, 0x42, 0x41,\n 0xc0, 0xc3, 0xc6, 0xc5, 0xcc, 0xcf, 0xca, 0xc9, 0xd8, 0xdb, 0xde, 0xdd, 0xd4, 0xd7, 0xd2, 0xd1,\n 0xf0, 0xf3, 0xf6, 0xf5, 0xfc, 0xff, 0xfa, 0xf9, 0xe8, 0xeb, 0xee, 0xed, 0xe4, 0xe7, 0xe2, 0xe1,\n 0xa0, 0xa3, 0xa6, 0xa5, 0xac, 0xaf, 0xaa, 0xa9, 0xb8, 0xbb, 0xbe, 0xbd, 0xb4, 0xb7, 0xb2, 0xb1,\n 0x90, 0x93, 0x96, 0x95, 0x9c, 0x9f, 0x9a, 0x99, 0x88, 0x8b, 0x8e, 0x8d, 0x84, 0x87, 0x82, 0x81,\n 0x9b, 0x98, 0x9d, 0x9e, 0x97, 0x94, 0x91, 0x92, 0x83, 0x80, 0x85, 0x86, 0x8f, 0x8c, 0x89, 0x8a,\n 0xab, 0xa8, 0xad, 0xae, 0xa7, 0xa4, 0xa1, 0xa2, 0xb3, 0xb0, 0xb5, 0xb6, 0xbf, 0xbc, 0xb9, 0xba,\n 0xfb, 0xf8, 0xfd, 0xfe, 0xf7, 0xf4, 0xf1, 0xf2, 0xe3, 0xe0, 0xe5, 0xe6, 0xef, 0xec, 0xe9, 0xea,\n 0xcb, 0xc8, 0xcd, 0xce, 0xc7, 0xc4, 0xc1, 0xc2, 0xd3, 0xd0, 0xd5, 0xd6, 0xdf, 0xdc, 0xd9, 0xda,\n 0x5b, 0x58, 0x5d, 0x5e, 0x57, 0x54, 0x51, 0x52, 0x43, 0x40, 0x45, 0x46, 0x4f, 0x4c, 0x49, 0x4a,\n 0x6b, 0x68, 0x6d, 0x6e, 0x67, 0x64, 0x61, 0x62, 0x73, 0x70, 0x75, 0x76, 0x7f, 0x7c, 0x79, 0x7a,\n 0x3b, 0x38, 0x3d, 0x3e, 0x37, 0x34, 0x31, 0x32, 0x23, 0x20, 0x25, 0x26, 0x2f, 0x2c, 0x29, 0x2a,\n 0x0b, 0x08, 0x0d, 0x0e, 0x07, 0x04, 0x01, 0x02, 0x13, 0x10, 0x15, 0x16, 0x1f, 0x1c, 0x19, 0x1a][self]\n end", "def sbc_a_d8\n end", "def evidence_to_binary(e)\n\tb = Hash.new(\"0\")\n\te.each_char do |i|\n\t\tb[i] = \"1\"\n\tend\n\n\tbinary = \"0000\"\n\tbinary[0] = b['N']\n\tbinary[1] = b['S']\n\tbinary[2] = b['W']\n\tbinary[3] = b['E']\n\tbinary\nend", "def firmware_version\n buffer = PN532::DataBuffer.new\n PN532.get_firmware_version(pn_struct, buffer)\n buffer[1..3]\n end", "def encryption_control_information\n \"Version: 1\"\n end", "def sbc_a_h\n end", "def levels\n levels = [\n \"1.1.1\",\n \"1.2.2\",\n \"1.3.1\",\n \"1.3.2\",\n \"2.1.1\",\n \"2.1.2\",\n \"2.2.1\",\n \"2.3.1\",\n \"2.4.1\",\n \"2.4.2\",\n \"2.4.3\",\n \"2.4.4\",\n \"3.1.1\",\n \"3.2.1\",\n \"3.3.2\",\n \"4.1.1\",\n \"4.1.2\",\n \"1.4.3\",\n \"1.4.4\",\n \"1.4.5\",\n \"2.4.6\",\n \"3.1.2\",\n \"3.2.4\",\n \"1.4.6\",\n \"1.4.8\",\n \"2.1.3\",\n \"2.2.4\",\n \"2.3.2\",\n \"2.4.10\",\n \"2.4.9\",\n \"2.5.5\",\n \"3.1.4\",\n \"3.1.5\",\n \"3.2.5\"\n ]\n return levels\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 vvec( version_string )\n\t\t\treturn version_string.split( '.' ).\n\t\t\t\tcollect {|num| num.to_i }.pack( 'N*' )\n\t\tend", "def eka_version\n if @version.first < 8\n 1\n elsif @version.first > 8\n 2\n elsif @version.last == \"a\"\n 1\n elsif @version.last == \"b\"\n 2\n else\n raise\n end\n end", "def kidmod10(base); end", "def crc; end", "def crc; end", "def crc; end", "def msg_version; @msg_version ||= PackedHeader.new(1, 'C').encode(VERSION); end", "def exponent; end", "def ld_mhl_n\n @mmu[hl] = next_byte\n @clock += 3\n end", "def poly8_types\n [\\\n [ 1 ], # 0 core\n [ 2, 65, 17, 5, 3, 33, 9, 129 ], # 1 centers 2^8\n [ 4, 97, 25, 7, 130, 193, 49, 13 ], # 2, 2 grips adjacent. Even Permutation. Factorial(8)/2. No orientation.\n [ 6, 81, 21, 66, 11, 41, 131, 161], # 3 -- 2 grips spaced out by 1. Two orbits. In each orbit: even perm. No flip. (Factorial(4)/2)^2\n [ 10, 73, 19, 133, 34, 67, 145, 37 ], # 4 -- 2 grips spaced out by 2. Even permutation. No flip. (Factorial(8)/2)\n [ 18, 69, 35, 137 ], # 5 -- 2 grips spaced out by 3 aka center bars. Tied to type 1\n [ 8, 113, 29, 194, 15, 57, 132, 225 ], # 6 -- 3 grips adjacent, two orbits. Perm tied to type 3, double flip in each orbit. (2^3)^2\n [ 22, 85, 70, 82, 43, 139, 163, 169 ], # 7 -- 3 grips with one grip between each. Two orbits. Each orbit contributes two. Just like 4-axis. 4\n [ 42, 75, 147, 165, 38, 83, 149, 74 ], # 8 -- 3 grips with two grips between each. Two orbits, perm tied to type 3 and 6. Double flip in each orbit. (2^3)^2\n [ 12, 105, 27, 135, 162, 195, 177, 45, 14, 89, 23, 134, 98, 68, 209, 53 ], # 9 -- 3 grips (chiral pieces with 1-wide gap). 16 pieces in two orbits. Even perm in each orbit. No flip (Factorial(8)/2)^2\n [ 20, 101, 26, 71, 146, 197, 50, 77, 36, 99, 153, 39, 138, 201, 51, 141 ], # 10 -- 3 grips (chiral pieces with 2-wide gap). 16 pieces in two orbits. Even perm in each orbit. No flip (Factorial(8)/2)^2\n [ 16, 121, 31, 136, 226, 196, 241, 61 ], # 11 -- 4 grips adjacent. Even perm, no flip. (Factorial(8)/2)\n [ 46, 91, 151, 166, 106, 76, 211, 181 ], # 12 -- 4 grips in one 1-gap two 1-gap one. Self-anti. Even perm. no flip. (Factorial(8)/2)\n [ 28, 109, 199, 178, 55, 142, 100, 217 ], # 13 -- 4 grips split into 2 groups seperated by a 1-wide gap. Two orbits. In each orbit, even perm, double flip. (Factorial(4)/2 * 2^3)^2\n [ 52, 103, 154, 205 ], # 14 -- 4 grips split into 2 groups separated by a 2-wide gap. Self-anti. Even perm. double flip: remote flip, flipping with antipode. (Factorial(4)/2 * 2^3)\n [ 40, 115, 157, 202, 58, 79, 148, 229 ], # 15 -- 4 grips, three adjacent on top, loner on bottom. Two orbits, perm tied to type 3. In each orbit: no more perm, no flip (orientation tied to center bars?). REDUNDANT\n [ 24, 117, 30, 72, 210, 198, 114, 93, 47, 59, 143, 164, 233, 140, 227, 185 ], # 16 -- 4 grips, three, 1-gap, one. Two orbits. Even perm in each. No flip. (Factorial(8)/2)^2\n [ 44, 107, 155, 167, 170, 203, 179, 173, 54, 87, 150, 102, 90, 78, 84, 213 ], # 17 -- 4 grips, two, 1-gap, one, 1-gap, one. Two orbits. Even perm in each. No flip. (Factorial(8)/2)^2\n [ 86, 171 ], # 18 -- 4 grips, windmill. [One, one gap] * 4. Self-anti. REDUNDANT\n [ 60, 111, 156, 231, 186, 207, 180, 237, 56, 119, 158, 104, 218, 206, 116, 221 ], # 19 -- 5 grips, anti-3 grips (chiral pieces with 2-wide gap). anti type 10. 16 pieces in two orbits. Even perm in each orbit. No flip (Factorial(8)/2)^2\n [ 62, 95, 152, 230, 122, 80, 212, 245, 48, 123, 159, 168, 234, 204, 243, 189 ], # 20 -- 5-grips, anti-3 grips (chiral pieces with 1-wide gap). anti type 9. 16 pieces in two orbits. Even perm in each orbit. No flip (Factorial(8)/2)^2\n [ 92, 110, 215, 182, 108, 219, 183, 174 ], # 21 -- 5-grips, anti-3 grips with two grips between each. anti type 8. Two orbits. Perm tied to type 13. double flip in each orbit. (2^3)^2\n # jump to type 29 to continue analysis\n\n [ 172, 235, 187, 175, 88, 118, 94, 214 ], # 22 -- 5-grips, anti-3 grips with one grip between each. anti type 7. Two orbits. Factor of 2. Don't understand.\n [ 32, 125, 200, 242, 63, 144, 228, 249 ], # 23 -- 5-grips, anti-3 grips adjacent, anti type 6, Two orbits. Perm tied to type 13. no flip given inner rings. redundant\n [ 188, 239, 120, 222 ], # 24 -- 6-grips, anti-2 grips spaced out by 3, anti type 5. anti center bars. redundant\n [ 112, 124, 223, 184, 238, 220, 247, 190 ], # 25 -- 6-grips, anti-2 grips spaced out by 2, anti type 4. Even Permutation. Factorial(8)/2. No flip.\n [ 176, 251, 191, 236, 96, 126, 216, 246 ], # 26 -- 6-grips, anti-2 grips spaced out by 1, anti type 3. Perm tied to type 13, no flip (flip tied to center bars), redundant.\n [ 64, 127, 160, 232, 250, 208, 244, 253 ], # 27 -- 6-grips, anti-2 grips adjacent, anti type 2. Even Permutation. Factorial(8)/2. No flip.\n [ 128, 224, 248, 254, 192, 255, 240, 252 ], # 28 -- 7-grips, anti-1 grip, anti type 1. Two orbits. Given type 29 and type 1, each orbit has 2^2. total factor 2^4\n [ 256 ]] # 29 anti core. Only two rotational states, given that type 1 pieces are solved.\n end", "def sbc_a_l\n end", "def decodeBits(bits)\n array_of_bits = bits.each_char.slice_when(&:!=).map(&:join)\n array_of_bits.shift if bits[0] == \"0\"\n array_of_bits.pop if bits[bits.length-1] == \"0\"\n rate_of_transmission = array_of_bits.min {|elem1,elem2| elem1.size <=> elem2.size}.length\n bit_to_morse_dict = {\n \".\": \"1\"*rate_of_transmission,\n \"-\": \"1\"*3*rate_of_transmission,\n \"\": \"0\"*rate_of_transmission,\n \" \": \"0\"*3*rate_of_transmission,\n \" \": \"0\"*7*rate_of_transmission\n }\n array_of_bits.map {|str| bit_to_morse_dict.key(str)}.join().to_s\nend", "def decode5(str)\n num = 0\n i = 0\n str.each_char do |char|\n pow = BASE ** (str.length - i -1)\n num += KEYS_HASH[char] * pow\n i += 1\n end\n return num\nend", "def _dearmor6b(c, len = 6)\n val = c.ord\n ret = val - (val >= 96 ? 56 : 48) # Mapped to 2 separate contiguous blocks of ascii, so choose which\n ret.to_s(2).rjust(6, \"0\")[0..(len - 1)]\n end", "def test_normalization_C_pri_29\n [\n [0x0B47, 0x0300, 0x0B3E],\n [0x1100, 0x0300, 0x1161]\n ].map { |c| c.pack('U*') }.each do |c|\n assert_equal c.ui, @handler.normalize(c, :c).ui, \"Composition is implemented incorrectly\"\n end\n end", "def bits\n flavor_info[:bits]\n end", "def autofmt8(value)\n {\n 0x0000 => :XL8_ITBLSIMPLE, # Simple\n 0x0001 => :XL8_ITBLCLASSIC1, # Classic 1\n 0x0002 => :XL8_ITBLCLASSIC2, # Classic 2\n 0x0003 => :XL8_ITBLCLASSIC3, # Classic 3\n 0x0004 => :XL8_ITBLACCOUNTING1, # Accounting 1\n 0x0005 => :XL8_ITBLACCOUNTING2, # Accounting 2\n 0x0006 => :XL8_ITBLACCOUNTING3, # Accounting 3\n 0x0007 => :XL8_ITBLACCOUNTING4, # Accounting 4\n 0x0008 => :XL8_ITBLCOLORFUL1, # Colorful 1\n 0x0009 => :XL8_ITBLCOLORFUL2, # Colorful 2\n 0x000A => :XL8_ITBLCOLORFUL3, # Colorful 3\n 0x000B => :XL8_ITBLLIST1, # List 1\n 0x000C => :XL8_ITBLLIST2, # List 2\n 0x000D => :XL8_ITBLLIST3, # List 3\n 0x000E => :XL8_ITBL3DEFFECTS1, # 3Deffects 1\n 0x000F => :XL8_ITBL3DEFFECTS2, # 3Deffects 2\n 0x0010 => :XL8_ITBLNONE_GEN, # None\n 0x0011 => :XL8_ITBLJAPAN2, # Japan 2\n 0x0012 => :XL8_ITBLJAPAN3, # Japan 3\n 0x0013 => :XL8_ITBLJAPAN4, # Japan 4\n 0x0014 => :XL8_ITBLNONE_JPN, # Japan None\n 0x1000 => :XL8_ITBLREPORT1, # Report 1\n 0x1001 => :XL8_ITBLREPORT2, # Report 2\n 0x1002 => :XL8_ITBLREPORT3, # Report 3\n 0x1003 => :XL8_ITBLREPORT4, # Report 4\n 0x1004 => :XL8_ITBLREPORT5, # Report 5\n 0x1005 => :XL8_ITBLREPORT6, # Report 6\n 0x1006 => :XL8_ITBLREPORT7, # Report 7\n 0x1007 => :XL8_ITBLREPORT8, # Report 8\n 0x1008 => :XL8_ITBLREPORT9, # Report 9\n 0x1009 => :XL8_ITBLREPORT10, # Report 10\n 0x100A => :XL8_ITBLTABLE1, # Table 1\n 0x100B => :XL8_ITBLTABLE2, # Table 2\n 0x100C => :XL8_ITBLTABLE3, # Table 3\n 0x100D => :XL8_ITBLTABLE4, # Table 4\n 0x100E => :XL8_ITBLTABLE5, # Table 5\n 0x100F => :XL8_ITBLTABLE6, # Table 6\n 0x1010 => :XL8_ITBLTABLE7, # Table 7\n 0x1011 => :XL8_ITBLTABLE8, # Table 8\n 0x1012 => :XL8_ITBLTABLE9, # Table 9\n 0x1013 => :XL8_ITBLTABLE10, # Table 10\n 0x1014 => :XL8_ITBLPTCLASSIC, # Table PTClassic\n 0x1015 => :XL8_ITBLPTNONE, # None\n }[value]\n end", "def hexadecimal\n while k.size < @clave.size\n @clave.each do |i|\n #expresion regular que controla si lo que recibe es un caracter numerico o no numerico.\n regex= i.match(/\\A[+-]?\\d+?(\\.\\d+)?\\Z/) == nil ? false : true\n if regex==false\n t_k=i.split(\"\")\n t_k.each do |j|\n k << j.unpack('U')[0].to_s(16)\n end\n else\n @k << sprintf(\"%02X\", i)\n end\n end\n end\n #pasar a hexadecimal el mensaje\n @mensaje.each do |i|\n #expresion regular que controla si lo que recibe es un caracter numerico o no numerico. Y realizar la conversión de una manera u otra.\n regex= i.match(/\\A[+-]?\\d+?(\\.\\d+)?\\Z/) == nil ? false : true\n if regex==false\n t_m=i.split(\"\")\n t_m.each do |j|\n m << j.unpack('U')[0].to_s(16)\n end\n else\n @m << sprintf(\"%02X\", i)\n end\n end\n puts \"\\n BLOQUE HEXADECIMAL DEL MENSAJE:#{@m}\"\n puts \"\\n BLOQUE HEXADECIMAL DE LA CLAVE:#{@k}\"\n end", "def bcd_byte\n [self / 100, (self/10) % 10, self % 10].map{|n| n.chr}.join\n end", "def cp_d8\n end", "def xp_from_hn(p_hn)\n return hc_from_hn(p_hn) * fw + hl_from_hn(p_hn)%2 * rhl\n end", "def gamma_linear\n a = (0..31).each.map { |v| v.chr }.join\n gamma_ctl 61697, a\n end", "def initialize(exponent_hex_string, modulus_hex_string)\n @e = BigNum.from_hex exponent_hex_string\n @n = BigNum.from_hex modulus_hex_string\n @size = (@n.to_hex.length + 1) / 2\n @chunk_cache = {}\n end", "def power_level(x, y)\n ((((x + 10) * y ) + $serial_num) * (x + 10)).digits[2] - 5\nend", "def power_level(x, y)\n ((((x + 10) * y ) + $serial_num) * (x + 10)).digits[2] - 5\nend", "def private_key_16_string\n @mask_1[0..15]\n end", "def yp_from_hn(p_hn)\n return hl_from_hn(p_hn) * (th + hex_side_length)\n end", "def ver\n @values.fetch('ver') { \n @values['ver'] = 1\n }\n end", "def read_bignum; end", "def koreanKey() # Kekekekeke\n\treturn \"\\x63\\xB8\\x2B\\xB4\\xF4\\x61\\x4E\\x2E\\x13\\xF2\\xFE\\xFB\\xBA\\x4C\\x9B\\x7E\"\nend", "def decoder(data)\n result = CKB::Utils.hex_to_bin(data).unpack(\"Q<\")[0]\n return result.to_i\nend", "def bit_strength\n if self.rsa?\n return @cert.public_key.n.num_bits\n elsif self.dsa?\n return @cert.public_key.p.num_bits\n end\n end", "def fbe_body\n 4 + 4 \\\n + byte0.fbe_size \\\n + byte1.fbe_size \\\n + byte2.fbe_size \\\n + byte3.fbe_size \\\n + byte4.fbe_size \\\n + byte5.fbe_size \\\n + char0.fbe_size \\\n + char1.fbe_size \\\n + char2.fbe_size \\\n + char3.fbe_size \\\n + char4.fbe_size \\\n + char5.fbe_size \\\n + wchar0.fbe_size \\\n + wchar1.fbe_size \\\n + wchar2.fbe_size \\\n + wchar3.fbe_size \\\n + wchar4.fbe_size \\\n + wchar5.fbe_size \\\n + int8b0.fbe_size \\\n + int8b1.fbe_size \\\n + int8b2.fbe_size \\\n + int8b3.fbe_size \\\n + int8b4.fbe_size \\\n + int8b5.fbe_size \\\n + uint8b0.fbe_size \\\n + uint8b1.fbe_size \\\n + uint8b2.fbe_size \\\n + uint8b3.fbe_size \\\n + uint8b4.fbe_size \\\n + uint8b5.fbe_size \\\n + int16b0.fbe_size \\\n + int16b1.fbe_size \\\n + int16b2.fbe_size \\\n + int16b3.fbe_size \\\n + int16b4.fbe_size \\\n + int16b5.fbe_size \\\n + uint16b0.fbe_size \\\n + uint16b1.fbe_size \\\n + uint16b2.fbe_size \\\n + uint16b3.fbe_size \\\n + uint16b4.fbe_size \\\n + uint16b5.fbe_size \\\n + int32b0.fbe_size \\\n + int32b1.fbe_size \\\n + int32b2.fbe_size \\\n + int32b3.fbe_size \\\n + int32b4.fbe_size \\\n + int32b5.fbe_size \\\n + uint32b0.fbe_size \\\n + uint32b1.fbe_size \\\n + uint32b2.fbe_size \\\n + uint32b3.fbe_size \\\n + uint32b4.fbe_size \\\n + uint32b5.fbe_size \\\n + int64b0.fbe_size \\\n + int64b1.fbe_size \\\n + int64b2.fbe_size \\\n + int64b3.fbe_size \\\n + int64b4.fbe_size \\\n + int64b5.fbe_size \\\n + uint64b0.fbe_size \\\n + uint64b1.fbe_size \\\n + uint64b2.fbe_size \\\n + uint64b3.fbe_size \\\n + uint64b4.fbe_size \\\n + uint64b5.fbe_size \\\n end", "def version_needed_to_extract\n 0x0014\n end", "def version_needed_to_extract\n 0x0014\n end", "def verify_checksum(hrp, data)\n const = polymod(expand_hrp(hrp) + data)\n case const\n when 1\n Encoding::BECH32\n when BECH32M_CONST\n Encoding::BECH32M\n end\n end", "def pulse_code\n # 64 is just the max number of entries which maybe in there times two\n length = usb_get_pulse_code_length(dataIn:1).unpack('C').first # find out the length of the currently loaded pulse code\n usb_get_pulse_code(dataIn: length * 2).unpack('v*')\n end", "def langrage_coefficients\n # TODO\n end", "def hl_from_hn(p_hn)\n g = (p_hn / (maxcol * 2 - 1)).floor * 2\n r = p_hn%(maxcol * 2 - 1)\n (r >= maxcol) ? g + 1 : g\n end", "def SORTVERSIONFROMLCID(lcid)\n (lcid >> 20) & 0xf\n end", "def _verxlhigh(id)\n {\n 0x0 => :'Excel 97',\n 0x1 => :'Excel 2000',\n 0x2 => :'Excel 2002',\n 0x3 => :'Excel 2003',\n 0x4 => :'Excel 2007',\n 0x6 => :'Excel 2010',\n 0x7 => :'Excel 2013'\n }[id]\n end", "def hash\n str = [major, minor, patch].map do |str|\n str ? str : \"0\"\n end.join(\".\")\n\n if pre\n str = \"#{str}.#{pre}\"\n end\n\n str.hash\n end", "def carray_version\n\n io = open(File.join(File.dirname(__FILE__), \"version.h\"))\n while line = io.gets\n case line \n when /^#define CA_VERSION (.*)$/\n ca_version = $1.strip[1..-2]\n when /^#define CA_VERSION_CODE (.*)$/\n ca_version_code = $1.to_i\n when /^#define CA_VERSION_MAJOR (.*)$/\n ca_version_major = $1.to_i\n when /^#define CA_VERSION_MINOR (.*)$/\n ca_version_minor = $1.to_i\n when /^#define CA_VERSION_TEENY (.*)$/\n ca_version_teeny = $1.to_i\n when /^#define CA_VERSION_DATE (.*)$/\n ca_version_date = $1.strip[1..-2]\n end\n end\n io.close\n\n ca_version2 = format(\"%i.%i.%i\", \n ca_version_major, ca_version_minor, ca_version_teeny)\n ca_version_code2 = \n 100 * ca_version_major + 10*ca_version_minor + ca_version_teeny\n\n if ca_version != ca_version2 or ca_version_code != ca_version_code2\n raise \"invalid version.h\"\n end\n \n return [ca_version, ca_version_date]\nend", "def decimal_digits\n pos0 = @pos\n if (code = @codes[@pos]) >= 0x30 and code <= 0x39\n @pos += 1\n while code = @codes[@pos] and code >= 0x30 and code <= 0x39\n @pos += 1\n end\n return @codes[pos0...@pos].pack(\"U*\")\n else\n nil\n end\n end", "def elv_armulys\n ((@code & 0xFFFF) % 10) <= 4\n end", "def rhl\n return ((hex_side_length - 0.15) * Math.cos(Math::PI / 6)) \n end", "def to_eiscp\n return [ @header[:magic], @header[:header_size], @header[:data_size], @header[:version], @header[:reserved], @iscp_message.to_s].pack(\"A4NNAa3A*\").encode(\"ascii\", :invalid => :replace, :undef => :replace)\n end", "def hc_from_hn(p_hn)\n r = p_hn%(maxcol * 2 - 1)\n return r%maxcol\n end", "def decode4(str)\n num = 0\n str.each_char.with_index do |char, i|\n pow = BASE ** (str.length - i -1)\n num += KEYS_HASH[char] * pow\n end\n return num\nend", "def line_count_experiment\n @letters_two.dump\n lines = @letters_two.xlate(@line_count_map)\n lines << @extra_digits\n lines.flatten!\n lines.dump('append')\n lines.chunk(2).to_i.collect { |d| d.to_s(5) }.dump(:from_base_5).to_i.to_letter\nend", "def value\n return 3*level\n end", "def honeydukes_bulb1\n cert1_24\n end", "def bit_length\n @bit_length ||= ECDSA.bit_length(field.prime)\n end", "def adjust_sp_binary()\n \"@SP\\nM=M-1\\n@SP\\nA=M\\nD=M\\n@SP\\nM=M-1\\nA=M\\n\"\n end", "def ver\n @values['ver']\n end", "def value\n return 15*level\n end", "def bit_strength\n if self.rsa?\n return @spki.public_key.n.num_bits\n elsif self.dsa?\n return @spki.public_key.p.num_bits\n elsif self.ec?\n raise R509::R509Error, 'Bit strength is not available for EC at this time.'\n end\n end", "def kcode() end", "def bootcode\n\t\t\t# /vl/bc.jsp?v=0.0.0.10&m=00:19:db:9e:92:91&l=00:00:00:00:00:00&p=00:00:00:00:00:00&h=4\n\t\t\t#\n\t\t\t# Firmware version, e.g.0.0.0.10\n\t\t\t@version = params[:v]\n\n\t\t\t# MAC address\n\t\t\t@serial = params[:m]\n\n\t\t\t# Hardware model 4 == V2 model\n\t\t\t@hardware = params[:h]\n\n\n\t\t\tsend_file Rails.public_path+'/'+'bc-nominal-segabor.bin',\n\t\t\t\t:type => 'application/octet-stream'\n\t\tend", "def major_version; end", "def ecd_pack_cpsd cpsd\n\t\tbase_ofs = 0\n\t\tamp_ofs = base_ofs + C.sizeof(@pack.htype)\n\t\tpack_ofs = base_ofs + C.sizeof(@pack.htype) * 2\n\t\trecl_ofs = pack_ofs + 4\n\t\tx = \"nxd\"\n\t\ty = \"nyd\"\n\t\tnelems = \"buf->nelems\"\n\t\tif @miss.lcname == \"mask\"\n\t\t\tx = \"i\"\n\t\t\ty = \"1\"\n\t\t\tnelems = \"i\"\n\t\tend\n\t\ttext = (<<-EOF).gsub(/^\\s*\\|/, \"\")\n\t\t|\tN_UI4\ti;\n\t\t|\tconst #{@user.ctype} *source = buf->ob_ptr;\n\t\t|\t#{@pack.elemint} *packed;\n\t\t|\t#{@pack.htype} base, amp;\n\t\t|\t#{@user.ctype} max0;\n\t\t|\t#{@user.ctype} min0;\n\t\t|\tdouble scale, base_d, amp_d;\n\t\t|\tunsigned char *dptr;\n\t\t|\tlong rlen;\n\t\t|#{ecd_miss_decl}\n\t\t|\t/* code */\n\t\t|#{ecd_maxmincheck}\n\t\t|#{@user.maxminzero}\n\t\t|#{@pack.getfactor}\n\t\t|\t#{ecd_miss_set}\n\t\t|\tPOKE_#{@pack.htype}(drec + #{base_ofs} + #{miss_offset}, base);\n\t\t|\tPOKE_#{@pack.htype}(drec + #{amp_ofs} + #{miss_offset}, amp);\n\t\t|\tpacked = (#{@pack.elemint} *)nus_malloc(sizeof(#{@pack.elemint})*buf->nelems);\n\t\t|#{parallel}\n\t\t|\tfor (#{i} = 0; #{i} < buf->nelems; #{i}++) {\n\t\t|\t\t#{ecd_mask_core}\n\t\t|\t}\n\t\t|\tdptr = drec + #{pack_ofs} + #{miss_offset};\n\t\t|\trlen = nus_encode_#{cpsd}((const unsigned char *)packed, #{x}, #{y}, dptr, sizeof(#{@pack.elemint})*buf->nelems*2);\n\t\t|\tnus_free(packed);\n\t\t|\tif (rlen < 0) { return rlen; }\n\t\t|\treturn #{recl_ofs} + #{miss_offset} + rlen;\n\t\tEOF\n\tend", "def edid_decode_extension( bytes, offset )\n extension_tag = bytes[offset+0]\n extension_revision = bytes[offset+1]\n extension_checksum = bytes[offset+127]\n puts\n case extension_tag\n when 0x00\n puts \"Timing Extension\"\n puts \" Extension revision %u\" % extension_revision\n when 0x01\n puts \"LCD Timings Extension\"\n puts \" Extension revision %u\" % extension_revision\n when 0x02 # CTA EDID Timing Extension\n puts \"CTA EDID Additional Timing Data Extension\"\n puts \" Revision %u\" % extension_revision\n edid_decode_cta_block( bytes, offset, \" \" )\n when 0x10\n puts \"Video Timing Block\"\n puts \"Extension revision %u\" % extension_revision\n when 0x20\n puts \"EDID 2.0 Extension\"\n puts \"Extension revision %u\" % extension_revision\n when 0x30\n puts \"Color information type 0\"\n puts \"Extension revision %u\" % extension_revision\n when 0x40 # VESA standard has this as DVI feature data\n puts \"Display Information Extension (DI-EXT)\"\n when 0x50 # VESA standard has this as Touch screen data\n puts \"Localized String Extension (LS-EXT)\"\n when 0x60\n puts \"Microdisplay Interface Extension (MI-EXT)\"\n when 0x70\n puts \"Display ID Extension\"\n when 0xa7, 0xaf, 0xbf\n puts \"Display Transfer Characteristics Data Block (DTCDB)\"\n when 0xf0\n puts \"EDID Block Map\"\n when 0xff\n puts \"Manufacturer Defined Extension\"\n puts \" Data: %s\" % extension_data.map{|b|\"%02x \"%b}.join\n else\n puts \"Undefined Extension Type 0x%02x\" % extension_tag\n puts \" Data: %s\" % extension_data.map{|b|\"%02x \"%b}.join\n end\nend", "def sha_to_b62 sha\n sint = sha.to_i(16)\n res = \"\"\n digits = (\"0\"..\"9\").to_a + (\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a\n while sint > 0\n rest,units = sint.divmod(62)\n res = digits[units] + res\n sint = rest\n end\n return res\nend" ]
[ "0.5999004", "0.55733955", "0.55686146", "0.5457292", "0.54318637", "0.5359448", "0.5351872", "0.5323534", "0.5295974", "0.52820617", "0.52570695", "0.52523667", "0.52517265", "0.52517265", "0.52517265", "0.52517265", "0.52517265", "0.5245727", "0.5234033", "0.52077717", "0.51354396", "0.5117945", "0.51015776", "0.51015776", "0.5089687", "0.5089687", "0.50799155", "0.5077128", "0.50489205", "0.50455433", "0.5038052", "0.50216997", "0.50190926", "0.50157696", "0.5011677", "0.50114334", "0.49998644", "0.49935436", "0.49933067", "0.49843052", "0.49800542", "0.49800542", "0.49800542", "0.49718627", "0.49650964", "0.49448043", "0.49396765", "0.4939337", "0.4932715", "0.49240205", "0.4921017", "0.49083248", "0.49067947", "0.4905502", "0.4882701", "0.48772725", "0.48712727", "0.48710856", "0.4850806", "0.48503533", "0.48429155", "0.48429155", "0.48384273", "0.48301592", "0.48247546", "0.48179126", "0.48168978", "0.4814967", "0.4814798", "0.48112002", "0.48019573", "0.48019573", "0.47966132", "0.47832435", "0.47806966", "0.4778095", "0.47651112", "0.47609192", "0.47593045", "0.47562432", "0.47544017", "0.47529075", "0.47525302", "0.47439685", "0.4742962", "0.47298533", "0.47206417", "0.47177827", "0.47132486", "0.47080323", "0.4702737", "0.4702027", "0.4697154", "0.46962005", "0.46955767", "0.46920758", "0.46917716", "0.46912926", "0.46883687", "0.46848348" ]
0.4748205
83
This object's stroke alpha value
def stroke_alpha dsl&.stroke&.alpha end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stroke_alpha\n dsl.stroke.alpha if dsl.stroke\n end", "def alpha\n (rgba & 0x7F000000) >> 24\n end", "def alpha(val=1.0)\n CGContextSetAlpha(@ctx, val)\n end", "def alpha(value=nil)\n if !value.nil?\n value = value.alpha if value.is_a?(Sketchup::Color)\n r, g, b, a = self.to_a\n return self.new_extended_color(r, g, b, value)\n else\n return super()\n end\n end", "def alpha=(value)\n self.rgba = (rgba & ~0xFF000000) | (self.class.normalize(value, ALPHA_MAX, :alpha) << 24)\n end", "def stroke_opacity(opacity)\n check_opacity(opacity)\n primitive \"stroke-opacity #{opacity}\"\n end", "def nostroke\n CGContextSetRGBStrokeColor(@ctx, 0, 0, 0, 0) # RGBA\n @stroke = false\n end", "def rgba\n rgb + [opacity]\n end", "def translucent_alpha\n return 160\n end", "def alpha(a1)\n Rubyvis.rgb(r,g,b,a1)\n end", "def pencolor args\n is_step\n stroke args\n @fg_color = args\n update_pen_info\n end", "def stroke(r=0, g=0, b=0, a=1.0)\n case r\n when Color\n g = r.g\n b = r.b\n a = r.a\n r = r.r\n end\n CGContextSetRGBStrokeColor(@ctx, r, g, b, a) # RGBA\n @stroke = true\n end", "def opacity(fill_o, stroke_o=nil, &block)\n @prawn.transparent(fill_o, stroke_o || fill_o) do\n yield\n end\n end", "def alpha(x, y, method)\n Kernel.raise ArgumentError, 'Unknown paint method' unless PAINT_METHOD_NAMES.key?(method.to_i)\n name = Gem::Version.new(Magick::IMAGEMAGICK_VERSION) > Gem::Version.new('7.0.0') ? 'alpha ' : 'matte '\n primitive name + sprintf('%g,%g, %s', x, y, PAINT_METHOD_NAMES[method.to_i])\n end", "def transparent!\n @transparency = 1.0\n self\n end", "def alpha_to_color(alpha)\n Gosu::Color.new((alpha * 0xff).to_i, 255, 255, 255)\n end", "def alpha\n @attrs[:alpha]\n end", "def transparent?\n alpha == ALPHA_TRANSPARENT\n end", "def alpha=(value)\n @alpha = value\n end", "def opacity\n @opacity ||= @normalized.length == 3 ? 1.0 : @normalized.last\n end", "def stroke_paint(paint)\n end", "def alpha\n @attrs[:alpha].to_f\n end", "def setup_attributes\n fill_opacity 0\n stroke 'gold3'\n stroke_width 2\n stroke_linecap 'round'\n stroke_linejoin 'round'\n end", "def alpha\n return @alpha\n end", "def stroke(color=nil)\n color ? @stroke=color : @stroke\n end", "def to_kmlcolor(color=\"#000000\", alpha = \"ff\")\n alpha + color[5,3] + color[3,2] + color[1,2]\n end", "def to_kmlcolor(color=\"#000000\", alpha = \"ff\")\n alpha + color[5,3].to_s + color[3,2].to_s + color[1,2].to_s\n end", "def draw_alpha_pixel(x,y,alpha,r,g,b)\r\n r = 0 if ( r < 0 ) \n r = 255 if ( r > 255 ) \r\n g = 0 if ( g < 0 ) \n g = 255 if ( g > 255 ) \r\n b = 0 if ( b < 0 ) \n b = 255 if ( b > 255 ) \r\n if ( x < 0 || y < 0 || x >= @x_size || y >= @y_size )\r\n #return(-1)\r\n #TODO check image_color_at method is right?\n else \r\n rGB2 = image_color_at(@picture, x, y)\n # debugger\n r2 = (rGB2 >> 16) & 0xFF\r\n g2 = (rGB2 >> 8) & 0xFF\r\n b2 = rGB2 & 0xFF\r\n ialpha = (100 - alpha)/100\r\n alpha = alpha / 100\r\n ra = (r*alpha+r2*ialpha).floor\r\n ga = (g*alpha+g2*ialpha).floor\r\n ba = (b*alpha+b2*ialpha).floor\r\n image_set_pixel(@picture,x,y,ra,ga,ba)\n end \r\n end", "def inspect\n alpha? ? rgba_str : hex_str\n end", "def inspect\n alpha? ? rgba_str : hex_str\n end", "def pbAlphaBlend(dstColor,srcColor)\n r=(255*(srcColor.red-dstColor.red)/255)+dstColor.red\n g=(255*(srcColor.green-dstColor.green)/255)+dstColor.green\n b=(255*(srcColor.blue-dstColor.blue)/255)+dstColor.blue\n a=(255*(srcColor.alpha-dstColor.alpha)/255)+dstColor.alpha\n return Color.new(r,g,b,a)\nend", "def stroke(color)\n @style[:stroke] = pattern(color)\n end", "def stroke_antialias(bool)\n bool = bool ? '1' : '0'\n primitive \"stroke-antialias #{bool}\"\n end", "def stroke(color)\n @style[:stroke] = color\n end", "def alpha_blending=(bool)\n ::GD2::GD2FFI.send(:gdImageAlphaBlending, image_ptr, bool ? 1 : 0)\n end", "def alpha_blending?\n !image_ptr[:alphaBlendingFlag].zero?\n end", "def red\n (rgba & 0xFF0000) >> 16\n end", "def blue\n rgba & 0x0000FF\n end", "def stroke_width(width)\n end", "def opaque?\n alpha == ALPHA_OPAQUE\n end", "def draw_alpha_pixel(x,y,alpha,r,g,b)\n r = 0 if ( r < 0 )\n r = 255 if ( r > 255 )\n g = 0 if ( g < 0 )\n g = 255 if ( g > 255 )\n b = 0 if ( b < 0 )\n b = 255 if ( b > 255 )\n if ( x < 0 || y < 0 || x >= @x_size || y >= @y_size )\n #return(-1)\n #TODO check image_color_at method is right?\n else\n rGB2 = image_color_at(@picture, x, y)\n\n r2 = (rGB2 >> 16) & 0xFF\n g2 = (rGB2 >> 8) & 0xFF\n b2 = rGB2 & 0xFF\n ialpha = (100 - alpha)/100\n alpha = alpha / 100\n ra = (r*alpha+r2*ialpha).floor\n ga = (g*alpha+g2*ialpha).floor\n ba = (b*alpha+b2*ialpha).floor\n image_set_pixel(@picture,x,y,ra,ga,ba)\n end\n end", "def sc1\n c = gauge_back_color\n c.alpha = 75\n c\n end", "def fill_opacity(opacity)\n check_opacity(opacity)\n primitive \"fill-opacity #{opacity}\"\n end", "def draw_setup(gc)\n if @obj.stroke and @obj.strokewidth > 0\n gc.set_foreground @obj.stroke\n gc.set_alpha @obj.stroke_alpha\n gc.set_line_width @obj.strokewidth\n true\n end\n end", "def transparent(fill_t, stroke_t=nil, &block)\n @prawn.transparent(1.0-fill_t, 1.0-(stroke_t || fill_t)) do\n yield\n end\n end", "def alpha\n end", "def alpha=(value)\n end", "def strokeColor=(color)\n @stroke_color = color.CGColor\n self.setNeedsDisplay\n end", "def rgba\n [red, green, blue, alpha].freeze\n end", "def color_state_mod(color_pnt, enabled=active_state, alpha=255)\n case enabled\n when :enb, true then color_pnt.alpha = alpha * 0.8\n when :dis, false then color_pnt.alpha = alpha * 0.3\n end\n end", "def update_pokemon_alpha_down\n max_alpha_time = POKEMON_ALPHA_DOWN_END - POKEMON_ALPHA_DOWN_START\n current_time = max_alpha_time - (@counter - POKEMON_ALPHA_DOWN_START)\n @pokemon_color.alpha = MAX_POKEMON_ALPHA * current_time / max_alpha_time\n @pokemon_sprite.set_color(@pokemon_color)\n end", "def alpha; end", "def alpha_blend!(other)\n self.rgba = ::GD2::GD2FFI.send(:gdAlphaBlend, rgba.to_i, other.rgba.to_i)\n self\n end", "def line_color\n :white_on_black\n end", "def green\n (rgba & 0x00FF00) >> 8\n end", "def bar_opacity=(alpha)\n @bar_opacity = [[alpha, 0].max, 255].min\n end", "def getAlphaOut\n if @fadeTime < 5\n return 0x11_000000\n elsif @fadeTime < 10\n return 0x22_000000\n elsif @fadeTime < 15\n return 0x33_000000\n elsif @fadeTime < 20\n return 0x44_000000\n elsif @fadeTime < 25\n return 0x55_000000\n elsif @fadeTime < 30\n return 0x66_000000\n elsif @fadeTime < 35\n return 0x77_000000\n elsif @fadeTime < 40\n return 0x88_000000\n elsif @fadeTime < 45\n return 0x99_000000\n elsif @fadeTime < 50\n return 0xaa_000000\n elsif @fadeTime < 55\n return 0xbb_000000\n elsif @fadeTime < 60\n return 0xcc_000000\n elsif @fadeTime < 65\n return 0xdd_000000\n elsif @fadeTime < 70\n return 0xee_000000\n else\n return 0xff_000000\n end\n end", "def from_rgba(red, green, blue, alpha)\n Inker.color(\"rgba(#{red}, #{green}, #{blue}, #{alpha})\")\n end", "def sc2\n c = gauge_back_color\n c.alpha = 150\n c\n end", "def alpha=(num)\n @alpha = constrain num, 0..255\n end", "def getDrawColor()\n return @drawColor\n end", "def stroke(colorspec)\n primitive \"stroke #{enquote(colorspec)}\"\n end", "def transparent=(value)\n\t\t\t@transparent = value\n\t\tend", "def r; self.color.r end", "def stroke\n cur_page.stroke\n end", "def _alpha_color color\n return nil unless trns\n\n # For color type 0 (grayscale), the tRNS chunk contains a single gray level value, stored in the format:\n #\n # Gray: 2 bytes, range 0 .. (2^bitdepth)-1\n #\n # For color type 2 (truecolor), the tRNS chunk contains a single RGB color value, stored in the format:\n #\n # Red: 2 bytes, range 0 .. (2^bitdepth)-1\n # Green: 2 bytes, range 0 .. (2^bitdepth)-1\n # Blue: 2 bytes, range 0 .. (2^bitdepth)-1\n #\n # (If the image bit depth is less than 16, the least significant bits are used and the others are 0)\n # Pixels of the specified gray level are to be treated as transparent (equivalent to alpha value 0);\n # all other pixels are to be treated as fully opaque ( alpha = (2^bitdepth)-1 )\n\n @alpha_color ||=\n case hdr.color\n when COLOR_GRAYSCALE\n v = trns.data.unpack('n')[0] & (2**hdr.depth-1)\n Color.from_grayscale(v, :depth => hdr.depth)\n when COLOR_RGB\n a = trns.data.unpack('n3').map{ |v| v & (2**hdr.depth-1) }\n Color.new(*a, :depth => hdr.depth)\n else\n raise Exception, \"color2alpha only intended for GRAYSCALE & RGB color modes\"\n end\n\n color == @alpha_color ? 0 : (2**hdr.depth-1)\n end", "def opaque?\n opacity == Utils::MAX_OPACITY\n end", "def backgroundColor\n self.layer.backgroundColor\n end", "def update_opacity\n self.opacity = @battler.max_opac\n @battler.refresh_opacity = false\n end", "def cur_alpha\n MSPhysics::Newton::Hinge.get_cur_alpha(@address)\n end", "def uicolor(alpha=1.0)\n red = self[0] / 255.0\n green = self[1] / 255.0\n blue = self[2] / 255.0\n UIColor.colorWithRed(red, green:green, blue:blue, alpha:alpha.to_f)\n end", "def getAlphaIn\n if @fadeTime < 5\n return 0xff_000000\n elsif @fadeTime < 10\n return 0xee_000000\n elsif @fadeTime < 15\n return 0xdd_000000\n elsif @fadeTime < 20\n return 0xcc_000000\n elsif @fadeTime < 25\n return 0xbb_000000\n elsif @fadeTime < 30\n return 0xaa_000000\n elsif @fadeTime < 35\n return 0x99_000000\n elsif @fadeTime < 40\n return 0x88_000000\n elsif @fadeTime < 45\n return 0x77_000000\n elsif @fadeTime < 50\n return 0x66_000000\n elsif @fadeTime < 55\n return 0x55_000000\n elsif @fadeTime < 60\n return 0x44_000000\n elsif @fadeTime < 65\n return 0x33_000000\n elsif @fadeTime < 70\n return 0x22_000000\n else\n return 0x11_000000\n end\n end", "def update_stroke\n @cached_swt_stroke = nil\n end", "def a\n\t\t\tColor.a(@color)\n\t\tend", "def draw_outline color: 'red'\n @canvas.rect(\n x: @left,\n y: @top,\n width: width,\n height: height,\n style: \"stroke: #{color}; fill: none\"\n )\n end", "def hex_color(value, alpha = nil)\n Color.from_hex(value, alpha)\n end", "def auxiliary_colour\n @cr[0xe] >> 4\n end", "def transparency_mode\n super\n end", "def settransparency(*)\n super\n end", "def set(red, green, blue, alpha=255)\n self.red = red\n self.green = green\n self.blue = blue\n self.alpha = alpha\n end", "def save_alpha=(bool)\n ::GD2::GD2FFI.send(:gdImageSaveAlpha, image_ptr, bool ? 1 : 0)\n end", "def setup\n size 100, 100\n orange = color(204, 102, 0)\n blue = color(0, 102, 153)\n orangeblueadd = blend_color(orange, blue, ADD)\n background(51)\n noStroke()\n fill(orange)\n rect(14, 20, 20, 60)\n fill(orangeblueadd)\n rect(40, 20, 20, 60)\n fill(blue)\n rect(66, 20, 20, 60)\nend", "def nodash\n CGContextSetLineDash(@ctx, 0.0, nil, 0)\n end", "def light_pen_x\n @cr[6]\n end", "def foreground_fill\n red = background_fill[1..2].to_i(16)\n green = background_fill[3..4].to_i(16)\n blue = background_fill[5..6].to_i(16)\n (red * 0.299 + green * 0.587 + blue * 0.114) > 186 ? '#000000' : '#FFFFFF'\n end", "def border_colour\n @cr[0xf] & 0x07\n end", "def alpha_mask(data, options = {})\n @canvas.alpha_mask data\n end", "def darken(value=0)\n return self.brighten(-value)\n end", "def svg\n values = self[0..2].map do |v|\n v = Range.O.trim( v )\n (255.0 * v).to_i \n end\n return \"rgb(#{values.join(\",\")})\"\n end", "def escape\n self.blend_type = 0\n self.color.set(0, 0, 0, 0)\n self.opacity = 255\n @_escape_duration = 32\n @_whiten_duration = 0\n @_appear_duration = 0\n @_collapse_duration = 0\n end", "def hex_color\n self.color_hex\n end", "def name\n COLOR_NAMES_REVERSE[rgba]\n end", "def rgba(r, g, b, a)\n r << 24 | g << 16 | b << 8 | a\n end", "def rgba(r, g, b, a)\n r << 24 | g << 16 | b << 8 | a\n end", "def hsla_color; end", "def b\n\t\t\tColor.b(@color)\n\t\tend", "def background_colour\n @cr[0xf] >> 4\n end", "def contextalpha=(alpha)\n @elementHash[:contextalpha] = alpha\n end", "def green\n\t\tlight COLOR_KEY_GREEN\n\tend", "def save_alpha?\n !image_ptr[:saveAlphaFlag].zero?\n end" ]
[ "0.84100735", "0.69870126", "0.69254094", "0.6897213", "0.6622687", "0.661469", "0.64578193", "0.64360726", "0.63820887", "0.633589", "0.6205916", "0.62009454", "0.6080869", "0.6026569", "0.60219085", "0.6017503", "0.5967396", "0.59634334", "0.59552765", "0.59451765", "0.5942627", "0.59355307", "0.58895123", "0.58867157", "0.58804655", "0.58215064", "0.58150125", "0.5814168", "0.5800699", "0.5800699", "0.5797662", "0.5792973", "0.5792518", "0.5777274", "0.5757771", "0.5756557", "0.57539254", "0.5716963", "0.56815857", "0.56551075", "0.56510836", "0.5647921", "0.56456983", "0.5636852", "0.563472", "0.5632928", "0.56086797", "0.5608483", "0.55985534", "0.55896395", "0.55843294", "0.5542641", "0.55385524", "0.5525387", "0.5493904", "0.5465071", "0.5462381", "0.5434329", "0.5429892", "0.54260194", "0.5423905", "0.5423889", "0.5421844", "0.5396601", "0.5382298", "0.53710157", "0.5370461", "0.53581285", "0.5336106", "0.53228337", "0.53065574", "0.52966017", "0.5295196", "0.5282105", "0.5268478", "0.5260264", "0.5257549", "0.52490824", "0.5234987", "0.5228048", "0.5220873", "0.5217848", "0.5214327", "0.5214097", "0.5196544", "0.5187704", "0.51784647", "0.51743644", "0.5164202", "0.5160687", "0.5137971", "0.51376104", "0.51363504", "0.51363504", "0.51309085", "0.512326", "0.51211447", "0.51040834", "0.51038945", "0.50943184" ]
0.8266243
1
Just clear it out and let next paint recreate and save our SWT color
def update_stroke @cached_swt_stroke = nil end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def invalidate_color_components\n @color_components = nil\n end", "def invalidate_color_components\n @color_components = nil\n end", "def reset!\n @color = @@colors[:white]\n end", "def clear\n @bitmap = solid_canvas(DEFAULT_COLOR)\n end", "def color_reset!(fill)\n save = background_color\n # Change the background color _outside_ the begin block\n # so that if this object is frozen the exeception will be\n # raised before we have to handle it explicitly.\n self.background_color = fill\n begin\n erase!\n ensure\n self.background_color = save\n end\n self\n end", "def clear\n self.color = COLOR_CLEAR unless self.color == COLOR_CLEAR\n end", "def clear\n @pixels.fill WHITE\n end", "def reset\n @victory = false\n @win = false\n drawFromPixmap\n end", "def reset!\n self.background_color = nil\n self.font_color = nil\n self.button_color = nil\n self.font = :helvetica\n self.save\n end", "def spray_paint(new_color)\n self.color = new_color\n end", "def clear_board\n FXDCWindow.new(@image) do |dc|\n dc.foreground = BACK_COLOR\n dc.fillRectangle(0, 0, IMG_WIDTH, IMG_HEIGHT)\n end\n board_draw\n end", "def restart\n pbBGMStop(0)\n 51.times do\n @viewport.tone.red-=5\n @viewport.tone.green-=5\n @viewport.tone.blue-=5\n self.updateElements\n Graphics.update\n end\n raise Reset.new\n end", "def fill_paint(paint)\n end", "def finish\n return if self.disposed?\n @viewport.color = Color.new(0, 0, 0, 0)\n 16.delta_add.times do\n @viewport.color.alpha += 32/self.delta\n self.wait\n end\n @viewport.color = Color.black\n self.dispose\n end", "def clear\n @draws.clear\n super\n end", "def reset_use_color\n @use_color = true\n end", "def end!\n @color = @@colors[:red]\n end", "def decolorize\n dup.decolorize!\n end", "def decolorize\n dup.decolorize!\n end", "def clear\n create rows: @rows, cols: @cols, color: \"O\"\n save_state\n end", "def clear c = :black\n fast_rect 0, 0, w, h, c\n end", "def clear c = :black\n fast_rect 0, 0, w, h, c\n end", "def reset\n # color is enabled by default, can be turned of by switch --no-color\n Term::ANSIColor.coloring = true\n end", "def reset\n Style.clear_index\n reset_color_scheme\n reset_use_color\n end", "def clear\n\t\t@screen.fill_rect 0, 0, @width, @height, @color_bg\n\tend", "def restore_state\n unless @state_stack.empty?\n state = @state_stack.pop\n @current_fill_color = state.fill_color\n @current_stroke_color = state.stroke_color\n @current_text_render_style = state.text_render_style\n @current_stroke_style = state.stroke_style\n stroke_style!\n end\n add_content(\"\\nQ\")\n end", "def clear_image\n tmp = [];\n @rows.times do |row|\n @cols.times do |col|\n tmp << @default_color\n end\n end\n @matrix = tmp.each_slice(@cols).to_a\n #display_image\n end", "def colorize!; @colors = true; end", "def reset\n @max_color_distance = @color_distance_limit ? 0 : nil\n @left = @top = @right = @bottom = nil\n end", "def reload\n draws = @draws.dup\n clear\n draws.each { |block| draw(&block) }\n end", "def populate_pad\n @_populate_needed = false\n\n create_pad\n\n # clearstring is the string required to clear the pad to background color\n @clearstring = nil\n $log.debug \" populate pad color = #{@color} , bg = #{@bgcolor} \"\n #cp = get_color($datacolor, color(), bgcolor())\n # commenting off next line meant that textdialog had a black background 2014-05-01 - 23:37\n #@cp = FFI::NCurses.COLOR_PAIR(cp)\n # we seem to be clearing always since a pad is often reused. so making the variable whenever pad created.\n\n @repaint_all = true\n\n end", "def do_reset\n\t\t\n\t\t\t# Mark state as reset\n\t\t\t@reset = true\n\t\t\t\n\t\t\t# Revert text and palette\n\t\t\tself.text = nil \n\t\t\tself.palette = @palette_normal\t\t\t\n\t\tend", "def reset_colors\n @color_output ||= true\n\n # Build the default colors\n Term::ANSIColorHI.coloring = color_output\n c = Term::ANSIColorHI\n @color_app_info = c.intense_white + c.bold\n @color_app_exe = c.intense_green + c.bold\n @color_command = c.intense_yellow\n @color_description = c.intense_white\n @color_parameter = c.intense_cyan\n @color_usage = c.intense_black + c.bold\n \n @color_error_word = c.intense_black + c.bold\n @color_error_name = c.intense_red + c.bold\n @color_error_description = c.intense_white + c.bold\n \n @color_bold = c.bold\n @color_reset = c.reset\n @screen_clear = \"\\e[H\\e[2J\"\n end", "def clear_all\n Terminal.move_up(previous_draw_amount_of_lines)\n Terminal.clear_screen_from_cursor\n end", "def paint( color )\n self.update(color: color)\n end", "def erase\n call Screen.setColor(false)\n call Screen.drawRectangle(@x, @y, @x + @size, @y + @size)\n end", "def draw_next_phase\n if (@color_pair)\n if Ncurses.respond_to?(:color_set)\n @window.color_set(@color_pair, nil)\n else\n @window.attrset(Ncurses.COLOR_PAIR(@color_pair))\n end\n end\n @window.mvaddstr(@y, @x, \"O\")\n end", "def matte_reset!\n alpha(TransparentAlphaChannel)\n self\n end", "def no_color\n reset_prev_formatting self, :color\n end", "def setcolorrep(*)\n super\n end", "def time_for_new_paint(new_color)\n @color = new_color\n ahh_fresh_paint\nend", "def reset_themes\n @color_index = 0\n @labels_seen = {}\n @theme_options = {}\n\n @d = Draw.new\n # Scale down from 800x600 used to calculate drawing.\n @d = @d.scale(@scale, @scale)\n end", "def clear\n closed!\n @leds.fill 0\n self\n end", "def reset!\n self.colors = {}\n self.texts = {}\n self.ifs = {}\n self.theme_images = []\n self.save\n end", "def repaint\n r,c = rowcol\n #@bgcolor ||= $def_bg_color # moved down 2011-11-5 \n #@color ||= $def_fg_color\n _bgcolor = bgcolor()\n _color = color()\n $log.debug(\"widget repaint : r:#{r} c:#{c} col:#{_color}\" )\n value = getvalue_for_paint\n len = @width || value.length\n acolor = @color_pair || get_color($datacolor, _color, _bgcolor)\n @graphic.printstring r, c, \"%-*s\" % [len, value], acolor, attr()\n # next line should be in same color but only have @att so we can change att is nec\n #@form.window.mvchgat(y=r, x=c, max=len, Ncurses::A_NORMAL, @bgcolor, nil)\n end", "def onCanvasPaint(sender, sel, event)\r\n dc = FXDCWindow.new(@canvas_disp, event)\r\n dc.foreground = @canvas_disp.backColor\r\n dc.fillRectangle(0, 0, @canvas_disp.width, @canvas_disp.height)\r\n @cards_todisp.each do |v|\r\n dc.drawImage(v.image, v.pos_x, v.pos_y)\r\n end\r\n end", "def repaint # button\n\n #@bgcolor ||= $def_bg_color\n #@color ||= $def_fg_color\n $log.debug(\"BUTTON repaint : #{self} r:#{@row} c:#{@col} , #{@color} , #{@bgcolor} , #{getvalue_for_paint}\" )\n r,c = @row, @col #rowcol include offset for putting cursor\n # NOTE: please override both (if using a string), or else it won't work \n # These are both colorpairs not colors ??? 2014-05-31 - 11:58 \n _highlight_color = @highlight_color || $reversecolor\n _highlight_bgcolor = @highlight_bgcolor || 0\n _bgcolor = bgcolor()\n _color = color()\n if @state == :HIGHLIGHTED\n _bgcolor = @state==:HIGHLIGHTED ? _highlight_bgcolor : _bgcolor\n _color = @state==:HIGHLIGHTED ? _highlight_color : _color\n elsif selected? # only for certain buttons lie toggle and radio\n _bgcolor = @selected_bgcolor || _bgcolor\n _color = @selected_color || _color\n end\n $log.debug \"XXX: button #{text} STATE is #{@state} color #{_color} , bg: #{_bgcolor} \"\n if _bgcolor.is_a?( Integer) && _color.is_a?( Integer)\n # i think this means they are colorpairs not colors, but what if we use colors on the 256 scale ?\n # i don;t like this at all. \n else\n _color = get_color($datacolor, _color, _bgcolor)\n end\n value = getvalue_for_paint\n $log.debug(\"button repaint :#{self} r:#{r} c:#{c} col:#{_color} bg #{_bgcolor} v: #{value} ul #{@underline} mnem #{@mnemonic} datacolor #{$datacolor} \")\n len = @width || value.length\n @graphic = @form.window if @graphic.nil? ## cell editor listbox hack \n @graphic.printstring r, c, \"%-*s\" % [len, value], _color, attr()\n# @form.window.mvchgat(y=r, x=c, max=len, Ncurses::A_NORMAL, bgcolor, nil)\n # in toggle buttons the underline can change as the text toggles\n if @underline || @mnemonic\n uline = @underline && (@underline + @text_offset) || value.index(@mnemonic) || \n value.index(@mnemonic.swapcase)\n # if the char is not found don't print it\n if uline\n y=r #-@graphic.top\n x=c+uline #-@graphic.left\n #\n # NOTE: often values go below zero since root windows are defined \n # with 0 w and h, and then i might use that value for calcaluting\n #\n $log.error \"XXX button underline location error #{x} , #{y} \" if x < 0 or c < 0\n raise \" #{r} #{c} #{uline} button underline location error x:#{x} , y:#{y}. left #{@graphic.left} top:#{@graphic.top} \" if x < 0 or c < 0\n @graphic.mvchgat(y, x, max=1, Ncurses::A_BOLD|Ncurses::A_UNDERLINE, _color, nil)\n end\n end\n end", "def reset_board_variables\n @color_on_turn = :white\n @fifty_counter = 0\n @pieces = {:white => [], :black => []} \n @last_moved_item = BoardInfoItem.new(0,0)\n @infosquare.each do |row_square|\n row_square.each do |cell|\n cell.clear\n end\n end\n #p @infosquare\n end", "def clear(options = {})\r\n options = {\r\n :color => :alpha,\r\n :fill => true\r\n }.merge!(options)\r\n\r\n capture {\r\n rect 0, 0, width - 1, height - 1, options\r\n \r\n self\r\n }\r\n end", "def onCanvasRepaint(sender, sel, event)\n sdc = FXDCWindow.new(@canvas, event) #dc object handles OS display to redraw monitor pixels on #drawable objects.\n if !@dirtyArray[@activeIndex] #Checks for pixel data in the active image.\n sdc.foreground = FXRGB(255, 255, 255) #Sets foreground color of the canvas to white.\n sdc.fillRectangle(0, 0, @canvas.width, @canvas.height) #Populates the canvas with white data.\n\n dc = FXDCWindow.new(@activeImage) #Grab the active image.\n dc.fillRectangle(0, 0, @canvas.width, @canvas.height) #Populates the active image with white pixel data.\n dc.end #closes the dc object to close thread and save resources.\n end\n \n index = @layerArray.length() #Create an index pointer that points to the last index of the layer array.\n \n while index >= 0 #Cycle through the layer array from back to front.\n if index == @layerArray.length() #Paint the canvas white before drawing images to the canvas. (Flushes the canvas)\n sdc.foreground = FXRGB(255, 255, 255) \n sdc.fillRectangle(0, 0, @canvas.width, @canvas.height)\n end\n \n if @layerArray[index] == false #If the layer is not hidden\n if @dirtyArray[index] == true #If the layer contains data\n sdc.drawImage(@imageArray[index], 0, 0) #Draw the image onto the canvas.\n end\n end\n index = index - 1 #Decriment the index.\n\n end\n sdc.end\n end", "def revert_unit_colors\n $game_map.units.each{|u|\n next if @unit_sprites[u.sprite_id].disposed?\n @unit_sprites[u.sprite_id].color.set(0, 0, 0, 0)\n u.acted = false\n }\n end", "def clear\n self.clear_overlays\n end", "def draw\n lastpixel = RuTui::Pixel.new(rand(255), rand(255), \".\")\n @map = Marshal.load( Marshal.dump( @smap )) # Deep copy\n\n # get all the objects\n @objects.each do |o|\n next if o.x.nil? or o.y.nil?\n o.each do |ri,ci,pixel|\n if !pixel.nil? and o.y+ri >= 0 and o.x+ci >= 0 and o.y+ri < @map.size and o.x+ci < @map[0].size\n # -1 enables a \"transparent\" effect\n if pixel.bg == -1\n pixel.bg = @map[o.y + ri][o.x + ci].bg if !@map[o.y + ri][o.x + ci].nil?\n pixel.bg = RuTui::Theme.get(:background).bg if pixel.bg == -1\n end\n if pixel.fg == -1\n pixel.fg = @map[o.y + ri][o.x + ci].fg if !@map[o.y + ri][o.x + ci].nil?\n pixel.fg = RuTui::Theme.get(:background).fg if pixel.fg == -1\n end\n\n @map[o.y + ri][o.x + ci] = pixel\n end\n end\n end\n\n out = \"\" # Color.go_home\n # and DRAW!\n @map.each do |line|\n line.each do |pixel|\n if lastpixel != pixel\n # out += RuTui::Ansi.clear_color if lastpixel != 0\n out << RuTui::Ansi.clear_color if lastpixel != 0\n if pixel.nil?\n # out += \"#{RuTui::Ansi.bg(@default.bg)}#{RuTui::Ansi.fg(@default.fg)}#{@default.symbol}\"\n out << \"#{RuTui::Ansi.bg(@default.bg)}#{RuTui::Ansi.fg(@default.fg)}#{@default.symbol}\"\n else\n # out += \"#{RuTui::Ansi.bg(pixel.bg)}#{RuTui::Ansi.fg(pixel.fg)}#{pixel.symbol}\"\n out << \"#{RuTui::Ansi.bg(pixel.bg)}#{RuTui::Ansi.fg(pixel.fg)}#{pixel.symbol}\"\n end\n lastpixel = pixel\n else\n if pixel.nil?\n # out += @default.symbol\n out << @default.symbol\n else\n # out += pixel.symbol\n out << pixel.symbol\n end\n end\n end\n end\n\n # draw out\n print out.chomp\n $stdout.flush\n end", "def closed!\n @color = @@colors[:lightcyan]\n end", "def reset_screen_clearing\n @clear_screen = false\n @clear_screen_code = \"\\e[H\\e[2J\"\n end", "def reset_board_variables\r\n @color_on_turn = :white\r\n @pieces = {:white => [], :black => []} \r\n @last_moved_item = BoardInfoItem.new(0,0)\r\n @infosquare.each do |row_square|\r\n row_square.each do |cell|\r\n cell.clear\r\n end\r\n end\r\n #p @infosquare\r\n end", "def uncolorize\n @uncolorized || self\n end", "def clear\n if undoManager != nil\n undoManager.registerUndoWithTarget(self, selector: 'unclear:', object: [@toys_in_scene, @strokes])\n end\n\n @strokes = []\n @toys_in_scene = []\n @actions = []\n @points = nil\n @selected = nil\n @truly_selected = nil\n\n addSceneToy\n\n setNeedsDisplay\n end", "def destroy\n #If two people remove the same colour without updating the site, we have a race condition.\n if !@preset_color.blank?\n @preset_color.destroy\n end\n\n @preset_colors = PresetColor.all\n render :preset_colors\n end", "def reset\n STDOUT.write \"\\033[0m\"\n end", "def stroke_paint(paint)\n end", "def output\n Vedeu.timer(\"Clearing: '#{name}'\") do\n @y = geometry.y\n @x = geometry.x\n @width = geometry.width\n @height = geometry.height\n @colour = interface.colour\n\n @clear ||= Array.new(@height) do |iy|\n Array.new(@width) do |ix|\n Vedeu::Views::Char.new(value: ' ',\n colour: @colour,\n position: [@y + iy, @x + ix])\n end\n end\n end\n end", "def reset_background(colors, moves)\n moves.each do |move|\n (0..7).each do |row|\n (0..7).each do |col|\n @display[row][col].background = colors.shift if move == [row, col]\n end\n end\n end\n end", "def redraw\n @terminal.erase_screen\n render\n end", "def paint(win, color)\r\n win.attron(Curses.color_pair(color))\r\n yield\r\n win.attroff(Curses.color_pair(color))\r\nend", "def erase\n CDK.eraseCursesWindow(@win)\n CDK.eraseCursesWindow(@shadow_win)\n end", "def points_gfx_reset_colors\r\n @players_on_match.each do |pl_single|\r\n player_label1 = pl_single.name.to_sym\r\n @points_status[player_label1][:widg_scopa].font_color = Fox.FXRGB(0, 0, 0)\r\n end\r\n end", "def setup\n super\n @background_colour = @colour\n @foreground_colour = Palette.white\n end", "def refresh\n contents.clear\n for i in 0...(@cw_data.size / 2)\n draw_text_ex(0, line_height*i, \"\\\\c[16]\" + @cw_data[i*2])\n reset_font_settings\n draw_text(0, line_height*i, contents_width, line_height, value(@cw_data[i*2 + 1]), 2)\n end\n end", "def paint_fill(screen, point, new_color)\n seen = {}\n old_color = color(point, screen)\n to_fill = [point]\n\n until to_fill.empty? do\n current_point = to_fill.shift\n screen[current_point[0]][current_point[1]] = new_color\n neighbors(current_point, screen.length, screen.first.length).each do |neighbor|\n if !seen[neighbor] && color(neighbor, screen) == old_color\n to_fill.push(neighbor)\n seen[neighbor] = true\n end\n end\n end\n\n render screen\nend", "def clear(color = DEFAULT_COLOR)\n @pixels = Array.new(@height) { Array.new(@width) { color } }\n end", "def window_update(oline)\n if oline != nil\n #text = \"\"\n @last_color = 0\n @contents_x = 0\n @contents_y = 0\n @biggest_text_height = 0\n @cControlsList.clear()\n for l in oline\n next if l == nil\n converted_line = convert_special_characters(l)\n generate_controls(converted_line)\n new_line\n end\n\n # Changes contents size for scrolling\n self.contents.dispose\n self.contents = Bitmap.new(self.width - 32, [self.height - 32, @contents_y].max)\n self.oy = 0\n end\n \n refresh()\n end", "def clear_screen_and_display_board\n clear\n display_board\n end", "def draw_setup(gc)\n if @obj.stroke and @obj.strokewidth > 0\n gc.set_foreground @obj.stroke\n gc.set_alpha @obj.stroke_alpha\n gc.set_line_width @obj.strokewidth\n true\n end\n end", "def reload\n document.default_style_sheet = Config.stylesheet\n\n palette = self.palette\n palette.set_color Qt::Palette::Base, Config.background\n self.palette = palette\n\n Config.term.each_shortcut do |key, block|\n Pride.add_shortcut(self, key) do\n change_cursor { |c| c.clear_selection }\n instance_eval(&block)\n end\n end\n end", "def reset_color\n \"\\e[#{COLORS[:reset]}m\"\n end", "def render\n system(\"clear\")\n board.each_with_index do |row,i1|\n complete_row = []\n row.each_with_index do |col,i2|\n pos = [i1, i2]\n # debugger\n if pos == cursor.cursor_pos\n complete_row << board[i1][i2].symbol.colorize(:color => :white, :background => :black)\n else\n complete_row << board[i1][i2].symbol.colorize(:color => :white, :background => :red)\n end\n end\n puts complete_row.join\n end\n end", "def clear_styles\n `this.__native__.style.cssText=''`\n return self\n end", "def clear\n `c$Element.prototype.m$clear_styles.call(#{@element})`\n end", "def colorize!(fg, bg)\n set_colors(fg, bg)\n num = @cwin.maxx * @cwin.maxy\n self.home\n self.go(0, 0) { @cwin.addstr(' '*num) }\n @cwin.refresh\n end", "def on_paint(dc)\n return unless @started\n dc.set_font(@font)\n first_row = row = get_first_visible_line\n last_row = get_last_visible_line+1\n y = 0\n hX = @hex0\n aX = @asc0\n idx = (row.zero?)? 0 : @columns * row\n\n hex_w = @hex_width + @asc_width\n h_off = @hex_width / 2\n\n # draw blank background\n dc.set_pen(Wx::TRANSPARENT_PEN)\n dc.set_brush(Wx::Brush.new(@bg_color))\n dc.draw_rectangle(0, 0, client_size.width, client_size.height)\n\n paint_row(dc, y, idx, row)\n\n while(c=@data[idx]) and row <= last_row\n if(hX >= @hexN)\n hX = @hex0\n aX = @asc0\n y += @txt_height\n row +=1\n paint_row(dc, y, idx, row)\n end\n\n # call byte colorization block if we have one\n text_color =\n if( @post_paint_proc and\n bret=@post_paint_proc.call(self,dc,idx,c,hX+h_off,aX,y) )\n bret\n else\n @dump_color\n end\n\n # selection stuff goes here\n if @selection and @selection.include?(idx)\n sbrushes = [\n @select_bgs[ @cursor.area ],\n @select_bgs[ (@cursor.area+1) % AREAS.size ]\n ]\n colorize_byte_bg(sbrushes, dc, hX+h_off, aX, y)\n end\n\n dc.set_text_foreground(text_color)\n dc.draw_text(\"#{disp_hex_byte(c)}\", hX+h_off, y)\n dc.draw_text(\"#{disp_ascii_byte(c)}\", aX, y)\n\n hX += hex_w\n aX += @asc_width\n idx += 1\n end\n\n paint_boundaries(dc)\n paint_cursor(dc)\n end", "def refresh\n contents.clear\n draw_header\n draw_face_area(line_height * 1.5)\n draw_attr_area(0, line_height * 2 + 104)\n draw_skill_area(240, line_height * 2 + 104)\n end", "def reset_colors\n @color_output = false\n\n #Term::ANSIColor.coloring = true\n c = Term::ANSIColor\n @color_app_info = c.intense_white + c.bold\n @color_app_exe = c.intense_green + c.bold\n @color_command = c.intense_yellow\n @color_description = c.intense_white\n @color_parameter = c.intense_cyan\n @color_usage = c.intense_black + c.bold\n \n @color_error_word = c.intense_black + c.bold\n @color_error_name = c.intense_red + c.bold\n @color_error_description = c.intense_white + c.bold\n \n @color_bold = c.bold\n @color_reset = c.reset\n end", "def paint(src=dup_src)\n yield src.graphics\n src.graphics.dispose\n ImageVoodoo.new src\n end", "def restore_graphics_state\n @stack.pop\n end", "def clear_shadow\n @shadow_active = false\n end", "def clear_patches\n @patches.clear\n end", "def erase\n if self.validCDKObject\n CDK.eraseCursesWindow(@win)\n CDK.eraseCursesWindow(@shadow_win)\n end\n end", "def erase\n if self.validCDKObject\n CDK.eraseCursesWindow(@win)\n CDK.eraseCursesWindow(@shadow_win)\n end\n end", "def spray_paint(new_color)\n self.color = new_color\n puts \"Your car is sprayed with a new #{new_color} paint.\"\n end", "def destroy\n CDK.deleteCursesWindow(@shadow_win)\n CDK.deleteCursesWindow(@win)\n\n self.cleanBindings(:BUTTON)\n\n CDK::SCREEN.unregister(:BUTTON, self)\n end", "def setfillcolorind(*)\n super\n end", "def recycle_colors(color_index)\n #\"or\" used for control flow\n colors[i+1] or 0\n end", "def recycle_colors(color_index)\n #\"or\" used for control flow\n colors[i+1] or 0\n end", "def reset(cols, rows)\n\n\t@cols = cols.to_i.abs\n\t@rows = rows.to_i.abs\n\t@created = true\n\n\tx = 0\n\tuntil x > @rows\n\t y = 0\n\t until y > @cols\n\t\tset_pixel(\"#{y}-#{x}\", COLOR_WHITE)\n\t\ty = y+1\n\t end\n\t x = x+1\n\tend\n\n end", "def reset(view)\n # This variable keeps track of which point we are currently getting\n @state = 0\n @x1=0\n @x2=0\n @y1=0\n @y2=0\n\n # Display a prompt on the status bar\n Sketchup::set_status_text((\"Draw cut line through geometry. CTRL=Cut Nested Geometry\"), SB_PROMPT)\n\n # clear the InputPoints\n @ip1.clear\n @ip2.clear\n\n if view\n view.tooltip = nil\n view.invalidate if @drawn\n end\n @drawn = false\n @dragging = false\n end", "def refresh()\n self.contents.clear\n @cLevelUpLabel.draw()\n end", "def repaint\n curses.wclear(@pointer)\n if @box\n self.box\n end\n if @title_data\n str, color, att = @title_data\n self.title str, color, att\n end\n end", "def repaint # tabbedbutton\n $log.debug(\"TabbedBUTTon repaint : #{self.class()} r:#{@row} c:#{@col} #{getvalue_for_paint}\" )\n r,c = rowcol\n attribs = @attrs\n @highlight_foreground ||= $reversecolor\n @highlight_background ||= 0\n _state = @state\n _state = :SELECTED if @variable.value == @value \n case _state\n when :HIGHLIGHTED\n $log.debug(\"TabbedBUTTon repaint : HIGHLIGHTED #{bgcolor}, #{color}, v: #{@value}\" )\n bgcolor = @highlight_background\n color = @highlight_foreground\n bgcolor = @bgcolor\n color = @color\n attribs = Ncurses::A_BOLD\n setrowcol r,c # show cursor on highlighted as we tab through\n ## but when tabbing thru selected one, then selected one doesn't show cursor\n when :SELECTED\n $log.debug(\"TabbedBUTTon repaint : SELECTED #{bgcolor}, #{color}\")\n bgcolor = @bgcolor\n color = @color\n attribs = Ncurses::A_REVERSE\n if @state == :HIGHLIGHTED\n setrowcol r,c # show cursor on highlighted as we tab through\n end\n else\n $log.debug(\"TabbedBUTTon repaint : ELSE #{bgcolor}, #{color}\")\n bgcolor = @bgcolor\n color = @color\n end\n #bgcolor = @state==:HIGHLIGHTED ? @highlight_background : @bgcolor\n #color = @state==:HIGHLIGHTED ? @highlight_foreground : @color\n if bgcolor.is_a? String and color.is_a? String\n color = ColorMap.get_color(color, bgcolor)\n end\n value = getvalue_for_paint\n $log.debug(\"button repaint : r:#{r} #{@graphic.top} c:#{c} #{@graphic.left} color:#{color} bg #{bgcolor} v: #{value}, g: #{@graphic} \")\n len = @display_length || value.length\n # paint the tabs name in approp place with attribs\n #@form.window.printstring r, c, \"%-*s\" % [len, value], color, attribs\n #@graphic.printstring r+@graphic.top, c+@graphic.left, \"%-*s\" % [len, value], color, attribs\n #@graphic.printstring r-@graphic.top, c-@graphic.left, \"%-*s\" % [len, value], color, attribs\n @graphic.printstring r, c, \"%-*s\" % [len, value], color, attribs\n @graphic.modified = true\n# @form.window.mvchgat(y=r, x=c, max=len, Ncurses::A_NORMAL, bgcolor, nil)\n # underline for the top tab buttons.\n if @underline != nil\n r -= @graphic.top # because of pad, remove if we go back to windows\n c -= @graphic.left # because of pad, remove if we go back to windows\n @graphic.mvchgat(y=r, x=c+@underline+0, max=1, Ncurses::A_BOLD|Ncurses::A_UNDERLINE, color, nil)\n end\n end", "def safe_colorize_deactive\n CLIColorize.off\n end" ]
[ "0.6805248", "0.6805248", "0.66695136", "0.6562173", "0.65481436", "0.6455313", "0.644509", "0.6401377", "0.6291436", "0.62480426", "0.6159281", "0.6133729", "0.6079227", "0.6040476", "0.60047877", "0.5997728", "0.59894615", "0.5982495", "0.5982495", "0.5972957", "0.59623754", "0.59623754", "0.5961388", "0.5949624", "0.59317464", "0.58819306", "0.58581126", "0.58528143", "0.58498275", "0.5847369", "0.5840253", "0.5811373", "0.5758347", "0.5755597", "0.5752469", "0.5750115", "0.57224715", "0.56987405", "0.56986", "0.5668082", "0.5665315", "0.5664468", "0.5654995", "0.56509876", "0.5647318", "0.5647159", "0.56341845", "0.5627171", "0.56271505", "0.5615359", "0.5614766", "0.5603916", "0.5602896", "0.56001514", "0.55917406", "0.55879486", "0.5585374", "0.55827993", "0.5555131", "0.5553499", "0.5544164", "0.55362976", "0.5534123", "0.55252624", "0.5524039", "0.55156356", "0.55139816", "0.5498921", "0.5489542", "0.5484701", "0.54845744", "0.5479242", "0.5469647", "0.5461779", "0.54617274", "0.54576635", "0.5422367", "0.54131126", "0.5407801", "0.5399418", "0.53927165", "0.5389602", "0.53891414", "0.5371823", "0.53706115", "0.53602755", "0.5355085", "0.53504574", "0.53504574", "0.534825", "0.53481084", "0.5336029", "0.5330413", "0.5330413", "0.5326339", "0.5326047", "0.5321678", "0.53178567", "0.5317722", "0.5313809" ]
0.6655167
3
GET /question_option_selections GET /question_option_selections.json
def index @question_option_selections = @question_answer.question_option_selections end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @selections = Selection.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @selections }\n end\n end", "def get_choices\n @choices = CONNECTION.execute(\"SELECT * FROM choices WHERE question_id = #{@id};\")\n end", "def index\n @options = @question.options.all\n end", "def index\n @question_options = QuestionOption.all\n end", "def index\n @question_options = QuestionOption.find_all_by_question_id(@question.id)\n\n respond_to do |format|\n format.json { render :json => @question_options.to_json }\n format.xml { render :xml => @question_options.to_xml }\n end\n end", "def questions\n self.class.get(\"/2.2/questions\", @options)\n end", "def index\n @selections = Selection.all\n end", "def chosen_options\n Option.find_all_by_id session[:chosen_options]\n end", "def show\n \n load_quiz_section_and_question\n load_option\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @option }\n end\n end", "def set_question_option_selection\n @question_option_selection = QuestionAnswer.question_option_selections.find(params[:id])\n end", "def index\n @choices = Choice.all\n\n render json: @choices\n end", "def options\n SurveyQuestionOption.where(id: eval(selected_options))\n end", "def show\n @questions_option = QuestionsOption.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @questions_option }\n end\n end", "def show\n render json: @choice\n end", "def index\n @survey_questions = SurveyQuestion.all\n render json: @survey_questions.to_json(include: {\n answer_options: {\n include: {\n chosen_answers: {}\n } \n }\n })\n end", "def index\n @choice_sets = ChoiceSet.all\n end", "def index\n @selections = Selection.all(:include => {:place => :category})\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @selections }\n format.json { render :json => @selections }\n end\n end", "def index\n @options = @question.options.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @options }\n end\n end", "def show\n\t\t_get_current_question_and_choices(params[:id])\n\tend", "def index\n render status: :ok, json: @simple_question_alternatives\n end", "def index\n @selected_answers = SelectedAnswer.all\n end", "def getChoices(token, pollnum)\n\t\turl = \"/polls/#{pollnum}\"\n\t\theaders = { 'Content-Type' => 'application/json',\n\t\t\t'Authorization' => 'Bearer #{token}'}\n\t\tresponse = HTTParty.get(url, :headers => headers)\n\t\tresult = response['choices']\n\t\treturn result\n\tend", "def choices_ok(question) question.get_choice_ok_from_idurls(choice_idurls_ok) end", "def questions_list \n #render json: {status: 200, questions: Quiz.all, msg: \"Success.\"}\n render json: {status: 200, questions: Quiz.all.map{|que| [id: que.id, question: que.question, options: [que.opt1,que.opt2,que.opt3,que.opt4], answer: que.answer]}.flatten, msg: \"Success.\"}\n end", "def question_option_selection_params\n params.require(:question_option_selection).permit(:question_answer_id, :question_option_id)\n end", "def answer\n @form_data = Form.get_published_form(params[:code])\n if @form_data.nil?\n redirect_to \"/dashboard\"\n else\n @questions = Question.get_questions_by_ids(@form_data['id'], JSON.parse(@form_data['question_order']))\n @all_options = Option.collect_options_per_quetions(JSON.parse(@form_data['question_order']))\n end\n end", "def get_choices(question)\n puts 'get_choices()'\n choices = Choice.select('id, prompt').find(question.correct_choice_id, question.close_choice_id)\n choices += Choice.select('id, prompt').where.not(id: question.correct_choice_id).where.not(id: question.close_choice_id).where(choice_type:0).shuffle.first(3)\n choices.shuffle!\n end", "def choices\n @@choices\n end", "def get_choices\n @choices = Choice.where(\"user_id\" => self.id)\n end", "def show\n @survey_question_option = SurveyQuestionOption.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @survey_question_option }\n end\n end", "def index\n @choice_items = ChoiceItem.all\n end", "def choose_question\n if params.dig(:assessment, :type).present? && params.dig(:assessment, :type_id).present?\n type = params[:assessment][:type].camelize.constantize.where(id: params[:assessment][:type_id]).first rescue ''\n if type.present?\n all_questions = fetch_all_questions(type)\n if all_questions.count > 0\n assessment_questions = Assessment.fetch_assessment_questions(all_questions.ids, current_user.id)\n render json: calculate_remaining_qusts(all_questions, assessment_questions).order(\"RANDOM()\").limit(2).select(:id, :content, :options)\n else\n render json: {'type': 'No data found for selected type'}\n end\n else\n render json: {'type': 'Invalid selected type or type id'}\n end\n else\n render json: {'Input': 'Invalid inputs'}\n end\n end", "def getvotes\n @the_question = Question.find(params[:id])\n render json: [{question: @the_question}, {votes: @the_question.votes_for}] and return\n end", "def show\n @item = Vger::Resources::Suitability::Item.find(params[:id])\n @options = Vger::Resources::Suitability::Option.where(\n query_options: {\n item_id: @item.id\n },\n methods: [:reference_option_body]\n )\n respond_to do |format|\n format.html\n end\n end", "def get_question_list\n json= RestClient.get(\"http://localhost:3000/questions\")\n JSON.parse(json)\n end", "def index\n @store = Store.find(params[:store_id])\n @dish_choices = @store.dish_choices\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dish_choices }\n end\n end", "def render_multiple_choice(q)\n ans = array_of_answers(q)\n question_text = q.multiple ? '(Select all that apply.) ' + q.question_text : q.question_text\n question_type = q.multiple ? 'multiple_answers_question' : 'multiple_choice_question'\n comments_key = q.raw? ? :incorrect_comments_html : :incorrect_comments_text\n\n ques = {\n :quiz_group_id => @current_group_id,\n :question_name => \"#{q.points} point#{'s' if q.points > 1}\",\n :question_type => question_type,\n :points_possible => q.points,\n :question_text => question_text,\n :position => 10000,\n :answers => ans\n }\n { question: ques }\n end", "def show\n @question_option = QuestionOption.find(params[:id])\n check_forged_path\n\n respond_to do |format|\n format.json { render :json => @question_option.to_json }\n format.xml { render :xml => @question_option.to_xml }\n end\n end", "def index\n @choices = Choice.all\n end", "def index\n @choices = Choice.all\n end", "def options\n case object.question_type\n when 'dropdown'\n object.dropdown_options\n when 'range'\n object.range_options\n else\n []\n end\n end", "def options_for_action_select\n source_array = []\n self.questions.each do |q|\n if q.class == MatrixQuestion\n q.choice_questions.each {|cq| source_array << [\"#{q.question_content.statement}: #{cq.question_content.statement} response\", \"#{cq.question_content.id}\"]}\n else\n source_array << [\"#{q.question_content.statement} response\", \"#{q.question_content.id}\"]\n end\n end\n source_array\n end", "def show\n @multiple_choice_question = MultipleChoiceQuestion.find(params[:id])\n @possible_answers = []\n @multiple_choice_question.wrong_answers.split(\",\").each do |wrong_answer|\n @possible_answers << wrong_answer\n end\n @possible_answers << @multiple_choice_question.correct_answer\n @possible_answers.shuffle!\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @multiple_choice_question }\n end\n end", "def index\n render status: :ok, json: @group_question_alternatives\n end", "def add_option\n render json: Option.create_default_option(params[:question_id])\n end", "def show\n @poll_options_set = PollOptionsSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @poll_options_set }\n end\n end", "def correct_options\n Survey::Question.where(section_id: section_ids).map(&:correct_options).flatten\n end", "def responses\n question=Question.find(params[:questionId])\n render :json=> question.response\n end", "def index\n params.require(:course)\n @questions = Course.find(params[:course]).questions.select {|q| q.answered == false}\n\n render json: @questions\n end", "def show\n @choices = Choice.where(course_id: @course.id)\n end", "def preview\n @form_data = Form.get_form_by_code(current_user[\"id\"], params[:code])\n @questions = Question.get_questions_by_ids(@form_data['id'], JSON.parse(@form_data['question_order']))\n @all_options = Option.collect_options_per_quetions(JSON.parse(@form_data['question_order']))\n end", "def index\n @attempt_choices = AttemptChoice.all\n end", "def serve_choice_array(question_prompt)\n if question_prompt.specific.choices.nil?\n return [\"No answers available\"]\n else\n answers = Array.new\n raw = question_prompt.specific.choices.sort_by{ |a| a[:position] }\n raw.each do |c|\n answers.push(c)\n end\n if question_prompt.specific.is_scrambled\n scrambled = Array.new\n until answers.empty?\n rand = Random.rand(answers.length)\n scrambled.push(answers.delete_at(rand))\n end\n answers = scrambled\n end\n return answers\n end\n end", "def selected_options; end", "def selected_options; end", "def choices\n choices = serialization_options[:choices]\n ActiveModel::ArraySerializer.new(choices, each_serializer: ChoiceTreeSerializer)\n end", "def add_others_option\n render json: Option.add_others_option(params[:question_id])\n end", "def index\n @questions = @subsection.questions.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @questions }\n end\n end", "def index\n @options = Option.all\n end", "def index\n @options = Option.all\n end", "def index\n @options = Option.all\n end", "def index\n @options = Option.all\n end", "def index\n @options = Option.all\n end", "def show\n @quick_poll_option = QuickPollOption.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quick_poll_option }\n end\n end", "def index\n @possible_answers = PossibleAnswer.all\n end", "def new\n \n load_quiz_section_and_question\n @option = Option.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @option }\n end\n end", "def show\n render_json @question\n end", "def show\n @store = Store.find(params[:store_id])\n @dish_choice = @store.dish_choices.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dish_choice }\n end\n end", "def get_questions\n items = get_items\n make_response(HttpStatus::OK, make_result_list(items))\nend", "def new\n @questions_option = QuestionsOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @questions_option }\n end\n end", "def show\n @time_series_question = @time_series.questions.find(params[:id])\n @datasets = @time_series.datasets.sorted\n add_common_options\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_series_question }\n end\n end", "def render_answer\n @selected.map(&:value)\n end", "def find_selected\n selected_quests = self.user_quests.where(complete: false)\n selected_quests.map do |x|\n x.quest_id\n end\n end", "def create\n @question_option_selection = @question_answer.question_option_selection.build(question_option_selection_params)\n\n respond_to do |format|\n if @question_option_selection.save\n format.html { redirect_to @question_answer_question_option_selection_path(@question_answer), notice: 'Question option selection was successfully created.' }\n format.json { render :show, status: :created, location: @question_option_selection }\n else\n format.html { render :new }\n format.json { render json: @question_option_selection.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @options = Option.all\n end", "def show\n @choices = Choice.where(employee_id: @employee.id)\n end", "def show\n @answer = Answer.find(params[:answer_id])\n @available_tags = @answer.available_tags\n end", "def choice_params\n params.require(:choice).permit(:question_id, :statement, :selected)\n end", "def show\n @option = Vger::Resources::Suitability::Option.find(params[:id], :factor_id => params[:factor_id], :item_id => params[:item_id], :methods => [:option_type])\n respond_to do |format|\n format.html\n end\n end", "def set_choice\n @choice = @question.choices.find(params[:id])\n end", "def getdata\n \n #@survey = Survey.find(params[:survey_id])\n #@questions = Question.where(survey_section_id: @survey.sections.ids)\n #@answerOptions = \n # this contains what has been selected in the first select box\n authorize! :post, @survey\n\n @data_from_select1 = params[:first_select]\n\n\n # we get the data for selectbox 2\n @data_for_select2 = @questions.where(:name => @data_from_select1).all\n\n # render an array in JSON containing arrays like:\n # [[:id1, :name1], [:id2, :name2]]\n respond_to do |format|\n format.html {}\n format.json {render :json => @data_for_select2.map{|c| [c.id, c.name]}}\n end\n \n end", "def serve_choice_array\n if self.choices.nil?\n return [\"No answers available\"]\n else\n answers = Array.new\n raw = self.choices.sort_by{|a| a[:order]}\n raw.each do |c|\n formatted = c\n formatted[:answer] = make_html(c[:answer])\n answers.push( formatted )\n end\n if self.mcq_is_scrambled\n scrambled = Array.new\n until answers.empty?\n rand = Random.rand(answers.length)\n scrambled.push(answers.delete_at(rand))\n end\n answers = scrambled\n end\n return answers\n end\n end", "def index\n @survey_questions = get_survey_questions\n end", "def index\n @survey_questions = get_survey_questions\n end", "def show\n authorize! :answer, @questionnaire\n\n respond_to do |format|\n format.html {\n @answer_set = AnswerSet.new()\n @answer_set.questionnaire_id = @questionnaire.id\n @answer_set.init_questionnaire(@questionnaire)\n }\n format.json { render :json => @questionnaire.questions.to_json }\n end\n end", "def answer_a_question\n user = current_user\n render_401 and return unless user\n question = ShortQuestion.find_by_id(params[:id])\n render_404 and return unless question\n\n obj = {\n :qid => params[:id],\n :answer => params[:choice]\n }\n \n answers = {}\n $r.multi do\n $r.lpush(\"user:#{user.id}:questions\", obj)\n $r.hincrby(\"question:#{question.id}:answers\", \"choice#{params[:choice]}\", 1)\n choices = $r.hget(\"question:#{question.id}:answers\", :num_choices)\n for i in 1..choices\n answers[i] = $r.hget(\"question:#{question.id}:answers\", \"choice#{i}\")\n end\n end\n render :json => {\n :success => true,\n :answers => answers\n }\n end", "def index\n if get_event\n @v1_answers = @event.alternatives\n render json: @v1_answers\n else\n @v1_answers = V1::Answer.all\n render json: @v1_answers\n end\n end", "def questions\n # Get a list of questionnaires that belong to instances of the current race\n if @course\n questionnaire_ids = @course.questionnaire_ids\n elsif @instance\n questionnaire_ids = @instance.questionnaire_ids\n else\n questionnaire_ids = []\n end\n\n # Collect question_ids that are used in those questionnaires\n question_ids = Set.new\n Questionnaire.where(:id => questionnaire_ids).find_each do |questionnaire|\n question_ids.merge(questionnaire.question_ids)\n end\n\n @questions = Question.find(question_ids.to_a)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @questions.to_json }\n end\n end", "def index\n @questions = @questionable.questions\n end", "def prebooking_questions\n\n # this is a patch\n if @url.blank? or @token.blank?\n return []\n end\n\n [\n {\n question: \"How many guests will be riding with you?\", \n choices: [0,1,2,3], \n code: \"guests\"\n },\n {\n question: \"How many attendants will be riding with you?\", \n choices: [0,1,2,3], \n code: \"attendants\"\n },\n {\n question: \"How many mobility devices will you be bringing?\", \n choices: [0,1,2,3], \n code: \"mobility_devices\"\n },\n {\n question: \"What is your trip purpose?\", \n choices: (trip_purposes[\"trip_purposes\"] || \n Config.ride_pilot_purposes.try(:map) {|k,v| {\"name\" => k, \"code\" => v}} || \n []).map{|p| [p[\"name\"], p[\"code\"]]}, \n code: \"purpose\"\n }\n ]\n end", "def show\n @exam_option = ExamOption.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam_option }\n end\n end", "def get_chosen_answers\n ChosenAnswer.order('created_at DESC')\n end", "def all_answered_options\n self.user_answers.map{ |answer| answer.answer_option}\n end", "def index\n @choice_tests = ChoiceTest.all\n end", "def show\n @survey_choice = Survey::Choice.find(params[:id])\n\n respond_to do |format|\n format.html {redirect_to @survey_choice.question}\n format.json { render json: @survey_choice }\n format.js\n end\n end", "def show\n @response = Response.find(params[:response_id])\n @request_selection = RequestSelection.find(params[:id])\n\n #@request_selection = RequestSelection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @request_selection }\n end\n end", "def options\n @session_user = User.find(session[:user_id])\n @page = @session_user.page\n options = Array.new\n for panel in @page.panels.order(:created_at)\n if panel.type == 'MSelectpanel' || panel.type == 'SSelectpanel'\n if panel.options\n for option in panel.options.order(:created_at)\n options.push(option)\n end\n end \n end \n end\n render json: options\n end", "def select_solution\n if session[:solution]\n load_sections(params[:chosen] && params[:chosen].to_i)\n else\n render :nothing => true\n end\n end", "def types\n types = Question.distinct.pluck(:type)\n render json: types.to_a\n end", "def index\n @questions = @time_series.questions.sorted\n @datasets = @time_series.datasets.sorted\n add_common_options\n\n respond_to do |format|\n format.html\n format.js { render json: @questions}\n end\n end" ]
[ "0.66065097", "0.6558567", "0.65470684", "0.64444864", "0.6403623", "0.63972723", "0.6378797", "0.63696617", "0.634588", "0.63029164", "0.62848073", "0.6263732", "0.62483597", "0.6207424", "0.6025557", "0.602436", "0.60094285", "0.5992142", "0.5974422", "0.59623593", "0.5960225", "0.5920317", "0.5903237", "0.5875504", "0.58625937", "0.58399975", "0.58305544", "0.58235055", "0.5822496", "0.5806423", "0.58048034", "0.57770544", "0.5759151", "0.5744957", "0.5738784", "0.56899977", "0.56751776", "0.56749725", "0.5650763", "0.5650763", "0.5645475", "0.5633246", "0.5629975", "0.5629492", "0.56200254", "0.55920327", "0.55844355", "0.5576079", "0.55589277", "0.5558026", "0.5557847", "0.55511755", "0.5532338", "0.5522806", "0.5522806", "0.5519621", "0.55173784", "0.55171865", "0.5513995", "0.5513995", "0.5513995", "0.5513995", "0.5513995", "0.55123174", "0.55018014", "0.5501175", "0.54829115", "0.5472044", "0.5471038", "0.5468119", "0.54673624", "0.5463263", "0.54508865", "0.5449095", "0.54484534", "0.5438617", "0.543157", "0.5422527", "0.54023695", "0.5401657", "0.5387501", "0.5385201", "0.5373886", "0.5373886", "0.5364308", "0.53570914", "0.53511345", "0.5345499", "0.53453034", "0.53380156", "0.53227645", "0.5318217", "0.5311068", "0.53087765", "0.53001493", "0.5298331", "0.52981186", "0.5287609", "0.5281199", "0.5280871" ]
0.769497
0
GET /question_option_selections/1 GET /question_option_selections/1.json
def show end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @question_option_selections = @question_answer.question_option_selections\n end", "def show\n @questions_option = QuestionsOption.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @questions_option }\n end\n end", "def set_question_option_selection\n @question_option_selection = QuestionAnswer.question_option_selections.find(params[:id])\n end", "def show\n \n load_quiz_section_and_question\n load_option\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @option }\n end\n end", "def get_choices\n @choices = CONNECTION.execute(\"SELECT * FROM choices WHERE question_id = #{@id};\")\n end", "def index\n @options = @question.options.all\n end", "def index\n @question_options = QuestionOption.all\n end", "def show\n @survey_question_option = SurveyQuestionOption.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @survey_question_option }\n end\n end", "def index\n @question_options = QuestionOption.find_all_by_question_id(@question.id)\n\n respond_to do |format|\n format.json { render :json => @question_options.to_json }\n format.xml { render :xml => @question_options.to_xml }\n end\n end", "def show\n render json: @choice\n end", "def index\n @selections = Selection.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @selections }\n end\n end", "def index\n @choices = Choice.all\n\n render json: @choices\n end", "def choose_question\n if params.dig(:assessment, :type).present? && params.dig(:assessment, :type_id).present?\n type = params[:assessment][:type].camelize.constantize.where(id: params[:assessment][:type_id]).first rescue ''\n if type.present?\n all_questions = fetch_all_questions(type)\n if all_questions.count > 0\n assessment_questions = Assessment.fetch_assessment_questions(all_questions.ids, current_user.id)\n render json: calculate_remaining_qusts(all_questions, assessment_questions).order(\"RANDOM()\").limit(2).select(:id, :content, :options)\n else\n render json: {'type': 'No data found for selected type'}\n end\n else\n render json: {'type': 'Invalid selected type or type id'}\n end\n else\n render json: {'Input': 'Invalid inputs'}\n end\n end", "def add_option\n render json: Option.create_default_option(params[:question_id])\n end", "def show\n\t\t_get_current_question_and_choices(params[:id])\n\tend", "def questions\n self.class.get(\"/2.2/questions\", @options)\n end", "def index\n render status: :ok, json: @simple_question_alternatives\n end", "def show\n @quick_poll_option = QuickPollOption.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quick_poll_option }\n end\n end", "def show\n @question_option = QuestionOption.find(params[:id])\n check_forged_path\n\n respond_to do |format|\n format.json { render :json => @question_option.to_json }\n format.xml { render :xml => @question_option.to_xml }\n end\n end", "def show\n @poll_options_set = PollOptionsSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @poll_options_set }\n end\n end", "def options\n SurveyQuestionOption.where(id: eval(selected_options))\n end", "def new\n \n load_quiz_section_and_question\n @option = Option.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @option }\n end\n end", "def index\n @selections = Selection.all\n end", "def show\n @item = Vger::Resources::Suitability::Item.find(params[:id])\n @options = Vger::Resources::Suitability::Option.where(\n query_options: {\n item_id: @item.id\n },\n methods: [:reference_option_body]\n )\n respond_to do |format|\n format.html\n end\n end", "def new\n @questions_option = QuestionsOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @questions_option }\n end\n end", "def index\n @options = @question.options.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @options }\n end\n end", "def show\n if @v1_question\n render json: @v1_question\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end", "def chosen_options\n Option.find_all_by_id session[:chosen_options]\n end", "def index\n @survey_questions = SurveyQuestion.all\n render json: @survey_questions.to_json(include: {\n answer_options: {\n include: {\n chosen_answers: {}\n } \n }\n })\n end", "def choices_ok(question) question.get_choice_ok_from_idurls(choice_idurls_ok) end", "def getvotes\n @the_question = Question.find(params[:id])\n render json: [{question: @the_question}, {votes: @the_question.votes_for}] and return\n end", "def show\n @option = Vger::Resources::Suitability::Option.find(params[:id], :factor_id => params[:factor_id], :item_id => params[:item_id], :methods => [:option_type])\n respond_to do |format|\n format.html\n end\n end", "def getChoices(token, pollnum)\n\t\turl = \"/polls/#{pollnum}\"\n\t\theaders = { 'Content-Type' => 'application/json',\n\t\t\t'Authorization' => 'Bearer #{token}'}\n\t\tresponse = HTTParty.get(url, :headers => headers)\n\t\tresult = response['choices']\n\t\treturn result\n\tend", "def show\n @exam_option = ExamOption.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @exam_option }\n end\n end", "def index\n @choice_sets = ChoiceSet.all\n end", "def answer\n @form_data = Form.get_published_form(params[:code])\n if @form_data.nil?\n redirect_to \"/dashboard\"\n else\n @questions = Question.get_questions_by_ids(@form_data['id'], JSON.parse(@form_data['question_order']))\n @all_options = Option.collect_options_per_quetions(JSON.parse(@form_data['question_order']))\n end\n end", "def set_choice\n @choice = @question.choices.find(params[:id])\n end", "def show\n @option = Option.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @option }\n end\n end", "def show\n @option = Option.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @option }\n end\n end", "def add_others_option\n render json: Option.add_others_option(params[:question_id])\n end", "def answer_a_question\n user = current_user\n render_401 and return unless user\n question = ShortQuestion.find_by_id(params[:id])\n render_404 and return unless question\n\n obj = {\n :qid => params[:id],\n :answer => params[:choice]\n }\n \n answers = {}\n $r.multi do\n $r.lpush(\"user:#{user.id}:questions\", obj)\n $r.hincrby(\"question:#{question.id}:answers\", \"choice#{params[:choice]}\", 1)\n choices = $r.hget(\"question:#{question.id}:answers\", :num_choices)\n for i in 1..choices\n answers[i] = $r.hget(\"question:#{question.id}:answers\", \"choice#{i}\")\n end\n end\n render :json => {\n :success => true,\n :answers => answers\n }\n end", "def index\n @selected_answers = SelectedAnswer.all\n end", "def new\n @question = current_user.questions.new\n\t2.times do\n\t @question.choices.build\n\tend\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def new\n @question_requirement = QuestionRequirement.new\n @question_requirement.question_id = params[:id]\n\n @options = @question_requirement.question.survey.options\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @question_requirement }\n end\n end", "def index\n @answers = Answer.where(url_params)\n if @answers.size == 1\n @answers.first!\n end\n render json: @answers\n end", "def show\n @store = Store.find(params[:store_id])\n @dish_choice = @store.dish_choices.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dish_choice }\n end\n end", "def new\n @survey_question_option = SurveyQuestionOption.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @survey_question_option }\n end\n end", "def show\n @auto_option = AutoOption.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @auto_option }\n end\n end", "def show\n @survey_choice = Survey::Choice.find(params[:id])\n\n respond_to do |format|\n format.html {redirect_to @survey_choice.question}\n format.json { render json: @survey_choice }\n format.js\n end\n end", "def question_option_selection_params\n params.require(:question_option_selection).permit(:question_answer_id, :question_option_id)\n end", "def get_choices(question)\n puts 'get_choices()'\n choices = Choice.select('id, prompt').find(question.correct_choice_id, question.close_choice_id)\n choices += Choice.select('id, prompt').where.not(id: question.correct_choice_id).where.not(id: question.close_choice_id).where(choice_type:0).shuffle.first(3)\n choices.shuffle!\n end", "def responses\n question=Question.find(params[:questionId])\n render :json=> question.response\n end", "def show\n @option = Vger::Resources::Mrf::Option.find(params[:id], :item_id => params[:item_id])\n respond_to do |format|\n format.html\n end\n end", "def get_choices\n @choices = Choice.where(\"user_id\" => self.id)\n end", "def show\n @response = Response.find(params[:response_id])\n @request_selection = RequestSelection.find(params[:id])\n\n #@request_selection = RequestSelection.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @request_selection }\n end\n end", "def show\n @multiple_choice_question = MultipleChoiceQuestion.find(params[:id])\n @possible_answers = []\n @multiple_choice_question.wrong_answers.split(\",\").each do |wrong_answer|\n @possible_answers << wrong_answer\n end\n @possible_answers << @multiple_choice_question.correct_answer\n @possible_answers.shuffle!\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @multiple_choice_question }\n end\n end", "def index\n @choice_items = ChoiceItem.all\n end", "def new\n @quick_poll_option = QuickPollOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quick_poll_option }\n end\n end", "def show\n render_json @question\n end", "def get_question_list\n json= RestClient.get(\"http://localhost:3000/questions\")\n JSON.parse(json)\n end", "def show\n authorize! :answer, @questionnaire\n\n respond_to do |format|\n format.html {\n @answer_set = AnswerSet.new()\n @answer_set.questionnaire_id = @questionnaire.id\n @answer_set.init_questionnaire(@questionnaire)\n }\n format.json { render :json => @questionnaire.questions.to_json }\n end\n end", "def getdata\n \n #@survey = Survey.find(params[:survey_id])\n #@questions = Question.where(survey_section_id: @survey.sections.ids)\n #@answerOptions = \n # this contains what has been selected in the first select box\n authorize! :post, @survey\n\n @data_from_select1 = params[:first_select]\n\n\n # we get the data for selectbox 2\n @data_for_select2 = @questions.where(:name => @data_from_select1).all\n\n # render an array in JSON containing arrays like:\n # [[:id1, :name1], [:id2, :name2]]\n respond_to do |format|\n format.html {}\n format.json {render :json => @data_for_select2.map{|c| [c.id, c.name]}}\n end\n \n end", "def create\n @question_option_selection = @question_answer.question_option_selection.build(question_option_selection_params)\n\n respond_to do |format|\n if @question_option_selection.save\n format.html { redirect_to @question_answer_question_option_selection_path(@question_answer), notice: 'Question option selection was successfully created.' }\n format.json { render :show, status: :created, location: @question_option_selection }\n else\n format.html { render :new }\n format.json { render json: @question_option_selection.errors, status: :unprocessable_entity }\n end\n end\n end", "def show\n @choices = Choice.where(course_id: @course.id)\n end", "def index\n render status: :ok, json: @group_question_alternatives\n end", "def index\n @selections = Selection.all(:include => {:place => :category})\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @selections }\n format.json { render :json => @selections }\n end\n end", "def set_question_option\n @question_option = QuestionOption.find(params[:id])\n end", "def questions_list \n #render json: {status: 200, questions: Quiz.all, msg: \"Success.\"}\n render json: {status: 200, questions: Quiz.all.map{|que| [id: que.id, question: que.question, options: [que.opt1,que.opt2,que.opt3,que.opt4], answer: que.answer]}.flatten, msg: \"Success.\"}\n end", "def index\n @store = Store.find(params[:store_id])\n @dish_choices = @store.dish_choices\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @dish_choices }\n end\n end", "def get_one\n question_data = Question.new.get_one( params[:id] )\n return render json: question_data\n end", "def index\n @choices = Choice.all\n end", "def index\n @choices = Choice.all\n end", "def show\n @time_series_question = @time_series.questions.find(params[:id])\n @datasets = @time_series.datasets.sorted\n add_common_options\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_series_question }\n end\n end", "def show\n @question = Question.find(params[:id])\n\t@choice0 = @question.choices[0]\n\t@choice1 = @question.choices[1]\n#\t@comment0 = @choice0.comments.build(:choice_id => @choice0.id, :user_id => current_user.id)\n#\t@comment1 = @choice1.comments.build(:choice_id => @choice1.id, :user_id => current_user.id)\n#\t@comment0 = @choice0.comments.build()\n#\t@comment1 = @choice1.comments.build()\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question }\n end\n end", "def show\n @mainoption = Mainoption.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mainoption }\n end\n end", "def show\n @question_set = QuestionSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question_set }\n end\n end", "def index\n @attempt_choices = AttemptChoice.all\n end", "def create\n \n puts option_params\n @option = Option.new(option_params)\n puts @option.Question_id\n \n respond_to do |format|\n if @option.save\n format.html { redirect_to @option, notice: 'Option was successfully created.' }\n format.json { render :show, status: :created, location: @option }\n else\n format.html { render :new }\n format.json { render json: @option.errors, status: :unprocessable_entity }\n end\n end\n end", "def render_multiple_choice(q)\n ans = array_of_answers(q)\n question_text = q.multiple ? '(Select all that apply.) ' + q.question_text : q.question_text\n question_type = q.multiple ? 'multiple_answers_question' : 'multiple_choice_question'\n comments_key = q.raw? ? :incorrect_comments_html : :incorrect_comments_text\n\n ques = {\n :quiz_group_id => @current_group_id,\n :question_name => \"#{q.points} point#{'s' if q.points > 1}\",\n :question_type => question_type,\n :points_possible => q.points,\n :question_text => question_text,\n :position => 10000,\n :answers => ans\n }\n { question: ques }\n end", "def show\n @questionset = Questionset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @questionset }\n end\n end", "def show\n @tool_specialty_option = ToolSpecialtyOption.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tool_specialty_option }\n end\n end", "def show\n if @v1_answer\n render json: @v1_alternative\n else\n render json: get_errors(@v1_alternative), status: :unprocessable_entity\n end\n end", "def show\n @option_value = OptionValue.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @option_value }\n end\n end", "def choice(id, account: nil)\n get account, \"field/#{id}/choice\", {}\n end", "def show\n @story_choice = StoryChoice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @story_choice }\n end\n end", "def index\n if get_event\n @v1_answers = @event.alternatives\n render json: @v1_answers\n else\n @v1_answers = V1::Answer.all\n render json: @v1_answers\n end\n end", "def index\n @options = Option.all\n end", "def index\n @options = Option.all\n end", "def index\n @options = Option.all\n end", "def index\n @options = Option.all\n end", "def index\n @options = Option.all\n end", "def render_answer\n @selected.map(&:value)\n end", "def set_question_option\n @question_option = QuestionOption.find(params[:id])\n end", "def show\n @selection = Selection.find(params[:id])\n if @selection.nil?\n @user_name = params[:user_name]\n @selection_name = params[:selection_name]\n @selection = Selection.first(:public_url => \"#{@user_name}/#{@selection_name}\")\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @selection }\n end\n end", "def show\n @data_collection = DataCollection.find(params[:id])\n @questionnaires = @data_collection.questionnaires\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @data_collection }\n end\n end", "def new\n @survey_question = SurveyQuestion.new\n 2.times { @survey_question.survey_options.build }\n\n respond_to do |format|\n format.html # new.html.erb\n #format.json { render json: @survey_question }\n end\n end", "def index\n @possible_answers = PossibleAnswer.all\n end", "def new\n @poll_options_set = PollOptionsSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poll_options_set }\n end\n end", "def show\n @sellable = Sellable.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sellable }\n end\n end", "def show\n @poll_question = PollQuestion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @poll_question }\n end\n end", "def show\n @question_option = QuestionOption.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @question_option }\n end\n end" ]
[ "0.7469291", "0.666653", "0.6534739", "0.6514095", "0.6494142", "0.64826936", "0.6421232", "0.63739496", "0.6372789", "0.6346742", "0.634618", "0.6244067", "0.61738575", "0.61560106", "0.6140834", "0.6109289", "0.60785156", "0.60743695", "0.60537857", "0.6049564", "0.60258484", "0.60092515", "0.6008934", "0.5985836", "0.59751505", "0.5969829", "0.59608793", "0.59576905", "0.59287065", "0.5897206", "0.5873127", "0.5865152", "0.5850681", "0.58499897", "0.5843988", "0.5837202", "0.58357996", "0.58167624", "0.58167624", "0.5811005", "0.58060926", "0.57999396", "0.5795462", "0.57834405", "0.5774192", "0.5773479", "0.57628155", "0.57604784", "0.5743288", "0.57379156", "0.5727084", "0.5724176", "0.5715292", "0.5711758", "0.5689574", "0.5674137", "0.567128", "0.56643045", "0.565066", "0.5642852", "0.56422895", "0.56380105", "0.5623076", "0.5622748", "0.562264", "0.5621295", "0.5620269", "0.5606231", "0.5600231", "0.5599275", "0.5593937", "0.5593937", "0.55800164", "0.55625993", "0.5555315", "0.55236065", "0.551969", "0.55187804", "0.55182016", "0.55116266", "0.5505259", "0.5498385", "0.5496902", "0.54941565", "0.54924625", "0.5488636", "0.5484127", "0.5484127", "0.5484127", "0.5484127", "0.5484127", "0.5475661", "0.54694647", "0.546438", "0.54623926", "0.54559994", "0.54480785", "0.54391855", "0.5436446", "0.54340607", "0.54288495" ]
0.0
-1
POST /question_option_selections POST /question_option_selections.json
def create @question_option_selection = @question_answer.question_option_selection.build(question_option_selection_params) respond_to do |format| if @question_option_selection.save format.html { redirect_to @question_answer_question_option_selection_path(@question_answer), notice: 'Question option selection was successfully created.' } format.json { render :show, status: :created, location: @question_option_selection } else format.html { render :new } format.json { render json: @question_option_selection.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def index\n @question_option_selections = @question_answer.question_option_selections\n end", "def question_option_selection_params\n params.require(:question_option_selection).permit(:question_answer_id, :question_option_id)\n end", "def add_option\n render json: Option.create_default_option(params[:question_id])\n end", "def set_question_option_selection\n @question_option_selection = QuestionAnswer.question_option_selections.find(params[:id])\n end", "def choice_params\n params.require(:choice).permit(:question_id, :statement, :selected)\n end", "def question_params\n params.require(:question).permit(:question_title, :quiz_id, choices_attributes: [])\n end", "def choice_params\n params.require(:choice).permit(:answer, :correct_answer)\n end", "def create\n @option = @question.options.new(option_params)\n authorize(@option)\n respond_to do |format|\n if @option.save\n format.html { redirect_to question_options_url(@option.question), notice: \"Option was successfully created.\" }\n format.json { render :show, status: :created, location: question_options_url(@option.question) }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @option.errors, status: :unprocessable_entity }\n end\n end\n end", "def add_others_option\n render json: Option.add_others_option(params[:question_id])\n end", "def option_params\n params.require(:option).permit(:answer, :count)\n end", "def option_params\n \n \n params.require(:option).permit(:Question_id, :correct, :text)\n\n \n end", "def add_option_selection \n @product = Product.find(params[:product_id])\n @product_option = ProductOption.find(params[:product_option_id])\n name = params[:product_option_selection][:name]\n weight_adjustment = params[:product_option_selection][:weight_adjustment]\n price_adjustment = params[:product_option_selection][:price_adjustment]\n sku_adjustment = params[:product_option_selection][:sku_adjustment]\n @selection = ProductOptionSelection.new(:name => name,\n :weight_adjustment => weight_adjustment,\n :price_adjustment => price_adjustment,\n :sku_adjustment => sku_adjustment)\n @product_option.product_option_selections << @selection\n\n end", "def choice_params\n params.require(:choice).permit(:option, :option_a, :option_b, :option_a_image, :option_b_image, :option_a_votes, :option_b_votes)\n end", "def questionary_choice_params\n params.require(:questionary_choice).permit(:content, :value, :questionary_item_id)\n end", "def choice_params\n params.require(:choice).permit(:text, :correct, :dummya, :dummyb, :dummyc, :hint, :comment, :question_id)\n end", "def question_params\n params.require(:question).permit(:body, :slide, :presentation_id, :choices => [])\n end", "def question_option_params\n params.require(:question_option).permit(:question_id, :title)\n end", "def create\n @question_option = QuestionOption.new(question_option_params)\n\n respond_to do |format|\n if @question_option.save\n format.html { redirect_to @question_option, notice: 'Question option was successfully created.' }\n format.json { render :show, status: :created, location: @question_option }\n else\n format.html { render :new }\n format.json { render json: @question_option.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n \n load_quiz_section_and_question\n \n @option = Option.new(params[:option])\n @option.question_id = @question.id\n \n respond_to do |format|\n if @option.save\n format.html { redirect_to admins_quiz_section_question_path(@quiz,@section,@question.sequence_no), notice: 'Option was successfully created.' }\n format.json { render json: [@option.question.section.quiz,@option.question.section,@option.question,@option], status: :created, location: @option }\n else\n format.html { render action: \"new\" }\n format.json { render json: @option.errors, status: :unprocessable_entity }\n end\n end\n end", "def choice_params\n\t\t\tparams.require(:choice).permit(:title, :question_id)\n\t\tend", "def create\n \n puts option_params\n @option = Option.new(option_params)\n puts @option.Question_id\n \n respond_to do |format|\n if @option.save\n format.html { redirect_to @option, notice: 'Option was successfully created.' }\n format.json { render :show, status: :created, location: @option }\n else\n format.html { render :new }\n format.json { render json: @option.errors, status: :unprocessable_entity }\n end\n end\n end", "def save_choices(questionnaire_id)\n\n if params[:new_question] and params[:new_choices]\n questions = Question.find_all_by_questionnaire_id(questionnaire_id)\n i = 1\n for question in questions\n for choice_key in params[:new_choices][i.to_s].keys\n\n if choice_key == params[:new_question][i.to_s][\"weight\"]\n score = 1\n else\n score = 0\n end\n q = QuestionAdvice.new(:score => score, :advice => params[:new_choices][i.to_s][choice_key], :question_id => question.id)\n q.save\n end\n i += 1\n question.weight = 1\n question.true_false = false\n end\n end\n end", "def option_params\n params.require(:option).permit(:poll_id, :answer, :vote)\n end", "def choice_test_params\n params.require(:choice_test).permit(:test_id, :user_id, :gamble, :correct_slides, choices_attributes: [:id, :choice_test_id, :answer, :name])\n end", "def create\n params[:questions_option][:correct].to_i\n @questions_option = QuestionsOption.new(questions_option_params)\n\n respond_to do |format|\n if @questions_option.save\n format.html { redirect_to :back, notice: 'Questions option was successfully created.' }\n format.json { render json: :back, status: :created, location: @questions_option }\n else\n format.html { render action: \"new\" }\n format.json { render json: :back.errors, status: :unprocessable_entity }\n end\n end\n end", "def multiple_choice_question(text, points)\n question = MultipleOptionsQuestion.new(text, points)\n @errorReporter.register question\n @test.add_question question\nend", "def create\n #raise params.to_yaml\n @line_item = @line_items.build(params[:line_item])\n option_selection = params[:line_item].delete(:option_selections_attributes)\n\n respond_to do |format|\n if @line_item.save\n @line_item.update_options(option_selection) #if option_selection.present?\n format.html { redirect_to @cart.shop, notice: t(\"line_items.create.notice_success\") }\n else\n format.html { render action: \"new\" }\n end\n end\n end", "def create\n @question_option = QuestionOption.new(params[:question_option])\n @question_option.question = @question\n\n respond_to do |format|\n if @question_option.save\n format.json { head :created, :location => question_option_url(@questionnaire, @page, @question, @question_option, :format => 'json') }\n format.xml { head :created, :location => question_option_url(@questionnaire, @page, @question, @question_option, :format => 'xml') }\n else\n format.json { render :json => @question_option.errors.to_json }\n format.xml { render :xml => @question_option.errors.to_xml }\n end\n end\n end", "def create\n @choice = Choice.new(choice_params)\n\n if @choice.save\n render json: @choice, status: :created, location: @choice\n else\n render json: @choice.errors, status: :unprocessable_entity\n end\n end", "def answer\n @form_data = Form.get_published_form(params[:code])\n if @form_data.nil?\n redirect_to \"/dashboard\"\n else\n @questions = Question.get_questions_by_ids(@form_data['id'], JSON.parse(@form_data['question_order']))\n @all_options = Option.collect_options_per_quetions(JSON.parse(@form_data['question_order']))\n end\n end", "def create\n\t@option = Option.new(params[:option])\n\t@option_count=Option.find_all_by_question_id(@option.question_id).count\n\t@option.option_number=@option_count+1\n\n\trespond_to do |format|\n\t if @option.save\n\t\tformat.html { redirect_to new_option_path(:question_id=>@option.question_id) }\n\t\tformat.xml { render :xml => @option, :status => :created, :location => @option }\n\n\n\t else\n\t\tformat.html { render :action => \"new\" }\n\t\tformat.xml { render :xml => @option.errors, :status => :unprocessable_entity }\n\t end\n\tend\n end", "def option_answer_params\n params.require(:option_answer).permit(:answer_id, :option_id, :unique_ident)\n end", "def create\n @selection = Selection.new(params[:selection])\n @selection.user_id = session[:user_id]\n \n respond_to do |format|\n if @selection.save\n\n @bottles_to_add = params[\"bottles\"];\n if (@bottles_to_add)\n @bottles_to_add.each do |bottle_id|\n @selection.add_bottle(Bottle.find(bottle_id))\n end\n end\n\n format.html { redirect_to @selection, notice: 'Selection was successfully created.' }\n format.json { render json: @selection, status: :created, location: @selection }\n else\n format.html { render action: \"new\" }\n format.json { render json: @selection.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n #@option = Option.new(params[:option])\n\n f=0\n @options = params[:options].values.collect{ |option| Option.new(option) }\n @options.each do |o|\n if o.save\n f=1\n else\n f=0\n end\n\n\t end\n\t@question=Question.find(@options[0].question_id)\n respond_to do |format|\n if f==1\n format.html { redirect_to(:controller => :questions,:action=>\"index\",:qid=>@question.questionnaire_id, :notice => 'Options were successfully created.') }\n format.xml { render :xml => @option, :status => :created, :location => @option }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @option.errors, :status => :unprocessable_entity }\n end\n end\n end", "def option_params\n params.require(:option).permit(:name, :question_id, :a_decimal)\n end", "def update_correct_answer\n question_params = params.permit(:question_id, :question_type_id, :option_id)\n \n render json: Question.update_correct_option(question_params)\n end", "def create\n @quiz = Quiz.new(quiz_params)\n questions_arr.each do |i|\n question = Question.new(question_params(i))\n choices_arr(i).each do |j|\n choice = Choice.new(choice_params(j))\n choice.save\n question.choices << choice\n end\n @quiz.questions << question\n end\n\n if @quiz.save\n User.find(params[:user_id]).quizzes << @quiz\n render json: @quiz, status: :created, location: @quiz\n else\n render json: @quiz.errors, status: :unprocessable_entity\n end\n end", "def new\n @question = current_user.questions.new\n\t2.times do\n\t @question.choices.build\n\tend\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question }\n end\n end", "def question_params\n params.require(:question).permit(:content, :response_type_id, :parent_id, :category_id, :groups,\n :version_independent_id, :description, :other_allowed, :subcategory_id,\n concepts_attributes: [:id, :value, :display_name, :code_system],\n data_collection_methods: [])\n end", "def render_multiple_choice(q)\n ans = array_of_answers(q)\n question_text = q.multiple ? '(Select all that apply.) ' + q.question_text : q.question_text\n question_type = q.multiple ? 'multiple_answers_question' : 'multiple_choice_question'\n comments_key = q.raw? ? :incorrect_comments_html : :incorrect_comments_text\n\n ques = {\n :quiz_group_id => @current_group_id,\n :question_name => \"#{q.points} point#{'s' if q.points > 1}\",\n :question_type => question_type,\n :points_possible => q.points,\n :question_text => question_text,\n :position => 10000,\n :answers => ans\n }\n { question: ques }\n end", "def option_params\n params.require(:option).permit(:sentence_id, :option, :correct)\n end", "def option_params\n params.require(:option).permit(:poll_id, :name, :numVotes)\n end", "def selected_answer_params\n params.require(:selected_answer).permit(:statement_id, :answer_value_id)\n end", "def question_params\n # params.require(:question).permit(:question, :type, choices_attributes:[:id,:question_id,:choice,:is_correct])\n params.require(:question).permit(:question, :q_type, choices_attributes: Choice.attribute_names.map(&:to_sym).push(:_destroy))\n end", "def update\n @survey = Survey.find_by_id( params[:survey_id] )\n @question = Question.find_by_id( params[:id] )\n\n if @question.update( question_params )\n if params[:commit] == \"Continue to the Next Step\"\n params[:option_num].to_i.times do\n @question.options.create # TODO: cleanup, could create empty options in db\n end\n\n redirect_to edit_survey_question_path(@survey, @question)\n else\n flash.now[:success] = \"Question Added!\"\n\n # Create new empty question for render\n @question = @survey.questions.build\n\n render :new\n end\n else\n flash.now[:error] = \"Sorry, we couldn't add that question due to errors.\"\n render :new\n end\n end", "def new\n \n load_quiz_section_and_question\n @option = Option.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @option }\n end\n end", "def create_choice_upload(user_id, decision_id)\n post \"users/#{user_id}/decisions/#{decision_id}/choices\"\n end", "def new\n @survey_question = SurveyQuestion.new\n 2.times { @survey_question.survey_options.build }\n\n respond_to do |format|\n format.html # new.html.erb\n #format.json { render json: @survey_question }\n end\n end", "def add_option\n @option = QuestionOption.new\n end", "def question_params\n params.require(:question).permit(:voting_id, :title, :description, options_attributes: [:title, :id, :_destroy])\n end", "def create\n @survey_question_option = SurveyQuestionOption.new(params[:survey_question_option])\n \n respond_to do |format|\n if @survey_question_option.save\n format.html { redirect_to @survey_question_option, :notice => t('selecao_admin.flash_messages.successfully_created', :model => @survey_question_option.class.model_name.human) }\n format.json { render :json => @survey_question_option, :status => :created, :location => @survey_question_option }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @survey_question_option.errors, :status => :unprocessable_entity }\n end\n end\n end", "def attempt_choice_params\n params.require(:attempt_choice).permit(:attempt_id, :question_id, :choice_id, :user_id, :team_id)\n end", "def update\n respond_to do |format|\n if @question_option_selection.update(question_option_selection_params)\n format.html { redirect_to @question_answer_question_option_selection_path(@question_answer), notice: 'Question option selection was successfully updated.' }\n format.json { render :show, status: :ok, location: @question_option_selection }\n else\n format.html { render :edit }\n format.json { render json: @question_option_selection.errors, status: :unprocessable_entity }\n end\n end\n end", "def get_choices\n @choices = CONNECTION.execute(\"SELECT * FROM choices WHERE question_id = #{@id};\")\n end", "def answer_params\n params.require(:answer).permit(:customer_id, :response_id, :term_id, :stage)\n end", "def choices_ok(question) question.get_choice_ok_from_idurls(choice_idurls_ok) end", "def quizzes_question_params\n params.require(:quizzes_question).permit(:quiz_id, :topic, :ordinal, :question, :open_ended, :answer, :answer_option_id, :answer_format, :answer_template, options_attributes: [:id, :label, :grade, :_destroy])\n end", "def create\n # puts params\n questions = JSON.parse(params[:questions])\n q_hash = questions[\"questions\"]\n @assignment = Assignment.new\n @assignment.course_id = params[:course_id]\n @assignment.type = \"Homework\"\n @assignment.start_date = params[:start_date]\n @assignment.end_date = params[:end_date]\n @assignment.name = params[:name]\n # Following is the question hash\n q_hash.each do |key, value|\n a_hash = key[\"answers\"]\n question = key[\"question\"]\n puts question\n new_question = Question.new\n new_question.description = question\n new_question.type = \"MultipleChoice\"\n # Answer hash\n a_hash.each do |k,v|\n puts k[\"is_correct\"]\n puts k[\"description\"]\n new_answer = Answer.new\n new_answer.description = k[\"description\"]\n new_answer.is_correct = k[\"is_correct\"]\n new_question.association(:answers).add_to_target(new_answer)\n end\n @assignment.association(:questions).add_to_target(new_question)\n end\n \n if @assignment.save\n render :show, status: :created, location: @assignment\n else\n render json: @assignment.errors, status: :unprocessable_entity\n end\n end", "def vote(token, pollnum, choices)\n\t\turl = \"/polls/#{pollnum}/vote\"\n\t\theaders = { 'Content-Type' => 'application/json',\n\t\t\t'Authorization' => 'Bearer #{token}'}\n\t\tarray = Array.new\n\t\tchoices.each do |key, value| \n\t\t\tentry = Hash.new\n\t\t\tentry['choice'] = key\n\t\t\tentry['kind'] = value\n\t\t\tarray.push(entry)\n\t\tend\n\t\tresult = HTTParty.post(url, {:headers => headers, :body => array.to_json})\n\t\treturn result\n\tend", "def create\n @choice_set = ChoiceSet.new(choice_set_params)\n\n respond_to do |format|\n if @choice_set.save\n format.html { redirect_to @choice_set, notice: 'Choice set was successfully created.' }\n format.json { render :show, status: :created, location: @choice_set }\n else\n format.html { render :new }\n format.json { render json: @choice_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def answer_a_question\n user = current_user\n render_401 and return unless user\n question = ShortQuestion.find_by_id(params[:id])\n render_404 and return unless question\n\n obj = {\n :qid => params[:id],\n :answer => params[:choice]\n }\n \n answers = {}\n $r.multi do\n $r.lpush(\"user:#{user.id}:questions\", obj)\n $r.hincrby(\"question:#{question.id}:answers\", \"choice#{params[:choice]}\", 1)\n choices = $r.hget(\"question:#{question.id}:answers\", :num_choices)\n for i in 1..choices\n answers[i] = $r.hget(\"question:#{question.id}:answers\", \"choice#{i}\")\n end\n end\n render :json => {\n :success => true,\n :answers => answers\n }\n end", "def options\n SurveyQuestionOption.where(id: eval(selected_options))\n end", "def create\n @selected_answer = SelectedAnswer.new(selected_answer_params)\n\n respond_to do |format|\n if @selected_answer.save\n format.html { redirect_to @selected_answer, notice: 'Selected answer was successfully created.' }\n format.json { render :show, status: :created, location: @selected_answer }\n else\n format.html { render :new }\n format.json { render json: @selected_answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def index\n @question_options = QuestionOption.all\n end", "def question_params\n params.require(:question).permit(:text, :option_a, :option_b, :option_c, :option_d, :started, :finished, :answer, :poll_centre_id)\n end", "def create\n respond_to do |format|\n if @question.save\n @question_link = QuizQuestion.create!(:qtype => params[:qtype], :qid => @question.id, :quizid => params[:quizid], :points => params[:points])\n @question_link.save\n @question.update(:questionid => @question_link.id)\n @quiz = Quiz.find_by_id(params[:quizid])\n format.html { redirect_to admin_quiz_path(@quiz), notice: 'Quiz multiple choice question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def store_answers\n @user_choice = params[:userChoiceData]\n @user_data = params[:userId]\n is_save = AnswerService.store_answers(@user_choice, @user_data)\n if is_save\n render json: @answer, status: :created, location: @answer\n else\n render json: @answer.errors, status: :unprocessable_entity\n end\n end", "def create\n @questionary_choice = QuestionaryChoice.new(questionary_choice_params)\n @questionary_item = QuestionaryItem.find(@questionary_choice.questionary_item_id)\n @questionary = Questionary.find(@questionary_item.questionary_id)\n @questionary_choice_value = QuestionaryChoice.where(questionary_item_id: @questionary_choice.questionary_item_id).count + 1\n\n respond_to do |format|\n if @questionary_choice.save\n format.html { redirect_to \"/questionary_choices/#{@questionary_choice.questionary_item_id}/new/\", notice: \"選択肢を登録しました:「#{@questionary_choice.content}」\" }\n format.json { render :show, status: :created, location: @questionary_choice }\n @questionary_choice_value += 1\n else\n format.html { render :new }\n format.json { render json: @questionary_choice.errors, status: :unprocessable_entity }\n end\n end\n end", "def create\n @selection = Selection.find(params[:selection_id])\n @step = @selection.steps.new(params[:step])\n\n respond_to do |format|\n if @step.save\n format.html { redirect_to selection_step_path(@step.selection, @step), notice: 'Step was successfully created.' }\n format.json { render json: @step, status: :created, location: @step }\n else\n format.html { render action: \"new\" }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end", "def choose_question\n if params.dig(:assessment, :type).present? && params.dig(:assessment, :type_id).present?\n type = params[:assessment][:type].camelize.constantize.where(id: params[:assessment][:type_id]).first rescue ''\n if type.present?\n all_questions = fetch_all_questions(type)\n if all_questions.count > 0\n assessment_questions = Assessment.fetch_assessment_questions(all_questions.ids, current_user.id)\n render json: calculate_remaining_qusts(all_questions, assessment_questions).order(\"RANDOM()\").limit(2).select(:id, :content, :options)\n else\n render json: {'type': 'No data found for selected type'}\n end\n else\n render json: {'type': 'Invalid selected type or type id'}\n end\n else\n render json: {'Input': 'Invalid inputs'}\n end\n end", "def set_aside_params\n params.require(:set_aside).permit(:name, :selection_criterium_ids => [])\n end", "def create\n if (params[:question]!=nil)\n @question = Question.new(params[:question])\n @question.subject_id=session[:subjectid] \n else\n @question = Question.new\n end \n \n respond_to do |format|\n if @question.save\n format.html { redirect_to(@question, :notice => 'Question was successfully created.') }\n format.xml { render :xml => @question, :status => :created, :location => @question }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n \n end\n \n if (params[:A]!=nil)\n @choices = Choice.new()\n @choices.value = params[:A]\n @choices.question_id=@question.id\n @choices.save \n end\n if (params[:B]!=nil)\n @choices = Choice.new()\n @choices.value = params[:B]\n @choices.question_id=@question.id\n @choices.save \n end\n if (params[:C]!=nil)\n @choices = Choice.new()\n @choices.value = params[:C]\n @choices.question_id=@question.id\n @choices.save \n end\n \n @choices = Choice.new()\n @choices.value = @question.answer\n @choices.question_id=@question.id\n @choices.save \n \n end", "def prebooking_questions\n\n # this is a patch\n if @url.blank? or @token.blank?\n return []\n end\n\n [\n {\n question: \"How many guests will be riding with you?\", \n choices: [0,1,2,3], \n code: \"guests\"\n },\n {\n question: \"How many attendants will be riding with you?\", \n choices: [0,1,2,3], \n code: \"attendants\"\n },\n {\n question: \"How many mobility devices will you be bringing?\", \n choices: [0,1,2,3], \n code: \"mobility_devices\"\n },\n {\n question: \"What is your trip purpose?\", \n choices: (trip_purposes[\"trip_purposes\"] || \n Config.ride_pilot_purposes.try(:map) {|k,v| {\"name\" => k, \"code\" => v}} || \n []).map{|p| [p[\"name\"], p[\"code\"]]}, \n code: \"purpose\"\n }\n ]\n end", "def create\n @quick_poll_option = QuickPollOption.new(params[:quick_poll_option])\n\n respond_to do |format|\n if @quick_poll_option.save\n format.html { redirect_to @quick_poll_option, notice: 'Quick poll option was successfully created.' }\n format.json { render json: @quick_poll_option, status: :created, location: @quick_poll_option }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quick_poll_option.errors, status: :unprocessable_entity }\n end\n end\n end", "def selection_criterium_params\n #params.require(:selection_criterium).permit()\n params.require(:selection_criterium).permit(:name, :team_id, :set_aside_radio_id, :classification_code_ids => [], :procurement_type_ids => [], :set_aside_ids => [] )\n end", "def questions_list \n #render json: {status: 200, questions: Quiz.all, msg: \"Success.\"}\n render json: {status: 200, questions: Quiz.all.map{|que| [id: que.id, question: que.question, options: [que.opt1,que.opt2,que.opt3,que.opt4], answer: que.answer]}.flatten, msg: \"Success.\"}\n end", "def response_params\n p = params.require(:response).permit(:user_id, :question_id, :int_val, :string_val, :text_val, :array_val =>[ ])\n\t\t\t#save multiple choice q's as json array\n\t\t\tunless p['array_val'].nil?\n\t\t\t\tp['array_val'] = p['array_val'].to_json\n\t\t\tend\n\t\t\tp\n end", "def add_question\n\t\t\tif(current_instructor.quizzes.exists?(:id => params[:quiz_id]))\n\t\t\t\tquiz = current_instructor.quizzes.find(params[:quiz_id])\n\t\t\t\tno = quiz.no_of_MCQ + quiz.no_of_rearrangeQ\t\n\t\t\t\tno.times do |n|\n\t\t\t\t\tquestion = Question.create((params[\"_json\"][n]).permit([:text, :mark, :right_answer, :choices => []]))\n\t\t\t\t\tquiz.questions << question\n\t\t\t\tend\n\t\t\t\trender json: { info: \"created\"}, status: 201\n\t\t\telse\n\t\t\t\trender json: { error:\"Quiz is not found\" }, status: 422\n\t\t\tend\n\t\tend", "def set_choice\n @choice = @question.choices.find(params[:id])\n end", "def trivium_params\n params.require(:trivium).permit(:question,:category_id, :option_a, :option_b, :option_c, :option_d, :option_e, :right_answer)\n end", "def create\n @quiz = Quiz.new(quiz_params)\n\n respond_to do |format|\n if @quiz.save\n format.html { redirect_to @quiz, notice: \"Quiz was successfully created.\" }\n format.json { render :show, status: :created, location: @quiz }\n\t\tmy_array = []\n\t\tmy_array << @quiz.option1\n\t\tmy_array << @quiz.option2\n\t\tmy_array << @quiz.option3\n\t\tmy_array << @quiz.option4\n\t\t\n\t\tcorrect_respo = my_array[@quiz.correct_response.to_i - 1]\n\t\t@quiz.correct_response_text = correct_respo\n\t\t@quiz.save\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end", "def quiz_params\n params.permit(:difficulty, :number, :categories => [])\n end", "def pollanswer_params\n params.require(:pollanswer).permit(:pollquestion_id, :option, :status)\n end", "def create\n @option = Option.new(params[:option])\n @option.question_id = @question.id\n\n respond_to do |format|\n if @option.save\n flash[:notice] = 'Option was successfully created.'\n format.html { redirect_to(question_option_path(@question, @option)) }\n format.xml { render :xml => @option, :status => :created, :location => @option }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @option.errors, :status => :unprocessable_entity }\n end\n end\n end", "def question_options(elem_id)\n {\n type: 'checkbox',\n id: elem_id,\n name: answer_name(elem_id),\n value: true\n }\n end", "def new\n @questions_option = QuestionsOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @questions_option }\n end\n end", "def new\n @survey = Survey.new\n 3.times do\n question = @survey.questions.build\n 4.times { question.choices.build }\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @survey }\n end\n end", "def questionnaire_params\n params.require(:questionnaire).permit(:title, { question_ids: [] })\n end", "def index\n @options = @question.options.all\n end", "def choice_set_params\n params.require(:choice_set).permit(:name)\n end", "def interview_params\n params.require(:interview).permit(:survey_id, responses_attributes: [:selection, :content, :question_id])\n end", "def question_params\n params.require(:question).permit(:question,:a,:b,:c,:d,:option1,:option2,:option3,:option4,:genre,:subgenre)\n end", "def create\n @poll = Poll.new(poll_params)\n @poll.owner_id = current_user.id\n @poll.answer_count = 0\n @poll.status = \"pending\"\n @client = GooglePlaces::Client.new(\"AIzaSyBewVg-2JE4BAunjrxdhKU8ao8qnOLvuAc\")\n params[:poll][:respondees].tr(' ', '').split(\",\").each do |email|\n user = User.find_by(email: email)\n if user\n @poll.users << user\n end\n end\n options = @client.spots_by_query(@poll.address, types: ['restaurant', 'food']).slice(0, 10)\n respond_to do |format|\n if @poll.save\n options.each do |option|\n @poll.options.create(name: option.name, positive_votes: 0, negative_votes: 0, place_id: option.reference)\n end\n format.html { redirect_to root_path, notice: 'Poll was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end", "def create\n @question = Question.find(params[:question_id])\n @option = @question.options.create!(option_params)\n @option.update_attribute(:position, 9999)\n\n @question.options.each_with_index do |question, index|\n question.position = index\n question.save!\n end\n\n redirect_to edit_question_path(@question)\n end", "def create\n @option = \"Vger::Resources::#{params[:option][:option_type]}\".constantize.new(params[:option])\n respond_to do |format|\n if @option.save\n format.html { redirect_to suitability_factor_item_option_path(params[:factor_id],params[:item_id], @option), notice: 'Suitability Option was successfully created.' }\n format.js\n format.json { render json: @option, status: :created, location: @option }\n else\n format.html { render action: \"new\" }\n format.js\n format.json { render json: @option.errors, status: :unprocessable_entity }\n end\n end\n end", "def store_options\n pure_options = []\n self.options.each do |o|\n pure_options << {'text' => o.text, 'correct' => o.correct}\n end\n \n self.json_options = pure_options.to_json\n end", "def evals_questions evaluation_id\n call_path = \"evals/questions\"\n request = {\"evaluationID\": evaluation_id}.to_json\n data = build_post_data(request)\n perform_post(build_url(call_path), data)\n end", "def new\n @response = Response.find(params[:response_id])\n #@request_selection = @response.request_selections.build\n @request_selection = @response.build_request_selection\n #@request_selection = RequestSelection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request_selection }\n end\n end", "def four_choice_question_params\n params.require(:four_choice_question).permit(:title, :a, :b, :c, :d, :answer)\n end", "def question_params\n params.require(:question).permit(:category, :range, :type)\n end" ]
[ "0.67875326", "0.6616982", "0.65738964", "0.6385959", "0.63539124", "0.6280465", "0.61634994", "0.6126046", "0.61236984", "0.6051213", "0.60421056", "0.6003916", "0.59900224", "0.5978536", "0.5971318", "0.59675455", "0.59316427", "0.5918343", "0.59085405", "0.5874556", "0.58660966", "0.5811894", "0.5808491", "0.58032274", "0.57945627", "0.57927406", "0.5791105", "0.57724154", "0.57720995", "0.5747424", "0.5747374", "0.5741176", "0.57334083", "0.5721183", "0.5719687", "0.571528", "0.56936103", "0.56852615", "0.5677403", "0.56752855", "0.5650416", "0.56462574", "0.56368077", "0.56339663", "0.5632055", "0.5626522", "0.55920345", "0.5591718", "0.55862266", "0.5579383", "0.5576409", "0.55676275", "0.55426097", "0.55362743", "0.5534247", "0.55328447", "0.55304027", "0.55248535", "0.5516921", "0.55055624", "0.55040914", "0.54985756", "0.5494636", "0.54935724", "0.5484454", "0.5476314", "0.5476151", "0.5470357", "0.5460304", "0.54562855", "0.5452475", "0.54504776", "0.5447521", "0.54466575", "0.54438317", "0.5442103", "0.54327136", "0.543142", "0.54301786", "0.54244834", "0.5400119", "0.5395386", "0.5390872", "0.5381314", "0.5380941", "0.5380523", "0.53800327", "0.537742", "0.53755724", "0.5369688", "0.53639895", "0.5352011", "0.5351692", "0.53491646", "0.53485477", "0.5344868", "0.53424937", "0.533248", "0.53219235", "0.5314959" ]
0.6865646
0
PATCH/PUT /question_option_selections/1 PATCH/PUT /question_option_selections/1.json
def update respond_to do |format| if @question_option_selection.update(question_option_selection_params) format.html { redirect_to @question_answer_question_option_selection_path(@question_answer), notice: 'Question option selection was successfully updated.' } format.json { render :show, status: :ok, location: @question_option_selection } else format.html { render :edit } format.json { render json: @question_option_selection.errors, status: :unprocessable_entity } end end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def update_correct_answer\n question_params = params.permit(:question_id, :question_type_id, :option_id)\n \n render json: Question.update_correct_option(question_params)\n end", "def update\n @questions_option = QuestionsOption.find(params[:id])\n\n respond_to do |format|\n if @questions_option.update_attributes(params[:questions_option])\n format.html { redirect_to @questions_option, notice: 'Questions option was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @questions_option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @option.update(option_params)\n format.html { redirect_to question_options_url(@option.question), notice: \"Option was successfully updated.\" }\n format.json { render :show, status: :ok, location: question_options_url(@option.question) }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @question_option.update(question_option_params)\n format.html { redirect_to @question_option, notice: 'Question option was successfully updated.' }\n format.json { render :show, status: :ok, location: @question_option }\n else\n format.html { render :edit }\n format.json { render json: @question_option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question_option = QuestionOption.find(params[:id])\n check_forged_path\n\n respond_to do |format|\n if @question_option.update_attributes(params[:question_option])\n format.json { head :ok }\n format.xml { head :ok }\n else\n format.json { render :json => @question_option.errors.to_json }\n format.xml { render :xml => @question_option.errors.to_xml }\n end\n end\n end", "def update\n respond_to do |format|\n if @option.update(option_params)\n format.html { redirect_to edit_question_path(@option.question), notice: 'Option was successfully updated.' }\n format.json { render :show, status: :ok, location: @option }\n else\n format.html { render :edit }\n format.json { render json: @option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n \n load_quiz_section_and_question\n load_option\n \n respond_to do |format|\n if @option.update_attributes(params[:option])\n format.html { redirect_to admins_quiz_section_question_path(@quiz,@section,@question.sequence_no), notice: 'Option was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @survey = Survey.find_by_id( params[:survey_id] )\n @question = Question.find_by_id( params[:id] )\n\n if @question.update( question_params )\n if params[:commit] == \"Continue to the Next Step\"\n params[:option_num].to_i.times do\n @question.options.create # TODO: cleanup, could create empty options in db\n end\n\n redirect_to edit_survey_question_path(@survey, @question)\n else\n flash.now[:success] = \"Question Added!\"\n\n # Create new empty question for render\n @question = @survey.questions.build\n\n render :new\n end\n else\n flash.now[:error] = \"Sorry, we couldn't add that question due to errors.\"\n render :new\n end\n end", "def update\n question = Question.find(params[:id])\n authorize question\n\n new_version = question.template.generate_version?\n\n old_question_ids = {}\n if new_version\n # get a map from option number to id\n old_number_to_id = {}\n question.question_options.each do |opt|\n old_number_to_id[opt.number] = opt.id\n end\n\n # get a map from question versionable id to old id\n question.template.questions.each do |q|\n old_question_ids[q.versionable_id] = q.id\n end\n end\n\n question = get_modifiable(question)\n\n question_id_map = {}\n if new_version\n # params now out of sync (after versioning) with the question_options\n # so when we do the question.update it'll mess up\n # need to remap params to keep them consistent\n old_to_new_opts = {}\n question.question_options.each do |opt|\n old_id = old_number_to_id[opt.number]\n old_to_new_opts[old_id.to_s] = opt.id.to_s\n end\n\n question.template.questions.each do |q|\n question_id_map[old_question_ids[q.versionable_id].to_s] = q.id.to_s\n end\n end\n\n # rewrite the question_option ids so they match the new\n # version of the question\n # and also rewrite the remove_data question ids\n attrs = question_params\n attrs = update_option_ids(attrs, old_to_new_opts) if new_version && !attrs['question_options_attributes'].nil?\n\n # Need to reattach the incoming annotation's and question_options to the\n # modifiable (versioned) question\n attrs = transfer_associations(attrs, question) if new_version\n\n # If the user unchecked all of the themes set the association to an empty array\n # add check for number present to ensure this is not just an annotation\n attrs[:theme_ids] = [] if attrs[:theme_ids].blank? && attrs[:number].present?\n if question.update(attrs)\n if question.update_conditions(sanitize_hash(params['conditions']),\n old_to_new_opts, question_id_map)\n flash.now[:notice] = success_message(question, _('updated'))\n end\n else\n flash.now[:alert] = flash.now[:alert] = failure_message(question, _('update'))\n end\n if question.section.phase.template.customization_of.present?\n redirect_to org_admin_template_phase_path(\n template_id: question.section.phase.template.id,\n id: question.section.phase.id,\n section: question.section.id\n )\n else\n redirect_to edit_org_admin_template_phase_path(\n template_id: question.section.phase.template.id,\n id: question.section.phase.id,\n section: question.section.id\n )\n end\n end", "def update\n @quick_poll_option = QuickPollOption.find(params[:id])\n\n respond_to do |format|\n if @quick_poll_option.update_attributes(params[:quick_poll_option])\n format.html { redirect_to @quick_poll_option, notice: 'Quick poll option was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quick_poll_option.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_question_option_selection\n @question_option_selection = QuestionAnswer.question_option_selections.find(params[:id])\n end", "def update\n if @question.status == 'published' || @question.version_independent_id != question_params[:version_independent_id]\n render json: @question.errors, status: :unprocessable_entity\n else\n update_response_sets(params)\n @question.update_concepts('Question')\n @question.updated_by = current_user\n if @question.update(question_params)\n @question.groups.each do |group|\n @question.add_to_group(group.id)\n end\n render :show, status: :ok, location: @question\n else\n @categories = Category.all\n render json: @question.errors, status: :unprocessable_entity\n end\n end\n end", "def update\n @survey_question_option = SurveyQuestionOption.find(params[:id])\n \n respond_to do |format|\n if @survey_question_option.update_attributes(params[:survey_question_option])\n format.html { redirect_to @survey_question_option, :notice => t('selecao_admin.flash_messages.successfully_updated', :model => @survey_question_option.class.model_name.human) }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @survey_question_option.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @question_option = QuestionOption.find(params[:id])\n\n respond_to do |format|\n if @question_option.update_attributes(params[:question_option])\n format.html { redirect_to(@question_option, :notice => 'Question option was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question_option.errors, :status => :unprocessable_entity }\n end\n end\n end", "def edit(index, params)\n question.update(question: params[:questions][\"question_#{index + 1}\".to_sym])\n choice_num = 1\n @choices.select { |choice| choice.question_id == question.id}.each do |choice|\n choice.update(choice: params[\"choice_#{choice_num}\".to_sym])\n choice_num += 1\n end\n end", "def update\n @survey_choice = Survey::Choice.find(params[:id])\n\n respond_to do |format|\n if @survey_choice.update_attributes(params[:survey_choice])\n format.html { redirect_to @survey_choice, notice: 'Choice was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey_choice.errors, status: :unprocessable_entity }\n5 end\n end\n end", "def update\n @choice = Choice.find(params[:id])\n\n if @choice.update(choice_params)\n head :no_content\n else\n render json: @choice.errors, status: :unprocessable_entity\n end\n end", "def update\n if @v1_question.update(v1_question_params)\n render json: @v1_question, status: :ok\n else\n render json: get_errors, status: :unprocessable_entity\n end\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n @question_link = QuizQuestion.find_by_id(@question.questionid)\n @question_link.update(:points => params[:points])\n @quiz = Quiz.find_by_id(@question_link.quizid)\n format.html { redirect_to admin_quiz_path(@quiz), notice: 'Quiz multiple choice question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @multiple_choice_question = MultipleChoiceQuestion.find(params[:id])\n\n respond_to do |format|\n if @multiple_choice_question.update_attributes(params[:multiple_choice_question])\n format.html { redirect_to @multiple_choice_question, notice: 'Multiple choice question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @multiple_choice_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @option.update_attributes(params[:option])\n flash[:notice] = 'Option was successfully updated.'\n format.html { redirect_to(question_option_path(@question, @option)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @option.errors, :status => :unprocessable_entity }\n end\n end\n end", "def edit_correct_option(collection_id, question, key_for_correct_option)\r\n options = %w[A B C D]\r\n new_right_option = @prompt.select('Choose your new correct option:', options, per_page: 4)\r\n question[key_for_correct_option] = new_right_option\r\n edit_single_question(collection_id, question)\r\n end", "def mark_correct\n self.update_attribute(:option_id, self.question.options.where(correct: true).first.id)\n end", "def update\n\n qp = question_params\n if qp[:question_type] == \"vignette\" or qp[:question_type] == \"nonchoice\"\n qp[:answer] = \"\"\n end\n\n respond_to do |format|\n if @question.update(qp)\n format.html { redirect_to paper_questions_path(question_params[:paper_id],question_params[:id]), notice: '題目已被成功編輯' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { redirect_to edit_paper_question_path, notice: '上傳檔案大小不可超過500KB' }\n format.json { render json: paper_questions_path.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.update(params[:id], { \n :body => params[:body], \n :answer_type => params[:answer_type] }, \n params[:answers].values\n )\n\n respond_to do |format|\n format.json { render :json => @question.as_json({:include => :answers}) }\n\n # if @question.update_attributes(params[:question])\n # format.html { redirect_to @question, :notice => 'Question was successfully updated.' }\n # format.json { head :no_content }\n # else\n # format.html { render :action => \"edit\" }\n # format.json { render :json => @question.errors, :status => :unprocessable_entity }\n # end\n end\n end", "def set_question_option\n @question_option = QuestionOption.find(params[:id])\n end", "def update\n @option = Vger::Resources::Mrf::Option.find(params[:id], :item_id => params[:item_id])\n respond_to do |format|\n if @option.class.save_existing(params[:id], params[:option])\n format.html { redirect_to mrf_item_option_path(params[:trait_id], params[:item_id], params[:id]), notice: 'Mrf Option was successfully updated.' }\n format.js\n format.json { render json: @option, status: :created, location: @option }\n else\n format.html { render action: \"edit\" }\n format.js\n format.json { render json: @option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_single_poll(id,polls__question__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :polls__question__,\n :polls__description__,\n \n ]\n\n # verify existence of params\n raise \"id is required\" if id.nil?\n raise \"polls__question__ is required\" if polls__question__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :id => id,\n :polls__question__ => polls__question__\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{id}\",\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end", "def update!(**args)\n @choice_question = args[:choice_question] if args.key?(:choice_question)\n @date_question = args[:date_question] if args.key?(:date_question)\n @file_upload_question = args[:file_upload_question] if args.key?(:file_upload_question)\n @grading = args[:grading] if args.key?(:grading)\n @question_id = args[:question_id] if args.key?(:question_id)\n @required = args[:required] if args.key?(:required)\n @row_question = args[:row_question] if args.key?(:row_question)\n @scale_question = args[:scale_question] if args.key?(:scale_question)\n @text_question = args[:text_question] if args.key?(:text_question)\n @time_question = args[:time_question] if args.key?(:time_question)\n end", "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 update\n\n params[:choice][:option_a_votes] = @choice.option_a_votes + params[:choice][:option_a_votes].to_i\n params[:choice][:option_b_votes] = @choice.option_b_votes + params[:choice][:option_b_votes].to_i\n\n respond_to do |format|\n if @choice.update(choice_params)\n format.html { redirect_to @choice, notice: 'Choice was successfully updated.' }\n format.json { render :show, status: :ok, location: @choice }\n format.js\n else\n format.html { render :edit }\n format.json { render json: @choice.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end", "def update\n question = Question.find(params[:id_question])\n if question.update(params_question)\n render json: question, status: 200\n else\n render json: question.errors, status: 422\n end\n\n end", "def update\n params[:poll_question][:active] = params[:poll_question][:active].present?\n params[:poll_question][:existing_poll_option_attributes] ||= {}\n\n @poll_question.attributes = params[:poll_question]\n\n respond_to do |format|\n if @commit_type == 'preview' && @poll_question.valid?\n format.html { render template: 'admin/shared/update_preview', locals: { record: @poll_question }, layout: 'admin/admin_preview' }\n format.xml { render xml: @poll_question, status: :created, location: @poll_question }\n elsif @commit_type == 'save' && @poll_question.save(user: current_user)\n format.html do\n @refresh = true\n render 'admin/shared/update'\n end\n format.xml { head :ok }\n else\n format.html { render action: :edit }\n format.xml { render xml: @poll_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @choice_set.update(choice_set_params)\n format.html { redirect_to @choice_set, notice: 'Choice set was successfully updated.' }\n format.json { render :show, status: :ok, location: @choice_set }\n else\n format.html { render :edit }\n format.json { render json: @choice_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to api_v1_question_path(@question), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @option = Option.find(params[:id])\n\n respond_to do |format|\n if @option.update_attributes(params[:option])\n format.html { redirect_to @option, notice: 'Option was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_option_content\n option_params = params.require(:option).permit(:id, :content)\n\n render json: Option.update_option_content(option_params)\n end", "def update\n @option = Option.find(params[:id])\n\n respond_to do |format|\n if @option.update_attributes(params[:option])\n format.html { redirect_to @option, notice: 'Option was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @option = \"Vger::Resources::#{params[:option][:option_type]}\".constantize.find(params[:id], :factor_id => params[:factor_id], :item_id => params[:item_id])\n respond_to do |format|\n if @option.class.save_existing(params[:id], params[:option])\n format.html { redirect_to suitability_factor_item_option_path(params[:factor_id], params[:item_id], params[:id]), notice: 'Suitability Option was successfully updated.' }\n format.js\n format.json { render json: @option, status: :created, location: @option }\n else\n format.html { render action: \"edit\" }\n format.js\n format.json { render json: @option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @option.update(option_params)\n format.html { redirect_to @option, notice: 'Option was successfully updated.' }\n format.json { render :show, status: :ok, location: @option }\n else\n format.html { render :edit }\n format.json { render json: @option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @option.update(option_params)\n format.html { redirect_to @option, notice: 'Option was successfully updated.' }\n format.json { render :show, status: :ok, location: @option }\n else\n format.html { render :edit }\n format.json { render json: @option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @option.update(option_params)\n format.html { redirect_to @option, notice: 'Option was successfully updated.' }\n format.json { render :show, status: :ok, location: @option }\n else\n format.html { render :edit }\n format.json { render json: @option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @poll_options_set = PollOptionsSet.find(params[:id])\n\n respond_to do |format|\n if @poll_options_set.update_attributes(params[:poll_options_set])\n format.html { redirect_to @poll_options_set, notice: 'Poll options set was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @poll_options_set.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_existing_quiz_question(course_id,quiz_id,id,question__question_name__,question__question_text__,question__question_type__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :question__question_name__,\n :question__question_text__,\n :question__quiz_group_id__,\n :question__question_type__,\n :question__position__,\n :question__points_possible__,\n :question__correct_comments__,\n :question__incorrect_comments__,\n :question__neutral_comments__,\n :question__text_after_answers__,\n :question__answers__,\n \n ]\n\n # verify existence of params\n raise \"course_id is required\" if course_id.nil?\n raise \"quiz_id is required\" if quiz_id.nil?\n raise \"id is required\" if id.nil?\n raise \"question__question_name__ is required\" if question__question_name__.nil?\n raise \"question__question_text__ is required\" if question__question_text__.nil?\n raise \"question__question_type__ is required\" if question__question_type__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :course_id => course_id,\n :quiz_id => quiz_id,\n :id => id,\n :question__question_name__ => question__question_name__,\n :question__question_text__ => question__question_text__,\n :question__question_type__ => question__question_type__\n )\n\n # resource path\n path = path_replace(\"/v1/courses/{course_id}/quizzes/{quiz_id}/questions/{id}\",\n :course_id => course_id,\n :quiz_id => quiz_id,\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n QuizQuestion.new(response)\n end", "def update\n @exam_option = ExamOption.find(params[:id])\n\n respond_to do |format|\n if @exam_option.update_attributes(params[:exam_option])\n format.html { redirect_to @exam_option, notice: 'Exam option was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @exam_option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_single_poll_choice(poll_id,id,poll_choices__text__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :poll_choices__text__,\n :poll_choices__is_correct__,\n :poll_choices__position__,\n \n ]\n\n # verify existence of params\n raise \"poll_id is required\" if poll_id.nil?\n raise \"id is required\" if id.nil?\n raise \"poll_choices__text__ is required\" if poll_choices__text__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :poll_id => poll_id,\n :id => id,\n :poll_choices__text__ => poll_choices__text__\n )\n\n # resource path\n path = path_replace(\"/v1/polls/{poll_id}/poll_choices/{id}\",\n :poll_id => poll_id,\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n response\n \n end", "def update\n respond_to do |format|\n if @api_v1_question.update(api_v1_question_params)\n format.html { redirect_to @api_v1_question, notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_question }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @survey = Survey.find(params[:id])\n json = params[:survey]\n json[:questions] = JSON.parse(json[:questions])\n json[:questions].each_with_index do |question, idx|\n json[:questions][idx]['id'] = idx + 1\n end\n\n respond_to do |format|\n if @survey.update_attributes(json)\n format.html { redirect_to @survey, notice: 'Survey was successfully updated.' }\n format.json { render json: @survey }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to quiz_path(@question.subsection_id), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def edit_question\n\t\t\tquizzes = current_instructor.quizzes\n\t\t\t@found = 0\n\t\t\tquizzes.each do |quiz|\n\t\t\t\tif(quiz.questions.exists?(:id => params[:question_id]))\n\t\t\t\t\t@found = @found + 1\n\t\t\t\tend \n\t\t\tend\n\t\t\tif (@found > 0)\n\t\t\t\tquestion = Question.find(params[:question_id])\n\t\t\t\tif (question.update(question_params))\n\t\t\t\t\trender json: { success: true, data: { :question => question }, info:{} }, status: 200\n\t\t\t\telse\n\t\t\t\t\trender json: { error: question.errors }, status: 422 \n\t\t\t\tend\t\n\t\t\telse\n\t\t\t\trender json: { error:\"Question is not found\" }, status: 422\n\t\t\tend\n\t\tend", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n if (@question.question_type.short_text? || @question.question_type.open_ended_text?)\n path = survey_path(params[:survey_id])\n else\n path = survey_question_path(params[:survey_id],@question.id)\n end\n format.html { redirect_to path, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @choices = args[:choices] if args.key?(:choices)\n end", "def set_question_option\n @question_option = QuestionOption.find(params[:id])\n end", "def update\n respond_to do |format|\n if @option.update(option_params)\n format.html { redirect_to sentence_options_path(@option.sentence), notice: 'option was successfully updated.' }\n format.json { render :show, status: :ok, location: @option }\n else\n format.html { render :edit }\n format.json { render json: @option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n\n @response = Response.find(params[:response_id])\n @request_selection = RequestSelection.find(params[:id])\n \n\n respond_to do |format|\n if @request_selection.update_attributes(params[:request_selection])\n format.html { redirect_to response_request_selections_path(@response, @request_selection), notice: 'Request Selection was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @request_selection.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n if @simple_question_alternative.update(simple_question_alternative_params)\n render status: :ok, json: @simple_question_alternative\n else\n self.send(:edit)\n end\n end", "def question_option_selection_params\n params.require(:question_option_selection).permit(:question_answer_id, :question_option_id)\n end", "def update\n respond_to do |format|\n if @choice.update(choice_params)\n format.html { redirect_to @choice, notice: 'Choice was successfully updated.' }\n format.json { render :show, status: :ok, location: @choice }\n else\n format.html { render :edit }\n format.json { render json: @choice.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_question_type\n form_params = params.require(:form).permit(:question_id, :question_type)\n\n render json: Question.update_question_type(form_params)\n end", "def update\n if @four_choice_question.update(four_choice_question_params)\n render :show, status: :ok, location: @four_choice_question\n else\n render json: @four_choice_question.errors, status: :unprocessable_entity\n end\n end", "def update\n @questions = Question.all\n @categories = [\"Learning from Labs\", \"Lab Instructor\", \"Lab Space and Equipment\", \"Time Required to Complete Labs\", \"Lecture Section Instructor\"]\n respond_to do |format|\n if @survey.update(survey_params)\n format.html { redirect_to @survey, notice: 'Survey was successfully submitted.' }\n format.json { render :show, status: :ok, location: @survey }\n\n # Update 'completed' attribute to true\n submission = Survey.find_by(survey_ID: @survey.survey_ID)\n submission.update(status: true)\n\n # Increment 'completed' attribute for section\n @section = Section.find_by(class_num: @survey.class_num)\n @section.update(completed: @section.completed + 1)\n\n\n else\n format.html { render :edit }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n p = trial_params.clone\n if p[\"question_ids\"].nil?\n p[\"question_ids\"] = []\n end\n\n respond_to do |format|\n if @trial.update(p)\n format.html { redirect_to @trial, notice: 'Trial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trial.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n # @question.question_type_id = params[:question][:question_type_id]\n # @question.question_category_id = @question.question_type.question_category_id\n\n # authorize! :update, @question\n # @question.question_type_id = params[:question][:question_type_id]\n # @question.question_category_id = @question.question_type.question_category_id\n\n \n # # get fields from the form to update the question's section\n # @question.book = params[:question][:book]\n # @question.chapter = params[:question][:chapter]\n # @question.verse = params[:question][:verse]\n # @question.section_id = @question.set_section\n #---------------------------------------------------------\n \n # # if the the question has been approved, set the approver and the date approved\n # unless params[:question][:approval_level] == nil\n # @question.approved_by = current_user.id\n # @question.approved_on = DateTime.now\n # end\n\t\n @question.update_attributes(params[:question])\n unless @question.approval_level == -1\n respond_with @question\n\tend\n\t\n\t# set the section for this question\n\t#@question.section_id = @question.set_section\n \n # the quesiton is marked as refused, drop from database\n if @question.approval_level == -1\n \t@question.destroy\n destroyed = 1\n redirect_to approve_path, :notice => \"Successfully deleted question\"\n return\n end\n # if @question.update_attributes(params[:question])\n # # determine user and send them to appropriate page\n # if current_user.is_writer?\n # redirect_to write_path, :notice => \"Successfully updated question.\"\n # elsif current_user.is_approver?\n # redirect_to approve_path, :notice => \"Successfully updated question.\"\n # else\n # redirect_to @question, :notice => \"Successfully updated question.\"\n # end\n # else\n # render :action => 'edit'\n # end\n end", "def add_option\n render json: Option.create_default_option(params[:question_id])\n end", "def update\n @product_option = ProductOption.find(params[:product_option][:id])\n @product = Product.find(params[:product_id])\n @product_option.update_attributes(params[:product_option])\n \n @available_options = ProductOption.find(:all, :order => 'name')\n end", "def update\n @problem_set = ProblemSet.find(params[:problem_set_id])\n @question = Question.where(:id => params[:id], :problem_set_id => params[:problem_set_id]).first\n @answers = Answer.where(:question_id => @question.id)\n\n ans = [:answer1, :answer2, :answer3, :answer4]\n respond_to do |format|\n if @question.update_attributes(params[:question])\n \n @answers.each_with_index do |a, i|\n a.answer = params[ans[i]][:answer]\n a.correct = params[ans[i]][:correct]\n a.save\n end\n\n if @answers.size < 4 and params[ans[@answers.size]][:answer] != \"\"\n for i in @answers.size..4\n if params[ans[i]][:answer] != \"\"\n a = Answer.new(params[ans[i-1]])\n a.question_id = @question.id\n a.save\n end\n end\n end\n format.html { redirect_to(edit_problem_set_question_path(@problem_set.id, @question.count), :notice => 'Question was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n\n if params[:tags].nil?\n @question.tags = []\n else\n @question.tags = Tag.find(params[:tags])\n end\n\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to admin_question_path(@question), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @poll_question = PollQuestion.find(params[:id])\n\n respond_to do |format|\n if @poll_question.update_attributes(params[:poll_question])\n format.html { redirect_to @poll_question, notice: 'Poll question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @poll_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @selected_answer.update(selected_answer_params)\n format.html { redirect_to @selected_answer, notice: 'Selected answer was successfully updated.' }\n format.json { render :show, status: :ok, location: @selected_answer }\n else\n format.html { render :edit }\n format.json { render json: @selected_answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @poll_question.update(poll_question_params)\n format.html { redirect_to @poll_question, notice: 'Poll question was successfully updated.' }\n format.json { render :show, status: :ok, location: @poll_question }\n else\n @polls = Poll.all\n format.html { render :edit }\n format.json { render json: @poll_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update!(**args)\n @choices = args[:choices] if args.key?(:choices)\n @list_options = args[:list_options] if args.key?(:list_options)\n end", "def update\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to edit_question_path(@question), notice: 'Question was successfully updated.' }\n format.json\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to new_question_path, notice: 'questions was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @poll_option.update(poll_option_params)\n format.html { redirect_to [:admin, @poll_option], notice: 'Poll option was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @poll_option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n def answer_given(question_id)\n return (params[:answer] and params[:answer][question_id.to_s] and\n params[:answer][question_id.to_s].length > 0)\n end\n \n @resp = Response.find(params[:id])\n\n @questionnaire.questions.each do |question|\n if question.kind_of? Questions::Field\n ans = Answer.find_answer(@resp, question)\n if answer_given(question.id)\n if ans.nil?\n ans = Answer.new :question_id => question.id, :response_id => @resp.id\n end\n ans.value = params[:answer][question.id.to_s]\n ans.save\n else\n # No answer provided\n if not ans.nil?\n ans.destroy\n end\n end\n end\n end\n\n respond_to do |format|\n if @resp.update_attributes(params[:response])\n format.html { redirect_to(response_url(@questionnaire, @resp)) }\n format.js { redirect_to(response_url(@questionnaire, @resp, :format => \"js\")) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.js { render :action => \"edit\" }\n format.xml { render :xml => @resp.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n respond_to do |format|\n if @opt10075.update(opt10075_params)\n format.html { redirect_to @opt10075, notice: 'Opt10075 was successfully updated.' }\n format.json { render :show, status: :ok, location: @opt10075 }\n else\n format.html { render :edit }\n format.json { render json: @opt10075.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @answer.update(answer_params)\n respond_with( [ :admin, @survey, @section, @question, @answer ] )\n end", "def edit\n @answer = Answer.find_by_uuid(params[:id])\n if !@answer.pending?\n redirect_to(answer_path(@answer.uuid), notice: 'You have already answered this question.') and return\n end\n\n @question = @answer.question\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end", "def index\n @question_option_selections = @question_answer.question_option_selections\n end", "def update\n @auto_option = AutoOption.find(params[:id])\n\n respond_to do |format|\n if @auto_option.update_attributes(params[:auto_option])\n format.html { redirect_to @auto_option, notice: 'Auto option was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @auto_option.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, :notice => 'Question was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @question.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @time_series_question = @time_series.questions.find(params[:id])\n\n respond_to do |format|\n if @time_series_question.update_attributes(params[:time_series_question])\n format.html { redirect_to time_series_question_path(@owner, @time_series, @time_series_question), flash: {success: t('app.msgs.success_updated', :obj => t('mongoid.models.time_series_question.one'))} }\n format.json { head :no_content }\n else\n @datasets = @time_series.datasets.sorted\n\n # get the list of questions for each dataset in the time series that are not already in the time series\n @questions = {}\n\n @datasets.each do |dataset|\n # get the dataset question\n # - if it does not exist, build it\n dataset_question = @time_series_question.dataset_questions.by_dataset_id(dataset.dataset_id)\n dataset_question = @time_series_question.dataset_questions.build(dataset_id: dataset.dataset_id) if dataset_question.nil?\n\n @questions[dataset_question.dataset_id.to_s] = []\n # get all other questions not being used for this dataset\n not_in_use = dataset_question.dataset.questions.for_analysis_not_in_codes(@time_series.questions.codes_for_dataset(dataset_question.dataset_id)).to_a\n if not_in_use.present?\n @questions[dataset_question.dataset_id.to_s] << not_in_use\n end\n # get question for this dataset\n in_use = dataset_question.dataset.questions.with_code(dataset_question.code)\n if in_use.present?\n @questions[dataset_question.dataset_id.to_s] << in_use\n end\n @questions[dataset_question.dataset_id.to_s].flatten!.sort_by!{|x| x.original_code} if @questions[dataset_question.dataset_id.to_s].present?\n\n end\n\n\n add_common_options\n\n format.html { render action: \"edit\" }\n format.json { render json: @time_series_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n #@question = Question.find(params[:id])\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: t('alert.question.update_success', default: 'Question was successfully updated.') }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update_question\n respond_to do |format|\n if @question.update(question_params)\n format.html { redirect_to :planner, notice: 'Question was successfully updated.' }\n format.json { respond_with_bip(@question) }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @survey_option = SurveyOption.find(params[:id])\n\n respond_to do |format|\n if @survey_option.update_attributes(params[:survey_option])\n format.html { redirect_to(@survey_option, :notice => 'Survey option was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @survey_option.errors, :status => :unprocessable_entity }\n end\n end\n end", "def update\n @my_question = MyQuestion.find(params[:id])\n\n respond_to do |format|\n if @my_question.update_attributes(params[:my_question])\n format.html { redirect_to @my_question, notice: 'My question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @my_question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to @question, notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end", "def set_choice\n @choice = @question.choices.find(params[:id])\n end", "def option_params\n \n \n params.require(:option).permit(:Question_id, :correct, :text)\n\n \n end", "def update\n respond_to do |format|\n if @option.update(option_params)\n format.html { redirect_to @option, notice: 'Option was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end", "def set_v1_question\n @v1_question = V1::Question.find(params[:id])\n end", "def question_option_params\n params.require(:question_option).permit(:question_id, :title)\n end", "def update\n @selection = Selection.find(params[:id])\n \n @bottles_to_add = params[\"bottles\"];\n \n @selection.bottle_ids.clear\n if @bottles_to_add\n @bottles_to_add.each do |bottle_id|\n @selection.add_bottle(Bottle.find(bottle_id))\n end\n end\n \n @selection.user_id = session[:user_id]\n\n respond_to do |format|\n if @selection.update_attributes(params[:selection])\n format.html { redirect_to @selection, notice: 'Selection was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @selection.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @question = Question.find(params[:question_id])\n\n if !@question\n redirect_to :controller => :questions, :action => \"show\", :id => params[:question_id]\n end\n @tags = @question.tags.order(:id)\n @tag = @question.tags.build\n @taggings = Tagging.where(:tag_id => @tags.collect{|x| x.id},:question_id => params[:id]).order(:tag_id)\n @answer = @question.answers.find(params[:id])\n @user = @answer.user\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n # make other answers wrong\n if params[:answer][:correct]\n @question.answers.each do |a|\n if a != @answer\n a.correct = false\n a.save\n end\n end\n end\n format.html { render :template => 'questions/show', :answer_id=>@answer.id, :user_id=>@user.id,:question_id => @question.id, notice: 'Answer was successfully updated.'}\n #format.json { head :no_content }\n #redirect_to question_url(@question_id)\n else\n format.html { render action: \"edit\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end", "def update\n @menu = \"option\"\n @board = \"option\"\n @section = \"edit\"\n \n @option = Option.get(params[:id])\n \n @option.name = params[:option][:name]\n @option.priority = params[:option][:priority].to_i\n \n if @option.save\n redirect_to (admin_option_url)\n else\n render 'option'\n end\n\n end" ]
[ "0.72698116", "0.70224434", "0.6931022", "0.6925986", "0.67867243", "0.6774947", "0.67558545", "0.6726432", "0.67178553", "0.65660477", "0.6469441", "0.6468809", "0.64565307", "0.6449378", "0.6439106", "0.6426784", "0.6392963", "0.6388309", "0.6382278", "0.63695186", "0.6320252", "0.63175595", "0.6273573", "0.62402946", "0.62174445", "0.61946416", "0.6185116", "0.61707217", "0.6157002", "0.6151774", "0.6138161", "0.61375844", "0.6137154", "0.6135377", "0.611598", "0.61134183", "0.6104725", "0.60926944", "0.60921115", "0.6085558", "0.6085558", "0.6085558", "0.60753", "0.6068411", "0.60626286", "0.6053371", "0.6046038", "0.60238177", "0.6023768", "0.6023294", "0.60187787", "0.6014968", "0.60120106", "0.5994621", "0.599218", "0.596078", "0.59577143", "0.59500134", "0.5937686", "0.5934715", "0.5930603", "0.5920747", "0.59178483", "0.591247", "0.59069467", "0.59037447", "0.58975995", "0.58950925", "0.5890331", "0.58876824", "0.5876823", "0.58654594", "0.5864508", "0.5855919", "0.58481854", "0.58462316", "0.5846173", "0.58441156", "0.5836935", "0.5834672", "0.58263236", "0.5823662", "0.5822939", "0.5821205", "0.58206695", "0.5818936", "0.5815562", "0.5813454", "0.5813454", "0.5813454", "0.5813454", "0.5813454", "0.57968426", "0.5794977", "0.57943803", "0.5790527", "0.5769865", "0.57618475", "0.5761577", "0.5757426" ]
0.70291024
1
DELETE /question_option_selections/1 DELETE /question_option_selections/1.json
def destroy @question_option_selection.destroy respond_to do |format| format.html { redirect_to @question_answer_question_option_selection_path(@question_answer), notice: 'Question option selection was successfully destroyed.' } format.json { head :no_content } end end
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def destroy\n @questions_option = QuestionsOption.find(params[:id])\n @questions_option.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_options_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question_option = QuestionOption.find(params[:id])\n check_forged_path\n @question_option.destroy\n\n respond_to do |format|\n format.json { head :ok }\n format.xml { head :ok }\n end\n end", "def destroy\n @question_option.destroy\n respond_to do |format|\n format.html { redirect_to question_options_url, notice: 'Question option was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey_question_option = SurveyQuestionOption.find(params[:id])\n @survey_question_option.destroy\n \n respond_to do |format|\n format.html { redirect_to survey_question_options_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @exam_option = ExamOption.find(params[:id])\n @exam_option.destroy\n\n respond_to do |format|\n format.html { redirect_to exam_options_url }\n format.json { head :no_content }\n end\n end", "def destroy\n \n load_quiz_section_and_question\n load_option\n \n @option.destroy\n \n respond_to do |format|\n format.html { redirect_to admins_quiz_section_question_path(@quiz,@section,@question.sequence_no), notice: \"Option deleted successfully.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @option.destroy\n respond_to do |format|\n format.html { redirect_to question_options_url(@option.question), notice: \"Option was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @quick_poll_option = QuickPollOption.find(params[:id])\n @quick_poll_option.destroy\n\n respond_to do |format|\n format.html { redirect_to quick_poll_options_url }\n format.json { head :no_content }\n end\n end", "def delete_option\n option_param = params.permit(:id)\n\n render json: Option.delete_option(option_param)\n end", "def destroy\n @question_option = QuestionOption.find(params[:id])\n @question_option.destroy\n\n respond_to do |format|\n format.html { redirect_to(question_options_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @item = option_model.find(params[:id])\n @item.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @multiple_choice_question = MultipleChoiceQuestion.find(params[:id])\n @multiple_choice_question.destroy\n\n respond_to do |format|\n format.html { redirect_to multiple_choice_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @option = Option.find(params[:id])\n @qid=@option.question_id\n @option.destroy\n\n respond_to do |format|\n format.html { redirect_to(options_url(:qid=>@qid)) }\n format.xml { head :ok }\n end\n end", "def destroy\n\t@option = Option.find(params[:id])\n\t@qid=@option.question_id\n\t@option.destroy\n\n\trespond_to do |format|\n\t format.html { redirect_to(options_url(:qid=>@qid)) }\n\t format.xml { head :ok }\n\tend\n end", "def destroy\n @option.destroy\n\n respond_to do |format|\n format.html { redirect_to(question_options_path(@question)) }\n format.xml { head :ok }\n end\n end", "def delete_question\n question_params = params.permit(:id, :form_id, :question_type_id)\n\n render json: Question.delete_question(question_params)\n end", "def destroy\n @v1_answer.destroy\n end", "def destroy\n @choice.destroy\n\n head :no_content\n end", "def destroy\n if @v1_question.destroy\n render json: {'message': 'Deleted question successfully'}, status: :ok\n else\n render json: get_errors, status: :unprocessable_entity\n end\n\n end", "def destroy\n @poll_options_set = PollOptionsSet.find(params[:id])\n @poll_options_set.destroy\n\n respond_to do |format|\n format.html { redirect_to poll_options_sets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @option.destroy\n respond_to do |format|\n format.html { redirect_to sentence_options_url, notice: 'option was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @auto_option = AutoOption.find(params[:id])\n @auto_option.destroy\n\n respond_to do |format|\n format.html { redirect_to auto_options_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @option = Option.find(params[:id])\n @option.destroy\n\n respond_to do |format|\n format.html { redirect_to options_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @option = Option.find(params[:id])\n @option.destroy\n\n respond_to do |format|\n format.html { redirect_to options_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey_answer_item = SurveyAnswerItem.find(params[:id])\n @survey_answer_item.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_answer_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @quick_answer = QuickAnswer.find(params[:id])\n @quick_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to quick_answers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @selected_answer.destroy\n respond_to do |format|\n format.html { redirect_to selected_answers_url, notice: 'Selected answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey_option = SurveyOption.find(params[:id])\n @survey_option.destroy\n\n respond_to do |format|\n format.html { redirect_to(survey_options_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @choice_set.destroy\n respond_to do |format|\n format.html { redirect_to choice_sets_url, notice: 'Choice set was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question_link = QuizQuestion.find_by_id(@question.questionid)\n @quiz = Quiz.find_by_id(@question_link.quizid)\n @question_link.destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to admin_quiz_path(@quiz), notice: 'Quiz multiple choice question was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @survey_question_item = SurveyQuestionItem.find(params[:id])\n @survey_question_item.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_question_items_url }\n format.json { head :no_content }\n end\n end", "def destroy\n render_json_auto @survey.delete_filter(params[:id].to_i) and return\n end", "def destroy \n @step = Step.find(params[:id])\n @step.destroy\n\n respond_to do |format|\n format.html { redirect_to selection_path(params[:selection_id]) }\n format.json { head :no_content }\n end\n end", "def destroy\n @questionable = @question.questionable\n @question.destroy\n respond_to do |format|\n format.html\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to quiz_path(@question.subsection_id) }\n format.json { head :no_content }\n end\n end", "def destroy\n answer = Answer.find(params[:answer_id])\n answer.destroy\n \n render json: {success: true}\n end", "def destroy\n @answer = Answer.find_by_key(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @store = Store.find(params[:store_id])\n @dish_choice = @store.dish_choices.find(params[:id])\n @dish_choice.destroy\n\n respond_to do |format|\n format.html { redirect_to store_dish_choices_url(@store) }\n format.json { head :no_content }\n end\n end", "def destroy\n @four_choice_question.destroy\n end", "def destroy\n @response = Response.find(params[:response_id])\n \n @request_selection = RequestSelection.find(params[:id])\n @request_selection.destroy\n\n respond_to do |format|\n format.html { redirect_to response_request_selections_path(@response) }\n format.json { head :no_content }\n end\n end", "def destroy\n @questionset = Questionset.find(params[:id])\n @questionset.destroy\n\n respond_to do |format|\n format.html { redirect_to questionsets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question_set = QuestionSet.find(params[:id])\n @question_set.destroy\n\n respond_to do |format|\n format.html { redirect_to question_sets_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @option.destroy\n respond_to do |format|\n format.html { redirect_to options_url, notice: 'Option was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @option.destroy\n respond_to do |format|\n format.html { redirect_to options_url, notice: 'Option was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @option.destroy\n respond_to do |format|\n format.html { redirect_to options_url, notice: 'Option was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @choice.destroy\n respond_to do |format|\n format.html { redirect_to choices_url, notice: 'Choice was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v1_questions_url }\n format.json { head :no_content }\n end\n end", "def delete\n id = params[:format]\n @choice = Choice.where(\"id = #{id}\").first\n if @choice.destroy\n logger.debug \"choice successfully destroyed\"\n else\n logger.debug \"Choice NOT successfully destroyed\"\n end\n redirect_to home_index_url\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to survey_url(params[:survey_id]) }\n format.json { head :no_content }\n end\n end", "def destroy\n @question_answer = Question::Answer.find(params[:id])\n @question_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to question_answers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @opt = Opt.find(params[:id])\n @opt.destroy\n\n respond_to do |format|\n format.html { redirect_to(opts_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @attempt_question.destroy\n respond_to do |format|\n format.html { redirect_to attempt_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @examquestion.destroy\n respond_to do |format|\n format.html { redirect_to examquestions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question_field = QuestionField.find(params[:id])\n @question_field.destroy\n\n respond_to do |format|\n format.html { redirect_to question_fields_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @story_choice = StoryChoice.find(params[:id])\n @story_choice.destroy\n\n respond_to do |format|\n format.html { redirect_to story_choices_url }\n format.json { head :ok }\n end\n end", "def destroy\n @question.active = !@question.active\n\n questions_json = @question.to_h.to_json\n\n url = @httpIp+'/pet.com/api/question/updateQuestion'\n uri = URI(url)\n res = Net::HTTP.post(uri, questions_json, \"Content-Type\" => \"application/json\")\n puts res.body\n flash[:notice] = \"successfully deleted\"\n redirect_to questions_path\n end", "def destroy\n @selection = Selection.find(params[:id])\n @selection.destroy\n\n respond_to do |format|\n format.html { redirect_to(selections_url) }\n format.xml { head :ok }\n end\n end", "def destroy\n @choice_item.destroy\n respond_to do |format|\n format.html { redirect_to choice_items_url, notice: 'Choice item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @selection_criterium.destroy\n respond_to do |format|\n format.html { redirect_to selection_criteria_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to admin_questions_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @question_type = QuestionType.find(params[:id])\n @question_type.destroy\n\n respond_to do |format|\n format.html { redirect_to question_types_url }\n format.json { head :no_content }\n end\n end", "def delete\n supprimer = QuestionOuverteService.instance.supprimerQuestion(params[:id])\n (supprimer) ? (render json: true, status: :ok) : (render json: false, status: :not_found)\n end", "def destroy\n #@admin_academy_question.destroy\n a = Academy::Question.find(params[:id].split('-')[0])\n a.update(:is_deleted => true)\n dest = a.id\n type = 4 #answer_question_code\n Notification.clear_notifications(type,dest)\n a.save\n\n respond_to do |format|\n format.html { redirect_to admin_academy_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @opt10075.destroy\n respond_to do |format|\n format.html { redirect_to opt10075s_url, notice: 'Opt10075 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @client_answer = ClientAnswer.find(params[:id])\n @client_answer.destroy\n\n respond_to do |format|\n format.html { redirect_to client_answers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n #@question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @my_question = MyQuestion.find(params[:id])\n @my_question.destroy\n\n respond_to do |format|\n format.html { redirect_to my_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n render_json_auto @survey.delete_logic_control_rule(params[:id].to_i) and return\n end", "def delete_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by_id(params[:pathway_id])\n suggested_pathway.destroy\n render json: suggested_pathway\n end", "def destroy\n @test_question = TestQuestion.find(params[:id])\n @test_question.destroy\n\n respond_to do |format|\n format.html { redirect_to test_questions_url }\n format.json { head :ok }\n end\n end", "def delete\n question = QuestionTest.where(test_id: params[:test_id], question_id: params[:id])\n if question.delete_all\n return render json: {message: 'Question was removed succesfully.', error: false}\n else\n return render json: {message: 'Error: Something went wrong. Question was not removed.', error: true}\n end\n end", "def destroy\n @choice_test.destroy\n respond_to do |format|\n format.html { redirect_to choice_tests_url, notice: \"Choice test was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end", "def destroy\n @answer = current_user.answers.find(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @question_attempt_response = QuestionAttemptResponse.find(params[:id])\n @question_attempt_response.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n end\n end", "def destroy\n @possible_answer.destroy\n respond_to do |format|\n format.html { redirect_to possible_answers_url, notice: 'Possible answer was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question_learned.destroy\n respond_to do |format|\n format.html { redirect_to question_question_learneds_path(@question) }\n format.json { head :no_content }\n end\n end", "def destroy\n @poll_question = PollQuestion.find(params[:id])\n @poll_question.destroy\n\n respond_to do |format|\n format.html { redirect_to poll_questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @b_question.destroy\n respond_to do |format|\n format.html { redirect_to questions_path }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :ok }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :ok }\n end\n end", "def destroy\n authorize(@question_row_column_fields_question_row_column_field_option.question.project, policy_class: QuestionRowColumnFieldsQuestionRowColumnFieldOptionPolicy)\n @question_row_column_fields_question_row_column_field_option = @question_row_column_fields_question_row_column_field_option.destroy\n\n respond_to do |format|\n format.html { redirect_to edit_question_path(@question_row_column_fields_question_row_column_field_option.question), notice: t('removed') }\n format.json { head :no_content }\n end\n end", "def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @answer.destroy\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @opt10059.destroy\n respond_to do |format|\n format.html { redirect_to opt10059s_url, notice: 'Opt10059 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question = Question.find(params[:id])\n @question.destroy\n\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n @question.destroy\n respond_to do |format|\n format.html { redirect_to questions_url }\n format.json { head :no_content }\n end\n end", "def destroy\n#status_url(Status.find_by_survey_id(protocol.access_code)\n #@p = ResponseSet.where(:user_id => current_user)\n #@protocol = user_id.find_by_survey_id(protocol.access_code)\n #@p = ResponseSet.where(:question_id => @title_questions).first.string_value\n p= ResponseSet.where(:access_code => params[:id])\n p.first.destroy\n \n\n respond_to do |format|\n format.html { redirect_to :back }\n format.json { head :no_content }\n end\n end", "def destroy\n @option_type.destroy\n respond_to do |format|\n format.html { redirect_to admin_option_types_url }\n format.json { head :no_content }\n end\n end" ]
[ "0.73644316", "0.7339735", "0.71845007", "0.71193135", "0.7078158", "0.7072167", "0.7020615", "0.69713396", "0.69449323", "0.69287807", "0.6923465", "0.68403196", "0.68374455", "0.6823327", "0.6809441", "0.6798366", "0.6747096", "0.6739421", "0.6727583", "0.6703137", "0.66992086", "0.66952515", "0.66908604", "0.66908604", "0.6684308", "0.6683719", "0.66771823", "0.6631051", "0.66139907", "0.6599143", "0.6592516", "0.65919876", "0.6591502", "0.6590524", "0.6588882", "0.6587665", "0.65856284", "0.658173", "0.65815884", "0.656117", "0.6558977", "0.65468436", "0.65370786", "0.65370786", "0.65370786", "0.6531325", "0.6525069", "0.6508672", "0.65081143", "0.6507211", "0.65047365", "0.6500401", "0.64926684", "0.64921767", "0.64862096", "0.6483939", "0.6473938", "0.6464405", "0.64550596", "0.6449983", "0.6441124", "0.6440846", "0.6440406", "0.6440354", "0.6438531", "0.64342886", "0.64236456", "0.6419058", "0.64166874", "0.6416053", "0.6410438", "0.63988024", "0.63933855", "0.63893473", "0.6388383", "0.6383087", "0.6382968", "0.63796717", "0.6377732", "0.6377732", "0.6374705", "0.63722825", "0.63722825", "0.63703114", "0.6367087", "0.63668615", "0.63668615", "0.63668615", "0.63668615", "0.63668615", "0.63668615", "0.63665915", "0.63636756", "0.63636756", "0.63636756", "0.63636756", "0.63636756", "0.63636756", "0.6359785", "0.63592315" ]
0.7287374
2
Use callbacks to share common setup or constraints between actions.
def set_question_option_selection @question_option_selection = QuestionAnswer.question_option_selections.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